easyproctor-hml 2.5.24 → 2.5.26
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 +22 -10
- package/index.js +22 -10
- package/new-flow/recorders/VolumeMeter.d.ts +2 -0
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +5 -5
package/esm/index.js
CHANGED
|
@@ -12333,10 +12333,16 @@ function recorder(stream, buffer, videoOptions, onBufferSizeError = false, onBuf
|
|
|
12333
12333
|
}
|
|
12334
12334
|
console.log("startRecording", timeSlice);
|
|
12335
12335
|
try {
|
|
12336
|
-
mediaRecorder.start(timeSlice);
|
|
12337
12336
|
mediaRecorder.onstart = () => {
|
|
12338
12337
|
console.log("Grava\xE7\xE3o iniciada com sucesso!");
|
|
12339
12338
|
};
|
|
12339
|
+
mediaRecorder.onerror = (e3) => {
|
|
12340
|
+
console.error("Erro no MediaRecorder:", e3);
|
|
12341
|
+
};
|
|
12342
|
+
console.log("mediaRecorder.state", mediaRecorder.state);
|
|
12343
|
+
console.log(stream.active);
|
|
12344
|
+
console.log(stream.getTracks().map((t3) => t3.readyState));
|
|
12345
|
+
mediaRecorder.start(timeSlice);
|
|
12340
12346
|
} catch (e3) {
|
|
12341
12347
|
console.error("Falha ao iniciar:", e3);
|
|
12342
12348
|
}
|
|
@@ -12676,12 +12682,12 @@ var VolumeMeter = class {
|
|
|
12676
12682
|
async start(options = {}) {
|
|
12677
12683
|
return new Promise((resolve, reject) => {
|
|
12678
12684
|
try {
|
|
12679
|
-
|
|
12680
|
-
this.analyser = audioContext.createAnalyser();
|
|
12681
|
-
|
|
12685
|
+
this.audioContext = new AudioContext();
|
|
12686
|
+
this.analyser = this.audioContext.createAnalyser();
|
|
12687
|
+
this.microphone = this.audioContext.createMediaStreamSource(this.stream);
|
|
12682
12688
|
this.analyser.smoothingTimeConstant = 0.8;
|
|
12683
12689
|
this.analyser.fftSize = 1024;
|
|
12684
|
-
microphone.connect(this.analyser);
|
|
12690
|
+
this.microphone.connect(this.analyser);
|
|
12685
12691
|
const processAudio = () => {
|
|
12686
12692
|
const array = new Uint8Array(this.analyser.frequencyBinCount);
|
|
12687
12693
|
this.analyser.getByteFrequencyData(array);
|
|
@@ -12703,6 +12709,8 @@ var VolumeMeter = class {
|
|
|
12703
12709
|
if (this.animationFrameId !== null) {
|
|
12704
12710
|
cancelAnimationFrame(this.animationFrameId);
|
|
12705
12711
|
}
|
|
12712
|
+
this.microphone.disconnect();
|
|
12713
|
+
this.analyser.disconnect();
|
|
12706
12714
|
}
|
|
12707
12715
|
getVolume() {
|
|
12708
12716
|
return this.volume;
|
|
@@ -12984,6 +12992,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
12984
12992
|
console.log("startRecording Camera Recorder finished");
|
|
12985
12993
|
}
|
|
12986
12994
|
async stopRecording() {
|
|
12995
|
+
console.log("Stopping Camera Recorder...");
|
|
12987
12996
|
this.isCanvasLoopActive = false;
|
|
12988
12997
|
this.recordingStop && await this.recordingStop();
|
|
12989
12998
|
try {
|
|
@@ -17789,6 +17798,7 @@ var NoiseRecorder = class {
|
|
|
17789
17798
|
await this.stopSoundRecord();
|
|
17790
17799
|
await this.volumeMeter && this.volumeMeter.stop();
|
|
17791
17800
|
this.audioWorkletNode && this.audioWorkletNode.disconnect();
|
|
17801
|
+
this.context && this.context.close();
|
|
17792
17802
|
}
|
|
17793
17803
|
async pauseRecording() {
|
|
17794
17804
|
}
|
|
@@ -22071,9 +22081,11 @@ var Proctoring = class {
|
|
|
22071
22081
|
setDeviceCheckData(data) {
|
|
22072
22082
|
this.deviceData = data;
|
|
22073
22083
|
}
|
|
22074
|
-
createRecorders(options = getDefaultProctoringOptions) {
|
|
22075
|
-
var _a2, _b;
|
|
22084
|
+
async createRecorders(options = getDefaultProctoringOptions) {
|
|
22085
|
+
var _a2, _b, _c2;
|
|
22076
22086
|
this.onChangeDevices();
|
|
22087
|
+
console.log("Creating Recorders...");
|
|
22088
|
+
await ((_a2 = this.recorder) == null ? void 0 : _a2.stopAll());
|
|
22077
22089
|
const cameraRecorder = new CameraRecorder(
|
|
22078
22090
|
{
|
|
22079
22091
|
cameraId: this.sessionOptions.cameraId,
|
|
@@ -22098,8 +22110,8 @@ var Proctoring = class {
|
|
|
22098
22110
|
this.context.token
|
|
22099
22111
|
);
|
|
22100
22112
|
const screenRecorder = this.sessionOptions.captureScreen ? new ScreenRecorder({
|
|
22101
|
-
allowOnlyFirstMonitor: (
|
|
22102
|
-
allowMultipleMonitors: (
|
|
22113
|
+
allowOnlyFirstMonitor: (_b = this.sessionOptions.allowOnlyFirstMonitor) != null ? _b : true,
|
|
22114
|
+
allowMultipleMonitors: (_c2 = this.sessionOptions.allowMultipleMonitors) != null ? _c2 : true,
|
|
22103
22115
|
screenRecorderOptions: this.sessionOptions.screenRecorderOptions,
|
|
22104
22116
|
onStopSharingScreenCallback: () => this.onStopSharingScreenCallback(),
|
|
22105
22117
|
onBufferSizeError: this.sessionOptions.onBufferSizeError,
|
|
@@ -22170,7 +22182,7 @@ var Proctoring = class {
|
|
|
22170
22182
|
await this.repository.clear();
|
|
22171
22183
|
}
|
|
22172
22184
|
this.proctoringSession = new ProctoringSession();
|
|
22173
|
-
this.allRecorders = this.createRecorders(this.sessionOptions);
|
|
22185
|
+
this.allRecorders = await this.createRecorders(this.sessionOptions);
|
|
22174
22186
|
const startResponse = await this.backend.confirmStart(
|
|
22175
22187
|
{
|
|
22176
22188
|
clientId: this.context.clientId,
|
package/index.js
CHANGED
|
@@ -30430,10 +30430,16 @@ function recorder(stream4, buffer, videoOptions, onBufferSizeError = false, onBu
|
|
|
30430
30430
|
}
|
|
30431
30431
|
console.log("startRecording", timeSlice);
|
|
30432
30432
|
try {
|
|
30433
|
-
mediaRecorder.start(timeSlice);
|
|
30434
30433
|
mediaRecorder.onstart = () => {
|
|
30435
30434
|
console.log("Grava\xE7\xE3o iniciada com sucesso!");
|
|
30436
30435
|
};
|
|
30436
|
+
mediaRecorder.onerror = (e3) => {
|
|
30437
|
+
console.error("Erro no MediaRecorder:", e3);
|
|
30438
|
+
};
|
|
30439
|
+
console.log("mediaRecorder.state", mediaRecorder.state);
|
|
30440
|
+
console.log(stream4.active);
|
|
30441
|
+
console.log(stream4.getTracks().map((t3) => t3.readyState));
|
|
30442
|
+
mediaRecorder.start(timeSlice);
|
|
30437
30443
|
} catch (e3) {
|
|
30438
30444
|
console.error("Falha ao iniciar:", e3);
|
|
30439
30445
|
}
|
|
@@ -30773,12 +30779,12 @@ var VolumeMeter = class {
|
|
|
30773
30779
|
async start(options = {}) {
|
|
30774
30780
|
return new Promise((resolve, reject) => {
|
|
30775
30781
|
try {
|
|
30776
|
-
|
|
30777
|
-
this.analyser = audioContext.createAnalyser();
|
|
30778
|
-
|
|
30782
|
+
this.audioContext = new AudioContext();
|
|
30783
|
+
this.analyser = this.audioContext.createAnalyser();
|
|
30784
|
+
this.microphone = this.audioContext.createMediaStreamSource(this.stream);
|
|
30779
30785
|
this.analyser.smoothingTimeConstant = 0.8;
|
|
30780
30786
|
this.analyser.fftSize = 1024;
|
|
30781
|
-
microphone.connect(this.analyser);
|
|
30787
|
+
this.microphone.connect(this.analyser);
|
|
30782
30788
|
const processAudio = () => {
|
|
30783
30789
|
const array = new Uint8Array(this.analyser.frequencyBinCount);
|
|
30784
30790
|
this.analyser.getByteFrequencyData(array);
|
|
@@ -30800,6 +30806,8 @@ var VolumeMeter = class {
|
|
|
30800
30806
|
if (this.animationFrameId !== null) {
|
|
30801
30807
|
cancelAnimationFrame(this.animationFrameId);
|
|
30802
30808
|
}
|
|
30809
|
+
this.microphone.disconnect();
|
|
30810
|
+
this.analyser.disconnect();
|
|
30803
30811
|
}
|
|
30804
30812
|
getVolume() {
|
|
30805
30813
|
return this.volume;
|
|
@@ -31081,6 +31089,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31081
31089
|
console.log("startRecording Camera Recorder finished");
|
|
31082
31090
|
}
|
|
31083
31091
|
async stopRecording() {
|
|
31092
|
+
console.log("Stopping Camera Recorder...");
|
|
31084
31093
|
this.isCanvasLoopActive = false;
|
|
31085
31094
|
this.recordingStop && await this.recordingStop();
|
|
31086
31095
|
try {
|
|
@@ -35886,6 +35895,7 @@ var NoiseRecorder = class {
|
|
|
35886
35895
|
await this.stopSoundRecord();
|
|
35887
35896
|
await this.volumeMeter && this.volumeMeter.stop();
|
|
35888
35897
|
this.audioWorkletNode && this.audioWorkletNode.disconnect();
|
|
35898
|
+
this.context && this.context.close();
|
|
35889
35899
|
}
|
|
35890
35900
|
async pauseRecording() {
|
|
35891
35901
|
}
|
|
@@ -37320,9 +37330,11 @@ var Proctoring = class {
|
|
|
37320
37330
|
setDeviceCheckData(data) {
|
|
37321
37331
|
this.deviceData = data;
|
|
37322
37332
|
}
|
|
37323
|
-
createRecorders(options = getDefaultProctoringOptions) {
|
|
37324
|
-
var _a2, _b;
|
|
37333
|
+
async createRecorders(options = getDefaultProctoringOptions) {
|
|
37334
|
+
var _a2, _b, _c2;
|
|
37325
37335
|
this.onChangeDevices();
|
|
37336
|
+
console.log("Creating Recorders...");
|
|
37337
|
+
await ((_a2 = this.recorder) == null ? void 0 : _a2.stopAll());
|
|
37326
37338
|
const cameraRecorder = new CameraRecorder(
|
|
37327
37339
|
{
|
|
37328
37340
|
cameraId: this.sessionOptions.cameraId,
|
|
@@ -37347,8 +37359,8 @@ var Proctoring = class {
|
|
|
37347
37359
|
this.context.token
|
|
37348
37360
|
);
|
|
37349
37361
|
const screenRecorder = this.sessionOptions.captureScreen ? new ScreenRecorder({
|
|
37350
|
-
allowOnlyFirstMonitor: (
|
|
37351
|
-
allowMultipleMonitors: (
|
|
37362
|
+
allowOnlyFirstMonitor: (_b = this.sessionOptions.allowOnlyFirstMonitor) != null ? _b : true,
|
|
37363
|
+
allowMultipleMonitors: (_c2 = this.sessionOptions.allowMultipleMonitors) != null ? _c2 : true,
|
|
37352
37364
|
screenRecorderOptions: this.sessionOptions.screenRecorderOptions,
|
|
37353
37365
|
onStopSharingScreenCallback: () => this.onStopSharingScreenCallback(),
|
|
37354
37366
|
onBufferSizeError: this.sessionOptions.onBufferSizeError,
|
|
@@ -37419,7 +37431,7 @@ var Proctoring = class {
|
|
|
37419
37431
|
await this.repository.clear();
|
|
37420
37432
|
}
|
|
37421
37433
|
this.proctoringSession = new ProctoringSession();
|
|
37422
|
-
this.allRecorders = this.createRecorders(this.sessionOptions);
|
|
37434
|
+
this.allRecorders = await this.createRecorders(this.sessionOptions);
|
|
37423
37435
|
const startResponse = await this.backend.confirmStart(
|
|
37424
37436
|
{
|
|
37425
37437
|
clientId: this.context.clientId,
|
package/package.json
CHANGED
package/unpkg/easyproctor.min.js
CHANGED
|
@@ -68,7 +68,7 @@ Minimum version required to store current data is: `+o+`.
|
|
|
68
68
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[Ag]=this[Ag]={accessors:{}}).accessors,i=this.prototype;function o(s){let a=Lo(s);n[a]||(Qv(i,s),n[a]=!0)}return T.isArray(t)?t.forEach(o):o(t),this}};Ni.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);T.reduceDescriptors(Ni.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});T.freezeMethods(Ni);var at=Ni;function Fo(e,t){let r=this||Ui,n=t||r,i=at.from(n.headers),o=n.data;return T.forEach(e,function(a){o=a.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Mo(e){return!!(e&&e.__CANCEL__)}function Tg(e,t,r){le.call(this,e??"canceled",le.ERR_CANCELED,t,r),this.name="CanceledError"}T.inherits(Tg,le,{__CANCEL__:!0});var Br=Tg;function Uo(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new le("Request failed with status code "+r.status,[le.ERR_BAD_REQUEST,le.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function ad(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function e_(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,o=0,s;return t=t!==void 0?t:1e3,function(c){let l=Date.now(),h=n[o];s||(s=l),r[i]=c,n[i]=l;let d=o,m=0;for(;d!==i;)m+=r[d++],d=d%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),l-s<t)return;let p=h&&l-h;return p?Math.round(m*1e3/p):void 0}}var Ig=e_;function t_(e,t){let r=0,n=1e3/t,i,o,s=(l,h=Date.now())=>{r=h,i=null,o&&(clearTimeout(o),o=null),e.apply(null,l)};return[(...l)=>{let h=Date.now(),d=h-r;d>=n?s(l,h):(i=l,o||(o=setTimeout(()=>{o=null,s(i)},n-d)))},()=>i&&s(i)]}var Rg=t_;var zi=(e,t,r=3)=>{let n=0,i=Ig(50,250);return Rg(o=>{let s=o.loaded,a=o.lengthComputable?o.total:void 0,c=s-n,l=i(c),h=s<=a;n=s;let d={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&h?(a-s)/l:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},cd=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},ld=e=>(...t)=>T.asap(()=>e(...t));var Pg=je.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,je.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(je.origin),je.navigator&&/(msie|trident)/i.test(je.navigator.userAgent)):()=>!0;var Dg=je.hasStandardBrowserEnv?{write(e,t,r,n,i,o){let s=[e+"="+encodeURIComponent(t)];T.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),T.isString(n)&&s.push("path="+n),T.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function hd(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function dd(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function No(e,t,r){let n=!hd(t);return e&&(n||r==!1)?dd(e,t):t}var Og=e=>e instanceof at?{...e}:e;function br(e,t){t=t||{};let r={};function n(l,h,d,m){return T.isPlainObject(l)&&T.isPlainObject(h)?T.merge.call({caseless:m},l,h):T.isPlainObject(h)?T.merge({},h):T.isArray(h)?h.slice():h}function i(l,h,d,m){if(T.isUndefined(h)){if(!T.isUndefined(l))return n(void 0,l,d,m)}else return n(l,h,d,m)}function o(l,h){if(!T.isUndefined(h))return n(void 0,h)}function s(l,h){if(T.isUndefined(h)){if(!T.isUndefined(l))return n(void 0,l)}else return n(void 0,h)}function a(l,h,d){if(d in t)return n(l,h);if(d in e)return n(void 0,l)}let c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(l,h,d)=>i(Og(l),Og(h),d,!0)};return T.forEach(Object.keys(Object.assign({},e,t)),function(h){let d=c[h]||i,m=d(e[h],t[h],h);T.isUndefined(m)&&d!==a||(r[h]=m)}),r}var Ca=e=>{let t=br({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=at.from(s),t.url=Bo(No(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(T.isFormData(r)){if(je.hasStandardBrowserEnv||je.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){let[l,...h]=c?c.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([l||"multipart/form-data",...h].join("; "))}}if(je.hasStandardBrowserEnv&&(n&&T.isFunction(n)&&(n=n(t)),n||n!==!1&&Pg(t.url))){let l=i&&o&&Dg.read(o);l&&s.set(i,l)}return t};var r_=typeof XMLHttpRequest<"u",Bg=r_&&function(e){return new Promise(function(r,n){let i=Ca(e),o=i.data,s=at.from(i.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:l}=i,h,d,m,p,g;function f(){p&&p(),g&&g(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let b=new XMLHttpRequest;b.open(i.method.toUpperCase(),i.url,!0),b.timeout=i.timeout;function _(){if(!b)return;let k=at.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),x={data:!a||a==="text"||a==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:k,config:e,request:b};Uo(function(P){r(P),f()},function(P){n(P),f()},x),b=null}"onloadend"in b?b.onloadend=_:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(_)},b.onabort=function(){b&&(n(new le("Request aborted",le.ECONNABORTED,e,b)),b=null)},b.onerror=function(){n(new le("Network Error",le.ERR_NETWORK,e,b)),b=null},b.ontimeout=function(){let I=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",x=i.transitional||Sa;i.timeoutErrorMessage&&(I=i.timeoutErrorMessage),n(new le(I,x.clarifyTimeoutError?le.ETIMEDOUT:le.ECONNABORTED,e,b)),b=null},o===void 0&&s.setContentType(null),"setRequestHeader"in b&&T.forEach(s.toJSON(),function(I,x){b.setRequestHeader(x,I)}),T.isUndefined(i.withCredentials)||(b.withCredentials=!!i.withCredentials),a&&a!=="json"&&(b.responseType=i.responseType),l&&([m,g]=zi(l,!0),b.addEventListener("progress",m)),c&&b.upload&&([d,p]=zi(c),b.upload.addEventListener("progress",d),b.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(h=k=>{b&&(n(!k||k.type?new Br(null,e,b):k),b.abort(),b=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));let S=ad(i.url);if(S&&je.protocols.indexOf(S)===-1){n(new le("Unsupported protocol "+S+":",le.ERR_BAD_REQUEST,e));return}b.send(o||null)})};var n_=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,o=function(l){if(!i){i=!0,a();let h=l instanceof Error?l:this.reason;n.abort(h instanceof le?h:new Br(h instanceof Error?h.message:h))}},s=t&&setTimeout(()=>{s=null,o(new le(`timeout ${t} of ms exceeded`,le.ETIMEDOUT))},t),a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),e=null)};e.forEach(l=>l.addEventListener("abort",o));let{signal:c}=n;return c.unsubscribe=()=>T.asap(a),c}},Lg=n_;var i_=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},o_=async function*(e,t){for await(let r of s_(e))yield*i_(r,t)},s_=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},ud=(e,t,r,n)=>{let i=o_(e,t),o=0,s,a=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:l,value:h}=await i.next();if(l){a(),c.close();return}let d=h.byteLength;if(r){let m=o+=d;r(m)}c.enqueue(new Uint8Array(h))}catch(l){throw a(l),l}},cancel(c){return a(c),i.return()}},{highWaterMark:2})};var Aa=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Mg=Aa&&typeof ReadableStream=="function",a_=Aa&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Ug=(e,...t)=>{try{return!!e(...t)}catch{return!1}},c_=Mg&&Ug(()=>{let e=!1,t=new Request(je.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Fg=64*1024,fd=Mg&&Ug(()=>T.isReadableStream(new Response("").body)),xa={stream:fd&&(e=>e.body)};Aa&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!xa[t]&&(xa[t]=T.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new le(`Response type '${t}' is not supported`,le.ERR_NOT_SUPPORT,n)})})})(new Response);var l_=async e=>{if(e==null)return 0;if(T.isBlob(e))return e.size;if(T.isSpecCompliantForm(e))return(await new Request(je.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(T.isArrayBufferView(e)||T.isArrayBuffer(e))return e.byteLength;if(T.isURLSearchParams(e)&&(e=e+""),T.isString(e))return(await a_(e)).byteLength},h_=async(e,t)=>{let r=T.toFiniteNumber(e.getContentLength());return r??l_(t)},Ng=Aa&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:h,withCredentials:d="same-origin",fetchOptions:m}=Ca(e);l=l?(l+"").toLowerCase():"text";let p=Lg([i,o&&o.toAbortSignal()],s),g,f=p&&p.unsubscribe&&(()=>{p.unsubscribe()}),b;try{if(c&&c_&&r!=="get"&&r!=="head"&&(b=await h_(h,n))!==0){let x=new Request(t,{method:"POST",body:n,duplex:"half"}),O;if(T.isFormData(n)&&(O=x.headers.get("content-type"))&&h.setContentType(O),x.body){let[P,z]=cd(b,zi(ld(c)));n=ud(x.body,Fg,P,z)}}T.isString(d)||(d=d?"include":"omit");let _="credentials"in Request.prototype;g=new Request(t,{...m,signal:p,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:_?d:void 0});let S=await fetch(g),k=fd&&(l==="stream"||l==="response");if(fd&&(a||k&&f)){let x={};["status","statusText","headers"].forEach(Z=>{x[Z]=S[Z]});let O=T.toFiniteNumber(S.headers.get("content-length")),[P,z]=a&&cd(O,zi(ld(a),!0))||[];S=new Response(ud(S.body,Fg,P,()=>{z&&z(),f&&f()}),x)}l=l||"text";let I=await xa[T.findKey(xa,l)||"text"](S,e);return!k&&f&&f(),await new Promise((x,O)=>{Uo(x,O,{data:I,headers:at.from(S.headers),status:S.status,statusText:S.statusText,config:e,request:g})})}catch(_){throw f&&f(),_&&_.name==="TypeError"&&/fetch/i.test(_.message)?Object.assign(new le("Network Error",le.ERR_NETWORK,e,g),{cause:_.cause||_}):le.from(_,_&&_.code,e,g)}});var pd={http:_a,xhr:Bg,fetch:Ng};T.forEach(pd,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var zg=e=>`- ${e}`,d_=e=>T.isFunction(e)||e===null||e===!1,Ta={getAdapter:e=>{e=T.isArray(e)?e:[e];let{length:t}=e,r,n,i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!d_(r)&&(n=pd[(s=String(r)).toLowerCase()],n===void 0))throw new le(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){let o=Object.entries(i).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build")),s=t?o.length>1?`since :
|
|
69
69
|
`+o.map(zg).join(`
|
|
70
70
|
`):" "+zg(o[0]):"as no adapter specified";throw new le("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:pd};function md(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Br(null,e)}function Ia(e){return md(e),e.headers=at.from(e.headers),e.data=Fo.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ta.getAdapter(e.adapter||Ui.adapter)(e).then(function(n){return md(e),n.data=Fo.call(e,e.transformResponse,n),n.headers=at.from(n.headers),n},function(n){return Mo(n)||(md(e),n&&n.response&&(n.response.data=Fo.call(e,e.transformResponse,n.response),n.response.headers=at.from(n.response.headers))),Promise.reject(n)})}var Ra="1.8.4";var Pa={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Pa[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var jg={};Pa.transitional=function(t,r,n){function i(o,s){return"[Axios v"+Ra+"] Transitional option '"+o+"'"+s+(n?". "+n:"")}return(o,s,a)=>{if(t===!1)throw new le(i(s," has been removed"+(r?" in "+r:"")),le.ERR_DEPRECATED);return r&&!jg[s]&&(jg[s]=!0,console.warn(i(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(o,s,a):!0}};Pa.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function u_(e,t,r){if(typeof e!="object")throw new le("options must be an object",le.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),i=n.length;for(;i-- >0;){let o=n[i],s=t[o];if(s){let a=e[o],c=a===void 0||s(a,o,e);if(c!==!0)throw new le("option "+o+" must be "+c,le.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new le("Unknown option "+o,le.ERR_BAD_OPTION)}}var zo={assertOptions:u_,validators:Pa};var Lr=zo.validators,ji=class{constructor(t){this.defaults=t,this.interceptors={request:new ed,response:new ed}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;let o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
71
|
-
`+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=br(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&zo.assertOptions(n,{silentJSONParsing:Lr.transitional(Lr.boolean),forcedJSONParsing:Lr.transitional(Lr.boolean),clarifyTimeoutError:Lr.transitional(Lr.boolean)},!1),i!=null&&(T.isFunction(i)?r.paramsSerializer={serialize:i}:zo.assertOptions(i,{encode:Lr.function,serialize:Lr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),zo.assertOptions(r,{baseUrl:Lr.spelling("baseURL"),withXsrfToken:Lr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&T.merge(o.common,o[r.method]);o&&T.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),r.headers=at.concat(s,o);let a=[],c=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(c=c&&f.synchronous,a.unshift(f.fulfilled,f.rejected))});let l=[];this.interceptors.response.forEach(function(f){l.push(f.fulfilled,f.rejected)});let h,d=0,m;if(!c){let g=[Ia.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,l),m=g.length,h=Promise.resolve(r);d<m;)h=h.then(g[d++],g[d++]);return h}m=a.length;let p=r;for(d=0;d<m;){let g=a[d++],f=a[d++];try{p=g(p)}catch(b){f.call(this,b);break}}try{h=Ia.call(this,p)}catch(g){return Promise.reject(g)}for(d=0,m=l.length;d<m;)h=h.then(l[d++],l[d++]);return h}getUri(t){t=br(this.defaults,t);let r=No(t.baseURL,t.url,t.allowAbsoluteUrls);return Bo(r,t.params,t.paramsSerializer)}};T.forEach(["delete","get","head","options"],function(t){ji.prototype[t]=function(r,n){return this.request(br(n||{},{method:t,url:r,data:(n||{}).data}))}});T.forEach(["post","put","patch"],function(t){function r(n){return function(o,s,a){return this.request(br(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}ji.prototype[t]=r(),ji.prototype[t+"Form"]=r(!0)});var jo=ji;var gd=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(o,s,a){n.reason||(n.reason=new Br(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(i){t=i}),cancel:t}}},Vg=gd;function yd(e){return function(r){return e.apply(null,r)}}function bd(e){return T.isObject(e)&&e.isAxiosError===!0}var vd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(vd).forEach(([e,t])=>{vd[t]=e});var Hg=vd;function Wg(e){let t=new jo(e),r=Po(jo.prototype.request,t);return T.extend(r,jo.prototype,t,{allOwnKeys:!0}),T.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return Wg(br(e,i))},r}var rt=Wg(Ui);rt.Axios=jo;rt.CanceledError=Br;rt.CancelToken=Vg;rt.isCancel=Mo;rt.VERSION=Ra;rt.toFormData=mn;rt.AxiosError=le;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=yd;rt.isAxiosError=bd;rt.mergeConfig=br;rt.AxiosHeaders=at;rt.formToJSON=e=>ka(T.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=Ta.getAdapter;rt.HttpStatusCode=Hg;rt.default=rt;var vr=rt;var{Axios:kC,AxiosError:EC,CanceledError:CC,isCancel:xC,CancelToken:AC,VERSION:TC,all:IC,Cancel:RC,isAxiosError:PC,spread:DC,toFormData:OC,AxiosHeaders:BC,HttpStatusCode:LC,formToJSON:FC,getAdapter:MC,mergeConfig:UC}=vr;var f_="https://proctoring-api-dev.easyproctor.tech/api",p_="https://proctoring-api-hml.easyproctor.tech/api",$g="https://proctoring-api.easyproctor.tech/api",nr=class{constructor(t){this.options=t;this.baseUrl=this.selectBaseUrl(t.type),this.token=t.token}selectBaseUrl(t){return t==="dev"?f_:t==="homol"?p_:$g}getSocketUrl(){return this.baseUrl.replace("/api","/hub/sockethub")}async loginAuth(t,r){return await this.makeRequest({path:"/Auth",method:"POST",body:{emailOrCpf:t,key:r}})}async externalCameraRegister(t){return await this.makeRequest({path:"/ExternalCamera/register",method:"POST",body:t,jwt:this.token})}async externalCameraCheckTransmission(t){return await this.makeRequest({path:`/ExternalCamera/send-action/${t}`,method:"POST",body:{command:"Check_Transmission"},jwt:this.token})}async externalCameraStartTransmission(t,r){return await this.makeRequest({path:`/ExternalCamera/start-transmission/${t}`,method:"POST",body:{proctoringId:r},jwt:this.token})}async externalCameraStartSession(){return await this.makeRequest({path:"/ExternalCamera/start-session",method:"POST",body:{},jwt:this.token})}async goToExternalCameraPositionStep(t){return await this.makeRequest({path:`/ExternalCamera/go-to-position-step/${t}`,method:"POST",body:{},jwt:this.token})}async externalCameraFinish(t){return await this.makeRequest({path:`/ExternalCamera/finish/${t}`,method:"POST",body:{},jwt:this.token})}async confirmStart(t,r,n,i){return await this.makeRequest({path:`/proctoring/start/${t.examId}`,method:"POST",body:{clientId:t.clientId,proctoringType:r.proctoringType,latitude:n,longitude:i,captureScreen:r.captureScreen},jwt:t.token})}async getParamsConfig(t){return(await this.makeRequestAxios({path:"/Client/params",method:"GET",jwt:t.token}).catch(n=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async getSignedUrlImage(t,r){return(await this.makeRequestAxios({path:"/upload/signed-url-batch",method:"POST",jwt:t,body:r})).data}async getSignedUrl(t,r,n){return(await this.makeRequestAxios({path:"/upload/signed-url",method:"POST",jwt:t,body:{objectName:`${n}/${r.name}`,contentType:r.type}})).data}async saveAlerts(t,r){await this.makeRequest({path:"/proctoring/save-alerts",method:"POST",jwt:t.token,body:{proctoringId:r.id,alerts:r.alerts}})}async finishAndSendUrls(t){return await this.makeRequest({path:`/proctoring/finish/${t.examId}`,method:"POST",body:{endDate:new Date().toISOString(),videoCameraUrl:"",audioCameraUrl:"",videoScreenUrl:""},jwt:t.token})}async log(t,r){let n;return r?.success!==null&&r?.success!==void 0?n=r.success?"4":"1":n="4",await this.makeRequest({path:"/Log",method:"POST",body:{entryType:n,eventName:t,message:r},jwt:this.token})}async signTerm(){return await this.makeRequest({path:"/User/sign-terms",method:"PATCH",body:{},jwt:this.token})}async signTermUrl(){return(await this.makeRequestAxios({path:"/User/sign-terms-url",method:"GET",jwt:this.token})).data}async startChallenge(t){return(await this.makeRequestAxios({path:"/Challenge/start",method:"POST",jwt:this.token,body:t})).data}async stopChallenge(t,r){return(await this.makeRequestAxios({path:`/Challenge/stop/${t}`,method:"POST",jwt:this.token,body:r})).data}async startRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/start-warning",method:"POST",jwt:this.token,body:t})).data}async stopRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/stop-warning",method:"POST",jwt:this.token,body:t})).data}async verifyFace(t,r,n){return(await this.makeRequestAxios({path:"/Realtime/verify-face",method:"POST",jwt:this.token,body:{proctoringId:t,base64:r,retry:n}})).data}async getServerHour(t){return await this.makeRequest({path:"/Proctoring/server-hour",method:"GET",jwt:t})}async makeRequest(t){let{path:r,method:n,body:i,jwt:o}=t,s=await fetch(this.baseUrl+r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}async makeRequestPUT(t){let{url:r,method:n,body:i,jwt:o}=t,s=await fetch(r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Accept:"*/*","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","aeg-event-type":"Notification","Content-Type":"application/json","Cache-Control":"no-cache","x-ms-blob-type":"BlockBlob"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}};var Da=class{constructor(){this.baseUrl="https://localhost:5080"}async isAlive(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-alive",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async isPluggedIn(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-plugged-in",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async ConnectAndScan(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/connect-and-scan",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=[];return t&&i.push(`deviceType=${t}`),r&&i.push(`rssiThreshold=${r}`),n&&i.push(`packageRateThreshold=${n}`),(await this.makeRequestAxios({path:`/api/usb-device-manager/devices?${i.join("&")}`,method:"GET",jwt:this.token}).catch(s=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}};var Hn=class{constructor(){this.sessionDuration=0;this.state="Created",this.startedAt=new Date,this.alerts=[],this.recordings=[]}get hasSomethingToUpload(){for(let t of this.recordings)if(!t.upload)return!0;return!1}start(){this.state="Recording",this.startedAt=new Date(Date.now())}pause(){this.state="Paused"}resume(){this.state="Recording"}stop(){this.state="Ended",this.sessionDuration=Date.now()-this.startedAt.getTime()}setProctoringId(t){this.id=t}setEndConfirmed(){this.state="EndConfirmed"}setUploaded(){this.state="Uploaded"}setUploadConfirmed(){this.state="UploadConfirmed"}addAlert(t){this.alerts.push(t)}addRecording(t){this.recordings.push(t)}};var Vi=class{constructor(t,r){this.backendService=new Da;this.scanInterval=5;this.options={};this.options=r,this.context=t,this.backend=new nr({type:t?.type||"prod",token:t.token}),this.currentIsPlugged=!0}setProctoringId(t){this.proctoringId=t}async isPluggedIn(t=!1){try{let r=await this.backendService.isPluggedIn();if(this.proctoringId&&t)if(r)this.currentIsPlugged||this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Dispositivo de varredura conectado.",status:"OK"});else{let n=new Hn;n.setProctoringId(this.proctoringId),n.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:33,type:5}),await this.backend.saveAlerts(this.context,n),this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Nenhum dispositivo de varredura conectado.",status:"ALERT"})}return this.currentIsPlugged=r,this.currentIsPlugged}catch(r){throw r}}async isAlive(){try{return await this.backendService.isAlive()}catch(t){throw t}}connectAndScan(){return this.backendService.ConnectAndScan()}async devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=await this.backendService.Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n});if(i.length>0&&(this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam detected",description:"Dispositivo espi\xE3o detectado.",data:i}),this.proctoringId)){let o=new Hn;o.setProctoringId(this.proctoringId),o.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:32,type:5}),await this.backend.saveAlerts(this.context,o)}return i}async startCheckSpyCam(t,{deviceType:r,rssiThreshold:n,packageRateThreshold:i}){this.scanInterval=t,this.startTime=new Date(Date.now()),await this.isPluggedIn(!0),this.checkSpyCam=setInterval(async()=>{await this.isPluggedIn(!0)&&await this.devices({deviceType:r,rssiThreshold:n,packageRateThreshold:i})},this.scanInterval*6e4)}stopCheckSpyCam(){clearInterval(this.checkSpyCam)}};var ir={cameraId:void 0,microphoneId:void 0,allowMultipleMonitors:!1,allowOnlyFirstMonitor:!0,captureScreen:!0,noiseLimit:40,proctoringType:"IMAGE",insights:"",onBufferSizeError:!1,useGeolocation:!1,useSpyScan:!1,useExternalCamera:!1,useChallenge:!1,screenRecorderOptions:{width:1280,height:720}};function Oa(e){return e.width&&e.height?{width:e.width,height:e.height,minWidth:e.minWidth,minHeight:e.minHeight,timeSlice:e.timeSlice,videoBitsPerSecond:e.videoBitsPerSecond,mimeType:e.mimeType}:{width:640,height:480}}var Gg={width:1280,height:720,minWidth:640,minHeight:480};function qg(){let e=navigator.userAgent,t;return e.match(/chrome|chromium|crios/i)?t="chrome":e.match(/firefox|fxios/i)?t="firefox":e.match(/safari/i)?t="safari":e.match(/opr\//i)?t="opera":e.match(/edg/i)?t="edge":t="No browser detection",t}function Fr(){if("userAgentData"in navigator){let e=navigator.userAgentData,t=e.mobile||!1,r=e.platform||"";return t||/Android|iOS/i.test(r)}return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)}var Ba,Kg=e=>(Ba=e,Ba),Pt={DEVICES_CHECKED:"devices_checked",START:"start",FINISH:"finish",ERROR:"error",UPLOAD:"upload",UPLOAD_FILE:"upload_file",DOWNLOAD_VIDEO:"download_video",BUFFER_SIZE:"buffer_size",ANOTHER_STREAM:"another_stream",CHANGE_DEVICE:"change_device",STOP_SHARING_SCREEN:"stop_sharing_screen",ERROR_RECORDER_RTC:"error_recorder_rtc",BROWSER_NOT_SUPPORTED:"browser_not_supported",SAVE_ON_SESSION:"save_on_session"},Dt=(e,t)=>Ba&&Ba.log(e,t),ue={registerDevicesChecked:(e,t,r)=>Dt(Pt.DEVICES_CHECKED,{proctoringId:e,success:t,description:r}),registerStart:(e,t,r)=>Dt(Pt.START,{proctoringId:e,success:t,description:r}),registerFinish:(e,t,r)=>Dt(Pt.FINISH,{proctoringId:e,success:t,description:r}),registerError:(e,t)=>Dt(Pt.ERROR,{proctoringId:e,description:t}),registerBrowserNotSupported:(e,t)=>Dt(Pt.BROWSER_NOT_SUPPORTED,{proctoringId:e,description:t}),registerUpload:(e,t,r,n,i)=>Dt(Pt.UPLOAD,{proctoringId:e,success:t,description:r,serviceType:n,uploadTime:i}),registerUploadFile:(e,t,r)=>Dt(Pt.UPLOAD_FILE,{proctoringId:e,description:t,fileType:r}),registerChangeDevice:(e,t,r)=>Dt(Pt.CHANGE_DEVICE,{proctoringId:e,inOrOut:t,description:r}),registerStopSharingScreen:(e,t)=>Dt(Pt.STOP_SHARING_SCREEN,{proctoringId:e,description:t}),registerErrorRecorderRTC:(e,t)=>Dt(Pt.ERROR_RECORDER_RTC,{proctoringId:e,description:t}),registerDownloadFile:(e,t)=>Dt(Pt.DOWNLOAD_VIDEO,{proctoringId:e,description:t}),registerOnBufferSizeError:(e,t)=>Dt(Pt.BUFFER_SIZE,{proctoringId:e,description:t}),registerAnotherStream:(e,t)=>Dt(Pt.ANOTHER_STREAM,{proctoringId:e,description:t}),registerSaveOnSession:(e,t)=>Dt(Pt.SAVE_ON_SESSION,{proctoringId:e,description:t})};var Vo;function La(e){Vo=e}function Wn(e,t,r,n=!1,i,o=!1){let s,a=!1,c,l,h;h=0;let d={mimeType:"video/webm",videoBitsPerSecond:128e3,audioBitsPerSecond:64*1e3};MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?d.mimeType="video/webm;codecs=vp9":console.warn("vp9 codec not supported. Using default mimeType without vp9."),r?.mimeType&&(d.mimeType=r?.mimeType),r?.videoBitsPerSecond!=null&&(d.videoBitsPerSecond=r?.videoBitsPerSecond),o&&(d={mimeType:"audio/webm",audioBitsPerSecond:64*1e3}),console.log("recorderOptions bitsPerSecond",d.videoBitsPerSecond);let m=new MediaRecorder(e,d);m.ondataavailable=S=>{if(h=h+S.data.size,console.log("video tracks length > 0",e.getVideoTracks().length>0),e.getVideoTracks().length>0){let k=e.getVideoTracks()[0];console.log(k.readyState),console.log(k.enabled)}S.data.size>0&&t.push(S.data),a?(o&&m.state=="inactive"&&(t=[new Blob(t,{type:"audio/webm"})]),s&&s()):((l&&S.data.size===l.data.size||S.data.size===0)&&(Vo&&l&&S.data.size===l.data.size&&ue.registerOnBufferSizeError(Vo,`onBufferSizeError: Recorder size freezed: ${S.data.size} Mb`),Vo&&S.data.size===0&&ue.registerOnBufferSizeError(Vo,"onBufferSizeError: Recorder size equal 0 Mb"),console.log("onbuffer size error"+S.data.size),i&&i()),l=S)};function p(){return new Promise(S=>{s=S;var k=1e4;r?.timeSlice!=null&&(k=r?.timeSlice),console.log("startRecording",k);try{m.start(k),m.onstart=()=>{console.log("Grava\xE7\xE3o iniciada com sucesso!")}}catch(I){console.error("Falha ao iniciar:",I)}h=0,a=!1})}function g(){return new Promise(S=>{m.state=="recording"?(s=S,m.stop(),a=!0,e.getTracks().forEach(k=>{k.stop()})):S()})}function f(){return new Promise(S=>{m.state=="recording"&&m.pause(),S()})}function b(){return new Promise(S=>{m.state=="paused"&&m.resume(),S()})}function _(){return h}return{startRecording:p,stopRecording:g,pauseRecording:f,resumeRecording:b,recorderOptions:d,getBufferSize:_}}var Yr=class{constructor(t,r){this.backend=r;this.imageUrlPackage=[];this.imageBatchNum=0;this.contImages=0;this.proctoringId=t}async uploadPackage(t,r){let{file:n,onProgress:i}=t;try{let o=c=>{let l=c.loadedBytes/n.size*100;i&&i(Math.round(l))},s=await this.backend.getSignedUrl(r,n,this.proctoringId),a=await vr.request({url:s,method:"PUT",headers:{"Content-Type":n.type,"x-ms-blob-type":"BlockBlob"},data:n,onUploadProgress:c=>{o({loadedBytes:c.loaded})}}).then(()=>!0).catch(()=>!1);return{storage:"upload",url:s,uploaded:a}}catch{throw ue.registerError(this.proctoringId,`Failed to upload to AWS
|
|
71
|
+
`+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=br(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&zo.assertOptions(n,{silentJSONParsing:Lr.transitional(Lr.boolean),forcedJSONParsing:Lr.transitional(Lr.boolean),clarifyTimeoutError:Lr.transitional(Lr.boolean)},!1),i!=null&&(T.isFunction(i)?r.paramsSerializer={serialize:i}:zo.assertOptions(i,{encode:Lr.function,serialize:Lr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),zo.assertOptions(r,{baseUrl:Lr.spelling("baseURL"),withXsrfToken:Lr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&T.merge(o.common,o[r.method]);o&&T.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),r.headers=at.concat(s,o);let a=[],c=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(c=c&&f.synchronous,a.unshift(f.fulfilled,f.rejected))});let l=[];this.interceptors.response.forEach(function(f){l.push(f.fulfilled,f.rejected)});let h,d=0,m;if(!c){let g=[Ia.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,l),m=g.length,h=Promise.resolve(r);d<m;)h=h.then(g[d++],g[d++]);return h}m=a.length;let p=r;for(d=0;d<m;){let g=a[d++],f=a[d++];try{p=g(p)}catch(b){f.call(this,b);break}}try{h=Ia.call(this,p)}catch(g){return Promise.reject(g)}for(d=0,m=l.length;d<m;)h=h.then(l[d++],l[d++]);return h}getUri(t){t=br(this.defaults,t);let r=No(t.baseURL,t.url,t.allowAbsoluteUrls);return Bo(r,t.params,t.paramsSerializer)}};T.forEach(["delete","get","head","options"],function(t){ji.prototype[t]=function(r,n){return this.request(br(n||{},{method:t,url:r,data:(n||{}).data}))}});T.forEach(["post","put","patch"],function(t){function r(n){return function(o,s,a){return this.request(br(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}ji.prototype[t]=r(),ji.prototype[t+"Form"]=r(!0)});var jo=ji;var gd=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(o,s,a){n.reason||(n.reason=new Br(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(i){t=i}),cancel:t}}},Vg=gd;function yd(e){return function(r){return e.apply(null,r)}}function bd(e){return T.isObject(e)&&e.isAxiosError===!0}var vd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(vd).forEach(([e,t])=>{vd[t]=e});var Hg=vd;function Wg(e){let t=new jo(e),r=Po(jo.prototype.request,t);return T.extend(r,jo.prototype,t,{allOwnKeys:!0}),T.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return Wg(br(e,i))},r}var rt=Wg(Ui);rt.Axios=jo;rt.CanceledError=Br;rt.CancelToken=Vg;rt.isCancel=Mo;rt.VERSION=Ra;rt.toFormData=mn;rt.AxiosError=le;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=yd;rt.isAxiosError=bd;rt.mergeConfig=br;rt.AxiosHeaders=at;rt.formToJSON=e=>ka(T.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=Ta.getAdapter;rt.HttpStatusCode=Hg;rt.default=rt;var vr=rt;var{Axios:kC,AxiosError:EC,CanceledError:CC,isCancel:xC,CancelToken:AC,VERSION:TC,all:IC,Cancel:RC,isAxiosError:PC,spread:DC,toFormData:OC,AxiosHeaders:BC,HttpStatusCode:LC,formToJSON:FC,getAdapter:MC,mergeConfig:UC}=vr;var f_="https://proctoring-api-dev.easyproctor.tech/api",p_="https://proctoring-api-hml.easyproctor.tech/api",$g="https://proctoring-api.easyproctor.tech/api",nr=class{constructor(t){this.options=t;this.baseUrl=this.selectBaseUrl(t.type),this.token=t.token}selectBaseUrl(t){return t==="dev"?f_:t==="homol"?p_:$g}getSocketUrl(){return this.baseUrl.replace("/api","/hub/sockethub")}async loginAuth(t,r){return await this.makeRequest({path:"/Auth",method:"POST",body:{emailOrCpf:t,key:r}})}async externalCameraRegister(t){return await this.makeRequest({path:"/ExternalCamera/register",method:"POST",body:t,jwt:this.token})}async externalCameraCheckTransmission(t){return await this.makeRequest({path:`/ExternalCamera/send-action/${t}`,method:"POST",body:{command:"Check_Transmission"},jwt:this.token})}async externalCameraStartTransmission(t,r){return await this.makeRequest({path:`/ExternalCamera/start-transmission/${t}`,method:"POST",body:{proctoringId:r},jwt:this.token})}async externalCameraStartSession(){return await this.makeRequest({path:"/ExternalCamera/start-session",method:"POST",body:{},jwt:this.token})}async goToExternalCameraPositionStep(t){return await this.makeRequest({path:`/ExternalCamera/go-to-position-step/${t}`,method:"POST",body:{},jwt:this.token})}async externalCameraFinish(t){return await this.makeRequest({path:`/ExternalCamera/finish/${t}`,method:"POST",body:{},jwt:this.token})}async confirmStart(t,r,n,i){return await this.makeRequest({path:`/proctoring/start/${t.examId}`,method:"POST",body:{clientId:t.clientId,proctoringType:r.proctoringType,latitude:n,longitude:i,captureScreen:r.captureScreen},jwt:t.token})}async getParamsConfig(t){return(await this.makeRequestAxios({path:"/Client/params",method:"GET",jwt:t.token}).catch(n=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async getSignedUrlImage(t,r){return(await this.makeRequestAxios({path:"/upload/signed-url-batch",method:"POST",jwt:t,body:r})).data}async getSignedUrl(t,r,n){return(await this.makeRequestAxios({path:"/upload/signed-url",method:"POST",jwt:t,body:{objectName:`${n}/${r.name}`,contentType:r.type}})).data}async saveAlerts(t,r){await this.makeRequest({path:"/proctoring/save-alerts",method:"POST",jwt:t.token,body:{proctoringId:r.id,alerts:r.alerts}})}async finishAndSendUrls(t){return await this.makeRequest({path:`/proctoring/finish/${t.examId}`,method:"POST",body:{endDate:new Date().toISOString(),videoCameraUrl:"",audioCameraUrl:"",videoScreenUrl:""},jwt:t.token})}async log(t,r){let n;return r?.success!==null&&r?.success!==void 0?n=r.success?"4":"1":n="4",await this.makeRequest({path:"/Log",method:"POST",body:{entryType:n,eventName:t,message:r},jwt:this.token})}async signTerm(){return await this.makeRequest({path:"/User/sign-terms",method:"PATCH",body:{},jwt:this.token})}async signTermUrl(){return(await this.makeRequestAxios({path:"/User/sign-terms-url",method:"GET",jwt:this.token})).data}async startChallenge(t){return(await this.makeRequestAxios({path:"/Challenge/start",method:"POST",jwt:this.token,body:t})).data}async stopChallenge(t,r){return(await this.makeRequestAxios({path:`/Challenge/stop/${t}`,method:"POST",jwt:this.token,body:r})).data}async startRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/start-warning",method:"POST",jwt:this.token,body:t})).data}async stopRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/stop-warning",method:"POST",jwt:this.token,body:t})).data}async verifyFace(t,r,n){return(await this.makeRequestAxios({path:"/Realtime/verify-face",method:"POST",jwt:this.token,body:{proctoringId:t,base64:r,retry:n}})).data}async getServerHour(t){return await this.makeRequest({path:"/Proctoring/server-hour",method:"GET",jwt:t})}async makeRequest(t){let{path:r,method:n,body:i,jwt:o}=t,s=await fetch(this.baseUrl+r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}async makeRequestPUT(t){let{url:r,method:n,body:i,jwt:o}=t,s=await fetch(r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Accept:"*/*","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","aeg-event-type":"Notification","Content-Type":"application/json","Cache-Control":"no-cache","x-ms-blob-type":"BlockBlob"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}};var Da=class{constructor(){this.baseUrl="https://localhost:5080"}async isAlive(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-alive",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async isPluggedIn(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-plugged-in",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async ConnectAndScan(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/connect-and-scan",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=[];return t&&i.push(`deviceType=${t}`),r&&i.push(`rssiThreshold=${r}`),n&&i.push(`packageRateThreshold=${n}`),(await this.makeRequestAxios({path:`/api/usb-device-manager/devices?${i.join("&")}`,method:"GET",jwt:this.token}).catch(s=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}};var Hn=class{constructor(){this.sessionDuration=0;this.state="Created",this.startedAt=new Date,this.alerts=[],this.recordings=[]}get hasSomethingToUpload(){for(let t of this.recordings)if(!t.upload)return!0;return!1}start(){this.state="Recording",this.startedAt=new Date(Date.now())}pause(){this.state="Paused"}resume(){this.state="Recording"}stop(){this.state="Ended",this.sessionDuration=Date.now()-this.startedAt.getTime()}setProctoringId(t){this.id=t}setEndConfirmed(){this.state="EndConfirmed"}setUploaded(){this.state="Uploaded"}setUploadConfirmed(){this.state="UploadConfirmed"}addAlert(t){this.alerts.push(t)}addRecording(t){this.recordings.push(t)}};var Vi=class{constructor(t,r){this.backendService=new Da;this.scanInterval=5;this.options={};this.options=r,this.context=t,this.backend=new nr({type:t?.type||"prod",token:t.token}),this.currentIsPlugged=!0}setProctoringId(t){this.proctoringId=t}async isPluggedIn(t=!1){try{let r=await this.backendService.isPluggedIn();if(this.proctoringId&&t)if(r)this.currentIsPlugged||this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Dispositivo de varredura conectado.",status:"OK"});else{let n=new Hn;n.setProctoringId(this.proctoringId),n.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:33,type:5}),await this.backend.saveAlerts(this.context,n),this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Nenhum dispositivo de varredura conectado.",status:"ALERT"})}return this.currentIsPlugged=r,this.currentIsPlugged}catch(r){throw r}}async isAlive(){try{return await this.backendService.isAlive()}catch(t){throw t}}connectAndScan(){return this.backendService.ConnectAndScan()}async devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=await this.backendService.Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n});if(i.length>0&&(this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam detected",description:"Dispositivo espi\xE3o detectado.",data:i}),this.proctoringId)){let o=new Hn;o.setProctoringId(this.proctoringId),o.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:32,type:5}),await this.backend.saveAlerts(this.context,o)}return i}async startCheckSpyCam(t,{deviceType:r,rssiThreshold:n,packageRateThreshold:i}){this.scanInterval=t,this.startTime=new Date(Date.now()),await this.isPluggedIn(!0),this.checkSpyCam=setInterval(async()=>{await this.isPluggedIn(!0)&&await this.devices({deviceType:r,rssiThreshold:n,packageRateThreshold:i})},this.scanInterval*6e4)}stopCheckSpyCam(){clearInterval(this.checkSpyCam)}};var ir={cameraId:void 0,microphoneId:void 0,allowMultipleMonitors:!1,allowOnlyFirstMonitor:!0,captureScreen:!0,noiseLimit:40,proctoringType:"IMAGE",insights:"",onBufferSizeError:!1,useGeolocation:!1,useSpyScan:!1,useExternalCamera:!1,useChallenge:!1,screenRecorderOptions:{width:1280,height:720}};function Oa(e){return e.width&&e.height?{width:e.width,height:e.height,minWidth:e.minWidth,minHeight:e.minHeight,timeSlice:e.timeSlice,videoBitsPerSecond:e.videoBitsPerSecond,mimeType:e.mimeType}:{width:640,height:480}}var Gg={width:1280,height:720,minWidth:640,minHeight:480};function qg(){let e=navigator.userAgent,t;return e.match(/chrome|chromium|crios/i)?t="chrome":e.match(/firefox|fxios/i)?t="firefox":e.match(/safari/i)?t="safari":e.match(/opr\//i)?t="opera":e.match(/edg/i)?t="edge":t="No browser detection",t}function Fr(){if("userAgentData"in navigator){let e=navigator.userAgentData,t=e.mobile||!1,r=e.platform||"";return t||/Android|iOS/i.test(r)}return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)}var Ba,Kg=e=>(Ba=e,Ba),Pt={DEVICES_CHECKED:"devices_checked",START:"start",FINISH:"finish",ERROR:"error",UPLOAD:"upload",UPLOAD_FILE:"upload_file",DOWNLOAD_VIDEO:"download_video",BUFFER_SIZE:"buffer_size",ANOTHER_STREAM:"another_stream",CHANGE_DEVICE:"change_device",STOP_SHARING_SCREEN:"stop_sharing_screen",ERROR_RECORDER_RTC:"error_recorder_rtc",BROWSER_NOT_SUPPORTED:"browser_not_supported",SAVE_ON_SESSION:"save_on_session"},Dt=(e,t)=>Ba&&Ba.log(e,t),ue={registerDevicesChecked:(e,t,r)=>Dt(Pt.DEVICES_CHECKED,{proctoringId:e,success:t,description:r}),registerStart:(e,t,r)=>Dt(Pt.START,{proctoringId:e,success:t,description:r}),registerFinish:(e,t,r)=>Dt(Pt.FINISH,{proctoringId:e,success:t,description:r}),registerError:(e,t)=>Dt(Pt.ERROR,{proctoringId:e,description:t}),registerBrowserNotSupported:(e,t)=>Dt(Pt.BROWSER_NOT_SUPPORTED,{proctoringId:e,description:t}),registerUpload:(e,t,r,n,i)=>Dt(Pt.UPLOAD,{proctoringId:e,success:t,description:r,serviceType:n,uploadTime:i}),registerUploadFile:(e,t,r)=>Dt(Pt.UPLOAD_FILE,{proctoringId:e,description:t,fileType:r}),registerChangeDevice:(e,t,r)=>Dt(Pt.CHANGE_DEVICE,{proctoringId:e,inOrOut:t,description:r}),registerStopSharingScreen:(e,t)=>Dt(Pt.STOP_SHARING_SCREEN,{proctoringId:e,description:t}),registerErrorRecorderRTC:(e,t)=>Dt(Pt.ERROR_RECORDER_RTC,{proctoringId:e,description:t}),registerDownloadFile:(e,t)=>Dt(Pt.DOWNLOAD_VIDEO,{proctoringId:e,description:t}),registerOnBufferSizeError:(e,t)=>Dt(Pt.BUFFER_SIZE,{proctoringId:e,description:t}),registerAnotherStream:(e,t)=>Dt(Pt.ANOTHER_STREAM,{proctoringId:e,description:t}),registerSaveOnSession:(e,t)=>Dt(Pt.SAVE_ON_SESSION,{proctoringId:e,description:t})};var Vo;function La(e){Vo=e}function Wn(e,t,r,n=!1,i,o=!1){let s,a=!1,c,l,h;h=0;let d={mimeType:"video/webm",videoBitsPerSecond:128e3,audioBitsPerSecond:64*1e3};MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?d.mimeType="video/webm;codecs=vp9":console.warn("vp9 codec not supported. Using default mimeType without vp9."),r?.mimeType&&(d.mimeType=r?.mimeType),r?.videoBitsPerSecond!=null&&(d.videoBitsPerSecond=r?.videoBitsPerSecond),o&&(d={mimeType:"audio/webm",audioBitsPerSecond:64*1e3}),console.log("recorderOptions bitsPerSecond",d.videoBitsPerSecond);let m=new MediaRecorder(e,d);m.ondataavailable=S=>{if(h=h+S.data.size,console.log("video tracks length > 0",e.getVideoTracks().length>0),e.getVideoTracks().length>0){let k=e.getVideoTracks()[0];console.log(k.readyState),console.log(k.enabled)}S.data.size>0&&t.push(S.data),a?(o&&m.state=="inactive"&&(t=[new Blob(t,{type:"audio/webm"})]),s&&s()):((l&&S.data.size===l.data.size||S.data.size===0)&&(Vo&&l&&S.data.size===l.data.size&&ue.registerOnBufferSizeError(Vo,`onBufferSizeError: Recorder size freezed: ${S.data.size} Mb`),Vo&&S.data.size===0&&ue.registerOnBufferSizeError(Vo,"onBufferSizeError: Recorder size equal 0 Mb"),console.log("onbuffer size error"+S.data.size),i&&i()),l=S)};function p(){return new Promise(S=>{s=S;var k=1e4;r?.timeSlice!=null&&(k=r?.timeSlice),console.log("startRecording",k);try{m.onstart=()=>{console.log("Grava\xE7\xE3o iniciada com sucesso!")},m.onerror=I=>{console.error("Erro no MediaRecorder:",I)},console.log("mediaRecorder.state",m.state),console.log(e.active),console.log(e.getTracks().map(I=>I.readyState)),m.start(k)}catch(I){console.error("Falha ao iniciar:",I)}h=0,a=!1})}function g(){return new Promise(S=>{m.state=="recording"?(s=S,m.stop(),a=!0,e.getTracks().forEach(k=>{k.stop()})):S()})}function f(){return new Promise(S=>{m.state=="recording"&&m.pause(),S()})}function b(){return new Promise(S=>{m.state=="paused"&&m.resume(),S()})}function _(){return h}return{startRecording:p,stopRecording:g,pauseRecording:f,resumeRecording:b,recorderOptions:d,getBufferSize:_}}var Yr=class{constructor(t,r){this.backend=r;this.imageUrlPackage=[];this.imageBatchNum=0;this.contImages=0;this.proctoringId=t}async uploadPackage(t,r){let{file:n,onProgress:i}=t;try{let o=c=>{let l=c.loadedBytes/n.size*100;i&&i(Math.round(l))},s=await this.backend.getSignedUrl(r,n,this.proctoringId),a=await vr.request({url:s,method:"PUT",headers:{"Content-Type":n.type,"x-ms-blob-type":"BlockBlob"},data:n,onUploadProgress:c=>{o({loadedBytes:c.loaded})}}).then(()=>!0).catch(()=>!1);return{storage:"upload",url:s,uploaded:a}}catch{throw ue.registerError(this.proctoringId,`Failed to upload to AWS
|
|
72
72
|
File name: ${n.name}
|
|
73
73
|
File type: ${n.type}
|
|
74
74
|
File size: ${n.size}`),new Error("Failed to upload to AWS")}}async uploadImages(t,r,n){let{file:i,onProgress:o}=t;try{let s=l=>{let h=l.loadedBytes/i.size*100;o&&o(Math.round(h))},a;if(this.imageBatchNum===this.contImages){let l=[];for(let d=this.imageBatchNum;d<this.imageBatchNum+60;d++){let m=`${this.proctoringId}/${this.proctoringId}_${d+1}.jpg`;(d+1)%n==0&&(m=`${this.proctoringId}/${this.proctoringId}_${d+1}_realtime.jpg`),l.push({objectName:m,contentType:"image/jpeg"})}(await this.backend.getSignedUrlImage(r,l)).map(d=>{this.imageUrlPackage.push(d)}),this.imageBatchNum+=60}let c=!1;return c=await vr.request({url:this.imageUrlPackage[this.contImages],method:"PUT",headers:{"Content-Type":i.type,"x-ms-blob-type":"BlockBlob"},data:i,onUploadProgress:l=>{s({loadedBytes:l.loaded})}}).then(l=>l.status==200||l.status==201?(this.contImages++,!0):!1).catch(()=>!1).finally(()=>{}),{storage:"upload",url:a,uploaded:c}}catch{throw ue.registerError(this.proctoringId,`Failed to upload to AWS
|
|
@@ -77,11 +77,11 @@ Minimum version required to store current data is: `+o+`.
|
|
|
77
77
|
File size: ${i.size}`),new Error("Failed to upload to AWS")}}async upload(t,r,n){let{file:i,onProgress:o}=t;try{let s=l=>{let h=l.loadedBytes/i.size*100;o&&o(Math.round(h))},a;if(n){if(this.imageBatchNum===this.contImages){let l=[];for(let d=this.imageBatchNum;d<this.imageBatchNum+20;d++)l.push({objectName:`${this.proctoringId}/${this.proctoringId}_${d+1}.jpg`,contentType:"image/jpeg"});(await this.backend.getSignedUrlImage(r,l)).map(d=>{this.imageUrlPackage.push(d)}),this.imageBatchNum+=20}}else a=await this.backend.getSignedUrl(r,i,this.proctoringId);let c=!1;return n?c=await vr.request({url:this.imageUrlPackage[this.contImages],method:"PUT",headers:{"Content-Type":i.type,"x-ms-blob-type":"BlockBlob"},data:i,onUploadProgress:l=>{s({loadedBytes:l.loaded})}}).then(()=>!0).catch(()=>!1).finally(()=>{this.contImages++}):c=await vr.request({url:a,method:"PUT",headers:{"Content-Type":i.type,"x-ms-blob-type":"BlockBlob"},data:i,onUploadProgress:l=>{s({loadedBytes:l.loaded})}}).then(()=>!0).catch(()=>!1),{storage:"upload",url:a,uploaded:c}}catch{throw ue.registerError(this.proctoringId,`Failed to upload to AWS
|
|
78
78
|
File name: ${i.name}
|
|
79
79
|
File type: ${i.type}
|
|
80
|
-
File size: ${i.size}`),new Error("Failed to upload to AWS")}}};var Xg="not_shared_first_screen",Jg="not_shared_screen",Fa="multiple_monitors_detected",Yg="proctoring_already_started",Ma="proctoring_not_started";var Sd="another_stream_active",kd="stream_under_minimum_permitted",Zg="browser_not_supported",Qg="token_missing",e0="credentials_missing";var t0="spy_scan_api_not_found";var r0="external_camera_not_started";var Ua=class extends Bi{constructor(t,r,n="videoPreviewFrameDetection",i="liveViewFrameDetection"){super("ObjectDetector","https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite",t,r,n,i)}stopDetection(){super.stopDetection(),this.numPersonsSent>0&&this.handleOk("person_ok","person_detection_on_stream")}displayVideoDetections(t){for(let r of this.children)this.liveView.removeChild(r);this.children.splice(0);for(let r of t.detections){let n=window.innerWidth,i=window.innerHeight,o=this.video.offsetWidth,s=this.video.offsetHeight,a=o/n,c=s/i,l=o-r.boundingBox.width*a-r.boundingBox.originX*a,h=r.boundingBox.originY*c,d=(r.boundingBox.width-10)*a,m=r.boundingBox.height*c,p=document.createElement("p");p.innerText=r.categories[0].categoryName+" - with "+Math.round(parseFloat(r.categories[0].score)*100)+"% confidence.",p.style.right=l-20+"px",p.style.top=h+"px",p.style.width=d+"px";let g={zIndex:"2",position:"absolute",border:"1px dashed #fff"};Object.assign(p.style,{...g,margin:"0",fontSize:"9px",paddingBottom:"5px",paddingTop:"5px",color:"#fff",backgroundColor:"#007f8b"});let f=document.createElement("div");f.setAttribute("class","highlighter"),f.style.right=l-20+"px",f.style.top=h+"px",f.style.width=d+"px",f.style.height=m-20+"px",Object.assign(f.style,{...g,zIndex:"1",background:"rgba(0, 255, 0, 0.25)"}),this.liveView.appendChild(f),this.liveView.appendChild(p),this.children.push(f),this.children.push(p)}}verify(t){let r=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="person")).length,n=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="cell phone")).length;this.paramsConfig.videoBehaviourParameters?.detectPerson&&r!==this.numPersonsSent&&(r===0?(this.handleAlert("no_person_detected","person_detection_on_stream"),this.numPersonsSent=r):r>1?(this.handleAlert("multiple_persons_detected","person_detection_on_stream"),this.numPersonsSent=r):(this.handleOk("person_ok","person_detection_on_stream"),this.numPersonsSent=r)),this.paramsConfig.videoBehaviourParameters?.detectCellPhone&&n!==this.numCellphoneSent&&(n>0?(this.handleAlert("cellphone_detected","mobile_detection_on_stream"),this.numCellphoneSent=n):(this.handleOk("cellphone_ok","mobile_detection_on_stream"),this.numCellphoneSent=n))}};var gn=class{constructor(t){this.volume=null;this.animationFrameId=null;this.stream=t}async start(t={}){return new Promise((r,n)=>{try{
|
|
80
|
+
File size: ${i.size}`),new Error("Failed to upload to AWS")}}};var Xg="not_shared_first_screen",Jg="not_shared_screen",Fa="multiple_monitors_detected",Yg="proctoring_already_started",Ma="proctoring_not_started";var Sd="another_stream_active",kd="stream_under_minimum_permitted",Zg="browser_not_supported",Qg="token_missing",e0="credentials_missing";var t0="spy_scan_api_not_found";var r0="external_camera_not_started";var Ua=class extends Bi{constructor(t,r,n="videoPreviewFrameDetection",i="liveViewFrameDetection"){super("ObjectDetector","https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite",t,r,n,i)}stopDetection(){super.stopDetection(),this.numPersonsSent>0&&this.handleOk("person_ok","person_detection_on_stream")}displayVideoDetections(t){for(let r of this.children)this.liveView.removeChild(r);this.children.splice(0);for(let r of t.detections){let n=window.innerWidth,i=window.innerHeight,o=this.video.offsetWidth,s=this.video.offsetHeight,a=o/n,c=s/i,l=o-r.boundingBox.width*a-r.boundingBox.originX*a,h=r.boundingBox.originY*c,d=(r.boundingBox.width-10)*a,m=r.boundingBox.height*c,p=document.createElement("p");p.innerText=r.categories[0].categoryName+" - with "+Math.round(parseFloat(r.categories[0].score)*100)+"% confidence.",p.style.right=l-20+"px",p.style.top=h+"px",p.style.width=d+"px";let g={zIndex:"2",position:"absolute",border:"1px dashed #fff"};Object.assign(p.style,{...g,margin:"0",fontSize:"9px",paddingBottom:"5px",paddingTop:"5px",color:"#fff",backgroundColor:"#007f8b"});let f=document.createElement("div");f.setAttribute("class","highlighter"),f.style.right=l-20+"px",f.style.top=h+"px",f.style.width=d+"px",f.style.height=m-20+"px",Object.assign(f.style,{...g,zIndex:"1",background:"rgba(0, 255, 0, 0.25)"}),this.liveView.appendChild(f),this.liveView.appendChild(p),this.children.push(f),this.children.push(p)}}verify(t){let r=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="person")).length,n=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="cell phone")).length;this.paramsConfig.videoBehaviourParameters?.detectPerson&&r!==this.numPersonsSent&&(r===0?(this.handleAlert("no_person_detected","person_detection_on_stream"),this.numPersonsSent=r):r>1?(this.handleAlert("multiple_persons_detected","person_detection_on_stream"),this.numPersonsSent=r):(this.handleOk("person_ok","person_detection_on_stream"),this.numPersonsSent=r)),this.paramsConfig.videoBehaviourParameters?.detectCellPhone&&n!==this.numCellphoneSent&&(n>0?(this.handleAlert("cellphone_detected","mobile_detection_on_stream"),this.numCellphoneSent=n):(this.handleOk("cellphone_ok","mobile_detection_on_stream"),this.numCellphoneSent=n))}};var gn=class{constructor(t){this.volume=null;this.animationFrameId=null;this.stream=t}async start(t={}){return new Promise((r,n)=>{try{this.audioContext=new AudioContext,this.analyser=this.audioContext.createAnalyser(),this.microphone=this.audioContext.createMediaStreamSource(this.stream),this.analyser.smoothingTimeConstant=.8,this.analyser.fftSize=1024,this.microphone.connect(this.analyser);let i=()=>{let o=new Uint8Array(this.analyser.frequencyBinCount);this.analyser.getByteFrequencyData(o);let a=o.reduce((c,l)=>c+l,0)/o.length;this.setVolume(a),t.setVolume&&t.setVolume(a),this.animationFrameId=requestAnimationFrame(i)};this.animationFrameId=requestAnimationFrame(i),r(!0)}catch(i){this.stop(),n(`Error: ${i}`)}})}stop(){this.animationFrameId!==null&&cancelAnimationFrame(this.animationFrameId),this.microphone.disconnect(),this.analyser.disconnect()}getVolume(){return this.volume}setVolume(t){this.volume=t}};var s0=ul(i0()),Zr=class{constructor(t,r,n,i,o){this.blobs=[];this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectPerson:!1,detectFace:!1,detectCellPhone:!1}};this.options={cameraId:void 0,microphoneId:void 0,onBufferSizeError:!1,onBufferSizeErrorCallback:t=>{},proctoringType:"IMAGE",onChangeDevicesCallback:t=>{},onRealtimeAlertsCallback:t=>{}};this.videoOptions={width:640,height:480,minWidth:0,minHeight:0};this.blobsRTC=[];this.imageCount=0;this.filesToUpload=[];this.animationFrameId=null;this.isCanvasLoopActive=!1;this.hardwareStream=null;this.internalClonedStream=null;this.currentRetries=0;this.packageCount=0;this.noiseWait=20;this.options=t,this.videoOptions=r,this.backend=i,this.backendToken=o,n&&(this.paramsConfig=n)}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Yr(this.proctoringId,this.backend)),La(t)}async initializeDetectors(){ag(),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&(this.objectDetection=new Ua({onRealtimeAlertsCallback:t=>this.options.onRealtimeAlertsCallback(t)},this.paramsConfig),await this.objectDetection.initializeDetector()),this.paramsConfig.videoBehaviourParameters?.detectFace&&(this.faceDetection=new Li({onRealtimeAlertsCallback:t=>this.options.onRealtimeAlertsCallback(t)},this.paramsConfig),await this.faceDetection.initializeDetector())}configImageCapture(){this.video=document.createElement("video"),this.canvas=document.createElement("canvas"),this.video.srcObject=this.cameraStream,this.video.play(),this.video.muted=!0,screen.orientation?.type.includes("portrait")&&Fr()?(console.log("configurando canvas em portrait"),this.canvas.width=this.videoOptions.height/2,this.canvas.height=this.videoOptions.width/2):(this.canvas.width=this.videoOptions.width/2,this.canvas.height=this.videoOptions.height/2)}async bufferError(t){console.log("buffer error Camera Recorder params "+this.paramsConfig.videoBehaviourParameters);let r=this.paramsConfig.videoBehaviourParameters?.retryEnabled||!1,n=this.paramsConfig.videoBehaviourParameters?.maxRetries||3;r&&this.currentRetries<n?(console.log("buffer error Camera Recorder retry"),await this.recordingStop(),await this.startRecording({retry:!0}),this.currentRetries++,this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback(this.cameraStream)):this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback()}async startStream(t){let{cameraId:r,microphoneId:n,onBufferSizeErrorCallback:i}=this.options,o={audio:{deviceId:n},video:{deviceId:r,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.hardwareStream=await navigator.mediaDevices.getUserMedia(o)}catch(d){throw d.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":d}this.cameraStream=this.hardwareStream;let a=this.cameraStream.getVideoTracks()[0].getSettings(),{width:c=0,height:l=0}=a;if(screen.orientation?.type.includes("portrait")&&Fr()&&this.videoOptions.width==l&&this.videoOptions.height==c&&([c,l]=[l,c]),this.videoOptions.minWidth>c||this.videoOptions.minHeight>l)throw kd;if(this.videoOptions.width!==c||this.videoOptions.height!==l)throw ue.registerAnotherStream(this.proctoringId,`Maybe have another stream active
|
|
81
81
|
Video Options: ${JSON.stringify(this.videoOptions,null,2)}
|
|
82
82
|
Setting: ${JSON.stringify(a,null,2)}`),Sd}async stopStream(){this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}async startRecording(t){console.log("startRecording Camera Recorder"),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone||this.paramsConfig.videoBehaviourParameters?.detectFace)&&!t?.retry&&(console.log("startRecording Camera Recorder initializeDetectors"),await this.initializeDetectors());let{cameraId:r,microphoneId:n,onBufferSizeErrorCallback:i}=this.options,o={audio:{deviceId:n},video:{deviceId:r,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.hardwareStream=await navigator.mediaDevices.getUserMedia(o)}catch(_){throw console.log("startRecording Camera Recorder error",_),_.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":_}this.cameraStream=this.hardwareStream;let a=this.cameraStream.getVideoTracks()[0].getSettings(),{width:c=0,height:l=0}=a,{startRecording:h,stopRecording:d,pauseRecording:m,resumeRecording:p,recorderOptions:g,getBufferSize:f}=Wn(this.cameraStream,this.blobs,this.videoOptions,this.options.onBufferSizeError,_=>this.bufferError(_),!1);if(this.recordingStart=h,this.recordingStop=d,this.recordingPause=m,this.recordingResume=p,this.recorderOptions=g,this.getBufferSize=f,console.log("startRecording Camera Recorder recordingStart"),this.recordingStart(),screen.orientation?.type.includes("portrait")&&Fr()&&this.videoOptions.width==l&&this.videoOptions.height==c&&([c,l]=[l,c]),this.videoOptions.minWidth>c||this.videoOptions.minHeight>l)throw kd;if(this.videoOptions.width!==c||this.videoOptions.height!==l)throw ue.registerAnotherStream(this.proctoringId,`Maybe have another stream active
|
|
83
83
|
Video Options: ${JSON.stringify(this.videoOptions,null,2)}
|
|
84
|
-
Setting: ${JSON.stringify(a,null,2)}`),Sd;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&await this.objectDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&this.captureFrame(),this.packageCount=0,console.log("startRecording Camera Recorder finished")}async stopRecording(){this.isCanvasLoopActive=!1,this.recordingStop&&await this.recordingStop();try{this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}catch{console.error("Erro ao parar os streams de m\xEDdia.")}this.faceDetection&&this.faceDetection.detecting&&this.faceDetection.stopDetection(),this.objectDetection&&this.objectDetection.detecting&&this.objectDetection.stopDetection(),clearInterval(this.imageInterval),clearInterval(this.sendFrameInterval),this.options.proctoringType=="REALTIME"&&this.upload&&this.backendToken&&(await this.sendPackage(this.filesToUpload),await this.filesToUpload.splice(0,this.filesToUpload.length)),this.volumeMeter&&this.volumeMeter.stop(),this.intervalNoiseDetection&&clearInterval(this.intervalNoiseDetection)}async pauseRecording(){await this.recordingPause()}async resumeRecording(){await this.recordingResume()}photoShotsCycle(){let t;this.configImageCapture(),this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.videoOptions.width,this.videoOptions.height);let r=this.canvas.toDataURL("image/jpeg");t=await this.getFile(r,`${this.proctoringId}_${this.imageCount+1}.jpg`,"image/jpeg"),t&&this.upload&&this.backendToken&&(this.upload.upload({file:t},this.backendToken,!0),this.imageCount++)},this.paramsConfig.imageBehaviourParameters.uploadInterval*1e3)}async getCurrentImageBase64(){return!this.video||!this.canvas?this.configImageCapture():this.video.srcObject!==this.cameraStream&&(this.video.srcObject=this.cameraStream,await this.video.play()),this.video.paused&&await this.video.play(),await new Promise(t=>{if(this.video.readyState>=2){t();return}let r=()=>{this.video.removeEventListener("loadedmetadata",r),setTimeout(()=>t(),50)};this.video.addEventListener("loadedmetadata",r),setTimeout(()=>{this.video.removeEventListener("loadedmetadata",r),t()},500)}),this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height),this.canvas.toDataURL("image/jpeg")}captureFrame(){let t;this.configImageCapture();let r=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize;this.imageCount=0,this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height);let n=this.canvas.toDataURL("image/jpeg");if(this.proctoringId==null)return;if(r==this.imageCount){this.imageCount=0;let o=[...this.filesToUpload];this.sendPackage(o),await this.filesToUpload.splice(0,this.filesToUpload.length)}let i=`${this.proctoringId}_${this.imageCount+1}.jpg`;t=await this.getFile(n,i,"image/jpeg"),t&&t.size>10&&r>0&&(this.filesToUpload.push(t),this.imageCount++)},this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval*1e3)}async sendPackage(t){let r=!1,n=0,i=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize,o=this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval+1;if(this.upload&&this.backendToken&&!r&&this.filesToUpload.length>0){n=0,r=!0;let s=new s0.default;for(let d of t)s.file(d.name,d);let a=await s.generateAsync({type:"blob"}),c="realtime_package_"+i*o*this.packageCount+".zip",l=new File([a],c,{type:"application/zip"});(await this.upload.uploadPackage({file:l},this.backendToken)).uploaded==!0?this.packageCount++:console.log("erro no upload do pacote"),r=!1}else if(r&&(n++,n==3)){n=0;let s=this.videoOptions.width/2,a=this.videoOptions.height/2;s<320&&(s=320),a<180&&(a=180),this.canvas.width=s,this.canvas.height=a}}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}async saveOnSession(t){this.blobs!=null&&ue.registerSaveOnSession(this.proctoringId,`Blobs Length: ${this.blobs.length} Buffer Size: ${this.getBufferSize()} `);let r=this.cameraStream.getVideoTracks()[0].getSettings(),n=this.cameraStream.getAudioTracks()[0].getSettings();(this.options.proctoringType=="VIDEO"||this.options.proctoringType=="REALTIME"||this.options.proctoringType=="IMAGE"&&this.paramsConfig.imageBehaviourParameters?.saveVideo)&&t.addRecording({device:`Audio
|
|
84
|
+
Setting: ${JSON.stringify(a,null,2)}`),Sd;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&await this.objectDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&this.captureFrame(),this.packageCount=0,console.log("startRecording Camera Recorder finished")}async stopRecording(){console.log("Stopping Camera Recorder..."),this.isCanvasLoopActive=!1,this.recordingStop&&await this.recordingStop();try{this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}catch{console.error("Erro ao parar os streams de m\xEDdia.")}this.faceDetection&&this.faceDetection.detecting&&this.faceDetection.stopDetection(),this.objectDetection&&this.objectDetection.detecting&&this.objectDetection.stopDetection(),clearInterval(this.imageInterval),clearInterval(this.sendFrameInterval),this.options.proctoringType=="REALTIME"&&this.upload&&this.backendToken&&(await this.sendPackage(this.filesToUpload),await this.filesToUpload.splice(0,this.filesToUpload.length)),this.volumeMeter&&this.volumeMeter.stop(),this.intervalNoiseDetection&&clearInterval(this.intervalNoiseDetection)}async pauseRecording(){await this.recordingPause()}async resumeRecording(){await this.recordingResume()}photoShotsCycle(){let t;this.configImageCapture(),this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.videoOptions.width,this.videoOptions.height);let r=this.canvas.toDataURL("image/jpeg");t=await this.getFile(r,`${this.proctoringId}_${this.imageCount+1}.jpg`,"image/jpeg"),t&&this.upload&&this.backendToken&&(this.upload.upload({file:t},this.backendToken,!0),this.imageCount++)},this.paramsConfig.imageBehaviourParameters.uploadInterval*1e3)}async getCurrentImageBase64(){return!this.video||!this.canvas?this.configImageCapture():this.video.srcObject!==this.cameraStream&&(this.video.srcObject=this.cameraStream,await this.video.play()),this.video.paused&&await this.video.play(),await new Promise(t=>{if(this.video.readyState>=2){t();return}let r=()=>{this.video.removeEventListener("loadedmetadata",r),setTimeout(()=>t(),50)};this.video.addEventListener("loadedmetadata",r),setTimeout(()=>{this.video.removeEventListener("loadedmetadata",r),t()},500)}),this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height),this.canvas.toDataURL("image/jpeg")}captureFrame(){let t;this.configImageCapture();let r=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize;this.imageCount=0,this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height);let n=this.canvas.toDataURL("image/jpeg");if(this.proctoringId==null)return;if(r==this.imageCount){this.imageCount=0;let o=[...this.filesToUpload];this.sendPackage(o),await this.filesToUpload.splice(0,this.filesToUpload.length)}let i=`${this.proctoringId}_${this.imageCount+1}.jpg`;t=await this.getFile(n,i,"image/jpeg"),t&&t.size>10&&r>0&&(this.filesToUpload.push(t),this.imageCount++)},this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval*1e3)}async sendPackage(t){let r=!1,n=0,i=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize,o=this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval+1;if(this.upload&&this.backendToken&&!r&&this.filesToUpload.length>0){n=0,r=!0;let s=new s0.default;for(let d of t)s.file(d.name,d);let a=await s.generateAsync({type:"blob"}),c="realtime_package_"+i*o*this.packageCount+".zip",l=new File([a],c,{type:"application/zip"});(await this.upload.uploadPackage({file:l},this.backendToken)).uploaded==!0?this.packageCount++:console.log("erro no upload do pacote"),r=!1}else if(r&&(n++,n==3)){n=0;let s=this.videoOptions.width/2,a=this.videoOptions.height/2;s<320&&(s=320),a<180&&(a=180),this.canvas.width=s,this.canvas.height=a}}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}async saveOnSession(t){this.blobs!=null&&ue.registerSaveOnSession(this.proctoringId,`Blobs Length: ${this.blobs.length} Buffer Size: ${this.getBufferSize()} `);let r=this.cameraStream.getVideoTracks()[0].getSettings(),n=this.cameraStream.getAudioTracks()[0].getSettings();(this.options.proctoringType=="VIDEO"||this.options.proctoringType=="REALTIME"||this.options.proctoringType=="IMAGE"&&this.paramsConfig.imageBehaviourParameters?.saveVideo)&&t.addRecording({device:`Audio
|
|
85
85
|
Sample Rate: ${n.sampleRate}
|
|
86
86
|
Sample Size: ${n.sampleSize}
|
|
87
87
|
|
|
@@ -434,7 +434,7 @@ Para iniciar um exame utilize uma outra c\xE2mera.`),o.setAttribute("class","che
|
|
|
434
434
|
File size: ${n.size}`),new Error("Error on machine download")}}};var Wa=class{constructor(t,r){this.session=t;this.recorders=r}async startAll(){this.session.start();for(let t of this.recorders)await t.startRecording({retry:!1})}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 $i=class{constructor(t,r,n){this.session=t;this.proctoringId=r;this.uploadServices=n}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 n=0;n<this.session.recordings.length;n++){let i=this.session.recordings[n];if(i.upload)continue;let o=a=>{let c=(n*100+a)/this.session.recordings.length;r&&r(c)},s=await this.uploadFile(i,t,o).catch(()=>{});s&&(i.upload||(i.upload={storage:"upload",awsUrl:"",azureUrl:""}),s.uploaded&&(i.upload.storage=s.storage),s.storage==="upload"?s.url&&(i.upload.azureUrl=s.url):s.url&&(i.upload.awsUrl=s.url))}r&&r(100)}async uploadFile(t,r,n){for await(let i of this.uploadServices){let o=await i.upload({file:t.file,onProgress:s=>{n&&n(s)}},r);if(o){let s="";return t.file.name.search("camera")!==-1?s="Camera":t.file.name.search("screen")!==-1?s="Screen":t.file.name.search("audio")!==-1&&(s="Audio"),ue.registerUploadFile(this.proctoringId,`Upload File
|
|
435
435
|
Name: ${t.file.name}
|
|
436
436
|
Type: ${t.file.type}
|
|
437
|
-
Size: ${t.file.size}`,s),o}}throw new Error("Could not upload")}};var $a=class{constructor(t,r){this.alerts=[];this.lastActivityTime=Date.now();this.IDLE_THRESHOLD_MS=3e4;this.handleVisibilityChange=()=>{document.visibilityState==="visible"?this.handleReturnFocus():this.handleLostFocus()};this.handleLostFocus=()=>{if(this.getRelativeTime()>1e4){let t={begin:this.getRelativeTime(),end:0,alert:25,type:3};this.onLostFocusCallback(t),this.alerts.push(t)}};this.handleReturnFocus=()=>{let t=this.alerts[this.alerts.length-1];t&&(this.onFocusCallback({begin:t.begin,end:this.getRelativeTime(),alert:25,type:3}),t.end=this.getRelativeTime())};this.handleResize=()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{let t=window.screen.availWidth,r=window.outerWidth;if(r<t*.85){let n=`Split Screen Detectado: Janela ocupa ${(r/t*100).toFixed(0)}% da tela`;this.createAlert(43,3,n),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:n,type:"split_screen"})}},1e3)};this.handleUserActivity=t=>{this.lastActivityTime=Date.now(),console.log("\u{1F449} handleUserActivity",t)};this.handleCopy=t=>{t.preventDefault();let r="Tentativa de Copiar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_copy"})};this.handleCut=t=>{t.preventDefault();let r="Tentativa de Recortar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_cut"})};this.handlePaste=t=>{t.preventDefault();let r="Tentativa de Colar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_paste"})};this.onLostFocusCallback=t.onLostFocusCallback,this.onFocusCallback=t.onFocusCallback,this.onRealtimeAlertCallback=t.onRealtimeAlertCallback,this.optionsProctoring=r}async startRecording(){this.startTime=new Date(Date.now()),this.alerts=[],this.attachListeners()}async pauseRecording(){this.detachListeners()}async resumeRecording(){this.attachListeners()}async stopRecording(){this.detachListeners()}async saveOnSession(t){this.alerts.forEach(r=>{t.addAlert(r)})}attachListeners(){this.optionsProctoring.captureScreen&&(window.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("resize",this.handleResize),window.document.addEventListener("copy",this.handleCopy),window.document.addEventListener("cut",this.handleCut),window.document.addEventListener("paste",this.handlePaste))}detachListeners(){window.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("resize",this.handleResize),window.document.removeEventListener("copy",this.handleCopy),window.document.removeEventListener("cut",this.handleCut),window.document.removeEventListener("paste",this.handlePaste)}addBackgroundEvent(t,r=200){this.createAlert(r,3,t),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:t,type:"background_event"})}getRelativeTime(){return Date.now()-this.startTime.getTime()}createAlert(t,r,n){this.alerts.push({begin:this.getRelativeTime(),end:this.getRelativeTime(),alert:t,type:r})}addAlert({alert:t,type:r}){this.alerts.push({begin:Date.now()-this.startTime.getTime(),end:Date.now()-this.startTime.getTime(),alert:t,type:r})}};var Ga=class{constructor(t,r){this.blobs=[];this.options={cameraId:void 0,microphoneId:void 0};this.audioParams={recordingBitrate:128};r&&(this.audioParams=r),t&&(this.options=t)}async startRecording(){let t={audio:{deviceId:this.options.microphoneId||"default"}};this.audioStream=await navigator.mediaDevices.getUserMedia(t);let{startRecording:r,stopRecording:n,pauseRecording:i,resumeRecording:o}=Wn(this.audioStream,this.blobs,null,void 0,void 0,!0);this.recordingStart=r,this.recordingStop=n,this.recordingPause=i,this.recordingResume=o,this.recordingStart()}async pauseRecording(){}async resumeRecording(){}async stopRecording(){this.recordingStop&&await this.recordingStop()}async saveOnSession(t,r,n){t.addRecording({device:"",file:new File(this.blobs,`EP_${t.id}_audio_${r&&n&&`${r}_${n}`||"0"}.webm`,{type:"audio/webm"}),origin:"Mic"})}};var Kn=typeof self<"u"?self:{};function $n(){throw Error("Invalid UTF8")}function l0(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var qa,Ad,y_=typeof TextDecoder<"u",b_,v_=typeof TextEncoder<"u";function G0(e){if(v_)e=(b_||=new TextEncoder).encode(e);else{let r=0,n=new Uint8Array(3*e.length);for(let i=0;i<e.length;i++){var t=e.charCodeAt(i);if(t<128)n[r++]=t;else{if(t<2048)n[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&i<e.length){let o=e.charCodeAt(++i);if(o>=56320&&o<=57343){t=1024*(t-55296)+o-56320+65536,n[r++]=t>>18|240,n[r++]=t>>12&63|128,n[r++]=t>>6&63|128,n[r++]=63&t|128;continue}i--}t=65533}n[r++]=t>>12|224,n[r++]=t>>6&63|128}n[r++]=63&t|128}}e=r===n.length?n:n.subarray(0,r)}return e}var $d,ec;e:{for(Td=["CLOSURE_FLAGS"],Ka=Kn,Xa=0;Xa<Td.length;Xa++)if((Ka=Ka[Td[Xa]])==null){ec=null;break e}ec=Ka}var Td,Ka,Xa,Jo,h0=ec&&ec[610401301];$d=h0!=null&&h0;var d0=Kn.navigator;function Md(e){return!!$d&&!!Jo&&Jo.brands.some((({brand:t})=>t&&t.indexOf(e)!=-1))}function cr(e){var t;return(t=Kn.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function vn(){return!!$d&&!!Jo&&Jo.brands.length>0}function Id(){return vn()?Md("Chromium"):(cr("Chrome")||cr("CriOS"))&&!(!vn()&&cr("Edge"))||cr("Silk")}Jo=d0&&d0.userAgentData||null;var __=!vn()&&(cr("Trident")||cr("MSIE"));!cr("Android")||Id(),Id(),cr("Safari")&&(Id()||!vn()&&cr("Coast")||!vn()&&cr("Opera")||!vn()&&cr("Edge")||(vn()?Md("Microsoft Edge"):cr("Edg/"))||vn()&&Md("Opera"));var q0={},$o=null;function w_(e){let 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);let n=new Uint8Array(r),i=0;return(function(o,s){function a(l){for(;c<o.length;){let h=o.charAt(c++),d=$o[h];if(d!=null)return d;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return l}K0();let c=0;for(;;){let l=a(-1),h=a(0),d=a(64),m=a(64);if(m===64&&l===-1)break;s(l<<2|h>>4),d!=64&&(s(h<<4&240|d>>2),m!=64&&s(d<<6&192|m))}})(e,(function(o){n[i++]=o})),i!==r?n.subarray(0,i):n}function K0(){if(!$o){$o={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=e.concat(t[r].split(""));q0[r]=n;for(let i=0;i<n.length;i++){let o=n[i];$o[o]===void 0&&($o[o]=i)}}}}var X0=typeof Uint8Array<"u",J0=!__&&typeof btoa=="function";function u0(e){if(!J0){var t;t===void 0&&(t=0),K0(),t=q0[t];var r=Array(Math.floor(e.length/3)),n=t[64]||"";let c=0,l=0;for(;c<e.length-2;c+=3){var i=e[c],o=e[c+1],s=e[c+2],a=t[i>>2];i=t[(3&i)<<4|o>>4],o=t[(15&o)<<2|s>>6],s=t[63&s],r[l++]=a+i+o+s}switch(a=0,s=n,e.length-c){case 2:s=t[(15&(a=e[c+1]))<<2]||n;case 1:e=e[c],r[l]=t[e>>2]+t[(3&e)<<4|a>>4]+s+n}return r.join("")}for(t="",r=0,n=e.length-10240;r<n;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}var f0=/[-_.]/g,S_={"-":"+",_:"/",".":"="};function k_(e){return S_[e]||""}function Y0(e){if(!J0)return w_(e);f0.test(e)&&(e=e.replace(f0,k_)),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 hc(e){return X0&&e!=null&&e instanceof Uint8Array}var Yi={};function Zi(){return E_||=new wn(null,Yi)}function Gd(e){Z0(Yi);var t=e.g;return(t=t==null||hc(t)?t:typeof t=="string"?Y0(t):null)==null?t:e.g=t}var wn=class{i(){return new Uint8Array(Gd(this)||0)}constructor(e,t){if(Z0(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}},E_,C_;function Z0(e){if(e!==Yi)throw Error("illegal external caller")}function Q0(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function p0(){let e=Error("int32");return Q0(e,"warning"),e}var dc=typeof Symbol=="function"&&typeof Symbol()=="symbol",x_=new Set;function uc(e,t,r=!1,n=!1){return e=typeof Symbol=="function"&&typeof Symbol()=="symbol"?n&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t,r&&x_.add(e),e}var A_=uc("jas",void 0,!0,!0),Rd=uc(void 0,"2ex"),Ho=uc(void 0,"1oa",!0),Qi=uc(void 0,Symbol(),!0),se=dc?A_:"M",e1={M:{value:0,configurable:!0,writable:!0,enumerable:!1}},t1=Object.defineProperties;function qd(e,t){dc||se in e||t1(e,e1),e[se]|=t}function ct(e,t){dc||se in e||t1(e,e1),e[se]=t}function T_(e,t){ct(t,-30975&(0|e))}function Ud(e,t){ct(t,-30941&(34|e))}function Kd(){return typeof BigInt=="function"}function lr(e){return Array.prototype.slice.call(e)}var Xd,Zo={},I_={};function m0(e){return!(!e||typeof e!="object"||e.g!==I_)}function Jd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function r1(e,t){if(e!=null){if(typeof e=="string")e=e?new wn(e,Yi):Zi();else if(e.constructor!==wn)if(hc(e))e=e.length?new wn(new Uint8Array(e),Yi):Zi();else{if(!t)throw Error();e=void 0}}return e}function tc(e){return!(!Array.isArray(e)||e.length)&&!!(1&(0|e[se]))}var g0=[];function Yn(e){if(2&e)throw Error()}function Yd(e){return Qi?e[Qi]:void 0}ct(g0,55),Xd=Object.freeze(g0);var n1=Object.freeze({}),Zd=typeof Kn.BigInt=="function"&&typeof Kn.BigInt(0)=="bigint",Nd=e=>Zd?e>=P_&&e<=O_:e[0]==="-"?y0(e,R_):y0(e,D_),R_=Number.MIN_SAFE_INTEGER.toString(),P_=Zd?BigInt(Number.MIN_SAFE_INTEGER):void 0,D_=Number.MAX_SAFE_INTEGER.toString(),O_=Zd?BigInt(Number.MAX_SAFE_INTEGER):void 0;function y0(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){let n=e[r],i=t[r];if(n>i)return!1;if(n<i)return!0}}var B_=typeof Uint8Array.prototype.slice=="function",i1,De=0,Ge=0;function b0(e){let t=e>>>0;De=t,Ge=(e-t)/4294967296>>>0}function eo(e){if(e<0){b0(-e);let[t,r]=tu(De,Ge);De=t>>>0,Ge=r>>>0}else b0(e)}function o1(e){let t=i1||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ge=0,De=t.getUint32(0,!0)}function Qd(e,t){let r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Yo(e,t)}function eu(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Qd(e,t))=="number"?r?-e:e:r?"-"+e:e}function Yo(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else Kd()?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,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+v0(r)+v0(e));return r}function v0(e){return e=String(e),"0000000".slice(e.length)+e}function fc(e){if(e.length<16)eo(Number(e));else if(Kd())e=BigInt(e),De=Number(e&BigInt(4294967295))>>>0,Ge=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");Ge=De=0;let r=e.length;for(let n=t,i=(r-t)%6+t;i<=r;n=i,i+=6){let o=Number(e.slice(n,i));Ge*=1e6,De=1e6*De+o,De>=4294967296&&(Ge+=Math.trunc(De/4294967296),Ge>>>=0,De>>>=0)}if(t){let[n,i]=tu(De,Ge);De=n,Ge=i}}}function tu(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}var s1=typeof BigInt=="function"?BigInt.asIntN:void 0,L_=typeof BigInt=="function"?BigInt.asUintN:void 0,Go=Number.isSafeInteger,pc=Number.isFinite,rc=Math.trunc;function Qo(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function _0(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}var F_=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function ru(e){switch(typeof e){case"bigint":return!0;case"number":return pc(e);case"string":return F_.test(e);default:return!1}}function Xn(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return pc(e)?0|e:void 0}function w0(e){if(e[0]==="-")return!1;let t=e.length;return t<20||t===20&&Number(e.substring(0,6))<184467}function a1(e){return e=rc(e),Go(e)||(eo(e),e=eu(De,Ge)),e}function c1(e){var t=rc(Number(e));if(Go(t))return String(t);if((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),t=e.length,!(e[0]==="-"?t<20||t===20&&Number(e.substring(0,7))>-922337:t<19||t===19&&Number(e.substring(0,6))<922337))if(fc(e),e=De,2147483648&(t=Ge))if(Kd())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=tu(e,t);e="-"+Yo(r,n)}else e=Yo(e,t);return e}function zd(e){return e==null?e:typeof e=="bigint"?(Nd(e)?e=Number(e):(e=s1(64,e),e=Nd(e)?Number(e):String(e)),e):ru(e)?typeof e=="number"?a1(e):c1(e):void 0}function M_(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(L_(64,e));if(ru(e)){if(t==="string")return t=rc(Number(e)),Go(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),w0(e)||(fc(e),e=Yo(De,Ge))),e;if(t==="number")return(e=rc(e))>=0&&Go(e)?e:(function(r){if(r<0){eo(r);var n=Yo(De,Ge);return r=Number(n),Go(r)?r:n}return w0(n=String(r))?n:(eo(r),Qd(De,Ge))})(e)}}function l1(e){if(typeof e!="string")throw Error();return e}function nc(e){if(e!=null&&typeof e!="string")throw Error();return e}function Sn(e){return e==null||typeof e=="string"?e:void 0}function h1(e,t,r){if(e!=null&&typeof e=="object"&&e.B===Zo)return e;if(Array.isArray(e)){var n=0|e[se],i=n;return i===0&&(i|=32&r),(i|=2&r)!==n&&ct(e,i),new t(e)}}function d1(e,t,r,n,i){if(e!=null){if(Array.isArray(e))e=tc(e)?void 0:i&&2&(0|e[se])?e:nu(e,t,r,n!==void 0,i);else if(Jd(e)){let o={};for(let s in e)o[s]=d1(e[s],t,r,n,i);e=o}else e=t(e,n);return e}}function nu(e,t,r,n,i){let o=n||r?0|e[se]:0,s=n?!!(32&o):void 0;n=lr(e);for(let a=0;a<n.length;a++)n[a]=d1(n[a],t,r,s,i);return r&&((e=Yd(e))&&(n[Qi]=lr(e)),r(o,n)),n}function U_(e){return e.B===Zo?e.toJSON():(function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return Nd(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(tc(t))return}else{if(hc(t))return u0(t);if(t instanceof wn){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=u0(r)}}}return t})(e)}function N_(e){return nu(e,U_,void 0,void 0,!1)}var u1,z_;function qo(e,t,r){return e=f1(e,t[0],t[1],r?1:2),t!==u1&&r&&qd(e,16384),e}function f1(e,t,r,n){if(e==null){var i=96;r?(e=[r],i|=512):e=[],t&&(i=-33521665&i|(1023&t)<<15)}else{if(!Array.isArray(e))throw Error("narr");if(2048&(i=0|e[se]))throw Error("farr");if(64&i)return e;if(n===1||n===2||(i|=64),r&&(i|=512,r!==e[0]))throw Error("mid");e:{if(n=(r=e).length){let o=n-1;if(Jd(r[o])){if((t=o-(512&(i|=256)?0:-1))>=1024)throw Error("pvtlmt");i=-33521665&i|(1023&t)<<15;break e}}if(t){if((t=Math.max(t,n-(512&i?0:-1)))>1024)throw Error("spvt");i=-33521665&i|(1023&t)<<15}}}return ct(e,i),e}function p1(e,t,r=Ud){if(e!=null){if(X0&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var n=0|e[se];return 2&n?e:(t&&=n===0||!!(32&n)&&!(64&n||!(16&n)),t?(ct(e,-12293&(34|n)),e):nu(e,p1,4&n?Ud:r,!0,!0))}return e.B===Zo&&(e=2&(n=0|(r=e.l)[se])?e:new e.constructor(mc(r,n,!0))),e}}function m1(e){let t=e.l;return new e.constructor(mc(t,0|t[se],!1))}function mc(e,t,r){let n=r||2&t?Ud:T_,i=!!(32&t);return e=(function(o,s,a){let c=lr(o);var l=c.length;let h=256&s?c[l-1]:void 0;for(l+=h?-1:0,s=512&s?1:0;s<l;s++)c[s]=a(c[s]);if(h){s=c[s]={};for(let d in h)s[d]=a(h[d])}return(o=Yd(o))&&(c[Qi]=lr(o)),c})(e,t,(o=>p1(o,i,n))),qd(e,32|(r?2:0)),e}function iu(e){let t=e.l,r=0|t[se];return 2&r?new e.constructor(mc(t,r,!1)):e}function _r(e,t){return Zn(e=e.l,0|e[se],t)}function Zn(e,t,r,n){if(r===-1)return null;var i=r+(512&t?0:-1);let o=e.length-1;return i>=o&&256&t?e[o][r]:n&&256&t&&(t=e[o][r])!=null?(e[i]!=null&&Rd!=null&&((i=(e=C_??={})[Rd]||0)>=4||(e[Rd]=i+1,Q0(e=Error(),"incident"),(function(s){Kn.setTimeout((()=>{throw s}),0)})(e))),t):i<=o?e[i]:void 0}function pt(e,t,r){let n=e.l,i=0|n[se];return Yn(i),lt(n,i,t,r),e}function lt(e,t,r,n){let i=512&t?0:-1,o=r+i;var s=e.length-1;return o>=s&&256&t?(e[s][r]=n,t):o<=s?(e[o]=n,256&t&&r in(e=e[s])&&delete e[r],t):(n!==void 0&&(r>=(s=t>>15&1023||536870912)?n!=null&&(e[s+i]={[r]:n},ct(e,t|=256)):e[o]=n),t)}function g1(e){let t=0|(e=e.l)[se],r=Zn(e,t,1),n=r1(r,!0);return n!=null&&n!==r&<(e,t,1,n),n}function y1(e,t,r,n,i){let o=e.l,s=2&(e=0|o[se])?1:n;i=!!i;let a=0|(n=ou(o,e,t))[se];if(!(4&a)){4&a&&(n=lr(n),a=en(a,e),e=lt(o,e,t,n));let c=0,l=0;for(;c<n.length;c++){let h=r(n[c]);h!=null&&(n[l++]=h)}l<c&&(n.length=l),a=su(a,e),r=-4097&(20|a),a=r&=-8193,ct(n,a),2&a&&Object.freeze(n)}return s===1||s===4&&32&a?Qr(a)||(i=a,a|=2,a!==i&&ct(n,a),Object.freeze(n)):(s===2&&Qr(a)&&(n=lr(n),a=en(a,e),a=kn(a,e,i),ct(n,a),e=lt(o,e,t,n)),Qr(a)||(t=a,a=kn(a,e,i),a!==t&&ct(n,a))),n}function ou(e,t,r,n){return e=Zn(e,t,r,n),Array.isArray(e)?e:Xd}function su(e,t){return e===0&&(e=en(e,t)),1|e}function Qr(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function S0(e,t,r){let n=0|(e=e.l)[se];if(Yn(n),r==null)lt(e,n,t);else{var i=0|r[se],o=i,s=Qr(i),a=s||Object.isFrozen(r);for(s||(i=0),a||(r=lr(r),o=0,i=kn(i=en(i,n),n,!0),a=!1),i|=21,s=0;s<r.length;s++){let c=r[s],l=l1(c);Object.is(c,l)||(a&&(r=lr(r),o=0,i=kn(i=en(i,n),n,!0),a=!1),r[s]=l)}i!==o&&(a&&(r=lr(r),i=kn(i=en(i,n),n,!0)),ct(r,i)),lt(e,n,t,r)}}function b1(e,t){let r=0|(e=e.l)[se];Yn(r),lt(e,r,2,t===""?void 0:t)}function es(e,t,r,n,i){Yn(t);var o=!(!(64&t)&&16384&t);let s=(i=ou(e,t,r,i))!==Xd;if(o||!s){let a=o=s?0|i[se]:0;(!s||2&a||Qr(a)||4&a&&!(32&a))&&(i=lr(i),a=en(a,t),t=lt(e,t,r,i)),a=-13&su(a,t),a=kn(n?-17&a:16|a,t,!0),a!==o&&ct(i,a)}return i}function Pd(e,t){var r=c2;return cu(au(e=e.l),e,0|e[se],r)===t?t:-1}function au(e){if(dc)return e[Ho]??(e[Ho]=new Map);if(Ho in e)return e[Ho];let t=new Map;return Object.defineProperty(e,Ho,{value:t}),t}function v1(e,t,r,n){let i=au(e),o=cu(i,e,t,r);return o!==n&&(o&&(t=lt(e,t,o)),i.set(r,n)),t}function cu(e,t,r,n){let i=e.get(n);if(i!=null)return i;i=0;for(let o=0;o<n.length;o++){let s=n[o];Zn(t,r,s)!=null&&(i!==0&&(r=lt(t,r,i)),i=s)}return e.set(n,i),i}function lu(e,t,r,n){let i,o=0|e[se];if((n=Zn(e,o,r,n))!=null&&n.B===Zo)return(t=iu(n))!==n&<(e,o,r,t),t.l;if(Array.isArray(n)){let s=0|n[se];i=2&s?qo(mc(n,s,!1),t,!0):64&s?n:qo(i,t,!0)}else i=qo(void 0,t,!0);return i!==n&<(e,o,r,i),i}function _1(e,t,r,n){let i=0|(e=e.l)[se];return(t=h1(n=Zn(e,i,r,n),t,i))!==n&&t!=null&<(e,i,r,t),t}function wr(e,t,r){if((t=_1(e,t,r,!1))==null)return t;let n=0|(e=e.l)[se];if(!(2&n)){let i=iu(t);i!==t&<(e,n,r,t=i)}return t}function w1(e,t,r,n,i,o){e=e.l;var s=!!(2&t);let a=s?1:n;i=!!i,o&&=!s;var c=0|(n=ou(e,t,1))[se];if(!(s=!!(4&c))){var l=n,h=t;let d=!!(2&(c=su(c,t)));d&&(h|=2);let m=!d,p=!0,g=0,f=0;for(;g<l.length;g++){let b=h1(l[g],r,h);if(b instanceof r){if(!d){let _=!!(2&(0|b.l[se]));m&&=!_,p&&=_}l[f++]=b}}f<g&&(l.length=f),c|=4,c=p?16|c:-17&c,ct(l,c=m?8|c:-9&c),d&&Object.freeze(l)}if(o&&!(8&c||!n.length&&(a===1||a===4&&32&c))){for(Qr(c)&&(n=lr(n),c=en(c,t),t=lt(e,t,1,n)),r=n,o=c,l=0;l<r.length;l++)(c=r[l])!==(h=iu(c))&&(r[l]=h);o|=8,ct(r,o=r.length?-17&o:16|o),c=o}return a===1||a===4&&32&c?Qr(c)||(t=c,(c|=!n.length||16&c&&(!s||32&c)?2:2048)!==t&&ct(n,c),Object.freeze(n)):(a===2&&Qr(c)&&(ct(n=lr(n),c=kn(c=en(c,t),t,i)),t=lt(e,t,1,n)),Qr(c)||(e=c,(c=kn(c,t,i))!==e&&ct(n,c))),n}function hu(e,t){let r=0|e.l[se];return w1(e,r,t,n1===void 0?2:4,!1,!(2&r))}function Sr(e,t,r,n){return n==null&&(n=void 0),pt(e,r,n)}function Dd(e,t,r){var n=i2;r==null&&(r=void 0);e:{let i=0|(e=e.l)[se];if(Yn(i),r==null){let o=au(e);if(cu(o,e,i,n)!==t)break e;o.set(n,0)}else i=v1(e,i,n,t);lt(e,i,t,r)}}function en(e,t){return-2049&(e=32|(2&t?2|e:-3&e))}function kn(e,t,r){return 32&t&&r||(e&=-33),e}function S1(e,t){var r=xu;let n=0|e.l[se];Yn(n),e=w1(e,n,r,2,!0),t=t??new r,e.push(t),e[se]=2&(0|t.l[se])?-9&e[se]:-17&e[se]}function Ot(e,t,r){Yn(0|e.l[se]),y1(e,t,Sn,2,!0).push(l1(r))}function k1(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function du(){return Error("Failed to read varint, encoding is invalid.")}function E1(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function uu(e){if(typeof e=="string")return{buffer:Y0(e),u:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),u:!1};if(e.constructor===Uint8Array)return{buffer:e,u:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),u:!1};if(e.constructor===wn)return{buffer:Gd(e)||new Uint8Array(0),u:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),u:!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 fu(e,t){let r,n=0,i=0,o=0,s=e.i,a=e.g;do r=s[a++],n|=(127&r)<<o,o+=7;while(o<32&&128&r);for(o>32&&(i|=(127&r)>>4),o=3;o<32&&128&r;o+=7)r=s[a++],i|=(127&r)<<o;if(qn(e,a),r<128)return t(n>>>0,i>>>0);throw du()}function pu(e){let t=0,r=e.g,n=r+10,i=e.i;for(;r<n;){let o=i[r++];if(t|=o,(128&o)==0)return qn(e,r),!!(127&t)}throw du()}function Bt(e){let t=e.i,r=e.g,n=t[r++],i=127&n;if(128&n&&(n=t[r++],i|=(127&n)<<7,128&n&&(n=t[r++],i|=(127&n)<<14,128&n&&(n=t[r++],i|=(127&n)<<21,128&n&&(n=t[r++],i|=n<<28,128&n&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw du();return qn(e,r),i}function jd(e){var t=e.i;let r=e.g,n=t[r],i=t[r+1],o=t[r+2];return t=t[r+3],qn(e,e.g+4),(n<<0|i<<8|o<<16|t<<24)>>>0}function Vd(e){var t=jd(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:e*(1/0):r==0?1401298464324817e-60*e*t:e*Math.pow(2,r-150)*(t+8388608)}function j_(e){return Bt(e)}function Od(e,t,{C:r=!1}={}){e.C=r,t&&(t=uu(t),e.i=t.buffer,e.m=t.u,e.s=0,e.j=e.i.length,e.g=e.s)}function qn(e,t){if(e.g=t,t>e.j)throw E1(e.j,t)}function C1(e,t){if(t<0)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,n=r+t;if(n>e.j)throw E1(t,e.j-r);return e.g=n,r}function x1(e,t){if(t==0)return Zi();var r=C1(e,t);return e.C&&e.m?r=e.i.subarray(r,r+t):(e=e.i,r=r===(t=r+t)?new Uint8Array(0):B_?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Zi():new wn(r,Yi)}var k0=[];function A1(e){var t=e.g;if(t.g==t.j)return!1;e.j=e.g.g;var r=Bt(e.g)>>>0;if(t=r>>>3,!((r&=7)>=0&&r<=5))throw k1(r,e.j);if(t<1)throw Error(`Invalid field number: ${t} (at position ${e.j})`);return e.m=t,e.i=r,!0}function Za(e){switch(e.i){case 0:e.i!=0?Za(e):pu(e.g);break;case 1:qn(e=e.g,e.g+8);break;case 2:if(e.i!=2)Za(e);else{var t=Bt(e.g)>>>0;qn(e=e.g,e.g+t)}break;case 5:qn(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!A1(e))throw Error("Unmatched start-group tag: stream EOF");if(e.i==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}Za(e)}break;default:throw k1(e.i,e.j)}}function gc(e,t,r){let n=e.g.j,i=Bt(e.g)>>>0,o=e.g.g+i,s=o-n;if(s<=0&&(e.g.j=o,r(t,e,void 0,void 0,void 0),s=o-e.g.g),s)throw Error(`Message parsing ended unexpectedly. Expected to read ${i} bytes, instead read ${i-s} bytes, either the data ended unexpectedly or the message misreported its own length`);e.g.g=o,e.g.j=n}function mu(e){var t=Bt(e.g)>>>0,r=C1(e=e.g,t);if(e=e.i,y_){var n,i=e;(n=Ad)||(n=Ad=new TextDecoder("utf-8",{fatal:!0})),t=r+t,i=r===0&&t===i.length?i:i.subarray(r,t);try{var o=n.decode(i)}catch(a){if(qa===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),qa=!0}catch{qa=!1}}throw!qa&&(Ad=void 0),a}}else{t=(o=r)+t,r=[];let a,c=null;for(;o<t;){var s=e[o++];s<128?r.push(s):s<224?o>=t?$n():(a=e[o++],s<194||(192&a)!=128?(o--,$n()):r.push((31&s)<<6|63&a)):s<240?o>=t-1?$n():(a=e[o++],(192&a)!=128||s===224&&a<160||s===237&&a>=160||(192&(n=e[o++]))!=128?(o--,$n()):r.push((15&s)<<12|(63&a)<<6|63&n)):s<=244?o>=t-2?$n():(a=e[o++],(192&a)!=128||a-144+(s<<28)>>30!=0||(192&(n=e[o++]))!=128||(192&(i=e[o++]))!=128?(o--,$n()):(s=(7&s)<<18|(63&a)<<12|(63&n)<<6|63&i,s-=65536,r.push(55296+(s>>10&1023),56320+(1023&s)))):$n(),r.length>=8192&&(c=l0(c,r),r.length=0)}o=l0(c,r)}return o}function T1(e){let t=Bt(e.g)>>>0;return x1(e.g,t)}function gu(e,t,r){var n=Bt(e.g)>>>0;for(n=e.g.g+n;e.g.g<n;)r.push(t(e.g))}var Ja=[];function V_(e){return e}var Ki;function I1(e,t,r){t.g?t.j(e,t.g,t.i,r):t.j(e,t.i,r)}var Ue=class{constructor(e,t){this.l=f1(e,t)}toJSON(){let e=!Ki;try{return e&&(Ki=N_),R1(this)}finally{e&&(Ki=void 0)}}u(){return!!(2&(0|this.l[se]))}};function R1(e){var t=e.l;{t=(e=Ki(t))!==t;let l=e.length;if(l){var r=e[l-1],n=Jd(r);n?l--:r=void 0;var i=e;if(n){e:{var o,s=r,a=!1;if(s)for(let h in s)isNaN(+h)?(o??={})[h]=s[h]:(n=s[h],Array.isArray(n)&&(tc(n)||m0(n)&&n.size===0)&&(n=null),n==null&&(a=!0),n!=null&&((o??={})[h]=n));if(a||(o=s),o)for(let h in o){a=o;break e}a=null}s=a==null?r!=null:a!==r}for(;l>0&&((o=i[l-1])==null||tc(o)||m0(o)&&o.size===0);l--)var c=!0;(i!==e||s||c)&&(t?(c||s||a)&&(i.length=l):i=Array.prototype.slice.call(i,0,l),a&&i.push(a)),c=i}else c=e}return c}function E0(e){return e?/^\d+$/.test(e)?(fc(e),new Hd(De,Ge)):null:H_||=new Hd(0,0)}Ue.prototype.B=Zo,Ue.prototype.toString=function(){try{return Ki=V_,R1(this).toString()}finally{Ki=void 0}};var Hd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},H_;function C0(e){return e?/^-?\d+$/.test(e)?(fc(e),new Wd(De,Ge)):null:W_||=new Wd(0,0)}var Wd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},W_;function Xi(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function ts(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function yc(e,t){if(t>=0)ts(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function ic(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 to(e,t){t.length!==0&&(e.j.push(t),e.i+=t.length)}function kr(e,t,r){ts(e.g,8*t+r)}function bc(e,t){return kr(e,t,2),t=e.g.end(),to(e,t),t.push(e.i),t}function vc(e,t){var r=t.pop();for(r=e.i+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.i++;t.push(r),e.i++}function _c(e,t,r){kr(e,t,2),ts(e.g,r.length),to(e,e.g.end()),to(e,r)}function Er(){let e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var yu=Er(),P1=Er(),bu=Er(),vu=Er(),D1=Er(),O1=Er(),B1=Er(),L1=Er(),ro=class{constructor(e,t,r){this.g=e,this.i=t,e=yu,this.j=!!e&&r===e||!1}};function _u(e,t){return new ro(e,t,yu)}function F1(e,t,r,n,i){(t=z1(t,n))!=null&&(r=bc(e,r),i(t,e),vc(e,r))}var $_=_u((function(e,t,r,n,i){return e.i===2&&(gc(e,lu(t,n,r),i),!0)}),F1),G_=_u((function(e,t,r,n,i){return e.i===2&&(gc(e,lu(t,n,r,!0),i),!0)}),F1),wc=Symbol(),wu=Symbol(),x0=Symbol(),A0=Symbol(),M1,U1;function Qn(e,t,r,n){var i=n[e];if(i)return i;(i={}).P=n,i.A=(function(d){switch(typeof d){case"boolean":return u1||=[0,void 0,!0];case"number":return d>0?void 0:d===0?z_||=[0,void 0]:[-d,void 0];case"string":return[0,d];case"object":return d}})(n[0]);var o=n[1];let s=1;o&&o.constructor===Object&&(i.H=o,typeof(o=n[++s])=="function"&&(i.I=!0,M1??=o,U1??=n[s+1],o=n[s+=2]));let a={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var c=0;c<o.length;c++)a[o[c]]=o;o=n[++s]}for(c=1;o!==void 0;){let d;typeof o=="number"&&(c+=o,o=n[++s]);var l=void 0;if(o instanceof ro?d=o:(d=$_,s--),d?.j){o=n[++s],l=n;var h=s;typeof o=="function"&&(o=o(),l[h]=o),l=o}for(h=c+1,typeof(o=n[++s])=="number"&&o<0&&(h-=o,o=n[++s]);c<h;c++){let m=a[c];l?r(i,c,d,l,m):t(i,c,d,m)}}return n[e]=i}function N1(e){return Array.isArray(e)?e[0]instanceof ro?e:[G_,e]:[e,void 0]}function z1(e,t){return e instanceof Ue?e.l:Array.isArray(e)?qo(e,t,!1):void 0}function Su(e,t,r,n){let i=r.g;e[t]=n?(o,s,a)=>i(o,s,a,n):i}function ku(e,t,r,n,i){let o=r.g,s,a;e[t]=(c,l,h)=>o(c,l,h,a||=Qn(wu,Su,ku,n).A,s||=Eu(n),i)}function Eu(e){let t=e[x0];if(t!=null)return t;let r=Qn(wu,Su,ku,e);return t=r.I?(n,i)=>M1(n,i,r):(n,i)=>{let o=0|n[se];for(;A1(i)&&i.i!=4;){var s=i.m,a=r[s];if(a==null){var c=r.H;c&&(c=c[s])&&(c=q_(c))!=null&&(a=r[s]=c)}a!=null&&a(i,n,s)||(s=(a=i).j,Za(a),a.G?a=void 0:(c=a.g.g-s,a.g.g=s,a=x1(a.g,c)),s=n,a&&((c=s[Qi])?c.push(a):s[Qi]=[a]))}return 16384&o&&qd(n,34),!0},e[x0]=t}function q_(e){let t=(e=N1(e))[0].g;if(e=e[1]){let r=Eu(e),n=Qn(wu,Su,ku,e).A;return(i,o,s)=>t(i,o,s,n,r)}return t}function Sc(e,t,r){e[t]=r.i}function kc(e,t,r,n){let i,o,s=r.i;e[t]=(a,c,l)=>s(a,c,l,o||=Qn(wc,Sc,kc,n).A,i||=j1(n))}function j1(e){let t=e[A0];if(!t){let r=Qn(wc,Sc,kc,e);t=(n,i)=>V1(n,i,r),e[A0]=t}return t}function V1(e,t,r){for(var n=0|e[se],i=512&n?0:-1,o=e.length,s=512&n?1:0,a=o+(256&n?-1:0);s<a;s++){let c=e[s];if(c==null)continue;let l=s-i,h=T0(r,l);h&&h(t,c,l)}if(256&n){n=e[o-1];for(let c in n)i=+c,Number.isNaN(i)||(o=n[i])!=null&&(a=T0(r,i))&&a(t,o,i)}if(e=Yd(e))for(to(t,t.g.end()),r=0;r<e.length;r++)to(t,Gd(e[r])||new Uint8Array(0))}function T0(e,t){var r=e[t];if(r)return r;if((r=e.H)&&(r=r[t])){var n=(r=N1(r))[0].i;if(r=r[1]){let i=j1(r),o=Qn(wc,Sc,kc,r).A;r=e.I?U1(o,i):(s,a,c)=>n(s,a,c,o,i)}else r=n;return e[t]=r}}function Ec(e,t){if(Array.isArray(t)){var r=0|t[se];if(4&r)return t;for(var n=0,i=0;n<t.length;n++){let o=e(t[n]);o!=null&&(t[i++]=o)}return i<n&&(t.length=i),ct(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}function wt(e,t,r){return new ro(e,t,r)}function Cc(e,t,r){return new ro(e,t,r)}function St(e,t,r){lt(e,0|e[se],t,r)}function H1(e,t,r){if(t=(function(n){if(n==null)return n;let i=typeof n;if(i==="bigint")return String(s1(64,n));if(ru(n)){if(i==="string")return c1(n);if(i==="number")return a1(n)}})(t),t!=null&&(typeof t=="string"&&C0(t),t!=null))switch(kr(e,r,0),typeof t){case"number":e=e.g,eo(t),Xi(e,De,Ge);break;case"bigint":r=BigInt.asUintN(64,t),r=new Wd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=C0(t),Xi(e.g,r.i,r.g)}}function W1(e,t,r){(t=Xn(t))!=null&&t!=null&&(kr(e,r,0),yc(e.g,t))}function $1(e,t,r){(t=t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0)!=null&&(kr(e,r,0),e.g.g.push(t?1:0))}function G1(e,t,r){(t=Sn(t))!=null&&_c(e,r,G0(t))}function q1(e,t,r,n,i){(t=z1(t,n))!=null&&(r=bc(e,r),i(t,e),vc(e,r))}function K1(e,t,r){(t=t==null||typeof t=="string"||hc(t)||t instanceof wn?t:void 0)!=null&&_c(e,r,uu(t).buffer)}var K_=wt((function(e,t,r){if(e.i!==1)return!1;var n=e.g;e=jd(n);let i=jd(n);n=2*(i>>31)+1;let o=i>>>20&2047;return e=4294967296*(1048575&i)+e,St(t,r,o==2047?e?NaN:n*(1/0):o==0?5e-324*n*e:n*Math.pow(2,o-1075)*(e+4503599627370496)),!0}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,1),e=e.g,(r=i1||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),De=r.getUint32(0,!0),Ge=r.getUint32(4,!0),ic(e,De),ic(e,Ge))}),Er()),X1=wt((function(e,t,r){return e.i===5&&(St(t,r,Vd(e.g)),!0)}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,5),e=e.g,o1(t),ic(e,De))}),O1),X_=Cc((function(e,t,r){return(e.i===5||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?gu(e,Vd,t):t.push(Vd(e.g)),!0)}),(function(e,t,r){if((t=Ec(Qo,t))!=null&&t.length){kr(e,r,2),ts(e.g,4*t.length);for(let n=0;n<t.length;n++)r=e.g,o1(t[n]),ic(r,De)}}),O1),oc=wt((function(e,t,r){return e.i===0&&(St(t,r,fu(e.g,eu)),!0)}),H1,D1),Bd=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=fu(e.g,eu))===0?void 0:e),!0)}),H1,D1),J_=wt((function(e,t,r){return e.i===0&&(St(t,r,fu(e.g,Qd)),!0)}),(function(e,t,r){if((t=M_(t))!=null&&(typeof t=="string"&&E0(t),t!=null))switch(kr(e,r,0),typeof t){case"number":e=e.g,eo(t),Xi(e,De,Ge);break;case"bigint":r=BigInt.asUintN(64,t),r=new Hd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=E0(t),Xi(e.g,r.i,r.g)}}),Er()),En=wt((function(e,t,r){return e.i===0&&(St(t,r,Bt(e.g)),!0)}),W1,vu),Cu=Cc((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?gu(e,Bt,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=Ec(Xn,t))!=null&&t.length){r=bc(e,r);for(let n=0;n<t.length;n++)yc(e.g,t[n]);vc(e,r)}}),vu),Gi=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g))===0?void 0:e),!0)}),W1,vu),Wt=wt((function(e,t,r){return e.i===0&&(St(t,r,pu(e.g)),!0)}),$1,P1),Ji=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=pu(e.g))===!1?void 0:e),!0)}),$1,P1),sr=Cc((function(e,t,r){return e.i===2&&(e=mu(e),es(t,0|t[se],r,!1).push(e),!0)}),(function(e,t,r){if((t=Ec(Sn,t))!=null)for(let s=0;s<t.length;s++){var n=e,i=r,o=t[s];o!=null&&_c(n,i,G0(o))}}),bu),_n=wt((function(e,t,r){return e.i===2&&(St(t,r,(e=mu(e))===""?void 0:e),!0)}),G1,bu),Ze=wt((function(e,t,r){return e.i===2&&(St(t,r,mu(e)),!0)}),G1,bu),ar=(function(e,t,r=yu){return new ro(e,t,r)})((function(e,t,r,n,i){return e.i===2&&(n=qo(void 0,n,!0),es(t,0|t[se],r,!0).push(n),gc(e,n,i),!0)}),(function(e,t,r,n,i){if(Array.isArray(t))for(let o=0;o<t.length;o++)q1(e,t[o],r,n,i)})),ft=_u((function(e,t,r,n,i,o){return e.i===2&&(v1(t,0|t[se],o,r),gc(e,t=lu(t,n,r),i),!0)}),q1),J1=wt((function(e,t,r){return e.i===2&&(St(t,r,T1(e)),!0)}),K1,B1),Y_=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g)>>>0)===0?void 0:e),!0)}),(function(e,t,r){t=(function(n){if(n==null)return n;if(typeof n=="string"&&n)n=+n;else if(typeof n!="number")return;return pc(n)?n>>>0:void 0})(t),t!=null&&t!=null&&(kr(e,r,0),ts(e.g,t))}),Er()),Jn=wt((function(e,t,r){return e.i===0&&(St(t,r,Bt(e.g)),!0)}),(function(e,t,r){(t=Xn(t))!=null&&(t=parseInt(t,10),kr(e,r,0),yc(e.g,t))}),L1),sc=class{constructor(t,r){this.i=t,this.g=r,this.j=Sr,this.defaultValue=void 0}};function Y1(e,t){return(r,n)=>{if(Ja.length){let o=Ja.pop();o.o(n),Od(o.g,r,n),r=o}else r=new class{constructor(o,s){if(k0.length){let a=k0.pop();Od(a,o,s),o=a}else o=new class{constructor(a,c){this.i=null,this.m=!1,this.g=this.j=this.s=0,Od(this,a,c)}clear(){this.i=null,this.m=!1,this.g=this.j=this.s=0,this.C=!1}}(o,s);this.g=o,this.j=this.g.g,this.i=this.m=-1,this.o(s)}o({G:o=!1}={}){this.G=o}}(r,n);try{let o=new e,s=o.l;Eu(t)(s,r);var i=o}finally{r.g.clear(),r.m=-1,r.i=-1,Ja.length<100&&Ja.push(r)}return i}}var I0=[0,_n,wt((function(e,t,r){return e.i===2&&(St(t,r,(e=T1(e))===Zi()?void 0:e),!0)}),(function(e,t,r){if(t!=null){if(t instanceof Ue){let n=t.R;return void(n&&(t=n(t),t!=null&&_c(e,r,uu(t).buffer)))}if(Array.isArray(t))return}K1(e,t,r)}),B1)],Ld,R0=globalThis.trustedTypes;function P0(e){Ld===void 0&&(Ld=(function(){let r=null;if(!R0)return r;try{let n=i=>i;r=R0.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r})());var t=Ld;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function Z_(e,...t){if(t.length===0)return P0(e[0]);let r=e[0];for(let n=0;n<t.length;n++)r+=encodeURIComponent(t[n])+e[n+1];return P0(r)}var Z1=[0,En,Jn,Wt,-1,Cu,Jn,-1],Q_=class extends Ue{constructor(e){super(e)}},Q1=[0,Wt,Ze,Wt,Jn,-1,Cc((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?gu(e,j_,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=Ec(Xn,t))!=null&&t.length){r=bc(e,r);for(let n=0;n<t.length;n++)yc(e.g,t[n]);vc(e,r)}}),L1),Ze,-1,[0,Wt,-1],Jn,Wt,-1],e2=[0,Ze,-2],D0=class extends Ue{constructor(e){super(e)}},t2=[0],r2=[0,En,Wt,1,Wt,-3],n2=class extends Ue{constructor(e){super(e,2)}},xc={};xc[336783863]=[0,Ze,Wt,-1,En,[0,[1,2,3,4,5,6,7,8],ft,t2,ft,Q1,ft,e2,ft,r2,ft,Z1,ft,[0,Ze,-2],ft,[0,Ze,Jn],ft,[0,Jn,Ze]],[0,Ze],Wt,[0,[1,3],[2,4],ft,[0,Cu],-1,ft,[0,sr],-1,ar,[0,Ze,-1]],Ze];var O0,B0=[0,Bd,-1,Ji,-3,Bd,Cu,_n,Gi,Bd,-1,Ji,Gi,Ji,-2,_n],xu=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,7,e)}},Ko=[-1,{}],L0=[0,Ze,1,Ko],F0=[0,Ze,sr,Ko],Au=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,1001,e)}};Au.prototype.g=(O0=[-500,ar,[-500,_n,-1,sr,-3,[-2,xc,Wt],ar,I0,Gi,-1,L0,F0,ar,[0,_n,Ji],_n,B0,Gi,sr,987,sr],4,ar,[-500,Ze,-1,[-1,{}],998,Ze],ar,[-500,Ze,sr,-1,[-2,{},Wt],997,sr,-1],Gi,ar,[-500,Ze,sr,Ko,998,sr],sr,Gi,L0,F0,ar,[0,_n,-1,Ko],sr,-2,B0,_n,-1,Ji,[0,Ji,Y_],978,Ko,ar,I0],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 o=this.g;return this.g=[],o}}}};V1(this.l,e,Qn(wc,Sc,kc,O0)),to(e,e.g.end());let t=new Uint8Array(e.i),r=e.j,n=r.length,i=0;for(let o=0;o<n;o++){let s=r[o];t.set(s,i),i+=s.length}return e.j=[t],t});var e3=class extends Ue{constructor(e){super(e)}},t3=class extends Ue{constructor(e){super(e)}g(){return hu(this,e3)}},r3=[0,ar,[0,En,X1,Ze,-1]],M0=class extends Ue{constructor(e){super(e)}},U0=class extends Ue{constructor(e){super(e)}},i2=[1,2,3,4,5],ac=class extends Ue{constructor(e){super(e)}g(){return g1(this)!=null}i(){return Sn(_r(this,2))!=null}},cc=class extends Ue{constructor(e){super(e)}},o2=class extends Ue{constructor(e){super(e)}},s2=[0,[0,J1,Ze,[0,En,oc,-1],[0,J_,oc]],Wt,[0,i2,ft,r2,ft,Q1,ft,Z1,ft,t2,ft,e2],Jn],n3=new sc(451755788,o2);xc[451755788]=[0,s2,[0,Ze,En,X1,sr,-1],K_];var N0=class extends Ue{constructor(e){super(e)}},a2=class extends Ue{constructor(e){super(e)}},i3=new sc(487277289,a2);xc[487277289]=[0,s2,[0,Wt,-1]];var o3=class extends Ue{constructor(e){super(e)}},s3=Y1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,1,En,Ze,r3],oc]),z0=class extends Ue{constructor(e){super(e)}},a3=class extends Ue{constructor(e){super(e)}J(){let e=g1(this);return e??Zi()}},c3=class extends Ue{constructor(e){super(e)}},c2=[1,2],j0=Y1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,c2,ft,[0,X_],ft,[0,J1],En,Ze],oc]);function l3(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!(function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")})(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function V0(e){if(typeof importScripts!="function"){let t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((r,n)=>{t.addEventListener("load",(()=>{r()}),!1),t.addEventListener("error",(i=>{n(i)}),!1),document.body.appendChild(t)}))}importScripts(e.toString())}function ie(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 H0(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");let n=new Uint32Array(t.length);for(let i=0;i<t.length;i++)n[i]=e.h.stringToNewUTF8(t[i]);t=e.h._malloc(4*n.length),e.h.HEAPU32.set(n,t>>2),r(t);for(let i of n)e.h._free(i);e.h._free(t)}function yn(e,t,r){e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=r}function Gn(e,t,r){let n=[];e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=(i,o,s)=>{o?(r(n,s),n=[]):n.push(i)}}var h3=(function(e){return class extends e{N(){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:l3()?this.h.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas"))}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,n=this.h._malloc(r);this.h.HEAPU8.set(e,n),t?this.h._changeBinaryGraph(r,n):this.h._changeTextGraph(r,n),this.h._free(n)}configureAudio(e,t,r,n,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),ie(this,n||"input_audio",(o=>{ie(this,i=i||"audio_header",(s=>{this.h._configureAudio(o,s,e,t??0,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,n,i){let o=4*e.length;this.i!==o&&(this.g&&this.h._free(this.g),this.g=this.h._malloc(o),this.i=o),this.h.HEAPF32.set(e,this.g/4),ie(this,n,(s=>{this.h._addAudioToInputStream(this.g,t,r,s,i)}))}addGpuBufferToStream(e,t,r){ie(this,t,(n=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");n?this.h._bindTextureToStream(n):this.h._bindTextureToCanvas();let i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);let[o,s]=e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height];!this.j||o===this.h.canvas.width&&s===this.h.canvas.height||(this.h.canvas.width=o,this.h.canvas.height=s);let[a,c]=[o,s];this.h._addBoundTextureToStream(n,a,c,r)}))}addBoolToStream(e,t,r){ie(this,t,(n=>{this.h._addBoolToInputStream(e,n,r)}))}addDoubleToStream(e,t,r){ie(this,t,(n=>{this.h._addDoubleToInputStream(e,n,r)}))}addFloatToStream(e,t,r){ie(this,t,(n=>{this.h._addFloatToInputStream(e,n,r)}))}addIntToStream(e,t,r){ie(this,t,(n=>{this.h._addIntToInputStream(e,n,r)}))}addUintToStream(e,t,r){ie(this,t,(n=>{this.h._addUintToInputStream(e,n,r)}))}addStringToStream(e,t,r){ie(this,t,(n=>{ie(this,e,(i=>{this.h._addStringToInputStream(i,n,r)}))}))}addStringRecordToStream(e,t,r){ie(this,t,(n=>{H0(this,Object.keys(e),(i=>{H0(this,Object.values(e),(o=>{this.h._addFlatHashMapToInputStream(i,o,Object.keys(e).length,n,r)}))}))}))}addProtoToStream(e,t,r,n){ie(this,r,(i=>{ie(this,t,(o=>{let s=this.h._malloc(e.length);this.h.HEAPU8.set(e,s),this.h._addProtoToInputStream(s,e.length,o,i,n),this.h._free(s)}))}))}addEmptyPacketToStream(e,t){ie(this,e,(r=>{this.h._addEmptyPacketToInputStream(r,t)}))}addBoolVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.h._addBoolVectorEntry(i,o);this.h._addBoolVectorToInputStream(i,n,r)}))}addDoubleVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.h._addDoubleVectorEntry(i,o);this.h._addDoubleVectorToInputStream(i,n,r)}))}addFloatVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.h._addFloatVectorEntry(i,o);this.h._addFloatVectorToInputStream(i,n,r)}))}addIntVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.h._addIntVectorEntry(i,o);this.h._addIntVectorToInputStream(i,n,r)}))}addUintVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let o of e)this.h._addUintVectorEntry(i,o);this.h._addUintVectorToInputStream(i,n,r)}))}addStringVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let o of e)ie(this,o,(s=>{this.h._addStringVectorEntry(i,s)}));this.h._addStringVectorToInputStream(i,n,r)}))}addBoolToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addBoolToInputSidePacket(e,r)}))}addDoubleToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addDoubleToInputSidePacket(e,r)}))}addFloatToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addFloatToInputSidePacket(e,r)}))}addIntToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addIntToInputSidePacket(e,r)}))}addUintToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addUintToInputSidePacket(e,r)}))}addStringToInputSidePacket(e,t){ie(this,t,(r=>{ie(this,e,(n=>{this.h._addStringToInputSidePacket(n,r)}))}))}addProtoToInputSidePacket(e,t,r){ie(this,r,(n=>{ie(this,t,(i=>{let o=this.h._malloc(e.length);this.h.HEAPU8.set(e,o),this.h._addProtoToInputSidePacket(o,e.length,i,n),this.h._free(o)}))}))}addBoolVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let i of e)this.h._addBoolVectorEntry(n,i);this.h._addBoolVectorToInputSidePacket(n,r)}))}addDoubleVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let i of e)this.h._addDoubleVectorEntry(n,i);this.h._addDoubleVectorToInputSidePacket(n,r)}))}addFloatVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let i of e)this.h._addFloatVectorEntry(n,i);this.h._addFloatVectorToInputSidePacket(n,r)}))}addIntVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let i of e)this.h._addIntVectorEntry(n,i);this.h._addIntVectorToInputSidePacket(n,r)}))}addUintVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let i of e)this.h._addUintVectorEntry(n,i);this.h._addUintVectorToInputSidePacket(n,r)}))}addStringVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let i of e)ie(this,i,(o=>{this.h._addStringVectorEntry(n,o)}));this.h._addStringVectorToInputSidePacket(n,r)}))}attachBoolListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachBoolListener(r)}))}attachBoolVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachBoolVectorListener(r)}))}attachIntListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachIntListener(r)}))}attachIntVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachIntVectorListener(r)}))}attachUintListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachUintListener(r)}))}attachUintVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachUintVectorListener(r)}))}attachDoubleListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachDoubleListener(r)}))}attachDoubleVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachDoubleVectorListener(r)}))}attachFloatListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachFloatListener(r)}))}attachFloatVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachFloatVectorListener(r)}))}attachStringListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachStringListener(r)}))}attachStringVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachStringVectorListener(r)}))}attachProtoListener(e,t,r){yn(this,e,t),ie(this,e,(n=>{this.h._attachProtoListener(n,r||!1)}))}attachProtoVectorListener(e,t,r){Gn(this,e,t),ie(this,e,(n=>{this.h._attachProtoVectorListener(n,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?'),yn(this,e,((n,i)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,i)})),ie(this,e,(n=>{this.h._attachAudioListener(n,r||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}}),l2=class extends h3{};async function d3(e,t,r){return e=await(async(n,i,o,s)=>{if(i&&await V0(i),!self.ModuleFactory||o&&(await V0(o),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&s&&((i=self.Module).locateFile=s.locateFile,s.mainScriptUrlOrBlob&&(i.mainScriptUrlOrBlob=s.mainScriptUrlOrBlob)),s=await self.ModuleFactory(self.Module||s),self.ModuleFactory=self.Module=void 0,new n(s,null)})(e,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:n=>n.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&n.endsWith(".data")?t.assetBinaryPath.toString():n}),await e.o(r),e}async function h2(e,t,r){return d3(e,t,r)}function Fd(e,t){let r=wr(e.baseOptions,ac,1)||new ac;typeof t=="string"?(pt(r,2,nc(t)),pt(r,1)):t instanceof Uint8Array&&(pt(r,1,r1(t,!1)),pt(r,2)),Sr(e.baseOptions,0,1,r)}function d2(e,t){let r=t.baseOptions||{};if(t.baseOptions?.modelAssetBuffer&&t.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(wr(e.baseOptions,ac,1)?.g()||wr(e.baseOptions,ac,1)?.i()||t.baseOptions?.modelAssetBuffer||t.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if((function(n,i){let o=wr(n.baseOptions,U0,3);if(!o){var s=o=new U0;Dd(s,4,new D0)}"delegate"in i&&(i.delegate==="GPU"?Dd(i=o,2,s=new Q_):Dd(i=o,4,s=new D0)),Sr(n.baseOptions,0,3,o)})(e,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then((n=>{if(n.ok)return n.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${n.status})`)})).then((n=>{try{e.g.h.FS_unlink("/model.dat")}catch{}e.g.h.FS_createDataFile("/","model.dat",new Uint8Array(n),!0,!1,!1),Fd(e,"/model.dat"),e.v()}));if(r.modelAssetBuffer instanceof Uint8Array)Fd(e,r.modelAssetBuffer);else if(r.modelAssetBuffer)return(async function(n){let i=[];for(var o=0;;){let{done:s,value:a}=await n.read();if(s)break;i.push(a),o+=a.length}if(i.length===0)return new Uint8Array(0);if(i.length===1)return i[0];n=new Uint8Array(o),o=0;for(let s of i)n.set(s,o),o+=s.length;return n})(r.modelAssetBuffer).then((n=>{Fd(e,n),e.v()}));return e.v(),Promise.resolve()}function W0(e){try{let t=e.j.length;if(t===1)throw Error(e.j[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.j.map((r=>r.message)).join(", "))}finally{e.j=[]}}function qi(e,t){e.s=Math.max(e.s,t)}var Qa=class{constructor(e){this.g=e,this.j=[],this.s=0,this.g.setAutoRenderToScreen(!1)}setGraph(e,t){this.g.attachErrorListener(((r,n)=>{this.j.push(Error(n))})),this.g.N(),this.g.setGraph(e,t),W0(this)}finishProcessing(){this.g.finishProcessing(),W0(this)}close(){this.g.closeGraph()}};async function Xo(e,t,r){return h2(e,t,r)}Qa.prototype.close=Qa.prototype.close,(function(e,t){e=e.split(".");var r,n=Kn;for((e[0]in n)||n.execScript===void 0||n.execScript("var "+e[0]);e.length&&(r=e.shift());)e.length||t===void 0?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=t})("TaskRunner",Qa);var lc=class extends Qa{constructor(){super(...arguments),this.F=48e3}O(e){this.F=e}};function u3(e){let t={classifications:hu(e,o3).map((r=>(function(n,i=-1,o=""){return{categories:n.map((s=>{var a=Xn(_r(s,1))??0??-1;let c=s.l,l=0|c[se],h=Zn(c,l,2),d=Qo(h);return d!=null&&d!==h&<(c,l,2,d),{index:a,score:d??0??0,categoryName:Sn(_r(s,3))??""??"",displayName:Sn(_r(s,4))??""??""}})),headIndex:i,headName:o}})(wr(r,t3,4)?.g()??[],Xn(_r(r,2))??0,Sn(_r(r,3))??"")))};return zd(_r(e,2))!=null&&(t.timestampMs=zd(_r(e,2))??0),t}lc.prototype.setDefaultSampleRate=lc.prototype.O;var or=class extends lc{constructor(e,t){super(new l2(e,t)),this.m=[],Sr(e=this.i=new o2,0,1,t=new cc)}get baseOptions(){return wr(this.i,cc,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,M0,2);if(r=r?m1(r):new M0,e.displayNamesLocale!==void 0?pt(r,1,nc(e.displayNamesLocale)):e.displayNamesLocale===void 0&&pt(r,1),e.maxResults!==void 0){var n=e.maxResults;if(n!=null){if(typeof n!="number"||!pc(n))throw p0();n|=0}pt(r,2,n)}else"maxResults"in e&&pt(r,2);if(e.scoreThreshold!==void 0){if((n=e.scoreThreshold)!=null&&typeof n!="number")throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);pt(r,3,n)}else"scoreThreshold"in e&&pt(r,3);return e.categoryAllowlist!==void 0?S0(r,4,e.categoryAllowlist):"categoryAllowlist"in e&&pt(r,4),e.categoryDenylist!==void 0?S0(r,5,e.categoryDenylist):"categoryDenylist"in e&&pt(r,5),Sr(t,0,2,r),d2(this,e)}K(e,t){return this.D(e,t??this.F,this.s+1)}D(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]}v(){var e=new Au;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"timestamped_classifications");let t=new n2;I1(t,n3,this.i);let r=new xu;b1(r,nc("mediapipe.tasks.audio.audio_classifier.AudioClassifierGraph")),Ot(r,3,"AUDIO:audio_in"),Ot(r,3,"SAMPLE_RATE:sample_rate"),Ot(r,4,"TIMESTAMPED_CLASSIFICATIONS:timestamped_classifications"),r.o(t),S1(e,r),this.g.attachProtoVectorListener("timestamped_classifications",((n,i)=>{(function(o,s){s.forEach((a=>{a=s3(a),o.m.push(u3(a))}))})(this,n),qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_classifications",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function $0(e){return{embeddings:hu(e,c3).map((t=>{let r={headIndex:Xn(_r(t,3))??0??-1,headName:Sn(_r(t,4))??""??""};if(_1(t,z0,Pd(t,1))!==void 0)r.floatEmbedding=y1(wr(t,z0,Pd(t,1)),1,Qo,n1===void 0?2:4).slice();else{let n=new Uint8Array(0);r.quantizedEmbedding=wr(t,a3,Pd(t,2))?.J()?.i()??n}return r})),timestampMs:zd(_r(e,2))??0}}or.prototype.classify=or.prototype.K,or.prototype.setOptions=or.prototype.o,or.createFromModelPath=function(e,t){return h2(or,e,{baseOptions:{modelAssetPath:t}})},or.createFromModelBuffer=function(e,t){return Xo(or,e,{baseOptions:{modelAssetBuffer:t}})},or.createFromOptions=function(e,t){return Xo(or,e,t)};var Mr=class extends lc{constructor(e,t){super(new l2(e,t)),this.m=[],Sr(e=this.i=new a2,0,1,t=new cc)}get baseOptions(){return wr(this.i,cc,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,N0,2);return r=r?m1(r):new N0,e.l2Normalize!==void 0?pt(r,1,_0(e.l2Normalize)):"l2Normalize"in e&&pt(r,1),e.quantize!==void 0?pt(r,2,_0(e.quantize)):"quantize"in e&&pt(r,2),Sr(t,0,2,r),d2(this,e)}L(e,t){return this.D(e,t??this.F,this.s+1)}D(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}v(){var e=new Au;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"embeddings_out"),Ot(e,15,"timestamped_embeddings_out");let t=new n2;I1(t,i3,this.i);let r=new xu;b1(r,nc("mediapipe.tasks.audio.audio_embedder.AudioEmbedderGraph")),Ot(r,3,"AUDIO:audio_in"),Ot(r,3,"SAMPLE_RATE:sample_rate"),Ot(r,4,"EMBEDDINGS:embeddings_out"),Ot(r,4,"TIMESTAMPED_EMBEDDINGS:timestamped_embeddings_out"),r.o(t),S1(e,r),this.g.attachProtoListener("embeddings_out",((n,i)=>{n=j0(n),this.m.push($0(n)),qi(this,i)})),this.g.attachEmptyPacketListener("embeddings_out",(n=>{qi(this,n)})),this.g.attachProtoVectorListener("timestamped_embeddings_out",((n,i)=>{for(let o of n)n=j0(o),this.m.push($0(n));qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_embeddings_out",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}},Ya;Mr.prototype.embed=Mr.prototype.L,Mr.prototype.setOptions=Mr.prototype.o,Mr.createFromModelPath=function(e,t){return Xo(Mr,e,{baseOptions:{modelAssetPath:t}})},Mr.createFromModelBuffer=function(e,t){return Xo(Mr,e,{baseOptions:{modelAssetBuffer:t}})},Mr.createFromOptions=function(e,t){return Xo(Mr,e,t)};var f3=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 u2(){if(Ya===void 0)try{await WebAssembly.instantiate(f3),Ya=!0}catch{Ya=!1}return Ya}async function Wo(e,t=Z_``){let r=await u2()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var bn=class{};bn.forVisionTasks=function(e){return Wo("vision",e)},bn.forTextTasks=function(e){return Wo("text",e)},bn.forGenAiExperimentalTasks=function(e){return Wo("genai_experimental",e)},bn.forGenAiTasks=function(e){return Wo("genai",e)},bn.forAudioTasks=function(e){return Wo("audio",e)},bn.isSimdSupported=function(){return u2()};function p3(e,t){let r=e.reduce((a,c)=>a+c.length,0),n=new ArrayBuffer(44+r*2),i=new DataView(n),o=(a,c,l)=>{for(let h=0;h<l.length;h++)a.setUint8(c+h,l.charCodeAt(h))};o(i,0,"RIFF"),i.setUint32(4,36+r*2,!0),o(i,8,"WAVE"),o(i,12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),o(i,36,"data"),i.setUint32(40,r*2,!0);let s=44;for(let a of e)for(let c=0;c<a.length;c++){let l=Math.max(-1,Math.min(1,a[c]));i.setInt16(s,l<0?l*32768:l*32767,!0),s+=2}return new Blob([i],{type:"audio/wav"})}var Ac=class{constructor(t,r,n,i,o,s,a){this.recordingInProgress=!1;this.recordIndex=1;this.countLoopTimes=0;this.examStartTime=0;this.recordingStartTime=0;this.recordingEndTime=0;this.isSpeech=!1;this.preRollBuffer=[];this.recordingChunks=[];this.PRE_ROLL_SECONDS=2;this.SAMPLE_RATE=16e3;this.MAX_PRE_ROLL_CHUNKS=4;this.lastNoiseTime=0;this.SILENCE_THRESHOLD=3e3;this.optionsProctoring=t,this.proctoringSession=r,this.paramsConfig=n,this.cameraRecorder=i,this.onRealtimeAlertsCallback=o,this.backend=s,this.backendToken=a}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Yr(this.proctoringId,this.backend))}async startRecording(){this.examStartTime=Date.now(),await this.createAudioClassifier(),this.audioRecorder=new Ga(void 0,this.paramsConfig.audioBehaviourParameters),this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetectedRecord(),200),this.streamingAudioClassification()}async stopRecording(){clearInterval(this.intervalNoiseDetection),await this.stopSoundRecord(),await this.volumeMeter&&this.volumeMeter.stop(),this.audioWorkletNode&&this.audioWorkletNode.disconnect()}async pauseRecording(){}async resumeRecording(){}async saveOnSession(t){}async onNoiseDetectedRecord(){!this.volumeMeter&&this.cameraRecorder.cameraStream&&(this.volumeMeter=new gn(this.cameraRecorder.cameraStream),this.volumeMeter.start().catch(i=>{console.log(i),this.volumeMeter=void 0}));let t=this.paramsConfig.audioBehaviourParameters?.noiseLimit||40,r=this.volumeMeter?.getVolume()||0;this.isSpeech=this.isSpeech||this.hasDesiredResult(this.audioClassificationResult),!this.isSpeech&&!this.recordingInProgress&&(t=t*1.25);let n=r>=t;if(n&&(this.lastNoiseTime=Date.now()),n&&!this.recordingInProgress){this.recordingInProgress=!0,this.recordingChunks=[...this.preRollBuffer];let o=this.preRollBuffer.reduce((a,c)=>a+c.length,0)/this.SAMPLE_RATE*1e3,s=Date.now()-this.examStartTime;this.recordingStartTime=s-o,this.recordingStartTime<0&&(this.recordingStartTime=0)}else if(this.recordingInProgress){let i=Date.now()-this.lastNoiseTime,o=Date.now()-this.recordingStartTime;i>=this.SILENCE_THRESHOLD&&o>=3e3&&this.countLoopTimes>4&&(await this.stopSoundRecord(),this.paramsConfig.videoBehaviourParameters?.detectNoise&&!this.isSpeech&&this.onRealtimeAlertsCallback({status:"ALERT",description:"Barulho detectado",type:"audio_detection_on_stream"}),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(!this.recordingInProgress&&this.recordingChunks.length===0||(this.recordingEndTime=Date.now()-this.examStartTime,this.optionsProctoring.proctoringType!=="REALTIME"))return;let t=p3(this.recordingChunks,this.SAMPLE_RATE),r=new File([t],`EP_${this.proctoringSession.id}_${this.recordingStartTime}_${this.recordingEndTime}_${this.isSpeech?"speech":"noise"}.wav`,{type:"audio/wav"});this.uploadRecord(r),this.recordingChunks=[],this.recordingInProgress=!1}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}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){let n=r.name.toLowerCase().includes("speech");if(this.optionsProctoring.proctoringType!=="REALTIME")return n;let i=parseFloat(r.score)>.22;if(n&&i)return!0}return!1}async createAudioClassifier(){let t=await bn.forAudioTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-audio@0.10.0/wasm");this.audioClassifier=await or.createFromOptions(t,{scoreThreshold:.15,maxResults:1,baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/1/yamnet.tflite"}})}async streamingAudioClassification(){this.context=new AudioContext({sampleRate:this.SAMPLE_RATE});try{await this.context.audioWorklet.addModule(URL.createObjectURL(new Blob([m3],{type:"text/javascript"})))}catch{throw new Error("\u274C Error loading audio worklet module")}let t=this.context.createMediaStreamSource(this.cameraRecorder.cameraStream);this.audioWorkletNode=new AudioWorkletNode(this.context,"audio-processor"),this.audioWorkletNode.port.onmessage=r=>{let n=r.data;this.preRollBuffer.push(n),this.preRollBuffer.length>this.MAX_PRE_ROLL_CHUNKS&&this.preRollBuffer.shift(),this.recordingInProgress&&this.recordingChunks.push(n);let o=this.audioClassifier.classify(n)[0].classifications[0].categories;o.length>0&&(this.audioClassificationResult=[{name:o[0].categoryName,score:o[0].score.toFixed(3)}])},t.connect(this.audioWorkletNode),this.audioWorkletNode.connect(this.context.destination)}},m3=`
|
|
437
|
+
Size: ${t.file.size}`,s),o}}throw new Error("Could not upload")}};var $a=class{constructor(t,r){this.alerts=[];this.lastActivityTime=Date.now();this.IDLE_THRESHOLD_MS=3e4;this.handleVisibilityChange=()=>{document.visibilityState==="visible"?this.handleReturnFocus():this.handleLostFocus()};this.handleLostFocus=()=>{if(this.getRelativeTime()>1e4){let t={begin:this.getRelativeTime(),end:0,alert:25,type:3};this.onLostFocusCallback(t),this.alerts.push(t)}};this.handleReturnFocus=()=>{let t=this.alerts[this.alerts.length-1];t&&(this.onFocusCallback({begin:t.begin,end:this.getRelativeTime(),alert:25,type:3}),t.end=this.getRelativeTime())};this.handleResize=()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{let t=window.screen.availWidth,r=window.outerWidth;if(r<t*.85){let n=`Split Screen Detectado: Janela ocupa ${(r/t*100).toFixed(0)}% da tela`;this.createAlert(43,3,n),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:n,type:"split_screen"})}},1e3)};this.handleUserActivity=t=>{this.lastActivityTime=Date.now(),console.log("\u{1F449} handleUserActivity",t)};this.handleCopy=t=>{t.preventDefault();let r="Tentativa de Copiar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_copy"})};this.handleCut=t=>{t.preventDefault();let r="Tentativa de Recortar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_cut"})};this.handlePaste=t=>{t.preventDefault();let r="Tentativa de Colar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_paste"})};this.onLostFocusCallback=t.onLostFocusCallback,this.onFocusCallback=t.onFocusCallback,this.onRealtimeAlertCallback=t.onRealtimeAlertCallback,this.optionsProctoring=r}async startRecording(){this.startTime=new Date(Date.now()),this.alerts=[],this.attachListeners()}async pauseRecording(){this.detachListeners()}async resumeRecording(){this.attachListeners()}async stopRecording(){this.detachListeners()}async saveOnSession(t){this.alerts.forEach(r=>{t.addAlert(r)})}attachListeners(){this.optionsProctoring.captureScreen&&(window.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("resize",this.handleResize),window.document.addEventListener("copy",this.handleCopy),window.document.addEventListener("cut",this.handleCut),window.document.addEventListener("paste",this.handlePaste))}detachListeners(){window.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("resize",this.handleResize),window.document.removeEventListener("copy",this.handleCopy),window.document.removeEventListener("cut",this.handleCut),window.document.removeEventListener("paste",this.handlePaste)}addBackgroundEvent(t,r=200){this.createAlert(r,3,t),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:t,type:"background_event"})}getRelativeTime(){return Date.now()-this.startTime.getTime()}createAlert(t,r,n){this.alerts.push({begin:this.getRelativeTime(),end:this.getRelativeTime(),alert:t,type:r})}addAlert({alert:t,type:r}){this.alerts.push({begin:Date.now()-this.startTime.getTime(),end:Date.now()-this.startTime.getTime(),alert:t,type:r})}};var Ga=class{constructor(t,r){this.blobs=[];this.options={cameraId:void 0,microphoneId:void 0};this.audioParams={recordingBitrate:128};r&&(this.audioParams=r),t&&(this.options=t)}async startRecording(){let t={audio:{deviceId:this.options.microphoneId||"default"}};this.audioStream=await navigator.mediaDevices.getUserMedia(t);let{startRecording:r,stopRecording:n,pauseRecording:i,resumeRecording:o}=Wn(this.audioStream,this.blobs,null,void 0,void 0,!0);this.recordingStart=r,this.recordingStop=n,this.recordingPause=i,this.recordingResume=o,this.recordingStart()}async pauseRecording(){}async resumeRecording(){}async stopRecording(){this.recordingStop&&await this.recordingStop()}async saveOnSession(t,r,n){t.addRecording({device:"",file:new File(this.blobs,`EP_${t.id}_audio_${r&&n&&`${r}_${n}`||"0"}.webm`,{type:"audio/webm"}),origin:"Mic"})}};var Kn=typeof self<"u"?self:{};function $n(){throw Error("Invalid UTF8")}function l0(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var qa,Ad,y_=typeof TextDecoder<"u",b_,v_=typeof TextEncoder<"u";function G0(e){if(v_)e=(b_||=new TextEncoder).encode(e);else{let r=0,n=new Uint8Array(3*e.length);for(let i=0;i<e.length;i++){var t=e.charCodeAt(i);if(t<128)n[r++]=t;else{if(t<2048)n[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&i<e.length){let o=e.charCodeAt(++i);if(o>=56320&&o<=57343){t=1024*(t-55296)+o-56320+65536,n[r++]=t>>18|240,n[r++]=t>>12&63|128,n[r++]=t>>6&63|128,n[r++]=63&t|128;continue}i--}t=65533}n[r++]=t>>12|224,n[r++]=t>>6&63|128}n[r++]=63&t|128}}e=r===n.length?n:n.subarray(0,r)}return e}var $d,ec;e:{for(Td=["CLOSURE_FLAGS"],Ka=Kn,Xa=0;Xa<Td.length;Xa++)if((Ka=Ka[Td[Xa]])==null){ec=null;break e}ec=Ka}var Td,Ka,Xa,Jo,h0=ec&&ec[610401301];$d=h0!=null&&h0;var d0=Kn.navigator;function Md(e){return!!$d&&!!Jo&&Jo.brands.some((({brand:t})=>t&&t.indexOf(e)!=-1))}function cr(e){var t;return(t=Kn.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function vn(){return!!$d&&!!Jo&&Jo.brands.length>0}function Id(){return vn()?Md("Chromium"):(cr("Chrome")||cr("CriOS"))&&!(!vn()&&cr("Edge"))||cr("Silk")}Jo=d0&&d0.userAgentData||null;var __=!vn()&&(cr("Trident")||cr("MSIE"));!cr("Android")||Id(),Id(),cr("Safari")&&(Id()||!vn()&&cr("Coast")||!vn()&&cr("Opera")||!vn()&&cr("Edge")||(vn()?Md("Microsoft Edge"):cr("Edg/"))||vn()&&Md("Opera"));var q0={},$o=null;function w_(e){let 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);let n=new Uint8Array(r),i=0;return(function(o,s){function a(l){for(;c<o.length;){let h=o.charAt(c++),d=$o[h];if(d!=null)return d;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return l}K0();let c=0;for(;;){let l=a(-1),h=a(0),d=a(64),m=a(64);if(m===64&&l===-1)break;s(l<<2|h>>4),d!=64&&(s(h<<4&240|d>>2),m!=64&&s(d<<6&192|m))}})(e,(function(o){n[i++]=o})),i!==r?n.subarray(0,i):n}function K0(){if(!$o){$o={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=e.concat(t[r].split(""));q0[r]=n;for(let i=0;i<n.length;i++){let o=n[i];$o[o]===void 0&&($o[o]=i)}}}}var X0=typeof Uint8Array<"u",J0=!__&&typeof btoa=="function";function u0(e){if(!J0){var t;t===void 0&&(t=0),K0(),t=q0[t];var r=Array(Math.floor(e.length/3)),n=t[64]||"";let c=0,l=0;for(;c<e.length-2;c+=3){var i=e[c],o=e[c+1],s=e[c+2],a=t[i>>2];i=t[(3&i)<<4|o>>4],o=t[(15&o)<<2|s>>6],s=t[63&s],r[l++]=a+i+o+s}switch(a=0,s=n,e.length-c){case 2:s=t[(15&(a=e[c+1]))<<2]||n;case 1:e=e[c],r[l]=t[e>>2]+t[(3&e)<<4|a>>4]+s+n}return r.join("")}for(t="",r=0,n=e.length-10240;r<n;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}var f0=/[-_.]/g,S_={"-":"+",_:"/",".":"="};function k_(e){return S_[e]||""}function Y0(e){if(!J0)return w_(e);f0.test(e)&&(e=e.replace(f0,k_)),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 hc(e){return X0&&e!=null&&e instanceof Uint8Array}var Yi={};function Zi(){return E_||=new wn(null,Yi)}function Gd(e){Z0(Yi);var t=e.g;return(t=t==null||hc(t)?t:typeof t=="string"?Y0(t):null)==null?t:e.g=t}var wn=class{i(){return new Uint8Array(Gd(this)||0)}constructor(e,t){if(Z0(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}},E_,C_;function Z0(e){if(e!==Yi)throw Error("illegal external caller")}function Q0(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function p0(){let e=Error("int32");return Q0(e,"warning"),e}var dc=typeof Symbol=="function"&&typeof Symbol()=="symbol",x_=new Set;function uc(e,t,r=!1,n=!1){return e=typeof Symbol=="function"&&typeof Symbol()=="symbol"?n&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t,r&&x_.add(e),e}var A_=uc("jas",void 0,!0,!0),Rd=uc(void 0,"2ex"),Ho=uc(void 0,"1oa",!0),Qi=uc(void 0,Symbol(),!0),se=dc?A_:"M",e1={M:{value:0,configurable:!0,writable:!0,enumerable:!1}},t1=Object.defineProperties;function qd(e,t){dc||se in e||t1(e,e1),e[se]|=t}function ct(e,t){dc||se in e||t1(e,e1),e[se]=t}function T_(e,t){ct(t,-30975&(0|e))}function Ud(e,t){ct(t,-30941&(34|e))}function Kd(){return typeof BigInt=="function"}function lr(e){return Array.prototype.slice.call(e)}var Xd,Zo={},I_={};function m0(e){return!(!e||typeof e!="object"||e.g!==I_)}function Jd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function r1(e,t){if(e!=null){if(typeof e=="string")e=e?new wn(e,Yi):Zi();else if(e.constructor!==wn)if(hc(e))e=e.length?new wn(new Uint8Array(e),Yi):Zi();else{if(!t)throw Error();e=void 0}}return e}function tc(e){return!(!Array.isArray(e)||e.length)&&!!(1&(0|e[se]))}var g0=[];function Yn(e){if(2&e)throw Error()}function Yd(e){return Qi?e[Qi]:void 0}ct(g0,55),Xd=Object.freeze(g0);var n1=Object.freeze({}),Zd=typeof Kn.BigInt=="function"&&typeof Kn.BigInt(0)=="bigint",Nd=e=>Zd?e>=P_&&e<=O_:e[0]==="-"?y0(e,R_):y0(e,D_),R_=Number.MIN_SAFE_INTEGER.toString(),P_=Zd?BigInt(Number.MIN_SAFE_INTEGER):void 0,D_=Number.MAX_SAFE_INTEGER.toString(),O_=Zd?BigInt(Number.MAX_SAFE_INTEGER):void 0;function y0(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){let n=e[r],i=t[r];if(n>i)return!1;if(n<i)return!0}}var B_=typeof Uint8Array.prototype.slice=="function",i1,De=0,Ge=0;function b0(e){let t=e>>>0;De=t,Ge=(e-t)/4294967296>>>0}function eo(e){if(e<0){b0(-e);let[t,r]=tu(De,Ge);De=t>>>0,Ge=r>>>0}else b0(e)}function o1(e){let t=i1||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ge=0,De=t.getUint32(0,!0)}function Qd(e,t){let r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Yo(e,t)}function eu(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Qd(e,t))=="number"?r?-e:e:r?"-"+e:e}function Yo(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else Kd()?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,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+v0(r)+v0(e));return r}function v0(e){return e=String(e),"0000000".slice(e.length)+e}function fc(e){if(e.length<16)eo(Number(e));else if(Kd())e=BigInt(e),De=Number(e&BigInt(4294967295))>>>0,Ge=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");Ge=De=0;let r=e.length;for(let n=t,i=(r-t)%6+t;i<=r;n=i,i+=6){let o=Number(e.slice(n,i));Ge*=1e6,De=1e6*De+o,De>=4294967296&&(Ge+=Math.trunc(De/4294967296),Ge>>>=0,De>>>=0)}if(t){let[n,i]=tu(De,Ge);De=n,Ge=i}}}function tu(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}var s1=typeof BigInt=="function"?BigInt.asIntN:void 0,L_=typeof BigInt=="function"?BigInt.asUintN:void 0,Go=Number.isSafeInteger,pc=Number.isFinite,rc=Math.trunc;function Qo(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function _0(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}var F_=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function ru(e){switch(typeof e){case"bigint":return!0;case"number":return pc(e);case"string":return F_.test(e);default:return!1}}function Xn(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return pc(e)?0|e:void 0}function w0(e){if(e[0]==="-")return!1;let t=e.length;return t<20||t===20&&Number(e.substring(0,6))<184467}function a1(e){return e=rc(e),Go(e)||(eo(e),e=eu(De,Ge)),e}function c1(e){var t=rc(Number(e));if(Go(t))return String(t);if((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),t=e.length,!(e[0]==="-"?t<20||t===20&&Number(e.substring(0,7))>-922337:t<19||t===19&&Number(e.substring(0,6))<922337))if(fc(e),e=De,2147483648&(t=Ge))if(Kd())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=tu(e,t);e="-"+Yo(r,n)}else e=Yo(e,t);return e}function zd(e){return e==null?e:typeof e=="bigint"?(Nd(e)?e=Number(e):(e=s1(64,e),e=Nd(e)?Number(e):String(e)),e):ru(e)?typeof e=="number"?a1(e):c1(e):void 0}function M_(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(L_(64,e));if(ru(e)){if(t==="string")return t=rc(Number(e)),Go(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),w0(e)||(fc(e),e=Yo(De,Ge))),e;if(t==="number")return(e=rc(e))>=0&&Go(e)?e:(function(r){if(r<0){eo(r);var n=Yo(De,Ge);return r=Number(n),Go(r)?r:n}return w0(n=String(r))?n:(eo(r),Qd(De,Ge))})(e)}}function l1(e){if(typeof e!="string")throw Error();return e}function nc(e){if(e!=null&&typeof e!="string")throw Error();return e}function Sn(e){return e==null||typeof e=="string"?e:void 0}function h1(e,t,r){if(e!=null&&typeof e=="object"&&e.B===Zo)return e;if(Array.isArray(e)){var n=0|e[se],i=n;return i===0&&(i|=32&r),(i|=2&r)!==n&&ct(e,i),new t(e)}}function d1(e,t,r,n,i){if(e!=null){if(Array.isArray(e))e=tc(e)?void 0:i&&2&(0|e[se])?e:nu(e,t,r,n!==void 0,i);else if(Jd(e)){let o={};for(let s in e)o[s]=d1(e[s],t,r,n,i);e=o}else e=t(e,n);return e}}function nu(e,t,r,n,i){let o=n||r?0|e[se]:0,s=n?!!(32&o):void 0;n=lr(e);for(let a=0;a<n.length;a++)n[a]=d1(n[a],t,r,s,i);return r&&((e=Yd(e))&&(n[Qi]=lr(e)),r(o,n)),n}function U_(e){return e.B===Zo?e.toJSON():(function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return Nd(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(tc(t))return}else{if(hc(t))return u0(t);if(t instanceof wn){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=u0(r)}}}return t})(e)}function N_(e){return nu(e,U_,void 0,void 0,!1)}var u1,z_;function qo(e,t,r){return e=f1(e,t[0],t[1],r?1:2),t!==u1&&r&&qd(e,16384),e}function f1(e,t,r,n){if(e==null){var i=96;r?(e=[r],i|=512):e=[],t&&(i=-33521665&i|(1023&t)<<15)}else{if(!Array.isArray(e))throw Error("narr");if(2048&(i=0|e[se]))throw Error("farr");if(64&i)return e;if(n===1||n===2||(i|=64),r&&(i|=512,r!==e[0]))throw Error("mid");e:{if(n=(r=e).length){let o=n-1;if(Jd(r[o])){if((t=o-(512&(i|=256)?0:-1))>=1024)throw Error("pvtlmt");i=-33521665&i|(1023&t)<<15;break e}}if(t){if((t=Math.max(t,n-(512&i?0:-1)))>1024)throw Error("spvt");i=-33521665&i|(1023&t)<<15}}}return ct(e,i),e}function p1(e,t,r=Ud){if(e!=null){if(X0&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var n=0|e[se];return 2&n?e:(t&&=n===0||!!(32&n)&&!(64&n||!(16&n)),t?(ct(e,-12293&(34|n)),e):nu(e,p1,4&n?Ud:r,!0,!0))}return e.B===Zo&&(e=2&(n=0|(r=e.l)[se])?e:new e.constructor(mc(r,n,!0))),e}}function m1(e){let t=e.l;return new e.constructor(mc(t,0|t[se],!1))}function mc(e,t,r){let n=r||2&t?Ud:T_,i=!!(32&t);return e=(function(o,s,a){let c=lr(o);var l=c.length;let h=256&s?c[l-1]:void 0;for(l+=h?-1:0,s=512&s?1:0;s<l;s++)c[s]=a(c[s]);if(h){s=c[s]={};for(let d in h)s[d]=a(h[d])}return(o=Yd(o))&&(c[Qi]=lr(o)),c})(e,t,(o=>p1(o,i,n))),qd(e,32|(r?2:0)),e}function iu(e){let t=e.l,r=0|t[se];return 2&r?new e.constructor(mc(t,r,!1)):e}function _r(e,t){return Zn(e=e.l,0|e[se],t)}function Zn(e,t,r,n){if(r===-1)return null;var i=r+(512&t?0:-1);let o=e.length-1;return i>=o&&256&t?e[o][r]:n&&256&t&&(t=e[o][r])!=null?(e[i]!=null&&Rd!=null&&((i=(e=C_??={})[Rd]||0)>=4||(e[Rd]=i+1,Q0(e=Error(),"incident"),(function(s){Kn.setTimeout((()=>{throw s}),0)})(e))),t):i<=o?e[i]:void 0}function pt(e,t,r){let n=e.l,i=0|n[se];return Yn(i),lt(n,i,t,r),e}function lt(e,t,r,n){let i=512&t?0:-1,o=r+i;var s=e.length-1;return o>=s&&256&t?(e[s][r]=n,t):o<=s?(e[o]=n,256&t&&r in(e=e[s])&&delete e[r],t):(n!==void 0&&(r>=(s=t>>15&1023||536870912)?n!=null&&(e[s+i]={[r]:n},ct(e,t|=256)):e[o]=n),t)}function g1(e){let t=0|(e=e.l)[se],r=Zn(e,t,1),n=r1(r,!0);return n!=null&&n!==r&<(e,t,1,n),n}function y1(e,t,r,n,i){let o=e.l,s=2&(e=0|o[se])?1:n;i=!!i;let a=0|(n=ou(o,e,t))[se];if(!(4&a)){4&a&&(n=lr(n),a=en(a,e),e=lt(o,e,t,n));let c=0,l=0;for(;c<n.length;c++){let h=r(n[c]);h!=null&&(n[l++]=h)}l<c&&(n.length=l),a=su(a,e),r=-4097&(20|a),a=r&=-8193,ct(n,a),2&a&&Object.freeze(n)}return s===1||s===4&&32&a?Qr(a)||(i=a,a|=2,a!==i&&ct(n,a),Object.freeze(n)):(s===2&&Qr(a)&&(n=lr(n),a=en(a,e),a=kn(a,e,i),ct(n,a),e=lt(o,e,t,n)),Qr(a)||(t=a,a=kn(a,e,i),a!==t&&ct(n,a))),n}function ou(e,t,r,n){return e=Zn(e,t,r,n),Array.isArray(e)?e:Xd}function su(e,t){return e===0&&(e=en(e,t)),1|e}function Qr(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function S0(e,t,r){let n=0|(e=e.l)[se];if(Yn(n),r==null)lt(e,n,t);else{var i=0|r[se],o=i,s=Qr(i),a=s||Object.isFrozen(r);for(s||(i=0),a||(r=lr(r),o=0,i=kn(i=en(i,n),n,!0),a=!1),i|=21,s=0;s<r.length;s++){let c=r[s],l=l1(c);Object.is(c,l)||(a&&(r=lr(r),o=0,i=kn(i=en(i,n),n,!0),a=!1),r[s]=l)}i!==o&&(a&&(r=lr(r),i=kn(i=en(i,n),n,!0)),ct(r,i)),lt(e,n,t,r)}}function b1(e,t){let r=0|(e=e.l)[se];Yn(r),lt(e,r,2,t===""?void 0:t)}function es(e,t,r,n,i){Yn(t);var o=!(!(64&t)&&16384&t);let s=(i=ou(e,t,r,i))!==Xd;if(o||!s){let a=o=s?0|i[se]:0;(!s||2&a||Qr(a)||4&a&&!(32&a))&&(i=lr(i),a=en(a,t),t=lt(e,t,r,i)),a=-13&su(a,t),a=kn(n?-17&a:16|a,t,!0),a!==o&&ct(i,a)}return i}function Pd(e,t){var r=c2;return cu(au(e=e.l),e,0|e[se],r)===t?t:-1}function au(e){if(dc)return e[Ho]??(e[Ho]=new Map);if(Ho in e)return e[Ho];let t=new Map;return Object.defineProperty(e,Ho,{value:t}),t}function v1(e,t,r,n){let i=au(e),o=cu(i,e,t,r);return o!==n&&(o&&(t=lt(e,t,o)),i.set(r,n)),t}function cu(e,t,r,n){let i=e.get(n);if(i!=null)return i;i=0;for(let o=0;o<n.length;o++){let s=n[o];Zn(t,r,s)!=null&&(i!==0&&(r=lt(t,r,i)),i=s)}return e.set(n,i),i}function lu(e,t,r,n){let i,o=0|e[se];if((n=Zn(e,o,r,n))!=null&&n.B===Zo)return(t=iu(n))!==n&<(e,o,r,t),t.l;if(Array.isArray(n)){let s=0|n[se];i=2&s?qo(mc(n,s,!1),t,!0):64&s?n:qo(i,t,!0)}else i=qo(void 0,t,!0);return i!==n&<(e,o,r,i),i}function _1(e,t,r,n){let i=0|(e=e.l)[se];return(t=h1(n=Zn(e,i,r,n),t,i))!==n&&t!=null&<(e,i,r,t),t}function wr(e,t,r){if((t=_1(e,t,r,!1))==null)return t;let n=0|(e=e.l)[se];if(!(2&n)){let i=iu(t);i!==t&<(e,n,r,t=i)}return t}function w1(e,t,r,n,i,o){e=e.l;var s=!!(2&t);let a=s?1:n;i=!!i,o&&=!s;var c=0|(n=ou(e,t,1))[se];if(!(s=!!(4&c))){var l=n,h=t;let d=!!(2&(c=su(c,t)));d&&(h|=2);let m=!d,p=!0,g=0,f=0;for(;g<l.length;g++){let b=h1(l[g],r,h);if(b instanceof r){if(!d){let _=!!(2&(0|b.l[se]));m&&=!_,p&&=_}l[f++]=b}}f<g&&(l.length=f),c|=4,c=p?16|c:-17&c,ct(l,c=m?8|c:-9&c),d&&Object.freeze(l)}if(o&&!(8&c||!n.length&&(a===1||a===4&&32&c))){for(Qr(c)&&(n=lr(n),c=en(c,t),t=lt(e,t,1,n)),r=n,o=c,l=0;l<r.length;l++)(c=r[l])!==(h=iu(c))&&(r[l]=h);o|=8,ct(r,o=r.length?-17&o:16|o),c=o}return a===1||a===4&&32&c?Qr(c)||(t=c,(c|=!n.length||16&c&&(!s||32&c)?2:2048)!==t&&ct(n,c),Object.freeze(n)):(a===2&&Qr(c)&&(ct(n=lr(n),c=kn(c=en(c,t),t,i)),t=lt(e,t,1,n)),Qr(c)||(e=c,(c=kn(c,t,i))!==e&&ct(n,c))),n}function hu(e,t){let r=0|e.l[se];return w1(e,r,t,n1===void 0?2:4,!1,!(2&r))}function Sr(e,t,r,n){return n==null&&(n=void 0),pt(e,r,n)}function Dd(e,t,r){var n=i2;r==null&&(r=void 0);e:{let i=0|(e=e.l)[se];if(Yn(i),r==null){let o=au(e);if(cu(o,e,i,n)!==t)break e;o.set(n,0)}else i=v1(e,i,n,t);lt(e,i,t,r)}}function en(e,t){return-2049&(e=32|(2&t?2|e:-3&e))}function kn(e,t,r){return 32&t&&r||(e&=-33),e}function S1(e,t){var r=xu;let n=0|e.l[se];Yn(n),e=w1(e,n,r,2,!0),t=t??new r,e.push(t),e[se]=2&(0|t.l[se])?-9&e[se]:-17&e[se]}function Ot(e,t,r){Yn(0|e.l[se]),y1(e,t,Sn,2,!0).push(l1(r))}function k1(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function du(){return Error("Failed to read varint, encoding is invalid.")}function E1(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function uu(e){if(typeof e=="string")return{buffer:Y0(e),u:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),u:!1};if(e.constructor===Uint8Array)return{buffer:e,u:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),u:!1};if(e.constructor===wn)return{buffer:Gd(e)||new Uint8Array(0),u:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),u:!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 fu(e,t){let r,n=0,i=0,o=0,s=e.i,a=e.g;do r=s[a++],n|=(127&r)<<o,o+=7;while(o<32&&128&r);for(o>32&&(i|=(127&r)>>4),o=3;o<32&&128&r;o+=7)r=s[a++],i|=(127&r)<<o;if(qn(e,a),r<128)return t(n>>>0,i>>>0);throw du()}function pu(e){let t=0,r=e.g,n=r+10,i=e.i;for(;r<n;){let o=i[r++];if(t|=o,(128&o)==0)return qn(e,r),!!(127&t)}throw du()}function Bt(e){let t=e.i,r=e.g,n=t[r++],i=127&n;if(128&n&&(n=t[r++],i|=(127&n)<<7,128&n&&(n=t[r++],i|=(127&n)<<14,128&n&&(n=t[r++],i|=(127&n)<<21,128&n&&(n=t[r++],i|=n<<28,128&n&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw du();return qn(e,r),i}function jd(e){var t=e.i;let r=e.g,n=t[r],i=t[r+1],o=t[r+2];return t=t[r+3],qn(e,e.g+4),(n<<0|i<<8|o<<16|t<<24)>>>0}function Vd(e){var t=jd(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:e*(1/0):r==0?1401298464324817e-60*e*t:e*Math.pow(2,r-150)*(t+8388608)}function j_(e){return Bt(e)}function Od(e,t,{C:r=!1}={}){e.C=r,t&&(t=uu(t),e.i=t.buffer,e.m=t.u,e.s=0,e.j=e.i.length,e.g=e.s)}function qn(e,t){if(e.g=t,t>e.j)throw E1(e.j,t)}function C1(e,t){if(t<0)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,n=r+t;if(n>e.j)throw E1(t,e.j-r);return e.g=n,r}function x1(e,t){if(t==0)return Zi();var r=C1(e,t);return e.C&&e.m?r=e.i.subarray(r,r+t):(e=e.i,r=r===(t=r+t)?new Uint8Array(0):B_?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Zi():new wn(r,Yi)}var k0=[];function A1(e){var t=e.g;if(t.g==t.j)return!1;e.j=e.g.g;var r=Bt(e.g)>>>0;if(t=r>>>3,!((r&=7)>=0&&r<=5))throw k1(r,e.j);if(t<1)throw Error(`Invalid field number: ${t} (at position ${e.j})`);return e.m=t,e.i=r,!0}function Za(e){switch(e.i){case 0:e.i!=0?Za(e):pu(e.g);break;case 1:qn(e=e.g,e.g+8);break;case 2:if(e.i!=2)Za(e);else{var t=Bt(e.g)>>>0;qn(e=e.g,e.g+t)}break;case 5:qn(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!A1(e))throw Error("Unmatched start-group tag: stream EOF");if(e.i==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}Za(e)}break;default:throw k1(e.i,e.j)}}function gc(e,t,r){let n=e.g.j,i=Bt(e.g)>>>0,o=e.g.g+i,s=o-n;if(s<=0&&(e.g.j=o,r(t,e,void 0,void 0,void 0),s=o-e.g.g),s)throw Error(`Message parsing ended unexpectedly. Expected to read ${i} bytes, instead read ${i-s} bytes, either the data ended unexpectedly or the message misreported its own length`);e.g.g=o,e.g.j=n}function mu(e){var t=Bt(e.g)>>>0,r=C1(e=e.g,t);if(e=e.i,y_){var n,i=e;(n=Ad)||(n=Ad=new TextDecoder("utf-8",{fatal:!0})),t=r+t,i=r===0&&t===i.length?i:i.subarray(r,t);try{var o=n.decode(i)}catch(a){if(qa===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),qa=!0}catch{qa=!1}}throw!qa&&(Ad=void 0),a}}else{t=(o=r)+t,r=[];let a,c=null;for(;o<t;){var s=e[o++];s<128?r.push(s):s<224?o>=t?$n():(a=e[o++],s<194||(192&a)!=128?(o--,$n()):r.push((31&s)<<6|63&a)):s<240?o>=t-1?$n():(a=e[o++],(192&a)!=128||s===224&&a<160||s===237&&a>=160||(192&(n=e[o++]))!=128?(o--,$n()):r.push((15&s)<<12|(63&a)<<6|63&n)):s<=244?o>=t-2?$n():(a=e[o++],(192&a)!=128||a-144+(s<<28)>>30!=0||(192&(n=e[o++]))!=128||(192&(i=e[o++]))!=128?(o--,$n()):(s=(7&s)<<18|(63&a)<<12|(63&n)<<6|63&i,s-=65536,r.push(55296+(s>>10&1023),56320+(1023&s)))):$n(),r.length>=8192&&(c=l0(c,r),r.length=0)}o=l0(c,r)}return o}function T1(e){let t=Bt(e.g)>>>0;return x1(e.g,t)}function gu(e,t,r){var n=Bt(e.g)>>>0;for(n=e.g.g+n;e.g.g<n;)r.push(t(e.g))}var Ja=[];function V_(e){return e}var Ki;function I1(e,t,r){t.g?t.j(e,t.g,t.i,r):t.j(e,t.i,r)}var Ue=class{constructor(e,t){this.l=f1(e,t)}toJSON(){let e=!Ki;try{return e&&(Ki=N_),R1(this)}finally{e&&(Ki=void 0)}}u(){return!!(2&(0|this.l[se]))}};function R1(e){var t=e.l;{t=(e=Ki(t))!==t;let l=e.length;if(l){var r=e[l-1],n=Jd(r);n?l--:r=void 0;var i=e;if(n){e:{var o,s=r,a=!1;if(s)for(let h in s)isNaN(+h)?(o??={})[h]=s[h]:(n=s[h],Array.isArray(n)&&(tc(n)||m0(n)&&n.size===0)&&(n=null),n==null&&(a=!0),n!=null&&((o??={})[h]=n));if(a||(o=s),o)for(let h in o){a=o;break e}a=null}s=a==null?r!=null:a!==r}for(;l>0&&((o=i[l-1])==null||tc(o)||m0(o)&&o.size===0);l--)var c=!0;(i!==e||s||c)&&(t?(c||s||a)&&(i.length=l):i=Array.prototype.slice.call(i,0,l),a&&i.push(a)),c=i}else c=e}return c}function E0(e){return e?/^\d+$/.test(e)?(fc(e),new Hd(De,Ge)):null:H_||=new Hd(0,0)}Ue.prototype.B=Zo,Ue.prototype.toString=function(){try{return Ki=V_,R1(this).toString()}finally{Ki=void 0}};var Hd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},H_;function C0(e){return e?/^-?\d+$/.test(e)?(fc(e),new Wd(De,Ge)):null:W_||=new Wd(0,0)}var Wd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},W_;function Xi(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function ts(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function yc(e,t){if(t>=0)ts(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function ic(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 to(e,t){t.length!==0&&(e.j.push(t),e.i+=t.length)}function kr(e,t,r){ts(e.g,8*t+r)}function bc(e,t){return kr(e,t,2),t=e.g.end(),to(e,t),t.push(e.i),t}function vc(e,t){var r=t.pop();for(r=e.i+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.i++;t.push(r),e.i++}function _c(e,t,r){kr(e,t,2),ts(e.g,r.length),to(e,e.g.end()),to(e,r)}function Er(){let e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var yu=Er(),P1=Er(),bu=Er(),vu=Er(),D1=Er(),O1=Er(),B1=Er(),L1=Er(),ro=class{constructor(e,t,r){this.g=e,this.i=t,e=yu,this.j=!!e&&r===e||!1}};function _u(e,t){return new ro(e,t,yu)}function F1(e,t,r,n,i){(t=z1(t,n))!=null&&(r=bc(e,r),i(t,e),vc(e,r))}var $_=_u((function(e,t,r,n,i){return e.i===2&&(gc(e,lu(t,n,r),i),!0)}),F1),G_=_u((function(e,t,r,n,i){return e.i===2&&(gc(e,lu(t,n,r,!0),i),!0)}),F1),wc=Symbol(),wu=Symbol(),x0=Symbol(),A0=Symbol(),M1,U1;function Qn(e,t,r,n){var i=n[e];if(i)return i;(i={}).P=n,i.A=(function(d){switch(typeof d){case"boolean":return u1||=[0,void 0,!0];case"number":return d>0?void 0:d===0?z_||=[0,void 0]:[-d,void 0];case"string":return[0,d];case"object":return d}})(n[0]);var o=n[1];let s=1;o&&o.constructor===Object&&(i.H=o,typeof(o=n[++s])=="function"&&(i.I=!0,M1??=o,U1??=n[s+1],o=n[s+=2]));let a={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var c=0;c<o.length;c++)a[o[c]]=o;o=n[++s]}for(c=1;o!==void 0;){let d;typeof o=="number"&&(c+=o,o=n[++s]);var l=void 0;if(o instanceof ro?d=o:(d=$_,s--),d?.j){o=n[++s],l=n;var h=s;typeof o=="function"&&(o=o(),l[h]=o),l=o}for(h=c+1,typeof(o=n[++s])=="number"&&o<0&&(h-=o,o=n[++s]);c<h;c++){let m=a[c];l?r(i,c,d,l,m):t(i,c,d,m)}}return n[e]=i}function N1(e){return Array.isArray(e)?e[0]instanceof ro?e:[G_,e]:[e,void 0]}function z1(e,t){return e instanceof Ue?e.l:Array.isArray(e)?qo(e,t,!1):void 0}function Su(e,t,r,n){let i=r.g;e[t]=n?(o,s,a)=>i(o,s,a,n):i}function ku(e,t,r,n,i){let o=r.g,s,a;e[t]=(c,l,h)=>o(c,l,h,a||=Qn(wu,Su,ku,n).A,s||=Eu(n),i)}function Eu(e){let t=e[x0];if(t!=null)return t;let r=Qn(wu,Su,ku,e);return t=r.I?(n,i)=>M1(n,i,r):(n,i)=>{let o=0|n[se];for(;A1(i)&&i.i!=4;){var s=i.m,a=r[s];if(a==null){var c=r.H;c&&(c=c[s])&&(c=q_(c))!=null&&(a=r[s]=c)}a!=null&&a(i,n,s)||(s=(a=i).j,Za(a),a.G?a=void 0:(c=a.g.g-s,a.g.g=s,a=x1(a.g,c)),s=n,a&&((c=s[Qi])?c.push(a):s[Qi]=[a]))}return 16384&o&&qd(n,34),!0},e[x0]=t}function q_(e){let t=(e=N1(e))[0].g;if(e=e[1]){let r=Eu(e),n=Qn(wu,Su,ku,e).A;return(i,o,s)=>t(i,o,s,n,r)}return t}function Sc(e,t,r){e[t]=r.i}function kc(e,t,r,n){let i,o,s=r.i;e[t]=(a,c,l)=>s(a,c,l,o||=Qn(wc,Sc,kc,n).A,i||=j1(n))}function j1(e){let t=e[A0];if(!t){let r=Qn(wc,Sc,kc,e);t=(n,i)=>V1(n,i,r),e[A0]=t}return t}function V1(e,t,r){for(var n=0|e[se],i=512&n?0:-1,o=e.length,s=512&n?1:0,a=o+(256&n?-1:0);s<a;s++){let c=e[s];if(c==null)continue;let l=s-i,h=T0(r,l);h&&h(t,c,l)}if(256&n){n=e[o-1];for(let c in n)i=+c,Number.isNaN(i)||(o=n[i])!=null&&(a=T0(r,i))&&a(t,o,i)}if(e=Yd(e))for(to(t,t.g.end()),r=0;r<e.length;r++)to(t,Gd(e[r])||new Uint8Array(0))}function T0(e,t){var r=e[t];if(r)return r;if((r=e.H)&&(r=r[t])){var n=(r=N1(r))[0].i;if(r=r[1]){let i=j1(r),o=Qn(wc,Sc,kc,r).A;r=e.I?U1(o,i):(s,a,c)=>n(s,a,c,o,i)}else r=n;return e[t]=r}}function Ec(e,t){if(Array.isArray(t)){var r=0|t[se];if(4&r)return t;for(var n=0,i=0;n<t.length;n++){let o=e(t[n]);o!=null&&(t[i++]=o)}return i<n&&(t.length=i),ct(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}function wt(e,t,r){return new ro(e,t,r)}function Cc(e,t,r){return new ro(e,t,r)}function St(e,t,r){lt(e,0|e[se],t,r)}function H1(e,t,r){if(t=(function(n){if(n==null)return n;let i=typeof n;if(i==="bigint")return String(s1(64,n));if(ru(n)){if(i==="string")return c1(n);if(i==="number")return a1(n)}})(t),t!=null&&(typeof t=="string"&&C0(t),t!=null))switch(kr(e,r,0),typeof t){case"number":e=e.g,eo(t),Xi(e,De,Ge);break;case"bigint":r=BigInt.asUintN(64,t),r=new Wd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=C0(t),Xi(e.g,r.i,r.g)}}function W1(e,t,r){(t=Xn(t))!=null&&t!=null&&(kr(e,r,0),yc(e.g,t))}function $1(e,t,r){(t=t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0)!=null&&(kr(e,r,0),e.g.g.push(t?1:0))}function G1(e,t,r){(t=Sn(t))!=null&&_c(e,r,G0(t))}function q1(e,t,r,n,i){(t=z1(t,n))!=null&&(r=bc(e,r),i(t,e),vc(e,r))}function K1(e,t,r){(t=t==null||typeof t=="string"||hc(t)||t instanceof wn?t:void 0)!=null&&_c(e,r,uu(t).buffer)}var K_=wt((function(e,t,r){if(e.i!==1)return!1;var n=e.g;e=jd(n);let i=jd(n);n=2*(i>>31)+1;let o=i>>>20&2047;return e=4294967296*(1048575&i)+e,St(t,r,o==2047?e?NaN:n*(1/0):o==0?5e-324*n*e:n*Math.pow(2,o-1075)*(e+4503599627370496)),!0}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,1),e=e.g,(r=i1||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),De=r.getUint32(0,!0),Ge=r.getUint32(4,!0),ic(e,De),ic(e,Ge))}),Er()),X1=wt((function(e,t,r){return e.i===5&&(St(t,r,Vd(e.g)),!0)}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,5),e=e.g,o1(t),ic(e,De))}),O1),X_=Cc((function(e,t,r){return(e.i===5||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?gu(e,Vd,t):t.push(Vd(e.g)),!0)}),(function(e,t,r){if((t=Ec(Qo,t))!=null&&t.length){kr(e,r,2),ts(e.g,4*t.length);for(let n=0;n<t.length;n++)r=e.g,o1(t[n]),ic(r,De)}}),O1),oc=wt((function(e,t,r){return e.i===0&&(St(t,r,fu(e.g,eu)),!0)}),H1,D1),Bd=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=fu(e.g,eu))===0?void 0:e),!0)}),H1,D1),J_=wt((function(e,t,r){return e.i===0&&(St(t,r,fu(e.g,Qd)),!0)}),(function(e,t,r){if((t=M_(t))!=null&&(typeof t=="string"&&E0(t),t!=null))switch(kr(e,r,0),typeof t){case"number":e=e.g,eo(t),Xi(e,De,Ge);break;case"bigint":r=BigInt.asUintN(64,t),r=new Hd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=E0(t),Xi(e.g,r.i,r.g)}}),Er()),En=wt((function(e,t,r){return e.i===0&&(St(t,r,Bt(e.g)),!0)}),W1,vu),Cu=Cc((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?gu(e,Bt,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=Ec(Xn,t))!=null&&t.length){r=bc(e,r);for(let n=0;n<t.length;n++)yc(e.g,t[n]);vc(e,r)}}),vu),Gi=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g))===0?void 0:e),!0)}),W1,vu),Wt=wt((function(e,t,r){return e.i===0&&(St(t,r,pu(e.g)),!0)}),$1,P1),Ji=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=pu(e.g))===!1?void 0:e),!0)}),$1,P1),sr=Cc((function(e,t,r){return e.i===2&&(e=mu(e),es(t,0|t[se],r,!1).push(e),!0)}),(function(e,t,r){if((t=Ec(Sn,t))!=null)for(let s=0;s<t.length;s++){var n=e,i=r,o=t[s];o!=null&&_c(n,i,G0(o))}}),bu),_n=wt((function(e,t,r){return e.i===2&&(St(t,r,(e=mu(e))===""?void 0:e),!0)}),G1,bu),Ze=wt((function(e,t,r){return e.i===2&&(St(t,r,mu(e)),!0)}),G1,bu),ar=(function(e,t,r=yu){return new ro(e,t,r)})((function(e,t,r,n,i){return e.i===2&&(n=qo(void 0,n,!0),es(t,0|t[se],r,!0).push(n),gc(e,n,i),!0)}),(function(e,t,r,n,i){if(Array.isArray(t))for(let o=0;o<t.length;o++)q1(e,t[o],r,n,i)})),ft=_u((function(e,t,r,n,i,o){return e.i===2&&(v1(t,0|t[se],o,r),gc(e,t=lu(t,n,r),i),!0)}),q1),J1=wt((function(e,t,r){return e.i===2&&(St(t,r,T1(e)),!0)}),K1,B1),Y_=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g)>>>0)===0?void 0:e),!0)}),(function(e,t,r){t=(function(n){if(n==null)return n;if(typeof n=="string"&&n)n=+n;else if(typeof n!="number")return;return pc(n)?n>>>0:void 0})(t),t!=null&&t!=null&&(kr(e,r,0),ts(e.g,t))}),Er()),Jn=wt((function(e,t,r){return e.i===0&&(St(t,r,Bt(e.g)),!0)}),(function(e,t,r){(t=Xn(t))!=null&&(t=parseInt(t,10),kr(e,r,0),yc(e.g,t))}),L1),sc=class{constructor(t,r){this.i=t,this.g=r,this.j=Sr,this.defaultValue=void 0}};function Y1(e,t){return(r,n)=>{if(Ja.length){let o=Ja.pop();o.o(n),Od(o.g,r,n),r=o}else r=new class{constructor(o,s){if(k0.length){let a=k0.pop();Od(a,o,s),o=a}else o=new class{constructor(a,c){this.i=null,this.m=!1,this.g=this.j=this.s=0,Od(this,a,c)}clear(){this.i=null,this.m=!1,this.g=this.j=this.s=0,this.C=!1}}(o,s);this.g=o,this.j=this.g.g,this.i=this.m=-1,this.o(s)}o({G:o=!1}={}){this.G=o}}(r,n);try{let o=new e,s=o.l;Eu(t)(s,r);var i=o}finally{r.g.clear(),r.m=-1,r.i=-1,Ja.length<100&&Ja.push(r)}return i}}var I0=[0,_n,wt((function(e,t,r){return e.i===2&&(St(t,r,(e=T1(e))===Zi()?void 0:e),!0)}),(function(e,t,r){if(t!=null){if(t instanceof Ue){let n=t.R;return void(n&&(t=n(t),t!=null&&_c(e,r,uu(t).buffer)))}if(Array.isArray(t))return}K1(e,t,r)}),B1)],Ld,R0=globalThis.trustedTypes;function P0(e){Ld===void 0&&(Ld=(function(){let r=null;if(!R0)return r;try{let n=i=>i;r=R0.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r})());var t=Ld;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function Z_(e,...t){if(t.length===0)return P0(e[0]);let r=e[0];for(let n=0;n<t.length;n++)r+=encodeURIComponent(t[n])+e[n+1];return P0(r)}var Z1=[0,En,Jn,Wt,-1,Cu,Jn,-1],Q_=class extends Ue{constructor(e){super(e)}},Q1=[0,Wt,Ze,Wt,Jn,-1,Cc((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?gu(e,j_,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=Ec(Xn,t))!=null&&t.length){r=bc(e,r);for(let n=0;n<t.length;n++)yc(e.g,t[n]);vc(e,r)}}),L1),Ze,-1,[0,Wt,-1],Jn,Wt,-1],e2=[0,Ze,-2],D0=class extends Ue{constructor(e){super(e)}},t2=[0],r2=[0,En,Wt,1,Wt,-3],n2=class extends Ue{constructor(e){super(e,2)}},xc={};xc[336783863]=[0,Ze,Wt,-1,En,[0,[1,2,3,4,5,6,7,8],ft,t2,ft,Q1,ft,e2,ft,r2,ft,Z1,ft,[0,Ze,-2],ft,[0,Ze,Jn],ft,[0,Jn,Ze]],[0,Ze],Wt,[0,[1,3],[2,4],ft,[0,Cu],-1,ft,[0,sr],-1,ar,[0,Ze,-1]],Ze];var O0,B0=[0,Bd,-1,Ji,-3,Bd,Cu,_n,Gi,Bd,-1,Ji,Gi,Ji,-2,_n],xu=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,7,e)}},Ko=[-1,{}],L0=[0,Ze,1,Ko],F0=[0,Ze,sr,Ko],Au=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,1001,e)}};Au.prototype.g=(O0=[-500,ar,[-500,_n,-1,sr,-3,[-2,xc,Wt],ar,I0,Gi,-1,L0,F0,ar,[0,_n,Ji],_n,B0,Gi,sr,987,sr],4,ar,[-500,Ze,-1,[-1,{}],998,Ze],ar,[-500,Ze,sr,-1,[-2,{},Wt],997,sr,-1],Gi,ar,[-500,Ze,sr,Ko,998,sr],sr,Gi,L0,F0,ar,[0,_n,-1,Ko],sr,-2,B0,_n,-1,Ji,[0,Ji,Y_],978,Ko,ar,I0],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 o=this.g;return this.g=[],o}}}};V1(this.l,e,Qn(wc,Sc,kc,O0)),to(e,e.g.end());let t=new Uint8Array(e.i),r=e.j,n=r.length,i=0;for(let o=0;o<n;o++){let s=r[o];t.set(s,i),i+=s.length}return e.j=[t],t});var e3=class extends Ue{constructor(e){super(e)}},t3=class extends Ue{constructor(e){super(e)}g(){return hu(this,e3)}},r3=[0,ar,[0,En,X1,Ze,-1]],M0=class extends Ue{constructor(e){super(e)}},U0=class extends Ue{constructor(e){super(e)}},i2=[1,2,3,4,5],ac=class extends Ue{constructor(e){super(e)}g(){return g1(this)!=null}i(){return Sn(_r(this,2))!=null}},cc=class extends Ue{constructor(e){super(e)}},o2=class extends Ue{constructor(e){super(e)}},s2=[0,[0,J1,Ze,[0,En,oc,-1],[0,J_,oc]],Wt,[0,i2,ft,r2,ft,Q1,ft,Z1,ft,t2,ft,e2],Jn],n3=new sc(451755788,o2);xc[451755788]=[0,s2,[0,Ze,En,X1,sr,-1],K_];var N0=class extends Ue{constructor(e){super(e)}},a2=class extends Ue{constructor(e){super(e)}},i3=new sc(487277289,a2);xc[487277289]=[0,s2,[0,Wt,-1]];var o3=class extends Ue{constructor(e){super(e)}},s3=Y1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,1,En,Ze,r3],oc]),z0=class extends Ue{constructor(e){super(e)}},a3=class extends Ue{constructor(e){super(e)}J(){let e=g1(this);return e??Zi()}},c3=class extends Ue{constructor(e){super(e)}},c2=[1,2],j0=Y1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,c2,ft,[0,X_],ft,[0,J1],En,Ze],oc]);function l3(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!(function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")})(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function V0(e){if(typeof importScripts!="function"){let t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((r,n)=>{t.addEventListener("load",(()=>{r()}),!1),t.addEventListener("error",(i=>{n(i)}),!1),document.body.appendChild(t)}))}importScripts(e.toString())}function ie(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 H0(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");let n=new Uint32Array(t.length);for(let i=0;i<t.length;i++)n[i]=e.h.stringToNewUTF8(t[i]);t=e.h._malloc(4*n.length),e.h.HEAPU32.set(n,t>>2),r(t);for(let i of n)e.h._free(i);e.h._free(t)}function yn(e,t,r){e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=r}function Gn(e,t,r){let n=[];e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=(i,o,s)=>{o?(r(n,s),n=[]):n.push(i)}}var h3=(function(e){return class extends e{N(){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:l3()?this.h.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas"))}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,n=this.h._malloc(r);this.h.HEAPU8.set(e,n),t?this.h._changeBinaryGraph(r,n):this.h._changeTextGraph(r,n),this.h._free(n)}configureAudio(e,t,r,n,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),ie(this,n||"input_audio",(o=>{ie(this,i=i||"audio_header",(s=>{this.h._configureAudio(o,s,e,t??0,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,n,i){let o=4*e.length;this.i!==o&&(this.g&&this.h._free(this.g),this.g=this.h._malloc(o),this.i=o),this.h.HEAPF32.set(e,this.g/4),ie(this,n,(s=>{this.h._addAudioToInputStream(this.g,t,r,s,i)}))}addGpuBufferToStream(e,t,r){ie(this,t,(n=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");n?this.h._bindTextureToStream(n):this.h._bindTextureToCanvas();let i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);let[o,s]=e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height];!this.j||o===this.h.canvas.width&&s===this.h.canvas.height||(this.h.canvas.width=o,this.h.canvas.height=s);let[a,c]=[o,s];this.h._addBoundTextureToStream(n,a,c,r)}))}addBoolToStream(e,t,r){ie(this,t,(n=>{this.h._addBoolToInputStream(e,n,r)}))}addDoubleToStream(e,t,r){ie(this,t,(n=>{this.h._addDoubleToInputStream(e,n,r)}))}addFloatToStream(e,t,r){ie(this,t,(n=>{this.h._addFloatToInputStream(e,n,r)}))}addIntToStream(e,t,r){ie(this,t,(n=>{this.h._addIntToInputStream(e,n,r)}))}addUintToStream(e,t,r){ie(this,t,(n=>{this.h._addUintToInputStream(e,n,r)}))}addStringToStream(e,t,r){ie(this,t,(n=>{ie(this,e,(i=>{this.h._addStringToInputStream(i,n,r)}))}))}addStringRecordToStream(e,t,r){ie(this,t,(n=>{H0(this,Object.keys(e),(i=>{H0(this,Object.values(e),(o=>{this.h._addFlatHashMapToInputStream(i,o,Object.keys(e).length,n,r)}))}))}))}addProtoToStream(e,t,r,n){ie(this,r,(i=>{ie(this,t,(o=>{let s=this.h._malloc(e.length);this.h.HEAPU8.set(e,s),this.h._addProtoToInputStream(s,e.length,o,i,n),this.h._free(s)}))}))}addEmptyPacketToStream(e,t){ie(this,e,(r=>{this.h._addEmptyPacketToInputStream(r,t)}))}addBoolVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.h._addBoolVectorEntry(i,o);this.h._addBoolVectorToInputStream(i,n,r)}))}addDoubleVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.h._addDoubleVectorEntry(i,o);this.h._addDoubleVectorToInputStream(i,n,r)}))}addFloatVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.h._addFloatVectorEntry(i,o);this.h._addFloatVectorToInputStream(i,n,r)}))}addIntVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.h._addIntVectorEntry(i,o);this.h._addIntVectorToInputStream(i,n,r)}))}addUintVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let o of e)this.h._addUintVectorEntry(i,o);this.h._addUintVectorToInputStream(i,n,r)}))}addStringVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let o of e)ie(this,o,(s=>{this.h._addStringVectorEntry(i,s)}));this.h._addStringVectorToInputStream(i,n,r)}))}addBoolToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addBoolToInputSidePacket(e,r)}))}addDoubleToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addDoubleToInputSidePacket(e,r)}))}addFloatToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addFloatToInputSidePacket(e,r)}))}addIntToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addIntToInputSidePacket(e,r)}))}addUintToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addUintToInputSidePacket(e,r)}))}addStringToInputSidePacket(e,t){ie(this,t,(r=>{ie(this,e,(n=>{this.h._addStringToInputSidePacket(n,r)}))}))}addProtoToInputSidePacket(e,t,r){ie(this,r,(n=>{ie(this,t,(i=>{let o=this.h._malloc(e.length);this.h.HEAPU8.set(e,o),this.h._addProtoToInputSidePacket(o,e.length,i,n),this.h._free(o)}))}))}addBoolVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let i of e)this.h._addBoolVectorEntry(n,i);this.h._addBoolVectorToInputSidePacket(n,r)}))}addDoubleVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let i of e)this.h._addDoubleVectorEntry(n,i);this.h._addDoubleVectorToInputSidePacket(n,r)}))}addFloatVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let i of e)this.h._addFloatVectorEntry(n,i);this.h._addFloatVectorToInputSidePacket(n,r)}))}addIntVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let i of e)this.h._addIntVectorEntry(n,i);this.h._addIntVectorToInputSidePacket(n,r)}))}addUintVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let i of e)this.h._addUintVectorEntry(n,i);this.h._addUintVectorToInputSidePacket(n,r)}))}addStringVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let i of e)ie(this,i,(o=>{this.h._addStringVectorEntry(n,o)}));this.h._addStringVectorToInputSidePacket(n,r)}))}attachBoolListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachBoolListener(r)}))}attachBoolVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachBoolVectorListener(r)}))}attachIntListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachIntListener(r)}))}attachIntVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachIntVectorListener(r)}))}attachUintListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachUintListener(r)}))}attachUintVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachUintVectorListener(r)}))}attachDoubleListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachDoubleListener(r)}))}attachDoubleVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachDoubleVectorListener(r)}))}attachFloatListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachFloatListener(r)}))}attachFloatVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachFloatVectorListener(r)}))}attachStringListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachStringListener(r)}))}attachStringVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachStringVectorListener(r)}))}attachProtoListener(e,t,r){yn(this,e,t),ie(this,e,(n=>{this.h._attachProtoListener(n,r||!1)}))}attachProtoVectorListener(e,t,r){Gn(this,e,t),ie(this,e,(n=>{this.h._attachProtoVectorListener(n,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?'),yn(this,e,((n,i)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,i)})),ie(this,e,(n=>{this.h._attachAudioListener(n,r||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}}),l2=class extends h3{};async function d3(e,t,r){return e=await(async(n,i,o,s)=>{if(i&&await V0(i),!self.ModuleFactory||o&&(await V0(o),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&s&&((i=self.Module).locateFile=s.locateFile,s.mainScriptUrlOrBlob&&(i.mainScriptUrlOrBlob=s.mainScriptUrlOrBlob)),s=await self.ModuleFactory(self.Module||s),self.ModuleFactory=self.Module=void 0,new n(s,null)})(e,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:n=>n.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&n.endsWith(".data")?t.assetBinaryPath.toString():n}),await e.o(r),e}async function h2(e,t,r){return d3(e,t,r)}function Fd(e,t){let r=wr(e.baseOptions,ac,1)||new ac;typeof t=="string"?(pt(r,2,nc(t)),pt(r,1)):t instanceof Uint8Array&&(pt(r,1,r1(t,!1)),pt(r,2)),Sr(e.baseOptions,0,1,r)}function d2(e,t){let r=t.baseOptions||{};if(t.baseOptions?.modelAssetBuffer&&t.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(wr(e.baseOptions,ac,1)?.g()||wr(e.baseOptions,ac,1)?.i()||t.baseOptions?.modelAssetBuffer||t.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if((function(n,i){let o=wr(n.baseOptions,U0,3);if(!o){var s=o=new U0;Dd(s,4,new D0)}"delegate"in i&&(i.delegate==="GPU"?Dd(i=o,2,s=new Q_):Dd(i=o,4,s=new D0)),Sr(n.baseOptions,0,3,o)})(e,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then((n=>{if(n.ok)return n.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${n.status})`)})).then((n=>{try{e.g.h.FS_unlink("/model.dat")}catch{}e.g.h.FS_createDataFile("/","model.dat",new Uint8Array(n),!0,!1,!1),Fd(e,"/model.dat"),e.v()}));if(r.modelAssetBuffer instanceof Uint8Array)Fd(e,r.modelAssetBuffer);else if(r.modelAssetBuffer)return(async function(n){let i=[];for(var o=0;;){let{done:s,value:a}=await n.read();if(s)break;i.push(a),o+=a.length}if(i.length===0)return new Uint8Array(0);if(i.length===1)return i[0];n=new Uint8Array(o),o=0;for(let s of i)n.set(s,o),o+=s.length;return n})(r.modelAssetBuffer).then((n=>{Fd(e,n),e.v()}));return e.v(),Promise.resolve()}function W0(e){try{let t=e.j.length;if(t===1)throw Error(e.j[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.j.map((r=>r.message)).join(", "))}finally{e.j=[]}}function qi(e,t){e.s=Math.max(e.s,t)}var Qa=class{constructor(e){this.g=e,this.j=[],this.s=0,this.g.setAutoRenderToScreen(!1)}setGraph(e,t){this.g.attachErrorListener(((r,n)=>{this.j.push(Error(n))})),this.g.N(),this.g.setGraph(e,t),W0(this)}finishProcessing(){this.g.finishProcessing(),W0(this)}close(){this.g.closeGraph()}};async function Xo(e,t,r){return h2(e,t,r)}Qa.prototype.close=Qa.prototype.close,(function(e,t){e=e.split(".");var r,n=Kn;for((e[0]in n)||n.execScript===void 0||n.execScript("var "+e[0]);e.length&&(r=e.shift());)e.length||t===void 0?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=t})("TaskRunner",Qa);var lc=class extends Qa{constructor(){super(...arguments),this.F=48e3}O(e){this.F=e}};function u3(e){let t={classifications:hu(e,o3).map((r=>(function(n,i=-1,o=""){return{categories:n.map((s=>{var a=Xn(_r(s,1))??0??-1;let c=s.l,l=0|c[se],h=Zn(c,l,2),d=Qo(h);return d!=null&&d!==h&<(c,l,2,d),{index:a,score:d??0??0,categoryName:Sn(_r(s,3))??""??"",displayName:Sn(_r(s,4))??""??""}})),headIndex:i,headName:o}})(wr(r,t3,4)?.g()??[],Xn(_r(r,2))??0,Sn(_r(r,3))??"")))};return zd(_r(e,2))!=null&&(t.timestampMs=zd(_r(e,2))??0),t}lc.prototype.setDefaultSampleRate=lc.prototype.O;var or=class extends lc{constructor(e,t){super(new l2(e,t)),this.m=[],Sr(e=this.i=new o2,0,1,t=new cc)}get baseOptions(){return wr(this.i,cc,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,M0,2);if(r=r?m1(r):new M0,e.displayNamesLocale!==void 0?pt(r,1,nc(e.displayNamesLocale)):e.displayNamesLocale===void 0&&pt(r,1),e.maxResults!==void 0){var n=e.maxResults;if(n!=null){if(typeof n!="number"||!pc(n))throw p0();n|=0}pt(r,2,n)}else"maxResults"in e&&pt(r,2);if(e.scoreThreshold!==void 0){if((n=e.scoreThreshold)!=null&&typeof n!="number")throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);pt(r,3,n)}else"scoreThreshold"in e&&pt(r,3);return e.categoryAllowlist!==void 0?S0(r,4,e.categoryAllowlist):"categoryAllowlist"in e&&pt(r,4),e.categoryDenylist!==void 0?S0(r,5,e.categoryDenylist):"categoryDenylist"in e&&pt(r,5),Sr(t,0,2,r),d2(this,e)}K(e,t){return this.D(e,t??this.F,this.s+1)}D(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]}v(){var e=new Au;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"timestamped_classifications");let t=new n2;I1(t,n3,this.i);let r=new xu;b1(r,nc("mediapipe.tasks.audio.audio_classifier.AudioClassifierGraph")),Ot(r,3,"AUDIO:audio_in"),Ot(r,3,"SAMPLE_RATE:sample_rate"),Ot(r,4,"TIMESTAMPED_CLASSIFICATIONS:timestamped_classifications"),r.o(t),S1(e,r),this.g.attachProtoVectorListener("timestamped_classifications",((n,i)=>{(function(o,s){s.forEach((a=>{a=s3(a),o.m.push(u3(a))}))})(this,n),qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_classifications",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function $0(e){return{embeddings:hu(e,c3).map((t=>{let r={headIndex:Xn(_r(t,3))??0??-1,headName:Sn(_r(t,4))??""??""};if(_1(t,z0,Pd(t,1))!==void 0)r.floatEmbedding=y1(wr(t,z0,Pd(t,1)),1,Qo,n1===void 0?2:4).slice();else{let n=new Uint8Array(0);r.quantizedEmbedding=wr(t,a3,Pd(t,2))?.J()?.i()??n}return r})),timestampMs:zd(_r(e,2))??0}}or.prototype.classify=or.prototype.K,or.prototype.setOptions=or.prototype.o,or.createFromModelPath=function(e,t){return h2(or,e,{baseOptions:{modelAssetPath:t}})},or.createFromModelBuffer=function(e,t){return Xo(or,e,{baseOptions:{modelAssetBuffer:t}})},or.createFromOptions=function(e,t){return Xo(or,e,t)};var Mr=class extends lc{constructor(e,t){super(new l2(e,t)),this.m=[],Sr(e=this.i=new a2,0,1,t=new cc)}get baseOptions(){return wr(this.i,cc,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,N0,2);return r=r?m1(r):new N0,e.l2Normalize!==void 0?pt(r,1,_0(e.l2Normalize)):"l2Normalize"in e&&pt(r,1),e.quantize!==void 0?pt(r,2,_0(e.quantize)):"quantize"in e&&pt(r,2),Sr(t,0,2,r),d2(this,e)}L(e,t){return this.D(e,t??this.F,this.s+1)}D(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}v(){var e=new Au;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"embeddings_out"),Ot(e,15,"timestamped_embeddings_out");let t=new n2;I1(t,i3,this.i);let r=new xu;b1(r,nc("mediapipe.tasks.audio.audio_embedder.AudioEmbedderGraph")),Ot(r,3,"AUDIO:audio_in"),Ot(r,3,"SAMPLE_RATE:sample_rate"),Ot(r,4,"EMBEDDINGS:embeddings_out"),Ot(r,4,"TIMESTAMPED_EMBEDDINGS:timestamped_embeddings_out"),r.o(t),S1(e,r),this.g.attachProtoListener("embeddings_out",((n,i)=>{n=j0(n),this.m.push($0(n)),qi(this,i)})),this.g.attachEmptyPacketListener("embeddings_out",(n=>{qi(this,n)})),this.g.attachProtoVectorListener("timestamped_embeddings_out",((n,i)=>{for(let o of n)n=j0(o),this.m.push($0(n));qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_embeddings_out",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}},Ya;Mr.prototype.embed=Mr.prototype.L,Mr.prototype.setOptions=Mr.prototype.o,Mr.createFromModelPath=function(e,t){return Xo(Mr,e,{baseOptions:{modelAssetPath:t}})},Mr.createFromModelBuffer=function(e,t){return Xo(Mr,e,{baseOptions:{modelAssetBuffer:t}})},Mr.createFromOptions=function(e,t){return Xo(Mr,e,t)};var f3=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 u2(){if(Ya===void 0)try{await WebAssembly.instantiate(f3),Ya=!0}catch{Ya=!1}return Ya}async function Wo(e,t=Z_``){let r=await u2()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var bn=class{};bn.forVisionTasks=function(e){return Wo("vision",e)},bn.forTextTasks=function(e){return Wo("text",e)},bn.forGenAiExperimentalTasks=function(e){return Wo("genai_experimental",e)},bn.forGenAiTasks=function(e){return Wo("genai",e)},bn.forAudioTasks=function(e){return Wo("audio",e)},bn.isSimdSupported=function(){return u2()};function p3(e,t){let r=e.reduce((a,c)=>a+c.length,0),n=new ArrayBuffer(44+r*2),i=new DataView(n),o=(a,c,l)=>{for(let h=0;h<l.length;h++)a.setUint8(c+h,l.charCodeAt(h))};o(i,0,"RIFF"),i.setUint32(4,36+r*2,!0),o(i,8,"WAVE"),o(i,12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),o(i,36,"data"),i.setUint32(40,r*2,!0);let s=44;for(let a of e)for(let c=0;c<a.length;c++){let l=Math.max(-1,Math.min(1,a[c]));i.setInt16(s,l<0?l*32768:l*32767,!0),s+=2}return new Blob([i],{type:"audio/wav"})}var Ac=class{constructor(t,r,n,i,o,s,a){this.recordingInProgress=!1;this.recordIndex=1;this.countLoopTimes=0;this.examStartTime=0;this.recordingStartTime=0;this.recordingEndTime=0;this.isSpeech=!1;this.preRollBuffer=[];this.recordingChunks=[];this.PRE_ROLL_SECONDS=2;this.SAMPLE_RATE=16e3;this.MAX_PRE_ROLL_CHUNKS=4;this.lastNoiseTime=0;this.SILENCE_THRESHOLD=3e3;this.optionsProctoring=t,this.proctoringSession=r,this.paramsConfig=n,this.cameraRecorder=i,this.onRealtimeAlertsCallback=o,this.backend=s,this.backendToken=a}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Yr(this.proctoringId,this.backend))}async startRecording(){this.examStartTime=Date.now(),await this.createAudioClassifier(),this.audioRecorder=new Ga(void 0,this.paramsConfig.audioBehaviourParameters),this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetectedRecord(),200),this.streamingAudioClassification()}async stopRecording(){clearInterval(this.intervalNoiseDetection),await this.stopSoundRecord(),await this.volumeMeter&&this.volumeMeter.stop(),this.audioWorkletNode&&this.audioWorkletNode.disconnect(),this.context&&this.context.close()}async pauseRecording(){}async resumeRecording(){}async saveOnSession(t){}async onNoiseDetectedRecord(){!this.volumeMeter&&this.cameraRecorder.cameraStream&&(this.volumeMeter=new gn(this.cameraRecorder.cameraStream),this.volumeMeter.start().catch(i=>{console.log(i),this.volumeMeter=void 0}));let t=this.paramsConfig.audioBehaviourParameters?.noiseLimit||40,r=this.volumeMeter?.getVolume()||0;this.isSpeech=this.isSpeech||this.hasDesiredResult(this.audioClassificationResult),!this.isSpeech&&!this.recordingInProgress&&(t=t*1.25);let n=r>=t;if(n&&(this.lastNoiseTime=Date.now()),n&&!this.recordingInProgress){this.recordingInProgress=!0,this.recordingChunks=[...this.preRollBuffer];let o=this.preRollBuffer.reduce((a,c)=>a+c.length,0)/this.SAMPLE_RATE*1e3,s=Date.now()-this.examStartTime;this.recordingStartTime=s-o,this.recordingStartTime<0&&(this.recordingStartTime=0)}else if(this.recordingInProgress){let i=Date.now()-this.lastNoiseTime,o=Date.now()-this.recordingStartTime;i>=this.SILENCE_THRESHOLD&&o>=3e3&&this.countLoopTimes>4&&(await this.stopSoundRecord(),this.paramsConfig.videoBehaviourParameters?.detectNoise&&!this.isSpeech&&this.onRealtimeAlertsCallback({status:"ALERT",description:"Barulho detectado",type:"audio_detection_on_stream"}),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(!this.recordingInProgress&&this.recordingChunks.length===0||(this.recordingEndTime=Date.now()-this.examStartTime,this.optionsProctoring.proctoringType!=="REALTIME"))return;let t=p3(this.recordingChunks,this.SAMPLE_RATE),r=new File([t],`EP_${this.proctoringSession.id}_${this.recordingStartTime}_${this.recordingEndTime}_${this.isSpeech?"speech":"noise"}.wav`,{type:"audio/wav"});this.uploadRecord(r),this.recordingChunks=[],this.recordingInProgress=!1}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}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){let n=r.name.toLowerCase().includes("speech");if(this.optionsProctoring.proctoringType!=="REALTIME")return n;let i=parseFloat(r.score)>.22;if(n&&i)return!0}return!1}async createAudioClassifier(){let t=await bn.forAudioTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-audio@0.10.0/wasm");this.audioClassifier=await or.createFromOptions(t,{scoreThreshold:.15,maxResults:1,baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/1/yamnet.tflite"}})}async streamingAudioClassification(){this.context=new AudioContext({sampleRate:this.SAMPLE_RATE});try{await this.context.audioWorklet.addModule(URL.createObjectURL(new Blob([m3],{type:"text/javascript"})))}catch{throw new Error("\u274C Error loading audio worklet module")}let t=this.context.createMediaStreamSource(this.cameraRecorder.cameraStream);this.audioWorkletNode=new AudioWorkletNode(this.context,"audio-processor"),this.audioWorkletNode.port.onmessage=r=>{let n=r.data;this.preRollBuffer.push(n),this.preRollBuffer.length>this.MAX_PRE_ROLL_CHUNKS&&this.preRollBuffer.shift(),this.recordingInProgress&&this.recordingChunks.push(n);let o=this.audioClassifier.classify(n)[0].classifications[0].categories;o.length>0&&(this.audioClassificationResult=[{name:o[0].categoryName,score:o[0].score.toFixed(3)}])},t.connect(this.audioWorkletNode),this.audioWorkletNode.connect(this.context.destination)}},m3=`
|
|
438
438
|
class AudioProcessor extends AudioWorkletProcessor {
|
|
439
439
|
bufferSize;
|
|
440
440
|
inputBuffer;
|
|
@@ -502,7 +502,7 @@ registerProcessor("audio-processor", AudioProcessor);
|
|
|
502
502
|
<circle cx="10" cy="10" r="9" stroke="#16A34A" stroke-width="2" fill="none"/>
|
|
503
503
|
<path d="M6 10L9 13L14 7" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
504
504
|
</svg>
|
|
505
|
-
`,this.applyStyles(_,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",flexShrink:"0"});let S=document.createElement("span");S.innerText=f,b.appendChild(_),b.appendChild(S),c.appendChild(b)}),s.appendChild(c);let h=document.createElement("button");h.innerText="Capturar foto",h.id="position-capture-button",this.applyStyles(h,{marginTop:"10px",padding:"12px 24px",fontSize:"14px",fontWeight:"bold",color:"white",backgroundColor:"#16A34A",border:"none",borderRadius:"6px",cursor:"pointer",transition:"background-color 0.2s",alignSelf:"flex-start"}),h.onclick=()=>{if(this.connection){let f=document.getElementById("photo-message");f&&(f.innerText="N\xE3o saia da posi\xE7\xE3o atual, estamos validando o ambiente..."),n.style.display="none",this.takePicture(!0,()=>{}),h.disabled=!0,this.applyStyles(h,{backgroundColor:"#9CA3AF",cursor:"not-allowed"})}},s.appendChild(h),i.appendChild(s),t.appendChild(i);let d=document.createElement("div");this.applyStyles(d,{marginTop:"10px",fontSize:"13px",color:"#666"});let m=document.createElement("span");m.innerText="Dica: ",m.style.fontWeight="bold";let p=document.createElement("span");p.innerText="mantenha o celular est\xE1vel durante todo o processo.",d.appendChild(m),d.appendChild(p),t.appendChild(d);let g=document.getElementById("external-camera-continue");g.disabled=!0,this.applyStyles(g,{color:"#ccc",cursor:"not-allowed"})}renderImageStep(t){t.innerHTML="";let r=document.createElement("img");r.src="data:image/jpeg;base64,"+this.capturePhotoUrl,this.applyStyles(r,{maxWidth:"100%",maxHeight:"300px",borderRadius:"8px"}),t.appendChild(r);let n=document.createElement("photo-message");n.id="photo-message",n.innerText="Verifica\xE7\xE3o finalizada com sucesso.",this.applyStyles(n,{textAlign:"center",color:"#555",marginTop:"20px"}),t.appendChild(n);let i=document.getElementById("external-camera-continue");i.disabled=!1,i.innerText="Concluir",this.applyStyles(i,{width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"0 0 10px 0",cursor:"pointer",borderLeft:"2px solid rgba(0, 0, 0, .1)"}),i.onclick=()=>{this.closeCheckExternalCamera(),this.resolvePromise({result:!0})}}nextState(){this.renderCurrentStep()}async initializeWebSocketConnection(){let t=this.backend.getSocketUrl();this.connection=new as().withUrl(t,{accessTokenFactory:()=>this.context.token,transport:Ve.WebSockets,withCredentials:!1,skipNegotiation:!0}).withAutomaticReconnect().configureLogging(L.Information).build(),this.connection.on("ReceiveMessage",(r,n)=>{if(console.log("sessionId: ",r),console.log("Message: ",n),r!==this.externalSessionId){console.warn("Sess\xE3o diferente!");return}try{let o=_y[n];console.log("Mensagem -> ",o),this.handleWebSocketMessage(o)}catch(i){console.error("Erro ao processar mensagem do WebSocket:",i)}}),this.connection.on("ReceiveAction",(r,n)=>{if(console.log("sessionId: ",r),console.log("Message: ",n),r!==this.externalSessionId){console.warn("Sess\xE3o diferente!");return}try{this.handleWebSocketAction(n)}catch(i){console.error("Erro ao processar mensagem do WebSocket:",i)}});try{await this.connection.start(),console.log("Conectado ao Hub SignalR com sucesso!")}catch(r){throw console.error("Falha ao conectar ou entrar no grupo do SignalR: ",r),new Error("N\xE3o foi poss\xEDvel conectar ao servi\xE7o em tempo real.")}}handleWebSocketAction(t){let r=document.getElementById("position-capture-button"),n=document.getElementById("photo-message"),i=document.getElementById("photo-error-banner");switch(t.command){case"Capture_Error":r&&(this.applyStyles(r,{marginTop:"30px",padding:"12px 20px",fontSize:"16px",fontWeight:"bold",color:"white",backgroundColor:"#16A34A",border:"none",borderRadius:"8px",cursor:"pointer",transition:"background-color 0.2s"}),r.disabled=!1),n&&(n.innerText=""+t.message),i&&(i.style.display="flex"),this.waitingPositionValidation==!0&&this.onTakePictureCallback({photo:this.capturePhotoUrl,errorMessage:t.message,success:!1});break;case"CapturePhoto":this.capturePhotoUrl=""+t.message;let o=document.getElementById("photo-icon-container");if(o&&this.capturePhotoUrl&&this.capturePhotoUrl.trim()!==""){let s=document.getElementById("img-photo");s||(o.innerHTML="",s=document.createElement("img"),s.id="img-photo",this.applyStyles(s,{width:"100%",height:"100%",objectFit:"contain",objectPosition:"center",borderRadius:"8px",display:"block"}),o.appendChild(s));let a=this.capturePhotoUrl.startsWith("data:")?this.capturePhotoUrl:"data:image/jpeg;base64,"+this.capturePhotoUrl;s.src=a,s.onload=()=>{console.log("Image loaded successfully in icon container")},s.onerror=c=>{console.error("Error loading image:",c)}}this.waitingPositionValidation==!1&&this.onTakePictureCallback({photo:this.capturePhotoUrl});break;case"Check_Transmission":t.message=="Transmission_OK"&&(this.transmissionOk=!0);break;case"Cancel":this.closeCheckExternalCamera();break;case"EnvironmentAlert":this.onRealtimeAlertsCallback({status:"ALERT",description:t.message,type:"environment_alert"});break}}handleWebSocketMessage(t){switch(this.currentStep=t,t){case 1:this.currentStep===1&&(this.nextState(),this.onQrCodeReadedCallback(!0));break;case 2:this.nextState(),this.waitingPositionValidation==!0&&this.onTakePictureCallback({photo:this.capturePhotoUrl,success:!0});break;case 3:this.closeCheckExternalCamera();break;case 9:console.error("Erro recebido do processo de c\xE2mera externa."),this.closeCheckExternalCamera(),this.resolvePromise({result:!1});break}}async disconnectWebSocket(){if(this.connection)try{await this.connection.stop(),console.log("Desconectado do SignalR.")}catch(t){console.error("Erro ao desconectar do SignalR:",t)}finally{this.connection=null}}closeCheckExternalCamera(){e.isModalOpen=!1,this.disconnectWebSocket(),document.querySelector("#externalCameraCheck")?.remove()}applyStyles(t,r){for(let n in r)t.style[n]=r[n]}};var cl=class{constructor(t){this.context=t;this.deviceData=null;this.sessionStartTime=0;this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectFace:!1,detectPerson:!1,detectCellPhone:!1,detectNoise:!1,detectSpeech:!1,realtimePackageSize:10,realtimeCaptureInterval:2}};this.proctoringId="";this.insights=void 0;this.state="Stop";this.serviceType="Upload";this.onStopSharingScreenCallback=()=>{};this.onLostFocusCallback=()=>{};this.onLostFocusAlertRecorderCallback=t=>{};this.onFocusCallback=()=>{};this.onFocusAlertRecorderCallback=t=>{};this.onChangeDevicesCallback=t=>{};this.onRealtimeAlertsCallback=t=>{};this.onBufferSizeErrorCallback=t=>{};this.backend=new nr({type:t.type||"prod",token:t.token}),this.repository=new rs("EasyProctorDb","exams2"),this.repositoryDevices=new rs("EasyProctorDbDevices","devices"),this.context.credentials?.cpf&&(this.auth=new Ic(this.context.credentials.cpf,this.backend)),this.appChecker=new al(this.context,r=>this.onRealtimeAlertsCallback(r))}setOnStopSharingScreenCallback(t){this.onStopSharingScreenCallback=async()=>{ue.registerStopSharingScreen(this.proctoringId,"Stop sharing screen"),this.allRecorders?.alertRecorder?.addAlert({alert:34,type:3}),this.allRecorders?.screenRecorder?.stopRecording(),t()}}setOnLostFocusAlertRecorderCallback(){this.onLostFocusAlertRecorderCallback=async t=>{this.onLostFocusCallback&&this.onLostFocusCallback(),this.sessionOptions.proctoringType==="REALTIME"&&await this.onRealtimeAlertsCallback({type:"lost_focus",category:"lost_focus",description:"Perda de foco no exame",begin:t.begin,end:t.end,alert:25,status:"ALERT"})}}setOnFocusAlertRecorderCallback(){this.onFocusAlertRecorderCallback=async t=>{this.onFocusCallback&&this.onFocusCallback(),this.sessionOptions.proctoringType==="REALTIME"&&await this.onRealtimeAlertsCallback({type:"focus",category:"focus",description:"Retorno de foco no exame",begin:t.begin,end:t.end,alert:25,status:"OK"})}}async setOnLostFocusCallback(t){this.onLostFocusCallback=async()=>await t(),this.setOnLostFocusAlertRecorderCallback()}async setOnFocusCallback(t){this.onFocusCallback=async()=>await t(),this.setOnFocusAlertRecorderCallback()}async onChangeDevices(t={}){new Ha(this.repositoryDevices,this.proctoringId,this.sessionOptions,this.allRecorders).startRecording(t),this.onChangeDevicesCallback=n=>t.status&&t.status(n)}convertRealtimeCategoryToAlertCategory(t){switch(t){case"no_face_detected":return 1;case"multiple_faces_detected":return 2;case"multiple_persons_detected":return 28;case"no_person_detected":return 29;case"lost_focus":return 25;case"focus":return 25;default:return null}}convertRealtimeTypeToWarningType(t){switch(t){case"face_detection_on_stream":return 0;case"person_detection_on_stream":return 1;case"lost_focus":return 2;case"focus":return 2;default:return null}}async stopRealtimeAlert(t){let n=async i=>{if(!(i>3))try{var o=await this.backend.stopRealtimeAlert({proctoringId:this.proctoringId,begin:t.begin,end:t.end,warningCategoryEnum:this.convertRealtimeTypeToWarningType(t.type),alertImageBase64:await this.allRecorders.cameraRecorder.getCurrentImageBase64(),retry:i<2});return console.log("response stopRealtimeAlert",o),o}catch(s){return console.log("error stopRealtimeAlert",s),n(i+1)}};await n(1)}async onRealtimeAlerts(t={}){this.setOnLostFocusAlertRecorderCallback(),this.setOnFocusAlertRecorderCallback(),this.onRealtimeAlertsCallback=async r=>{t.data&&t.data(r),this.sessionOptions.proctoringType==="REALTIME"&&(r.type==="face_detection_on_stream"||r.type==="person_detection_on_stream"||r.type==="lost_focus"||r.type==="focus")&&(r.status==="ALERT"?await this.backend.startRealtimeAlert({proctoringId:this.proctoringId,begin:r.begin,end:r.end,alert:this.convertRealtimeCategoryToAlertCategory(r.category)}):r.status==="OK"&&await this.stopRealtimeAlert(r))}}setOnBufferSizeErrorCallback(t){this.onBufferSizeErrorCallback=r=>t(r)}setDeviceCheckData(t){this.deviceData=t}createRecorders(t=ir){this.onChangeDevices();let r=new Zr({cameraId:this.sessionOptions.cameraId,microphoneId:this.sessionOptions.microphoneId,onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:a=>this.onBufferSizeErrorCallback(a),proctoringType:this.sessionOptions.proctoringType,onChangeDevicesCallback:a=>this.onChangeDevicesCallback(a),onRealtimeAlertsCallback:a=>this.onRealtimeAlertsCallback(a)},{width:this.videoOptions.width,height:this.videoOptions.height,minWidth:this.videoOptions.minWidth,minHeight:this.videoOptions.minHeight,timeSlice:this.videoOptions.timeSlice,videoBitsPerSecond:this.videoOptions.videoBitsPerSecond,mimeType:this.videoOptions.mimeType},this.paramsConfig,this.backend,this.context.token),n=this.sessionOptions.captureScreen?new Tc({allowOnlyFirstMonitor:this.sessionOptions.allowOnlyFirstMonitor??!0,allowMultipleMonitors:this.sessionOptions.allowMultipleMonitors??!0,screenRecorderOptions:this.sessionOptions.screenRecorderOptions,onStopSharingScreenCallback:()=>this.onStopSharingScreenCallback(),onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:()=>this.onBufferSizeErrorCallback()}):void 0,i=new $a({onFocusCallback:a=>this.onFocusAlertRecorderCallback(a),onLostFocusCallback:a=>this.onLostFocusAlertRecorderCallback(a),onRealtimeAlertCallback:a=>this.onRealtimeAlertsCallback(a)},t),o=new Ac(t,this.proctoringSession,this.paramsConfig,r,a=>this.onRealtimeAlertsCallback(a),this.backend,this.context.token),s=[r,n,i].filter(Boolean);return s.push(o),this.recorder=new Wa(this.proctoringSession,s),{cameraRecorder:r,screenRecorder:n,alertRecorder:i,noiseRecorder:o}}async login(){if(!this.context.credentials?.cpf)throw e0;this.context.token=await this.auth.login()}async start(t=ir,r={}){try{if(this.context.token===void 0)throw Qg;t.useChallenge&&(this.extensionEasycatcher=new Va),this.extension=new ja,this.extension.addEventListener();let n=this.backend.selectBaseUrl(this.context.type),i=await ur();await this.repositoryDevices.save({...i,id:"devices"}),this.sessionOptions={...ir,...t},this.videoOptions=Oa(r),await this.initConfig(t.useGeolocation),await this.verifyBrowser(),this.sessionOptions.captureScreen&&await this.verifyMultipleMonitors(this.sessionOptions);try{t?.useSpyScan&&await this.spyCam.isAlive()}catch{throw t0}if(this.state!="Stop")throw Yg;this.state="Starting",await this.repository.hasSessions()&&await this.repository.clear(),this.proctoringSession=new Hn,this.allRecorders=this.createRecorders(this.sessionOptions);let o=await this.backend.confirmStart({clientId:this.context.clientId,examId:this.context.examId,token:this.context.token},this.sessionOptions,this.geolocation?this.geolocation.coords.latitude:void 0,this.geolocation?this.geolocation.coords.longitude:void 0);this.proctoringId=o.id,ue.registerDevicesChecked(this.proctoringId,!!this.deviceData,`Devices checked: ${JSON.stringify(this.deviceData)} | Devices List: ${JSON.stringify(i)}`);try{t?.useExternalCamera&&await this.appChecker.startTransmission(this.proctoringId)}catch{throw r0}this.sessionStartTime=Date.now(),this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId),this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId),this.proctoringSession.setProctoringId(this.proctoringId),await this.recorder.startAll(),t?.useSpyScan&&(this.spyCam.setProctoringId(this.proctoringId),this.spyCam.startCheckSpyCam(this.paramsConfig.spyScanInterval??5,{deviceType:3})),await this.repository.save(this.proctoringSession);let s={};for(let l in navigator)s[l]=navigator[l];ue.registerStart(this.proctoringId,!0,`Version: ${ns()}
|
|
505
|
+
`,this.applyStyles(_,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",flexShrink:"0"});let S=document.createElement("span");S.innerText=f,b.appendChild(_),b.appendChild(S),c.appendChild(b)}),s.appendChild(c);let h=document.createElement("button");h.innerText="Capturar foto",h.id="position-capture-button",this.applyStyles(h,{marginTop:"10px",padding:"12px 24px",fontSize:"14px",fontWeight:"bold",color:"white",backgroundColor:"#16A34A",border:"none",borderRadius:"6px",cursor:"pointer",transition:"background-color 0.2s",alignSelf:"flex-start"}),h.onclick=()=>{if(this.connection){let f=document.getElementById("photo-message");f&&(f.innerText="N\xE3o saia da posi\xE7\xE3o atual, estamos validando o ambiente..."),n.style.display="none",this.takePicture(!0,()=>{}),h.disabled=!0,this.applyStyles(h,{backgroundColor:"#9CA3AF",cursor:"not-allowed"})}},s.appendChild(h),i.appendChild(s),t.appendChild(i);let d=document.createElement("div");this.applyStyles(d,{marginTop:"10px",fontSize:"13px",color:"#666"});let m=document.createElement("span");m.innerText="Dica: ",m.style.fontWeight="bold";let p=document.createElement("span");p.innerText="mantenha o celular est\xE1vel durante todo o processo.",d.appendChild(m),d.appendChild(p),t.appendChild(d);let g=document.getElementById("external-camera-continue");g.disabled=!0,this.applyStyles(g,{color:"#ccc",cursor:"not-allowed"})}renderImageStep(t){t.innerHTML="";let r=document.createElement("img");r.src="data:image/jpeg;base64,"+this.capturePhotoUrl,this.applyStyles(r,{maxWidth:"100%",maxHeight:"300px",borderRadius:"8px"}),t.appendChild(r);let n=document.createElement("photo-message");n.id="photo-message",n.innerText="Verifica\xE7\xE3o finalizada com sucesso.",this.applyStyles(n,{textAlign:"center",color:"#555",marginTop:"20px"}),t.appendChild(n);let i=document.getElementById("external-camera-continue");i.disabled=!1,i.innerText="Concluir",this.applyStyles(i,{width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"0 0 10px 0",cursor:"pointer",borderLeft:"2px solid rgba(0, 0, 0, .1)"}),i.onclick=()=>{this.closeCheckExternalCamera(),this.resolvePromise({result:!0})}}nextState(){this.renderCurrentStep()}async initializeWebSocketConnection(){let t=this.backend.getSocketUrl();this.connection=new as().withUrl(t,{accessTokenFactory:()=>this.context.token,transport:Ve.WebSockets,withCredentials:!1,skipNegotiation:!0}).withAutomaticReconnect().configureLogging(L.Information).build(),this.connection.on("ReceiveMessage",(r,n)=>{if(console.log("sessionId: ",r),console.log("Message: ",n),r!==this.externalSessionId){console.warn("Sess\xE3o diferente!");return}try{let o=_y[n];console.log("Mensagem -> ",o),this.handleWebSocketMessage(o)}catch(i){console.error("Erro ao processar mensagem do WebSocket:",i)}}),this.connection.on("ReceiveAction",(r,n)=>{if(console.log("sessionId: ",r),console.log("Message: ",n),r!==this.externalSessionId){console.warn("Sess\xE3o diferente!");return}try{this.handleWebSocketAction(n)}catch(i){console.error("Erro ao processar mensagem do WebSocket:",i)}});try{await this.connection.start(),console.log("Conectado ao Hub SignalR com sucesso!")}catch(r){throw console.error("Falha ao conectar ou entrar no grupo do SignalR: ",r),new Error("N\xE3o foi poss\xEDvel conectar ao servi\xE7o em tempo real.")}}handleWebSocketAction(t){let r=document.getElementById("position-capture-button"),n=document.getElementById("photo-message"),i=document.getElementById("photo-error-banner");switch(t.command){case"Capture_Error":r&&(this.applyStyles(r,{marginTop:"30px",padding:"12px 20px",fontSize:"16px",fontWeight:"bold",color:"white",backgroundColor:"#16A34A",border:"none",borderRadius:"8px",cursor:"pointer",transition:"background-color 0.2s"}),r.disabled=!1),n&&(n.innerText=""+t.message),i&&(i.style.display="flex"),this.waitingPositionValidation==!0&&this.onTakePictureCallback({photo:this.capturePhotoUrl,errorMessage:t.message,success:!1});break;case"CapturePhoto":this.capturePhotoUrl=""+t.message;let o=document.getElementById("photo-icon-container");if(o&&this.capturePhotoUrl&&this.capturePhotoUrl.trim()!==""){let s=document.getElementById("img-photo");s||(o.innerHTML="",s=document.createElement("img"),s.id="img-photo",this.applyStyles(s,{width:"100%",height:"100%",objectFit:"contain",objectPosition:"center",borderRadius:"8px",display:"block"}),o.appendChild(s));let a=this.capturePhotoUrl.startsWith("data:")?this.capturePhotoUrl:"data:image/jpeg;base64,"+this.capturePhotoUrl;s.src=a,s.onload=()=>{console.log("Image loaded successfully in icon container")},s.onerror=c=>{console.error("Error loading image:",c)}}this.waitingPositionValidation==!1&&this.onTakePictureCallback({photo:this.capturePhotoUrl});break;case"Check_Transmission":t.message=="Transmission_OK"&&(this.transmissionOk=!0);break;case"Cancel":this.closeCheckExternalCamera();break;case"EnvironmentAlert":this.onRealtimeAlertsCallback({status:"ALERT",description:t.message,type:"environment_alert"});break}}handleWebSocketMessage(t){switch(this.currentStep=t,t){case 1:this.currentStep===1&&(this.nextState(),this.onQrCodeReadedCallback(!0));break;case 2:this.nextState(),this.waitingPositionValidation==!0&&this.onTakePictureCallback({photo:this.capturePhotoUrl,success:!0});break;case 3:this.closeCheckExternalCamera();break;case 9:console.error("Erro recebido do processo de c\xE2mera externa."),this.closeCheckExternalCamera(),this.resolvePromise({result:!1});break}}async disconnectWebSocket(){if(this.connection)try{await this.connection.stop(),console.log("Desconectado do SignalR.")}catch(t){console.error("Erro ao desconectar do SignalR:",t)}finally{this.connection=null}}closeCheckExternalCamera(){e.isModalOpen=!1,this.disconnectWebSocket(),document.querySelector("#externalCameraCheck")?.remove()}applyStyles(t,r){for(let n in r)t.style[n]=r[n]}};var cl=class{constructor(t){this.context=t;this.deviceData=null;this.sessionStartTime=0;this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectFace:!1,detectPerson:!1,detectCellPhone:!1,detectNoise:!1,detectSpeech:!1,realtimePackageSize:10,realtimeCaptureInterval:2}};this.proctoringId="";this.insights=void 0;this.state="Stop";this.serviceType="Upload";this.onStopSharingScreenCallback=()=>{};this.onLostFocusCallback=()=>{};this.onLostFocusAlertRecorderCallback=t=>{};this.onFocusCallback=()=>{};this.onFocusAlertRecorderCallback=t=>{};this.onChangeDevicesCallback=t=>{};this.onRealtimeAlertsCallback=t=>{};this.onBufferSizeErrorCallback=t=>{};this.backend=new nr({type:t.type||"prod",token:t.token}),this.repository=new rs("EasyProctorDb","exams2"),this.repositoryDevices=new rs("EasyProctorDbDevices","devices"),this.context.credentials?.cpf&&(this.auth=new Ic(this.context.credentials.cpf,this.backend)),this.appChecker=new al(this.context,r=>this.onRealtimeAlertsCallback(r))}setOnStopSharingScreenCallback(t){this.onStopSharingScreenCallback=async()=>{ue.registerStopSharingScreen(this.proctoringId,"Stop sharing screen"),this.allRecorders?.alertRecorder?.addAlert({alert:34,type:3}),this.allRecorders?.screenRecorder?.stopRecording(),t()}}setOnLostFocusAlertRecorderCallback(){this.onLostFocusAlertRecorderCallback=async t=>{this.onLostFocusCallback&&this.onLostFocusCallback(),this.sessionOptions.proctoringType==="REALTIME"&&await this.onRealtimeAlertsCallback({type:"lost_focus",category:"lost_focus",description:"Perda de foco no exame",begin:t.begin,end:t.end,alert:25,status:"ALERT"})}}setOnFocusAlertRecorderCallback(){this.onFocusAlertRecorderCallback=async t=>{this.onFocusCallback&&this.onFocusCallback(),this.sessionOptions.proctoringType==="REALTIME"&&await this.onRealtimeAlertsCallback({type:"focus",category:"focus",description:"Retorno de foco no exame",begin:t.begin,end:t.end,alert:25,status:"OK"})}}async setOnLostFocusCallback(t){this.onLostFocusCallback=async()=>await t(),this.setOnLostFocusAlertRecorderCallback()}async setOnFocusCallback(t){this.onFocusCallback=async()=>await t(),this.setOnFocusAlertRecorderCallback()}async onChangeDevices(t={}){new Ha(this.repositoryDevices,this.proctoringId,this.sessionOptions,this.allRecorders).startRecording(t),this.onChangeDevicesCallback=n=>t.status&&t.status(n)}convertRealtimeCategoryToAlertCategory(t){switch(t){case"no_face_detected":return 1;case"multiple_faces_detected":return 2;case"multiple_persons_detected":return 28;case"no_person_detected":return 29;case"lost_focus":return 25;case"focus":return 25;default:return null}}convertRealtimeTypeToWarningType(t){switch(t){case"face_detection_on_stream":return 0;case"person_detection_on_stream":return 1;case"lost_focus":return 2;case"focus":return 2;default:return null}}async stopRealtimeAlert(t){let n=async i=>{if(!(i>3))try{var o=await this.backend.stopRealtimeAlert({proctoringId:this.proctoringId,begin:t.begin,end:t.end,warningCategoryEnum:this.convertRealtimeTypeToWarningType(t.type),alertImageBase64:await this.allRecorders.cameraRecorder.getCurrentImageBase64(),retry:i<2});return console.log("response stopRealtimeAlert",o),o}catch(s){return console.log("error stopRealtimeAlert",s),n(i+1)}};await n(1)}async onRealtimeAlerts(t={}){this.setOnLostFocusAlertRecorderCallback(),this.setOnFocusAlertRecorderCallback(),this.onRealtimeAlertsCallback=async r=>{t.data&&t.data(r),this.sessionOptions.proctoringType==="REALTIME"&&(r.type==="face_detection_on_stream"||r.type==="person_detection_on_stream"||r.type==="lost_focus"||r.type==="focus")&&(r.status==="ALERT"?await this.backend.startRealtimeAlert({proctoringId:this.proctoringId,begin:r.begin,end:r.end,alert:this.convertRealtimeCategoryToAlertCategory(r.category)}):r.status==="OK"&&await this.stopRealtimeAlert(r))}}setOnBufferSizeErrorCallback(t){this.onBufferSizeErrorCallback=r=>t(r)}setDeviceCheckData(t){this.deviceData=t}async createRecorders(t=ir){this.onChangeDevices(),console.log("Creating Recorders..."),await this.recorder?.stopAll();let r=new Zr({cameraId:this.sessionOptions.cameraId,microphoneId:this.sessionOptions.microphoneId,onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:a=>this.onBufferSizeErrorCallback(a),proctoringType:this.sessionOptions.proctoringType,onChangeDevicesCallback:a=>this.onChangeDevicesCallback(a),onRealtimeAlertsCallback:a=>this.onRealtimeAlertsCallback(a)},{width:this.videoOptions.width,height:this.videoOptions.height,minWidth:this.videoOptions.minWidth,minHeight:this.videoOptions.minHeight,timeSlice:this.videoOptions.timeSlice,videoBitsPerSecond:this.videoOptions.videoBitsPerSecond,mimeType:this.videoOptions.mimeType},this.paramsConfig,this.backend,this.context.token),n=this.sessionOptions.captureScreen?new Tc({allowOnlyFirstMonitor:this.sessionOptions.allowOnlyFirstMonitor??!0,allowMultipleMonitors:this.sessionOptions.allowMultipleMonitors??!0,screenRecorderOptions:this.sessionOptions.screenRecorderOptions,onStopSharingScreenCallback:()=>this.onStopSharingScreenCallback(),onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:()=>this.onBufferSizeErrorCallback()}):void 0,i=new $a({onFocusCallback:a=>this.onFocusAlertRecorderCallback(a),onLostFocusCallback:a=>this.onLostFocusAlertRecorderCallback(a),onRealtimeAlertCallback:a=>this.onRealtimeAlertsCallback(a)},t),o=new Ac(t,this.proctoringSession,this.paramsConfig,r,a=>this.onRealtimeAlertsCallback(a),this.backend,this.context.token),s=[r,n,i].filter(Boolean);return s.push(o),this.recorder=new Wa(this.proctoringSession,s),{cameraRecorder:r,screenRecorder:n,alertRecorder:i,noiseRecorder:o}}async login(){if(!this.context.credentials?.cpf)throw e0;this.context.token=await this.auth.login()}async start(t=ir,r={}){try{if(this.context.token===void 0)throw Qg;t.useChallenge&&(this.extensionEasycatcher=new Va),this.extension=new ja,this.extension.addEventListener();let n=this.backend.selectBaseUrl(this.context.type),i=await ur();await this.repositoryDevices.save({...i,id:"devices"}),this.sessionOptions={...ir,...t},this.videoOptions=Oa(r),await this.initConfig(t.useGeolocation),await this.verifyBrowser(),this.sessionOptions.captureScreen&&await this.verifyMultipleMonitors(this.sessionOptions);try{t?.useSpyScan&&await this.spyCam.isAlive()}catch{throw t0}if(this.state!="Stop")throw Yg;this.state="Starting",await this.repository.hasSessions()&&await this.repository.clear(),this.proctoringSession=new Hn,this.allRecorders=await this.createRecorders(this.sessionOptions);let o=await this.backend.confirmStart({clientId:this.context.clientId,examId:this.context.examId,token:this.context.token},this.sessionOptions,this.geolocation?this.geolocation.coords.latitude:void 0,this.geolocation?this.geolocation.coords.longitude:void 0);this.proctoringId=o.id,ue.registerDevicesChecked(this.proctoringId,!!this.deviceData,`Devices checked: ${JSON.stringify(this.deviceData)} | Devices List: ${JSON.stringify(i)}`);try{t?.useExternalCamera&&await this.appChecker.startTransmission(this.proctoringId)}catch{throw r0}this.sessionStartTime=Date.now(),this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId),this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId),this.proctoringSession.setProctoringId(this.proctoringId),await this.recorder.startAll(),t?.useSpyScan&&(this.spyCam.setProctoringId(this.proctoringId),this.spyCam.startCheckSpyCam(this.paramsConfig.spyScanInterval??5,{deviceType:3})),await this.repository.save(this.proctoringSession);let s={};for(let l in navigator)s[l]=navigator[l];ue.registerStart(this.proctoringId,!0,`Version: ${ns()}
|
|
506
506
|
Navigator: ${JSON.stringify(s)}`),o.cameraStream=this.allRecorders.cameraRecorder.cameraStream,this.allRecorders.screenRecorder&&(o.screenStream=this.allRecorders.screenRecorder.screenStream),this.state="Recording";let a=0,c=!1;return this.verifyFirstFaceInterval=setInterval(async()=>{if(this.sessionOptions.proctoringType==="REALTIME"){if(c)return;c=!0,a++;try{var l=await this.backend.verifyFace(this.proctoringId,await this.allRecorders.cameraRecorder.getCurrentImageBase64(),!(a>5));c=!1,clearInterval(this.verifyFirstFaceInterval)}catch{c=!1;return}}},1500),o}catch(n){throw console.log(n),await this.cancel(),this.proctoringId&&ue.registerStart(this.proctoringId,!1,`Token: ${this.context.token}
|
|
507
507
|
Version: ${ns()}
|
|
508
508
|
Navigator: ${navigator}
|