easyproctor-hml 2.5.23 → 2.5.24

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/esm/index.js CHANGED
@@ -12289,7 +12289,7 @@ function recorder(stream, buffer, videoOptions, onBufferSizeError = false, onBuf
12289
12289
  audioBitsPerSecond: 64 * 1e3
12290
12290
  };
12291
12291
  }
12292
- console.log("recorderOptions bitsPerSecond", recorderOptions.bitsPerSecond);
12292
+ console.log("recorderOptions bitsPerSecond", recorderOptions.videoBitsPerSecond);
12293
12293
  const mediaRecorder = new MediaRecorder(stream, recorderOptions);
12294
12294
  mediaRecorder.ondataavailable = (e3) => {
12295
12295
  bufferSize = bufferSize + e3.data.size;
@@ -12312,7 +12312,7 @@ function recorder(stream, buffer, videoOptions, onBufferSizeError = false, onBuf
12312
12312
  proctoringId,
12313
12313
  `onBufferSizeError: Recorder size equal 0 Mb`
12314
12314
  );
12315
- console.log("onbuffer size error");
12315
+ console.log("onbuffer size error" + e3.data.size);
12316
12316
  onBufferSizeErrorCallback && onBufferSizeErrorCallback();
12317
12317
  }
12318
12318
  lastEvent = e3;
@@ -12332,7 +12332,14 @@ function recorder(stream, buffer, videoOptions, onBufferSizeError = false, onBuf
12332
12332
  timeSlice = videoOptions == null ? void 0 : videoOptions.timeSlice;
12333
12333
  }
12334
12334
  console.log("startRecording", timeSlice);
12335
- mediaRecorder.start(timeSlice);
12335
+ try {
12336
+ mediaRecorder.start(timeSlice);
12337
+ mediaRecorder.onstart = () => {
12338
+ console.log("Grava\xE7\xE3o iniciada com sucesso!");
12339
+ };
12340
+ } catch (e3) {
12341
+ console.error("Falha ao iniciar:", e3);
12342
+ }
12336
12343
  bufferSize = 0;
12337
12344
  stopped = false;
12338
12345
  });
@@ -12815,6 +12822,7 @@ var CameraRecorder = class {
12815
12822
  const retryEnabled = ((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.retryEnabled) || false;
12816
12823
  const maxRetries = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.maxRetries) || 3;
12817
12824
  if (retryEnabled && this.currentRetries < maxRetries) {
12825
+ console.log("buffer error Camera Recorder retry");
12818
12826
  await this.recordingStop();
12819
12827
  await this.startRecording({
12820
12828
  retry: true
@@ -12887,7 +12895,9 @@ Setting: ${JSON.stringify(settings, null, 2)}`
12887
12895
  }
12888
12896
  async startRecording(options) {
12889
12897
  var _a2, _b, _c2, _d, _e3, _f, _g, _h;
12898
+ console.log("startRecording Camera Recorder");
12890
12899
  if ((((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace)) && !(options == null ? void 0 : options.retry)) {
12900
+ console.log("startRecording Camera Recorder initializeDetectors");
12891
12901
  await this.initializeDetectors();
12892
12902
  }
12893
12903
  const { cameraId, microphoneId, onBufferSizeErrorCallback } = this.options;
@@ -12905,6 +12915,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
12905
12915
  constraints
12906
12916
  );
12907
12917
  } catch (error) {
12918
+ console.log("startRecording Camera Recorder error", error);
12908
12919
  if (error.toString() == "NotReadableError: Could not start video source")
12909
12920
  throw "N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa";
12910
12921
  throw error;
@@ -12935,6 +12946,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
12935
12946
  this.recordingResume = resumeRecording;
12936
12947
  this.recorderOptions = recorderOptions;
12937
12948
  this.getBufferSize = getBufferSize;
12949
+ console.log("startRecording Camera Recorder recordingStart");
12938
12950
  this.recordingStart();
12939
12951
  const isPortrait = (_d = screen.orientation) == null ? void 0 : _d.type.includes("portrait");
12940
12952
  if (isPortrait && isMobileDevice()) {
@@ -12969,6 +12981,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
12969
12981
  this.captureFrame();
12970
12982
  }
12971
12983
  this.packageCount = 0;
12984
+ console.log("startRecording Camera Recorder finished");
12972
12985
  }
12973
12986
  async stopRecording() {
12974
12987
  this.isCanvasLoopActive = false;
@@ -14287,6 +14300,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14287
14300
  return this.deviceCheckResult;
14288
14301
  }
14289
14302
  async runCheckDevicesFlow(options, _videoOptions, onModalConfirm, onModalCancel, onUpdate) {
14303
+ var _a2;
14290
14304
  if (_DeviceCheckerService.isModalOpen) {
14291
14305
  return Promise.reject("Modal j\xE1 est\xE1 aberto");
14292
14306
  }
@@ -14304,7 +14318,9 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14304
14318
  options,
14305
14319
  _videoOptions
14306
14320
  );
14307
- this.checkSpyScan();
14321
+ if ((_a2 = this.options) == null ? void 0 : _a2.useSpyScan) {
14322
+ await this.checkSpyScan();
14323
+ }
14308
14324
  const returnData = { cameraStream: this.cameraRecorder.cameraStream };
14309
14325
  this.onUpdateCb = (e3) => onUpdate(e3);
14310
14326
  const resultPromise = new Promise(
@@ -14359,6 +14375,11 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14359
14375
  if (_DeviceCheckerService.isModalOpen) {
14360
14376
  return Promise.reject();
14361
14377
  }
14378
+ console.log("checkDevices started");
14379
+ this.allowedMicrophone = false;
14380
+ this.allowedResolution = false;
14381
+ this.allowedAmbient = false;
14382
+ this.allowedPositionFace = false;
14362
14383
  _DeviceCheckerService.isModalOpen = true;
14363
14384
  this.DeviceCheckerUI = new DeviceCheckerUI(options, _videoOptions);
14364
14385
  try {
@@ -14396,8 +14417,8 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14396
14417
  resolve(response);
14397
14418
  });
14398
14419
  } catch (error) {
14420
+ this.DeviceCheckerUI && this.DeviceCheckerUI.closeModal();
14399
14421
  this.closeCheckDevices();
14400
- this.DeviceCheckerUI.closeModal();
14401
14422
  return Promise.reject(error);
14402
14423
  }
14403
14424
  }
@@ -14468,7 +14489,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14468
14489
  }
14469
14490
  async changeSelectedDevice({ cameraId, microphoneId }) {
14470
14491
  var _a2;
14471
- this.cameraRecorder.stopRecording && await this.cameraRecorder.stopRecording();
14492
+ await this.cameraRecorder.stopStream();
14472
14493
  (_a2 = this.volumeMeter) == null ? void 0 : _a2.stop();
14473
14494
  this.faceDetection.stopDetection();
14474
14495
  this.cameraRecorder = new CameraRecorder(
@@ -14484,7 +14505,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14484
14505
  height: this.videoOptions.height
14485
14506
  }
14486
14507
  );
14487
- await this.cameraRecorder.startRecording();
14508
+ await this.cameraRecorder.startStream();
14488
14509
  this.videoDeviceInterface(this.cameraRecorder.cameraStream);
14489
14510
  this.audioDeviceInterface(this.cameraRecorder.cameraStream);
14490
14511
  return {
@@ -14492,6 +14513,10 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14492
14513
  };
14493
14514
  }
14494
14515
  async startCheckDevices(options = getDefaultProctoringOptions, _videoOptions) {
14516
+ this.allowedMicrophone = false;
14517
+ this.allowedResolution = false;
14518
+ this.allowedAmbient = false;
14519
+ this.allowedPositionFace = false;
14495
14520
  this.DeviceCheckerUI && this.DeviceCheckerUI.setSelectOption(
14496
14521
  options,
14497
14522
  (e3) => this.changeSelectedDevice(e3)
@@ -14511,7 +14536,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14511
14536
  height: this.videoOptions.height
14512
14537
  }
14513
14538
  );
14514
- await this.cameraRecorder.startRecording();
14539
+ await this.cameraRecorder.startStream();
14515
14540
  this.videoDeviceInterface(this.cameraRecorder.cameraStream);
14516
14541
  this.audioDeviceInterface(this.cameraRecorder.cameraStream);
14517
14542
  if (this.DeviceCheckerUI) {
@@ -14528,7 +14553,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14528
14553
  this.faceDetection.stopDetection();
14529
14554
  (_a2 = this.volumeMeter) == null ? void 0 : _a2.stop();
14530
14555
  this.volumeMedia = Math.ceil(this.volumeSum / this.volumeCounter);
14531
- this.cameraRecorder.stopRecording && await this.cameraRecorder.stopRecording();
14556
+ await this.cameraRecorder.stopStream();
14532
14557
  this.DeviceCheckerUI = void 0;
14533
14558
  this.onUpdateCb = void 0;
14534
14559
  }
package/index.js CHANGED
@@ -30386,7 +30386,7 @@ function recorder(stream4, buffer, videoOptions, onBufferSizeError = false, onBu
30386
30386
  audioBitsPerSecond: 64 * 1e3
30387
30387
  };
30388
30388
  }
30389
- console.log("recorderOptions bitsPerSecond", recorderOptions.bitsPerSecond);
30389
+ console.log("recorderOptions bitsPerSecond", recorderOptions.videoBitsPerSecond);
30390
30390
  const mediaRecorder = new MediaRecorder(stream4, recorderOptions);
30391
30391
  mediaRecorder.ondataavailable = (e3) => {
30392
30392
  bufferSize = bufferSize + e3.data.size;
@@ -30409,7 +30409,7 @@ function recorder(stream4, buffer, videoOptions, onBufferSizeError = false, onBu
30409
30409
  proctoringId,
30410
30410
  `onBufferSizeError: Recorder size equal 0 Mb`
30411
30411
  );
30412
- console.log("onbuffer size error");
30412
+ console.log("onbuffer size error" + e3.data.size);
30413
30413
  onBufferSizeErrorCallback && onBufferSizeErrorCallback();
30414
30414
  }
30415
30415
  lastEvent = e3;
@@ -30429,7 +30429,14 @@ function recorder(stream4, buffer, videoOptions, onBufferSizeError = false, onBu
30429
30429
  timeSlice = videoOptions == null ? void 0 : videoOptions.timeSlice;
30430
30430
  }
30431
30431
  console.log("startRecording", timeSlice);
30432
- mediaRecorder.start(timeSlice);
30432
+ try {
30433
+ mediaRecorder.start(timeSlice);
30434
+ mediaRecorder.onstart = () => {
30435
+ console.log("Grava\xE7\xE3o iniciada com sucesso!");
30436
+ };
30437
+ } catch (e3) {
30438
+ console.error("Falha ao iniciar:", e3);
30439
+ }
30433
30440
  bufferSize = 0;
30434
30441
  stopped = false;
30435
30442
  });
@@ -30912,6 +30919,7 @@ var CameraRecorder = class {
30912
30919
  const retryEnabled = ((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.retryEnabled) || false;
30913
30920
  const maxRetries = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.maxRetries) || 3;
30914
30921
  if (retryEnabled && this.currentRetries < maxRetries) {
30922
+ console.log("buffer error Camera Recorder retry");
30915
30923
  await this.recordingStop();
30916
30924
  await this.startRecording({
30917
30925
  retry: true
@@ -30984,7 +30992,9 @@ Setting: ${JSON.stringify(settings, null, 2)}`
30984
30992
  }
30985
30993
  async startRecording(options) {
30986
30994
  var _a2, _b, _c2, _d, _e3, _f, _g, _h;
30995
+ console.log("startRecording Camera Recorder");
30987
30996
  if ((((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace)) && !(options == null ? void 0 : options.retry)) {
30997
+ console.log("startRecording Camera Recorder initializeDetectors");
30988
30998
  await this.initializeDetectors();
30989
30999
  }
30990
31000
  const { cameraId, microphoneId, onBufferSizeErrorCallback } = this.options;
@@ -31002,6 +31012,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31002
31012
  constraints
31003
31013
  );
31004
31014
  } catch (error) {
31015
+ console.log("startRecording Camera Recorder error", error);
31005
31016
  if (error.toString() == "NotReadableError: Could not start video source")
31006
31017
  throw "N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa";
31007
31018
  throw error;
@@ -31032,6 +31043,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31032
31043
  this.recordingResume = resumeRecording;
31033
31044
  this.recorderOptions = recorderOptions;
31034
31045
  this.getBufferSize = getBufferSize;
31046
+ console.log("startRecording Camera Recorder recordingStart");
31035
31047
  this.recordingStart();
31036
31048
  const isPortrait = (_d = screen.orientation) == null ? void 0 : _d.type.includes("portrait");
31037
31049
  if (isPortrait && isMobileDevice()) {
@@ -31066,6 +31078,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31066
31078
  this.captureFrame();
31067
31079
  }
31068
31080
  this.packageCount = 0;
31081
+ console.log("startRecording Camera Recorder finished");
31069
31082
  }
31070
31083
  async stopRecording() {
31071
31084
  this.isCanvasLoopActive = false;
@@ -32384,6 +32397,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32384
32397
  return this.deviceCheckResult;
32385
32398
  }
32386
32399
  async runCheckDevicesFlow(options, _videoOptions, onModalConfirm, onModalCancel, onUpdate) {
32400
+ var _a2;
32387
32401
  if (_DeviceCheckerService.isModalOpen) {
32388
32402
  return Promise.reject("Modal j\xE1 est\xE1 aberto");
32389
32403
  }
@@ -32401,7 +32415,9 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32401
32415
  options,
32402
32416
  _videoOptions
32403
32417
  );
32404
- this.checkSpyScan();
32418
+ if ((_a2 = this.options) == null ? void 0 : _a2.useSpyScan) {
32419
+ await this.checkSpyScan();
32420
+ }
32405
32421
  const returnData = { cameraStream: this.cameraRecorder.cameraStream };
32406
32422
  this.onUpdateCb = (e3) => onUpdate(e3);
32407
32423
  const resultPromise = new Promise(
@@ -32456,6 +32472,11 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32456
32472
  if (_DeviceCheckerService.isModalOpen) {
32457
32473
  return Promise.reject();
32458
32474
  }
32475
+ console.log("checkDevices started");
32476
+ this.allowedMicrophone = false;
32477
+ this.allowedResolution = false;
32478
+ this.allowedAmbient = false;
32479
+ this.allowedPositionFace = false;
32459
32480
  _DeviceCheckerService.isModalOpen = true;
32460
32481
  this.DeviceCheckerUI = new DeviceCheckerUI(options, _videoOptions);
32461
32482
  try {
@@ -32493,8 +32514,8 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32493
32514
  resolve(response);
32494
32515
  });
32495
32516
  } catch (error) {
32517
+ this.DeviceCheckerUI && this.DeviceCheckerUI.closeModal();
32496
32518
  this.closeCheckDevices();
32497
- this.DeviceCheckerUI.closeModal();
32498
32519
  return Promise.reject(error);
32499
32520
  }
32500
32521
  }
@@ -32565,7 +32586,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32565
32586
  }
32566
32587
  async changeSelectedDevice({ cameraId, microphoneId }) {
32567
32588
  var _a2;
32568
- this.cameraRecorder.stopRecording && await this.cameraRecorder.stopRecording();
32589
+ await this.cameraRecorder.stopStream();
32569
32590
  (_a2 = this.volumeMeter) == null ? void 0 : _a2.stop();
32570
32591
  this.faceDetection.stopDetection();
32571
32592
  this.cameraRecorder = new CameraRecorder(
@@ -32581,7 +32602,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32581
32602
  height: this.videoOptions.height
32582
32603
  }
32583
32604
  );
32584
- await this.cameraRecorder.startRecording();
32605
+ await this.cameraRecorder.startStream();
32585
32606
  this.videoDeviceInterface(this.cameraRecorder.cameraStream);
