easyproctor-hml 0.0.59 → 0.0.60

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
@@ -21927,7 +21927,7 @@ Setting: ${settings}`);
21927
21927
  const size = this.filesToUpload.length;
21928
21928
  const packSize = this.paramsConfig.imageBehaviourParameters.uploadInterval;
21929
21929
  for (let i3 = 0; i3 < size; i3++) {
21930
- if (i3 == size - 1) {
21930
+ if (i3 == size - 1 && this.filesToUpload[0]) {
21931
21931
  const imageName = this.filesToUpload[0].name.replace(".jpg", "_realtime.jpg");
21932
21932
  const file = new File([this.filesToUpload[0]], imageName, { type: "image/jpeg" });
21933
21933
  this.filesToUpload[0] = file;
@@ -22062,7 +22062,7 @@ Setting: ${settings}`);
22062
22062
  if (this.noiseWait >= 20) {
22063
22063
  this.options.onRealtimeAlertsCallback({
22064
22064
  status: "ALERT",
22065
- description: "noise",
22065
+ description: "Barulho detectado",
22066
22066
  type: "audio_detection_on_stream"
22067
22067
  });
22068
22068
  this.noiseWait = 0;
@@ -26040,7 +26040,7 @@ var NoiseRecorder = class {
26040
26040
  if (((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectSpeech) && this.isSpeech) {
26041
26041
  this.onRealtimeAlertsCallback({
26042
26042
  status: "ALERT",
26043
- description: "speech",
26043
+ description: "Fala detectada",
26044
26044
  type: "audio_detection_on_stream"
26045
26045
  });
26046
26046
  }
package/index.js CHANGED
@@ -33475,7 +33475,7 @@ Setting: ${settings}`);
33475
33475
  const size = this.filesToUpload.length;
33476
33476
  const packSize = this.paramsConfig.imageBehaviourParameters.uploadInterval;
33477
33477
  for (let i3 = 0; i3 < size; i3++) {
33478
- if (i3 == size - 1) {
33478
+ if (i3 == size - 1 && this.filesToUpload[0]) {
33479
33479
  const imageName = this.filesToUpload[0].name.replace(".jpg", "_realtime.jpg");
33480
33480
  const file = new File([this.filesToUpload[0]], imageName, { type: "image/jpeg" });
33481
33481
  this.filesToUpload[0] = file;
@@ -33610,7 +33610,7 @@ Setting: ${settings}`);
33610
33610
  if (this.noiseWait >= 20) {
33611
33611
  this.options.onRealtimeAlertsCallback({
33612
33612
  status: "ALERT",
33613
- description: "noise",
33613
+ description: "Barulho detectado",
33614
33614
  type: "audio_detection_on_stream"
33615
33615
  });
33616
33616
  this.noiseWait = 0;
@@ -37588,7 +37588,7 @@ var NoiseRecorder = class {
37588
37588
  if (((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectSpeech) && this.isSpeech) {
37589
37589
  this.onRealtimeAlertsCallback({
37590
37590
  status: "ALERT",
37591
- description: "speech",
37591
+ description: "Fala detectada",
37592
37592
  type: "audio_detection_on_stream"
37593
37593
  });
37594
37594
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor-hml",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -72,9 +72,9 @@ bitsperframe: %d
72
72
  }
73
73
  `,document.getElementsByTagName("head")[0].appendChild(i)}async predictWebcam(){this.lastVideoTime===-1&&await this.detector.setOptions({runningMode:"VIDEO"});let t=Date.now();if(this.video.currentTime!==this.lastVideoTime){this.lastVideoTime=this.video.currentTime;let r=this.detector.detectForVideo(this.video,t);this.verify(r)}this.animationFrameId=window.requestAnimationFrame(()=>this.predictWebcam())}handleAlert(t,r){this.options.onRealtimeAlertsCallback&&this.options.onRealtimeAlertsCallback({status:"ALERT",description:this.alertTranslate(t),type:r}),this.error&&(this.error.innerText=t)}handleOk(t){this.options.onRealtimeAlertsCallback&&this.options.onRealtimeAlertsCallback({status:"OK",type:t}),this.error&&(this.error.innerText="")}displayVideoDetections(t){}verify(t){}alertTranslate(t){switch(t){case"multiple_faces_detected":return"M\xFAltiplas faces detectadas";case"no_face_detected":return"Nenhuma face encontrada";case"multiple_persons_detected":return"M\xFAltiplas pessoas detectadas";case"no_person_detected":return"Nenhuma pessoa encontrada";case"cellphone_detected":return"Celular detectado";case"wrong_position_face_detected":return"Face na posi\xE7\xE3o errada";default:return t}}};function s4(){let e=document.createElement("div");e.setAttribute("id","liveViewFrameDetection");let t=document.createElement("erro");t.setAttribute("id","errorFrameDetection");let r=document.createElement("video");r.setAttribute("id","videoPreviewFrameDetection"),r.muted=!0,e.style.width="320px",e.style.height="180px",e.style.position="fixed",e.style.bottom="30px",e.style.right="30px",e.style.display="none",r.style.width="100%",r.style.height="100%",r.style.background="#000",e.appendChild(t),e.appendChild(r),document.body.appendChild(e)}var aa=class extends Z0{constructor(r,i,n="videoPreviewFrameDetection",s="liveViewFrameDetection"){super("FaceDetector","https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite",r,i,n,s);this.emmitedPositionAlert=!1}displayVideoDetections(r){for(let i of this.children)this.liveView.removeChild(i);this.children.splice(0);for(let i of r.detections){let n=window.innerWidth,s=window.innerHeight,a=this.video.offsetWidth,m=this.video.offsetHeight,p=a/n,T=m/s,Z=a-i.boundingBox.width*p-i.boundingBox.originX*p,G=i.boundingBox.originY*T,fe=(i.boundingBox.width-10)*p,Ae=i.boundingBox.height*T,ne=document.createElement("p");ne.innerText="Confidence: "+Math.round(parseFloat(i.categories[0].score)*100)+"% .",ne.style.right=Z+"px",ne.style.top=G-50+"px",ne.style.width=fe+"px";let pe={zIndex:"2",position:"absolute",border:"1px dashed #fff"};Object.assign(ne.style,{...pe,margin:"0",fontSize:"9px",paddingBottom:"5px",paddingTop:"5px",color:"#fff",backgroundColor:"#007f8b"});let J=document.createElement("div");J.setAttribute("class","highlighter"),J.style.right=Z+"px",J.style.top=G+"px",J.style.width=fe+"px",J.style.height=Ae-10+"px",Object.assign(J.style,{...pe,zIndex:"1",background:"rgba(0, 255, 0, 0.25)"}),this.liveView.appendChild(J),this.liveView.appendChild(ne),this.children.push(J),this.children.push(ne);for(let Ue of i.keypoints){let Pe=document.createElement("spam");Pe.className="key-point",Pe.style.top=`${Ue.y*this.video.offsetHeight-3}px`,Pe.style.right=`${this.video.offsetWidth-Ue.x*this.video.offsetWidth-3}px`,this.liveView.appendChild(Pe),this.children.push(Pe)}}}verify(r){this.paramsConfig.videoBehaviourParameters?.detectFace&&r.detections.length!==this.numFacesSent&&(this.numFacesSent=r.detections.length,r.detections.length===0?this.handleAlert("no_face_detected","face_detection_on_stream"):r.detections.length>1?this.handleAlert("multiple_faces_detected","face_detection_on_stream"):this.handleOk("face_detection_on_stream")),r.detections[0]?.keypoints[4].x<.2||r.detections[0]?.keypoints[5].x>.8?(!this.emmitedPositionAlert&&this.handleAlert("wrong_position_face_detected","position_detection_on_stream"),this.emmitedPositionAlert=!0):(this.emmitedPositionAlert&&this.handleOk("position_detection_on_stream"),this.emmitedPositionAlert=!1)}};var Un=class{constructor(t){this.stream=t}start(t={}){return new Promise((r,i)=>{try{let n=new AudioContext,s=n.createAnalyser(),a=n.createMediaStreamSource(this.stream);this.scriptProcessor=n.createScriptProcessor(2048,1,1),s.smoothingTimeConstant=.8,s.fftSize=1024,a.connect(s),s.connect(this.scriptProcessor),this.scriptProcessor.connect(n.destination);let m=this;this.scriptProcessor.onaudioprocess=function(){let p=new Uint8Array(s.frequencyBinCount);s.getByteFrequencyData(p);let Z=p.reduce((G,fe)=>G+fe,0)/p.length;m.setVolume(Z),t.setVolume&&t.setVolume(Z)},r(!0)}catch(n){this.stop(),i(`Error: ${n}`)}})}stop(){this.scriptProcessor&&this.scriptProcessor.disconnect()}getVolume(){return this.volume}setVolume(t){this.volume=t}};var $i=class{constructor(t,r,i,n,s){this.blobs=[];this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128},imageBehaviourParameters:{frames:40,useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectPerson:!1,detectFace:!1,detectCellPhone:!1}};this.options={cameraId:void 0,microphoneId:void 0,onBufferSizeError:!1,onBufferSizeErrorCallback:()=>{},proctoringType:"IMAGE",onChangeDevicesCallback:t=>{},onRealtimeAlertsCallback:t=>{}};this.videoOptions={width:640,height:480,minWidth:0,minHeight:0};this.blobsRTC=[];this.imageCount=0;this.filesToUpload=[];this.noiseWait=20;this.options=t,this.videoOptions=r,this.backend=n,this.backendToken=s,i&&(this.paramsConfig=i)}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new cn(this.proctoringId,this.backend))}async initializeDetectors(){s4(),this.paramsConfig.videoBehaviourParameters?.detectFace&&(this.faceDetection=new aa({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,this.canvas.width=this.videoOptions.width,this.canvas.height=this.videoOptions.height}async startRecording(){(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone||this.paramsConfig.videoBehaviourParameters?.detectFace)&&await this.initializeDetectors();let{cameraId:t,microphoneId:r,onBufferSizeErrorCallback:i}=this.options,n={audio:{deviceId:r},video:{deviceId:t,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.cameraStream=await navigator.mediaDevices.getUserMedia(n)}catch(G){throw G.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":G}let{startRecording:s,stopRecording:a,pauseRecording:m,resumeRecording:p}=Oa(this.cameraStream,this.blobs,this.proctoringId,this.options.onBufferSizeError,i);this.recordingStart=s,this.recordingStop=a,this.recordingPause=m,this.recordingResume=p,this.recordingStart();let Z=this.cameraStream.getVideoTracks()[0].getSettings();if(this.videoOptions.minWidth>Z.width||this.videoOptions.minHeight>Z.height)throw zu;if(this.videoOptions.width!==Z.width||this.videoOptions.height!==Z.height)throw ot.registerAnotherStream(this.proctoringId,`Maybe have another stream active
74
74
  Video Options: ${this.videoOptions}
75
- Setting: ${Z}`),Xu;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&this.captureFrame(),this.paramsConfig.videoBehaviourParameters?.detectNoise&&(this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetected(),500))}async stopRecording(){if(this.recordingStop&&await this.recordingStop(),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){let t=this.filesToUpload.length,r=this.paramsConfig.imageBehaviourParameters.uploadInterval;for(let i=0;i<t;i++){if(i==t-1){let n=this.filesToUpload[0].name.replace(".jpg","_realtime.jpg"),s=new File([this.filesToUpload[0]],n,{type:"image/jpeg"});this.filesToUpload[0]=s}this.filesToUpload[0]&&await this.upload.uploadImages({file:this.filesToUpload[0]},this.backendToken,r),this.filesToUpload.shift()}}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)}captureFrame(){let t;this.configImageCapture();let r=this.paramsConfig.imageBehaviourParameters.uploadInterval,i=!1;this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.videoOptions.width,this.videoOptions.height);let n=this.canvas.toDataURL("image/jpeg");if(this.proctoringId==null)return;i==!1&&(i=!0,this.sendFrame());let s=`${this.proctoringId}_${this.imageCount+1}.jpg`;(this.imageCount+1)%r==0&&(s=`${this.proctoringId}_${this.imageCount+1}_realtime.jpg`),t=await this.getFile(n,s,"image/jpeg"),t&&(this.filesToUpload.push(t),this.imageCount++)},1e3)}sendFrame(){let t=this.paramsConfig.imageBehaviourParameters.uploadInterval;this.sendFrameInterval=setInterval(async()=>{if(this.upload&&this.backendToken)for(let r=0;r<t&&this.filesToUpload.length!=0;r++)await this.upload.uploadImages({file:this.filesToUpload[0]},this.backendToken,t),await this.filesToUpload.shift()},t*1e3)}download(t){let r=URL.createObjectURL(t),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=r,i.download=t.name,i.click(),window.URL.revokeObjectURL(r)}async saveOnSession(t){let r=this.cameraStream.getVideoTracks()[0].getSettings(),i=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
75
+ Setting: ${Z}`),Xu;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&this.captureFrame(),this.paramsConfig.videoBehaviourParameters?.detectNoise&&(this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetected(),500))}async stopRecording(){if(this.recordingStop&&await this.recordingStop(),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){let t=this.filesToUpload.length,r=this.paramsConfig.imageBehaviourParameters.uploadInterval;for(let i=0;i<t;i++){if(i==t-1&&this.filesToUpload[0]){let n=this.filesToUpload[0].name.replace(".jpg","_realtime.jpg"),s=new File([this.filesToUpload[0]],n,{type:"image/jpeg"});this.filesToUpload[0]=s}this.filesToUpload[0]&&await this.upload.uploadImages({file:this.filesToUpload[0]},this.backendToken,r),this.filesToUpload.shift()}}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)}captureFrame(){let t;this.configImageCapture();let r=this.paramsConfig.imageBehaviourParameters.uploadInterval,i=!1;this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.videoOptions.width,this.videoOptions.height);let n=this.canvas.toDataURL("image/jpeg");if(this.proctoringId==null)return;i==!1&&(i=!0,this.sendFrame());let s=`${this.proctoringId}_${this.imageCount+1}.jpg`;(this.imageCount+1)%r==0&&(s=`${this.proctoringId}_${this.imageCount+1}_realtime.jpg`),t=await this.getFile(n,s,"image/jpeg"),t&&(this.filesToUpload.push(t),this.imageCount++)},1e3)}sendFrame(){let t=this.paramsConfig.imageBehaviourParameters.uploadInterval;this.sendFrameInterval=setInterval(async()=>{if(this.upload&&this.backendToken)for(let r=0;r<t&&this.filesToUpload.length!=0;r++)await this.upload.uploadImages({file:this.filesToUpload[0]},this.backendToken,t),await this.filesToUpload.shift()},t*1e3)}download(t){let r=URL.createObjectURL(t),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=r,i.download=t.name,i.click(),window.URL.revokeObjectURL(r)}async saveOnSession(t){let r=this.cameraStream.getVideoTracks()[0].getSettings(),i=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
76
76
  Sample Rate: ${i.sampleRate}
77
- Sample Size: ${i.sampleSize}`,file:new File(this.blobs,`EP_${t.id}_camera_0.webm`,{type:"video/webm"}),origin:"Camera"})}async getFile(t,r,i){return new Promise((n,s)=>{t.length>5&&fetch(t).then(a=>a.blob()).then(a=>{let m=new File([a],r,{type:i});n(m)}).catch(a=>{s(a)})})}onNoiseDetected(){!this.volumeMeter&&this.cameraStream&&(this.volumeMeter=new Un(this.cameraStream),this.volumeMeter.start().catch(t=>{console.log(t),this.volumeMeter=void 0})),this.volumeMeter?.getVolume()>=(this.options.noiseLimit||40)&&this.noiseWait>=20&&(this.options.onRealtimeAlertsCallback({status:"ALERT",description:"noise",type:"audio_detection_on_stream"}),this.noiseWait=0),this.noiseWait++}};var oa=class{constructor(){}async takePicture(t,r,i={width:1080,height:720}){return this.resolution=i,await this.takePictureInterface(t,r)}async startCapture(t="default"){let r=document.querySelector("#cameraStream"),i={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 $i({cameraId:t,onBufferSizeErrorCallback:()=>{}},{...this.resolution}),await this.cameraRecorder.startRecording(),r.srcObject=this.cameraRecorder.cameraStream,r.play()}shot(){let t=document.querySelector("#cameraStream"),r=document.querySelector("#canvas"),i=document.querySelector("#image");r.width=t.videoWidth,r.height=t.videoHeight,r.getContext("2d").drawImage(t,0,0,t.videoWidth,t.videoHeight),i.src=r.toDataURL("image/jpg"),this.base64=r.toDataURL("image/jpg")}takePictureInterface(t,r){return new Promise(i=>{let n=document.createElement("div");n.setAttribute("id","authPhoto"),n.style.backgroundColor="rgba(0,0,0,0.4)",n.style.zIndex="1000",n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.height="100vh",n.style.width="100%",n.style.display="flex",n.style.alignItems="center",n.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 m=document.createElement("p");m.innerText=r||"Encaixe seu rosto no formato e clique no bot\xE3o abaixo",m.style.color="rgba(0, 0, 0, .7)",m.style.fontWeight="normal",m.style.fontSize="16px",m.style.marginBottom="15px",m.style.padding="0px 0px 20px",m.style.width="100%",m.style.textAlign="center",m.style.position="fixed",m.style.top="55px",m.style.left="0",m.style.zIndex="1011",s.appendChild(m);let p=document.createElement("div"),T=document.createElement("h3"),Z=document.createElement("select");Z.setAttribute("id","cameraSelect"),p.style.padding="0 20px",p.style.width="100%",p.style.display="flex",p.style.justifyContent="space-between",p.style.marginBottom="15px",T.innerText="C\xE2mera",T.style.color="rgba(0, 0, 0, .75)",T.style.fontWeight="bold",T.style.fontSize="16px",p.appendChild(T),p.appendChild(Z);let G=document.createElement("div"),fe=document.createElement("video");fe.setAttribute("id","cameraStream"),fe.muted=!0,G.style.position="fixed",G.style.top="0",G.style.left="0",G.style.height="100vh",G.style.width="100%",G.style.display="flex",G.style.justifyContent="center",fe.style.backgroundColor="#000",fe.style.borderRadius="10px",fe.style.width="auto",fe.style.height="auto",fe.style.minHeight="100%",G.appendChild(fe);let Ae=document.createElement("canvas");Ae.setAttribute("id","canvas"),Ae.style.display="none",Ae.style.width="100%",Ae.style.height="100%";let ne=document.createElement("img");ne.setAttribute("id","image"),ne.style.objectFit="contain",ne.style.display="none",ne.style.borderRadius="8px",G.appendChild(Ae),G.appendChild(ne);let pe=document.createElement("div");pe.setAttribute("class","facial-biometry__mask"),pe.style.width="100%",pe.style.height="100%",pe.style.position="absolute",pe.style.top="0px",pe.style.left="0px",pe.style.backgroundColor="#fff",pe.style.opacity="0.8";let J=document.createElement("div");J.setAttribute("class","biometry__frame"),J.style.width="100%",J.style.height="100%",J.style.position="absolute",J.style.top="0px",J.style.left="0px",J.style.zIndex="10",G.appendChild(pe),G.appendChild(J),s.appendChild(G),this.addStyleMask();let Ue=document.createElement("button"),Pe=document.createElement("div");Ue.setAttribute("id","confirmBtn"),Pe.style.position="fixed",Pe.style.bottom="0",Pe.style.left="0",Pe.style.width="100%",Pe.style.display="flex",Pe.style.alignItems="center",Pe.style.justifyContent="center",Ue.style.background="url('https://iarisprod.blob.core.windows.net/imagens/camera.svg') no-repeat center",Ue.style.width="70px",Ue.style.height="70px",Ue.style.borderRadius="70px",Ue.style.border="none",Ue.style.backgroundColor="#16a34a",Ue.style.margin="20px 0",Pe.appendChild(Ue),s.appendChild(Pe);let wt=document.createElement("button");wt.style.background="url('https://iarisprod.blob.core.windows.net/imagens/close.svg') no-repeat center",wt.style.width="70px",wt.style.height="70px",wt.style.borderRadius="70px",wt.style.border="none",wt.style.backgroundColor="#e74141",wt.style.margin="20px 20px";let er=document.createElement("button");er.style.background="url('https://iarisprod.blob.core.windows.net/imagens/check.svg') no-repeat center",er.style.width="70px",er.style.height="70px",er.style.borderRadius="70px",er.style.border="none",er.style.backgroundColor="#16a34a",er.style.margin="20px 20px",n.appendChild(s),document.body.appendChild(n),this.setSelectOption(),this.startCapture(),Ue.addEventListener("click",()=>{Pe.removeChild(Ue),Pe.appendChild(wt),Pe.appendChild(er),this.shot(),fe.style.display="none",ne.style.display="block"}),wt.addEventListener("click",()=>{Pe.appendChild(Ue),Pe.removeChild(wt),Pe.removeChild(er),fe.style.display="block",ne.style.display="none"}),er.addEventListener("click",()=>{this.closeInterface(),i({base64:this.base64})})})}async setSelectOption(){let t=document.querySelector("#cameraSelect"),r=await gi();t&&(t.value="default");let i=(n,s)=>{let a=document.createElement("option");return a.setAttribute("value",s),a.innerHTML=n,a};r.cameras.forEach(n=>{let s=i(n.label,n.id);t?.appendChild(s)}),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=`
77
+ Sample Size: ${i.sampleSize}`,file:new File(this.blobs,`EP_${t.id}_camera_0.webm`,{type:"video/webm"}),origin:"Camera"})}async getFile(t,r,i){return new Promise((n,s)=>{t.length>5&&fetch(t).then(a=>a.blob()).then(a=>{let m=new File([a],r,{type:i});n(m)}).catch(a=>{s(a)})})}onNoiseDetected(){!this.volumeMeter&&this.cameraStream&&(this.volumeMeter=new Un(this.cameraStream),this.volumeMeter.start().catch(t=>{console.log(t),this.volumeMeter=void 0})),this.volumeMeter?.getVolume()>=(this.options.noiseLimit||40)&&this.noiseWait>=20&&(this.options.onRealtimeAlertsCallback({status:"ALERT",description:"Barulho detectado",type:"audio_detection_on_stream"}),this.noiseWait=0),this.noiseWait++}};var oa=class{constructor(){}async takePicture(t,r,i={width:1080,height:720}){return this.resolution=i,await this.takePictureInterface(t,r)}async startCapture(t="default"){let r=document.querySelector("#cameraStream"),i={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 $i({cameraId:t,onBufferSizeErrorCallback:()=>{}},{...this.resolution}),await this.cameraRecorder.startRecording(),r.srcObject=this.cameraRecorder.cameraStream,r.play()}shot(){let t=document.querySelector("#cameraStream"),r=document.querySelector("#canvas"),i=document.querySelector("#image");r.width=t.videoWidth,r.height=t.videoHeight,r.getContext("2d").drawImage(t,0,0,t.videoWidth,t.videoHeight),i.src=r.toDataURL("image/jpg"),this.base64=r.toDataURL("image/jpg")}takePictureInterface(t,r){return new Promise(i=>{let n=document.createElement("div");n.setAttribute("id","authPhoto"),n.style.backgroundColor="rgba(0,0,0,0.4)",n.style.zIndex="1000",n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.height="100vh",n.style.width="100%",n.style.display="flex",n.style.alignItems="center",n.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 m=document.createElement("p");m.innerText=r||"Encaixe seu rosto no formato e clique no bot\xE3o abaixo",m.style.color="rgba(0, 0, 0, .7)",m.style.fontWeight="normal",m.style.fontSize="16px",m.style.marginBottom="15px",m.style.padding="0px 0px 20px",m.style.width="100%",m.style.textAlign="center",m.style.position="fixed",m.style.top="55px",m.style.left="0",m.style.zIndex="1011",s.appendChild(m);let p=document.createElement("div"),T=document.createElement("h3"),Z=document.createElement("select");Z.setAttribute("id","cameraSelect"),p.style.padding="0 20px",p.style.width="100%",p.style.display="flex",p.style.justifyContent="space-between",p.style.marginBottom="15px",T.innerText="C\xE2mera",T.style.color="rgba(0, 0, 0, .75)",T.style.fontWeight="bold",T.style.fontSize="16px",p.appendChild(T),p.appendChild(Z);let G=document.createElement("div"),fe=document.createElement("video");fe.setAttribute("id","cameraStream"),fe.muted=!0,G.style.position="fixed",G.style.top="0",G.style.left="0",G.style.height="100vh",G.style.width="100%",G.style.display="flex",G.style.justifyContent="center",fe.style.backgroundColor="#000",fe.style.borderRadius="10px",fe.style.width="auto",fe.style.height="auto",fe.style.minHeight="100%",G.appendChild(fe);let Ae=document.createElement("canvas");Ae.setAttribute("id","canvas"),Ae.style.display="none",Ae.style.width="100%",Ae.style.height="100%";let ne=document.createElement("img");ne.setAttribute("id","image"),ne.style.objectFit="contain",ne.style.display="none",ne.style.borderRadius="8px",G.appendChild(Ae),G.appendChild(ne);let pe=document.createElement("div");pe.setAttribute("class","facial-biometry__mask"),pe.style.width="100%",pe.style.height="100%",pe.style.position="absolute",pe.style.top="0px",pe.style.left="0px",pe.style.backgroundColor="#fff",pe.style.opacity="0.8";let J=document.createElement("div");J.setAttribute("class","biometry__frame"),J.style.width="100%",J.style.height="100%",J.style.position="absolute",J.style.top="0px",J.style.left="0px",J.style.zIndex="10",G.appendChild(pe),G.appendChild(J),s.appendChild(G),this.addStyleMask();let Ue=document.createElement("button"),Pe=document.createElement("div");Ue.setAttribute("id","confirmBtn"),Pe.style.position="fixed",Pe.style.bottom="0",Pe.style.left="0",Pe.style.width="100%",Pe.style.display="flex",Pe.style.alignItems="center",Pe.style.justifyContent="center",Ue.style.background="url('https://iarisprod.blob.core.windows.net/imagens/camera.svg') no-repeat center",Ue.style.width="70px",Ue.style.height="70px",Ue.style.borderRadius="70px",Ue.style.border="none",Ue.style.backgroundColor="#16a34a",Ue.style.margin="20px 0",Pe.appendChild(Ue),s.appendChild(Pe);let wt=document.createElement("button");wt.style.background="url('https://iarisprod.blob.core.windows.net/imagens/close.svg') no-repeat center",wt.style.width="70px",wt.style.height="70px",wt.style.borderRadius="70px",wt.style.border="none",wt.style.backgroundColor="#e74141",wt.style.margin="20px 20px";let er=document.createElement("button");er.style.background="url('https://iarisprod.blob.core.windows.net/imagens/check.svg') no-repeat center",er.style.width="70px",er.style.height="70px",er.style.borderRadius="70px",er.style.border="none",er.style.backgroundColor="#16a34a",er.style.margin="20px 20px",n.appendChild(s),document.body.appendChild(n),this.setSelectOption(),this.startCapture(),Ue.addEventListener("click",()=>{Pe.removeChild(Ue),Pe.appendChild(wt),Pe.appendChild(er),this.shot(),fe.style.display="none",ne.style.display="block"}),wt.addEventListener("click",()=>{Pe.appendChild(Ue),Pe.removeChild(wt),Pe.removeChild(er),fe.style.display="block",ne.style.display="none"}),er.addEventListener("click",()=>{this.closeInterface(),i({base64:this.base64})})})}async setSelectOption(){let t=document.querySelector("#cameraSelect"),r=await gi();t&&(t.value="default");let i=(n,s)=>{let a=document.createElement("option");return a.setAttribute("value",s),a.innerHTML=n,a};r.cameras.forEach(n=>{let s=i(n.label,n.id);t?.appendChild(s)}),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=`
78
78
  .facial-biometry__mask {
79
79
  mask-image: url('https://iarisprod.blob.core.windows.net/imagens/square.svg'), url('https://iarisprod.blob.core.windows.net/imagens/face-mask.svg');
80
80
  mask-size: cover, auto 65%;
@@ -231,7 +231,7 @@ Para iniciar um exame utilize uma outra c\xE2mera.`),s.setAttribute("class","che
231
231
  `,document.getElementsByTagName("head")[0].appendChild(t),new Promise((r,i)=>{let n=document.createElement("div");n.setAttribute("id","checkDevices");let s={backgroundColor:"rgba(0,0,0,0.4)",zIndex:"1000",position:"fixed",top:"0",left:"0",height:"100vh",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"};this.applyStyles(n,s);let a=document.createElement("div"),m={backgroundColor:"#fff",zIndex:"1001",width:"600px",borderRadius:"10px",display:"flex",flexDirection:"column",alignItems:"center"};this.applyStyles(a,m);let p=document.createElement("h3");p.innerText="Para iniciar configure a c\xE2mera e o microfone";let T={color:"rgba(0, 0, 0, .7)",fontWeight:"bold",fontSize:"20px",marginBottom:"15px",padding:"20px 0px",borderBottom:"2px solid rgba(0, 0, 0, .1)",width:"100%",textAlign:"center"};this.applyStyles(p,T),a.appendChild(p);let Z=document.createElement("div"),G=document.createElement("h3"),fe=document.createElement("select");fe.setAttribute("id","cameraSelect");let Ae={padding:"0 20px",width:"100%",display:"flex",justifyContent:"space-between",marginBottom:"15px"};this.applyStyles(Z,Ae),G.innerText="C\xE2mera";let ne={color:"rgba(0, 0, 0, .75)",fontWeight:"bold",fontSize:"16px"};this.applyStyles(G,ne),fe.style.maxWidth="400px",Z.appendChild(G),Z.appendChild(fe),a.appendChild(Z);let pe=document.createElement("div");pe.setAttribute("id","liveCheckDevices");let J=document.createElement("div"),Ue=document.createElement("video"),Pe=document.createElement("div");Ue.setAttribute("id","cameraStream"),Ue.muted=!0;let wt={width:"calc(100% - 40px)",display:"flex",justifyContent:"space-between",borderBottom:"2px solid rgba(0, 0, 0, .1)",paddingBottom:"15px",transform:"rotateY(180deg)"};this.applyStyles(pe,wt);let er={width:"20rem",backgroundColor:"#000",borderRadius:"10px",marginBottom:"15px"};this.applyStyles(Ue,er),this.applyStyles(J,{position:"relative"});let bn=document.createElement("div");bn.setAttribute("class","alert-div"),bn.setAttribute("id","alertDivResolution");let Yn=document.createElement("error");Yn.setAttribute("id","resolutionAlert"),Yn.innerText="Resolu\xE7\xE3o m\xEDnima",Yn.style.marginLeft="10px",Yn.style.marginRight="5px";let Ts=document.createElement("span"),Bo=document.createElement("div"),Io=document.createElement("div");Ts.setAttribute("id","checkmark_resolution"),Bo.setAttribute("id","checkmark_stem_resolution"),Io.setAttribute("id","checkmark_kick_resolution"),Ts.appendChild(Bo),Ts.appendChild(Io);let Wn=document.createElement("span"),Kn=document.createElement("div"),Co=document.createElement("div");Wn.setAttribute("class","info"),Wn.setAttribute("id","info_resolution"),Kn.setAttribute("class","info_stem"),Co.setAttribute("class","info_kick"),Wn.appendChild(Kn),Wn.appendChild(Co),bn.appendChild(Ts),bn.appendChild(Yn),bn.appendChild(Wn);let Zn=document.createElement("div");Zn.setAttribute("class","alert-div"),Zn.setAttribute("id","alertDivFacePosition");let Qn=document.createElement("error");Qn.setAttribute("id","facePositionAlert"),Qn.innerText="Posicionamento da face",Qn.style.marginLeft="10px";let Ji=document.createElement("span"),ya=document.createElement("div"),ga=document.createElement("div");Ji.setAttribute("id","checkmark_FacePosition"),ya.setAttribute("id","checkmark_stem_FacePosition"),ga.setAttribute("id","checkmark_kick_FacePosition"),Ji.appendChild(ya),Ji.appendChild(ga),Zn.appendChild(Ji),Zn.appendChild(Qn);let Jn=document.createElement("div");Jn.setAttribute("class","alert-div"),Jn.setAttribute("id","alertDivAmbientVerify");let ks=document.createElement("error");ks.setAttribute("id","ambientVerifyAlert"),ks.innerText="Verifica\xE7\xE3o do ambiente",ks.style.marginLeft="10px";let Ii=document.createElement("span"),qe=document.createElement("div"),x=document.createElement("div");Ii.setAttribute("id","checkmark_AmbientVerify"),qe.setAttribute("id","checkmark_stem_AmbientVerify"),x.setAttribute("id","checkmark_kick_AmbientVerify"),Ii.appendChild(qe),Ii.appendChild(x),Jn.appendChild(Ii),Jn.appendChild(ks),Pe.style.transform="rotateY(180deg)",Pe.appendChild(bn),Pe.appendChild(Zn),Pe.appendChild(Jn),pe.appendChild(Pe),J.appendChild(Ue),pe.appendChild(J);let $r=document.createElement("div");$r.setAttribute("class","facial-biometry__mask"),$r.style.width="100%",$r.style.height="100%",$r.style.position="absolute",$r.style.top="0px",$r.style.left="0px",$r.style.backgroundColor="#fff",$r.style.opacity="0.6";let mi=document.createElement("div");mi.setAttribute("class","biometry__frame"),mi.style.width="100%",mi.style.height="100%",mi.style.position="absolute",mi.style.top="0px",mi.style.left="0px",mi.style.zIndex="10",J.appendChild($r),J.appendChild(mi),a.appendChild(pe);let Ms=document.createElement("div"),Sa=document.createElement("h3"),Yr=document.createElement("select");Yr.setAttribute("id","micSelect");let Oo={padding:"0 20px",width:"100%",display:"flex",justifyContent:"space-between",margin:"15px 0"};this.applyStyles(Ms,Oo),Sa.innerText="Microfone";let yn={color:"rgba(0, 0, 0, .7)",fontWeight:"bold",fontSize:"16px"};this.applyStyles(Sa,yn),Yr.style.maxWidth="400px",Ms.appendChild(Sa),Ms.appendChild(Yr),a.appendChild(Ms);let Yt=document.createElement("div"),j1={width:"100%",padding:"0px 40px",display:"flex"};this.applyStyles(Yt,j1);let mt=document.createElement("div"),vr={display:"flex",flexDirection:"column",justifyContent:"space-between",paddingBottom:"15px"};this.applyStyles(mt,vr);let Wr=document.createElement("div");Wr.setAttribute("id","audioStream");let Be={display:"flex",marginBottom:"15px"};this.applyStyles(Wr,Be);let G1={height:"16px",width:"5px",marginRight:"5px",borderRadius:"10px",backgroundColor:"rgba(0, 0, 0, .3)"};for(let Cs=0;Cs<25;Cs++){let Fo=document.createElement("div");this.applyStyles(Fo,G1),Wr.appendChild(Fo)}let en=document.createElement("div"),br=document.createElement("p"),wa=document.createElement("p"),Po=document.createElement("p"),X1={width:"250px",display:"flex",justifyContent:"space-between"};this.applyStyles(en,X1),br.innerText="0",wa.innerText="50",Po.innerText="100",en.appendChild(br),en.appendChild(wa),en.appendChild(Po);let tn=document.createElement("div");tn.setAttribute("class","alert-div"),tn.setAttribute("id","alertDivMicrophone");let rn={alignItems:"start",justifyContent:"end",width:"inherit"};this.applyStyles(tn,rn);let Bs=document.createElement("error");Bs.setAttribute("id","microphoneAlert"),Bs.innerText="Teste de funcionamento",Bs.style.marginLeft="10px";let Kr=document.createElement("span"),Lo=document.createElement("div"),es=document.createElement("div");Kr.setAttribute("id","checkmark_microphone"),Lo.setAttribute("id","checkmark_stem_microphone"),es.setAttribute("id","checkmark_kick_microphone"),Kr.appendChild(Lo),Kr.appendChild(es),tn.appendChild(Kr),tn.appendChild(Bs),mt.appendChild(Wr),mt.appendChild(en);let ts=document.createElement("p");ts.innerText='Pronuncie em voz alta: "um, dois, tr\xEAs, quatro".',ts.style.textAlign="start";let z1={width:"100%",marginLeft:"40px",marginBottom:"15px"};this.applyStyles(ts,z1),Yt.appendChild(mt),Yt.appendChild(tn),a.appendChild(ts),a.appendChild(Yt);let rs=document.createElement("div"),Is={width:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderTop:"2px solid rgba(0, 0, 0, .1)"};this.applyStyles(rs,Is);let nn=document.createElement("button");nn.innerText="Cancelar";let q1={width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"10px",paddingTop:"5px",paddingBottom:"5px"};this.applyStyles(nn,q1),nn.addEventListener("click",()=>{this.closeCheckDevices(),r({cameraId:fe?.value,microphoneId:Yr?.value,result:!1})});let Pr=document.createElement("span"),Aa={width:"3px",height:"70px",margin:"0px 2px",background:"rgba(0, 0, 0, .1)"};this.applyStyles(Pr,Aa);let is=document.createElement("button");is.innerText="Continuar",is.setAttribute("id","confirmBtn");let $1={width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"10px",paddingTop:"5px",paddingBottom:"5px",disabled:!0};this.applyStyles(is,$1),is.addEventListener("click",()=>{this.closeCheckDevices(),r({cameraId:fe?.value,microphoneId:Yr?.value,result:!0})}),rs.appendChild(nn),rs.appendChild(Pr),rs.appendChild(is),a.appendChild(rs),n.appendChild(a),document.body.appendChild(n),this.startCheckDevices(this.options,this.videoOptions).catch(Cs=>i(Cs))})}videoDeviceInterface(t){let r=document.querySelector("#cameraStream");r&&(r.srcObject=t,r.play(),this.isUnderResolution()),this.faceDetection.enableCam()}audioDeviceInterface(t){let i=document.querySelector("#audioStream")?.querySelectorAll("div"),n=document.querySelector("#audioText"),s=document.getElementById("microphoneAlert"),a=document.getElementById("alertDivMicrophone"),m=document.getElementById("checkmark_microphone"),p=document.getElementById("checkmark_stem_microphone"),T=document.getElementById("checkmark_kick_microphone"),Z=document.getElementById("ambientVerifyAlert"),G=document.getElementById("alertDivAmbientVerify"),fe=document.getElementById("checkmark_AmbientVerify"),Ae=document.getElementById("checkmark_stem_AmbientVerify"),ne=document.getElementById("checkmark_kick_AmbientVerify");this.volumeMeter=new Un(this.cameraRecorder.cameraStream),this.volumeMeter.start({setVolume:pe=>{this.volumeCounter++,this.volumeSum+=pe,!this.allowedMicrophone&&pe>this.microphoneMinThreshold?(this.allowedMicrophone=!0,s&&(s.style.color="#16A34A"),a&&a.setAttribute("title",""),m&&m.setAttribute("class","checkmark"),p&&p.setAttribute("class","checkmark_stem"),T&&T.setAttribute("class","checkmark_kick")):this.allowedMicrophone||(s&&(s.style.color="#FF0000"),a&&a.setAttribute("title","Microfone n\xE3o est\xE1 funcionando corretamente!"),m&&m.setAttribute("class","checkmark_error"),p&&p.setAttribute("class","checkmark_stem_error"),T&&T.setAttribute("class","checkmark_kick_error"));let J=pe/4;i?.forEach((Ue,Pe)=>{Pe<Math.ceil(J)?Ue.style.backgroundColor="rgb(22, 163, 74)":Ue.style.backgroundColor="rgba(0, 0, 0, .3)"}),n&&(n.innerText=pe.toFixed(0).toString()),pe>this.options.noiseLimit?(Z&&(Z.style.color="#FF0000"),G&&G.setAttribute("title","Ambiente apresentando muito ru\xEDdo!"),this.allowedAmbient=!1,fe.setAttribute("class","checkmark_error"),Ae.setAttribute("class","checkmark_stem_error"),ne.setAttribute("class","checkmark_kick_error")):(Z&&(Z.style.color="#16A34A"),G&&G.setAttribute("title",""),this.allowedAmbient=!0,fe.setAttribute("class","checkmark"),Ae.setAttribute("class","checkmark_stem"),ne.setAttribute("class","checkmark_kick"))}}).catch(pe=>{console.log(pe),this.volumeMeter=void 0,s&&(s.style.color="#FF0000"),m&&m.setAttribute("class","checkmark_error"),p&&p.setAttribute("class","checkmark_stem_error"),T&&T.setAttribute("class","checkmark_kick_error")})}async setSelectOption(t){let r=document.querySelector("#cameraSelect"),i=document.querySelector("#micSelect"),n=await gi();r&&(r.value=t.cameraId||"default"),i&&(i.value=t.microphoneId||"default");let s=(a,m)=>{let p=document.createElement("option");return p.setAttribute("value",m),p.innerHTML=a,p};n.cameras.forEach(a=>{let m=s(a.label,a.id);r?.appendChild(m)}),n.microphones.forEach(a=>{let m=s(a.label,a.id);i?.appendChild(m)}),this.onSelectOptionChange()}async onSelectOptionChange(){let t=document.querySelector("#cameraSelect"),r=document.querySelector("#micSelect");t?.addEventListener("change",async()=>{await this.cameraRecorder.stopRecording(),this.volumeMeter?.stop(),this.cameraRecorder=new $i({cameraId:t?.value,microphoneId:r?.value,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)}),r?.addEventListener("change",async()=>{await this.cameraRecorder.stopRecording(),this.volumeMeter?.stop(),this.cameraRecorder=new $i({cameraId:t?.value,microphoneId:r?.value,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)})}async startCheckDevices(t=Hn,r){this.setSelectOption(t),this.videoOptions=Q0(r),await zo(),this.cameraRecorder=new $i({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);let i=document.querySelector("#confirmBtn");return i.disabled=!1,{cameraStream:this.cameraRecorder.cameraStream}}async closeCheckDevices(){document.querySelector("#checkDevices")?.remove(),this.faceDetection.stopDetection(),this.volumeMeter?.stop(),this.volumeMedia=Math.ceil(this.volumeSum/this.volumeCounter),await this.cameraRecorder.stopRecording()}applyStyles(t,r){for(let[i,n]of Object.entries(r))t.style[i]=n}};var e1=class{constructor(){this.hasExtension=!1;this.tryes=0;this.responseStart=!1}start(){let t;return new Promise((r,i)=>{window.postMessage({type:"easyproctor",func:"startExtensionEasyproctor"},"*"),t=setInterval(()=>{this.tryes>10&&(clearInterval(t),i(new Error("N\xE3o foi poss\xEDvel se conectar com a extens\xE3o"))),this.responseStart&&(clearInterval(t),r(this.responseStart)),this.tryes++},1e3)})}sendVerifyMsg(t,r){window.postMessage({type:"easyproctor",func:"verifyExtensionEasyproctor",url:t,token:r},"*")}verify(t){return t.source==window&&t.data.sender&&t.data.sender==="easyproctor-extension"&&t.data.message_name&&t.data.message_name==="progress"&&this.options.onProgress&&this.options.onProgress(100),t.source==window&&t.data.sender&&t.data.sender==="easyproctor-extension"&&t.data.message_name&&t.data.message_name==="start"&&(this.responseStart=!0),new Promise((r,i)=>{t.source==window&&t.data.sender&&t.data.sender==="easyproctor-extension"&&t.data.message_name&&t.data.message_name==="version"&&(this.hasExtension=!0,r(this.hasExtension))})}addEventListener(){window.addEventListener("message",t=>this.verify(t))}};var t1=class{constructor(t,r){this.repositoryDevices=t,this.proctoringId=r}startRecording(t){navigator.mediaDevices.ondevicechange=()=>{this.onChangeDevices(t)}}async onChangeDevices(t){let r=await gi(),i=(G,fe)=>G.label===fe.label&&G.id===fe.id,n=(G,fe,Ae)=>G.filter(ne=>!fe.some(pe=>Ae(ne,pe))),s=await this.repositoryDevices.getDevices("devices"),a={label:"",id:""},m={cameras:s?.cameras||[a],microphones:s?.microphones||[a]},p,T;r.cameras.length!=m?.cameras.length&&(p=r.cameras.length>m?.cameras.length?n(r.cameras,m?.cameras,i):n(m?.cameras,r.cameras,i),p=p.filter(G=>G.id!="default")),r.microphones.length!=m?.microphones.length&&(T=r.microphones.length>m?.microphones.length?n(r.microphones,m?.microphones,i):n(m?.microphones,r.microphones,i),T=T.filter(G=>G.id!="default"&&G.id!="communications"));let Z={cameras:p||[],microphones:T||[],status:r.cameras.length>m?.cameras.length||r.microphones.length>m?.microphones.length?"in":"out"};await this.repositoryDevices.save({...r,id:"devices",status:r.cameras.length>m?.cameras.length||r.microphones.length>m?.microphones.length?"in":"out"}),t.status&&(Z.cameras.length!=0||Z.microphones.length!=0)&&(ot.registerChangeDevice(this.proctoringId,Z.status,Z),t.status(Z))}};var v6="https://proctoring-api-dev.easyproctor.tech/api",b6="https://proctoring-api-hml.easyproctor.tech/api",o4="https://proctoring-api.easyproctor.tech/api",r1=class{constructor(t){this.options=t;this.baseUrl=this.selectBaseUrl(t.type),this.token=t.token}selectBaseUrl(t){return t==="dev"?v6:t==="homol"?b6:o4}async loginAuth(t,r){return await this.makeRequest({path:"/Auth",method:"POST",body:{emailOrCpf:t,key:r}})}async confirmStart(t,r,i,n){return await this.makeRequest({path:`/proctoring/start/${t.examId}`,method:"POST",body:{clientId:t.clientId,proctoringType:r,latitude:i,longitude:n},jwt:t.token})}async getParamsConfig(t){return(await this.makeRequestAxios({path:"/Client/params",method:"GET",jwt:t.token}).catch(i=>{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,i){return(await this.makeRequestAxios({path:"/upload/signed-url",method:"POST",jwt:t,body:{objectName:`${i}/${r.name}`,contentType:r.type}})).data}async saveScreenAlerts(t,r){await this.makeRequest({path:"/proctoring/save-screen",method:"POST",jwt:t.token,body:{proctoringId:r.id,alerts:r.alerts}})}async finishAndSendUrls(t,r){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 i;return r?.success!==null&&r?.success!==void 0?i=r.success?"4":"1":i="4",await this.makeRequest({path:"/Log",method:"POST",body:{entryType:i,eventName:t,message:r},jwt:this.token})}async getServerHour(t){return await this.makeRequest({path:"/Proctoring/server-hour",method:"GET",jwt:t})}async makeRequest(t){let{path:r,method:i,body:n,jwt:s}=t,a=await fetch(this.baseUrl+r,{method:i,body:n!=null?JSON.stringify(n):void 0,headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}});if(a.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let m=a.headers.get("content-type");return(m?m.includes("application/json"):!1)?await a.json():null}async makeRequestAxios(t){let{path:r,method:i,body:n,jwt:s}=t,a=await kn.request({url:this.baseUrl+r,method:i,headers:{Authorization:`Bearer ${s}`,"Access-Control-Allow-Origin":"*"},data:n});if(a.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return a}async makeRequestPUT(t){let{url:r,method:i,body:n,jwt:s}=t,a=await fetch(r,{method:i,body:n!=null?JSON.stringify(n):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(a.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let m=a.headers.get("content-type");return(m?m.includes("application/json"):!1)?await a.json():null}};var la=class{constructor(t){this.loadingBoolean=!0;this.proctoringId=t}async upload(t,r){try{let{file:i,onProgress:n}=t,s=URL.createObjectURL(i),a=document.createElement("a");document.body.appendChild(a),a.style.display="none",a.href=s,a.download=i.name,a.click(),window.URL.revokeObjectURL(s),this.loadingBoolean=!1,clearInterval(this.loadingInterval),n&&n(Math.round(100))}catch{throw new Error("Error on machine download")}}};var i1=class{constructor(t,r){this.session=t;this.recorders=r}async startAll(){this.session.start();for(let t of this.recorders)await t.startRecording()}async pauseAll(){this.session.pause();for(let t of this.recorders)await t.pauseRecording()}async resumeAll(){this.session.resume();for(let t of this.recorders)await t.resumeRecording()}async stopAll(){for(let t of this.recorders)await t.stopRecording();this.session.stop()}async saveAllOnSession(){for(let t of this.recorders)await t.saveOnSession(this.session)}};var ca=class{constructor(t,r,i){this.session=t;this.proctoringId=r;this.uploadServices=i}async upload(t,r){await this.uploadRecordings(t,r)}async uploadRecordings(t,r){await this.uploadAllFiles(t,r),this.session.hasSomethingToUpload||this.session.setUploaded()}async uploadAllFiles(t,r){for(let i=0;i<this.session.recordings.length;i++){let n=this.session.recordings[i];if(n.upload)continue;let s=m=>{let p=(i*100+m)/this.session.recordings.length;r&&r(p)},a=await this.uploadFile(n,t,s).catch(()=>{});a&&(n.upload||(n.upload={storage:"upload",awsUrl:"",azureUrl:""}),a.uploaded&&(n.upload.storage=a.storage),a.storage==="upload"?a.url&&(n.upload.azureUrl=a.url):a.url&&(n.upload.awsUrl=a.url))}r&&r(100)}async uploadFile(t,r,i){for await(let n of this.uploadServices){let s=await n.upload({file:t.file,onProgress:a=>{i&&i(a)}},r);if(s){let a="";return t.file.name.search("camera")!==-1?a="Camera":t.file.name.search("screen")!==-1?a="Screen":t.file.name.search("audio")!==-1&&(a="Audio"),ot.registerUploadFile(this.proctoringId,`Upload File
232
232
  Name: ${t.file.name}
233
233
  Type: ${t.file.type}
234
- Size: ${t.file.size}`,a),s}}throw new Error("Could not upload")}};var n1=class{constructor(t,r,i){this.alerts=[];this.onLostFocusCallback=t.onLostFocusCallback,this.onFocusCallback=t.onFocusCallback,this.optionsProctoring=r,this.cameraRecorder=i}async startRecording(){this.startTime=new Date(Date.now()),this.optionsProctoring.captureScreen&&(window.addEventListener("blur",()=>this.onLostFocus()),window.addEventListener("focus",()=>this.onReturnFocus()))}async pauseRecording(){window.removeEventListener("blur",()=>this.onLostFocus()),window.removeEventListener("focus",()=>this.onReturnFocus())}async resumeRecording(){this.optionsProctoring.captureScreen&&(window.addEventListener("blur",()=>this.onLostFocus()),window.addEventListener("focus",()=>this.onReturnFocus()))}async stopRecording(){window.removeEventListener("blur",()=>this.onLostFocus()),window.removeEventListener("focus",()=>this.onReturnFocus())}async saveOnSession(t){this.alerts.forEach(r=>{t.addAlert(r)})}onLostFocus(){Date.now()-this.startTime?.getTime()>1e4&&(this.onLostFocusCallback(),this.alerts.push({begin:Date.now()-this.startTime.getTime(),end:0,alert:25}))}onReturnFocus(){let t=this.alerts[this.alerts.length-1];t&&(this.onFocusCallback(),t.end=Date.now()-this.startTime.getTime())}};var y6=l4();function c4(e){return new y6(e)}var ua=class{constructor(t){this.blobs=[];this.audioParams={recordingBitrate:128};t&&(this.audioParams=t)}async startRecording(){this.recorder=c4({bitRate:this.audioParams.recordingBitrate}),this.recorder.start().catch(t=>{throw new Error("Error on Audio to Start Recording")})}async pauseRecording(){}async resumeRecording(){}async stopRecording(){if(!this.recorder)return;let t=await this.recorder.stop().getMp3().then(async([r,i])=>({buffer:r,blob:i})).catch(r=>{alert("We could not retrieve your message")});t&&this.blobs.push(t.blob)}async saveOnSession(t,r,i){t.addRecording({device:"",file:new File(this.blobs,`EP_${t.id}_audio_${r&&i&&`${r}_${i}`||"0"}.mp3`,{type:"audio/mp3"}),origin:"Mic"})}};var f2=typeof self<"u"?self:{};function X4(e,t){e:{for(var r=["CLOSURE_FLAGS"],i=f2,n=0;n<r.length;n++)if((i=i[r[n]])==null){r=null;break e}r=i}return(e=r&&r[e])!=null?e:t}function gs(){throw Error("Invalid UTF8")}function u4(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var s1,Wc,g6=typeof TextDecoder<"u",S6,w6=typeof TextEncoder<"u";function z4(e){if(w6)e=(S6||=new TextEncoder).encode(e);else{let r=0,i=new Uint8Array(3*e.length);for(let n=0;n<e.length;n++){var t=e.charCodeAt(n);if(128>t)i[r++]=t;else{if(2048>t)i[r++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&n<e.length){let s=e.charCodeAt(++n);if(56320<=s&&57343>=s){t=1024*(t-55296)+s-56320+65536,i[r++]=t>>18|240,i[r++]=t>>12&63|128,i[r++]=t>>6&63|128,i[r++]=63&t|128;continue}n--}t=65533}i[r++]=t>>12|224,i[r++]=t>>6&63|128}i[r++]=63&t|128}}e=r===i.length?i:i.subarray(0,r)}return e}var go,q4=X4(610401301,!1),m2=X4(572417392,!0),h4=f2.navigator;function r2(e){return!!q4&&!!go&&go.brands.some(({brand:t})=>t&&t.indexOf(e)!=-1)}function hi(e){var t;return(t=f2.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function jn(){return!!q4&&!!go&&0<go.brands.length}function Kc(){return jn()?r2("Chromium"):(hi("Chrome")||hi("CriOS"))&&!(!jn()&&hi("Edge"))||hi("Silk")}go=h4&&h4.userAgentData||null;var A6=!jn()&&(hi("Trident")||hi("MSIE"));!hi("Android")||Kc(),Kc(),hi("Safari")&&(Kc()||!jn()&&hi("Coast")||!jn()&&hi("Opera")||!jn()&&hi("Edge")||(jn()?r2("Microsoft Edge"):hi("Edg/"))||jn()&&r2("Opera"));var $4={},po=null;function E6(e){var t=e.length,r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);var i=new Uint8Array(r),n=0;return function(s,a){function m(Ae){for(;p<s.length;){var ne=s.charAt(p++),pe=po[ne];if(pe!=null)return pe;if(!/^[\s\xa0]*$/.test(ne))throw Error("Unknown base64 encoding at char: "+ne)}return Ae}Y4();for(var p=0;;){var T=m(-1),Z=m(0),G=m(64),fe=m(64);if(fe===64&&T===-1)break;a(T<<2|Z>>4),G!=64&&(a(Z<<4&240|G>>2),fe!=64&&a(G<<6&192|fe))}}(e,function(s){i[n++]=s}),n!==r?i.subarray(0,n):i}function Y4(){if(!po){po={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var i=e.concat(t[r].split(""));$4[r]=i;for(var n=0;n<i.length;n++){var s=i[n];po[s]===void 0&&(po[s]=n)}}}}var W4=typeof Uint8Array<"u",K4=!A6&&typeof btoa=="function";function d4(e){if(!K4){var t;t===void 0&&(t=0),Y4(),t=$4[t];var r=Array(Math.floor(e.length/3)),i=t[64]||"";let p=0,T=0;for(;p<e.length-2;p+=3){var n=e[p],s=e[p+1],a=e[p+2],m=t[n>>2];n=t[(3&n)<<4|s>>4],s=t[(15&s)<<2|a>>6],a=t[63&a],r[T++]=m+n+s+a}switch(m=0,a=i,e.length-p){case 2:a=t[(15&(m=e[p+1]))<<2]||i;case 1:e=e[p],r[T]=t[e>>2]+t[(3&e)<<4|m>>4]+a+i}return r.join("")}for(t="",r=0,i=e.length-10240;r<i;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}var f4=/[-_.]/g,x6={"-":"+",_:"/",".":"="};function R6(e){return x6[e]||""}function Z4(e){if(!K4)return E6(e);f4.test(e)&&(e=e.replace(f4,R6)),e=atob(e);let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function x1(e){return W4&&e!=null&&e instanceof Uint8Array}var T6;function R1(){return T6||=new Uint8Array(0)}var pa={},k6;function Q4(e){if(e!==pa)throw Error("illegal external caller")}function _a(){return k6||=new Gn(null,pa)}function p2(e){Q4(pa);var t=e.D;return(t=t==null||x1(t)?t:typeof t=="string"?Z4(t):null)==null?t:e.D=t}var Gn=class{constructor(e,t){if(Q4(t),this.D=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}P(){let e=p2(this);return e?new Uint8Array(e):R1()}};function J4(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function _2(){return Error("Failed to read varint, encoding is invalid.")}function ef(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function tf(e){return e.length==0?_a():new Gn(e,pa)}function v2(e){if(typeof e=="string")return{buffer:Z4(e),A:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),A:!1};if(e.constructor===Uint8Array)return{buffer:e,A:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),A:!1};if(e.constructor===Gn)return{buffer:p2(e)||R1(),A:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),A:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function b2(){return typeof BigInt=="function"}var m4=!m2,p4=!m2,M6=typeof Uint8Array.prototype.slice=="function",rf,Bt=0,qt=0;function ma(e){let t=0>e,r=(e=Math.abs(e))>>>0;if(e=Math.floor((e-r)/4294967296),t){let[i,n]=g2(r,e);e=n,r=i}Bt=r>>>0,qt=e>>>0}function nf(e){let t=rf||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),qt=0,Bt=t.getUint32(0,!0)}function i2(e,t){return 4294967296*t+(e>>>0)}function y2(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),e=i2(e,t),r?-e:e}function d1(e,t){if(e>>>=0,2097151>=(t>>>=0))var r=""+(4294967296*t+e);else b2()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,1e7<=e&&(r+=Math.floor(e/1e7),e%=1e7),1e7<=r&&(t+=Math.floor(r/1e7),r%=1e7),r=t+_4(r)+_4(e));return r}function _4(e){return e=String(e),"0000000".slice(e.length)+e}function T1(e){if(16>e.length)ma(Number(e));else if(b2())e=BigInt(e),Bt=Number(e&BigInt(4294967295))>>>0,qt=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");qt=Bt=0;let r=e.length;for(let i=t,n=(r-t)%6+t;n<=r;i=n,n+=6){let s=Number(e.slice(i,n));qt*=1e6,Bt=1e6*Bt+s,4294967296<=Bt&&(qt+=Math.trunc(Bt/4294967296),qt>>>=0,Bt>>>=0)}if(t){let[i,n]=g2(Bt,qt);Bt=i,qt=n}}}function g2(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function S2(e,t){let r,i=0,n=0,s=0,a=e.i,m=e.g;do r=a[m++],i|=(127&r)<<s,s+=7;while(32>s&&128&r);for(32<s&&(n|=(127&r)>>4),s=3;32>s&&128&r;s+=7)r=a[m++],n|=(127&r)<<s;if(As(e,m),128>r)return t(i>>>0,n>>>0);throw _2()}function w2(e){let t=0,r=e.g,i=r+10,n=e.i;for(;r<i;){let s=n[r++];if(t|=s,(128&s)==0)return As(e,r),!!(127&t)}throw _2()}function zr(e){let t=e.i,r=e.g,i=t[r++],n=127&i;if(128&i&&(i=t[r++],n|=(127&i)<<7,128&i&&(i=t[r++],n|=(127&i)<<14,128&i&&(i=t[r++],n|=(127&i)<<21,128&i&&(i=t[r++],n|=i<<28,128&i&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw _2();return As(e,r),n}function n2(e){var t=e.i;let r=e.g,i=t[r],n=t[r+1],s=t[r+2];return t=t[r+3],As(e,e.g+4),(i<<0|n<<8|s<<16|t<<24)>>>0}function s2(e){var t=n2(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:1/0*e:r==0?e*Math.pow(2,-149)*t:e*Math.pow(2,r-150)*(t+Math.pow(2,23))}function B6(e){return zr(e)}function Zc(e,t,{F:r=!1}={}){e.F=r,t&&(t=v2(t),e.i=t.buffer,e.m=t.A,e.u=0,e.j=e.i.length,e.g=e.u)}function As(e,t){if(e.g=t,t>e.j)throw ef(e.j,t)}function sf(e,t){if(0>t)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,i=r+t;if(i>e.j)throw ef(t,e.j-r);return e.g=i,r}function af(e,t){if(t==0)return _a();var r=sf(e,t);return e.F&&e.m?r=e.i.subarray(r,r+t):(e=e.i,r=r===(t=r+t)?R1():M6?e.slice(r,t):new Uint8Array(e.subarray(r,t))),tf(r)}var v4=[];function of(e){var t=e.g;if(t.g==t.j)return!1;e.j=e.g.g;var r=zr(e.g)>>>0;if(t=r>>>3,!(0<=(r&=7)&&5>=r))throw J4(r,e.j);if(1>t)throw Error(`Invalid field number: ${t} (at position ${e.j})`);return e.m=t,e.i=r,!0}function l1(e){switch(e.i){case 0:e.i!=0?l1(e):w2(e.g);break;case 1:As(e=e.g,e.g+8);break;case 2:if(e.i!=2)l1(e);else{var t=zr(e.g)>>>0;As(e=e.g,e.g+t)}break;case 5:As(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!of(e))throw Error("Unmatched start-group tag: stream EOF");if(e.i==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}l1(e)}break;default:throw J4(e.i,e.j)}}function k1(e,t,r){let i=e.g.j,n=zr(e.g)>>>0,s=e.g.g+n,a=s-i;if(0>=a&&(e.g.j=s,r(t,e,void 0,void 0,void 0),a=s-e.g.g),a)throw Error(`Message parsing ended unexpectedly. Expected to read ${n} bytes, instead read ${n-a} bytes, either the data ended unexpectedly or the message misreported its own length`);e.g.g=s,e.g.j=i}function A2(e){var t=zr(e.g)>>>0,r=sf(e=e.g,t);if(e=e.i,g6){var i,n=e;(i=Wc)||(i=Wc=new TextDecoder("utf-8",{fatal:!0})),t=r+t,n=r===0&&t===n.length?n:n.subarray(r,t);try{var s=i.decode(n)}catch(m){if(s1===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),s1=!0}catch{s1=!1}}throw!s1&&(Wc=void 0),m}}else{t=(s=r)+t,r=[];let m,p=null;for(;s<t;){var a=e[s++];128>a?r.push(a):224>a?s>=t?gs():(m=e[s++],194>a||(192&m)!=128?(s--,gs()):r.push((31&a)<<6|63&m)):240>a?s>=t-1?gs():(m=e[s++],(192&m)!=128||a===224&&160>m||a===237&&160<=m||(192&(i=e[s++]))!=128?(s--,gs()):r.push((15&a)<<12|(63&m)<<6|63&i)):244>=a?s>=t-2?gs():(m=e[s++],(192&m)!=128||m-144+(a<<28)>>30!=0||(192&(i=e[s++]))!=128||(192&(n=e[s++]))!=128?(s--,gs()):(a=(7&a)<<18|(63&m)<<12|(63&i)<<6|63&n,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):gs(),8192<=r.length&&(p=u4(p,r),r.length=0)}s=u4(p,r)}return s}function lf(e){let t=zr(e.g)>>>0;return af(e.g,t)}function E2(e,t,r){var i=zr(e.g)>>>0;for(i=e.g.g+i;e.g.g<i;)r.push(t(e.g))}var a1=[];function b4(e){return e?/^\d+$/.test(e)?(T1(e),new y4(Bt,qt)):null:I6||=new y4(0,0)}var y4=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},I6;function g4(e){return e?/^-?\d+$/.test(e)?(T1(e),new S4(Bt,qt)):null:C6||=new S4(0,0)}var S4=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},C6;function f1(e,t,r){for(;0<r||127<t;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function M1(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function B1(e,t){if(0<=t)M1(e,t);else{for(let r=0;9>r;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function m1(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function va(e,t){t.length!==0&&(e.j.push(t),e.i+=t.length)}function Qi(e,t,r){M1(e.g,8*t+r)}function x2(e,t){return Qi(e,t,2),t=e.g.end(),va(e,t),t.push(e.i),t}function R2(e,t){var r=t.pop();for(r=e.i+e.g.length()-r;127<r;)t.push(127&r|128),r>>>=7,e.i++;t.push(r),e.i++}function I1(e,t,r){Qi(e,t,2),M1(e.g,r.length),va(e,e.g.end()),va(e,r)}var Wi,Ki=class{constructor(t,r,i,n){this.g=t,this.i=r,this.j=i,this.N=n}};function qr(e){return Array.prototype.slice.call(e)}var T2=(Wi=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol():void 0)?(e,t)=>{e[Wi]|=t}:(e,t)=>{e.o!==void 0?e.o|=t:Object.defineProperties(e,{o:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function w4(e){let t=$t(e);(1&t)!=1&&(Object.isFrozen(e)&&(e=qr(e)),Nt(e,1|t))}var a2=Wi?(e,t)=>{e[Wi]&=~t}:(e,t)=>{e.o!==void 0&&(e.o&=~t)};function ar(e,t,r){return r?e|t:e&~t}var $t=Wi?e=>0|e[Wi]:e=>0|e.o,lt=Wi?e=>e[Wi]:e=>e.o,Nt=Wi?(e,t)=>{e[Wi]=t}:(e,t)=>{e.o!==void 0?e.o=t:Object.defineProperties(e,{o:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function A4(){var e=[];return T2(e,1),e}function O6(e,t){Nt(t,-14591&(0|e))}function o2(e,t){Nt(t,-14557&(34|e))}function p1(e){return(e=e>>14&1023)===0?536870912:e}var Eo={},P6={};function E4(e){return!(!e||typeof e!="object"||e.W!==P6)}function _o(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}var cf=!m2;function uf(e,t,r){if(e!=null){if(typeof e=="string")e=e?new Gn(e,pa):_a();else if(e.constructor!==Gn)if(x1(e))e=r?tf(e):e.length?new Gn(new Uint8Array(e),pa):_a();else{if(!t)throw Error();e=void 0}}return e}function l2(e,t,r){if(!Array.isArray(e)||e.length)return!1;let i=$t(e);return!!(1&i)||!(!t||!(Array.isArray(t)?t.includes(r):t.has(r)))&&(Nt(e,1|i),!0)}var ws,x4=[];function vn(e){if(2&e)throw Error()}var Xn,So;function hf(e,t){(t=Xn?t[Xn]:void 0)&&(e[Xn]=qr(t))}Nt(x4,55),ws=Object.freeze(x4);function R4(){let e=Error("int32");return e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity="warning",e}function xo(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function T4(e){if(e!=null&&typeof e!="boolean"){var t=typeof e;throw Error(`Expected boolean but got ${t!="object"?t:e?Array.isArray(e)?"array":t:"null"}: ${e}`)}return e}Object.freeze(new class{}),Object.freeze(new class{});var L6=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function k2(e){let t=typeof e;return t==="number"?Number.isFinite(e):t==="string"&&L6.test(e)}function xs(e){if(e==null)return e;if(typeof e=="string"){if(!e)return;e=+e}return typeof e=="number"&&Number.isFinite(e)?0|e:void 0}function k4(e){return e[0]!=="-"&&(20>e.length||e.length===20&&184467>Number(e.substring(0,6)))}function df(e){return e=Math.trunc(e),Number.isSafeInteger(e)||(ma(e),e=y2(Bt,qt)),e}function ff(e){var t=Math.trunc(Number(e));if(Number.isSafeInteger(t))return String(t);if((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),!(e[0]==="-"?20>e.length||e.length===20&&-922337<Number(e.substring(0,7)):19>e.length||e.length===19&&922337>Number(e.substring(0,6))))if(T1(e),e=Bt,2147483648&(t=qt))if(b2())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,i]=g2(e,t);e="-"+d1(r,i)}else e=d1(e,t);return e}function mf(e){if(typeof e!="string")throw Error();return e}function _1(e){if(e!=null&&typeof e!="string")throw Error();return e}function Es(e){return e==null||typeof e=="string"?e:void 0}function pf(e,t,r){if(e!=null&&typeof e=="object"&&e.C===Eo)return e;if(Array.isArray(e)){var i=$t(e),n=i;return n===0&&(n|=32&r),(n|=2&r)!==i&&Nt(e,n),new t(e)}}var v1,M2,F6;function b1(e){switch(typeof e){case"boolean":return M2||=[0,void 0,!0];case"number":return 0<e?void 0:e===0?F6||=[0,void 0]:[-e,void 0];case"string":return[0,e];case"object":return e}}function wo(e,t,r){if(e==null&&(e=v1),v1=void 0,e==null){var i=96;r?(e=[r],i|=512):e=[],t&&(i=-16760833&i|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error();if(64&(i=$t(e)))return So&&delete e[So],e;if(i|=64,r&&(i|=512,r!==e[0]))throw Error();e:{let n=(r=e).length;if(n){let s=n-1;if(_o(r[s])){if(1024<=(t=s-(+!!(512&(i|=256))-1)))throw Error();i=-16760833&i|(1023&t)<<14;break e}}if(t){if(1024<(t=Math.max(t,n-(+!!(512&i)-1))))throw Error();i=-16760833&i|(1023&t)<<14}}}return Nt(e,i),e}function _f(e,t,r,i,n,s){if(e!=null){if(Array.isArray(e))e=n&&e.length==0&&1&$t(e)?void 0:s&&2&$t(e)?e:B2(e,t,r,i!==void 0,n,s);else if(_o(e)){let a={};for(let m in e)a[m]=_f(e[m],t,r,i,n,s);e=a}else e=t(e,i);return e}}function B2(e,t,r,i,n,s){let a=i||r?$t(e):0;i=i?!!(32&a):void 0;let m=qr(e);for(let p=0;p<m.length;p++)m[p]=_f(m[p],t,r,i,n,s);return r&&(hf(m,e),r(a,m)),m}function D6(e){return e.C===Eo?e.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"boolean":return t?1:0;case"object":if(t){if(Array.isArray(t))return cf||!l2(t,void 0,9999)?t:void 0;if(x1(t))return d4(t);if(t instanceof Gn){let r=t.D;return r==null?"":typeof r=="string"?r:t.D=d4(r)}}}return t}(e)}function vf(e,t,r=o2){if(e!=null){if(W4&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var i=$t(e);return 2&i?e:(t&&=i===0||!!(32&i)&&!(64&i||!(16&i)),t?(Nt(e,-12293&(34|i)),e):B2(e,vf,4&i?o2:r,!0,!1,!0))}return e.C===Eo&&(r=e.l,e=2&(i=lt(r))?e:I2(e,r,i,!0)),e}}function bf(e){let t=e.l;return I2(e,t,lt(t),!1)}function I2(e,t,r,i){return e=e.constructor,v1=t=yf(t,r,i),t=new e(t),v1=void 0,t}function yf(e,t,r){let i=r||2&t?o2:O6,n=!!(32&t);return e=function(s,a,m){let p=qr(s);var T=p.length;let Z=256&a?p[T-1]:void 0;for(T+=Z?-1:0,a=512&a?1:0;a<T;a++)p[a]=m(p[a]);if(Z){a=p[a]={};for(let G in Z)a[G]=m(Z[G])}return hf(p,s),p}(e,t,s=>vf(s,n,i)),T2(e,32|(r?2:0)),e}function C2(e){let t=e.l,r=lt(t);return 2&r?I2(e,t,r,!1):e}function _n(e,t){return qn(e=e.l,lt(e),t)}function qn(e,t,r,i){if(r===-1)return null;if(r>=p1(t)){if(256&t)return e[e.length-1][r]}else{var n=e.length;if(i&&256&t&&(i=e[n-1][r])!=null)return i;if((t=r+(+!!(512&t)-1))<n)return e[t]}}function or(e,t,r,i){let n=e.l,s=lt(n);return vn(s),Ut(n,s,t,r,i),e}function Ut(e,t,r,i,n){var s=p1(t);if(r>=s||n){if(n=t,256&t)s=e[e.length-1];else{if(i==null)return n;s=e[s+(+!!(512&t)-1)]={},n|=256}return s[r]=i,n!==t&&Nt(e,n),n}return e[r+(+!!(512&t)-1)]=i,256&t&&r in(e=e[e.length-1])&&delete e[r],t}function Ro(e,t,r,i,n){var s=2&t;let a=qn(e,t,r,n);Array.isArray(a)||(a=ws);let m=!(2&i);i=!(1&i);let p=!!(32&t),T=$t(a);return T!==0||!p||s||m?1&T||(T|=1,Nt(a,T)):(T|=33,Nt(a,T)),s?(e=!1,2&T||(T2(a,34),e=!!(4&T)),(i||e)&&Object.freeze(a)):(s=!!(2&T)||!!(2048&T),i&&s?(a=qr(a),i=1,p&&!m&&(i|=32),Nt(a,i),Ut(e,t,r,a,n)):m&&32&T&&!s&&a2(a,32)),a}function gf(e){e=e.l;let t=lt(e),r=qn(e,t,1),i=uf(r,!0,!!(34&t));return i!=null&&i!==r&&Ut(e,t,1,i),i}function Sf(e,t){return e=qn(e,t,1),Array.isArray(e)?e:ws}function wf(e,t,r){return e===0&&(e=Rs(e,t,r)),ar(e,1,!0)}function vo(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function M4(e,t,r){{let a=e.l,m=lt(a);if(vn(m),r==null)Ut(a,m,t);else{var i,n=e=$t(r),s=!!(2&e)||Object.isFrozen(r);if((i=!s)&&(i=!1),!(4&e))for(e=21,s&&(r=qr(r),n=0,e=Rs(e,m,!0)),s=0;s<r.length;s++)r[s]=mf(r[s]);i&&(r=qr(r),n=0,e=Rs(e,m,!0)),e!==n&&Nt(r,e),Ut(a,m,t,r)}}}function Af(e,t){e=e.l;let r=lt(e);vn(r),Ut(e,r,2,t===""?void 0:t)}function Ef(e,t,r,i){let n=lt(e);vn(n),e=Ro(e,n,t,2),i=r(i,!!(4&(t=$t(e)))&&!!(4096&t)),e.push(i)}function N6(e){return e}function Qc(e,t){return O2(e=e.l,lt(e),cm)===t?t:-1}function O2(e,t,r){let i=0;for(let n=0;n<r.length;n++){let s=r[n];qn(e,t,s)!=null&&(i!==0&&(t=Ut(e,t,i)),i=s)}return i}function P2(e,t,r,i){let n=lt(e);vn(n);let s=qn(e,n,r,i),a;if(s!=null&&s.C===Eo)return(t=C2(s))!==s&&Ut(e,n,r,t,i),t.l;if(Array.isArray(s)){let m=$t(s);a=2&m?yf(s,m,!1):s,a=wo(a,t[0],t[1])}else a=wo(void 0,t[0],t[1]);return a!==s&&Ut(e,n,r,a,i),a}function xf(e,t,r,i){e=e.l;let n=lt(e),s=qn(e,n,r,i);return(t=pf(s,t,n))!==s&&t!=null&&Ut(e,n,r,t,i),t}function ki(e,t,r){if((t=xf(e,t,r,!1))==null)return t;e=e.l;let i=lt(e);if(!(2&i)){let n=C2(t);n!==t&&Ut(e,i,r,t=n,!1)}return t}function Rf(e,t,r,i,n){var s=!!(2&t),a=s?1:2;let m=a===1;a=a===2,i=!!i,n&&=!s,s=Sf(e,t);var p=$t(s);let T=!!(4&p);if(!T){var Z,G=s,fe=t;(Z=!!(2&(p=wf(p,t,i))))&&(fe=ar(fe,2,!0));let Ae=!Z,ne=!0,pe=0,J=0;for(;pe<G.length;pe++){let Ue=pf(G[pe],r,fe);if(Ue instanceof r){if(!Z){let Pe=!!(2&$t(Ue.l));Ae&&=!Pe,ne&&=Pe}G[J++]=Ue}}J<pe&&(G.length=J),p=ar(p,4,!0),p=ar(p,16,ne),p=ar(p,8,Ae),Nt(G,p),Z&&Object.freeze(G)}if(r=!!(8&p)||m&&!s.length,n&&!r){for(vo(p)&&(s=qr(s),p=Rs(p,t,i),t=Ut(e,t,1,s)),n=s,r=p,G=0;G<n.length;G++)(p=n[G])!==(fe=C2(p))&&(n[G]=fe);r=ar(r,8,!0),r=ar(r,16,!n.length),Nt(n,r),p=r}return vo(p)||(n=p,m?p=ar(p,!s.length||16&p&&(!T||32&p)?2:2048,!0):i||(p=ar(p,32,!1)),p!==n&&Nt(s,p),m&&Object.freeze(s)),a&&vo(p)&&(s=qr(s),p=Rs(p,t,i),Nt(s,p),Ut(e,t,1,s)),s}function L2(e,t){e=e.l;let r=lt(e);return Rf(e,r,t,!1,!(2&r))}function Mi(e,t,r,i,n){return i==null&&(i=void 0),or(e,r,i,n)}function Jc(e,t,r){var i=nm;r==null&&(r=void 0),e=e.l;let n=lt(e);vn(n),(i=O2(e,n,i))&&i!==t&&r!=null&&(n=Ut(e,n,i)),Ut(e,n,t,r)}function Rs(e,t,r){return e=ar(e,2,!!(2&t)),e=ar(e,32,!!(32&t)&&r),ar(e,2048,!1)}function Tf(e,t){var r=D1;e=e.l;let i=lt(e);vn(i),e=Rf(e,i,r,!0),t=t??new r,e.push(t),2&$t(t.l)?a2(e,8):a2(e,16)}function c2(e){return(e=_n(e,2))==null?e:k2(e)?typeof e=="number"?df(e):ff(e):void 0}function kf(e){return e??0}function Ir(e,t,r){Ef(e.l,t,mf,r)}function Mf(e,t,r){t.g?t.j(e,t.g,t.i,r,!0):t.j(e,t.i,r,!0)}var It=class{constructor(e,t){this.l=wo(e,t)}toJSON(){return Bf(this,B2(this.l,D6,void 0,void 0,!1,!1),!0)}A(){return!!(2&$t(this.l))}};function Bf(e,t,r){let i=e.constructor.v;var n=lt(r?e.l:t),s=p1(n),a=!1;if(i&&cf){if(!r){var m;if((t=qr(t)).length&&_o(m=t[t.length-1])){for(a=0;a<i.length;a++)if(i[a]>=s){Object.assign(t[t.length-1]={},m);break}}a=!0}var p;s=t,r=!r,e=p1(m=lt(e.l)),m=+!!(512&m)-1;for(let J=0;J<i.length;J++){var T=i[J];if(T<e){var Z=s[T+=m];Z==null?s[T]=r?ws:A4():r&&Z!==ws&&w4(Z)}else{if(!p){var G=void 0;s.length&&_o(G=s[s.length-1])?p=G:s.push(p={})}Z=p[T],p[T]==null?p[T]=r?ws:A4():r&&Z!==ws&&w4(Z)}}}if(!(p=t.length))return t;let fe,Ae;if(_o(G=t[p-1])){e:{var ne=G;for(var pe in s={},r=!1,ne)e=ne[pe],Array.isArray(e)&&(m=e,(!p4&&l2(e,i,+pe)||!m4&&E4(e)&&e.size===0)&&(e=null),e!=m&&(r=!0)),e!=null?s[pe]=e:r=!0;if(r){for(let J in s){ne=s;break e}ne=null}}ne!=G&&(fe=!0),p--}for(n=+!!(512&n)-1;0<p&&((G=t[pe=p-1])==null||!p4&&l2(G,i,pe-n)||!m4&&E4(G)&&G.size===0);p--)Ae=!0;return(fe||Ae)&&(t=a?t:Array.prototype.slice.call(t,0,p),a&&(t.length=p),ne&&t.push(ne)),t}function If(e){return Array.isArray(e)?e[0]instanceof Ki?e:[W6,e]:[e,void 0]}function C1(e,t){if(Array.isArray(t)){var r=$t(t);if(4&r)return t;for(var i=0,n=0;i<t.length;i++){let s=e(t[i]);s!=null&&(t[n++]=s)}return n<i&&(t.length=n),Nt(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}It.prototype.C=Eo,It.prototype.toString=function(){return Bf(this,this.l,!1).toString()};var B4=Symbol();function F2(e){let t=e[B4];if(!t){let r=Pf(e),i=N2(e),n=i.g;t=n?(s,a)=>n(s,a,i):(s,a)=>{for(;of(a)&&a.i!=4;){var m=a.m,p=i[m];if(!p){var T=i.K;T&&(T=T[m])&&(p=i[m]=V6(T))}p&&p(a,s,m)||(m=(p=a).j,l1(p),p.J?p=void 0:(T=p.g.g-m,p.g.g=m,p=af(p.g,T)),m=s,p&&(Xn||=Symbol(),(T=m[Xn])?T.push(p):m[Xn]=[p]))}r===Cf||r===Of||r.T||(s[So||=Symbol()]=r)},e[B4]=t}return t}function V6(e){let t=(e=If(e))[0].g;if(e=e[1]){let r=F2(e),i=N2(e).B;return(n,s,a)=>t(n,s,a,i,r)}return t}var Cf,Of,c1=Symbol();function U6(e,t,r){let i=r[1],n;if(i){let s=i[c1];n=s?s.B:b1(i[0]),e[t]=s??i}n&&n===M2?(e.L||(e.L=[])).push(t):r[0]&&(e.M||(e.M=[])).push(t)}function I4(e,t){return[e.j,!t||0<t[0]?void 0:t]}function Pf(e){var t=e[c1];if(t)return t;if(!(t=D2(e,e[c1]={},I4,I4,U6)).M&&!t.L){let r=!0;for(let i in t){isNaN(i)||(r=!1);break}r?(t=b1(e[0])===M2,t=e[c1]=t?Of||={B:b1(!0)}:Cf||={}):t.T=!0}return t}function H6(e,t,r){e[t]=r}function D2(e,t,r,i,n=H6){t.B=b1(e[0]);let s=0;var a=e[++s];a&&a.constructor===Object&&(t.K=a,typeof(a=e[++s])=="function"&&(t.g=a,t.i=e[++s],a=e[++s]));let m={};for(;Array.isArray(a)&&typeof a[0]=="number"&&0<a[0];){for(var p=0;p<a.length;p++)m[a[p]]=a;a=e[++s]}for(p=1;a!==void 0;){let G;typeof a=="number"&&(p+=a,a=e[++s]);var T=void 0;if(a instanceof Ki?G=a:(G=K6,s--),G.N){a=e[++s],T=e;var Z=s;typeof a=="function"&&(a=a(),T[Z]=a),T=a}for(Z=p+1,typeof(a=e[++s])=="number"&&0>a&&(Z-=a,a=e[++s]);p<Z;p++){let fe=m[p];n(t,p,T?i(G,T,fe):r(G,fe))}}return t}var C4=Symbol();function Lf(e){let t=e[C4];if(!t){let r=O1(e);t=(i,n)=>Ff(i,n,r),e[C4]=t}return t}var u1=Symbol();function j6(e){return e.i}function G6(e,t){let r,i,n=e.i;return(s,a,m)=>n(s,a,m,i||=O1(t).B,r||=Lf(t))}function O1(e){let t=e[u1];return t||(t=D2(e,e[u1]={},j6,G6),h1 in e&&u1 in e&&(e.length=0),t)}var h1=Symbol();function X6(e,t){let r=e.g;return t?(i,n,s)=>r(i,n,s,t):r}function z6(e,t,r){let i=e.g,n,s;return(a,m,p)=>i(a,m,p,s||=N2(t).B,n||=F2(t),r)}function N2(e){let t=e[h1];return t||(Pf(e),t=D2(e,e[h1]={},X6,z6),h1 in e&&u1 in e&&(e.length=0),t)}function O4(e,t){var r=e[t];if(r)return r;if((r=e.K)&&(r=r[t])){var i=(r=If(r))[0].i;if(r=r[1]){let n=Lf(r),s=O1(r).B;r=(r=e.i)?r(s,n):(a,m,p)=>i(a,m,p,s,n)}else r=i;return e[t]=r}}function Ff(e,t,r){for(var i=lt(e),n=+!!(512&i)-1,s=e.length,a=512&i?1:0,m=s+(256&i?-1:0);a<m;a++){let p=e[a];if(p==null)continue;let T=a-n,Z=O4(r,T);Z&&Z(t,p,T)}if(256&i){i=e[s-1];for(let p in i)n=+p,Number.isNaN(n)||(s=i[p])!=null&&(m=O4(r,n))&&m(t,s,n)}if(e=Xn?e[Xn]:void 0)for(va(t,t.g.end()),r=0;r<e.length;r++)va(t,p2(e[r])||R1())}function Cr(e,t){return new Ki(e,t,!1,!1)}function P1(e,t){return new Ki(e,t,!0,!1)}function Or(e,t,r){Ut(e,lt(e),t,r)}function Df(e,t,r){e:if(t!=null){if(k2(t)){if(typeof t=="string"){t=ff(t);break e}if(typeof t=="number"){t=df(t);break e}}t=void 0}t!=null&&(typeof t=="string"&&g4(t),t!=null&&(Qi(e,r,0),typeof t=="number"?(e=e.g,ma(t),f1(e,Bt,qt)):(r=g4(t),f1(e.g,r.i,r.g))))}function Nf(e,t,r){(t=xs(t))!=null&&t!=null&&(Qi(e,r,0),B1(e.g,t))}function Vf(e,t,r){(t=t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0)!=null&&(Qi(e,r,0),e.g.g.push(t?1:0))}function Uf(e,t,r){(t=Es(t))!=null&&I1(e,r,z4(t))}function L1(e,t,r,i,n){(t=t instanceof It?t.l:Array.isArray(t)?wo(t,i[0],i[1]):void 0)!=null&&(r=x2(e,r),n(t,e),R2(e,r))}function Hf(e,t,r){(t=t==null||typeof t=="string"||x1(t)||t instanceof Gn?t:void 0)!=null&&I1(e,r,v2(t).buffer)}var di,q6=Cr(function(e,t,r){if(e.i!==1)return!1;var i=e.g;e=n2(i);let n=n2(i);i=2*(n>>31)+1;let s=n>>>20&2047;return e=4294967296*(1048575&n)+e,Or(t,r,s==2047?e?NaN:1/0*i:s==0?i*Math.pow(2,-1074)*e:i*Math.pow(2,s-1075)*(e+4503599627370496)),!0},function(e,t,r){(t=xo(t))!=null&&(Qi(e,r,1),e=e.g,(r=rf||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),Bt=r.getUint32(0,!0),qt=r.getUint32(4,!0),m1(e,Bt),m1(e,qt))}),jf=Cr(function(e,t,r){return e.i===5&&(Or(t,r,s2(e.g)),!0)},function(e,t,r){(t=xo(t))!=null&&(Qi(e,r,5),e=e.g,nf(t),m1(e,Bt))}),$6=P1(function(e,t,r){return(e.i===5||e.i===2)&&(t=Ro(t,lt(t),r,2,!1),e.i==2?E2(e,s2,t):t.push(s2(e.g)),!0)},function(e,t,r){if((t=C1(xo,t))!=null&&t.length){Qi(e,r,2),M1(e.g,4*t.length);for(let i=0;i<t.length;i++)r=e.g,nf(t[i]),m1(r,Bt)}}),y1=Cr(function(e,t,r){return e.i===0&&(Or(t,r,S2(e.g,y2)),!0)},Df),e2=Cr(function(e,t,r){return e.i===0&&(Or(t,r,(e=S2(e.g,y2))===0?void 0:e),!0)},Df),Y6=Cr(function(e,t,r){return e.i===0&&(Or(t,r,S2(e.g,i2)),!0)},function(e,t,r){e:if(t!=null){if(k2(t)){if(typeof t=="string"){var i=Math.trunc(Number(t));Number.isSafeInteger(i)&&0<=i?t=String(i):((i=t.indexOf("."))!==-1&&(t=t.substring(0,i)),k4(t)||(T1(t),t=d1(Bt,qt)));break e}if(typeof t=="number"){t=0<=(t=Math.trunc(t))&&Number.isSafeInteger(t)?t:function(n){if(0>n){ma(n);let s=d1(Bt,qt);return n=Number(s),Number.isSafeInteger(n)?n:s}return k4(String(n))?n:(ma(n),i2(Bt,qt))}(t);break e}}t=void 0}t!=null&&(typeof t=="string"&&b4(t),t!=null&&(Qi(e,r,0),typeof t=="number"?(e=e.g,ma(t),f1(e,Bt,qt)):(r=b4(t),f1(e.g,r.i,r.g))))}),$n=Cr(function(e,t,r){return e.i===0&&(Or(t,r,zr(e.g)),!0)},Nf),Gf=P1(function(e,t,r){return(e.i===0||e.i===2)&&(t=Ro(t,lt(t),r,2,!1),e.i==2?E2(e,zr,t):t.push(zr(e.g)),!0)},function(e,t,r){if((t=C1(xs,t))!=null&&t.length){r=x2(e,r);for(let i=0;i<t.length;i++)B1(e.g,t[i]);R2(e,r)}}),ba=Cr(function(e,t,r){return e.i===0&&(Or(t,r,(e=zr(e.g))===0?void 0:e),!0)},Nf),Zi=Cr(function(e,t,r){return e.i===0&&(Or(t,r,w2(e.g)),!0)},Vf),bo=Cr(function(e,t,r){return e.i===0&&(Or(t,r,(e=w2(e.g))===!1?void 0:e),!0)},Vf),Bi=P1(function(e,t,r){return e.i===2&&(Ef(t,r,N6,e=A2(e)),!0)},function(e,t,r){if((t=C1(Es,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&I1(i,n,z4(s))}}),zn=Cr(function(e,t,r){return e.i===2&&(Or(t,r,(e=A2(e))===""?void 0:e),!0)},Uf),cr=Cr(function(e,t,r){return e.i===2&&(Or(t,r,A2(e)),!0)},Uf),W6=new Ki(function(e,t,r,i,n){return e.i===2&&(k1(e,P2(t,i,r,!0),n),!0)},L1,!1,!0),K6=new Ki(function(e,t,r,i,n){return e.i===2&&(k1(e,P2(t,i,r),n),!0)},L1,!1,!0);di=new Ki(function(e,t,r,i,n){if(e.i!==2)return!1;i=wo(void 0,i[0],i[1]);let s=lt(t);vn(s);let a=Ro(t,s,r,3);return s=lt(t),4&$t(a)&&(a=qr(a),Nt(a,-2079&(1|$t(a))),Ut(t,s,r,a)),a.push(i),k1(e,i,n),!0},function(e,t,r,i,n){if(Array.isArray(t))for(let s=0;s<t.length;s++)L1(e,t[s],r,i,n)},!0,!0);var fi=new Ki(function(e,t,r,i,n,s){if(e.i!==2)return!1;let a=lt(t);return vn(a),(s=O2(t,a,s))&&r!==s&&Ut(t,a,s),k1(e,t=P2(t,i,r),n),!0},L1,!1,!0),Xf=Cr(function(e,t,r){return e.i===2&&(Or(t,r,lf(e)),!0)},Hf),Ao=Cr(function(e,t,r){return e.i===0&&(Or(t,r,zr(e.g)),!0)},function(e,t,r){(t=xs(t))!=null&&(t=parseInt(t,10),Qi(e,r,0),B1(e.g,t))}),Z6=P1(function(e,t,r){return(e.i===0||e.i===2)&&(t=Ro(t,lt(t),r,2,!1),e.i==2?E2(e,B6,t):t.push(zr(e.g)),!0)},function(e,t,r){if((t=C1(xs,t))!=null&&t.length){r=x2(e,r);for(let i=0;i<t.length;i++)B1(e.g,t[i]);R2(e,r)}}),g1=class{constructor(t,r){this.i=t,this.g=r,this.j=Mi,this.defaultValue=void 0}};function zf(e,t){return(r,i)=>{e:{if(a1.length){let s=a1.pop();s.s(i),Zc(s.g,r,i),r=s}else r=new class{constructor(s,a){if(v4.length){let m=v4.pop();Zc(m,s,a),s=m}else s=new class{constructor(m,p){this.i=null,this.m=!1,this.g=this.j=this.u=0,Zc(this,m,p)}clear(){this.i=null,this.m=!1,this.g=this.j=this.u=0,this.F=!1}}(s,a);this.g=s,this.j=this.g.g,this.i=this.m=-1,this.s(a)}s({J:s=!1}={}){this.J=s}}(r,i);try{let s=new e,a=s.l;F2(t)(a,r),So&&delete a[So];var n=s;break e}finally{r.g.clear(),r.m=-1,r.i=-1,100>a1.length&&a1.push(r)}n=void 0}return n}}var qf=[0,zn,Cr(function(e,t,r){return e.i===2&&(Or(t,r,(e=lf(e))===_a()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof It){let i=t.X;return void(i&&(t=i(t),t!=null&&I1(e,r,v2(t).buffer)))}if(Array.isArray(t))return}Hf(e,t,r)})],Q6=[0,cr],$f=[0,$n,Ao,Zi,-1,Gf,Ao,-1],J6=[0,Zi,-1],Yf=class extends It{constructor(){super()}};Yf.v=[6];var Wf=[0,Zi,cr,Zi,Ao,-1,Z6,cr,-1,J6,Ao],Kf=[0,cr,-2],P4=class extends It{constructor(){super()}},Zf=[0],Qf=[0,$n,Zi,-2],Jf=class extends It{constructor(e){super(e,2)}},F1={},ev=[-2,F1,Zi];F1[336783863]=[0,cr,Zi,-1,$n,[0,[1,2,3,4,5],fi,Zf,fi,Wf,fi,Kf,fi,Qf,fi,$f],Q6];var tv=[0,zn,bo],em=[0,e2,-1,bo,-3,e2,Gf,zn,ba,e2,-1,bo,ba,bo,-2,zn],To=[-1,{}],tm=[0,cr,1,To],rm=[0,cr,Bi,To],D1=class extends It{constructor(e){super(e,500)}s(e){return Mi(this,0,7,e)}};D1.v=[3,4,5,6,8,13,17,1005];var L4,rv=[-500,zn,-1,Bi,-3,ev,di,qf,ba,-1,tm,rm,di,tv,zn,em,ba,Bi,987,Bi],iv=[0,zn,-1,To],nv=[-500,cr,-1,[-1,{}],998,cr],sv=[-500,cr,Bi,-1,[-2,{},Zi],997,Bi,-1],av=[-500,cr,Bi,To,998,Bi],S1=class extends It{constructor(){super(void 0,500)}s(e){return Mi(this,0,1001,e)}};S1.v=[1,6,7,9,10,15,16,17,14,1002],S1.prototype.g=(L4=[-500,di,rv,4,di,nv,di,sv,ba,di,av,Bi,ba,tm,rm,di,iv,Bi,-2,em,zn,-1,bo,979,To,di,qf],function(){let e=new class{constructor(){this.j=[],this.i=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){let s=this.g;return this.g=[],s}}}};Ff(this.l,e,O1(L4)),va(e,e.g.end());let t=new Uint8Array(e.i),r=e.j,i=r.length,n=0;for(let s=0;s<i;s++){let a=r[s];t.set(a,n),n+=a.length}return e.j=[t],t});var ov=class extends It{constructor(e){super(e)}},lv=[0,$n,jf,cr,-1],im=class extends It{constructor(e){super(e)}g(){return L2(this,ov)}};im.v=[1];var cv=[0,di,lv],u2=class extends It{constructor(e){super(e)}};u2.v=[4,5];var F4=class extends It{constructor(e){super(e)}},nm=[1,2,3,4,5],w1=class extends It{constructor(e){super(e)}g(){return gf(this)!=null}i(){return Es(_n(this,2))!=null}},A1=class extends It{constructor(e){super(e)}},sm=[0,[0,Xf,cr,[0,$n,y1,-1],[0,Y6,y1]],Zi,[0,nm,fi,Qf,fi,Wf,fi,$f,fi,Zf,fi,Kf],Ao],am=class extends It{constructor(e){super(e)}},uv=new g1(451755788,am);F1[451755788]=[0,sm,[0,cr,$n,jf,Bi,-1],q6];var D4=class extends It{constructor(e){super(e)}},om=class extends It{constructor(e){super(e)}},hv=new g1(487277289,om);F1[487277289]=[0,sm,[0,Zi,-1]];var dv=class extends It{constructor(e){super(e)}},fv=[0,1,$n,cr,cv],lm=class extends It{constructor(e){super(e)}};lm.v=[1];var mv=zf(lm,[0,di,fv,y1]),h2=class extends It{constructor(e){super(e)}};h2.v=[1];var pv=class extends It{constructor(e){super(e)}O(){let e=gf(this);return e??_a()}},_v=class extends It{constructor(e){super(e)}},cm=[1,2],vv=[0,cm,fi,[0,$6],fi,[0,Xf],$n,cr],um=class extends It{constructor(e){super(e)}};um.v=[1];var N4=zf(um,[0,di,vv,y1]);async function V4(e){if(typeof importScripts!="function"){let t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise((r,i)=>{t.addEventListener("load",()=>{r()},!1),t.addEventListener("error",n=>{i(n)},!1),document.body.appendChild(t)})}importScripts(e.toString())}function Xe(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.h.stringToNewUTF8(t)),e.h._free(t)}function U4(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");let i=new Uint32Array(t.length);for(let n=0;n<t.length;n++)i[n]=e.h.stringToNewUTF8(t[n]);t=e.h._malloc(4*i.length),e.h.HEAPU32.set(i,t>>2),r(t);for(let n of i)e.h._free(n);e.h._free(t)}function Ss(e,t,r){e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=r}function ha(e,t,r){let i=[];e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=(n,s,a)=>{s?(r(i,a),i=[]):i.push(n)}}var bv=function(e){return class extends e{U(){this.h._registerModelResourcesGraphService()}}}(class{constructor(e,t){this.j=!0,this.h=e,this.g=null,this.i=0,this.m=typeof this.h._addIntToInputStream=="function",t!==void 0?this.h.canvas=t:((e=typeof OffscreenCanvas>"u")||(e=(e=navigator.userAgent).includes("Safari")&&!e.includes("Chrome")),e?(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas")):this.h.canvas=new OffscreenCanvas(1,1))}async initializeGraph(e){let t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){let r=e.length,i=this.h._malloc(r);this.h.HEAPU8.set(e,i),t?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(e,t,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Xe(this,i||"input_audio",s=>{Xe(this,n=n||"audio_header",a=>{this.h._configureAudio(s,a,e,t,r)})})}setAutoResizeCanvas(e){this.j=e}setAutoRenderToScreen(e){this.h._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.h.gpuOriginForWebTexturesIsBottomLeft=e}attachErrorListener(e){this.h.errorListener=e}attachEmptyPacketListener(e,t){this.h.emptyPacketListeners=this.h.emptyPacketListeners||{},this.h.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,i,n){let s=4*e.length;this.i!==s&&(this.g&&this.h._free(this.g),this.g=this.h._malloc(s),this.i=s),this.h.HEAPF32.set(e,this.g/4),Xe(this,i,a=>{this.h._addAudioToInputStream(this.g,t,r,a,n)})}addGpuBufferToStream(e,t,r){Xe(this,t,i=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");i?this.h._bindTextureToStream(i):this.h._bindTextureToCanvas();var n=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!n)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");let s;this.h.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),this.h.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),e.videoWidth?(n=e.videoWidth,s=e.videoHeight):e.naturalWidth?(n=e.naturalWidth,s=e.naturalHeight):(n=e.width,s=e.height),!this.j||n===this.h.canvas.width&&s===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=s);let[a,m]=[n,s];this.h._addBoundTextureToStream(i,a,m,r)})}addBoolToStream(e,t,r){Xe(this,t,i=>{this.h._addBoolToInputStream(e,i,r)})}addDoubleToStream(e,t,r){Xe(this,t,i=>{this.h._addDoubleToInputStream(e,i,r)})}addFloatToStream(e,t,r){Xe(this,t,i=>{this.h._addFloatToInputStream(e,i,r)})}addIntToStream(e,t,r){Xe(this,t,i=>{this.h._addIntToInputStream(e,i,r)})}addStringToStream(e,t,r){Xe(this,t,i=>{Xe(this,e,n=>{this.h._addStringToInputStream(n,i,r)})})}addStringRecordToStream(e,t,r){Xe(this,t,i=>{U4(this,Object.keys(e),n=>{U4(this,Object.values(e),s=>{this.h._addFlatHashMapToInputStream(n,s,Object.keys(e).length,i,r)})})})}addProtoToStream(e,t,r,i){Xe(this,r,n=>{Xe(this,t,s=>{let a=this.h._malloc(e.length);this.h.HEAPU8.set(e,a),this.h._addProtoToInputStream(a,e.length,s,n,i),this.h._free(a)})})}addEmptyPacketToStream(e,t){Xe(this,e,r=>{this.h._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let s of e)this.h._addBoolVectorEntry(n,s);this.h._addBoolVectorToInputStream(n,i,r)})}addDoubleVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let s of e)this.h._addDoubleVectorEntry(n,s);this.h._addDoubleVectorToInputStream(n,i,r)})}addFloatVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let s of e)this.h._addFloatVectorEntry(n,s);this.h._addFloatVectorToInputStream(n,i,r)})}addIntVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let s of e)this.h._addIntVectorEntry(n,s);this.h._addIntVectorToInputStream(n,i,r)})}addStringVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let s of e)Xe(this,s,a=>{this.h._addStringVectorEntry(n,a)});this.h._addStringVectorToInputStream(n,i,r)})}addBoolToInputSidePacket(e,t){Xe(this,t,r=>{this.h._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){Xe(this,t,r=>{this.h._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){Xe(this,t,r=>{this.h._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){Xe(this,t,r=>{this.h._addIntToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){Xe(this,t,r=>{Xe(this,e,i=>{this.h._addStringToInputSidePacket(i,r)})})}addProtoToInputSidePacket(e,t,r){Xe(this,r,i=>{Xe(this,t,n=>{let s=this.h._malloc(e.length);this.h.HEAPU8.set(e,s),this.h._addProtoToInputSidePacket(s,e.length,n,i),this.h._free(s)})})}addBoolVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let n of e)this.h._addBoolVectorEntry(i,n);this.h._addBoolVectorToInputSidePacket(i,r)})}addDoubleVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let n of e)this.h._addDoubleVectorEntry(i,n);this.h._addDoubleVectorToInputSidePacket(i,r)})}addFloatVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let n of e)this.h._addFloatVectorEntry(i,n);this.h._addFloatVectorToInputSidePacket(i,r)})}addIntVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let n of e)this.h._addIntVectorEntry(i,n);this.h._addIntVectorToInputSidePacket(i,r)})}addStringVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let n of e)Xe(this,n,s=>{this.h._addStringVectorEntry(i,s)});this.h._addStringVectorToInputSidePacket(i,r)})}attachBoolListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachBoolListener(r)})}attachBoolVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachBoolVectorListener(r)})}attachIntListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachIntListener(r)})}attachIntVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachIntVectorListener(r)})}attachDoubleListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachDoubleVectorListener(r)})}attachFloatListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachFloatListener(r)})}attachFloatVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachFloatVectorListener(r)})}attachStringListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachStringListener(r)})}attachStringVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachStringVectorListener(r)})}attachProtoListener(e,t,r){Ss(this,e,t),Xe(this,e,i=>{this.h._attachProtoListener(i,r||!1)})}attachProtoVectorListener(e,t,r){ha(this,e,t),Xe(this,e,i=>{this.h._attachProtoVectorListener(i,r||!1)})}attachAudioListener(e,t,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Ss(this,e,(i,n)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,n)}),Xe(this,e,i=>{this.h._attachAudioListener(i,r||!1)})}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}}),hm=class extends bv{};async function yv(e,t,r){return e=await(async(i,n,s,a)=>{if(n&&await V4(n),!self.ModuleFactory||s&&(await V4(s),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&a&&((n=self.Module).locateFile=a.locateFile,a.mainScriptUrlOrBlob&&(n.mainScriptUrlOrBlob=a.mainScriptUrlOrBlob)),a=await self.ModuleFactory(self.Module||a),self.ModuleFactory=self.Module=void 0,new i(a,null)})(e,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:i=>i.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&i.endsWith(".data")?t.assetBinaryPath.toString():i}),await e.s(r),e}async function dm(e,t,r){return yv(e,t,r)}function H4(e,t){let r=ki(e.baseOptions,w1,1)||new w1;typeof t=="string"?(or(r,2,_1(t)),or(r,1)):t instanceof Uint8Array&&(or(r,1,uf(t,!1,!1)),or(r,2)),Mi(e.baseOptions,0,1,r)}function fm(e,t){let r=t.baseOptions||{};if(t.baseOptions?.modelAssetBuffer&&t.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(ki(e.baseOptions,w1,1)?.g()||ki(e.baseOptions,w1,1)?.i()||t.baseOptions?.modelAssetBuffer||t.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");return function(i,n){let s=ki(i.baseOptions,F4,3);if(!s){var a=s=new F4;Jc(a,4,new P4)}"delegate"in n&&(n.delegate==="GPU"?Jc(n=s,2,a=new Yf):Jc(n=s,4,a=new P4)),Mi(i.baseOptions,0,3,s)}(e,r),r.modelAssetPath?fetch(r.modelAssetPath.toString()).then(i=>{if(i.ok)return i.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${i.status})`)}).then(i=>{try{e.g.h.FS_unlink("/model.dat")}catch{}e.g.h.FS_createDataFile("/","model.dat",new Uint8Array(i),!0,!1,!1),H4(e,"/model.dat"),e.I()}):(H4(e,r.modelAssetBuffer),e.I(),Promise.resolve())}function j4(e){try{let t=e.j.length;if(t===1)throw Error(e.j[0].message);if(1<t)throw Error("Encountered multiple errors: "+e.j.map(r=>r.message).join(", "))}finally{e.j=[]}}function da(e,t){e.u=Math.max(e.u,t)}var d2=class{constructor(e){this.g=e,this.j=[],this.u=0,this.g.setAutoRenderToScreen(!1)}setGraph(e,t){this.g.attachErrorListener((r,i)=>{this.j.push(Error(i))}),this.g.U(),this.g.setGraph(e,t),j4(this)}finishProcessing(){this.g.finishProcessing(),j4(this)}close(){this.g.closeGraph()}};async function yo(e,t,r){return dm(e,t,r)}d2.prototype.close=d2.prototype.close;var E1=class extends d2{constructor(){super(...arguments),this.H=48e3}V(e){this.H=e}};function gv(e){let t={classifications:L2(e,dv).map(r=>function(i,n=-1,s=""){return{categories:i.map(a=>{var m=xs(_n(a,1))??0??-1;let p=a.l,T=lt(p),Z=qn(p,T,2),G=xo(Z);return G!=null&&G!==Z&&Ut(p,T,2,G),{index:m,score:G??0??0,categoryName:Es(_n(a,3))??""??"",displayName:Es(_n(a,4))??""??""}}),headIndex:n,headName:s}}(ki(r,im,4)?.g()??[],xs(_n(r,2))??0,Es(_n(r,3))??""))};return c2(e)!=null&&(t.timestampMs=kf(c2(e))),t}E1.prototype.setDefaultSampleRate=E1.prototype.V;var ui=class extends E1{constructor(e,t){super(new hm(e,t)),this.m=[],Mi(e=this.i=new am,0,1,t=new A1)}get baseOptions(){return ki(this.i,A1,1)}set baseOptions(e){Mi(this.i,0,1,e)}s(e){var t=this.i,r=ki(this.i,u2,2);if(r=r?bf(r):new u2,e.displayNamesLocale!==void 0?or(r,1,_1(e.displayNamesLocale)):e.displayNamesLocale===void 0&&or(r,1),e.maxResults!==void 0){var i=e.maxResults;if(i!=null){if(typeof i!="number"||!Number.isFinite(i))throw R4();i|=0}or(r,2,i)}else"maxResults"in e&&or(r,2);if(e.scoreThreshold!==void 0){if((i=e.scoreThreshold)!=null&&typeof i!="number")throw Error(`Value of float/double field must be a number, found ${typeof i}: ${i}`);or(r,3,i)}else"scoreThreshold"in e&&or(r,3);return e.categoryAllowlist!==void 0?M4(r,4,e.categoryAllowlist):"categoryAllowlist"in e&&or(r,4),e.categoryDenylist!==void 0?M4(r,5,e.categoryDenylist):"categoryDenylist"in e&&or(r,5),Mi(t,0,2,r),fm(this,e)}R(e,t){return this.G(e,t??this.H,this.u+1)}G(e,t,r){return this.g.addDoubleToStream(t,"sample_rate",r),this.g.addAudioToStreamWithShape(e,1,e.length,"audio_in",r),this.m=[],this.finishProcessing(),[...this.m]}I(){var e=new S1;Ir(e,10,"audio_in"),Ir(e,10,"sample_rate"),Ir(e,15,"timestamped_classifications");let t=new Jf;Mf(t,uv,this.i);let r=new D1;Af(r,_1("mediapipe.tasks.audio.audio_classifier.AudioClassifierGraph")),Ir(r,3,"AUDIO:audio_in"),Ir(r,3,"SAMPLE_RATE:sample_rate"),Ir(r,4,"TIMESTAMPED_CLASSIFICATIONS:timestamped_classifications"),r.s(t),Tf(e,r),this.g.attachProtoVectorListener("timestamped_classifications",(i,n)=>{(function(s,a){a.forEach(m=>{m=mv(m),s.m.push(gv(m))})})(this,i),da(this,n)}),this.g.attachEmptyPacketListener("timestamped_classifications",i=>{da(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function G4(e){return{embeddings:L2(e,_v).map(t=>{let r={headIndex:xs(_n(t,3))??0??-1,headName:Es(_n(t,4))??""??""};if(xf(t,h2,Qc(t,1))!==void 0){var i=void 0;t=ki(t,h2,Qc(t,1)).l;let m=lt(t),p=2&m?1:2;i=!!i;let T=Sf(t,m);var n=$t(T);if(!(4&n)){(4&n||Object.isFrozen(T))&&(T=qr(T),n=Rs(n,m,i),m=Ut(t,m,1,T));for(var s=0,a=0;s<T.length;s++){let Z=xo(T[s]);Z!=null&&(T[a++]=Z)}a<s&&(T.length=a),n=ar(n=wf(n,m,i),20,!0),n=ar(n,4096,!1),n=ar(n,8192,!1),Nt(T,n),2&n&&Object.freeze(T)}vo(n)||(s=n,(a=p===1)?n=ar(n,2,!0):i||(n=ar(n,32,!1)),n!==s&&Nt(T,n),a&&Object.freeze(T)),p===2&&vo(n)&&(T=qr(T),n=Rs(n,m,i),Nt(T,n),Ut(t,m,1,T)),r.floatEmbedding=T}else i=new Uint8Array(0),r.quantizedEmbedding=ki(t,pv,Qc(t,2))?.O()?.P()??i;return r}),timestampMs:kf(c2(e))}}ui.prototype.classify=ui.prototype.R,ui.prototype.setOptions=ui.prototype.s,ui.createFromModelPath=function(e,t){return dm(ui,e,{baseOptions:{modelAssetPath:t}})},ui.createFromModelBuffer=function(e,t){return yo(ui,e,{baseOptions:{modelAssetBuffer:t}})},ui.createFromOptions=function(e,t){return yo(ui,e,t)};var Yi=class extends E1{constructor(e,t){super(new hm(e,t)),this.m=[],Mi(e=this.i=new om,0,1,t=new A1)}get baseOptions(){return ki(this.i,A1,1)}set baseOptions(e){Mi(this.i,0,1,e)}s(e){var t=this.i,r=ki(this.i,D4,2);return r=r?bf(r):new D4,e.l2Normalize!==void 0?or(r,1,T4(e.l2Normalize)):"l2Normalize"in e&&or(r,1),e.quantize!==void 0?or(r,2,T4(e.quantize)):"quantize"in e&&or(r,2),Mi(t,0,2,r),fm(this,e)}S(e,t){return this.G(e,t??this.H,this.u+1)}G(e,t,r){return this.g.addDoubleToStream(t,"sample_rate",r),this.g.addAudioToStreamWithShape(e,1,e.length,"audio_in",r),this.m=[],this.finishProcessing(),this.m}I(){var e=new S1;Ir(e,10,"audio_in"),Ir(e,10,"sample_rate"),Ir(e,15,"embeddings_out"),Ir(e,15,"timestamped_embeddings_out");let t=new Jf;Mf(t,hv,this.i);let r=new D1;Af(r,_1("mediapipe.tasks.audio.audio_embedder.AudioEmbedderGraph")),Ir(r,3,"AUDIO:audio_in"),Ir(r,3,"SAMPLE_RATE:sample_rate"),Ir(r,4,"EMBEDDINGS:embeddings_out"),Ir(r,4,"TIMESTAMPED_EMBEDDINGS:timestamped_embeddings_out"),r.s(t),Tf(e,r),this.g.attachProtoListener("embeddings_out",(i,n)=>{i=N4(i),this.m.push(G4(i)),da(this,n)}),this.g.attachEmptyPacketListener("embeddings_out",i=>{da(this,i)}),this.g.attachProtoVectorListener("timestamped_embeddings_out",(i,n)=>{for(let s of i)i=N4(s),this.m.push(G4(i));da(this,n)}),this.g.attachEmptyPacketListener("timestamped_embeddings_out",i=>{da(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}},o1;Yi.prototype.embed=Yi.prototype.S,Yi.prototype.setOptions=Yi.prototype.s,Yi.createFromModelPath=function(e,t){return yo(Yi,e,{baseOptions:{modelAssetPath:t}})},Yi.createFromModelBuffer=function(e,t){return yo(Yi,e,{baseOptions:{modelAssetBuffer:t}})},Yi.createFromOptions=function(e,t){return yo(Yi,e,t)};var Sv=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function mm(){if(o1===void 0)try{await WebAssembly.instantiate(Sv),o1=!0}catch{o1=!1}return o1}async function t2(e,t=""){let r=await mm()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var fa=class{};fa.forVisionTasks=function(e){return t2("vision",e)},fa.forTextTasks=function(e){return t2("text",e)},fa.forAudioTasks=function(e){return t2("audio",e)},fa.isSimdSupported=function(){return mm()};var N1=class{constructor(t,r,i,n,s,a,m){this.recordingInProgress=!1;this.recordIndex=1;this.countLoopTimes=0;this.examStartTime=0;this.recordingStartTime=0;this.recordingEndTime=0;this.isSpeech=!1;this.optionsProctoring=t,this.proctoringSession=r,this.paramsConfig=i,this.cameraRecorder=n,this.onRealtimeAlertsCallback=s,this.backend=a,this.backendToken=m}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new cn(this.proctoringId,this.backend))}async startRecording(){this.examStartTime=Date.now(),await this.createAudioClassifier(),this.audioRecorder=new ua(this.paramsConfig.audioBehaviourParameters),this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetectedRecord(),500),this.streamingAudioClassification()}async stopRecording(){clearInterval(this.intervalNoiseDetection),await this.stopSoundRecord(),await this.volumeMeter.stop(),this.scriptProcessor&&this.scriptProcessor.disconnect()}async pauseRecording(){}async resumeRecording(){}async saveOnSession(t){}async onNoiseDetectedRecord(){!this.volumeMeter&&this.cameraRecorder.cameraStream&&(this.volumeMeter=new Un(this.cameraRecorder.cameraStream),this.volumeMeter.start().catch(i=>{console.log(i),this.volumeMeter=void 0}));let t=this.optionsProctoring.noiseLimit||40,r=this.volumeMeter?.getVolume()||0;this.isSpeech=this.isSpeech||this.hasDesiredResult(this.audioClassificationResult),!this.isSpeech&&!this.recordingInProgress&&(t=t+t*.25),r>=t&&!this.recordingInProgress?(this.recordingInProgress=!0,this.audioRecorder.startRecording(),this.recordingStartTime=Date.now()-this.examStartTime):r<t&&this.recordingInProgress&&(Date.now()-this.recordingStartTime>=3e3&&this.countLoopTimes>4&&!this.hasDesiredResult(this.audioClassificationResult)&&(await this.stopSoundRecord(),this.paramsConfig.videoBehaviourParameters?.detectSpeech&&this.isSpeech&&this.onRealtimeAlertsCallback({status:"ALERT",description:"speech",type:"audio_detection_on_stream"}),this.recordingInProgress=!1,this.recordIndex++,this.countLoopTimes=0,this.isSpeech=!1),this.countLoopTimes++)}async stopSoundRecord(){if(await this.audioRecorder.stopRecording(),this.recordingEndTime=Date.now()-this.examStartTime,!this.isSpeech)return;let t=new File(this.audioRecorder.blobs,`EP_${this.proctoringSession.id}_${this.recordingStartTime}_${this.recordingEndTime}_${this.isSpeech?"speech":"noise"}.mp3`,{type:"audio/mp3"});this.uploadRecord(t),this.audioRecorder.blobs=[]}download(t){let r=URL.createObjectURL(t),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=r,i.download=t.name,i.click(),window.URL.revokeObjectURL(r)}uploadRecord(t){t&&this.upload&&this.backendToken&&this.upload.upload({file:t},this.backendToken)}hasDesiredResult(t){if(t==null)return!1;for(let r of t)return r.name.toLowerCase().includes("speech");return!1}async createAudioClassifier(){let t=await fa.forAudioTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-audio@0.10.0/wasm");this.audioClassifier=await ui.createFromOptions(t,{scoreThreshold:.15,maxResults:1,baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/1/yamnet.tflite"}})}async streamingAudioClassification(){let t=new AudioContext({sampleRate:16e3}),r=t.createMediaStreamSource(this.cameraRecorder.cameraStream);this.scriptProcessor=t.createScriptProcessor(16384,1,1);let i=this;this.scriptProcessor.onaudioprocess=function(n){let a=n.inputBuffer.getChannelData(0),m=i.audioClassifier.classify(a),p=m[0].classifications[0].categories;m[0].classifications[0].categories.length>0&&(i.audioClassificationResult=[{name:p[0].categoryName,score:p[0].score.toFixed(3)}])},r.connect(this.scriptProcessor),this.scriptProcessor.connect(t.destination)}};var V1=class{constructor(t){this.blobs=[];this.blobsFinal=[];this.options=t}setProctoringId(t){this.proctoringId=t}async startRecording(){this.startTime=new Date(Date.now());let{allowOnlyFirstMonitor:t,allowMultipleMonitors:r,onStopSharingScreenCallback:i,onBufferSizeErrorCallback:n}=this.options,s={video:{cursor:"always",width:854,height:480,displaySurface:"monitor"},audio:!1};this.screenStream=await navigator.mediaDevices.getDisplayMedia(s);let a=this.screenStream.getVideoTracks();if(a[0].onended=i,navigator.userAgent.indexOf("Firefox")>-1){let Ae=a.find(ne=>ne.label=="");if(Ae&&t||Ae&&!r)throw c0}let p=a.find(Ae=>["screen:0:0","Primary Monitor"].includes(Ae.label))!=null,T=a.find(Ae=>["screen:0:0","Primary Monitor",""].includes(Ae.label)||["screen:"].some(ne=>Ae.label.includes(ne)))!=null,Z=a.find(Ae=>["web-contents-media-stream","window"].some(ne=>Ae.label.includes(ne)))!=null;if(!p&&t)throw a.forEach(Ae=>{Ae.stop()}),Hu;if(!T||Z)throw a.forEach(Ae=>{Ae.stop()}),ju;let{startRecording:G,stopRecording:fe}=Oa(this.screenStream,this.blobs,this.proctoringId,this.options.onBufferSizeError,n);this.recordingStart=G,this.recordingStop=fe,this.recordingStart()}async pauseRecording(){}async resumeRecording(){}async stopRecording(){this.recordingStop&&await this.recordingStop()}async saveOnSession(t){t.addRecording({device:"",file:new File(this.blobs,`EP_${t.id}_screen_0.webm`,{type:"video/webm"}),origin:"Screen"})}};var ko=class{constructor(t,r){this.dbName="EasyProctorDb";this.dbVersion=2;this.storeName="exams2";this.dbName=t,this.storeName=r}async save(t){let{transaction:r,store:i}=await this.connectToStore("readwrite");return this.processRequest(i.put(t),r).then(()=>{})}async delete(t){let{transaction:r,store:i}=await this.connectToStore("readwrite");return this.processRequest(i.delete(t),r)}async get(t){let{transaction:r,store:i}=await this.connectToStore("readwrite");return this.processRequest(i.get(t),r).catch(()=>{})}async getDevices(t){let{transaction:r,store:i}=await this.connectToStore("readwrite");return this.processRequest(i.get(t),r).catch(()=>{})}async list(){let{transaction:t,store:r}=await this.connectToStore("readonly");return this.processRequest(r.getAll(),t)}async clear(){let{transaction:t,store:r}=await this.connectToStore("readwrite");return this.processRequest(r.clear(),t)}async processRequest(t,r){return new Promise((i,n)=>{t.onerror=s=>{n(t.error?.message)},t.onsuccess=s=>{r.commit(),i(t.result)}})}async hasSessions(){return(await this.list()).length>0}async connectToStore(t){let n=(await this.connect()).result.transaction(this.storeName,t),s=n.objectStore(this.storeName);return{transaction:n,store:s}}async connect(){return this.connection?this.connection:new Promise((t,r)=>{let i=window.indexedDB.open(this.dbName,this.dbVersion);i.onerror=n=>{r("Can't connect to IndexedDB")},i.onupgradeneeded=n=>{let s=i.result;s.onerror=a=>{},s.createObjectStore(this.storeName,{keyPath:"id"})},i.onsuccess=n=>{this.connection=i,t(i)}})}};function pm(){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 _m(){return new Promise((e,t)=>{window.navigator.geolocation.getCurrentPosition(e,t)})}function Mo(){let e=window.navigator.userAgent.split("SEB/");return e.length>1?e[1]:"1.0.0.0"}var U1=class{constructor(t,r){this.cpf=t,this.backend=r,this.capturePhoto=new oa}async login(){let t=await this.capturePhoto.takePicture("Login com biometria facial","Encaixe seu rosto no formato e clique no bot\xE3o abaixo",{width:1080,height:720});return this.loading(),new Promise((r,i)=>{this.backend.loginAuth(this.cpf,t.base64.substr(22,t.base64.length)).then(n=>{this.token=n.token,document.querySelector("#authLoader")?.remove(),this.backend.token=this.token,r(this.token)}).catch(n=>{console.log(n),document.querySelector("#authLoader")?.remove(),i(n)})})}loading(){let t=document.createElement("div");t.setAttribute("id","authLoader"),t.style.backgroundColor="rgba(0,0,0,0.4)",t.style.zIndex="1000",t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.height="100vh",t.style.width="100%",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center";let r=document.createElement("div");r.setAttribute("class","loader"),t.appendChild(r),document.body.appendChild(t);let i=`
234
+ Size: ${t.file.size}`,a),s}}throw new Error("Could not upload")}};var n1=class{constructor(t,r,i){this.alerts=[];this.onLostFocusCallback=t.onLostFocusCallback,this.onFocusCallback=t.onFocusCallback,this.optionsProctoring=r,this.cameraRecorder=i}async startRecording(){this.startTime=new Date(Date.now()),this.optionsProctoring.captureScreen&&(window.addEventListener("blur",()=>this.onLostFocus()),window.addEventListener("focus",()=>this.onReturnFocus()))}async pauseRecording(){window.removeEventListener("blur",()=>this.onLostFocus()),window.removeEventListener("focus",()=>this.onReturnFocus())}async resumeRecording(){this.optionsProctoring.captureScreen&&(window.addEventListener("blur",()=>this.onLostFocus()),window.addEventListener("focus",()=>this.onReturnFocus()))}async stopRecording(){window.removeEventListener("blur",()=>this.onLostFocus()),window.removeEventListener("focus",()=>this.onReturnFocus())}async saveOnSession(t){this.alerts.forEach(r=>{t.addAlert(r)})}onLostFocus(){Date.now()-this.startTime?.getTime()>1e4&&(this.onLostFocusCallback(),this.alerts.push({begin:Date.now()-this.startTime.getTime(),end:0,alert:25}))}onReturnFocus(){let t=this.alerts[this.alerts.length-1];t&&(this.onFocusCallback(),t.end=Date.now()-this.startTime.getTime())}};var y6=l4();function c4(e){return new y6(e)}var ua=class{constructor(t){this.blobs=[];this.audioParams={recordingBitrate:128};t&&(this.audioParams=t)}async startRecording(){this.recorder=c4({bitRate:this.audioParams.recordingBitrate}),this.recorder.start().catch(t=>{throw new Error("Error on Audio to Start Recording")})}async pauseRecording(){}async resumeRecording(){}async stopRecording(){if(!this.recorder)return;let t=await this.recorder.stop().getMp3().then(async([r,i])=>({buffer:r,blob:i})).catch(r=>{alert("We could not retrieve your message")});t&&this.blobs.push(t.blob)}async saveOnSession(t,r,i){t.addRecording({device:"",file:new File(this.blobs,`EP_${t.id}_audio_${r&&i&&`${r}_${i}`||"0"}.mp3`,{type:"audio/mp3"}),origin:"Mic"})}};var f2=typeof self<"u"?self:{};function X4(e,t){e:{for(var r=["CLOSURE_FLAGS"],i=f2,n=0;n<r.length;n++)if((i=i[r[n]])==null){r=null;break e}r=i}return(e=r&&r[e])!=null?e:t}function gs(){throw Error("Invalid UTF8")}function u4(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var s1,Wc,g6=typeof TextDecoder<"u",S6,w6=typeof TextEncoder<"u";function z4(e){if(w6)e=(S6||=new TextEncoder).encode(e);else{let r=0,i=new Uint8Array(3*e.length);for(let n=0;n<e.length;n++){var t=e.charCodeAt(n);if(128>t)i[r++]=t;else{if(2048>t)i[r++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&n<e.length){let s=e.charCodeAt(++n);if(56320<=s&&57343>=s){t=1024*(t-55296)+s-56320+65536,i[r++]=t>>18|240,i[r++]=t>>12&63|128,i[r++]=t>>6&63|128,i[r++]=63&t|128;continue}n--}t=65533}i[r++]=t>>12|224,i[r++]=t>>6&63|128}i[r++]=63&t|128}}e=r===i.length?i:i.subarray(0,r)}return e}var go,q4=X4(610401301,!1),m2=X4(572417392,!0),h4=f2.navigator;function r2(e){return!!q4&&!!go&&go.brands.some(({brand:t})=>t&&t.indexOf(e)!=-1)}function hi(e){var t;return(t=f2.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function jn(){return!!q4&&!!go&&0<go.brands.length}function Kc(){return jn()?r2("Chromium"):(hi("Chrome")||hi("CriOS"))&&!(!jn()&&hi("Edge"))||hi("Silk")}go=h4&&h4.userAgentData||null;var A6=!jn()&&(hi("Trident")||hi("MSIE"));!hi("Android")||Kc(),Kc(),hi("Safari")&&(Kc()||!jn()&&hi("Coast")||!jn()&&hi("Opera")||!jn()&&hi("Edge")||(jn()?r2("Microsoft Edge"):hi("Edg/"))||jn()&&r2("Opera"));var $4={},po=null;function E6(e){var t=e.length,r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);var i=new Uint8Array(r),n=0;return function(s,a){function m(Ae){for(;p<s.length;){var ne=s.charAt(p++),pe=po[ne];if(pe!=null)return pe;if(!/^[\s\xa0]*$/.test(ne))throw Error("Unknown base64 encoding at char: "+ne)}return Ae}Y4();for(var p=0;;){var T=m(-1),Z=m(0),G=m(64),fe=m(64);if(fe===64&&T===-1)break;a(T<<2|Z>>4),G!=64&&(a(Z<<4&240|G>>2),fe!=64&&a(G<<6&192|fe))}}(e,function(s){i[n++]=s}),n!==r?i.subarray(0,n):i}function Y4(){if(!po){po={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var i=e.concat(t[r].split(""));$4[r]=i;for(var n=0;n<i.length;n++){var s=i[n];po[s]===void 0&&(po[s]=n)}}}}var W4=typeof Uint8Array<"u",K4=!A6&&typeof btoa=="function";function d4(e){if(!K4){var t;t===void 0&&(t=0),Y4(),t=$4[t];var r=Array(Math.floor(e.length/3)),i=t[64]||"";let p=0,T=0;for(;p<e.length-2;p+=3){var n=e[p],s=e[p+1],a=e[p+2],m=t[n>>2];n=t[(3&n)<<4|s>>4],s=t[(15&s)<<2|a>>6],a=t[63&a],r[T++]=m+n+s+a}switch(m=0,a=i,e.length-p){case 2:a=t[(15&(m=e[p+1]))<<2]||i;case 1:e=e[p],r[T]=t[e>>2]+t[(3&e)<<4|m>>4]+a+i}return r.join("")}for(t="",r=0,i=e.length-10240;r<i;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}var f4=/[-_.]/g,x6={"-":"+",_:"/",".":"="};function R6(e){return x6[e]||""}function Z4(e){if(!K4)return E6(e);f4.test(e)&&(e=e.replace(f4,R6)),e=atob(e);let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function x1(e){return W4&&e!=null&&e instanceof Uint8Array}var T6;function R1(){return T6||=new Uint8Array(0)}var pa={},k6;function Q4(e){if(e!==pa)throw Error("illegal external caller")}function _a(){return k6||=new Gn(null,pa)}function p2(e){Q4(pa);var t=e.D;return(t=t==null||x1(t)?t:typeof t=="string"?Z4(t):null)==null?t:e.D=t}var Gn=class{constructor(e,t){if(Q4(t),this.D=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}P(){let e=p2(this);return e?new Uint8Array(e):R1()}};function J4(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function _2(){return Error("Failed to read varint, encoding is invalid.")}function ef(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function tf(e){return e.length==0?_a():new Gn(e,pa)}function v2(e){if(typeof e=="string")return{buffer:Z4(e),A:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),A:!1};if(e.constructor===Uint8Array)return{buffer:e,A:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),A:!1};if(e.constructor===Gn)return{buffer:p2(e)||R1(),A:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),A:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function b2(){return typeof BigInt=="function"}var m4=!m2,p4=!m2,M6=typeof Uint8Array.prototype.slice=="function",rf,Bt=0,qt=0;function ma(e){let t=0>e,r=(e=Math.abs(e))>>>0;if(e=Math.floor((e-r)/4294967296),t){let[i,n]=g2(r,e);e=n,r=i}Bt=r>>>0,qt=e>>>0}function nf(e){let t=rf||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),qt=0,Bt=t.getUint32(0,!0)}function i2(e,t){return 4294967296*t+(e>>>0)}function y2(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),e=i2(e,t),r?-e:e}function d1(e,t){if(e>>>=0,2097151>=(t>>>=0))var r=""+(4294967296*t+e);else b2()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,1e7<=e&&(r+=Math.floor(e/1e7),e%=1e7),1e7<=r&&(t+=Math.floor(r/1e7),r%=1e7),r=t+_4(r)+_4(e));return r}function _4(e){return e=String(e),"0000000".slice(e.length)+e}function T1(e){if(16>e.length)ma(Number(e));else if(b2())e=BigInt(e),Bt=Number(e&BigInt(4294967295))>>>0,qt=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");qt=Bt=0;let r=e.length;for(let i=t,n=(r-t)%6+t;n<=r;i=n,n+=6){let s=Number(e.slice(i,n));qt*=1e6,Bt=1e6*Bt+s,4294967296<=Bt&&(qt+=Math.trunc(Bt/4294967296),qt>>>=0,Bt>>>=0)}if(t){let[i,n]=g2(Bt,qt);Bt=i,qt=n}}}function g2(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function S2(e,t){let r,i=0,n=0,s=0,a=e.i,m=e.g;do r=a[m++],i|=(127&r)<<s,s+=7;while(32>s&&128&r);for(32<s&&(n|=(127&r)>>4),s=3;32>s&&128&r;s+=7)r=a[m++],n|=(127&r)<<s;if(As(e,m),128>r)return t(i>>>0,n>>>0);throw _2()}function w2(e){let t=0,r=e.g,i=r+10,n=e.i;for(;r<i;){let s=n[r++];if(t|=s,(128&s)==0)return As(e,r),!!(127&t)}throw _2()}function zr(e){let t=e.i,r=e.g,i=t[r++],n=127&i;if(128&i&&(i=t[r++],n|=(127&i)<<7,128&i&&(i=t[r++],n|=(127&i)<<14,128&i&&(i=t[r++],n|=(127&i)<<21,128&i&&(i=t[r++],n|=i<<28,128&i&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw _2();return As(e,r),n}function n2(e){var t=e.i;let r=e.g,i=t[r],n=t[r+1],s=t[r+2];return t=t[r+3],As(e,e.g+4),(i<<0|n<<8|s<<16|t<<24)>>>0}function s2(e){var t=n2(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:1/0*e:r==0?e*Math.pow(2,-149)*t:e*Math.pow(2,r-150)*(t+Math.pow(2,23))}function B6(e){return zr(e)}function Zc(e,t,{F:r=!1}={}){e.F=r,t&&(t=v2(t),e.i=t.buffer,e.m=t.A,e.u=0,e.j=e.i.length,e.g=e.u)}function As(e,t){if(e.g=t,t>e.j)throw ef(e.j,t)}function sf(e,t){if(0>t)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,i=r+t;if(i>e.j)throw ef(t,e.j-r);return e.g=i,r}function af(e,t){if(t==0)return _a();var r=sf(e,t);return e.F&&e.m?r=e.i.subarray(r,r+t):(e=e.i,r=r===(t=r+t)?R1():M6?e.slice(r,t):new Uint8Array(e.subarray(r,t))),tf(r)}var v4=[];function of(e){var t=e.g;if(t.g==t.j)return!1;e.j=e.g.g;var r=zr(e.g)>>>0;if(t=r>>>3,!(0<=(r&=7)&&5>=r))throw J4(r,e.j);if(1>t)throw Error(`Invalid field number: ${t} (at position ${e.j})`);return e.m=t,e.i=r,!0}function l1(e){switch(e.i){case 0:e.i!=0?l1(e):w2(e.g);break;case 1:As(e=e.g,e.g+8);break;case 2:if(e.i!=2)l1(e);else{var t=zr(e.g)>>>0;As(e=e.g,e.g+t)}break;case 5:As(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!of(e))throw Error("Unmatched start-group tag: stream EOF");if(e.i==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}l1(e)}break;default:throw J4(e.i,e.j)}}function k1(e,t,r){let i=e.g.j,n=zr(e.g)>>>0,s=e.g.g+n,a=s-i;if(0>=a&&(e.g.j=s,r(t,e,void 0,void 0,void 0),a=s-e.g.g),a)throw Error(`Message parsing ended unexpectedly. Expected to read ${n} bytes, instead read ${n-a} bytes, either the data ended unexpectedly or the message misreported its own length`);e.g.g=s,e.g.j=i}function A2(e){var t=zr(e.g)>>>0,r=sf(e=e.g,t);if(e=e.i,g6){var i,n=e;(i=Wc)||(i=Wc=new TextDecoder("utf-8",{fatal:!0})),t=r+t,n=r===0&&t===n.length?n:n.subarray(r,t);try{var s=i.decode(n)}catch(m){if(s1===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),s1=!0}catch{s1=!1}}throw!s1&&(Wc=void 0),m}}else{t=(s=r)+t,r=[];let m,p=null;for(;s<t;){var a=e[s++];128>a?r.push(a):224>a?s>=t?gs():(m=e[s++],194>a||(192&m)!=128?(s--,gs()):r.push((31&a)<<6|63&m)):240>a?s>=t-1?gs():(m=e[s++],(192&m)!=128||a===224&&160>m||a===237&&160<=m||(192&(i=e[s++]))!=128?(s--,gs()):r.push((15&a)<<12|(63&m)<<6|63&i)):244>=a?s>=t-2?gs():(m=e[s++],(192&m)!=128||m-144+(a<<28)>>30!=0||(192&(i=e[s++]))!=128||(192&(n=e[s++]))!=128?(s--,gs()):(a=(7&a)<<18|(63&m)<<12|(63&i)<<6|63&n,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):gs(),8192<=r.length&&(p=u4(p,r),r.length=0)}s=u4(p,r)}return s}function lf(e){let t=zr(e.g)>>>0;return af(e.g,t)}function E2(e,t,r){var i=zr(e.g)>>>0;for(i=e.g.g+i;e.g.g<i;)r.push(t(e.g))}var a1=[];function b4(e){return e?/^\d+$/.test(e)?(T1(e),new y4(Bt,qt)):null:I6||=new y4(0,0)}var y4=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},I6;function g4(e){return e?/^-?\d+$/.test(e)?(T1(e),new S4(Bt,qt)):null:C6||=new S4(0,0)}var S4=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},C6;function f1(e,t,r){for(;0<r||127<t;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function M1(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function B1(e,t){if(0<=t)M1(e,t);else{for(let r=0;9>r;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function m1(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function va(e,t){t.length!==0&&(e.j.push(t),e.i+=t.length)}function Qi(e,t,r){M1(e.g,8*t+r)}function x2(e,t){return Qi(e,t,2),t=e.g.end(),va(e,t),t.push(e.i),t}function R2(e,t){var r=t.pop();for(r=e.i+e.g.length()-r;127<r;)t.push(127&r|128),r>>>=7,e.i++;t.push(r),e.i++}function I1(e,t,r){Qi(e,t,2),M1(e.g,r.length),va(e,e.g.end()),va(e,r)}var Wi,Ki=class{constructor(t,r,i,n){this.g=t,this.i=r,this.j=i,this.N=n}};function qr(e){return Array.prototype.slice.call(e)}var T2=(Wi=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol():void 0)?(e,t)=>{e[Wi]|=t}:(e,t)=>{e.o!==void 0?e.o|=t:Object.defineProperties(e,{o:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function w4(e){let t=$t(e);(1&t)!=1&&(Object.isFrozen(e)&&(e=qr(e)),Nt(e,1|t))}var a2=Wi?(e,t)=>{e[Wi]&=~t}:(e,t)=>{e.o!==void 0&&(e.o&=~t)};function ar(e,t,r){return r?e|t:e&~t}var $t=Wi?e=>0|e[Wi]:e=>0|e.o,lt=Wi?e=>e[Wi]:e=>e.o,Nt=Wi?(e,t)=>{e[Wi]=t}:(e,t)=>{e.o!==void 0?e.o=t:Object.defineProperties(e,{o:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function A4(){var e=[];return T2(e,1),e}function O6(e,t){Nt(t,-14591&(0|e))}function o2(e,t){Nt(t,-14557&(34|e))}function p1(e){return(e=e>>14&1023)===0?536870912:e}var Eo={},P6={};function E4(e){return!(!e||typeof e!="object"||e.W!==P6)}function _o(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}var cf=!m2;function uf(e,t,r){if(e!=null){if(typeof e=="string")e=e?new Gn(e,pa):_a();else if(e.constructor!==Gn)if(x1(e))e=r?tf(e):e.length?new Gn(new Uint8Array(e),pa):_a();else{if(!t)throw Error();e=void 0}}return e}function l2(e,t,r){if(!Array.isArray(e)||e.length)return!1;let i=$t(e);return!!(1&i)||!(!t||!(Array.isArray(t)?t.includes(r):t.has(r)))&&(Nt(e,1|i),!0)}var ws,x4=[];function vn(e){if(2&e)throw Error()}var Xn,So;function hf(e,t){(t=Xn?t[Xn]:void 0)&&(e[Xn]=qr(t))}Nt(x4,55),ws=Object.freeze(x4);function R4(){let e=Error("int32");return e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity="warning",e}function xo(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function T4(e){if(e!=null&&typeof e!="boolean"){var t=typeof e;throw Error(`Expected boolean but got ${t!="object"?t:e?Array.isArray(e)?"array":t:"null"}: ${e}`)}return e}Object.freeze(new class{}),Object.freeze(new class{});var L6=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function k2(e){let t=typeof e;return t==="number"?Number.isFinite(e):t==="string"&&L6.test(e)}function xs(e){if(e==null)return e;if(typeof e=="string"){if(!e)return;e=+e}return typeof e=="number"&&Number.isFinite(e)?0|e:void 0}function k4(e){return e[0]!=="-"&&(20>e.length||e.length===20&&184467>Number(e.substring(0,6)))}function df(e){return e=Math.trunc(e),Number.isSafeInteger(e)||(ma(e),e=y2(Bt,qt)),e}function ff(e){var t=Math.trunc(Number(e));if(Number.isSafeInteger(t))return String(t);if((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),!(e[0]==="-"?20>e.length||e.length===20&&-922337<Number(e.substring(0,7)):19>e.length||e.length===19&&922337>Number(e.substring(0,6))))if(T1(e),e=Bt,2147483648&(t=qt))if(b2())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,i]=g2(e,t);e="-"+d1(r,i)}else e=d1(e,t);return e}function mf(e){if(typeof e!="string")throw Error();return e}function _1(e){if(e!=null&&typeof e!="string")throw Error();return e}function Es(e){return e==null||typeof e=="string"?e:void 0}function pf(e,t,r){if(e!=null&&typeof e=="object"&&e.C===Eo)return e;if(Array.isArray(e)){var i=$t(e),n=i;return n===0&&(n|=32&r),(n|=2&r)!==i&&Nt(e,n),new t(e)}}var v1,M2,F6;function b1(e){switch(typeof e){case"boolean":return M2||=[0,void 0,!0];case"number":return 0<e?void 0:e===0?F6||=[0,void 0]:[-e,void 0];case"string":return[0,e];case"object":return e}}function wo(e,t,r){if(e==null&&(e=v1),v1=void 0,e==null){var i=96;r?(e=[r],i|=512):e=[],t&&(i=-16760833&i|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error();if(64&(i=$t(e)))return So&&delete e[So],e;if(i|=64,r&&(i|=512,r!==e[0]))throw Error();e:{let n=(r=e).length;if(n){let s=n-1;if(_o(r[s])){if(1024<=(t=s-(+!!(512&(i|=256))-1)))throw Error();i=-16760833&i|(1023&t)<<14;break e}}if(t){if(1024<(t=Math.max(t,n-(+!!(512&i)-1))))throw Error();i=-16760833&i|(1023&t)<<14}}}return Nt(e,i),e}function _f(e,t,r,i,n,s){if(e!=null){if(Array.isArray(e))e=n&&e.length==0&&1&$t(e)?void 0:s&&2&$t(e)?e:B2(e,t,r,i!==void 0,n,s);else if(_o(e)){let a={};for(let m in e)a[m]=_f(e[m],t,r,i,n,s);e=a}else e=t(e,i);return e}}function B2(e,t,r,i,n,s){let a=i||r?$t(e):0;i=i?!!(32&a):void 0;let m=qr(e);for(let p=0;p<m.length;p++)m[p]=_f(m[p],t,r,i,n,s);return r&&(hf(m,e),r(a,m)),m}function D6(e){return e.C===Eo?e.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"boolean":return t?1:0;case"object":if(t){if(Array.isArray(t))return cf||!l2(t,void 0,9999)?t:void 0;if(x1(t))return d4(t);if(t instanceof Gn){let r=t.D;return r==null?"":typeof r=="string"?r:t.D=d4(r)}}}return t}(e)}function vf(e,t,r=o2){if(e!=null){if(W4&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var i=$t(e);return 2&i?e:(t&&=i===0||!!(32&i)&&!(64&i||!(16&i)),t?(Nt(e,-12293&(34|i)),e):B2(e,vf,4&i?o2:r,!0,!1,!0))}return e.C===Eo&&(r=e.l,e=2&(i=lt(r))?e:I2(e,r,i,!0)),e}}function bf(e){let t=e.l;return I2(e,t,lt(t),!1)}function I2(e,t,r,i){return e=e.constructor,v1=t=yf(t,r,i),t=new e(t),v1=void 0,t}function yf(e,t,r){let i=r||2&t?o2:O6,n=!!(32&t);return e=function(s,a,m){let p=qr(s);var T=p.length;let Z=256&a?p[T-1]:void 0;for(T+=Z?-1:0,a=512&a?1:0;a<T;a++)p[a]=m(p[a]);if(Z){a=p[a]={};for(let G in Z)a[G]=m(Z[G])}return hf(p,s),p}(e,t,s=>vf(s,n,i)),T2(e,32|(r?2:0)),e}function C2(e){let t=e.l,r=lt(t);return 2&r?I2(e,t,r,!1):e}function _n(e,t){return qn(e=e.l,lt(e),t)}function qn(e,t,r,i){if(r===-1)return null;if(r>=p1(t)){if(256&t)return e[e.length-1][r]}else{var n=e.length;if(i&&256&t&&(i=e[n-1][r])!=null)return i;if((t=r+(+!!(512&t)-1))<n)return e[t]}}function or(e,t,r,i){let n=e.l,s=lt(n);return vn(s),Ut(n,s,t,r,i),e}function Ut(e,t,r,i,n){var s=p1(t);if(r>=s||n){if(n=t,256&t)s=e[e.length-1];else{if(i==null)return n;s=e[s+(+!!(512&t)-1)]={},n|=256}return s[r]=i,n!==t&&Nt(e,n),n}return e[r+(+!!(512&t)-1)]=i,256&t&&r in(e=e[e.length-1])&&delete e[r],t}function Ro(e,t,r,i,n){var s=2&t;let a=qn(e,t,r,n);Array.isArray(a)||(a=ws);let m=!(2&i);i=!(1&i);let p=!!(32&t),T=$t(a);return T!==0||!p||s||m?1&T||(T|=1,Nt(a,T)):(T|=33,Nt(a,T)),s?(e=!1,2&T||(T2(a,34),e=!!(4&T)),(i||e)&&Object.freeze(a)):(s=!!(2&T)||!!(2048&T),i&&s?(a=qr(a),i=1,p&&!m&&(i|=32),Nt(a,i),Ut(e,t,r,a,n)):m&&32&T&&!s&&a2(a,32)),a}function gf(e){e=e.l;let t=lt(e),r=qn(e,t,1),i=uf(r,!0,!!(34&t));return i!=null&&i!==r&&Ut(e,t,1,i),i}function Sf(e,t){return e=qn(e,t,1),Array.isArray(e)?e:ws}function wf(e,t,r){return e===0&&(e=Rs(e,t,r)),ar(e,1,!0)}function vo(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function M4(e,t,r){{let a=e.l,m=lt(a);if(vn(m),r==null)Ut(a,m,t);else{var i,n=e=$t(r),s=!!(2&e)||Object.isFrozen(r);if((i=!s)&&(i=!1),!(4&e))for(e=21,s&&(r=qr(r),n=0,e=Rs(e,m,!0)),s=0;s<r.length;s++)r[s]=mf(r[s]);i&&(r=qr(r),n=0,e=Rs(e,m,!0)),e!==n&&Nt(r,e),Ut(a,m,t,r)}}}function Af(e,t){e=e.l;let r=lt(e);vn(r),Ut(e,r,2,t===""?void 0:t)}function Ef(e,t,r,i){let n=lt(e);vn(n),e=Ro(e,n,t,2),i=r(i,!!(4&(t=$t(e)))&&!!(4096&t)),e.push(i)}function N6(e){return e}function Qc(e,t){return O2(e=e.l,lt(e),cm)===t?t:-1}function O2(e,t,r){let i=0;for(let n=0;n<r.length;n++){let s=r[n];qn(e,t,s)!=null&&(i!==0&&(t=Ut(e,t,i)),i=s)}return i}function P2(e,t,r,i){let n=lt(e);vn(n);let s=qn(e,n,r,i),a;if(s!=null&&s.C===Eo)return(t=C2(s))!==s&&Ut(e,n,r,t,i),t.l;if(Array.isArray(s)){let m=$t(s);a=2&m?yf(s,m,!1):s,a=wo(a,t[0],t[1])}else a=wo(void 0,t[0],t[1]);return a!==s&&Ut(e,n,r,a,i),a}function xf(e,t,r,i){e=e.l;let n=lt(e),s=qn(e,n,r,i);return(t=pf(s,t,n))!==s&&t!=null&&Ut(e,n,r,t,i),t}function ki(e,t,r){if((t=xf(e,t,r,!1))==null)return t;e=e.l;let i=lt(e);if(!(2&i)){let n=C2(t);n!==t&&Ut(e,i,r,t=n,!1)}return t}function Rf(e,t,r,i,n){var s=!!(2&t),a=s?1:2;let m=a===1;a=a===2,i=!!i,n&&=!s,s=Sf(e,t);var p=$t(s);let T=!!(4&p);if(!T){var Z,G=s,fe=t;(Z=!!(2&(p=wf(p,t,i))))&&(fe=ar(fe,2,!0));let Ae=!Z,ne=!0,pe=0,J=0;for(;pe<G.length;pe++){let Ue=pf(G[pe],r,fe);if(Ue instanceof r){if(!Z){let Pe=!!(2&$t(Ue.l));Ae&&=!Pe,ne&&=Pe}G[J++]=Ue}}J<pe&&(G.length=J),p=ar(p,4,!0),p=ar(p,16,ne),p=ar(p,8,Ae),Nt(G,p),Z&&Object.freeze(G)}if(r=!!(8&p)||m&&!s.length,n&&!r){for(vo(p)&&(s=qr(s),p=Rs(p,t,i),t=Ut(e,t,1,s)),n=s,r=p,G=0;G<n.length;G++)(p=n[G])!==(fe=C2(p))&&(n[G]=fe);r=ar(r,8,!0),r=ar(r,16,!n.length),Nt(n,r),p=r}return vo(p)||(n=p,m?p=ar(p,!s.length||16&p&&(!T||32&p)?2:2048,!0):i||(p=ar(p,32,!1)),p!==n&&Nt(s,p),m&&Object.freeze(s)),a&&vo(p)&&(s=qr(s),p=Rs(p,t,i),Nt(s,p),Ut(e,t,1,s)),s}function L2(e,t){e=e.l;let r=lt(e);return Rf(e,r,t,!1,!(2&r))}function Mi(e,t,r,i,n){return i==null&&(i=void 0),or(e,r,i,n)}function Jc(e,t,r){var i=nm;r==null&&(r=void 0),e=e.l;let n=lt(e);vn(n),(i=O2(e,n,i))&&i!==t&&r!=null&&(n=Ut(e,n,i)),Ut(e,n,t,r)}function Rs(e,t,r){return e=ar(e,2,!!(2&t)),e=ar(e,32,!!(32&t)&&r),ar(e,2048,!1)}function Tf(e,t){var r=D1;e=e.l;let i=lt(e);vn(i),e=Rf(e,i,r,!0),t=t??new r,e.push(t),2&$t(t.l)?a2(e,8):a2(e,16)}function c2(e){return(e=_n(e,2))==null?e:k2(e)?typeof e=="number"?df(e):ff(e):void 0}function kf(e){return e??0}function Ir(e,t,r){Ef(e.l,t,mf,r)}function Mf(e,t,r){t.g?t.j(e,t.g,t.i,r,!0):t.j(e,t.i,r,!0)}var It=class{constructor(e,t){this.l=wo(e,t)}toJSON(){return Bf(this,B2(this.l,D6,void 0,void 0,!1,!1),!0)}A(){return!!(2&$t(this.l))}};function Bf(e,t,r){let i=e.constructor.v;var n=lt(r?e.l:t),s=p1(n),a=!1;if(i&&cf){if(!r){var m;if((t=qr(t)).length&&_o(m=t[t.length-1])){for(a=0;a<i.length;a++)if(i[a]>=s){Object.assign(t[t.length-1]={},m);break}}a=!0}var p;s=t,r=!r,e=p1(m=lt(e.l)),m=+!!(512&m)-1;for(let J=0;J<i.length;J++){var T=i[J];if(T<e){var Z=s[T+=m];Z==null?s[T]=r?ws:A4():r&&Z!==ws&&w4(Z)}else{if(!p){var G=void 0;s.length&&_o(G=s[s.length-1])?p=G:s.push(p={})}Z=p[T],p[T]==null?p[T]=r?ws:A4():r&&Z!==ws&&w4(Z)}}}if(!(p=t.length))return t;let fe,Ae;if(_o(G=t[p-1])){e:{var ne=G;for(var pe in s={},r=!1,ne)e=ne[pe],Array.isArray(e)&&(m=e,(!p4&&l2(e,i,+pe)||!m4&&E4(e)&&e.size===0)&&(e=null),e!=m&&(r=!0)),e!=null?s[pe]=e:r=!0;if(r){for(let J in s){ne=s;break e}ne=null}}ne!=G&&(fe=!0),p--}for(n=+!!(512&n)-1;0<p&&((G=t[pe=p-1])==null||!p4&&l2(G,i,pe-n)||!m4&&E4(G)&&G.size===0);p--)Ae=!0;return(fe||Ae)&&(t=a?t:Array.prototype.slice.call(t,0,p),a&&(t.length=p),ne&&t.push(ne)),t}function If(e){return Array.isArray(e)?e[0]instanceof Ki?e:[W6,e]:[e,void 0]}function C1(e,t){if(Array.isArray(t)){var r=$t(t);if(4&r)return t;for(var i=0,n=0;i<t.length;i++){let s=e(t[i]);s!=null&&(t[n++]=s)}return n<i&&(t.length=n),Nt(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}It.prototype.C=Eo,It.prototype.toString=function(){return Bf(this,this.l,!1).toString()};var B4=Symbol();function F2(e){let t=e[B4];if(!t){let r=Pf(e),i=N2(e),n=i.g;t=n?(s,a)=>n(s,a,i):(s,a)=>{for(;of(a)&&a.i!=4;){var m=a.m,p=i[m];if(!p){var T=i.K;T&&(T=T[m])&&(p=i[m]=V6(T))}p&&p(a,s,m)||(m=(p=a).j,l1(p),p.J?p=void 0:(T=p.g.g-m,p.g.g=m,p=af(p.g,T)),m=s,p&&(Xn||=Symbol(),(T=m[Xn])?T.push(p):m[Xn]=[p]))}r===Cf||r===Of||r.T||(s[So||=Symbol()]=r)},e[B4]=t}return t}function V6(e){let t=(e=If(e))[0].g;if(e=e[1]){let r=F2(e),i=N2(e).B;return(n,s,a)=>t(n,s,a,i,r)}return t}var Cf,Of,c1=Symbol();function U6(e,t,r){let i=r[1],n;if(i){let s=i[c1];n=s?s.B:b1(i[0]),e[t]=s??i}n&&n===M2?(e.L||(e.L=[])).push(t):r[0]&&(e.M||(e.M=[])).push(t)}function I4(e,t){return[e.j,!t||0<t[0]?void 0:t]}function Pf(e){var t=e[c1];if(t)return t;if(!(t=D2(e,e[c1]={},I4,I4,U6)).M&&!t.L){let r=!0;for(let i in t){isNaN(i)||(r=!1);break}r?(t=b1(e[0])===M2,t=e[c1]=t?Of||={B:b1(!0)}:Cf||={}):t.T=!0}return t}function H6(e,t,r){e[t]=r}function D2(e,t,r,i,n=H6){t.B=b1(e[0]);let s=0;var a=e[++s];a&&a.constructor===Object&&(t.K=a,typeof(a=e[++s])=="function"&&(t.g=a,t.i=e[++s],a=e[++s]));let m={};for(;Array.isArray(a)&&typeof a[0]=="number"&&0<a[0];){for(var p=0;p<a.length;p++)m[a[p]]=a;a=e[++s]}for(p=1;a!==void 0;){let G;typeof a=="number"&&(p+=a,a=e[++s]);var T=void 0;if(a instanceof Ki?G=a:(G=K6,s--),G.N){a=e[++s],T=e;var Z=s;typeof a=="function"&&(a=a(),T[Z]=a),T=a}for(Z=p+1,typeof(a=e[++s])=="number"&&0>a&&(Z-=a,a=e[++s]);p<Z;p++){let fe=m[p];n(t,p,T?i(G,T,fe):r(G,fe))}}return t}var C4=Symbol();function Lf(e){let t=e[C4];if(!t){let r=O1(e);t=(i,n)=>Ff(i,n,r),e[C4]=t}return t}var u1=Symbol();function j6(e){return e.i}function G6(e,t){let r,i,n=e.i;return(s,a,m)=>n(s,a,m,i||=O1(t).B,r||=Lf(t))}function O1(e){let t=e[u1];return t||(t=D2(e,e[u1]={},j6,G6),h1 in e&&u1 in e&&(e.length=0),t)}var h1=Symbol();function X6(e,t){let r=e.g;return t?(i,n,s)=>r(i,n,s,t):r}function z6(e,t,r){let i=e.g,n,s;return(a,m,p)=>i(a,m,p,s||=N2(t).B,n||=F2(t),r)}function N2(e){let t=e[h1];return t||(Pf(e),t=D2(e,e[h1]={},X6,z6),h1 in e&&u1 in e&&(e.length=0),t)}function O4(e,t){var r=e[t];if(r)return r;if((r=e.K)&&(r=r[t])){var i=(r=If(r))[0].i;if(r=r[1]){let n=Lf(r),s=O1(r).B;r=(r=e.i)?r(s,n):(a,m,p)=>i(a,m,p,s,n)}else r=i;return e[t]=r}}function Ff(e,t,r){for(var i=lt(e),n=+!!(512&i)-1,s=e.length,a=512&i?1:0,m=s+(256&i?-1:0);a<m;a++){let p=e[a];if(p==null)continue;let T=a-n,Z=O4(r,T);Z&&Z(t,p,T)}if(256&i){i=e[s-1];for(let p in i)n=+p,Number.isNaN(n)||(s=i[p])!=null&&(m=O4(r,n))&&m(t,s,n)}if(e=Xn?e[Xn]:void 0)for(va(t,t.g.end()),r=0;r<e.length;r++)va(t,p2(e[r])||R1())}function Cr(e,t){return new Ki(e,t,!1,!1)}function P1(e,t){return new Ki(e,t,!0,!1)}function Or(e,t,r){Ut(e,lt(e),t,r)}function Df(e,t,r){e:if(t!=null){if(k2(t)){if(typeof t=="string"){t=ff(t);break e}if(typeof t=="number"){t=df(t);break e}}t=void 0}t!=null&&(typeof t=="string"&&g4(t),t!=null&&(Qi(e,r,0),typeof t=="number"?(e=e.g,ma(t),f1(e,Bt,qt)):(r=g4(t),f1(e.g,r.i,r.g))))}function Nf(e,t,r){(t=xs(t))!=null&&t!=null&&(Qi(e,r,0),B1(e.g,t))}function Vf(e,t,r){(t=t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0)!=null&&(Qi(e,r,0),e.g.g.push(t?1:0))}function Uf(e,t,r){(t=Es(t))!=null&&I1(e,r,z4(t))}function L1(e,t,r,i,n){(t=t instanceof It?t.l:Array.isArray(t)?wo(t,i[0],i[1]):void 0)!=null&&(r=x2(e,r),n(t,e),R2(e,r))}function Hf(e,t,r){(t=t==null||typeof t=="string"||x1(t)||t instanceof Gn?t:void 0)!=null&&I1(e,r,v2(t).buffer)}var di,q6=Cr(function(e,t,r){if(e.i!==1)return!1;var i=e.g;e=n2(i);let n=n2(i);i=2*(n>>31)+1;let s=n>>>20&2047;return e=4294967296*(1048575&n)+e,Or(t,r,s==2047?e?NaN:1/0*i:s==0?i*Math.pow(2,-1074)*e:i*Math.pow(2,s-1075)*(e+4503599627370496)),!0},function(e,t,r){(t=xo(t))!=null&&(Qi(e,r,1),e=e.g,(r=rf||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),Bt=r.getUint32(0,!0),qt=r.getUint32(4,!0),m1(e,Bt),m1(e,qt))}),jf=Cr(function(e,t,r){return e.i===5&&(Or(t,r,s2(e.g)),!0)},function(e,t,r){(t=xo(t))!=null&&(Qi(e,r,5),e=e.g,nf(t),m1(e,Bt))}),$6=P1(function(e,t,r){return(e.i===5||e.i===2)&&(t=Ro(t,lt(t),r,2,!1),e.i==2?E2(e,s2,t):t.push(s2(e.g)),!0)},function(e,t,r){if((t=C1(xo,t))!=null&&t.length){Qi(e,r,2),M1(e.g,4*t.length);for(let i=0;i<t.length;i++)r=e.g,nf(t[i]),m1(r,Bt)}}),y1=Cr(function(e,t,r){return e.i===0&&(Or(t,r,S2(e.g,y2)),!0)},Df),e2=Cr(function(e,t,r){return e.i===0&&(Or(t,r,(e=S2(e.g,y2))===0?void 0:e),!0)},Df),Y6=Cr(function(e,t,r){return e.i===0&&(Or(t,r,S2(e.g,i2)),!0)},function(e,t,r){e:if(t!=null){if(k2(t)){if(typeof t=="string"){var i=Math.trunc(Number(t));Number.isSafeInteger(i)&&0<=i?t=String(i):((i=t.indexOf("."))!==-1&&(t=t.substring(0,i)),k4(t)||(T1(t),t=d1(Bt,qt)));break e}if(typeof t=="number"){t=0<=(t=Math.trunc(t))&&Number.isSafeInteger(t)?t:function(n){if(0>n){ma(n);let s=d1(Bt,qt);return n=Number(s),Number.isSafeInteger(n)?n:s}return k4(String(n))?n:(ma(n),i2(Bt,qt))}(t);break e}}t=void 0}t!=null&&(typeof t=="string"&&b4(t),t!=null&&(Qi(e,r,0),typeof t=="number"?(e=e.g,ma(t),f1(e,Bt,qt)):(r=b4(t),f1(e.g,r.i,r.g))))}),$n=Cr(function(e,t,r){return e.i===0&&(Or(t,r,zr(e.g)),!0)},Nf),Gf=P1(function(e,t,r){return(e.i===0||e.i===2)&&(t=Ro(t,lt(t),r,2,!1),e.i==2?E2(e,zr,t):t.push(zr(e.g)),!0)},function(e,t,r){if((t=C1(xs,t))!=null&&t.length){r=x2(e,r);for(let i=0;i<t.length;i++)B1(e.g,t[i]);R2(e,r)}}),ba=Cr(function(e,t,r){return e.i===0&&(Or(t,r,(e=zr(e.g))===0?void 0:e),!0)},Nf),Zi=Cr(function(e,t,r){return e.i===0&&(Or(t,r,w2(e.g)),!0)},Vf),bo=Cr(function(e,t,r){return e.i===0&&(Or(t,r,(e=w2(e.g))===!1?void 0:e),!0)},Vf),Bi=P1(function(e,t,r){return e.i===2&&(Ef(t,r,N6,e=A2(e)),!0)},function(e,t,r){if((t=C1(Es,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&I1(i,n,z4(s))}}),zn=Cr(function(e,t,r){return e.i===2&&(Or(t,r,(e=A2(e))===""?void 0:e),!0)},Uf),cr=Cr(function(e,t,r){return e.i===2&&(Or(t,r,A2(e)),!0)},Uf),W6=new Ki(function(e,t,r,i,n){return e.i===2&&(k1(e,P2(t,i,r,!0),n),!0)},L1,!1,!0),K6=new Ki(function(e,t,r,i,n){return e.i===2&&(k1(e,P2(t,i,r),n),!0)},L1,!1,!0);di=new Ki(function(e,t,r,i,n){if(e.i!==2)return!1;i=wo(void 0,i[0],i[1]);let s=lt(t);vn(s);let a=Ro(t,s,r,3);return s=lt(t),4&$t(a)&&(a=qr(a),Nt(a,-2079&(1|$t(a))),Ut(t,s,r,a)),a.push(i),k1(e,i,n),!0},function(e,t,r,i,n){if(Array.isArray(t))for(let s=0;s<t.length;s++)L1(e,t[s],r,i,n)},!0,!0);var fi=new Ki(function(e,t,r,i,n,s){if(e.i!==2)return!1;let a=lt(t);return vn(a),(s=O2(t,a,s))&&r!==s&&Ut(t,a,s),k1(e,t=P2(t,i,r),n),!0},L1,!1,!0),Xf=Cr(function(e,t,r){return e.i===2&&(Or(t,r,lf(e)),!0)},Hf),Ao=Cr(function(e,t,r){return e.i===0&&(Or(t,r,zr(e.g)),!0)},function(e,t,r){(t=xs(t))!=null&&(t=parseInt(t,10),Qi(e,r,0),B1(e.g,t))}),Z6=P1(function(e,t,r){return(e.i===0||e.i===2)&&(t=Ro(t,lt(t),r,2,!1),e.i==2?E2(e,B6,t):t.push(zr(e.g)),!0)},function(e,t,r){if((t=C1(xs,t))!=null&&t.length){r=x2(e,r);for(let i=0;i<t.length;i++)B1(e.g,t[i]);R2(e,r)}}),g1=class{constructor(t,r){this.i=t,this.g=r,this.j=Mi,this.defaultValue=void 0}};function zf(e,t){return(r,i)=>{e:{if(a1.length){let s=a1.pop();s.s(i),Zc(s.g,r,i),r=s}else r=new class{constructor(s,a){if(v4.length){let m=v4.pop();Zc(m,s,a),s=m}else s=new class{constructor(m,p){this.i=null,this.m=!1,this.g=this.j=this.u=0,Zc(this,m,p)}clear(){this.i=null,this.m=!1,this.g=this.j=this.u=0,this.F=!1}}(s,a);this.g=s,this.j=this.g.g,this.i=this.m=-1,this.s(a)}s({J:s=!1}={}){this.J=s}}(r,i);try{let s=new e,a=s.l;F2(t)(a,r),So&&delete a[So];var n=s;break e}finally{r.g.clear(),r.m=-1,r.i=-1,100>a1.length&&a1.push(r)}n=void 0}return n}}var qf=[0,zn,Cr(function(e,t,r){return e.i===2&&(Or(t,r,(e=lf(e))===_a()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof It){let i=t.X;return void(i&&(t=i(t),t!=null&&I1(e,r,v2(t).buffer)))}if(Array.isArray(t))return}Hf(e,t,r)})],Q6=[0,cr],$f=[0,$n,Ao,Zi,-1,Gf,Ao,-1],J6=[0,Zi,-1],Yf=class extends It{constructor(){super()}};Yf.v=[6];var Wf=[0,Zi,cr,Zi,Ao,-1,Z6,cr,-1,J6,Ao],Kf=[0,cr,-2],P4=class extends It{constructor(){super()}},Zf=[0],Qf=[0,$n,Zi,-2],Jf=class extends It{constructor(e){super(e,2)}},F1={},ev=[-2,F1,Zi];F1[336783863]=[0,cr,Zi,-1,$n,[0,[1,2,3,4,5],fi,Zf,fi,Wf,fi,Kf,fi,Qf,fi,$f],Q6];var tv=[0,zn,bo],em=[0,e2,-1,bo,-3,e2,Gf,zn,ba,e2,-1,bo,ba,bo,-2,zn],To=[-1,{}],tm=[0,cr,1,To],rm=[0,cr,Bi,To],D1=class extends It{constructor(e){super(e,500)}s(e){return Mi(this,0,7,e)}};D1.v=[3,4,5,6,8,13,17,1005];var L4,rv=[-500,zn,-1,Bi,-3,ev,di,qf,ba,-1,tm,rm,di,tv,zn,em,ba,Bi,987,Bi],iv=[0,zn,-1,To],nv=[-500,cr,-1,[-1,{}],998,cr],sv=[-500,cr,Bi,-1,[-2,{},Zi],997,Bi,-1],av=[-500,cr,Bi,To,998,Bi],S1=class extends It{constructor(){super(void 0,500)}s(e){return Mi(this,0,1001,e)}};S1.v=[1,6,7,9,10,15,16,17,14,1002],S1.prototype.g=(L4=[-500,di,rv,4,di,nv,di,sv,ba,di,av,Bi,ba,tm,rm,di,iv,Bi,-2,em,zn,-1,bo,979,To,di,qf],function(){let e=new class{constructor(){this.j=[],this.i=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){let s=this.g;return this.g=[],s}}}};Ff(this.l,e,O1(L4)),va(e,e.g.end());let t=new Uint8Array(e.i),r=e.j,i=r.length,n=0;for(let s=0;s<i;s++){let a=r[s];t.set(a,n),n+=a.length}return e.j=[t],t});var ov=class extends It{constructor(e){super(e)}},lv=[0,$n,jf,cr,-1],im=class extends It{constructor(e){super(e)}g(){return L2(this,ov)}};im.v=[1];var cv=[0,di,lv],u2=class extends It{constructor(e){super(e)}};u2.v=[4,5];var F4=class extends It{constructor(e){super(e)}},nm=[1,2,3,4,5],w1=class extends It{constructor(e){super(e)}g(){return gf(this)!=null}i(){return Es(_n(this,2))!=null}},A1=class extends It{constructor(e){super(e)}},sm=[0,[0,Xf,cr,[0,$n,y1,-1],[0,Y6,y1]],Zi,[0,nm,fi,Qf,fi,Wf,fi,$f,fi,Zf,fi,Kf],Ao],am=class extends It{constructor(e){super(e)}},uv=new g1(451755788,am);F1[451755788]=[0,sm,[0,cr,$n,jf,Bi,-1],q6];var D4=class extends It{constructor(e){super(e)}},om=class extends It{constructor(e){super(e)}},hv=new g1(487277289,om);F1[487277289]=[0,sm,[0,Zi,-1]];var dv=class extends It{constructor(e){super(e)}},fv=[0,1,$n,cr,cv],lm=class extends It{constructor(e){super(e)}};lm.v=[1];var mv=zf(lm,[0,di,fv,y1]),h2=class extends It{constructor(e){super(e)}};h2.v=[1];var pv=class extends It{constructor(e){super(e)}O(){let e=gf(this);return e??_a()}},_v=class extends It{constructor(e){super(e)}},cm=[1,2],vv=[0,cm,fi,[0,$6],fi,[0,Xf],$n,cr],um=class extends It{constructor(e){super(e)}};um.v=[1];var N4=zf(um,[0,di,vv,y1]);async function V4(e){if(typeof importScripts!="function"){let t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise((r,i)=>{t.addEventListener("load",()=>{r()},!1),t.addEventListener("error",n=>{i(n)},!1),document.body.appendChild(t)})}importScripts(e.toString())}function Xe(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.h.stringToNewUTF8(t)),e.h._free(t)}function U4(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");let i=new Uint32Array(t.length);for(let n=0;n<t.length;n++)i[n]=e.h.stringToNewUTF8(t[n]);t=e.h._malloc(4*i.length),e.h.HEAPU32.set(i,t>>2),r(t);for(let n of i)e.h._free(n);e.h._free(t)}function Ss(e,t,r){e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=r}function ha(e,t,r){let i=[];e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=(n,s,a)=>{s?(r(i,a),i=[]):i.push(n)}}var bv=function(e){return class extends e{U(){this.h._registerModelResourcesGraphService()}}}(class{constructor(e,t){this.j=!0,this.h=e,this.g=null,this.i=0,this.m=typeof this.h._addIntToInputStream=="function",t!==void 0?this.h.canvas=t:((e=typeof OffscreenCanvas>"u")||(e=(e=navigator.userAgent).includes("Safari")&&!e.includes("Chrome")),e?(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas")):this.h.canvas=new OffscreenCanvas(1,1))}async initializeGraph(e){let t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){let r=e.length,i=this.h._malloc(r);this.h.HEAPU8.set(e,i),t?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(e,t,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Xe(this,i||"input_audio",s=>{Xe(this,n=n||"audio_header",a=>{this.h._configureAudio(s,a,e,t,r)})})}setAutoResizeCanvas(e){this.j=e}setAutoRenderToScreen(e){this.h._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.h.gpuOriginForWebTexturesIsBottomLeft=e}attachErrorListener(e){this.h.errorListener=e}attachEmptyPacketListener(e,t){this.h.emptyPacketListeners=this.h.emptyPacketListeners||{},this.h.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,i,n){let s=4*e.length;this.i!==s&&(this.g&&this.h._free(this.g),this.g=this.h._malloc(s),this.i=s),this.h.HEAPF32.set(e,this.g/4),Xe(this,i,a=>{this.h._addAudioToInputStream(this.g,t,r,a,n)})}addGpuBufferToStream(e,t,r){Xe(this,t,i=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");i?this.h._bindTextureToStream(i):this.h._bindTextureToCanvas();var n=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!n)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");let s;this.h.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),this.h.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),e.videoWidth?(n=e.videoWidth,s=e.videoHeight):e.naturalWidth?(n=e.naturalWidth,s=e.naturalHeight):(n=e.width,s=e.height),!this.j||n===this.h.canvas.width&&s===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=s);let[a,m]=[n,s];this.h._addBoundTextureToStream(i,a,m,r)})}addBoolToStream(e,t,r){Xe(this,t,i=>{this.h._addBoolToInputStream(e,i,r)})}addDoubleToStream(e,t,r){Xe(this,t,i=>{this.h._addDoubleToInputStream(e,i,r)})}addFloatToStream(e,t,r){Xe(this,t,i=>{this.h._addFloatToInputStream(e,i,r)})}addIntToStream(e,t,r){Xe(this,t,i=>{this.h._addIntToInputStream(e,i,r)})}addStringToStream(e,t,r){Xe(this,t,i=>{Xe(this,e,n=>{this.h._addStringToInputStream(n,i,r)})})}addStringRecordToStream(e,t,r){Xe(this,t,i=>{U4(this,Object.keys(e),n=>{U4(this,Object.values(e),s=>{this.h._addFlatHashMapToInputStream(n,s,Object.keys(e).length,i,r)})})})}addProtoToStream(e,t,r,i){Xe(this,r,n=>{Xe(this,t,s=>{let a=this.h._malloc(e.length);this.h.HEAPU8.set(e,a),this.h._addProtoToInputStream(a,e.length,s,n,i),this.h._free(a)})})}addEmptyPacketToStream(e,t){Xe(this,e,r=>{this.h._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let s of e)this.h._addBoolVectorEntry(n,s);this.h._addBoolVectorToInputStream(n,i,r)})}addDoubleVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let s of e)this.h._addDoubleVectorEntry(n,s);this.h._addDoubleVectorToInputStream(n,i,r)})}addFloatVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let s of e)this.h._addFloatVectorEntry(n,s);this.h._addFloatVectorToInputStream(n,i,r)})}addIntVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let s of e)this.h._addIntVectorEntry(n,s);this.h._addIntVectorToInputStream(n,i,r)})}addStringVectorToStream(e,t,r){Xe(this,t,i=>{let n=this.h._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let s of e)Xe(this,s,a=>{this.h._addStringVectorEntry(n,a)});this.h._addStringVectorToInputStream(n,i,r)})}addBoolToInputSidePacket(e,t){Xe(this,t,r=>{this.h._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){Xe(this,t,r=>{this.h._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){Xe(this,t,r=>{this.h._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){Xe(this,t,r=>{this.h._addIntToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){Xe(this,t,r=>{Xe(this,e,i=>{this.h._addStringToInputSidePacket(i,r)})})}addProtoToInputSidePacket(e,t,r){Xe(this,r,i=>{Xe(this,t,n=>{let s=this.h._malloc(e.length);this.h.HEAPU8.set(e,s),this.h._addProtoToInputSidePacket(s,e.length,n,i),this.h._free(s)})})}addBoolVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let n of e)this.h._addBoolVectorEntry(i,n);this.h._addBoolVectorToInputSidePacket(i,r)})}addDoubleVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let n of e)this.h._addDoubleVectorEntry(i,n);this.h._addDoubleVectorToInputSidePacket(i,r)})}addFloatVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let n of e)this.h._addFloatVectorEntry(i,n);this.h._addFloatVectorToInputSidePacket(i,r)})}addIntVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let n of e)this.h._addIntVectorEntry(i,n);this.h._addIntVectorToInputSidePacket(i,r)})}addStringVectorToInputSidePacket(e,t){Xe(this,t,r=>{let i=this.h._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let n of e)Xe(this,n,s=>{this.h._addStringVectorEntry(i,s)});this.h._addStringVectorToInputSidePacket(i,r)})}attachBoolListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachBoolListener(r)})}attachBoolVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachBoolVectorListener(r)})}attachIntListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachIntListener(r)})}attachIntVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachIntVectorListener(r)})}attachDoubleListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachDoubleVectorListener(r)})}attachFloatListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachFloatListener(r)})}attachFloatVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachFloatVectorListener(r)})}attachStringListener(e,t){Ss(this,e,t),Xe(this,e,r=>{this.h._attachStringListener(r)})}attachStringVectorListener(e,t){ha(this,e,t),Xe(this,e,r=>{this.h._attachStringVectorListener(r)})}attachProtoListener(e,t,r){Ss(this,e,t),Xe(this,e,i=>{this.h._attachProtoListener(i,r||!1)})}attachProtoVectorListener(e,t,r){ha(this,e,t),Xe(this,e,i=>{this.h._attachProtoVectorListener(i,r||!1)})}attachAudioListener(e,t,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Ss(this,e,(i,n)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,n)}),Xe(this,e,i=>{this.h._attachAudioListener(i,r||!1)})}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}}),hm=class extends bv{};async function yv(e,t,r){return e=await(async(i,n,s,a)=>{if(n&&await V4(n),!self.ModuleFactory||s&&(await V4(s),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&a&&((n=self.Module).locateFile=a.locateFile,a.mainScriptUrlOrBlob&&(n.mainScriptUrlOrBlob=a.mainScriptUrlOrBlob)),a=await self.ModuleFactory(self.Module||a),self.ModuleFactory=self.Module=void 0,new i(a,null)})(e,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:i=>i.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&i.endsWith(".data")?t.assetBinaryPath.toString():i}),await e.s(r),e}async function dm(e,t,r){return yv(e,t,r)}function H4(e,t){let r=ki(e.baseOptions,w1,1)||new w1;typeof t=="string"?(or(r,2,_1(t)),or(r,1)):t instanceof Uint8Array&&(or(r,1,uf(t,!1,!1)),or(r,2)),Mi(e.baseOptions,0,1,r)}function fm(e,t){let r=t.baseOptions||{};if(t.baseOptions?.modelAssetBuffer&&t.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(ki(e.baseOptions,w1,1)?.g()||ki(e.baseOptions,w1,1)?.i()||t.baseOptions?.modelAssetBuffer||t.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");return function(i,n){let s=ki(i.baseOptions,F4,3);if(!s){var a=s=new F4;Jc(a,4,new P4)}"delegate"in n&&(n.delegate==="GPU"?Jc(n=s,2,a=new Yf):Jc(n=s,4,a=new P4)),Mi(i.baseOptions,0,3,s)}(e,r),r.modelAssetPath?fetch(r.modelAssetPath.toString()).then(i=>{if(i.ok)return i.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${i.status})`)}).then(i=>{try{e.g.h.FS_unlink("/model.dat")}catch{}e.g.h.FS_createDataFile("/","model.dat",new Uint8Array(i),!0,!1,!1),H4(e,"/model.dat"),e.I()}):(H4(e,r.modelAssetBuffer),e.I(),Promise.resolve())}function j4(e){try{let t=e.j.length;if(t===1)throw Error(e.j[0].message);if(1<t)throw Error("Encountered multiple errors: "+e.j.map(r=>r.message).join(", "))}finally{e.j=[]}}function da(e,t){e.u=Math.max(e.u,t)}var d2=class{constructor(e){this.g=e,this.j=[],this.u=0,this.g.setAutoRenderToScreen(!1)}setGraph(e,t){this.g.attachErrorListener((r,i)=>{this.j.push(Error(i))}),this.g.U(),this.g.setGraph(e,t),j4(this)}finishProcessing(){this.g.finishProcessing(),j4(this)}close(){this.g.closeGraph()}};async function yo(e,t,r){return dm(e,t,r)}d2.prototype.close=d2.prototype.close;var E1=class extends d2{constructor(){super(...arguments),this.H=48e3}V(e){this.H=e}};function gv(e){let t={classifications:L2(e,dv).map(r=>function(i,n=-1,s=""){return{categories:i.map(a=>{var m=xs(_n(a,1))??0??-1;let p=a.l,T=lt(p),Z=qn(p,T,2),G=xo(Z);return G!=null&&G!==Z&&Ut(p,T,2,G),{index:m,score:G??0??0,categoryName:Es(_n(a,3))??""??"",displayName:Es(_n(a,4))??""??""}}),headIndex:n,headName:s}}(ki(r,im,4)?.g()??[],xs(_n(r,2))??0,Es(_n(r,3))??""))};return c2(e)!=null&&(t.timestampMs=kf(c2(e))),t}E1.prototype.setDefaultSampleRate=E1.prototype.V;var ui=class extends E1{constructor(e,t){super(new hm(e,t)),this.m=[],Mi(e=this.i=new am,0,1,t=new A1)}get baseOptions(){return ki(this.i,A1,1)}set baseOptions(e){Mi(this.i,0,1,e)}s(e){var t=this.i,r=ki(this.i,u2,2);if(r=r?bf(r):new u2,e.displayNamesLocale!==void 0?or(r,1,_1(e.displayNamesLocale)):e.displayNamesLocale===void 0&&or(r,1),e.maxResults!==void 0){var i=e.maxResults;if(i!=null){if(typeof i!="number"||!Number.isFinite(i))throw R4();i|=0}or(r,2,i)}else"maxResults"in e&&or(r,2);if(e.scoreThreshold!==void 0){if((i=e.scoreThreshold)!=null&&typeof i!="number")throw Error(`Value of float/double field must be a number, found ${typeof i}: ${i}`);or(r,3,i)}else"scoreThreshold"in e&&or(r,3);return e.categoryAllowlist!==void 0?M4(r,4,e.categoryAllowlist):"categoryAllowlist"in e&&or(r,4),e.categoryDenylist!==void 0?M4(r,5,e.categoryDenylist):"categoryDenylist"in e&&or(r,5),Mi(t,0,2,r),fm(this,e)}R(e,t){return this.G(e,t??this.H,this.u+1)}G(e,t,r){return this.g.addDoubleToStream(t,"sample_rate",r),this.g.addAudioToStreamWithShape(e,1,e.length,"audio_in",r),this.m=[],this.finishProcessing(),[...this.m]}I(){var e=new S1;Ir(e,10,"audio_in"),Ir(e,10,"sample_rate"),Ir(e,15,"timestamped_classifications");let t=new Jf;Mf(t,uv,this.i);let r=new D1;Af(r,_1("mediapipe.tasks.audio.audio_classifier.AudioClassifierGraph")),Ir(r,3,"AUDIO:audio_in"),Ir(r,3,"SAMPLE_RATE:sample_rate"),Ir(r,4,"TIMESTAMPED_CLASSIFICATIONS:timestamped_classifications"),r.s(t),Tf(e,r),this.g.attachProtoVectorListener("timestamped_classifications",(i,n)=>{(function(s,a){a.forEach(m=>{m=mv(m),s.m.push(gv(m))})})(this,i),da(this,n)}),this.g.attachEmptyPacketListener("timestamped_classifications",i=>{da(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function G4(e){return{embeddings:L2(e,_v).map(t=>{let r={headIndex:xs(_n(t,3))??0??-1,headName:Es(_n(t,4))??""??""};if(xf(t,h2,Qc(t,1))!==void 0){var i=void 0;t=ki(t,h2,Qc(t,1)).l;let m=lt(t),p=2&m?1:2;i=!!i;let T=Sf(t,m);var n=$t(T);if(!(4&n)){(4&n||Object.isFrozen(T))&&(T=qr(T),n=Rs(n,m,i),m=Ut(t,m,1,T));for(var s=0,a=0;s<T.length;s++){let Z=xo(T[s]);Z!=null&&(T[a++]=Z)}a<s&&(T.length=a),n=ar(n=wf(n,m,i),20,!0),n=ar(n,4096,!1),n=ar(n,8192,!1),Nt(T,n),2&n&&Object.freeze(T)}vo(n)||(s=n,(a=p===1)?n=ar(n,2,!0):i||(n=ar(n,32,!1)),n!==s&&Nt(T,n),a&&Object.freeze(T)),p===2&&vo(n)&&(T=qr(T),n=Rs(n,m,i),Nt(T,n),Ut(t,m,1,T)),r.floatEmbedding=T}else i=new Uint8Array(0),r.quantizedEmbedding=ki(t,pv,Qc(t,2))?.O()?.P()??i;return r}),timestampMs:kf(c2(e))}}ui.prototype.classify=ui.prototype.R,ui.prototype.setOptions=ui.prototype.s,ui.createFromModelPath=function(e,t){return dm(ui,e,{baseOptions:{modelAssetPath:t}})},ui.createFromModelBuffer=function(e,t){return yo(ui,e,{baseOptions:{modelAssetBuffer:t}})},ui.createFromOptions=function(e,t){return yo(ui,e,t)};var Yi=class extends E1{constructor(e,t){super(new hm(e,t)),this.m=[],Mi(e=this.i=new om,0,1,t=new A1)}get baseOptions(){return ki(this.i,A1,1)}set baseOptions(e){Mi(this.i,0,1,e)}s(e){var t=this.i,r=ki(this.i,D4,2);return r=r?bf(r):new D4,e.l2Normalize!==void 0?or(r,1,T4(e.l2Normalize)):"l2Normalize"in e&&or(r,1),e.quantize!==void 0?or(r,2,T4(e.quantize)):"quantize"in e&&or(r,2),Mi(t,0,2,r),fm(this,e)}S(e,t){return this.G(e,t??this.H,this.u+1)}G(e,t,r){return this.g.addDoubleToStream(t,"sample_rate",r),this.g.addAudioToStreamWithShape(e,1,e.length,"audio_in",r),this.m=[],this.finishProcessing(),this.m}I(){var e=new S1;Ir(e,10,"audio_in"),Ir(e,10,"sample_rate"),Ir(e,15,"embeddings_out"),Ir(e,15,"timestamped_embeddings_out");let t=new Jf;Mf(t,hv,this.i);let r=new D1;Af(r,_1("mediapipe.tasks.audio.audio_embedder.AudioEmbedderGraph")),Ir(r,3,"AUDIO:audio_in"),Ir(r,3,"SAMPLE_RATE:sample_rate"),Ir(r,4,"EMBEDDINGS:embeddings_out"),Ir(r,4,"TIMESTAMPED_EMBEDDINGS:timestamped_embeddings_out"),r.s(t),Tf(e,r),this.g.attachProtoListener("embeddings_out",(i,n)=>{i=N4(i),this.m.push(G4(i)),da(this,n)}),this.g.attachEmptyPacketListener("embeddings_out",i=>{da(this,i)}),this.g.attachProtoVectorListener("timestamped_embeddings_out",(i,n)=>{for(let s of i)i=N4(s),this.m.push(G4(i));da(this,n)}),this.g.attachEmptyPacketListener("timestamped_embeddings_out",i=>{da(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}},o1;Yi.prototype.embed=Yi.prototype.S,Yi.prototype.setOptions=Yi.prototype.s,Yi.createFromModelPath=function(e,t){return yo(Yi,e,{baseOptions:{modelAssetPath:t}})},Yi.createFromModelBuffer=function(e,t){return yo(Yi,e,{baseOptions:{modelAssetBuffer:t}})},Yi.createFromOptions=function(e,t){return yo(Yi,e,t)};var Sv=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function mm(){if(o1===void 0)try{await WebAssembly.instantiate(Sv),o1=!0}catch{o1=!1}return o1}async function t2(e,t=""){let r=await mm()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var fa=class{};fa.forVisionTasks=function(e){return t2("vision",e)},fa.forTextTasks=function(e){return t2("text",e)},fa.forAudioTasks=function(e){return t2("audio",e)},fa.isSimdSupported=function(){return mm()};var N1=class{constructor(t,r,i,n,s,a,m){this.recordingInProgress=!1;this.recordIndex=1;this.countLoopTimes=0;this.examStartTime=0;this.recordingStartTime=0;this.recordingEndTime=0;this.isSpeech=!1;this.optionsProctoring=t,this.proctoringSession=r,this.paramsConfig=i,this.cameraRecorder=n,this.onRealtimeAlertsCallback=s,this.backend=a,this.backendToken=m}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new cn(this.proctoringId,this.backend))}async startRecording(){this.examStartTime=Date.now(),await this.createAudioClassifier(),this.audioRecorder=new ua(this.paramsConfig.audioBehaviourParameters),this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetectedRecord(),500),this.streamingAudioClassification()}async stopRecording(){clearInterval(this.intervalNoiseDetection),await this.stopSoundRecord(),await this.volumeMeter.stop(),this.scriptProcessor&&this.scriptProcessor.disconnect()}async pauseRecording(){}async resumeRecording(){}async saveOnSession(t){}async onNoiseDetectedRecord(){!this.volumeMeter&&this.cameraRecorder.cameraStream&&(this.volumeMeter=new Un(this.cameraRecorder.cameraStream),this.volumeMeter.start().catch(i=>{console.log(i),this.volumeMeter=void 0}));let t=this.optionsProctoring.noiseLimit||40,r=this.volumeMeter?.getVolume()||0;this.isSpeech=this.isSpeech||this.hasDesiredResult(this.audioClassificationResult),!this.isSpeech&&!this.recordingInProgress&&(t=t+t*.25),r>=t&&!this.recordingInProgress?(this.recordingInProgress=!0,this.audioRecorder.startRecording(),this.recordingStartTime=Date.now()-this.examStartTime):r<t&&this.recordingInProgress&&(Date.now()-this.recordingStartTime>=3e3&&this.countLoopTimes>4&&!this.hasDesiredResult(this.audioClassificationResult)&&(await this.stopSoundRecord(),this.paramsConfig.videoBehaviourParameters?.detectSpeech&&this.isSpeech&&this.onRealtimeAlertsCallback({status:"ALERT",description:"Fala detectada",type:"audio_detection_on_stream"}),this.recordingInProgress=!1,this.recordIndex++,this.countLoopTimes=0,this.isSpeech=!1),this.countLoopTimes++)}async stopSoundRecord(){if(await this.audioRecorder.stopRecording(),this.recordingEndTime=Date.now()-this.examStartTime,!this.isSpeech)return;let t=new File(this.audioRecorder.blobs,`EP_${this.proctoringSession.id}_${this.recordingStartTime}_${this.recordingEndTime}_${this.isSpeech?"speech":"noise"}.mp3`,{type:"audio/mp3"});this.uploadRecord(t),this.audioRecorder.blobs=[]}download(t){let r=URL.createObjectURL(t),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=r,i.download=t.name,i.click(),window.URL.revokeObjectURL(r)}uploadRecord(t){t&&this.upload&&this.backendToken&&this.upload.upload({file:t},this.backendToken)}hasDesiredResult(t){if(t==null)return!1;for(let r of t)return r.name.toLowerCase().includes("speech");return!1}async createAudioClassifier(){let t=await fa.forAudioTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-audio@0.10.0/wasm");this.audioClassifier=await ui.createFromOptions(t,{scoreThreshold:.15,maxResults:1,baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/1/yamnet.tflite"}})}async streamingAudioClassification(){let t=new AudioContext({sampleRate:16e3}),r=t.createMediaStreamSource(this.cameraRecorder.cameraStream);this.scriptProcessor=t.createScriptProcessor(16384,1,1);let i=this;this.scriptProcessor.onaudioprocess=function(n){let a=n.inputBuffer.getChannelData(0),m=i.audioClassifier.classify(a),p=m[0].classifications[0].categories;m[0].classifications[0].categories.length>0&&(i.audioClassificationResult=[{name:p[0].categoryName,score:p[0].score.toFixed(3)}])},r.connect(this.scriptProcessor),this.scriptProcessor.connect(t.destination)}};var V1=class{constructor(t){this.blobs=[];this.blobsFinal=[];this.options=t}setProctoringId(t){this.proctoringId=t}async startRecording(){this.startTime=new Date(Date.now());let{allowOnlyFirstMonitor:t,allowMultipleMonitors:r,onStopSharingScreenCallback:i,onBufferSizeErrorCallback:n}=this.options,s={video:{cursor:"always",width:854,height:480,displaySurface:"monitor"},audio:!1};this.screenStream=await navigator.mediaDevices.getDisplayMedia(s);let a=this.screenStream.getVideoTracks();if(a[0].onended=i,navigator.userAgent.indexOf("Firefox")>-1){let Ae=a.find(ne=>ne.label=="");if(Ae&&t||Ae&&!r)throw c0}let p=a.find(Ae=>["screen:0:0","Primary Monitor"].includes(Ae.label))!=null,T=a.find(Ae=>["screen:0:0","Primary Monitor",""].includes(Ae.label)||["screen:"].some(ne=>Ae.label.includes(ne)))!=null,Z=a.find(Ae=>["web-contents-media-stream","window"].some(ne=>Ae.label.includes(ne)))!=null;if(!p&&t)throw a.forEach(Ae=>{Ae.stop()}),Hu;if(!T||Z)throw a.forEach(Ae=>{Ae.stop()}),ju;let{startRecording:G,stopRecording:fe}=Oa(this.screenStream,this.blobs,this.proctoringId,this.options.onBufferSizeError,n);this.recordingStart=G,this.recordingStop=fe,this.recordingStart()}async pauseRecording(){}async resumeRecording(){}async stopRecording(){this.recordingStop&&await this.recordingStop()}async saveOnSession(t){t.addRecording({device:"",file:new File(this.blobs,`EP_${t.id}_screen_0.webm`,{type:"video/webm"}),origin:"Screen"})}};var ko=class{constructor(t,r){this.dbName="EasyProctorDb";this.dbVersion=2;this.storeName="exams2";this.dbName=t,this.storeName=r}async save(t){let{transaction:r,store:i}=await this.connectToStore("readwrite");return this.processRequest(i.put(t),r).then(()=>{})}async delete(t){let{transaction:r,store:i}=await this.connectToStore("readwrite");return this.processRequest(i.delete(t),r)}async get(t){let{transaction:r,store:i}=await this.connectToStore("readwrite");return this.processRequest(i.get(t),r).catch(()=>{})}async getDevices(t){let{transaction:r,store:i}=await this.connectToStore("readwrite");return this.processRequest(i.get(t),r).catch(()=>{})}async list(){let{transaction:t,store:r}=await this.connectToStore("readonly");return this.processRequest(r.getAll(),t)}async clear(){let{transaction:t,store:r}=await this.connectToStore("readwrite");return this.processRequest(r.clear(),t)}async processRequest(t,r){return new Promise((i,n)=>{t.onerror=s=>{n(t.error?.message)},t.onsuccess=s=>{r.commit(),i(t.result)}})}async hasSessions(){return(await this.list()).length>0}async connectToStore(t){let n=(await this.connect()).result.transaction(this.storeName,t),s=n.objectStore(this.storeName);return{transaction:n,store:s}}async connect(){return this.connection?this.connection:new Promise((t,r)=>{let i=window.indexedDB.open(this.dbName,this.dbVersion);i.onerror=n=>{r("Can't connect to IndexedDB")},i.onupgradeneeded=n=>{let s=i.result;s.onerror=a=>{},s.createObjectStore(this.storeName,{keyPath:"id"})},i.onsuccess=n=>{this.connection=i,t(i)}})}};function pm(){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 _m(){return new Promise((e,t)=>{window.navigator.geolocation.getCurrentPosition(e,t)})}function Mo(){let e=window.navigator.userAgent.split("SEB/");return e.length>1?e[1]:"1.0.0.0"}var U1=class{constructor(t,r){this.cpf=t,this.backend=r,this.capturePhoto=new oa}async login(){let t=await this.capturePhoto.takePicture("Login com biometria facial","Encaixe seu rosto no formato e clique no bot\xE3o abaixo",{width:1080,height:720});return this.loading(),new Promise((r,i)=>{this.backend.loginAuth(this.cpf,t.base64.substr(22,t.base64.length)).then(n=>{this.token=n.token,document.querySelector("#authLoader")?.remove(),this.backend.token=this.token,r(this.token)}).catch(n=>{console.log(n),document.querySelector("#authLoader")?.remove(),i(n)})})}loading(){let t=document.createElement("div");t.setAttribute("id","authLoader"),t.style.backgroundColor="rgba(0,0,0,0.4)",t.style.zIndex="1000",t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.height="100vh",t.style.width="100%",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center";let r=document.createElement("div");r.setAttribute("class","loader"),t.appendChild(r),document.body.appendChild(t);let i=`
235
235
  .loader {
236
236
  border: 6px solid #f3f3f3;
237
237
  border-radius: 50%;