32586
32607
  this.audioDeviceInterface(this.cameraRecorder.cameraStream);
32587
32608
  return {
@@ -32589,6 +32610,10 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32589
32610
  };
32590
32611
  }
32591
32612
  async startCheckDevices(options = getDefaultProctoringOptions, _videoOptions) {
32613
+ this.allowedMicrophone = false;
32614
+ this.allowedResolution = false;
32615
+ this.allowedAmbient = false;
32616
+ this.allowedPositionFace = false;
32592
32617
  this.DeviceCheckerUI && this.DeviceCheckerUI.setSelectOption(
32593
32618
  options,
32594
32619
  (e3) => this.changeSelectedDevice(e3)
@@ -32608,7 +32633,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32608
32633
  height: this.videoOptions.height
32609
32634
  }
32610
32635
  );
32611
- await this.cameraRecorder.startRecording();
32636
+ await this.cameraRecorder.startStream();
32612
32637
  this.videoDeviceInterface(this.cameraRecorder.cameraStream);
32613
32638
  this.audioDeviceInterface(this.cameraRecorder.cameraStream);
32614
32639
  if (this.DeviceCheckerUI) {
@@ -32625,7 +32650,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
32625
32650
  this.faceDetection.stopDetection();
32626
32651
  (_a2 = this.volumeMeter) == null ? void 0 : _a2.stop();
32627
32652
  this.volumeMedia = Math.ceil(this.volumeSum / this.volumeCounter);
32628
- this.cameraRecorder.stopRecording && await this.cameraRecorder.stopRecording();
32653
+ await this.cameraRecorder.stopStream();
32629
32654
  this.DeviceCheckerUI = void 0;
32630
32655
  this.onUpdateCb = void 0;
32631
32656
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor-hml",
3
- "version": "2.5.23",
3
+ "version": "2.5.24",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -68,7 +68,7 @@ Minimum version required to store current data is: `+o+`.
68
68
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[Ag]=this[Ag]={accessors:{}}).accessors,i=this.prototype;function o(s){let a=Lo(s);n[a]||(Qv(i,s),n[a]=!0)}return T.isArray(t)?t.forEach(o):o(t),this}};Ni.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);T.reduceDescriptors(Ni.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});T.freezeMethods(Ni);var at=Ni;function Fo(e,t){let r=this||Ui,n=t||r,i=at.from(n.headers),o=n.data;return T.forEach(e,function(a){o=a.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Mo(e){return!!(e&&e.__CANCEL__)}function Tg(e,t,r){le.call(this,e??"canceled",le.ERR_CANCELED,t,r),this.name="CanceledError"}T.inherits(Tg,le,{__CANCEL__:!0});var Br=Tg;function Uo(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new le("Request failed with status code "+r.status,[le.ERR_BAD_REQUEST,le.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function ad(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function e_(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,o=0,s;return t=t!==void 0?t:1e3,function(c){let l=Date.now(),h=n[o];s||(s=l),r[i]=c,n[i]=l;let d=o,m=0;for(;d!==i;)m+=r[d++],d=d%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),l-s<t)return;let p=h&&l-h;return p?Math.round(m*1e3/p):void 0}}var Ig=e_;function t_(e,t){let r=0,n=1e3/t,i,o,s=(l,h=Date.now())=>{r=h,i=null,o&&(clearTimeout(o),o=null),e.apply(null,l)};return[(...l)=>{let h=Date.now(),d=h-r;d>=n?s(l,h):(i=l,o||(o=setTimeout(()=>{o=null,s(i)},n-d)))},()=>i&&s(i)]}var Rg=t_;var zi=(e,t,r=3)=>{let n=0,i=Ig(50,250);return Rg(o=>{let s=o.loaded,a=o.lengthComputable?o.total:void 0,c=s-n,l=i(c),h=s<=a;n=s;let d={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&h?(a-s)/l:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},cd=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},ld=e=>(...t)=>T.asap(()=>e(...t));var Pg=je.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,je.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(je.origin),je.navigator&&/(msie|trident)/i.test(je.navigator.userAgent)):()=>!0;var Dg=je.hasStandardBrowserEnv?{write(e,t,r,n,i,o){let s=[e+"="+encodeURIComponent(t)];T.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),T.isString(n)&&s.push("path="+n),T.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function hd(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function dd(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function No(e,t,r){let n=!hd(t);return e&&(n||r==!1)?dd(e,t):t}var Og=e=>e instanceof at?{...e}:e;function br(e,t){t=t||{};let r={};function n(l,h,d,m){return T.isPlainObject(l)&&T.isPlainObject(h)?T.merge.call({caseless:m},l,h):T.isPlainObject(h)?T.merge({},h):T.isArray(h)?h.slice():h}function i(l,h,d,m){if(T.isUndefined(h)){if(!T.isUndefined(l))return n(void 0,l,d,m)}else return n(l,h,d,m)}function o(l,h){if(!T.isUndefined(h))return n(void 0,h)}function s(l,h){if(T.isUndefined(h)){if(!T.isUndefined(l))return n(void 0,l)}else return n(void 0,h)}function a(l,h,d){if(d in t)return n(l,h);if(d in e)return n(void 0,l)}let c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(l,h,d)=>i(Og(l),Og(h),d,!0)};return T.forEach(Object.keys(Object.assign({},e,t)),function(h){let d=c[h]||i,m=d(e[h],t[h],h);T.isUndefined(m)&&d!==a||(r[h]=m)}),r}var Ca=e=>{let t=br({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=at.from(s),t.url=Bo(No(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(T.isFormData(r)){if(je.hasStandardBrowserEnv||je.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){let[l,...h]=c?c.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([l||"multipart/form-data",...h].join("; "))}}if(je.hasStandardBrowserEnv&&(n&&T.isFunction(n)&&(n=n(t)),n||n!==!1&&Pg(t.url))){let l=i&&o&&Dg.read(o);l&&s.set(i,l)}return t};var r_=typeof XMLHttpRequest<"u",Bg=r_&&function(e){return new Promise(function(r,n){let i=Ca(e),o=i.data,s=at.from(i.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:l}=i,h,d,m,p,g;function f(){p&&p(),g&&g(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let b=new XMLHttpRequest;b.open(i.method.toUpperCase(),i.url,!0),b.timeout=i.timeout;function _(){if(!b)return;let k=at.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),x={data:!a||a==="text"||a==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:k,config:e,request:b};Uo(function(P){r(P),f()},function(P){n(P),f()},x),b=null}"onloadend"in b?b.onloadend=_:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(_)},b.onabort=function(){b&&(n(new le("Request aborted",le.ECONNABORTED,e,b)),b=null)},b.onerror=function(){n(new le("Network Error",le.ERR_NETWORK,e,b)),b=null},b.ontimeout=function(){let I=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",x=i.transitional||Sa;i.timeoutErrorMessage&&(I=i.timeoutErrorMessage),n(new le(I,x.clarifyTimeoutError?le.ETIMEDOUT:le.ECONNABORTED,e,b)),b=null},o===void 0&&s.setContentType(null),"setRequestHeader"in b&&T.forEach(s.toJSON(),function(I,x){b.setRequestHeader(x,I)}),T.isUndefined(i.withCredentials)||(b.withCredentials=!!i.withCredentials),a&&a!=="json"&&(b.responseType=i.responseType),l&&([m,g]=zi(l,!0),b.addEventListener("progress",m)),c&&b.upload&&([d,p]=zi(c),b.upload.addEventListener("progress",d),b.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(h=k=>{b&&(n(!k||k.type?new Br(null,e,b):k),b.abort(),b=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));let S=ad(i.url);if(S&&je.protocols.indexOf(S)===-1){n(new le("Unsupported protocol "+S+":",le.ERR_BAD_REQUEST,e));return}b.send(o||null)})};var n_=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,o=function(l){if(!i){i=!0,a();let h=l instanceof Error?l:this.reason;n.abort(h instanceof le?h:new Br(h instanceof Error?h.message:h))}},s=t&&setTimeout(()=>{s=null,o(new le(`timeout ${t} of ms exceeded`,le.ETIMEDOUT))},t),a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),e=null)};e.forEach(l=>l.addEventListener("abort",o));let{signal:c}=n;return c.unsubscribe=()=>T.asap(a),c}},Lg=n_;var i_=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},o_=async function*(e,t){for await(let r of s_(e))yield*i_(r,t)},s_=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},ud=(e,t,r,n)=>{let i=o_(e,t),o=0,s,a=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:l,value:h}=await i.next();if(l){a(),c.close();return}let d=h.byteLength;if(r){let m=o+=d;r(m)}c.enqueue(new Uint8Array(h))}catch(l){throw a(l),l}},cancel(c){return a(c),i.return()}},{highWaterMark:2})};var Aa=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Mg=Aa&&typeof ReadableStream=="function",a_=Aa&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Ug=(e,...t)=>{try{return!!e(...t)}catch{return!1}},c_=Mg&&Ug(()=>{let e=!1,t=new Request(je.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Fg=64*1024,fd=Mg&&Ug(()=>T.isReadableStream(new Response("").body)),xa={stream:fd&&(e=>e.body)};Aa&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!xa[t]&&(xa[t]=T.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new le(`Response type '${t}' is not supported`,le.ERR_NOT_SUPPORT,n)})})})(new Response);var l_=async e=>{if(e==null)return 0;if(T.isBlob(e))return e.size;if(T.isSpecCompliantForm(e))return(await new Request(je.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(T.isArrayBufferView(e)||T.isArrayBuffer(e))return e.byteLength;if(T.isURLSearchParams(e)&&(e=e+""),T.isString(e))return(await a_(e)).byteLength},h_=async(e,t)=>{let r=T.toFiniteNumber(e.getContentLength());return r??l_(t)},Ng=Aa&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:h,withCredentials:d="same-origin",fetchOptions:m}=Ca(e);l=l?(l+"").toLowerCase():"text";let p=Lg([i,o&&o.toAbortSignal()],s),g,f=p&&p.unsubscribe&&(()=>{p.unsubscribe()}),b;try{if(c&&c_&&r!=="get"&&r!=="head"&&(b=await h_(h,n))!==0){let x=new Request(t,{method:"POST",body:n,duplex:"half"}),O;if(T.isFormData(n)&&(O=x.headers.get("content-type"))&&h.setContentType(O),x.body){let[P,z]=cd(b,zi(ld(c)));n=ud(x.body,Fg,P,z)}}T.isString(d)||(d=d?"include":"omit");let _="credentials"in Request.prototype;g=new Request(t,{...m,signal:p,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:_?d:void 0});let S=await fetch(g),k=fd&&(l==="stream"||l==="response");if(fd&&(a||k&&f)){let x={};["status","statusText","headers"].forEach(Z=>{x[Z]=S[Z]});let O=T.toFiniteNumber(S.headers.get("content-length")),[P,z]=a&&cd(O,zi(ld(a),!0))||[];S=new Response(ud(S.body,Fg,P,()=>{z&&z(),f&&f()}),x)}l=l||"text";let I=await xa[T.findKey(xa,l)||"text"](S,e);return!k&&f&&f(),await new Promise((x,O)=>{Uo(x,O,{data:I,headers:at.from(S.headers),status:S.status,statusText:S.statusText,config:e,request:g})})}catch(_){throw f&&f(),_&&_.name==="TypeError"&&/fetch/i.test(_.message)?Object.assign(new le("Network Error",le.ERR_NETWORK,e,g),{cause:_.cause||_}):le.from(_,_&&_.code,e,g)}});var pd={http:_a,xhr:Bg,fetch:Ng};T.forEach(pd,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var zg=e=>`- ${e}`,d_=e=>T.isFunction(e)||e===null||e===!1,Ta={getAdapter:e=>{e=T.isArray(e)?e:[e];let{length:t}=e,r,n,i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!d_(r)&&(n=pd[(s=String(r)).toLowerCase()],n===void 0))throw new le(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){let o=Object.entries(i).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build")),s=t?o.length>1?`since :
69
69
  `+o.map(zg).join(`
70
70
  `):" "+zg(o[0]):"as no adapter specified";throw new le("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:pd};function md(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Br(null,e)}function Ia(e){return md(e),e.headers=at.from(e.headers),e.data=Fo.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ta.getAdapter(e.adapter||Ui.adapter)(e).then(function(n){return md(e),n.data=Fo.call(e,e.transformResponse,n),n.headers=at.from(n.headers),n},function(n){return Mo(n)||(md(e),n&&n.response&&(n.response.data=Fo.call(e,e.transformResponse,n.response),n.response.headers=at.from(n.response.headers))),Promise.reject(n)})}var Ra="1.8.4";var Pa={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Pa[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var jg={};Pa.transitional=function(t,r,n){function i(o,s){return"[Axios v"+Ra+"] Transitional option '"+o+"'"+s+(n?". "+n:"")}return(o,s,a)=>{if(t===!1)throw new le(i(s," has been removed"+(r?" in "+r:"")),le.ERR_DEPRECATED);return r&&!jg[s]&&(jg[s]=!0,console.warn(i(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(o,s,a):!0}};Pa.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function u_(e,t,r){if(typeof e!="object")throw new le("options must be an object",le.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),i=n.length;for(;i-- >0;){let o=n[i],s=t[o];if(s){let a=e[o],c=a===void 0||s(a,o,e);if(c!==!0)throw new le("option "+o+" must be "+c,le.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new le("Unknown option "+o,le.ERR_BAD_OPTION)}}var zo={assertOptions:u_,validators:Pa};var Lr=zo.validators,ji=class{constructor(t){this.defaults=t,this.interceptors={request:new ed,response:new ed}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;let o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
71
- `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=br(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&zo.assertOptions(n,{silentJSONParsing:Lr.transitional(Lr.boolean),forcedJSONParsing:Lr.transitional(Lr.boolean),clarifyTimeoutError:Lr.transitional(Lr.boolean)},!1),i!=null&&(T.isFunction(i)?r.paramsSerializer={serialize:i}:zo.assertOptions(i,{encode:Lr.function,serialize:Lr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),zo.assertOptions(r,{baseUrl:Lr.spelling("baseURL"),withXsrfToken:Lr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&T.merge(o.common,o[r.method]);o&&T.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),r.headers=at.concat(s,o);let a=[],c=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(c=c&&f.synchronous,a.unshift(f.fulfilled,f.rejected))});let l=[];this.interceptors.response.forEach(function(f){l.push(f.fulfilled,f.rejected)});let h,d=0,m;if(!c){let g=[Ia.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,l),m=g.length,h=Promise.resolve(r);d<m;)h=h.then(g[d++],g[d++]);return h}m=a.length;let p=r;for(d=0;d<m;){let g=a[d++],f=a[d++];try{p=g(p)}catch(b){f.call(this,b);break}}try{h=Ia.call(this,p)}catch(g){return Promise.reject(g)}for(d=0,m=l.length;d<m;)h=h.then(l[d++],l[d++]);return h}getUri(t){t=br(this.defaults,t);let r=No(t.baseURL,t.url,t.allowAbsoluteUrls);return Bo(r,t.params,t.paramsSerializer)}};T.forEach(["delete","get","head","options"],function(t){ji.prototype[t]=function(r,n){return this.request(br(n||{},{method:t,url:r,data:(n||{}).data}))}});T.forEach(["post","put","patch"],function(t){function r(n){return function(o,s,a){return this.request(br(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}ji.prototype[t]=r(),ji.prototype[t+"Form"]=r(!0)});var jo=ji;var gd=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(o,s,a){n.reason||(n.reason=new Br(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(i){t=i}),cancel:t}}},Vg=gd;function yd(e){return function(r){return e.apply(null,r)}}function bd(e){return T.isObject(e)&&e.isAxiosError===!0}var vd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(vd).forEach(([e,t])=>{vd[t]=e});var Hg=vd;function Wg(e){let t=new jo(e),r=Po(jo.prototype.request,t);return T.extend(r,jo.prototype,t,{allOwnKeys:!0}),T.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return Wg(br(e,i))},r}var rt=Wg(Ui);rt.Axios=jo;rt.CanceledError=Br;rt.CancelToken=Vg;rt.isCancel=Mo;rt.VERSION=Ra;rt.toFormData=mn;rt.AxiosError=le;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=yd;rt.isAxiosError=bd;rt.mergeConfig=br;rt.AxiosHeaders=at;rt.formToJSON=e=>ka(T.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=Ta.getAdapter;rt.HttpStatusCode=Hg;rt.default=rt;var vr=rt;var{Axios:kC,AxiosError:EC,CanceledError:CC,isCancel:xC,CancelToken:AC,VERSION:TC,all:IC,Cancel:RC,isAxiosError:PC,spread:DC,toFormData:OC,AxiosHeaders:BC,HttpStatusCode:LC,formToJSON:FC,getAdapter:MC,mergeConfig:UC}=vr;var f_="https://proctoring-api-dev.easyproctor.tech/api",p_="https://proctoring-api-hml.easyproctor.tech/api",$g="https://proctoring-api.easyproctor.tech/api",nr=class{constructor(t){this.options=t;this.baseUrl=this.selectBaseUrl(t.type),this.token=t.token}selectBaseUrl(t){return t==="dev"?f_:t==="homol"?p_:$g}getSocketUrl(){return this.baseUrl.replace("/api","/hub/sockethub")}async loginAuth(t,r){return await this.makeRequest({path:"/Auth",method:"POST",body:{emailOrCpf:t,key:r}})}async externalCameraRegister(t){return await this.makeRequest({path:"/ExternalCamera/register",method:"POST",body:t,jwt:this.token})}async externalCameraCheckTransmission(t){return await this.makeRequest({path:`/ExternalCamera/send-action/${t}`,method:"POST",body:{command:"Check_Transmission"},jwt:this.token})}async externalCameraStartTransmission(t,r){return await this.makeRequest({path:`/ExternalCamera/start-transmission/${t}`,method:"POST",body:{proctoringId:r},jwt:this.token})}async externalCameraStartSession(){return await this.makeRequest({path:"/ExternalCamera/start-session",method:"POST",body:{},jwt:this.token})}async goToExternalCameraPositionStep(t){return await this.makeRequest({path:`/ExternalCamera/go-to-position-step/${t}`,method:"POST",body:{},jwt:this.token})}async externalCameraFinish(t){return await this.makeRequest({path:`/ExternalCamera/finish/${t}`,method:"POST",body:{},jwt:this.token})}async confirmStart(t,r,n,i){return await this.makeRequest({path:`/proctoring/start/${t.examId}`,method:"POST",body:{clientId:t.clientId,proctoringType:r.proctoringType,latitude:n,longitude:i,captureScreen:r.captureScreen},jwt:t.token})}async getParamsConfig(t){return(await this.makeRequestAxios({path:"/Client/params",method:"GET",jwt:t.token}).catch(n=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async getSignedUrlImage(t,r){return(await this.makeRequestAxios({path:"/upload/signed-url-batch",method:"POST",jwt:t,body:r})).data}async getSignedUrl(t,r,n){return(await this.makeRequestAxios({path:"/upload/signed-url",method:"POST",jwt:t,body:{objectName:`${n}/${r.name}`,contentType:r.type}})).data}async saveAlerts(t,r){await this.makeRequest({path:"/proctoring/save-alerts",method:"POST",jwt:t.token,body:{proctoringId:r.id,alerts:r.alerts}})}async finishAndSendUrls(t){return await this.makeRequest({path:`/proctoring/finish/${t.examId}`,method:"POST",body:{endDate:new Date().toISOString(),videoCameraUrl:"",audioCameraUrl:"",videoScreenUrl:""},jwt:t.token})}async log(t,r){let n;return r?.success!==null&&r?.success!==void 0?n=r.success?"4":"1":n="4",await this.makeRequest({path:"/Log",method:"POST",body:{entryType:n,eventName:t,message:r},jwt:this.token})}async signTerm(){return await this.makeRequest({path:"/User/sign-terms",method:"PATCH",body:{},jwt:this.token})}async signTermUrl(){return(await this.makeRequestAxios({path:"/User/sign-terms-url",method:"GET",jwt:this.token})).data}async startChallenge(t){return(await this.makeRequestAxios({path:"/Challenge/start",method:"POST",jwt:this.token,body:t})).data}async stopChallenge(t,r){return(await this.makeRequestAxios({path:`/Challenge/stop/${t}`,method:"POST",jwt:this.token,body:r})).data}async startRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/start-warning",method:"POST",jwt:this.token,body:t})).data}async stopRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/stop-warning",method:"POST",jwt:this.token,body:t})).data}async verifyFace(t,r,n){return(await this.makeRequestAxios({path:"/Realtime/verify-face",method:"POST",jwt:this.token,body:{proctoringId:t,base64:r,retry:n}})).data}async getServerHour(t){return await this.makeRequest({path:"/Proctoring/server-hour",method:"GET",jwt:t})}async makeRequest(t){let{path:r,method:n,body:i,jwt:o}=t,s=await fetch(this.baseUrl+r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}async makeRequestPUT(t){let{url:r,method:n,body:i,jwt:o}=t,s=await fetch(r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Accept:"*/*","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","aeg-event-type":"Notification","Content-Type":"application/json","Cache-Control":"no-cache","x-ms-blob-type":"BlockBlob"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}};var Da=class{constructor(){this.baseUrl="https://localhost:5080"}async isAlive(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-alive",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async isPluggedIn(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-plugged-in",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async ConnectAndScan(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/connect-and-scan",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=[];return t&&i.push(`deviceType=${t}`),r&&i.push(`rssiThreshold=${r}`),n&&i.push(`packageRateThreshold=${n}`),(await this.makeRequestAxios({path:`/api/usb-device-manager/devices?${i.join("&")}`,method:"GET",jwt:this.token}).catch(s=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}};var Hn=class{constructor(){this.sessionDuration=0;this.state="Created",this.startedAt=new Date,this.alerts=[],this.recordings=[]}get hasSomethingToUpload(){for(let t of this.recordings)if(!t.upload)return!0;return!1}start(){this.state="Recording",this.startedAt=new Date(Date.now())}pause(){this.state="Paused"}resume(){this.state="Recording"}stop(){this.state="Ended",this.sessionDuration=Date.now()-this.startedAt.getTime()}setProctoringId(t){this.id=t}setEndConfirmed(){this.state="EndConfirmed"}setUploaded(){this.state="Uploaded"}setUploadConfirmed(){this.state="UploadConfirmed"}addAlert(t){this.alerts.push(t)}addRecording(t){this.recordings.push(t)}};var Vi=class{constructor(t,r){this.backendService=new Da;this.scanInterval=5;this.options={};this.options=r,this.context=t,this.backend=new nr({type:t?.type||"prod",token:t.token}),this.currentIsPlugged=!0}setProctoringId(t){this.proctoringId=t}async isPluggedIn(t=!1){try{let r=await this.backendService.isPluggedIn();if(this.proctoringId&&t)if(r)this.currentIsPlugged||this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Dispositivo de varredura conectado.",status:"OK"});else{let n=new Hn;n.setProctoringId(this.proctoringId),n.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:33,type:5}),await this.backend.saveAlerts(this.context,n),this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Nenhum dispositivo de varredura conectado.",status:"ALERT"})}return this.currentIsPlugged=r,this.currentIsPlugged}catch(r){throw r}}async isAlive(){try{return await this.backendService.isAlive()}catch(t){throw t}}connectAndScan(){return this.backendService.ConnectAndScan()}async devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=await this.backendService.Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n});if(i.length>0&&(this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam detected",description:"Dispositivo espi\xE3o detectado.",data:i}),this.proctoringId)){let o=new Hn;o.setProctoringId(this.proctoringId),o.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:32,type:5}),await this.backend.saveAlerts(this.context,o)}return i}async startCheckSpyCam(t,{deviceType:r,rssiThreshold:n,packageRateThreshold:i}){this.scanInterval=t,this.startTime=new Date(Date.now()),await this.isPluggedIn(!0),this.checkSpyCam=setInterval(async()=>{await this.isPluggedIn(!0)&&await this.devices({deviceType:r,rssiThreshold:n,packageRateThreshold:i})},this.scanInterval*6e4)}stopCheckSpyCam(){clearInterval(this.checkSpyCam)}};var ir={cameraId:void 0,microphoneId:void 0,allowMultipleMonitors:!1,allowOnlyFirstMonitor:!0,captureScreen:!0,noiseLimit:40,proctoringType:"IMAGE",insights:"",onBufferSizeError:!1,useGeolocation:!1,useSpyScan:!1,useExternalCamera:!1,useChallenge:!1,screenRecorderOptions:{width:1280,height:720}};function Oa(e){return e.width&&e.height?{width:e.width,height:e.height,minWidth:e.minWidth,minHeight:e.minHeight,timeSlice:e.timeSlice,videoBitsPerSecond:e.videoBitsPerSecond,mimeType:e.mimeType}:{width:640,height:480}}var Gg={width:1280,height:720,minWidth:640,minHeight:480};function qg(){let e=navigator.userAgent,t;return e.match(/chrome|chromium|crios/i)?t="chrome":e.match(/firefox|fxios/i)?t="firefox":e.match(/safari/i)?t="safari":e.match(/opr\//i)?t="opera":e.match(/edg/i)?t="edge":t="No browser detection",t}function Fr(){if("userAgentData"in navigator){let e=navigator.userAgentData,t=e.mobile||!1,r=e.platform||"";return t||/Android|iOS/i.test(r)}return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)}var Ba,Kg=e=>(Ba=e,Ba),Pt={DEVICES_CHECKED:"devices_checked",START:"start",FINISH:"finish",ERROR:"error",UPLOAD:"upload",UPLOAD_FILE:"upload_file",DOWNLOAD_VIDEO:"download_video",BUFFER_SIZE:"buffer_size",ANOTHER_STREAM:"another_stream",CHANGE_DEVICE:"change_device",STOP_SHARING_SCREEN:"stop_sharing_screen",ERROR_RECORDER_RTC:"error_recorder_rtc",BROWSER_NOT_SUPPORTED:"browser_not_supported",SAVE_ON_SESSION:"save_on_session"},Dt=(e,t)=>Ba&&Ba.log(e,t),ue={registerDevicesChecked:(e,t,r)=>Dt(Pt.DEVICES_CHECKED,{proctoringId:e,success:t,description:r}),registerStart:(e,t,r)=>Dt(Pt.START,{proctoringId:e,success:t,description:r}),registerFinish:(e,t,r)=>Dt(Pt.FINISH,{proctoringId:e,success:t,description:r}),registerError:(e,t)=>Dt(Pt.ERROR,{proctoringId:e,description:t}),registerBrowserNotSupported:(e,t)=>Dt(Pt.BROWSER_NOT_SUPPORTED,{proctoringId:e,description:t}),registerUpload:(e,t,r,n,i)=>Dt(Pt.UPLOAD,{proctoringId:e,success:t,description:r,serviceType:n,uploadTime:i}),registerUploadFile:(e,t,r)=>Dt(Pt.UPLOAD_FILE,{proctoringId:e,description:t,fileType:r}),registerChangeDevice:(e,t,r)=>Dt(Pt.CHANGE_DEVICE,{proctoringId:e,inOrOut:t,description:r}),registerStopSharingScreen:(e,t)=>Dt(Pt.STOP_SHARING_SCREEN,{proctoringId:e,description:t}),registerErrorRecorderRTC:(e,t)=>Dt(Pt.ERROR_RECORDER_RTC,{proctoringId:e,description:t}),registerDownloadFile:(e,t)=>Dt(Pt.DOWNLOAD_VIDEO,{proctoringId:e,description:t}),registerOnBufferSizeError:(e,t)=>Dt(Pt.BUFFER_SIZE,{proctoringId:e,description:t}),registerAnotherStream:(e,t)=>Dt(Pt.ANOTHER_STREAM,{proctoringId:e,description:t}),registerSaveOnSession:(e,t)=>Dt(Pt.SAVE_ON_SESSION,{proctoringId:e,description:t})};var Vo;function La(e){Vo=e}function Wn(e,t,r,n=!1,i,o=!1){let s,a=!1,c,l,h;h=0;let d={mimeType:"video/webm",videoBitsPerSecond:128e3,audioBitsPerSecond:64*1e3};MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?d.mimeType="video/webm;codecs=vp9":console.warn("vp9 codec not supported. Using default mimeType without vp9."),r?.mimeType&&(d.mimeType=r?.mimeType),r?.videoBitsPerSecond!=null&&(d.videoBitsPerSecond=r?.videoBitsPerSecond),o&&(d={mimeType:"audio/webm",audioBitsPerSecond:64*1e3}),console.log("recorderOptions bitsPerSecond",d.bitsPerSecond);let m=new MediaRecorder(e,d);m.ondataavailable=S=>{if(h=h+S.data.size,console.log("video tracks length > 0",e.getVideoTracks().length>0),e.getVideoTracks().length>0){let k=e.getVideoTracks()[0];console.log(k.readyState),console.log(k.enabled)}S.data.size>0&&t.push(S.data),a?(o&&m.state=="inactive"&&(t=[new Blob(t,{type:"audio/webm"})]),s&&s()):((l&&S.data.size===l.data.size||S.data.size===0)&&(Vo&&l&&S.data.size===l.data.size&&ue.registerOnBufferSizeError(Vo,`onBufferSizeError: Recorder size freezed: ${S.data.size} Mb`),Vo&&S.data.size===0&&ue.registerOnBufferSizeError(Vo,"onBufferSizeError: Recorder size equal 0 Mb"),console.log("onbuffer size error"),i&&i()),l=S)};function p(){return new Promise(S=>{s=S;var k=1e4;r?.timeSlice!=null&&(k=r?.timeSlice),console.log("startRecording",k),m.start(k),h=0,a=!1})}function g(){return new Promise(S=>{m.state=="recording"?(s=S,m.stop(),a=!0,e.getTracks().forEach(k=>{k.stop()})):S()})}function f(){return new Promise(S=>{m.state=="recording"&&m.pause(),S()})}function b(){return new Promise(S=>{m.state=="paused"&&m.resume(),S()})}function _(){return h}return{startRecording:p,stopRecording:g,pauseRecording:f,resumeRecording:b,recorderOptions:d,getBufferSize:_}}var Yr=class{constructor(t,r){this.backend=r;this.imageUrlPackage=[];this.imageBatchNum=0;this.contImages=0;this.proctoringId=t}async uploadPackage(t,r){let{file:n,onProgress:i}=t;try{let o=c=>{let l=c.loadedBytes/n.size*100;i&&i(Math.round(l))},s=await this.backend.getSignedUrl(r,n,this.proctoringId),a=await vr.request({url:s,method:"PUT",headers:{"Content-Type":n.type,"x-ms-blob-type":"BlockBlob"},data:n,onUploadProgress:c=>{o({loadedBytes:c.loaded})}}).then(()=>!0).catch(()=>!1);return{storage:"upload",url:s,uploaded:a}}catch{throw ue.registerError(this.proctoringId,`Failed to upload to AWS
71
+ `+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=br(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&zo.assertOptions(n,{silentJSONParsing:Lr.transitional(Lr.boolean),forcedJSONParsing:Lr.transitional(Lr.boolean),clarifyTimeoutError:Lr.transitional(Lr.boolean)},!1),i!=null&&(T.isFunction(i)?r.paramsSerializer={serialize:i}:zo.assertOptions(i,{encode:Lr.function,serialize:Lr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),zo.assertOptions(r,{baseUrl:Lr.spelling("baseURL"),withXsrfToken:Lr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&T.merge(o.common,o[r.method]);o&&T.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),r.headers=at.concat(s,o);let a=[],c=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(c=c&&f.synchronous,a.unshift(f.fulfilled,f.rejected))});let l=[];this.interceptors.response.forEach(function(f){l.push(f.fulfilled,f.rejected)});let h,d=0,m;if(!c){let g=[Ia.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,l),m=g.length,h=Promise.resolve(r);d<m;)h=h.then(g[d++],g[d++]);return h}m=a.length;let p=r;for(d=0;d<m;){let g=a[d++],f=a[d++];try{p=g(p)}catch(b){f.call(this,b);break}}try{h=Ia.call(this,p)}catch(g){return Promise.reject(g)}for(d=0,m=l.length;d<m;)h=h.then(l[d++],l[d++]);return h}getUri(t){t=br(this.defaults,t);let r=No(t.baseURL,t.url,t.allowAbsoluteUrls);return Bo(r,t.params,t.paramsSerializer)}};T.forEach(["delete","get","head","options"],function(t){ji.prototype[t]=function(r,n){return this.request(br(n||{},{method:t,url:r,data:(n||{}).data}))}});T.forEach(["post","put","patch"],function(t){function r(n){return function(o,s,a){return this.request(br(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}ji.prototype[t]=r(),ji.prototype[t+"Form"]=r(!0)});var jo=ji;var gd=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(o,s,a){n.reason||(n.reason=new Br(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(i){t=i}),cancel:t}}},Vg=gd;function yd(e){return function(r){return e.apply(null,r)}}function bd(e){return T.isObject(e)&&e.isAxiosError===!0}var vd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(vd).forEach(([e,t])=>{vd[t]=e});var Hg=vd;function Wg(e){let t=new jo(e),r=Po(jo.prototype.request,t);return T.extend(r,jo.prototype,t,{allOwnKeys:!0}),T.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return Wg(br(e,i))},r}var rt=Wg(Ui);rt.Axios=jo;rt.CanceledError=Br;rt.CancelToken=Vg;rt.isCancel=Mo;rt.VERSION=Ra;rt.toFormData=mn;rt.AxiosError=le;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=yd;rt.isAxiosError=bd;rt.mergeConfig=br;rt.AxiosHeaders=at;rt.formToJSON=e=>ka(T.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=Ta.getAdapter;rt.HttpStatusCode=Hg;rt.default=rt;var vr=rt;var{Axios:kC,AxiosError:EC,CanceledError:CC,isCancel:xC,CancelToken:AC,VERSION:TC,all:IC,Cancel:RC,isAxiosError:PC,spread:DC,toFormData:OC,AxiosHeaders:BC,HttpStatusCode:LC,formToJSON:FC,getAdapter:MC,mergeConfig:UC}=vr;var f_="https://proctoring-api-dev.easyproctor.tech/api",p_="https://proctoring-api-hml.easyproctor.tech/api",$g="https://proctoring-api.easyproctor.tech/api",nr=class{constructor(t){this.options=t;this.baseUrl=this.selectBaseUrl(t.type),this.token=t.token}selectBaseUrl(t){return t==="dev"?f_:t==="homol"?p_:$g}getSocketUrl(){return this.baseUrl.replace("/api","/hub/sockethub")}async loginAuth(t,r){return await this.makeRequest({path:"/Auth",method:"POST",body:{emailOrCpf:t,key:r}})}async externalCameraRegister(t){return await this.makeRequest({path:"/ExternalCamera/register",method:"POST",body:t,jwt:this.token})}async externalCameraCheckTransmission(t){return await this.makeRequest({path:`/ExternalCamera/send-action/${t}`,method:"POST",body:{command:"Check_Transmission"},jwt:this.token})}async externalCameraStartTransmission(t,r){return await this.makeRequest({path:`/ExternalCamera/start-transmission/${t}`,method:"POST",body:{proctoringId:r},jwt:this.token})}async externalCameraStartSession(){return await this.makeRequest({path:"/ExternalCamera/start-session",method:"POST",body:{},jwt:this.token})}async goToExternalCameraPositionStep(t){return await this.makeRequest({path:`/ExternalCamera/go-to-position-step/${t}`,method:"POST",body:{},jwt:this.token})}async externalCameraFinish(t){return await this.makeRequest({path:`/ExternalCamera/finish/${t}`,method:"POST",body:{},jwt:this.token})}async confirmStart(t,r,n,i){return await this.makeRequest({path:`/proctoring/start/${t.examId}`,method:"POST",body:{clientId:t.clientId,proctoringType:r.proctoringType,latitude:n,longitude:i,captureScreen:r.captureScreen},jwt:t.token})}async getParamsConfig(t){return(await this.makeRequestAxios({path:"/Client/params",method:"GET",jwt:t.token}).catch(n=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async getSignedUrlImage(t,r){return(await this.makeRequestAxios({path:"/upload/signed-url-batch",method:"POST",jwt:t,body:r})).data}async getSignedUrl(t,r,n){return(await this.makeRequestAxios({path:"/upload/signed-url",method:"POST",jwt:t,body:{objectName:`${n}/${r.name}`,contentType:r.type}})).data}async saveAlerts(t,r){await this.makeRequest({path:"/proctoring/save-alerts",method:"POST",jwt:t.token,body:{proctoringId:r.id,alerts:r.alerts}})}async finishAndSendUrls(t){return await this.makeRequest({path:`/proctoring/finish/${t.examId}`,method:"POST",body:{endDate:new Date().toISOString(),videoCameraUrl:"",audioCameraUrl:"",videoScreenUrl:""},jwt:t.token})}async log(t,r){let n;return r?.success!==null&&r?.success!==void 0?n=r.success?"4":"1":n="4",await this.makeRequest({path:"/Log",method:"POST",body:{entryType:n,eventName:t,message:r},jwt:this.token})}async signTerm(){return await this.makeRequest({path:"/User/sign-terms",method:"PATCH",body:{},jwt:this.token})}async signTermUrl(){return(await this.makeRequestAxios({path:"/User/sign-terms-url",method:"GET",jwt:this.token})).data}async startChallenge(t){return(await this.makeRequestAxios({path:"/Challenge/start",method:"POST",jwt:this.token,body:t})).data}async stopChallenge(t,r){return(await this.makeRequestAxios({path:`/Challenge/stop/${t}`,method:"POST",jwt:this.token,body:r})).data}async startRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/start-warning",method:"POST",jwt:this.token,body:t})).data}async stopRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/stop-warning",method:"POST",jwt:this.token,body:t})).data}async verifyFace(t,r,n){return(await this.makeRequestAxios({path:"/Realtime/verify-face",method:"POST",jwt:this.token,body:{proctoringId:t,base64:r,retry:n}})).data}async getServerHour(t){return await this.makeRequest({path:"/Proctoring/server-hour",method:"GET",jwt:t})}async makeRequest(t){let{path:r,method:n,body:i,jwt:o}=t,s=await fetch(this.baseUrl+r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}async makeRequestPUT(t){let{url:r,method:n,body:i,jwt:o}=t,s=await fetch(r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Accept:"*/*","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","aeg-event-type":"Notification","Content-Type":"application/json","Cache-Control":"no-cache","x-ms-blob-type":"BlockBlob"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}};var Da=class{constructor(){this.baseUrl="https://localhost:5080"}async isAlive(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-alive",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async isPluggedIn(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-plugged-in",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async ConnectAndScan(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/connect-and-scan",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=[];return t&&i.push(`deviceType=${t}`),r&&i.push(`rssiThreshold=${r}`),n&&i.push(`packageRateThreshold=${n}`),(await this.makeRequestAxios({path:`/api/usb-device-manager/devices?${i.join("&")}`,method:"GET",jwt:this.token}).catch(s=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}};var Hn=class{constructor(){this.sessionDuration=0;this.state="Created",this.startedAt=new Date,this.alerts=[],this.recordings=[]}get hasSomethingToUpload(){for(let t of this.recordings)if(!t.upload)return!0;return!1}start(){this.state="Recording",this.startedAt=new Date(Date.now())}pause(){this.state="Paused"}resume(){this.state="Recording"}stop(){this.state="Ended",this.sessionDuration=Date.now()-this.startedAt.getTime()}setProctoringId(t){this.id=t}setEndConfirmed(){this.state="EndConfirmed"}setUploaded(){this.state="Uploaded"}setUploadConfirmed(){this.state="UploadConfirmed"}addAlert(t){this.alerts.push(t)}addRecording(t){this.recordings.push(t)}};var Vi=class{constructor(t,r){this.backendService=new Da;this.scanInterval=5;this.options={};this.options=r,this.context=t,this.backend=new nr({type:t?.type||"prod",token:t.token}),this.currentIsPlugged=!0}setProctoringId(t){this.proctoringId=t}async isPluggedIn(t=!1){try{let r=await this.backendService.isPluggedIn();if(this.proctoringId&&t)if(r)this.currentIsPlugged||this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Dispositivo de varredura conectado.",status:"OK"});else{let n=new Hn;n.setProctoringId(this.proctoringId),n.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:33,type:5}),await this.backend.saveAlerts(this.context,n),this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Nenhum dispositivo de varredura conectado.",status:"ALERT"})}return this.currentIsPlugged=r,this.currentIsPlugged}catch(r){throw r}}async isAlive(){try{return await this.backendService.isAlive()}catch(t){throw t}}connectAndScan(){return this.backendService.ConnectAndScan()}async devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=await this.backendService.Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n});if(i.length>0&&(this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam detected",description:"Dispositivo espi\xE3o detectado.",data:i}),this.proctoringId)){let o=new Hn;o.setProctoringId(this.proctoringId),o.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:32,type:5}),await this.backend.saveAlerts(this.context,o)}return i}async startCheckSpyCam(t,{deviceType:r,rssiThreshold:n,packageRateThreshold:i}){this.scanInterval=t,this.startTime=new Date(Date.now()),await this.isPluggedIn(!0),this.checkSpyCam=setInterval(async()=>{await this.isPluggedIn(!0)&&await this.devices({deviceType:r,rssiThreshold:n,packageRateThreshold:i})},this.scanInterval*6e4)}stopCheckSpyCam(){clearInterval(this.checkSpyCam)}};var ir={cameraId:void 0,microphoneId:void 0,allowMultipleMonitors:!1,allowOnlyFirstMonitor:!0,captureScreen:!0,noiseLimit:40,proctoringType:"IMAGE",insights:"",onBufferSizeError:!1,useGeolocation:!1,useSpyScan:!1,useExternalCamera:!1,useChallenge:!1,screenRecorderOptions:{width:1280,height:720}};function Oa(e){return e.width&&e.height?{width:e.width,height:e.height,minWidth:e.minWidth,minHeight:e.minHeight,timeSlice:e.timeSlice,videoBitsPerSecond:e.videoBitsPerSecond,mimeType:e.mimeType}:{width:640,height:480}}var Gg={width:1280,height:720,minWidth:640,minHeight:480};function qg(){let e=navigator.userAgent,t;return e.match(/chrome|chromium|crios/i)?t="chrome":e.match(/firefox|fxios/i)?t="firefox":e.match(/safari/i)?t="safari":e.match(/opr\//i)?t="opera":e.match(/edg/i)?t="edge":t="No browser detection",t}function Fr(){if("userAgentData"in navigator){let e=navigator.userAgentData,t=e.mobile||!1,r=e.platform||"";return t||/Android|iOS/i.test(r)}return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)}var Ba,Kg=e=>(Ba=e,Ba),Pt={DEVICES_CHECKED:"devices_checked",START:"start",FINISH:"finish",ERROR:"error",UPLOAD:"upload",UPLOAD_FILE:"upload_file",DOWNLOAD_VIDEO:"download_video",BUFFER_SIZE:"buffer_size",ANOTHER_STREAM:"another_stream",CHANGE_DEVICE:"change_device",STOP_SHARING_SCREEN:"stop_sharing_screen",ERROR_RECORDER_RTC:"error_recorder_rtc",BROWSER_NOT_SUPPORTED:"browser_not_supported",SAVE_ON_SESSION:"save_on_session"},Dt=(e,t)=>Ba&&Ba.log(e,t),ue={registerDevicesChecked:(e,t,r)=>Dt(Pt.DEVICES_CHECKED,{proctoringId:e,success:t,description:r}),registerStart:(e,t,r)=>Dt(Pt.START,{proctoringId:e,success:t,description:r}),registerFinish:(e,t,r)=>Dt(Pt.FINISH,{proctoringId:e,success:t,description:r}),registerError:(e,t)=>Dt(Pt.ERROR,{proctoringId:e,description:t}),registerBrowserNotSupported:(e,t)=>Dt(Pt.BROWSER_NOT_SUPPORTED,{proctoringId:e,description:t}),registerUpload:(e,t,r,n,i)=>Dt(Pt.UPLOAD,{proctoringId:e,success:t,description:r,serviceType:n,uploadTime:i}),registerUploadFile:(e,t,r)=>Dt(Pt.UPLOAD_FILE,{proctoringId:e,description:t,fileType:r}),registerChangeDevice:(e,t,r)=>Dt(Pt.CHANGE_DEVICE,{proctoringId:e,inOrOut:t,description:r}),registerStopSharingScreen:(e,t)=>Dt(Pt.STOP_SHARING_SCREEN,{proctoringId:e,description:t}),registerErrorRecorderRTC:(e,t)=>Dt(Pt.ERROR_RECORDER_RTC,{proctoringId:e,description:t}),registerDownloadFile:(e,t)=>Dt(Pt.DOWNLOAD_VIDEO,{proctoringId:e,description:t}),registerOnBufferSizeError:(e,t)=>Dt(Pt.BUFFER_SIZE,{proctoringId:e,description:t}),registerAnotherStream:(e,t)=>Dt(Pt.ANOTHER_STREAM,{proctoringId:e,description:t}),registerSaveOnSession:(e,t)=>Dt(Pt.SAVE_ON_SESSION,{proctoringId:e,description:t})};var Vo;function La(e){Vo=e}function Wn(e,t,r,n=!1,i,o=!1){let s,a=!1,c,l,h;h=0;let d={mimeType:"video/webm",videoBitsPerSecond:128e3,audioBitsPerSecond:64*1e3};MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?d.mimeType="video/webm;codecs=vp9":console.warn("vp9 codec not supported. Using default mimeType without vp9."),r?.mimeType&&(d.mimeType=r?.mimeType),r?.videoBitsPerSecond!=null&&(d.videoBitsPerSecond=r?.videoBitsPerSecond),o&&(d={mimeType:"audio/webm",audioBitsPerSecond:64*1e3}),console.log("recorderOptions bitsPerSecond",d.videoBitsPerSecond);let m=new MediaRecorder(e,d);m.ondataavailable=S=>{if(h=h+S.data.size,console.log("video tracks length > 0",e.getVideoTracks().length>0),e.getVideoTracks().length>0){let k=e.getVideoTracks()[0];console.log(k.readyState),console.log(k.enabled)}S.data.size>0&&t.push(S.data),a?(o&&m.state=="inactive"&&(t=[new Blob(t,{type:"audio/webm"})]),s&&s()):((l&&S.data.size===l.data.size||S.data.size===0)&&(Vo&&l&&S.data.size===l.data.size&&ue.registerOnBufferSizeError(Vo,`onBufferSizeError: Recorder size freezed: ${S.data.size} Mb`),Vo&&S.data.size===0&&ue.registerOnBufferSizeError(Vo,"onBufferSizeError: Recorder size equal 0 Mb"),console.log("onbuffer size error"+S.data.size),i&&i()),l=S)};function p(){return new Promise(S=>{s=S;var k=1e4;r?.timeSlice!=null&&(k=r?.timeSlice),console.log("startRecording",k);try{m.start(k),m.onstart=()=>{console.log("Grava\xE7\xE3o iniciada com sucesso!")}}catch(I){console.error("Falha ao iniciar:",I)}h=0,a=!1})}function g(){return new Promise(S=>{m.state=="recording"?(s=S,m.stop(),a=!0,e.getTracks().forEach(k=>{k.stop()})):S()})}function f(){return new Promise(S=>{m.state=="recording"&&m.pause(),S()})}function b(){return new Promise(S=>{m.state=="paused"&&m.resume(),S()})}function _(){return h}return{startRecording:p,stopRecording:g,pauseRecording:f,resumeRecording:b,recorderOptions:d,getBufferSize:_}}var Yr=class{constructor(t,r){this.backend=r;this.imageUrlPackage=[];this.imageBatchNum=0;this.contImages=0;this.proctoringId=t}async uploadPackage(t,r){let{file:n,onProgress:i}=t;try{let o=c=>{let l=c.loadedBytes/n.size*100;i&&i(Math.round(l))},s=await this.backend.getSignedUrl(r,n,this.proctoringId),a=await vr.request({url:s,method:"PUT",headers:{"Content-Type":n.type,"x-ms-blob-type":"BlockBlob"},data:n,onUploadProgress:c=>{o({loadedBytes:c.loaded})}}).then(()=>!0).catch(()=>!1);return{storage:"upload",url:s,uploaded:a}}catch{throw ue.registerError(this.proctoringId,`Failed to upload to AWS
72
72
  File name: ${n.name}
73
73
  File type: ${n.type}
74
74
  File size: ${n.size}`),new Error("Failed to upload to AWS")}}async uploadImages(t,r,n){let{file:i,onProgress:o}=t;try{let s=l=>{let h=l.loadedBytes/i.size*100;o&&o(Math.round(h))},a;if(this.imageBatchNum===this.contImages){let l=[];for(let d=this.imageBatchNum;d<this.imageBatchNum+60;d++){let m=`${this.proctoringId}/${this.proctoringId}_${d+1}.jpg`;(d+1)%n==0&&(m=`${this.proctoringId}/${this.proctoringId}_${d+1}_realtime.jpg`),l.push({objectName:m,contentType:"image/jpeg"})}(await this.backend.getSignedUrlImage(r,l)).map(d=>{this.imageUrlPackage.push(d)}),this.imageBatchNum+=60}let c=!1;return c=await vr.request({url:this.imageUrlPackage[this.contImages],method:"PUT",headers:{"Content-Type":i.type,"x-ms-blob-type":"BlockBlob"},data:i,onUploadProgress:l=>{s({loadedBytes:l.loaded})}}).then(l=>l.status==200||l.status==201?(this.contImages++,!0):!1).catch(()=>!1).finally(()=>{}),{storage:"upload",url:a,uploaded:c}}catch{throw ue.registerError(this.proctoringId,`Failed to upload to AWS
@@ -77,11 +77,11 @@ Minimum version required to store current data is: `+o+`.
77
77
  File size: ${i.size}`),new Error("Failed to upload to AWS")}}async upload(t,r,n){let{file:i,onProgress:o}=t;try{let s=l=>{let h=l.loadedBytes/i.size*100;o&&o(Math.round(h))},a;if(n){if(this.imageBatchNum===this.contImages){let l=[];for(let d=this.imageBatchNum;d<this.imageBatchNum+20;d++)l.push({objectName:`${this.proctoringId}/${this.proctoringId}_${d+1}.jpg`,contentType:"image/jpeg"});(await this.backend.getSignedUrlImage(r,l)).map(d=>{this.imageUrlPackage.push(d)}),this.imageBatchNum+=20}}else a=await this.backend.getSignedUrl(r,i,this.proctoringId);let c=!1;return n?c=await vr.request({url:this.imageUrlPackage[this.contImages],method:"PUT",headers:{"Content-Type":i.type,"x-ms-blob-type":"BlockBlob"},data:i,onUploadProgress:l=>{s({loadedBytes:l.loaded})}}).then(()=>!0).catch(()=>!1).finally(()=>{this.contImages++}):c=await vr.request({url:a,method:"PUT",headers:{"Content-Type":i.type,"x-ms-blob-type":"BlockBlob"},data:i,onUploadProgress:l=>{s({loadedBytes:l.loaded})}}).then(()=>!0).catch(()=>!1),{storage:"upload",url:a,uploaded:c}}catch{throw ue.registerError(this.proctoringId,`Failed to upload to AWS
78
78
  File name: ${i.name}
79
79
  File type: ${i.type}
80
- File size: ${i.size}`),new Error("Failed to upload to AWS")}}};var Xg="not_shared_first_screen",Jg="not_shared_screen",Fa="multiple_monitors_detected",Yg="proctoring_already_started",Ma="proctoring_not_started";var Sd="another_stream_active",kd="stream_under_minimum_permitted",Zg="browser_not_supported",Qg="token_missing",e0="credentials_missing";var t0="spy_scan_api_not_found";var r0="external_camera_not_started";var Ua=class extends Bi{constructor(t,r,n="videoPreviewFrameDetection",i="liveViewFrameDetection"){super("ObjectDetector","https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite",t,r,n,i)}stopDetection(){super.stopDetection(),this.numPersonsSent>0&&this.handleOk("person_ok","person_detection_on_stream")}displayVideoDetections(t){for(let r of this.children)this.liveView.removeChild(r);this.children.splice(0);for(let r of t.detections){let n=window.innerWidth,i=window.innerHeight,o=this.video.offsetWidth,s=this.video.offsetHeight,a=o/n,c=s/i,l=o-r.boundingBox.width*a-r.boundingBox.originX*a,h=r.boundingBox.originY*c,d=(r.boundingBox.width-10)*a,m=r.boundingBox.height*c,p=document.createElement("p");p.innerText=r.categories[0].categoryName+" - with "+Math.round(parseFloat(r.categories[0].score)*100)+"% confidence.",p.style.right=l-20+"px",p.style.top=h+"px",p.style.width=d+"px";let g={zIndex:"2",position:"absolute",border:"1px dashed #fff"};Object.assign(p.style,{...g,margin:"0",fontSize:"9px",paddingBottom:"5px",paddingTop:"5px",color:"#fff",backgroundColor:"#007f8b"});let f=document.createElement("div");f.setAttribute("class","highlighter"),f.style.right=l-20+"px",f.style.top=h+"px",f.style.width=d+"px",f.style.height=m-20+"px",Object.assign(f.style,{...g,zIndex:"1",background:"rgba(0, 255, 0, 0.25)"}),this.liveView.appendChild(f),this.liveView.appendChild(p),this.children.push(f),this.children.push(p)}}verify(t){let r=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="person")).length,n=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="cell phone")).length;this.paramsConfig.videoBehaviourParameters?.detectPerson&&r!==this.numPersonsSent&&(r===0?(this.handleAlert("no_person_detected","person_detection_on_stream"),this.numPersonsSent=r):r>1?(this.handleAlert("multiple_persons_detected","person_detection_on_stream"),this.numPersonsSent=r):(this.handleOk("person_ok","person_detection_on_stream"),this.numPersonsSent=r)),this.paramsConfig.videoBehaviourParameters?.detectCellPhone&&n!==this.numCellphoneSent&&(n>0?(this.handleAlert("cellphone_detected","mobile_detection_on_stream"),this.numCellphoneSent=n):(this.handleOk("cellphone_ok","mobile_detection_on_stream"),this.numCellphoneSent=n))}};var gn=class{constructor(t){this.volume=null;this.animationFrameId=null;this.stream=t}async start(t={}){return new Promise((r,n)=>{try{let i=new AudioContext;this.analyser=i.createAnalyser();let o=i.createMediaStreamSource(this.stream);this.analyser.smoothingTimeConstant=.8,this.analyser.fftSize=1024,o.connect(this.analyser);let s=()=>{let a=new Uint8Array(this.analyser.frequencyBinCount);this.analyser.getByteFrequencyData(a);let l=a.reduce((h,d)=>h+d,0)/a.length;this.setVolume(l),t.setVolume&&t.setVolume(l),this.animationFrameId=requestAnimationFrame(s)};this.animationFrameId=requestAnimationFrame(s),r(!0)}catch(i){this.stop(),n(`Error: ${i}`)}})}stop(){this.animationFrameId!==null&&cancelAnimationFrame(this.animationFrameId)}getVolume(){return this.volume}setVolume(t){this.volume=t}};var s0=ul(i0()),Zr=class{constructor(t,r,n,i,o){this.blobs=[];this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectPerson:!1,detectFace:!1,detectCellPhone:!1}};this.options={cameraId:void 0,microphoneId:void 0,onBufferSizeError:!1,onBufferSizeErrorCallback:t=>{},proctoringType:"IMAGE",onChangeDevicesCallback:t=>{},onRealtimeAlertsCallback:t=>{}};this.videoOptions={width:640,height:480,minWidth:0,minHeight:0};this.blobsRTC=[];this.imageCount=0;this.filesToUpload=[];this.animationFrameId=null;this.isCanvasLoopActive=!1;this.hardwareStream=null;this.internalClonedStream=null;this.currentRetries=0;this.packageCount=0;this.noiseWait=20;this.options=t,this.videoOptions=r,this.backend=i,this.backendToken=o,n&&(this.paramsConfig=n)}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Yr(this.proctoringId,this.backend)),La(t)}async initializeDetectors(){ag(),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&(this.objectDetection=new Ua({onRealtimeAlertsCallback:t=>this.options.onRealtimeAlertsCallback(t)},this.paramsConfig),await this.objectDetection.initializeDetector()),this.paramsConfig.videoBehaviourParameters?.detectFace&&(this.faceDetection=new Li({onRealtimeAlertsCallback:t=>this.options.onRealtimeAlertsCallback(t)},this.paramsConfig),await this.faceDetection.initializeDetector())}configImageCapture(){this.video=document.createElement("video"),this.canvas=document.createElement("canvas"),this.video.srcObject=this.cameraStream,this.video.play(),this.video.muted=!0,screen.orientation?.type.includes("portrait")&&Fr()?(console.log("configurando canvas em portrait"),this.canvas.width=this.videoOptions.height/2,this.canvas.height=this.videoOptions.width/2):(this.canvas.width=this.videoOptions.width/2,this.canvas.height=this.videoOptions.height/2)}async bufferError(t){console.log("buffer error Camera Recorder params "+this.paramsConfig.videoBehaviourParameters);let r=this.paramsConfig.videoBehaviourParameters?.retryEnabled||!1,n=this.paramsConfig.videoBehaviourParameters?.maxRetries||3;r&&this.currentRetries<n?(await this.recordingStop(),await this.startRecording({retry:!0}),this.currentRetries++,this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback(this.cameraStream)):this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback()}async startStream(t){let{cameraId:r,microphoneId:n,onBufferSizeErrorCallback:i}=this.options,o={audio:{deviceId:n},video:{deviceId:r,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.hardwareStream=await navigator.mediaDevices.getUserMedia(o)}catch(d){throw d.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":d}this.cameraStream=this.hardwareStream;let a=this.cameraStream.getVideoTracks()[0].getSettings(),{width:c=0,height:l=0}=a;if(screen.orientation?.type.includes("portrait")&&Fr()&&this.videoOptions.width==l&&this.videoOptions.height==c&&([c,l]=[l,c]),this.videoOptions.minWidth>c||this.videoOptions.minHeight>l)throw kd;if(this.videoOptions.width!==c||this.videoOptions.height!==l)throw ue.registerAnotherStream(this.proctoringId,`Maybe have another stream active
80
+ File size: ${i.size}`),new Error("Failed to upload to AWS")}}};var Xg="not_shared_first_screen",Jg="not_shared_screen",Fa="multiple_monitors_detected",Yg="proctoring_already_started",Ma="proctoring_not_started";var Sd="another_stream_active",kd="stream_under_minimum_permitted",Zg="browser_not_supported",Qg="token_missing",e0="credentials_missing";var t0="spy_scan_api_not_found";var r0="external_camera_not_started";var Ua=class extends Bi{constructor(t,r,n="videoPreviewFrameDetection",i="liveViewFrameDetection"){super("ObjectDetector","https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite",t,r,n,i)}stopDetection(){super.stopDetection(),this.numPersonsSent>0&&this.handleOk("person_ok","person_detection_on_stream")}displayVideoDetections(t){for(let r of this.children)this.liveView.removeChild(r);this.children.splice(0);for(let r of t.detections){let n=window.innerWidth,i=window.innerHeight,o=this.video.offsetWidth,s=this.video.offsetHeight,a=o/n,c=s/i,l=o-r.boundingBox.width*a-r.boundingBox.originX*a,h=r.boundingBox.originY*c,d=(r.boundingBox.width-10)*a,m=r.boundingBox.height*c,p=document.createElement("p");p.innerText=r.categories[0].categoryName+" - with "+Math.round(parseFloat(r.categories[0].score)*100)+"% confidence.",p.style.right=l-20+"px",p.style.top=h+"px",p.style.width=d+"px";let g={zIndex:"2",position:"absolute",border:"1px dashed #fff"};Object.assign(p.style,{...g,margin:"0",fontSize:"9px",paddingBottom:"5px",paddingTop:"5px",color:"#fff",backgroundColor:"#007f8b"});let f=document.createElement("div");f.setAttribute("class","highlighter"),f.style.right=l-20+"px",f.style.top=h+"px",f.style.width=d+"px",f.style.height=m-20+"px",Object.assign(f.style,{...g,zIndex:"1",background:"rgba(0, 255, 0, 0.25)"}),this.liveView.appendChild(f),this.liveView.appendChild(p),this.children.push(f),this.children.push(p)}}verify(t){let r=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="person")).length,n=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="cell phone")).length;this.paramsConfig.videoBehaviourParameters?.detectPerson&&r!==this.numPersonsSent&&(r===0?(this.handleAlert("no_person_detected","person_detection_on_stream"),this.numPersonsSent=r):r>1?(this.handleAlert("multiple_persons_detected","person_detection_on_stream"),this.numPersonsSent=r):(this.handleOk("person_ok","person_detection_on_stream"),this.numPersonsSent=r)),this.paramsConfig.videoBehaviourParameters?.detectCellPhone&&n!==this.numCellphoneSent&&(n>0?(this.handleAlert("cellphone_detected","mobile_detection_on_stream"),this.numCellphoneSent=n):(this.handleOk("cellphone_ok","mobile_detection_on_stream"),this.numCellphoneSent=n))}};var gn=class{constructor(t){this.volume=null;this.animationFrameId=null;this.stream=t}async start(t={}){return new Promise((r,n)=>{try{let i=new AudioContext;this.analyser=i.createAnalyser();let o=i.createMediaStreamSource(this.stream);this.analyser.smoothingTimeConstant=.8,this.analyser.fftSize=1024,o.connect(this.analyser);let s=()=>{let a=new Uint8Array(this.analyser.frequencyBinCount);this.analyser.getByteFrequencyData(a);let l=a.reduce((h,d)=>h+d,0)/a.length;this.setVolume(l),t.setVolume&&t.setVolume(l),this.animationFrameId=requestAnimationFrame(s)};this.animationFrameId=requestAnimationFrame(s),r(!0)}catch(i){this.stop(),n(`Error: ${i}`)}})}stop(){this.animationFrameId!==null&&cancelAnimationFrame(this.animationFrameId)}getVolume(){return this.volume}setVolume(t){this.volume=t}};var s0=ul(i0()),Zr=class{constructor(t,r,n,i,o){this.blobs=[];this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectPerson:!1,detectFace:!1,detectCellPhone:!1}};this.options={cameraId:void 0,microphoneId:void 0,onBufferSizeError:!1,onBufferSizeErrorCallback:t=>{},proctoringType:"IMAGE",onChangeDevicesCallback:t=>{},onRealtimeAlertsCallback:t=>{}};this.videoOptions={width:640,height:480,minWidth:0,minHeight:0};this.blobsRTC=[];this.imageCount=0;this.filesToUpload=[];this.animationFrameId=null;this.isCanvasLoopActive=!1;this.hardwareStream=null;this.internalClonedStream=null;this.currentRetries=0;this.packageCount=0;this.noiseWait=20;this.options=t,this.videoOptions=r,this.backend=i,this.backendToken=o,n&&(this.paramsConfig=n)}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Yr(this.proctoringId,this.backend)),La(t)}async initializeDetectors(){ag(),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&(this.objectDetection=new Ua({onRealtimeAlertsCallback:t=>this.options.onRealtimeAlertsCallback(t)},this.paramsConfig),await this.objectDetection.initializeDetector()),this.paramsConfig.videoBehaviourParameters?.detectFace&&(this.faceDetection=new Li({onRealtimeAlertsCallback:t=>this.options.onRealtimeAlertsCallback(t)},this.paramsConfig),await this.faceDetection.initializeDetector())}configImageCapture(){this.video=document.createElement("video"),this.canvas=document.createElement("canvas"),this.video.srcObject=this.cameraStream,this.video.play(),this.video.muted=!0,screen.orientation?.type.includes("portrait")&&Fr()?(console.log("configurando canvas em portrait"),this.canvas.width=this.videoOptions.height/2,this.canvas.height=this.videoOptions.width/2):(this.canvas.width=this.videoOptions.width/2,this.canvas.height=this.videoOptions.height/2)}async bufferError(t){console.log("buffer error Camera Recorder params "+this.paramsConfig.videoBehaviourParameters);let r=this.paramsConfig.videoBehaviourParameters?.retryEnabled||!1,n=this.paramsConfig.videoBehaviourParameters?.maxRetries||3;r&&this.currentRetries<n?(console.log("buffer error Camera Recorder retry"),await this.recordingStop(),await this.startRecording({retry:!0}),this.currentRetries++,this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback(this.cameraStream)):this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback()}async startStream(t){let{cameraId:r,microphoneId:n,onBufferSizeErrorCallback:i}=this.options,o={audio:{deviceId:n},video:{deviceId:r,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.hardwareStream=await navigator.mediaDevices.getUserMedia(o)}catch(d){throw d.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":d}this.cameraStream=this.hardwareStream;let a=this.cameraStream.getVideoTracks()[0].getSettings(),{width:c=0,height:l=0}=a;if(screen.orientation?.type.includes("portrait")&&Fr()&&this.videoOptions.width==l&&this.videoOptions.height==c&&([c,l]=[l,c]),this.videoOptions.minWidth>c||this.videoOptions.minHeight>l)throw kd;if(this.videoOptions.width!==c||this.videoOptions.height!==l)throw ue.registerAnotherStream(this.proctoringId,`Maybe have another stream active
81
81
  Video Options: ${JSON.stringify(this.videoOptions,null,2)}
82
- Setting: ${JSON.stringify(a,null,2)}`),Sd}async stopStream(){this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}async startRecording(t){(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone||this.paramsConfig.videoBehaviourParameters?.detectFace)&&!t?.retry&&await this.initializeDetectors();let{cameraId:r,microphoneId:n,onBufferSizeErrorCallback:i}=this.options,o={audio:{deviceId:n},video:{deviceId:r,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.hardwareStream=await navigator.mediaDevices.getUserMedia(o)}catch(_){throw _.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":_}this.cameraStream=this.hardwareStream;let a=this.cameraStream.getVideoTracks()[0].getSettings(),{width:c=0,height:l=0}=a,{startRecording:h,stopRecording:d,pauseRecording:m,resumeRecording:p,recorderOptions:g,getBufferSize:f}=Wn(this.cameraStream,this.blobs,this.videoOptions,this.options.onBufferSizeError,_=>this.bufferError(_),!1);if(this.recordingStart=h,this.recordingStop=d,this.recordingPause=m,this.recordingResume=p,this.recorderOptions=g,this.getBufferSize=f,this.recordingStart(),screen.orientation?.type.includes("portrait")&&Fr()&&this.videoOptions.width==l&&this.videoOptions.height==c&&([c,l]=[l,c]),this.videoOptions.minWidth>c||this.videoOptions.minHeight>l)throw kd;if(this.videoOptions.width!==c||this.videoOptions.height!==l)throw ue.registerAnotherStream(this.proctoringId,`Maybe have another stream active
82
+ Setting: ${JSON.stringify(a,null,2)}`),Sd}async stopStream(){this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}async startRecording(t){console.log("startRecording Camera Recorder"),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone||this.paramsConfig.videoBehaviourParameters?.detectFace)&&!t?.retry&&(console.log("startRecording Camera Recorder initializeDetectors"),await this.initializeDetectors());let{cameraId:r,microphoneId:n,onBufferSizeErrorCallback:i}=this.options,o={audio:{deviceId:n},video:{deviceId:r,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.hardwareStream=await navigator.mediaDevices.getUserMedia(o)}catch(_){throw console.log("startRecording Camera Recorder error",_),_.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":_}this.cameraStream=this.hardwareStream;let a=this.cameraStream.getVideoTracks()[0].getSettings(),{width:c=0,height:l=0}=a,{startRecording:h,stopRecording:d,pauseRecording:m,resumeRecording:p,recorderOptions:g,getBufferSize:f}=Wn(this.cameraStream,this.blobs,this.videoOptions,this.options.onBufferSizeError,_=>this.bufferError(_),!1);if(this.recordingStart=h,this.recordingStop=d,this.recordingPause=m,this.recordingResume=p,this.recorderOptions=g,this.getBufferSize=f,console.log("startRecording Camera Recorder recordingStart"),this.recordingStart(),screen.orientation?.type.includes("portrait")&&Fr()&&this.videoOptions.width==l&&this.videoOptions.height==c&&([c,l]=[l,c]),this.videoOptions.minWidth>c||this.videoOptions.minHeight>l)throw kd;if(this.videoOptions.width!==c||this.videoOptions.height!==l)throw ue.registerAnotherStream(this.proctoringId,`Maybe have another stream active
83
83
  Video Options: ${JSON.stringify(this.videoOptions,null,2)}
84
- Setting: ${JSON.stringify(a,null,2)}`),Sd;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&await this.objectDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&this.captureFrame(),this.packageCount=0}async stopRecording(){this.isCanvasLoopActive=!1,this.recordingStop&&await this.recordingStop();try{this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}catch{console.error("Erro ao parar os streams de m\xEDdia.")}this.faceDetection&&this.faceDetection.detecting&&this.faceDetection.stopDetection(),this.objectDetection&&this.objectDetection.detecting&&this.objectDetection.stopDetection(),clearInterval(this.imageInterval),clearInterval(this.sendFrameInterval),this.options.proctoringType=="REALTIME"&&this.upload&&this.backendToken&&(await this.sendPackage(this.filesToUpload),await this.filesToUpload.splice(0,this.filesToUpload.length)),this.volumeMeter&&this.volumeMeter.stop(),this.intervalNoiseDetection&&clearInterval(this.intervalNoiseDetection)}async pauseRecording(){await this.recordingPause()}async resumeRecording(){await this.recordingResume()}photoShotsCycle(){let t;this.configImageCapture(),this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.videoOptions.width,this.videoOptions.height);let r=this.canvas.toDataURL("image/jpeg");t=await this.getFile(r,`${this.proctoringId}_${this.imageCount+1}.jpg`,"image/jpeg"),t&&this.upload&&this.backendToken&&(this.upload.upload({file:t},this.backendToken,!0),this.imageCount++)},this.paramsConfig.imageBehaviourParameters.uploadInterval*1e3)}async getCurrentImageBase64(){return!this.video||!this.canvas?this.configImageCapture():this.video.srcObject!==this.cameraStream&&(this.video.srcObject=this.cameraStream,await this.video.play()),this.video.paused&&await this.video.play(),await new Promise(t=>{if(this.video.readyState>=2){t();return}let r=()=>{this.video.removeEventListener("loadedmetadata",r),setTimeout(()=>t(),50)};this.video.addEventListener("loadedmetadata",r),setTimeout(()=>{this.video.removeEventListener("loadedmetadata",r),t()},500)}),this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height),this.canvas.toDataURL("image/jpeg")}captureFrame(){let t;this.configImageCapture();let r=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize;this.imageCount=0,this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height);let n=this.canvas.toDataURL("image/jpeg");if(this.proctoringId==null)return;if(r==this.imageCount){this.imageCount=0;let o=[...this.filesToUpload];this.sendPackage(o),await this.filesToUpload.splice(0,this.filesToUpload.length)}let i=`${this.proctoringId}_${this.imageCount+1}.jpg`;t=await this.getFile(n,i,"image/jpeg"),t&&t.size>10&&r>0&&(this.filesToUpload.push(t),this.imageCount++)},this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval*1e3)}async sendPackage(t){let r=!1,n=0,i=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize,o=this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval+1;if(this.upload&&this.backendToken&&!r&&this.filesToUpload.length>0){n=0,r=!0;let s=new s0.default;for(let d of t)s.file(d.name,d);let a=await s.generateAsync({type:"blob"}),c="realtime_package_"+i*o*this.packageCount+".zip",l=new File([a],c,{type:"application/zip"});(await this.upload.uploadPackage({file:l},this.backendToken)).uploaded==!0?this.packageCount++:console.log("erro no upload do pacote"),r=!1}else if(r&&(n++,n==3)){n=0;let s=this.videoOptions.width/2,a=this.videoOptions.height/2;s<320&&(s=320),a<180&&(a=180),this.canvas.width=s,this.canvas.height=a}}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}async saveOnSession(t){this.blobs!=null&&ue.registerSaveOnSession(this.proctoringId,`Blobs Length: ${this.blobs.length} Buffer Size: ${this.getBufferSize()} `);let r=this.cameraStream.getVideoTracks()[0].getSettings(),n=this.cameraStream.getAudioTracks()[0].getSettings();(this.options.proctoringType=="VIDEO"||this.options.proctoringType=="REALTIME"||this.options.proctoringType=="IMAGE"&&this.paramsConfig.imageBehaviourParameters?.saveVideo)&&t.addRecording({device:`Audio
84
+ Setting: ${JSON.stringify(a,null,2)}`),Sd;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&await this.objectDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&this.captureFrame(),this.packageCount=0,console.log("startRecording Camera Recorder finished")}async stopRecording(){this.isCanvasLoopActive=!1,this.recordingStop&&await this.recordingStop();try{this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}catch{console.error("Erro ao parar os streams de m\xEDdia.")}this.faceDetection&&this.faceDetection.detecting&&this.faceDetection.stopDetection(),this.objectDetection&&this.objectDetection.detecting&&this.objectDetection.stopDetection(),clearInterval(this.imageInterval),clearInterval(this.sendFrameInterval),this.options.proctoringType=="REALTIME"&&this.upload&&this.backendToken&&(await this.sendPackage(this.filesToUpload),await this.filesToUpload.splice(0,this.filesToUpload.length)),this.volumeMeter&&this.volumeMeter.stop(),this.intervalNoiseDetection&&clearInterval(this.intervalNoiseDetection)}async pauseRecording(){await this.recordingPause()}async resumeRecording(){await this.recordingResume()}photoShotsCycle(){let t;this.configImageCapture(),this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.videoOptions.width,this.videoOptions.height);let r=this.canvas.toDataURL("image/jpeg");t=await this.getFile(r,`${this.proctoringId}_${this.imageCount+1}.jpg`,"image/jpeg"),t&&this.upload&&this.backendToken&&(this.upload.upload({file:t},this.backendToken,!0),this.imageCount++)},this.paramsConfig.imageBehaviourParameters.uploadInterval*1e3)}async getCurrentImageBase64(){return!this.video||!this.canvas?this.configImageCapture():this.video.srcObject!==this.cameraStream&&(this.video.srcObject=this.cameraStream,await this.video.play()),this.video.paused&&await this.video.play(),await new Promise(t=>{if(this.video.readyState>=2){t();return}let r=()=>{this.video.removeEventListener("loadedmetadata",r),setTimeout(()=>t(),50)};this.video.addEventListener("loadedmetadata",r),setTimeout(()=>{this.video.removeEventListener("loadedmetadata",r),t()},500)}),this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height),this.canvas.toDataURL("image/jpeg")}captureFrame(){let t;this.configImageCapture();let r=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize;this.imageCount=0,this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height);let n=this.canvas.toDataURL("image/jpeg");if(this.proctoringId==null)return;if(r==this.imageCount){this.imageCount=0;let o=[...this.filesToUpload];this.sendPackage(o),await this.filesToUpload.splice(0,this.filesToUpload.length)}let i=`${this.proctoringId}_${this.imageCount+1}.jpg`;t=await this.getFile(n,i,"image/jpeg"),t&&t.size>10&&r>0&&(this.filesToUpload.push(t),this.imageCount++)},this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval*1e3)}async sendPackage(t){let r=!1,n=0,i=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize,o=this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval+1;if(this.upload&&this.backendToken&&!r&&this.filesToUpload.length>0){n=0,r=!0;let s=new s0.default;for(let d of t)s.file(d.name,d);let a=await s.generateAsync({type:"blob"}),c="realtime_package_"+i*o*this.packageCount+".zip",l=new File([a],c,{type:"application/zip"});(await this.upload.uploadPackage({file:l},this.backendToken)).uploaded==!0?this.packageCount++:console.log("erro no upload do pacote"),r=!1}else if(r&&(n++,n==3)){n=0;let s=this.videoOptions.width/2,a=this.videoOptions.height/2;s<320&&(s=320),a<180&&(a=180),this.canvas.width=s,this.canvas.height=a}}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}async saveOnSession(t){this.blobs!=null&&ue.registerSaveOnSession(this.proctoringId,`Blobs Length: ${this.blobs.length} Buffer Size: ${this.getBufferSize()} `);let r=this.cameraStream.getVideoTracks()[0].getSettings(),n=this.cameraStream.getAudioTracks()[0].getSettings();(this.options.proctoringType=="VIDEO"||this.options.proctoringType=="REALTIME"||this.options.proctoringType=="IMAGE"&&this.paramsConfig.imageBehaviourParameters?.saveVideo)&&t.addRecording({device:`Audio
85
85
  Sample Rate: ${n.sampleRate}
86
86
  Sample Size: ${n.sampleSize}
87
87
 
@@ -396,7 +396,7 @@ Para iniciar um exame utilize uma outra c\xE2mera.`),o.setAttribute("class","che
396
396
  // -webkit-mask-position: center;
397
397
  // -webkit-mask-repeat: no-repeat;
398
398
  }
399
- `,r=document.createElement("style");r.innerHTML=t,document.head.appendChild(r)}applyStyles(t,r){for(let[n,i]of Object.entries(r))t.style[n]=i}};var za=class e{constructor(t){this.deviceCheckResult=null;this.videoOptions={width:1080,height:720,minWidth:0,minHeight:0};this.volumeMedia=0;this.volumeSum=0;this.volumeCounter=0;this.microphoneMinThreshold=5;this.allowedResolution=!0;this.allowedAmbient=!0;this.allowedPositionFace=!0;this.allowedMicrophone=!1;this.allowedSpyScan=null;this.noiseLimit=0;this.faceDetection=new Li({onRealtimeAlertsCallback:r=>this.realtimeAlerts(r)},{videoBehaviourParameters:{detectFace:!0}},"cameraStream","liveCheckDevices"),this.context=t,this.backend=new nr({type:t?.type||"prod",token:t.token})}static{this.isModalOpen=!1}getDeviceCheckResult(){return this.deviceCheckResult}async runCheckDevicesFlow(t,r,n,i,o){if(e.isModalOpen)return Promise.reject("Modal j\xE1 est\xE1 aberto");this.options={...ir,...t,captureScreen:!1,allowMultipleMonitors:!0,allowOnlyFirstMonitor:!1},e.isModalOpen=!0;try{await this.faceDetection.initializeDetector();let{cameraStream:s}=await this.startCheckDevices(t,r);this.checkSpyScan();let a={cameraStream:this.cameraRecorder.cameraStream};this.onUpdateCb=l=>o(l);let c=new Promise((l,h)=>{n(()=>{this.closeCheckDevices(),l({result:!0,cameraId:t.cameraId||"default",microphoneId:t.microphoneId||"default",volumeRange:this.volumeMedia,allowedResolution:this.allowedResolution,allowedPositionFace:this.allowedPositionFace,allowedAmbient:this.allowedAmbient,allowedMicrophone:this.allowedMicrophone,allowedSpyScan:this.allowedSpyScan,faceDetectionAlerts:this.faceDetectionAlerts}),e.isModalOpen=!1}),i(()=>{this.closeCheckDevices(),l({result:!1}),e.isModalOpen=!1})});return this.deviceCheckResult={...a,result:c},{...a,result:c}}catch(s){throw this.closeCheckDevices(),e.isModalOpen=!1,s}}onUpdateCallback(){typeof this.onUpdateCb=="function"&&this.onUpdateCb({allowedResolution:this.allowedResolution,allowedPositionFace:this.allowedPositionFace,allowedAmbient:this.allowedAmbient,allowedMicrophone:this.allowedMicrophone,allowedSpyScan:this.allowedSpyScan,faceDetectionAlerts:this.faceDetectionAlerts})}async checkDevices(t=ir,r=Gg){if(e.isModalOpen)return Promise.reject();e.isModalOpen=!0,this.DeviceCheckerUI=new Na(t,r);try{this.options={...ir,...t,captureScreen:!1,allowMultipleMonitors:!0,allowOnlyFirstMonitor:!1},this.videoOptions={...this.videoOptions,...r};let n=await this.backend.getParamsConfig(this.context);this.noiseLimit=n.audioBehaviourParameters?.noiseLimit||40,await this.faceDetection.initializeDetector(),this.DeviceCheckerUI.checkDevicesInterface(),this.startCheckDevices(t,r),await this.checkSpyScan();let{cameraId:i,microphoneId:o,result:s}=await this.DeviceCheckerUI.modalActions(()=>this.closeCheckDevices());return new Promise(a=>{let c={result:s,cameraId:i,microphoneId:o,volumeRange:this.volumeMedia,allowedResolution:this.allowedResolution,allowedPositionFace:this.allowedPositionFace,allowedAmbient:this.allowedAmbient,allowedMicrophone:this.allowedMicrophone,allowedSpyScan:this.allowedSpyScan,faceDetectionAlerts:this.faceDetectionAlerts};this.deviceCheckResult=c,a(c)})}catch(n){return this.closeCheckDevices(),this.DeviceCheckerUI.closeModal(),Promise.reject(n)}}isUnderResolution(){let t=this.cameraRecorder.cameraStream.getVideoTracks()[0].getSettings(),{width:r=0,height:n=0}=t;screen.orientation?.type.includes("portrait")&&Fr()&&this.videoOptions.width==n&&this.videoOptions.height==r&&([r,n]=[n,r]),this.videoOptions.minWidth>r||this.videoOptions.minHeight>n?this.allowedResolution=!1:this.allowedResolution=!0,this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.isUnderResolutionUI(this.allowedResolution)}realtimeAlerts(t){this.faceDetectionAlerts=t,t.status==="OK"?(this.allowedPositionFace=!0,this.allowedAmbient=!0):(this.allowedPositionFace=!1,this.allowedAmbient=!1),this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.realtimeAlertsUI(t)}videoDeviceInterface(t){this.DeviceCheckerUI&&this.DeviceCheckerUI.videoDeviceInterfaceUI(t),this.isUnderResolution(),this.faceDetection.enableCam(t)}audioDeviceInterface(t){this.volumeMeter=new gn(this.cameraRecorder.cameraStream),this.volumeMeter.start({setVolume:r=>{this.volumeCounter++,this.volumeSum+=r,!this.allowedMicrophone&&r>this.microphoneMinThreshold?(this.allowedMicrophone=!0,this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIMicrophoneWorks(!0)):this.allowedMicrophone||this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIMicrophoneWorks(!1),this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIPills(r),r>this.noiseLimit?(this.allowedAmbient=!1,this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIAllowedAmbient(!1)):(this.allowedAmbient=!0,this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIAllowedAmbient(!0))}}).catch(r=>{console.log(r),this.volumeMeter=void 0,this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIErrorExec()})}async changeSelectedDevice({cameraId:t,microphoneId:r}){return this.cameraRecorder.stopRecording&&await this.cameraRecorder.stopRecording(),this.volumeMeter?.stop(),this.faceDetection.stopDetection(),this.cameraRecorder=new Zr({cameraId:t,microphoneId:r,onBufferSizeError:!1,onBufferSizeErrorCallback:()=>{}},{width:this.videoOptions.width,height:this.videoOptions.height}),await this.cameraRecorder.startRecording(),this.videoDeviceInterface(this.cameraRecorder.cameraStream),this.audioDeviceInterface(this.cameraRecorder.cameraStream),{cameraStream:this.cameraRecorder.cameraStream}}async startCheckDevices(t=ir,r){if(this.DeviceCheckerUI&&this.DeviceCheckerUI.setSelectOption(t,n=>this.changeSelectedDevice(n)),this.videoOptions=Oa(r),await vs(),this.cameraRecorder=new Zr({cameraId:t.cameraId,microphoneId:t.microphoneId,onBufferSizeError:!1,onBufferSizeErrorCallback:()=>{}},{width:this.videoOptions.width,height:this.videoOptions.height}),await this.cameraRecorder.startRecording(),this.videoDeviceInterface(this.cameraRecorder.cameraStream),this.audioDeviceInterface(this.cameraRecorder.cameraStream),this.DeviceCheckerUI){let n=document.querySelector("#confirmBtn");!this.options.useSpyScan&&(n.disabled=!1)}return{cameraStream:this.cameraRecorder.cameraStream}}async closeCheckDevices(){e.isModalOpen=!1,this.faceDetection.stopDetection(),this.volumeMeter?.stop(),this.volumeMedia=Math.ceil(this.volumeSum/this.volumeCounter),this.cameraRecorder.stopRecording&&await this.cameraRecorder.stopRecording(),this.DeviceCheckerUI=void 0,this.onUpdateCb=void 0}async checkSpyScan(){if(this.spycam=new Vi(this.context,{}),this.allowedSpyScan=null,this.options.useSpyScan){this.DeviceCheckerUI&&this.DeviceCheckerUI.waitingSpyDevices(!0);try{await this.spycam.isPluggedIn()?await this.spycam.devices({deviceType:3}).then(r=>{r?.length>0?this.allowedSpyScan=!1:this.allowedSpyScan=!0}).finally(()=>{this.DeviceCheckerUI&&this.DeviceCheckerUI.waitingSpyDevices(!1),this.DeviceCheckerUI&&this.allowedSpyScan!=null&&this.DeviceCheckerUI.isSpyDevicesUI(this.allowedSpyScan)}):(this.allowedSpyScan=!1,this.DeviceCheckerUI&&this.DeviceCheckerUI.waitingSpyDevices(!1),this.DeviceCheckerUI&&this.DeviceCheckerUI.isSpyDevicesUI(this.allowedSpyScan))}catch(t){this.allowedSpyScan=!1,this.DeviceCheckerUI&&this.DeviceCheckerUI.waitingSpyDevices(!1),this.DeviceCheckerUI&&this.DeviceCheckerUI.isSpyDevicesUI(this.allowedSpyScan),console.log(t)}}}};var Hi=class{constructor(){}async takePicture(t,r,n={width:1080,height:720}){return this.resolution=n,await this.takePictureInterface(t,r)}async startCapture(t="default"){let r=document.querySelector("#cameraStream"),n={audio:!1,video:{facingMode:"user",aspectRatio:1.777777778,width:{min:640,ideal:640,max:1920},height:{min:400,ideal:480},deviceId:t}};this.cameraRecorder=new Zr({cameraId:t,onBufferSizeErrorCallback:()=>{}},{...this.resolution}),await this.cameraRecorder.startRecording(),r.srcObject=this.cameraRecorder.cameraStream,r.play().catch(i=>{console.warn("Autoplay bloqueado ou erro ao iniciar v\xEDdeo:",i)})}shot(){let t=document.querySelector("#cameraStream"),r=document.querySelector("#canvas"),n=document.querySelector("#image");r.width=t.videoWidth,r.height=t.videoHeight,r.getContext("2d").drawImage(t,0,0,t.videoWidth,t.videoHeight),n.src=r.toDataURL("image/jpg"),this.base64=r.toDataURL("image/jpg")}takePictureInterface(t,r){return new Promise((n,i)=>{let o=document.createElement("div");o.setAttribute("id","authPhoto"),o.style.backgroundColor="rgba(0,0,0,0.4)",o.style.zIndex="1000",o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.height="100vh",o.style.width="100%",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center";let s=document.createElement("div");s.style.backgroundColor="#fff",s.style.zIndex="1001",s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.height="100vh",s.style.width="100%",s.style.borderRadius="10px",s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="center",s.style.boxSizing="border-box";let a=document.createElement("h3");a.innerText=t||"Biometria Facial",a.style.color="rgba(0, 0, 0, .7)",a.style.fontWeight="bold",a.style.fontSize="20px",a.style.marginTop="0px",a.style.marginBottom="15px",a.style.padding="20px 0px 0px",a.style.width="100%",a.style.textAlign="center",a.style.position="fixed",a.style.top="0",a.style.left="0",a.style.zIndex="1010",s.appendChild(a);let c=document.createElement("p");c.innerText=r||"Encaixe seu rosto no formato e clique no bot\xE3o abaixo",c.style.color="rgba(0, 0, 0, .7)",c.style.fontWeight="normal",c.style.fontSize="16px",c.style.marginBottom="15px",c.style.padding="0px 0px 20px",c.style.width="100%",c.style.textAlign="center",c.style.position="fixed",c.style.top="55px",c.style.left="0",c.style.zIndex="1011",s.appendChild(c);let l=document.createElement("div"),h=document.createElement("h3"),d=document.createElement("select");d.setAttribute("id","cameraSelect"),l.style.padding="0 20px",l.style.width="100%",l.style.display="flex",l.style.justifyContent="space-between",l.style.marginBottom="15px",h.innerText="C\xE2mera",h.style.color="rgba(0, 0, 0, .75)",h.style.fontWeight="bold",h.style.fontSize="16px",l.appendChild(h),l.appendChild(d);let m=document.createElement("div"),p=document.createElement("video");p.setAttribute("id","cameraStream"),p.muted=!0,p.setAttribute("playsinline","true"),p.setAttribute("webkit-playsinline","true"),p.autoplay=!0,m.style.position="fixed",m.style.top="0",m.style.left="0",m.style.height="100vh",m.style.width="100%",m.style.display="flex",m.style.justifyContent="center",p.style.backgroundColor="#000",p.style.borderRadius="10px",p.style.width="auto",p.style.height="auto",p.style.minHeight="100%",m.appendChild(p);let g=document.createElement("canvas");g.setAttribute("id","canvas"),g.style.display="none",g.style.width="100%",g.style.height="100%";let f=document.createElement("img");f.setAttribute("id","image"),f.style.objectFit="contain",f.style.display="none",f.style.borderRadius="8px",m.appendChild(g),m.appendChild(f);let b=document.createElement("div");b.setAttribute("class","facial-biometry__mask"),b.style.width="100%",b.style.height="100%",b.style.position="absolute",b.style.top="0px",b.style.left="0px",b.style.backgroundColor="#fff",b.style.opacity="0.8";let _=document.createElement("div");_.setAttribute("class","biometry__frame"),_.style.width="100%",_.style.height="100%",_.style.position="absolute",_.style.top="0px",_.style.left="0px",_.style.zIndex="10",m.appendChild(b),m.appendChild(_),s.appendChild(m),this.addStyleMask();let S=document.createElement("button"),k=document.createElement("div");S.setAttribute("id","confirmBtn"),k.style.position="fixed",k.style.bottom="0",k.style.left="0",k.style.width="100%",k.style.display="flex",k.style.alignItems="center",k.style.justifyContent="center",S.style.background="url('https://iarisprod.blob.core.windows.net/imagens/camera.svg') no-repeat center",S.style.width="70px",S.style.height="70px",S.style.borderRadius="70px",S.style.border="none",S.style.backgroundColor="#16a34a",S.style.margin="20px";let I=document.createElement("button");I.setAttribute("id","closeModal"),I.style.background="url('https://iarisprod.blob.core.windows.net/imagens/close.svg') no-repeat center",I.style.width="70px",I.style.height="70px",I.style.borderRadius="70px",I.style.border="none",I.style.backgroundColor="#e74141",I.style.margin="20px",k.appendChild(I),k.appendChild(S),s.appendChild(k);let x=document.createElement("button");x.style.background="url('https://easyproctor-public.s3.us-east-2.amazonaws.com/images/retry.svg') no-repeat center",x.style.width="70px",x.style.height="70px",x.style.borderRadius="70px",x.style.border="none",x.style.backgroundColor="#e74141",x.style.margin="20px 20px";let O=document.createElement("button");O.style.background="url('https://iarisprod.blob.core.windows.net/imagens/check.svg') no-repeat center",O.style.width="70px",O.style.height="70px",O.style.borderRadius="70px",O.style.border="none",O.style.backgroundColor="#16a34a",O.style.margin="20px 20px",o.appendChild(s),document.body.appendChild(o),this.setSelectOption(),this.startCapture(),S.addEventListener("click",()=>{k.removeChild(S),k.removeChild(I),k.appendChild(x),k.appendChild(O),this.shot(),p.style.display="none",f.style.display="block"}),x.addEventListener("click",()=>{k.appendChild(I),k.appendChild(S),k.removeChild(x),k.removeChild(O),p.style.display="block",f.style.display="none"}),O.addEventListener("click",()=>{this.closeInterface(),n({base64:this.base64})}),I.addEventListener("click",()=>{this.closeInterface(),i(new Error("User does not captured photo"))})})}async setSelectOption(){let t=document.querySelector("#cameraSelect"),r=await ur();t&&(t.value="default");let n=(i,o)=>{let s=document.createElement("option");return s.setAttribute("value",o),s.innerHTML=i,s};r.cameras.forEach(i=>{let o=n(i.label,i.id);t?.appendChild(o)}),this.onSelectOptionChange()}async onSelectOptionChange(){let t=document.querySelector("#cameraSelect");t?.addEventListener("change",async()=>{this.startCapture(t?.value)})}async closeInterface(){await this.cameraRecorder.stopRecording(),document.querySelector("#authPhoto")?.remove()}async addStyleMask(){let t=`
399
+ `,r=document.createElement("style");r.innerHTML=t,document.head.appendChild(r)}applyStyles(t,r){for(let[n,i]of Object.entries(r))t.style[n]=i}};var za=class e{constructor(t){this.deviceCheckResult=null;this.videoOptions={width:1080,height:720,minWidth:0,minHeight:0};this.volumeMedia=0;this.volumeSum=0;this.volumeCounter=0;this.microphoneMinThreshold=5;this.allowedResolution=!0;this.allowedAmbient=!0;this.allowedPositionFace=!0;this.allowedMicrophone=!1;this.allowedSpyScan=null;this.noiseLimit=0;this.faceDetection=new Li({onRealtimeAlertsCallback:r=>this.realtimeAlerts(r)},{videoBehaviourParameters:{detectFace:!0}},"cameraStream","liveCheckDevices"),this.context=t,this.backend=new nr({type:t?.type||"prod",token:t.token})}static{this.isModalOpen=!1}getDeviceCheckResult(){return this.deviceCheckResult}async runCheckDevicesFlow(t,r,n,i,o){if(e.isModalOpen)return Promise.reject("Modal j\xE1 est\xE1 aberto");this.options={...ir,...t,captureScreen:!1,allowMultipleMonitors:!0,allowOnlyFirstMonitor:!1},e.isModalOpen=!0;try{await this.faceDetection.initializeDetector();let{cameraStream:s}=await this.startCheckDevices(t,r);this.options?.useSpyScan&&await this.checkSpyScan();let a={cameraStream:this.cameraRecorder.cameraStream};this.onUpdateCb=l=>o(l);let c=new Promise((l,h)=>{n(()=>{this.closeCheckDevices(),l({result:!0,cameraId:t.cameraId||"default",microphoneId:t.microphoneId||"default",volumeRange:this.volumeMedia,allowedResolution:this.allowedResolution,allowedPositionFace:this.allowedPositionFace,allowedAmbient:this.allowedAmbient,allowedMicrophone:this.allowedMicrophone,allowedSpyScan:this.allowedSpyScan,faceDetectionAlerts:this.faceDetectionAlerts}),e.isModalOpen=!1}),i(()=>{this.closeCheckDevices(),l({result:!1}),e.isModalOpen=!1})});return this.deviceCheckResult={...a,result:c},{...a,result:c}}catch(s){throw this.closeCheckDevices(),e.isModalOpen=!1,s}}onUpdateCallback(){typeof this.onUpdateCb=="function"&&this.onUpdateCb({allowedResolution:this.allowedResolution,allowedPositionFace:this.allowedPositionFace,allowedAmbient:this.allowedAmbient,allowedMicrophone:this.allowedMicrophone,allowedSpyScan:this.allowedSpyScan,faceDetectionAlerts:this.faceDetectionAlerts})}async checkDevices(t=ir,r=Gg){if(e.isModalOpen)return Promise.reject();console.log("checkDevices started"),this.allowedMicrophone=!1,this.allowedResolution=!1,this.allowedAmbient=!1,this.allowedPositionFace=!1,e.isModalOpen=!0,this.DeviceCheckerUI=new Na(t,r);try{this.options={...ir,...t,captureScreen:!1,allowMultipleMonitors:!0,allowOnlyFirstMonitor:!1},this.videoOptions={...this.videoOptions,...r};let n=await this.backend.getParamsConfig(this.context);this.noiseLimit=n.audioBehaviourParameters?.noiseLimit||40,await this.faceDetection.initializeDetector(),this.DeviceCheckerUI.checkDevicesInterface(),this.startCheckDevices(t,r),await this.checkSpyScan();let{cameraId:i,microphoneId:o,result:s}=await this.DeviceCheckerUI.modalActions(()=>this.closeCheckDevices());return new Promise(a=>{let c={result:s,cameraId:i,microphoneId:o,volumeRange:this.volumeMedia,allowedResolution:this.allowedResolution,allowedPositionFace:this.allowedPositionFace,allowedAmbient:this.allowedAmbient,allowedMicrophone:this.allowedMicrophone,allowedSpyScan:this.allowedSpyScan,faceDetectionAlerts:this.faceDetectionAlerts};this.deviceCheckResult=c,a(c)})}catch(n){return this.DeviceCheckerUI&&this.DeviceCheckerUI.closeModal(),this.closeCheckDevices(),Promise.reject(n)}}isUnderResolution(){let t=this.cameraRecorder.cameraStream.getVideoTracks()[0].getSettings(),{width:r=0,height:n=0}=t;screen.orientation?.type.includes("portrait")&&Fr()&&this.videoOptions.width==n&&this.videoOptions.height==r&&([r,n]=[n,r]),this.videoOptions.minWidth>r||this.videoOptions.minHeight>n?this.allowedResolution=!1:this.allowedResolution=!0,this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.isUnderResolutionUI(this.allowedResolution)}realtimeAlerts(t){this.faceDetectionAlerts=t,t.status==="OK"?(this.allowedPositionFace=!0,this.allowedAmbient=!0):(this.allowedPositionFace=!1,this.allowedAmbient=!1),this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.realtimeAlertsUI(t)}videoDeviceInterface(t){this.DeviceCheckerUI&&this.DeviceCheckerUI.videoDeviceInterfaceUI(t),this.isUnderResolution(),this.faceDetection.enableCam(t)}audioDeviceInterface(t){this.volumeMeter=new gn(this.cameraRecorder.cameraStream),this.volumeMeter.start({setVolume:r=>{this.volumeCounter++,this.volumeSum+=r,!this.allowedMicrophone&&r>this.microphoneMinThreshold?(this.allowedMicrophone=!0,this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIMicrophoneWorks(!0)):this.allowedMicrophone||this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIMicrophoneWorks(!1),this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIPills(r),r>this.noiseLimit?(this.allowedAmbient=!1,this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIAllowedAmbient(!1)):(this.allowedAmbient=!0,this.onUpdateCallback(),this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIAllowedAmbient(!0))}}).catch(r=>{console.log(r),this.volumeMeter=void 0,this.DeviceCheckerUI&&this.DeviceCheckerUI.audioDeviceInterfaceUIErrorExec()})}async changeSelectedDevice({cameraId:t,microphoneId:r}){return await this.cameraRecorder.stopStream(),this.volumeMeter?.stop(),this.faceDetection.stopDetection(),this.cameraRecorder=new Zr({cameraId:t,microphoneId:r,onBufferSizeError:!1,onBufferSizeErrorCallback:()=>{}},{width:this.videoOptions.width,height:this.videoOptions.height}),await this.cameraRecorder.startStream(),this.videoDeviceInterface(this.cameraRecorder.cameraStream),this.audioDeviceInterface(this.cameraRecorder.cameraStream),{cameraStream:this.cameraRecorder.cameraStream}}async startCheckDevices(t=ir,r){if(this.allowedMicrophone=!1,this.allowedResolution=!1,this.allowedAmbient=!1,this.allowedPositionFace=!1,this.DeviceCheckerUI&&this.DeviceCheckerUI.setSelectOption(t,n=>this.changeSelectedDevice(n)),this.videoOptions=Oa(r),await vs(),this.cameraRecorder=new Zr({cameraId:t.cameraId,microphoneId:t.microphoneId,onBufferSizeError:!1,onBufferSizeErrorCallback:()=>{}},{width:this.videoOptions.width,height:this.videoOptions.height}),await this.cameraRecorder.startStream(),this.videoDeviceInterface(this.cameraRecorder.cameraStream),this.audioDeviceInterface(this.cameraRecorder.cameraStream),this.DeviceCheckerUI){let n=document.querySelector("#confirmBtn");!this.options.useSpyScan&&(n.disabled=!1)}return{cameraStream:this.cameraRecorder.cameraStream}}async closeCheckDevices(){e.isModalOpen=!1,this.faceDetection.stopDetection(),this.volumeMeter?.stop(),this.volumeMedia=Math.ceil(this.volumeSum/this.volumeCounter),await this.cameraRecorder.stopStream(),this.DeviceCheckerUI=void 0,this.onUpdateCb=void 0}async checkSpyScan(){if(this.spycam=new Vi(this.context,{}),this.allowedSpyScan=null,this.options.useSpyScan){this.DeviceCheckerUI&&this.DeviceCheckerUI.waitingSpyDevices(!0);try{await this.spycam.isPluggedIn()?await this.spycam.devices({deviceType:3}).then(r=>{r?.length>0?this.allowedSpyScan=!1:this.allowedSpyScan=!0}).finally(()=>{this.DeviceCheckerUI&&this.DeviceCheckerUI.waitingSpyDevices(!1),this.DeviceCheckerUI&&this.allowedSpyScan!=null&&this.DeviceCheckerUI.isSpyDevicesUI(this.allowedSpyScan)}):(this.allowedSpyScan=!1,this.DeviceCheckerUI&&this.DeviceCheckerUI.waitingSpyDevices(!1),this.DeviceCheckerUI&&this.DeviceCheckerUI.isSpyDevicesUI(this.allowedSpyScan))}catch(t){this.allowedSpyScan=!1,this.DeviceCheckerUI&&this.DeviceCheckerUI.waitingSpyDevices(!1),this.DeviceCheckerUI&&this.DeviceCheckerUI.isSpyDevicesUI(this.allowedSpyScan),console.log(t)}}}};var Hi=class{constructor(){}async takePicture(t,r,n={width:1080,height:720}){return this.resolution=n,await this.takePictureInterface(t,r)}async startCapture(t="default"){let r=document.querySelector("#cameraStream"),n={audio:!1,video:{facingMode:"user",aspectRatio:1.777777778,width:{min:640,ideal:640,max:1920},height:{min:400,ideal:480},deviceId:t}};this.cameraRecorder=new Zr({cameraId:t,onBufferSizeErrorCallback:()=>{}},{...this.resolution}),await this.cameraRecorder.startRecording(),r.srcObject=this.cameraRecorder.cameraStream,r.play().catch(i=>{console.warn("Autoplay bloqueado ou erro ao iniciar v\xEDdeo:",i)})}shot(){let t=document.querySelector("#cameraStream"),r=document.querySelector("#canvas"),n=document.querySelector("#image");r.width=t.videoWidth,r.height=t.videoHeight,r.getContext("2d").drawImage(t,0,0,t.videoWidth,t.videoHeight),n.src=r.toDataURL("image/jpg"),this.base64=r.toDataURL("image/jpg")}takePictureInterface(t,r){return new Promise((n,i)=>{let o=document.createElement("div");o.setAttribute("id","authPhoto"),o.style.backgroundColor="rgba(0,0,0,0.4)",o.style.zIndex="1000",o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.height="100vh",o.style.width="100%",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center";let s=document.createElement("div");s.style.backgroundColor="#fff",s.style.zIndex="1001",s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.height="100vh",s.style.width="100%",s.style.borderRadius="10px",s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="center",s.style.boxSizing="border-box";let a=document.createElement("h3");a.innerText=t||"Biometria Facial",a.style.color="rgba(0, 0, 0, .7)",a.style.fontWeight="bold",a.style.fontSize="20px",a.style.marginTop="0px",a.style.marginBottom="15px",a.style.padding="20px 0px 0px",a.style.width="100%",a.style.textAlign="center",a.style.position="fixed",a.style.top="0",a.style.left="0",a.style.zIndex="1010",s.appendChild(a);let c=document.createElement("p");c.innerText=r||"Encaixe seu rosto no formato e clique no bot\xE3o abaixo",c.style.color="rgba(0, 0, 0, .7)",c.style.fontWeight="normal",c.style.fontSize="16px",c.style.marginBottom="15px",c.style.padding="0px 0px 20px",c.style.width="100%",c.style.textAlign="center",c.style.position="fixed",c.style.top="55px",c.style.left="0",c.style.zIndex="1011",s.appendChild(c);let l=document.createElement("div"),h=document.createElement("h3"),d=document.createElement("select");d.setAttribute("id","cameraSelect"),l.style.padding="0 20px",l.style.width="100%",l.style.display="flex",l.style.justifyContent="space-between",l.style.marginBottom="15px",h.innerText="C\xE2mera",h.style.color="rgba(0, 0, 0, .75)",h.style.fontWeight="bold",h.style.fontSize="16px",l.appendChild(h),l.appendChild(d);let m=document.createElement("div"),p=document.createElement("video");p.setAttribute("id","cameraStream"),p.muted=!0,p.setAttribute("playsinline","true"),p.setAttribute("webkit-playsinline","true"),p.autoplay=!0,m.style.position="fixed",m.style.top="0",m.style.left="0",m.style.height="100vh",m.style.width="100%",m.style.display="flex",m.style.justifyContent="center",p.style.backgroundColor="#000",p.style.borderRadius="10px",p.style.width="auto",p.style.height="auto",p.style.minHeight="100%",m.appendChild(p);let g=document.createElement("canvas");g.setAttribute("id","canvas"),g.style.display="none",g.style.width="100%",g.style.height="100%";let f=document.createElement("img");f.setAttribute("id","image"),f.style.objectFit="contain",f.style.display="none",f.style.borderRadius="8px",m.appendChild(g),m.appendChild(f);let b=document.createElement("div");b.setAttribute("class","facial-biometry__mask"),b.style.width="100%",b.style.height="100%",b.style.position="absolute",b.style.top="0px",b.style.left="0px",b.style.backgroundColor="#fff",b.style.opacity="0.8";let _=document.createElement("div");_.setAttribute("class","biometry__frame"),_.style.width="100%",_.style.height="100%",_.style.position="absolute",_.style.top="0px",_.style.left="0px",_.style.zIndex="10",m.appendChild(b),m.appendChild(_),s.appendChild(m),this.addStyleMask();let S=document.createElement("button"),k=document.createElement("div");S.setAttribute("id","confirmBtn"),k.style.position="fixed",k.style.bottom="0",k.style.left="0",k.style.width="100%",k.style.display="flex",k.style.alignItems="center",k.style.justifyContent="center",S.style.background="url('https://iarisprod.blob.core.windows.net/imagens/camera.svg') no-repeat center",S.style.width="70px",S.style.height="70px",S.style.borderRadius="70px",S.style.border="none",S.style.backgroundColor="#16a34a",S.style.margin="20px";let I=document.createElement("button");I.setAttribute("id","closeModal"),I.style.background="url('https://iarisprod.blob.core.windows.net/imagens/close.svg') no-repeat center",I.style.width="70px",I.style.height="70px",I.style.borderRadius="70px",I.style.border="none",I.style.backgroundColor="#e74141",I.style.margin="20px",k.appendChild(I),k.appendChild(S),s.appendChild(k);let x=document.createElement("button");x.style.background="url('https://easyproctor-public.s3.us-east-2.amazonaws.com/images/retry.svg') no-repeat center",x.style.width="70px",x.style.height="70px",x.style.borderRadius="70px",x.style.border="none",x.style.backgroundColor="#e74141",x.style.margin="20px 20px";let O=document.createElement("button");O.style.background="url('https://iarisprod.blob.core.windows.net/imagens/check.svg') no-repeat center",O.style.width="70px",O.style.height="70px",O.style.borderRadius="70px",O.style.border="none",O.style.backgroundColor="#16a34a",O.style.margin="20px 20px",o.appendChild(s),document.body.appendChild(o),this.setSelectOption(),this.startCapture(),S.addEventListener("click",()=>{k.removeChild(S),k.removeChild(I),k.appendChild(x),k.appendChild(O),this.shot(),p.style.display="none",f.style.display="block"}),x.addEventListener("click",()=>{k.appendChild(I),k.appendChild(S),k.removeChild(x),k.removeChild(O),p.style.display="block",f.style.display="none"}),O.addEventListener("click",()=>{this.closeInterface(),n({base64:this.base64})}),I.addEventListener("click",()=>{this.closeInterface(),i(new Error("User does not captured photo"))})})}async setSelectOption(){let t=document.querySelector("#cameraSelect"),r=await ur();t&&(t.value="default");let n=(i,o)=>{let s=document.createElement("option");return s.setAttribute("value",o),s.innerHTML=i,s};r.cameras.forEach(i=>{let o=n(i.label,i.id);t?.appendChild(o)}),this.onSelectOptionChange()}async onSelectOptionChange(){let t=document.querySelector("#cameraSelect");t?.addEventListener("change",async()=>{this.startCapture(t?.value)})}async closeInterface(){await this.cameraRecorder.stopRecording(),document.querySelector("#authPhoto")?.remove()}async addStyleMask(){let t=`
400
400
  .facial-biometry__mask {
401
401
  mask-image: url('https://iarisprod.blob.core.windows.net/imagens/square.svg'), url('https://iarisprod.blob.core.windows.net/imagens/face-mask.svg');
402
402
  mask-size: cover, auto 65%;