easyproctor 2.5.3 → 2.5.4
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/README.md +7 -0
- package/esm/index.js +66 -36
- package/index.js +66 -36
- package/interfaces/ParamsConfig.d.ts +1 -1
- package/new-flow/proctoring/ProctoringSession.d.ts +3 -3
- package/new-flow/recorders/AlertRecorder.d.ts +1 -0
- package/new-flow/recorders/CameraRecorder.d.ts +1 -1
- package/package.json +1 -1
- package/proctoring/proctoring.d.ts +1 -0
- package/unpkg/easyproctor.min.js +3 -3
package/README.md
CHANGED
|
@@ -263,6 +263,13 @@ const {
|
|
|
263
263
|
token: "...",
|
|
264
264
|
});
|
|
265
265
|
```
|
|
266
|
+
## Release Note V 2.5.4
|
|
267
|
+
- Novos alertas de tela (Clipboard, SplitScreen)
|
|
268
|
+
- Ajustes na detecção de foco da tela
|
|
269
|
+
- Melhorias na analise biométrica
|
|
270
|
+
- Melhorias na analise do uso de dispositivos
|
|
271
|
+
- Correção do uso de câmera externa no ambiente de produção
|
|
272
|
+
|
|
266
273
|
## Release Note V 2.5.3
|
|
267
274
|
- Fix: Resolução do video
|
|
268
275
|
- Melhorias no proctoring do tipo REALTIME
|
package/esm/index.js
CHANGED
|
@@ -12802,7 +12802,7 @@ var CameraRecorder = class {
|
|
|
12802
12802
|
}
|
|
12803
12803
|
}
|
|
12804
12804
|
async startRecording(options) {
|
|
12805
|
-
var _a2, _b, _c2, _d, _e3, _f, _g, _h
|
|
12805
|
+
var _a2, _b, _c2, _d, _e3, _f, _g, _h;
|
|
12806
12806
|
if ((((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace)) && !(options == null ? void 0 : options.retry)) {
|
|
12807
12807
|
await this.initializeDetectors();
|
|
12808
12808
|
}
|
|
@@ -12882,7 +12882,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
12882
12882
|
this.filesToUpload = [];
|
|
12883
12883
|
if (this.options.proctoringType == "REALTIME") {
|
|
12884
12884
|
this.captureFrame();
|
|
12885
|
-
this.sendFrameInterval = setInterval(() => this.captureFrame(), 1e3 * ((_i3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _i3.realtimeUploadInterval));
|
|
12886
12885
|
}
|
|
12887
12886
|
this.packageCount = 0;
|
|
12888
12887
|
}
|
|
@@ -12913,7 +12912,8 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
12913
12912
|
clearInterval(this.imageInterval);
|
|
12914
12913
|
clearInterval(this.sendFrameInterval);
|
|
12915
12914
|
if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
|
|
12916
|
-
await this.sendPackage();
|
|
12915
|
+
await this.sendPackage(this.filesToUpload);
|
|
12916
|
+
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
12917
12917
|
}
|
|
12918
12918
|
this.volumeMeter && this.volumeMeter.stop();
|
|
12919
12919
|
this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
|
|
@@ -12983,23 +12983,29 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
12983
12983
|
this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
|
12984
12984
|
return this.canvas.toDataURL("image/jpeg");
|
|
12985
12985
|
}
|
|
12986
|
-
//
|
|
12986
|
+
// captura um frame a cada intervalo de tempo definido no paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval!
|
|
12987
12987
|
captureFrame() {
|
|
12988
|
-
var _a2;
|
|
12988
|
+
var _a2, _b;
|
|
12989
12989
|
let imageFile;
|
|
12990
12990
|
this.configImageCapture();
|
|
12991
|
+
let newCanvasWidth = this.videoOptions.width / 2;
|
|
12992
|
+
let newCanvasHeight = this.videoOptions.height / 2;
|
|
12993
|
+
if (newCanvasWidth < 320) newCanvasWidth = 320;
|
|
12994
|
+
if (newCanvasHeight < 180) newCanvasHeight = 180;
|
|
12995
|
+
this.canvas.width = newCanvasWidth;
|
|
12996
|
+
this.canvas.height = newCanvasHeight;
|
|
12991
12997
|
const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
|
|
12992
|
-
|
|
12993
|
-
this.imageCount++;
|
|
12998
|
+
this.imageCount = 0;
|
|
12994
12999
|
this.imageInterval = setInterval(async () => {
|
|
13000
|
+
console.log("capturando frame " + this.imageCount);
|
|
12995
13001
|
this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
|
12996
13002
|
const image_data_url = this.canvas.toDataURL("image/jpeg");
|
|
12997
13003
|
if (this.proctoringId == void 0) return;
|
|
12998
|
-
if (
|
|
12999
|
-
initSend = true;
|
|
13004
|
+
if (packSize == this.imageCount) {
|
|
13000
13005
|
this.imageCount = 0;
|
|
13001
|
-
|
|
13002
|
-
this.sendPackage();
|
|
13006
|
+
const framesToSend = [...this.filesToUpload];
|
|
13007
|
+
this.sendPackage(framesToSend);
|
|
13008
|
+
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
13003
13009
|
}
|
|
13004
13010
|
let imageName = `${this.proctoringId}_${this.imageCount + 1}.jpg`;
|
|
13005
13011
|
imageFile = await this.getFile(image_data_url, imageName, "image/jpeg");
|
|
@@ -13007,22 +13013,24 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
13007
13013
|
this.filesToUpload.push(imageFile);
|
|
13008
13014
|
this.imageCount++;
|
|
13009
13015
|
}
|
|
13010
|
-
}, 1e3);
|
|
13016
|
+
}, ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) * 1e3);
|
|
13011
13017
|
}
|
|
13012
13018
|
// envia pacote de imagens
|
|
13013
|
-
async sendPackage() {
|
|
13019
|
+
async sendPackage(framesToSend) {
|
|
13020
|
+
var _a2, _b;
|
|
13014
13021
|
let pending = false;
|
|
13015
13022
|
let undeliveredPackagesCount = 0;
|
|
13023
|
+
const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
|
|
13024
|
+
const packCaptureInterval = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) + 1;
|
|
13016
13025
|
if (this.upload && this.backendToken && !pending && this.filesToUpload.length > 0) {
|
|
13017
13026
|
undeliveredPackagesCount = 0;
|
|
13018
13027
|
pending = true;
|
|
13019
13028
|
const zip = new import_jszip_min.default();
|
|
13020
|
-
const
|
|
13021
|
-
for (const file of files) {
|
|
13029
|
+
for (const file of framesToSend) {
|
|
13022
13030
|
zip.file(file.name, file);
|
|
13023
13031
|
}
|
|
13024
13032
|
const blob = await zip.generateAsync({ type: "blob" });
|
|
13025
|
-
let packageName = "realtime_package_" +
|
|
13033
|
+
let packageName = "realtime_package_" + packSize * packCaptureInterval * this.packageCount + ".zip";
|
|
13026
13034
|
const myPackage = new File(
|
|
13027
13035
|
[blob],
|
|
13028
13036
|
packageName,
|
|
@@ -13035,7 +13043,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
13035
13043
|
this.backendToken
|
|
13036
13044
|
);
|
|
13037
13045
|
if (uploadResult.uploaded == true) {
|
|
13038
|
-
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
13039
13046
|
this.packageCount++;
|
|
13040
13047
|
} else {
|
|
13041
13048
|
console.log("erro no upload do pacote");
|
|
@@ -15110,6 +15117,13 @@ var AlertRecorder = class {
|
|
|
15110
15117
|
// HANDLERS (Funções Arrow para preservar o 'this')
|
|
15111
15118
|
// ==========================================
|
|
15112
15119
|
// 1. LOST / RETURN FOCUS
|
|
15120
|
+
this.handleVisibilityChange = () => {
|
|
15121
|
+
if (document.visibilityState === "visible") {
|
|
15122
|
+
this.handleReturnFocus();
|
|
15123
|
+
} else {
|
|
15124
|
+
this.handleLostFocus();
|
|
15125
|
+
}
|
|
15126
|
+
};
|
|
15113
15127
|
this.handleLostFocus = () => {
|
|
15114
15128
|
if (this.getRelativeTime() > 1e4) {
|
|
15115
15129
|
const alertPayload = {
|
|
@@ -15142,7 +15156,7 @@ var AlertRecorder = class {
|
|
|
15142
15156
|
const windowWidth = window.outerWidth;
|
|
15143
15157
|
if (windowWidth < screenWidth * 0.85) {
|
|
15144
15158
|
const msg = `Split Screen Detectado: Janela ocupa ${(windowWidth / screenWidth * 100).toFixed(0)}% da tela`;
|
|
15145
|
-
this.createAlert(
|
|
15159
|
+
this.createAlert(43 /* SplitScreen */, 3 /* Screen */, msg);
|
|
15146
15160
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15147
15161
|
status: "ALERT",
|
|
15148
15162
|
description: msg,
|
|
@@ -15160,7 +15174,7 @@ var AlertRecorder = class {
|
|
|
15160
15174
|
this.handleCopy = (e3) => {
|
|
15161
15175
|
e3.preventDefault();
|
|
15162
15176
|
const msg = "Tentativa de Copiar (Clipboard)";
|
|
15163
|
-
this.createAlert(
|
|
15177
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
15164
15178
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15165
15179
|
status: "ALERT",
|
|
15166
15180
|
description: msg,
|
|
@@ -15170,7 +15184,7 @@ var AlertRecorder = class {
|
|
|
15170
15184
|
this.handleCut = (e3) => {
|
|
15171
15185
|
e3.preventDefault();
|
|
15172
15186
|
const msg = "Tentativa de Recortar (Clipboard)";
|
|
15173
|
-
this.createAlert(
|
|
15187
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
15174
15188
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15175
15189
|
status: "ALERT",
|
|
15176
15190
|
description: msg,
|
|
@@ -15180,7 +15194,7 @@ var AlertRecorder = class {
|
|
|
15180
15194
|
this.handlePaste = (e3) => {
|
|
15181
15195
|
e3.preventDefault();
|
|
15182
15196
|
const msg = "Tentativa de Colar (Clipboard)";
|
|
15183
|
-
this.createAlert(
|
|
15197
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
15184
15198
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15185
15199
|
status: "ALERT",
|
|
15186
15200
|
description: msg,
|
|
@@ -15216,8 +15230,7 @@ var AlertRecorder = class {
|
|
|
15216
15230
|
// ==========================================
|
|
15217
15231
|
attachListeners() {
|
|
15218
15232
|
if (this.optionsProctoring.captureScreen) {
|
|
15219
|
-
window.addEventListener("
|
|
15220
|
-
window.addEventListener("focus", this.handleReturnFocus);
|
|
15233
|
+
window.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
15221
15234
|
window.addEventListener("resize", this.handleResize);
|
|
15222
15235
|
window.document.addEventListener("copy", this.handleCopy);
|
|
15223
15236
|
window.document.addEventListener("cut", this.handleCut);
|
|
@@ -15225,8 +15238,7 @@ var AlertRecorder = class {
|
|
|
15225
15238
|
}
|
|
15226
15239
|
}
|
|
15227
15240
|
detachListeners() {
|
|
15228
|
-
window.removeEventListener("
|
|
15229
|
-
window.removeEventListener("focus", this.handleReturnFocus);
|
|
15241
|
+
window.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
15230
15242
|
window.removeEventListener("resize", this.handleResize);
|
|
15231
15243
|
window.document.removeEventListener("copy", this.handleCopy);
|
|
15232
15244
|
window.document.removeEventListener("cut", this.handleCut);
|
|
@@ -15261,7 +15273,7 @@ var AlertRecorder = class {
|
|
|
15261
15273
|
// }
|
|
15262
15274
|
// 4. BACKGROUND EVENTS (Eventos disparados manualmente)
|
|
15263
15275
|
addBackgroundEvent(description, category = 200 /* System */) {
|
|
15264
|
-
this.createAlert(category,
|
|
15276
|
+
this.createAlert(category, 3 /* Screen */, description);
|
|
15265
15277
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15266
15278
|
status: "ALERT",
|
|
15267
15279
|
description,
|
|
@@ -21499,7 +21511,8 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
|
|
|
21499
21511
|
this.connection = new HubConnectionBuilder().withUrl(hubUrl, {
|
|
21500
21512
|
accessTokenFactory: () => this.context.token,
|
|
21501
21513
|
transport: HttpTransportType.WebSockets,
|
|
21502
|
-
withCredentials: false
|
|
21514
|
+
withCredentials: false,
|
|
21515
|
+
skipNegotiation: true
|
|
21503
21516
|
}).withAutomaticReconnect().configureLogging(LogLevel.Information).build();
|
|
21504
21517
|
this.connection.on(
|
|
21505
21518
|
"ReceiveMessage",
|
|
@@ -21715,8 +21728,8 @@ var Proctoring = class {
|
|
|
21715
21728
|
detectCellPhone: false,
|
|
21716
21729
|
detectNoise: false,
|
|
21717
21730
|
detectSpeech: false,
|
|
21718
|
-
realtimePackageSize:
|
|
21719
|
-
|
|
21731
|
+
realtimePackageSize: 10,
|
|
21732
|
+
realtimeCaptureInterval: 2
|
|
21720
21733
|
}
|
|
21721
21734
|
};
|
|
21722
21735
|
this.proctoringId = "";
|
|
@@ -21852,6 +21865,29 @@ var Proctoring = class {
|
|
|
21852
21865
|
return null;
|
|
21853
21866
|
}
|
|
21854
21867
|
}
|
|
21868
|
+
// metodo para fechar o alerta realtime e fica tentando verificar a face até 5 vezes
|
|
21869
|
+
async stopRealtimeAlert(alert) {
|
|
21870
|
+
const verifyMaxRetries = 3;
|
|
21871
|
+
const verifyFace = async (verifyCount) => {
|
|
21872
|
+
if (verifyCount > verifyMaxRetries) return;
|
|
21873
|
+
try {
|
|
21874
|
+
var response = await this.backend.stopRealtimeAlert({
|
|
21875
|
+
proctoringId: this.proctoringId,
|
|
21876
|
+
begin: alert.begin,
|
|
21877
|
+
end: alert.end,
|
|
21878
|
+
warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
|
|
21879
|
+
alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
|
|
21880
|
+
retry: verifyCount < verifyMaxRetries - 1 ? true : false
|
|
21881
|
+
});
|
|
21882
|
+
console.log("response stopRealtimeAlert", response);
|
|
21883
|
+
return response;
|
|
21884
|
+
} catch (error) {
|
|
21885
|
+
console.log("error stopRealtimeAlert", error);
|
|
21886
|
+
return verifyFace(verifyCount + 1);
|
|
21887
|
+
}
|
|
21888
|
+
};
|
|
21889
|
+
await verifyFace(1);
|
|
21890
|
+
}
|
|
21855
21891
|
async onRealtimeAlerts(options = {}) {
|
|
21856
21892
|
this.setOnLostFocusAlertRecorderCallback();
|
|
21857
21893
|
this.setOnFocusAlertRecorderCallback();
|
|
@@ -21866,13 +21902,7 @@ var Proctoring = class {
|
|
|
21866
21902
|
alert: this.convertRealtimeCategoryToAlertCategory(response.category)
|
|
21867
21903
|
});
|
|
21868
21904
|
} else if (response.status === "OK") {
|
|
21869
|
-
await this.
|
|
21870
|
-
proctoringId: this.proctoringId,
|
|
21871
|
-
begin: response.begin,
|
|
21872
|
-
end: response.end,
|
|
21873
|
-
warningCategoryEnum: this.convertRealtimeTypeToWarningType(response.type),
|
|
21874
|
-
alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64()
|
|
21875
|
-
});
|
|
21905
|
+
await this.stopRealtimeAlert(response);
|
|
21876
21906
|
}
|
|
21877
21907
|
}
|
|
21878
21908
|
};
|
package/index.js
CHANGED
|
@@ -30899,7 +30899,7 @@ var CameraRecorder = class {
|
|
|
30899
30899
|
}
|
|
30900
30900
|
}
|
|
30901
30901
|
async startRecording(options) {
|
|
30902
|
-
var _a2, _b, _c2, _d, _e3, _f, _g, _h
|
|
30902
|
+
var _a2, _b, _c2, _d, _e3, _f, _g, _h;
|
|
30903
30903
|
if ((((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace)) && !(options == null ? void 0 : options.retry)) {
|
|
30904
30904
|
await this.initializeDetectors();
|
|
30905
30905
|
}
|
|
@@ -30979,7 +30979,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
30979
30979
|
this.filesToUpload = [];
|
|
30980
30980
|
if (this.options.proctoringType == "REALTIME") {
|
|
30981
30981
|
this.captureFrame();
|
|
30982
|
-
this.sendFrameInterval = setInterval(() => this.captureFrame(), 1e3 * ((_i3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _i3.realtimeUploadInterval));
|
|
30983
30982
|
}
|
|
30984
30983
|
this.packageCount = 0;
|
|
30985
30984
|
}
|
|
@@ -31010,7 +31009,8 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31010
31009
|
clearInterval(this.imageInterval);
|
|
31011
31010
|
clearInterval(this.sendFrameInterval);
|
|
31012
31011
|
if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
|
|
31013
|
-
await this.sendPackage();
|
|
31012
|
+
await this.sendPackage(this.filesToUpload);
|
|
31013
|
+
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
31014
31014
|
}
|
|
31015
31015
|
this.volumeMeter && this.volumeMeter.stop();
|
|
31016
31016
|
this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
|
|
@@ -31080,23 +31080,29 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31080
31080
|
this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
|
31081
31081
|
return this.canvas.toDataURL("image/jpeg");
|
|
31082
31082
|
}
|
|
31083
|
-
//
|
|
31083
|
+
// captura um frame a cada intervalo de tempo definido no paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval!
|
|
31084
31084
|
captureFrame() {
|
|
31085
|
-
var _a2;
|
|
31085
|
+
var _a2, _b;
|
|
31086
31086
|
let imageFile;
|
|
31087
31087
|
this.configImageCapture();
|
|
31088
|
+
let newCanvasWidth = this.videoOptions.width / 2;
|
|
31089
|
+
let newCanvasHeight = this.videoOptions.height / 2;
|
|
31090
|
+
if (newCanvasWidth < 320) newCanvasWidth = 320;
|
|
31091
|
+
if (newCanvasHeight < 180) newCanvasHeight = 180;
|
|
31092
|
+
this.canvas.width = newCanvasWidth;
|
|
31093
|
+
this.canvas.height = newCanvasHeight;
|
|
31088
31094
|
const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
|
|
31089
|
-
|
|
31090
|
-
this.imageCount++;
|
|
31095
|
+
this.imageCount = 0;
|
|
31091
31096
|
this.imageInterval = setInterval(async () => {
|
|
31097
|
+
console.log("capturando frame " + this.imageCount);
|
|
31092
31098
|
this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
|
31093
31099
|
const image_data_url = this.canvas.toDataURL("image/jpeg");
|
|
31094
31100
|
if (this.proctoringId == void 0) return;
|
|
31095
|
-
if (
|
|
31096
|
-
initSend = true;
|
|
31101
|
+
if (packSize == this.imageCount) {
|
|
31097
31102
|
this.imageCount = 0;
|
|
31098
|
-
|
|
31099
|
-
this.sendPackage();
|
|
31103
|
+
const framesToSend = [...this.filesToUpload];
|
|
31104
|
+
this.sendPackage(framesToSend);
|
|
31105
|
+
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
31100
31106
|
}
|
|
31101
31107
|
let imageName = `${this.proctoringId}_${this.imageCount + 1}.jpg`;
|
|
31102
31108
|
imageFile = await this.getFile(image_data_url, imageName, "image/jpeg");
|
|
@@ -31104,22 +31110,24 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31104
31110
|
this.filesToUpload.push(imageFile);
|
|
31105
31111
|
this.imageCount++;
|
|
31106
31112
|
}
|
|
31107
|
-
}, 1e3);
|
|
31113
|
+
}, ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) * 1e3);
|
|
31108
31114
|
}
|
|
31109
31115
|
// envia pacote de imagens
|
|
31110
|
-
async sendPackage() {
|
|
31116
|
+
async sendPackage(framesToSend) {
|
|
31117
|
+
var _a2, _b;
|
|
31111
31118
|
let pending = false;
|
|
31112
31119
|
let undeliveredPackagesCount = 0;
|
|
31120
|
+
const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
|
|
31121
|
+
const packCaptureInterval = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) + 1;
|
|
31113
31122
|
if (this.upload && this.backendToken && !pending && this.filesToUpload.length > 0) {
|
|
31114
31123
|
undeliveredPackagesCount = 0;
|
|
31115
31124
|
pending = true;
|
|
31116
31125
|
const zip = new import_jszip_min.default();
|
|
31117
|
-
const
|
|
31118
|
-
for (const file of files) {
|
|
31126
|
+
for (const file of framesToSend) {
|
|
31119
31127
|
zip.file(file.name, file);
|
|
31120
31128
|
}
|
|
31121
31129
|
const blob = await zip.generateAsync({ type: "blob" });
|
|
31122
|
-
let packageName = "realtime_package_" +
|
|
31130
|
+
let packageName = "realtime_package_" + packSize * packCaptureInterval * this.packageCount + ".zip";
|
|
31123
31131
|
const myPackage = new File(
|
|
31124
31132
|
[blob],
|
|
31125
31133
|
packageName,
|
|
@@ -31132,7 +31140,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31132
31140
|
this.backendToken
|
|
31133
31141
|
);
|
|
31134
31142
|
if (uploadResult.uploaded == true) {
|
|
31135
|
-
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
31136
31143
|
this.packageCount++;
|
|
31137
31144
|
} else {
|
|
31138
31145
|
console.log("erro no upload do pacote");
|
|
@@ -33207,6 +33214,13 @@ var AlertRecorder = class {
|
|
|
33207
33214
|
// HANDLERS (Funções Arrow para preservar o 'this')
|
|
33208
33215
|
// ==========================================
|
|
33209
33216
|
// 1. LOST / RETURN FOCUS
|
|
33217
|
+
this.handleVisibilityChange = () => {
|
|
33218
|
+
if (document.visibilityState === "visible") {
|
|
33219
|
+
this.handleReturnFocus();
|
|
33220
|
+
} else {
|
|
33221
|
+
this.handleLostFocus();
|
|
33222
|
+
}
|
|
33223
|
+
};
|
|
33210
33224
|
this.handleLostFocus = () => {
|
|
33211
33225
|
if (this.getRelativeTime() > 1e4) {
|
|
33212
33226
|
const alertPayload = {
|
|
@@ -33239,7 +33253,7 @@ var AlertRecorder = class {
|
|
|
33239
33253
|
const windowWidth = window.outerWidth;
|
|
33240
33254
|
if (windowWidth < screenWidth * 0.85) {
|
|
33241
33255
|
const msg = `Split Screen Detectado: Janela ocupa ${(windowWidth / screenWidth * 100).toFixed(0)}% da tela`;
|
|
33242
|
-
this.createAlert(
|
|
33256
|
+
this.createAlert(43 /* SplitScreen */, 3 /* Screen */, msg);
|
|
33243
33257
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33244
33258
|
status: "ALERT",
|
|
33245
33259
|
description: msg,
|
|
@@ -33257,7 +33271,7 @@ var AlertRecorder = class {
|
|
|
33257
33271
|
this.handleCopy = (e3) => {
|
|
33258
33272
|
e3.preventDefault();
|
|
33259
33273
|
const msg = "Tentativa de Copiar (Clipboard)";
|
|
33260
|
-
this.createAlert(
|
|
33274
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
33261
33275
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33262
33276
|
status: "ALERT",
|
|
33263
33277
|
description: msg,
|
|
@@ -33267,7 +33281,7 @@ var AlertRecorder = class {
|
|
|
33267
33281
|
this.handleCut = (e3) => {
|
|
33268
33282
|
e3.preventDefault();
|
|
33269
33283
|
const msg = "Tentativa de Recortar (Clipboard)";
|
|
33270
|
-
this.createAlert(
|
|
33284
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
33271
33285
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33272
33286
|
status: "ALERT",
|
|
33273
33287
|
description: msg,
|
|
@@ -33277,7 +33291,7 @@ var AlertRecorder = class {
|
|
|
33277
33291
|
this.handlePaste = (e3) => {
|
|
33278
33292
|
e3.preventDefault();
|
|
33279
33293
|
const msg = "Tentativa de Colar (Clipboard)";
|
|
33280
|
-
this.createAlert(
|
|
33294
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
33281
33295
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33282
33296
|
status: "ALERT",
|
|
33283
33297
|
description: msg,
|
|
@@ -33313,8 +33327,7 @@ var AlertRecorder = class {
|
|
|
33313
33327
|
// ==========================================
|
|
33314
33328
|
attachListeners() {
|
|
33315
33329
|
if (this.optionsProctoring.captureScreen) {
|
|
33316
|
-
window.addEventListener("
|
|
33317
|
-
window.addEventListener("focus", this.handleReturnFocus);
|
|
33330
|
+
window.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
33318
33331
|
window.addEventListener("resize", this.handleResize);
|
|
33319
33332
|
window.document.addEventListener("copy", this.handleCopy);
|
|
33320
33333
|
window.document.addEventListener("cut", this.handleCut);
|
|
@@ -33322,8 +33335,7 @@ var AlertRecorder = class {
|
|
|
33322
33335
|
}
|
|
33323
33336
|
}
|
|
33324
33337
|
detachListeners() {
|
|
33325
|
-
window.removeEventListener("
|
|
33326
|
-
window.removeEventListener("focus", this.handleReturnFocus);
|
|
33338
|
+
window.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
33327
33339
|
window.removeEventListener("resize", this.handleResize);
|
|
33328
33340
|
window.document.removeEventListener("copy", this.handleCopy);
|
|
33329
33341
|
window.document.removeEventListener("cut", this.handleCut);
|
|
@@ -33358,7 +33370,7 @@ var AlertRecorder = class {
|
|
|
33358
33370
|
// }
|
|
33359
33371
|
// 4. BACKGROUND EVENTS (Eventos disparados manualmente)
|
|
33360
33372
|
addBackgroundEvent(description, category = 200 /* System */) {
|
|
33361
|
-
this.createAlert(category,
|
|
33373
|
+
this.createAlert(category, 3 /* Screen */, description);
|
|
33362
33374
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33363
33375
|
status: "ALERT",
|
|
33364
33376
|
description,
|
|
@@ -36748,7 +36760,8 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
|
|
|
36748
36760
|
this.connection = new import_signalr.HubConnectionBuilder().withUrl(hubUrl, {
|
|
36749
36761
|
accessTokenFactory: () => this.context.token,
|
|
36750
36762
|
transport: import_signalr.HttpTransportType.WebSockets,
|
|
36751
|
-
withCredentials: false
|
|
36763
|
+
withCredentials: false,
|
|
36764
|
+
skipNegotiation: true
|
|
36752
36765
|
}).withAutomaticReconnect().configureLogging(import_signalr.LogLevel.Information).build();
|
|
36753
36766
|
this.connection.on(
|
|
36754
36767
|
"ReceiveMessage",
|
|
@@ -36964,8 +36977,8 @@ var Proctoring = class {
|
|
|
36964
36977
|
detectCellPhone: false,
|
|
36965
36978
|
detectNoise: false,
|
|
36966
36979
|
detectSpeech: false,
|
|
36967
|
-
realtimePackageSize:
|
|
36968
|
-
|
|
36980
|
+
realtimePackageSize: 10,
|
|
36981
|
+
realtimeCaptureInterval: 2
|
|
36969
36982
|
}
|
|
36970
36983
|
};
|
|
36971
36984
|
this.proctoringId = "";
|
|
@@ -37101,6 +37114,29 @@ var Proctoring = class {
|
|
|
37101
37114
|
return null;
|
|
37102
37115
|
}
|
|
37103
37116
|
}
|
|
37117
|
+
// metodo para fechar o alerta realtime e fica tentando verificar a face até 5 vezes
|
|
37118
|
+
async stopRealtimeAlert(alert) {
|
|
37119
|
+
const verifyMaxRetries = 3;
|
|
37120
|
+
const verifyFace = async (verifyCount) => {
|
|
37121
|
+
if (verifyCount > verifyMaxRetries) return;
|
|
37122
|
+
try {
|
|
37123
|
+
var response = await this.backend.stopRealtimeAlert({
|
|
37124
|
+
proctoringId: this.proctoringId,
|
|
37125
|
+
begin: alert.begin,
|
|
37126
|
+
end: alert.end,
|
|
37127
|
+
warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
|
|
37128
|
+
alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
|
|
37129
|
+
retry: verifyCount < verifyMaxRetries - 1 ? true : false
|
|
37130
|
+
});
|
|
37131
|
+
console.log("response stopRealtimeAlert", response);
|
|
37132
|
+
return response;
|
|
37133
|
+
} catch (error) {
|
|
37134
|
+
console.log("error stopRealtimeAlert", error);
|
|
37135
|
+
return verifyFace(verifyCount + 1);
|
|
37136
|
+
}
|
|
37137
|
+
};
|
|
37138
|
+
await verifyFace(1);
|
|
37139
|
+
}
|
|
37104
37140
|
async onRealtimeAlerts(options = {}) {
|
|
37105
37141
|
this.setOnLostFocusAlertRecorderCallback();
|
|
37106
37142
|
this.setOnFocusAlertRecorderCallback();
|
|
@@ -37115,13 +37151,7 @@ var Proctoring = class {
|
|
|
37115
37151
|
alert: this.convertRealtimeCategoryToAlertCategory(response.category)
|
|
37116
37152
|
});
|
|
37117
37153
|
} else if (response.status === "OK") {
|
|
37118
|
-
await this.
|
|
37119
|
-
proctoringId: this.proctoringId,
|
|
37120
|
-
begin: response.begin,
|
|
37121
|
-
end: response.end,
|
|
37122
|
-
warningCategoryEnum: this.convertRealtimeTypeToWarningType(response.type),
|
|
37123
|
-
alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64()
|
|
37124
|
-
});
|
|
37154
|
+
await this.stopRealtimeAlert(response);
|
|
37125
37155
|
}
|
|
37126
37156
|
}
|
|
37127
37157
|
};
|
|
@@ -25,7 +25,7 @@ export type VideoBehaviourParameters = {
|
|
|
25
25
|
retryEnabled?: boolean;
|
|
26
26
|
maxRetries?: number;
|
|
27
27
|
realtimePackageSize?: number;
|
|
28
|
-
|
|
28
|
+
realtimeCaptureInterval?: number;
|
|
29
29
|
};
|
|
30
30
|
export default interface IParamsConfig {
|
|
31
31
|
audioBehaviourParameters?: AudioBehaviourParameters;
|
|
@@ -25,7 +25,8 @@ export declare enum AlertCategory {
|
|
|
25
25
|
SpyDeviceDisconnected = 33,
|
|
26
26
|
StopSharingScreen = 34,
|
|
27
27
|
ChangeDevices = 39,
|
|
28
|
-
|
|
28
|
+
ClipBoardUse = 42,
|
|
29
|
+
SplitScreen = 43,
|
|
29
30
|
System = 200
|
|
30
31
|
}
|
|
31
32
|
export declare enum FinishRealtimeWarningCategory {
|
|
@@ -38,8 +39,7 @@ export declare enum AlertType {
|
|
|
38
39
|
Video = 2,
|
|
39
40
|
Screen = 3,
|
|
40
41
|
Image = 4,
|
|
41
|
-
Environment = 5
|
|
42
|
-
System = 6
|
|
42
|
+
Environment = 5
|
|
43
43
|
}
|
|
44
44
|
export interface Alert {
|
|
45
45
|
begin: number;
|
|
@@ -24,6 +24,7 @@ export declare class AlertRecorder implements IRecorder {
|
|
|
24
24
|
saveOnSession(session: ProctoringSession): Promise<void>;
|
|
25
25
|
private attachListeners;
|
|
26
26
|
private detachListeners;
|
|
27
|
+
private handleVisibilityChange;
|
|
27
28
|
private handleLostFocus;
|
|
28
29
|
private handleReturnFocus;
|
|
29
30
|
private handleResize;
|
|
@@ -66,7 +66,7 @@ export declare class CameraRecorder implements IRecorder {
|
|
|
66
66
|
getCurrentImageBase64(): Promise<string>;
|
|
67
67
|
packageCount: number;
|
|
68
68
|
captureFrame(): void;
|
|
69
|
-
sendPackage(): Promise<void>;
|
|
69
|
+
sendPackage(framesToSend: File[]): Promise<void>;
|
|
70
70
|
download(file: File): void;
|
|
71
71
|
saveOnSession(session: ProctoringSession): Promise<void>;
|
|
72
72
|
getFile(file: string, name: string, type: string): Promise<File>;
|
package/package.json
CHANGED
|
@@ -70,6 +70,7 @@ export declare class Proctoring {
|
|
|
70
70
|
onChangeDevices(options?: ProctoringChangeDevicesOptions): Promise<void>;
|
|
71
71
|
private convertRealtimeCategoryToAlertCategory;
|
|
72
72
|
private convertRealtimeTypeToWarningType;
|
|
73
|
+
private stopRealtimeAlert;
|
|
73
74
|
private onRealtimeAlertsCallback;
|
|
74
75
|
onRealtimeAlerts(options?: ProctoringRealtimeAlertsOptions): Promise<void>;
|
|
75
76
|
private onBufferSizeErrorCallback;
|
package/unpkg/easyproctor.min.js
CHANGED
|
@@ -79,7 +79,7 @@ Minimum version required to store current data is: `+o+`.
|
|
|
79
79
|
File type: ${i.type}
|
|
80
80
|
File size: ${i.size}`),new Error("Failed to upload to AWS")}}};var Gg="not_shared_first_screen",qg="not_shared_screen",Fa="multiple_monitors_detected",Kg="proctoring_already_started",Ma="proctoring_not_started";var Xg="another_stream_active",Jg="stream_under_minimum_permitted",Yg="browser_not_supported",Zg="token_missing",Qg="credentials_missing";var e0="spy_scan_api_not_found";var t0="external_camera_not_started";var Ua=class extends Bi{constructor(t,r,n="videoPreviewFrameDetection",i="liveViewFrameDetection"){super("ObjectDetector","https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite",t,r,n,i)}stopDetection(){super.stopDetection(),this.numPersonsSent>0&&this.handleOk("person_ok","person_detection_on_stream")}displayVideoDetections(t){for(let r of this.children)this.liveView.removeChild(r);this.children.splice(0);for(let r of t.detections){let n=window.innerWidth,i=window.innerHeight,o=this.video.offsetWidth,s=this.video.offsetHeight,a=o/n,c=s/i,l=o-r.boundingBox.width*a-r.boundingBox.originX*a,h=r.boundingBox.originY*c,d=(r.boundingBox.width-10)*a,m=r.boundingBox.height*c,p=document.createElement("p");p.innerText=r.categories[0].categoryName+" - with "+Math.round(parseFloat(r.categories[0].score)*100)+"% confidence.",p.style.right=l-20+"px",p.style.top=h+"px",p.style.width=d+"px";let g={zIndex:"2",position:"absolute",border:"1px dashed #fff"};Object.assign(p.style,{...g,margin:"0",fontSize:"9px",paddingBottom:"5px",paddingTop:"5px",color:"#fff",backgroundColor:"#007f8b"});let f=document.createElement("div");f.setAttribute("class","highlighter"),f.style.right=l-20+"px",f.style.top=h+"px",f.style.width=d+"px",f.style.height=m-20+"px",Object.assign(f.style,{...g,zIndex:"1",background:"rgba(0, 255, 0, 0.25)"}),this.liveView.appendChild(f),this.liveView.appendChild(p),this.children.push(f),this.children.push(p)}}verify(t){let r=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="person")).length,n=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="cell phone")).length;this.paramsConfig.videoBehaviourParameters?.detectPerson&&r!==this.numPersonsSent&&(r===0?(this.handleAlert("no_person_detected","person_detection_on_stream"),this.numPersonsSent=r):r>1?(this.handleAlert("multiple_persons_detected","person_detection_on_stream"),this.numPersonsSent=r):(this.handleOk("person_ok","person_detection_on_stream"),this.numPersonsSent=r)),this.paramsConfig.videoBehaviourParameters?.detectCellPhone&&n!==this.numCellphoneSent&&(n>0?(this.handleAlert("cellphone_detected","mobile_detection_on_stream"),this.numCellphoneSent=n):(this.handleOk("cellphone_ok","mobile_detection_on_stream"),this.numCellphoneSent=n))}};var gn=class{constructor(t){this.volume=null;this.animationFrameId=null;this.stream=t}async start(t={}){return new Promise((r,n)=>{try{let i=new AudioContext;this.analyser=i.createAnalyser();let o=i.createMediaStreamSource(this.stream);this.analyser.smoothingTimeConstant=.8,this.analyser.fftSize=1024,o.connect(this.analyser);let s=()=>{let a=new Uint8Array(this.analyser.frequencyBinCount);this.analyser.getByteFrequencyData(a);let l=a.reduce((h,d)=>h+d,0)/a.length;this.setVolume(l),t.setVolume&&t.setVolume(l),this.animationFrameId=requestAnimationFrame(s)};this.animationFrameId=requestAnimationFrame(s),r(!0)}catch(i){this.stop(),n(`Error: ${i}`)}})}stop(){this.animationFrameId!==null&&cancelAnimationFrame(this.animationFrameId)}getVolume(){return this.volume}setVolume(t){this.volume=t}};var o0=dl(n0()),Yr=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 Jr(this.proctoringId,this.backend)),La(t)}async initializeDetectors(){ig(),(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,this.canvas.width=this.videoOptions.width,this.canvas.height=this.videoOptions.height}async bufferError(t){console.log("buffer error Camera Recorder params "+this.paramsConfig.videoBehaviourParameters);let r=this.paramsConfig.videoBehaviourParameters?.retryEnabled||!1,n=this.paramsConfig.videoBehaviourParameters?.maxRetries||3;r&&this.currentRetries<n?(await this.recordingStop(),await this.startRecording({retry:!0}),this.currentRetries++,this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback(this.cameraStream)):this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback()}async startRecording(t){(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone||this.paramsConfig.videoBehaviourParameters?.detectFace)&&!t?.retry&&await this.initializeDetectors();let{cameraId:r,microphoneId:n,onBufferSizeErrorCallback:i}=this.options,o={audio:{deviceId:n},video:{deviceId:r,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.hardwareStream=await navigator.mediaDevices.getUserMedia(o)}catch(v){throw v.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":v}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.options.onBufferSizeError,v=>this.bufferError(v),!1);if(this.recordingStart=h,this.recordingStop=d,this.recordingPause=m,this.recordingResume=p,this.recorderOptions=g,this.getBufferSize=f,this.recordingStart(),screen.orientation?.type.includes("portrait")&&mn()&&this.videoOptions.width==l&&this.videoOptions.height==c&&([c,l]=[l,c]),this.videoOptions.minWidth>c||this.videoOptions.minHeight>l)throw Jg;if(this.videoOptions.width!==c||this.videoOptions.height!==l)throw me.registerAnotherStream(this.proctoringId,`Maybe have another stream active
|
|
81
81
|
Video Options: ${JSON.stringify(this.videoOptions,null,2)}
|
|
82
|
-
Setting: ${JSON.stringify(a,null,2)}`),Xg;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"&&
|
|
82
|
+
Setting: ${JSON.stringify(a,null,2)}`),Xg;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&await this.objectDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&this.captureFrame(),this.packageCount=0}async stopRecording(){this.isCanvasLoopActive=!1,this.recordingStop&&await this.recordingStop();try{this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}catch{console.error("Erro ao parar os streams de m\xEDdia.")}this.faceDetection&&this.faceDetection.detecting&&this.faceDetection.stopDetection(),this.objectDetection&&this.objectDetection.detecting&&this.objectDetection.stopDetection(),clearInterval(this.imageInterval),clearInterval(this.sendFrameInterval),this.options.proctoringType=="REALTIME"&&this.upload&&this.backendToken&&(await this.sendPackage(this.filesToUpload),await this.filesToUpload.splice(0,this.filesToUpload.length)),this.volumeMeter&&this.volumeMeter.stop(),this.intervalNoiseDetection&&clearInterval(this.intervalNoiseDetection)}async pauseRecording(){await this.recordingPause()}async resumeRecording(){await this.recordingResume()}photoShotsCycle(){let t;this.configImageCapture(),this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.videoOptions.width,this.videoOptions.height);let r=this.canvas.toDataURL("image/jpeg");t=await this.getFile(r,`${this.proctoringId}_${this.imageCount+1}.jpg`,"image/jpeg"),t&&this.upload&&this.backendToken&&(this.upload.upload({file:t},this.backendToken,!0),this.imageCount++)},this.paramsConfig.imageBehaviourParameters.uploadInterval*1e3)}async getCurrentImageBase64(){return!this.video||!this.canvas?this.configImageCapture():this.video.srcObject!==this.cameraStream&&(this.video.srcObject=this.cameraStream,await this.video.play()),this.video.paused&&await this.video.play(),await new Promise(t=>{if(this.video.readyState>=2){t();return}let r=()=>{this.video.removeEventListener("loadedmetadata",r),setTimeout(()=>t(),50)};this.video.addEventListener("loadedmetadata",r),setTimeout(()=>{this.video.removeEventListener("loadedmetadata",r),t()},500)}),this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height),this.canvas.toDataURL("image/jpeg")}captureFrame(){let t;this.configImageCapture();let r=this.videoOptions.width/2,n=this.videoOptions.height/2;r<320&&(r=320),n<180&&(n=180),this.canvas.width=r,this.canvas.height=n;let i=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize;this.imageCount=0,this.imageInterval=setInterval(async()=>{console.log("capturando frame "+this.imageCount),this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height);let o=this.canvas.toDataURL("image/jpeg");if(this.proctoringId==null)return;if(i==this.imageCount){this.imageCount=0;let a=[...this.filesToUpload];this.sendPackage(a),await this.filesToUpload.splice(0,this.filesToUpload.length)}let s=`${this.proctoringId}_${this.imageCount+1}.jpg`;t=await this.getFile(o,s,"image/jpeg"),t&&t.size>10&&i>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 o0.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&&me.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
|
|
83
83
|
Sample Rate: ${n.sampleRate}
|
|
84
84
|
Sample Size: ${n.sampleSize}
|
|
85
85
|
|
|
@@ -432,7 +432,7 @@ Para iniciar um exame utilize uma outra c\xE2mera.`),o.setAttribute("class","che
|
|
|
432
432
|
File size: ${n.size}`),new Error("Error on machine download")}}};var Ha=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"),me.registerUploadFile(this.proctoringId,`Upload File
|
|
433
433
|
Name: ${t.file.name}
|
|
434
434
|
Type: ${t.file.type}
|
|
435
|
-
Size: ${t.file.size}`,s),o}}throw new Error("Could not upload")}};var Wa=class{constructor(t,r){this.alerts=[];this.lastActivityTime=Date.now();this.IDLE_THRESHOLD_MS=3e4;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(200,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(100,6,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(100,6,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(100,6,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("blur",this.handleLostFocus),window.addEventListener("focus",this.handleReturnFocus),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("blur",this.handleLostFocus),window.removeEventListener("focus",this.handleReturnFocus),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,6,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 $a=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,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 c0(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var Ga,Ed,g_=typeof TextDecoder<"u",y_,b_=typeof TextEncoder<"u";function $0(e){if(b_)e=(y_||=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 Vd,Qa;e:{for(Cd=["CLOSURE_FLAGS"],qa=Kn,Ka=0;Ka<Cd.length;Ka++)if((qa=qa[Cd[Ka]])==null){Qa=null;break e}Qa=qa}var Cd,qa,Ka,Jo,l0=Qa&&Qa[610401301];Vd=l0!=null&&l0;var h0=Kn.navigator;function Bd(e){return!!Vd&&!!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!!Vd&&!!Jo&&Jo.brands.length>0}function xd(){return vn()?Bd("Chromium"):(cr("Chrome")||cr("CriOS"))&&!(!vn()&&cr("Edge"))||cr("Silk")}Jo=h0&&h0.userAgentData||null;var v_=!vn()&&(cr("Trident")||cr("MSIE"));!cr("Android")||xd(),xd(),cr("Safari")&&(xd()||!vn()&&cr("Coast")||!vn()&&cr("Opera")||!vn()&&cr("Edge")||(vn()?Bd("Microsoft Edge"):cr("Edg/"))||vn()&&Bd("Opera"));var G0={},$o=null;function __(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}q0();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 q0(){if(!$o){$o={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=e.concat(t[r].split(""));G0[r]=n;for(let i=0;i<n.length;i++){let o=n[i];$o[o]===void 0&&($o[o]=i)}}}}var K0=typeof Uint8Array<"u",X0=!v_&&typeof btoa=="function";function d0(e){if(!X0){var t;t===void 0&&(t=0),q0(),t=G0[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 u0=/[-_.]/g,w_={"-":"+",_:"/",".":"="};function S_(e){return w_[e]||""}function J0(e){if(!X0)return __(e);u0.test(e)&&(e=e.replace(u0,S_)),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 lc(e){return K0&&e!=null&&e instanceof Uint8Array}var Yi={};function Zi(){return k_||=new wn(null,Yi)}function Hd(e){Y0(Yi);var t=e.g;return(t=t==null||lc(t)?t:typeof t=="string"?J0(t):null)==null?t:e.g=t}var wn=class{i(){return new Uint8Array(Hd(this)||0)}constructor(e,t){if(Y0(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}},k_,E_;function Y0(e){if(e!==Yi)throw Error("illegal external caller")}function Z0(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function f0(){let e=Error("int32");return Z0(e,"warning"),e}var hc=typeof Symbol=="function"&&typeof Symbol()=="symbol",C_=new Set;function dc(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&&C_.add(e),e}var x_=dc("jas",void 0,!0,!0),Ad=dc(void 0,"2ex"),Ho=dc(void 0,"1oa",!0),Qi=dc(void 0,Symbol(),!0),se=hc?x_:"M",Q0={M:{value:0,configurable:!0,writable:!0,enumerable:!1}},e1=Object.defineProperties;function Wd(e,t){hc||se in e||e1(e,Q0),e[se]|=t}function ct(e,t){hc||se in e||e1(e,Q0),e[se]=t}function A_(e,t){ct(t,-30975&(0|e))}function Ld(e,t){ct(t,-30941&(34|e))}function $d(){return typeof BigInt=="function"}function lr(e){return Array.prototype.slice.call(e)}var Gd,Zo={},T_={};function p0(e){return!(!e||typeof e!="object"||e.g!==T_)}function qd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function t1(e,t){if(e!=null){if(typeof e=="string")e=e?new wn(e,Yi):Zi();else if(e.constructor!==wn)if(lc(e))e=e.length?new wn(new Uint8Array(e),Yi):Zi();else{if(!t)throw Error();e=void 0}}return e}function ec(e){return!(!Array.isArray(e)||e.length)&&!!(1&(0|e[se]))}var m0=[];function Yn(e){if(2&e)throw Error()}function Kd(e){return Qi?e[Qi]:void 0}ct(m0,55),Gd=Object.freeze(m0);var r1=Object.freeze({}),Xd=typeof Kn.BigInt=="function"&&typeof Kn.BigInt(0)=="bigint",Fd=e=>Xd?e>=R_&&e<=D_:e[0]==="-"?g0(e,I_):g0(e,P_),I_=Number.MIN_SAFE_INTEGER.toString(),R_=Xd?BigInt(Number.MIN_SAFE_INTEGER):void 0,P_=Number.MAX_SAFE_INTEGER.toString(),D_=Xd?BigInt(Number.MAX_SAFE_INTEGER):void 0;function g0(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 O_=typeof Uint8Array.prototype.slice=="function",n1,De=0,Ge=0;function y0(e){let t=e>>>0;De=t,Ge=(e-t)/4294967296>>>0}function eo(e){if(e<0){y0(-e);let[t,r]=Zd(De,Ge);De=t>>>0,Ge=r>>>0}else y0(e)}function i1(e){let t=n1||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ge=0,De=t.getUint32(0,!0)}function Jd(e,t){let r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Yo(e,t)}function Yd(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Jd(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 $d()?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+b0(r)+b0(e));return r}function b0(e){return e=String(e),"0000000".slice(e.length)+e}function uc(e){if(e.length<16)eo(Number(e));else if($d())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]=Zd(De,Ge);De=n,Ge=i}}}function Zd(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}var o1=typeof BigInt=="function"?BigInt.asIntN:void 0,B_=typeof BigInt=="function"?BigInt.asUintN:void 0,Go=Number.isSafeInteger,fc=Number.isFinite,tc=Math.trunc;function Qo(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function v0(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 L_=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Qd(e){switch(typeof e){case"bigint":return!0;case"number":return fc(e);case"string":return L_.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 fc(e)?0|e:void 0}function _0(e){if(e[0]==="-")return!1;let t=e.length;return t<20||t===20&&Number(e.substring(0,6))<184467}function s1(e){return e=tc(e),Go(e)||(eo(e),e=Yd(De,Ge)),e}function a1(e){var t=tc(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(uc(e),e=De,2147483648&(t=Ge))if($d())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=Zd(e,t);e="-"+Yo(r,n)}else e=Yo(e,t);return e}function Md(e){return e==null?e:typeof e=="bigint"?(Fd(e)?e=Number(e):(e=o1(64,e),e=Fd(e)?Number(e):String(e)),e):Qd(e)?typeof e=="number"?s1(e):a1(e):void 0}function F_(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(B_(64,e));if(Qd(e)){if(t==="string")return t=tc(Number(e)),Go(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),_0(e)||(uc(e),e=Yo(De,Ge))),e;if(t==="number")return(e=tc(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 _0(n=String(r))?n:(eo(r),Jd(De,Ge))})(e)}}function c1(e){if(typeof e!="string")throw Error();return e}function rc(e){if(e!=null&&typeof e!="string")throw Error();return e}function Sn(e){return e==null||typeof e=="string"?e:void 0}function l1(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 h1(e,t,r,n,i){if(e!=null){if(Array.isArray(e))e=ec(e)?void 0:i&&2&(0|e[se])?e:eu(e,t,r,n!==void 0,i);else if(qd(e)){let o={};for(let s in e)o[s]=h1(e[s],t,r,n,i);e=o}else e=t(e,n);return e}}function eu(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]=h1(n[a],t,r,s,i);return r&&((e=Kd(e))&&(n[Qi]=lr(e)),r(o,n)),n}function M_(e){return e.B===Zo?e.toJSON():(function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return Fd(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(ec(t))return}else{if(lc(t))return d0(t);if(t instanceof wn){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=d0(r)}}}return t})(e)}function U_(e){return eu(e,M_,void 0,void 0,!1)}var d1,N_;function qo(e,t,r){return e=u1(e,t[0],t[1],r?1:2),t!==d1&&r&&Wd(e,16384),e}function u1(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(qd(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 f1(e,t,r=Ld){if(e!=null){if(K0&&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):eu(e,f1,4&n?Ld:r,!0,!0))}return e.B===Zo&&(e=2&(n=0|(r=e.l)[se])?e:new e.constructor(pc(r,n,!0))),e}}function p1(e){let t=e.l;return new e.constructor(pc(t,0|t[se],!1))}function pc(e,t,r){let n=r||2&t?Ld:A_,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=Kd(o))&&(c[Qi]=lr(o)),c})(e,t,(o=>f1(o,i,n))),Wd(e,32|(r?2:0)),e}function tu(e){let t=e.l,r=0|t[se];return 2&r?new e.constructor(pc(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&&Ad!=null&&((i=(e=E_??={})[Ad]||0)>=4||(e[Ad]=i+1,Z0(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 m1(e){let t=0|(e=e.l)[se],r=Zn(e,t,1),n=t1(r,!0);return n!=null&&n!==r&<(e,t,1,n),n}function g1(e,t,r,n,i){let o=e.l,s=2&(e=0|o[se])?1:n;i=!!i;let a=0|(n=ru(o,e,t))[se];if(!(4&a)){4&a&&(n=lr(n),a=Qr(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=nu(a,e),r=-4097&(20|a),a=r&=-8193,ct(n,a),2&a&&Object.freeze(n)}return s===1||s===4&&32&a?Zr(a)||(i=a,a|=2,a!==i&&ct(n,a),Object.freeze(n)):(s===2&&Zr(a)&&(n=lr(n),a=Qr(a,e),a=kn(a,e,i),ct(n,a),e=lt(o,e,t,n)),Zr(a)||(t=a,a=kn(a,e,i),a!==t&&ct(n,a))),n}function ru(e,t,r,n){return e=Zn(e,t,r,n),Array.isArray(e)?e:Gd}function nu(e,t){return e===0&&(e=Qr(e,t)),1|e}function Zr(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function w0(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=Zr(i),a=s||Object.isFrozen(r);for(s||(i=0),a||(r=lr(r),o=0,i=kn(i=Qr(i,n),n,!0),a=!1),i|=21,s=0;s<r.length;s++){let c=r[s],l=c1(c);Object.is(c,l)||(a&&(r=lr(r),o=0,i=kn(i=Qr(i,n),n,!0),a=!1),r[s]=l)}i!==o&&(a&&(r=lr(r),i=kn(i=Qr(i,n),n,!0)),ct(r,i)),lt(e,n,t,r)}}function y1(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=ru(e,t,r,i))!==Gd;if(o||!s){let a=o=s?0|i[se]:0;(!s||2&a||Zr(a)||4&a&&!(32&a))&&(i=lr(i),a=Qr(a,t),t=lt(e,t,r,i)),a=-13&nu(a,t),a=kn(n?-17&a:16|a,t,!0),a!==o&&ct(i,a)}return i}function Td(e,t){var r=a2;return ou(iu(e=e.l),e,0|e[se],r)===t?t:-1}function iu(e){if(hc)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 b1(e,t,r,n){let i=iu(e),o=ou(i,e,t,r);return o!==n&&(o&&(t=lt(e,t,o)),i.set(r,n)),t}function ou(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 su(e,t,r,n){let i,o=0|e[se];if((n=Zn(e,o,r,n))!=null&&n.B===Zo)return(t=tu(n))!==n&<(e,o,r,t),t.l;if(Array.isArray(n)){let s=0|n[se];i=2&s?qo(pc(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 v1(e,t,r,n){let i=0|(e=e.l)[se];return(t=l1(n=Zn(e,i,r,n),t,i))!==n&&t!=null&<(e,i,r,t),t}function wr(e,t,r){if((t=v1(e,t,r,!1))==null)return t;let n=0|(e=e.l)[se];if(!(2&n)){let i=tu(t);i!==t&<(e,n,r,t=i)}return t}function _1(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=ru(e,t,1))[se];if(!(s=!!(4&c))){var l=n,h=t;let d=!!(2&(c=nu(c,t)));d&&(h|=2);let m=!d,p=!0,g=0,f=0;for(;g<l.length;g++){let b=l1(l[g],r,h);if(b instanceof r){if(!d){let v=!!(2&(0|b.l[se]));m&&=!v,p&&=v}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(Zr(c)&&(n=lr(n),c=Qr(c,t),t=lt(e,t,1,n)),r=n,o=c,l=0;l<r.length;l++)(c=r[l])!==(h=tu(c))&&(r[l]=h);o|=8,ct(r,o=r.length?-17&o:16|o),c=o}return a===1||a===4&&32&c?Zr(c)||(t=c,(c|=!n.length||16&c&&(!s||32&c)?2:2048)!==t&&ct(n,c),Object.freeze(n)):(a===2&&Zr(c)&&(ct(n=lr(n),c=kn(c=Qr(c,t),t,i)),t=lt(e,t,1,n)),Zr(c)||(e=c,(c=kn(c,t,i))!==e&&ct(n,c))),n}function au(e,t){let r=0|e.l[se];return _1(e,r,t,r1===void 0?2:4,!1,!(2&r))}function Sr(e,t,r,n){return n==null&&(n=void 0),pt(e,r,n)}function Id(e,t,r){var n=n2;r==null&&(r=void 0);e:{let i=0|(e=e.l)[se];if(Yn(i),r==null){let o=iu(e);if(ou(o,e,i,n)!==t)break e;o.set(n,0)}else i=b1(e,i,n,t);lt(e,i,t,r)}}function Qr(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 w1(e,t){var r=ku;let n=0|e.l[se];Yn(n),e=_1(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]),g1(e,t,Sn,2,!0).push(c1(r))}function S1(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function cu(){return Error("Failed to read varint, encoding is invalid.")}function k1(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function lu(e){if(typeof e=="string")return{buffer:J0(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:Hd(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 hu(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 cu()}function du(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 cu()}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 cu();return qn(e,r),i}function Ud(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 Nd(e){var t=Ud(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 z_(e){return Bt(e)}function Rd(e,t,{C:r=!1}={}){e.C=r,t&&(t=lu(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 k1(e.j,t)}function E1(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 k1(t,e.j-r);return e.g=n,r}function C1(e,t){if(t==0)return Zi();var r=E1(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):O_?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Zi():new wn(r,Yi)}var S0=[];function x1(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 S1(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 Ya(e){switch(e.i){case 0:e.i!=0?Ya(e):du(e.g);break;case 1:qn(e=e.g,e.g+8);break;case 2:if(e.i!=2)Ya(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(!x1(e))throw Error("Unmatched start-group tag: stream EOF");if(e.i==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}Ya(e)}break;default:throw S1(e.i,e.j)}}function mc(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 uu(e){var t=Bt(e.g)>>>0,r=E1(e=e.g,t);if(e=e.i,g_){var n,i=e;(n=Ed)||(n=Ed=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(Ga===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),Ga=!0}catch{Ga=!1}}throw!Ga&&(Ed=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=c0(c,r),r.length=0)}o=c0(c,r)}return o}function A1(e){let t=Bt(e.g)>>>0;return C1(e.g,t)}function fu(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 Xa=[];function j_(e){return e}var Ki;function T1(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=u1(e,t)}toJSON(){let e=!Ki;try{return e&&(Ki=U_),I1(this)}finally{e&&(Ki=void 0)}}u(){return!!(2&(0|this.l[se]))}};function I1(e){var t=e.l;{t=(e=Ki(t))!==t;let l=e.length;if(l){var r=e[l-1],n=qd(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)&&(ec(n)||p0(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||ec(o)||p0(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 k0(e){return e?/^\d+$/.test(e)?(uc(e),new zd(De,Ge)):null:V_||=new zd(0,0)}Ue.prototype.B=Zo,Ue.prototype.toString=function(){try{return Ki=j_,I1(this).toString()}finally{Ki=void 0}};var zd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},V_;function E0(e){return e?/^-?\d+$/.test(e)?(uc(e),new jd(De,Ge)):null:H_||=new jd(0,0)}var jd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},H_;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 gc(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 nc(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 yc(e,t){return kr(e,t,2),t=e.g.end(),to(e,t),t.push(e.i),t}function bc(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 vc(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 pu=Er(),R1=Er(),mu=Er(),gu=Er(),P1=Er(),D1=Er(),O1=Er(),B1=Er(),ro=class{constructor(e,t,r){this.g=e,this.i=t,e=pu,this.j=!!e&&r===e||!1}};function yu(e,t){return new ro(e,t,pu)}function L1(e,t,r,n,i){(t=N1(t,n))!=null&&(r=yc(e,r),i(t,e),bc(e,r))}var W_=yu((function(e,t,r,n,i){return e.i===2&&(mc(e,su(t,n,r),i),!0)}),L1),$_=yu((function(e,t,r,n,i){return e.i===2&&(mc(e,su(t,n,r,!0),i),!0)}),L1),_c=Symbol(),bu=Symbol(),C0=Symbol(),x0=Symbol(),F1,M1;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 d1||=[0,void 0,!0];case"number":return d>0?void 0:d===0?N_||=[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,F1??=o,M1??=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=W_,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 U1(e){return Array.isArray(e)?e[0]instanceof ro?e:[$_,e]:[e,void 0]}function N1(e,t){return e instanceof Ue?e.l:Array.isArray(e)?qo(e,t,!1):void 0}function vu(e,t,r,n){let i=r.g;e[t]=n?(o,s,a)=>i(o,s,a,n):i}function _u(e,t,r,n,i){let o=r.g,s,a;e[t]=(c,l,h)=>o(c,l,h,a||=Qn(bu,vu,_u,n).A,s||=wu(n),i)}function wu(e){let t=e[C0];if(t!=null)return t;let r=Qn(bu,vu,_u,e);return t=r.I?(n,i)=>F1(n,i,r):(n,i)=>{let o=0|n[se];for(;x1(i)&&i.i!=4;){var s=i.m,a=r[s];if(a==null){var c=r.H;c&&(c=c[s])&&(c=G_(c))!=null&&(a=r[s]=c)}a!=null&&a(i,n,s)||(s=(a=i).j,Ya(a),a.G?a=void 0:(c=a.g.g-s,a.g.g=s,a=C1(a.g,c)),s=n,a&&((c=s[Qi])?c.push(a):s[Qi]=[a]))}return 16384&o&&Wd(n,34),!0},e[C0]=t}function G_(e){let t=(e=U1(e))[0].g;if(e=e[1]){let r=wu(e),n=Qn(bu,vu,_u,e).A;return(i,o,s)=>t(i,o,s,n,r)}return t}function wc(e,t,r){e[t]=r.i}function Sc(e,t,r,n){let i,o,s=r.i;e[t]=(a,c,l)=>s(a,c,l,o||=Qn(_c,wc,Sc,n).A,i||=z1(n))}function z1(e){let t=e[x0];if(!t){let r=Qn(_c,wc,Sc,e);t=(n,i)=>j1(n,i,r),e[x0]=t}return t}function j1(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=A0(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=A0(r,i))&&a(t,o,i)}if(e=Kd(e))for(to(t,t.g.end()),r=0;r<e.length;r++)to(t,Hd(e[r])||new Uint8Array(0))}function A0(e,t){var r=e[t];if(r)return r;if((r=e.H)&&(r=r[t])){var n=(r=U1(r))[0].i;if(r=r[1]){let i=z1(r),o=Qn(_c,wc,Sc,r).A;r=e.I?M1(o,i):(s,a,c)=>n(s,a,c,o,i)}else r=n;return e[t]=r}}function kc(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 Ec(e,t,r){return new ro(e,t,r)}function St(e,t,r){lt(e,0|e[se],t,r)}function V1(e,t,r){if(t=(function(n){if(n==null)return n;let i=typeof n;if(i==="bigint")return String(o1(64,n));if(Qd(n)){if(i==="string")return a1(n);if(i==="number")return s1(n)}})(t),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 jd(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)}}function H1(e,t,r){(t=Xn(t))!=null&&t!=null&&(kr(e,r,0),gc(e.g,t))}function W1(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 $1(e,t,r){(t=Sn(t))!=null&&vc(e,r,$0(t))}function G1(e,t,r,n,i){(t=N1(t,n))!=null&&(r=yc(e,r),i(t,e),bc(e,r))}function q1(e,t,r){(t=t==null||typeof t=="string"||lc(t)||t instanceof wn?t:void 0)!=null&&vc(e,r,lu(t).buffer)}var q_=wt((function(e,t,r){if(e.i!==1)return!1;var n=e.g;e=Ud(n);let i=Ud(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=n1||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),De=r.getUint32(0,!0),Ge=r.getUint32(4,!0),nc(e,De),nc(e,Ge))}),Er()),K1=wt((function(e,t,r){return e.i===5&&(St(t,r,Nd(e.g)),!0)}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,5),e=e.g,i1(t),nc(e,De))}),D1),K_=Ec((function(e,t,r){return(e.i===5||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?fu(e,Nd,t):t.push(Nd(e.g)),!0)}),(function(e,t,r){if((t=kc(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,i1(t[n]),nc(r,De)}}),D1),ic=wt((function(e,t,r){return e.i===0&&(St(t,r,hu(e.g,Yd)),!0)}),V1,P1),Pd=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=hu(e.g,Yd))===0?void 0:e),!0)}),V1,P1),X_=wt((function(e,t,r){return e.i===0&&(St(t,r,hu(e.g,Jd)),!0)}),(function(e,t,r){if((t=F_(t))!=null&&(typeof t=="string"&&k0(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 zd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=k0(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)}),H1,gu),Su=Ec((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?fu(e,Bt,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=kc(Xn,t))!=null&&t.length){r=yc(e,r);for(let n=0;n<t.length;n++)gc(e.g,t[n]);bc(e,r)}}),gu),Gi=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g))===0?void 0:e),!0)}),H1,gu),Wt=wt((function(e,t,r){return e.i===0&&(St(t,r,du(e.g)),!0)}),W1,R1),Ji=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=du(e.g))===!1?void 0:e),!0)}),W1,R1),sr=Ec((function(e,t,r){return e.i===2&&(e=uu(e),es(t,0|t[se],r,!1).push(e),!0)}),(function(e,t,r){if((t=kc(Sn,t))!=null)for(let s=0;s<t.length;s++){var n=e,i=r,o=t[s];o!=null&&vc(n,i,$0(o))}}),mu),_n=wt((function(e,t,r){return e.i===2&&(St(t,r,(e=uu(e))===""?void 0:e),!0)}),$1,mu),Ze=wt((function(e,t,r){return e.i===2&&(St(t,r,uu(e)),!0)}),$1,mu),ar=(function(e,t,r=pu){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),mc(e,n,i),!0)}),(function(e,t,r,n,i){if(Array.isArray(t))for(let o=0;o<t.length;o++)G1(e,t[o],r,n,i)})),ft=yu((function(e,t,r,n,i,o){return e.i===2&&(b1(t,0|t[se],o,r),mc(e,t=su(t,n,r),i),!0)}),G1),X1=wt((function(e,t,r){return e.i===2&&(St(t,r,A1(e)),!0)}),q1,O1),J_=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 fc(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),gc(e.g,t))}),B1),oc=class{constructor(t,r){this.i=t,this.g=r,this.j=Sr,this.defaultValue=void 0}};function J1(e,t){return(r,n)=>{if(Xa.length){let o=Xa.pop();o.o(n),Rd(o.g,r,n),r=o}else r=new class{constructor(o,s){if(S0.length){let a=S0.pop();Rd(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,Rd(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;wu(t)(s,r);var i=o}finally{r.g.clear(),r.m=-1,r.i=-1,Xa.length<100&&Xa.push(r)}return i}}var T0=[0,_n,wt((function(e,t,r){return e.i===2&&(St(t,r,(e=A1(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&&vc(e,r,lu(t).buffer)))}if(Array.isArray(t))return}q1(e,t,r)}),O1)],Dd,I0=globalThis.trustedTypes;function R0(e){Dd===void 0&&(Dd=(function(){let r=null;if(!I0)return r;try{let n=i=>i;r=I0.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r})());var t=Dd;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function Y_(e,...t){if(t.length===0)return R0(e[0]);let r=e[0];for(let n=0;n<t.length;n++)r+=encodeURIComponent(t[n])+e[n+1];return R0(r)}var Y1=[0,En,Jn,Wt,-1,Su,Jn,-1],Z_=class extends Ue{constructor(e){super(e)}},Z1=[0,Wt,Ze,Wt,Jn,-1,Ec((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?fu(e,z_,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=kc(Xn,t))!=null&&t.length){r=yc(e,r);for(let n=0;n<t.length;n++)gc(e.g,t[n]);bc(e,r)}}),B1),Ze,-1,[0,Wt,-1],Jn,Wt,-1],Q1=[0,Ze,-2],P0=class extends Ue{constructor(e){super(e)}},e2=[0],t2=[0,En,Wt,1,Wt,-3],r2=class extends Ue{constructor(e){super(e,2)}},Cc={};Cc[336783863]=[0,Ze,Wt,-1,En,[0,[1,2,3,4,5,6,7,8],ft,e2,ft,Z1,ft,Q1,ft,t2,ft,Y1,ft,[0,Ze,-2],ft,[0,Ze,Jn],ft,[0,Jn,Ze]],[0,Ze],Wt,[0,[1,3],[2,4],ft,[0,Su],-1,ft,[0,sr],-1,ar,[0,Ze,-1]],Ze];var D0,O0=[0,Pd,-1,Ji,-3,Pd,Su,_n,Gi,Pd,-1,Ji,Gi,Ji,-2,_n],ku=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,7,e)}},Ko=[-1,{}],B0=[0,Ze,1,Ko],L0=[0,Ze,sr,Ko],Eu=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,1001,e)}};Eu.prototype.g=(D0=[-500,ar,[-500,_n,-1,sr,-3,[-2,Cc,Wt],ar,T0,Gi,-1,B0,L0,ar,[0,_n,Ji],_n,O0,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,B0,L0,ar,[0,_n,-1,Ko],sr,-2,O0,_n,-1,Ji,[0,Ji,J_],978,Ko,ar,T0],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}}}};j1(this.l,e,Qn(_c,wc,Sc,D0)),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 Q_=class extends Ue{constructor(e){super(e)}},e3=class extends Ue{constructor(e){super(e)}g(){return au(this,Q_)}},t3=[0,ar,[0,En,K1,Ze,-1]],F0=class extends Ue{constructor(e){super(e)}},M0=class extends Ue{constructor(e){super(e)}},n2=[1,2,3,4,5],sc=class extends Ue{constructor(e){super(e)}g(){return m1(this)!=null}i(){return Sn(_r(this,2))!=null}},ac=class extends Ue{constructor(e){super(e)}},i2=class extends Ue{constructor(e){super(e)}},o2=[0,[0,X1,Ze,[0,En,ic,-1],[0,X_,ic]],Wt,[0,n2,ft,t2,ft,Z1,ft,Y1,ft,e2,ft,Q1],Jn],r3=new oc(451755788,i2);Cc[451755788]=[0,o2,[0,Ze,En,K1,sr,-1],q_];var U0=class extends Ue{constructor(e){super(e)}},s2=class extends Ue{constructor(e){super(e)}},n3=new oc(487277289,s2);Cc[487277289]=[0,o2,[0,Wt,-1]];var i3=class extends Ue{constructor(e){super(e)}},o3=J1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,1,En,Ze,t3],ic]),N0=class extends Ue{constructor(e){super(e)}},s3=class extends Ue{constructor(e){super(e)}J(){let e=m1(this);return e??Zi()}},a3=class extends Ue{constructor(e){super(e)}},a2=[1,2],z0=J1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,a2,ft,[0,K_],ft,[0,X1],En,Ze],ic]);function c3(){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 j0(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 V0(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 l3=(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:c3()?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=>{V0(this,Object.keys(e),(i=>{V0(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}}),c2=class extends l3{};async function h3(e,t,r){return e=await(async(n,i,o,s)=>{if(i&&await j0(i),!self.ModuleFactory||o&&(await j0(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 l2(e,t,r){return h3(e,t,r)}function Od(e,t){let r=wr(e.baseOptions,sc,1)||new sc;typeof t=="string"?(pt(r,2,rc(t)),pt(r,1)):t instanceof Uint8Array&&(pt(r,1,t1(t,!1)),pt(r,2)),Sr(e.baseOptions,0,1,r)}function h2(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,sc,1)?.g()||wr(e.baseOptions,sc,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,M0,3);if(!o){var s=o=new M0;Id(s,4,new P0)}"delegate"in i&&(i.delegate==="GPU"?Id(i=o,2,s=new Z_):Id(i=o,4,s=new P0)),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),Od(e,"/model.dat"),e.v()}));if(r.modelAssetBuffer instanceof Uint8Array)Od(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=>{Od(e,n),e.v()}));return e.v(),Promise.resolve()}function H0(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 Za=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),H0(this)}finishProcessing(){this.g.finishProcessing(),H0(this)}close(){this.g.closeGraph()}};async function Xo(e,t,r){return l2(e,t,r)}Za.prototype.close=Za.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",Za);var cc=class extends Za{constructor(){super(...arguments),this.F=48e3}O(e){this.F=e}};function d3(e){let t={classifications:au(e,i3).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,e3,4)?.g()??[],Xn(_r(r,2))??0,Sn(_r(r,3))??"")))};return Md(_r(e,2))!=null&&(t.timestampMs=Md(_r(e,2))??0),t}cc.prototype.setDefaultSampleRate=cc.prototype.O;var or=class extends cc{constructor(e,t){super(new c2(e,t)),this.m=[],Sr(e=this.i=new i2,0,1,t=new ac)}get baseOptions(){return wr(this.i,ac,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,F0,2);if(r=r?p1(r):new F0,e.displayNamesLocale!==void 0?pt(r,1,rc(e.displayNamesLocale)):e.displayNamesLocale===void 0&&pt(r,1),e.maxResults!==void 0){var n=e.maxResults;if(n!=null){if(typeof n!="number"||!fc(n))throw f0();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?w0(r,4,e.categoryAllowlist):"categoryAllowlist"in e&&pt(r,4),e.categoryDenylist!==void 0?w0(r,5,e.categoryDenylist):"categoryDenylist"in e&&pt(r,5),Sr(t,0,2,r),h2(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 Eu;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"timestamped_classifications");let t=new r2;T1(t,r3,this.i);let r=new ku;y1(r,rc("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),w1(e,r),this.g.attachProtoVectorListener("timestamped_classifications",((n,i)=>{(function(o,s){s.forEach((a=>{a=o3(a),o.m.push(d3(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 W0(e){return{embeddings:au(e,a3).map((t=>{let r={headIndex:Xn(_r(t,3))??0??-1,headName:Sn(_r(t,4))??""??""};if(v1(t,N0,Td(t,1))!==void 0)r.floatEmbedding=g1(wr(t,N0,Td(t,1)),1,Qo,r1===void 0?2:4).slice();else{let n=new Uint8Array(0);r.quantizedEmbedding=wr(t,s3,Td(t,2))?.J()?.i()??n}return r})),timestampMs:Md(_r(e,2))??0}}or.prototype.classify=or.prototype.K,or.prototype.setOptions=or.prototype.o,or.createFromModelPath=function(e,t){return l2(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 Fr=class extends cc{constructor(e,t){super(new c2(e,t)),this.m=[],Sr(e=this.i=new s2,0,1,t=new ac)}get baseOptions(){return wr(this.i,ac,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,U0,2);return r=r?p1(r):new U0,e.l2Normalize!==void 0?pt(r,1,v0(e.l2Normalize)):"l2Normalize"in e&&pt(r,1),e.quantize!==void 0?pt(r,2,v0(e.quantize)):"quantize"in e&&pt(r,2),Sr(t,0,2,r),h2(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 Eu;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"embeddings_out"),Ot(e,15,"timestamped_embeddings_out");let t=new r2;T1(t,n3,this.i);let r=new ku;y1(r,rc("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),w1(e,r),this.g.attachProtoListener("embeddings_out",((n,i)=>{n=z0(n),this.m.push(W0(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=z0(o),this.m.push(W0(n));qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_embeddings_out",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}},Ja;Fr.prototype.embed=Fr.prototype.L,Fr.prototype.setOptions=Fr.prototype.o,Fr.createFromModelPath=function(e,t){return Xo(Fr,e,{baseOptions:{modelAssetPath:t}})},Fr.createFromModelBuffer=function(e,t){return Xo(Fr,e,{baseOptions:{modelAssetBuffer:t}})},Fr.createFromOptions=function(e,t){return Xo(Fr,e,t)};var u3=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 d2(){if(Ja===void 0)try{await WebAssembly.instantiate(u3),Ja=!0}catch{Ja=!1}return Ja}async function Wo(e,t=Y_``){let r=await d2()?"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 d2()};function f3(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 xc=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 Jr(this.proctoringId,this.backend))}async startRecording(){this.examStartTime=Date.now(),await this.createAudioClassifier(),this.audioRecorder=new $a(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=f3(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([p3],{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)}},p3=`
|
|
435
|
+
Size: ${t.file.size}`,s),o}}throw new Error("Could not upload")}};var Wa=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 $a=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,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 c0(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var Ga,Ed,g_=typeof TextDecoder<"u",y_,b_=typeof TextEncoder<"u";function $0(e){if(b_)e=(y_||=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 Vd,Qa;e:{for(Cd=["CLOSURE_FLAGS"],qa=Kn,Ka=0;Ka<Cd.length;Ka++)if((qa=qa[Cd[Ka]])==null){Qa=null;break e}Qa=qa}var Cd,qa,Ka,Jo,l0=Qa&&Qa[610401301];Vd=l0!=null&&l0;var h0=Kn.navigator;function Bd(e){return!!Vd&&!!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!!Vd&&!!Jo&&Jo.brands.length>0}function xd(){return vn()?Bd("Chromium"):(cr("Chrome")||cr("CriOS"))&&!(!vn()&&cr("Edge"))||cr("Silk")}Jo=h0&&h0.userAgentData||null;var v_=!vn()&&(cr("Trident")||cr("MSIE"));!cr("Android")||xd(),xd(),cr("Safari")&&(xd()||!vn()&&cr("Coast")||!vn()&&cr("Opera")||!vn()&&cr("Edge")||(vn()?Bd("Microsoft Edge"):cr("Edg/"))||vn()&&Bd("Opera"));var G0={},$o=null;function __(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}q0();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 q0(){if(!$o){$o={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=e.concat(t[r].split(""));G0[r]=n;for(let i=0;i<n.length;i++){let o=n[i];$o[o]===void 0&&($o[o]=i)}}}}var K0=typeof Uint8Array<"u",X0=!v_&&typeof btoa=="function";function d0(e){if(!X0){var t;t===void 0&&(t=0),q0(),t=G0[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 u0=/[-_.]/g,w_={"-":"+",_:"/",".":"="};function S_(e){return w_[e]||""}function J0(e){if(!X0)return __(e);u0.test(e)&&(e=e.replace(u0,S_)),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 lc(e){return K0&&e!=null&&e instanceof Uint8Array}var Yi={};function Zi(){return k_||=new wn(null,Yi)}function Hd(e){Y0(Yi);var t=e.g;return(t=t==null||lc(t)?t:typeof t=="string"?J0(t):null)==null?t:e.g=t}var wn=class{i(){return new Uint8Array(Hd(this)||0)}constructor(e,t){if(Y0(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}},k_,E_;function Y0(e){if(e!==Yi)throw Error("illegal external caller")}function Z0(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function f0(){let e=Error("int32");return Z0(e,"warning"),e}var hc=typeof Symbol=="function"&&typeof Symbol()=="symbol",C_=new Set;function dc(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&&C_.add(e),e}var x_=dc("jas",void 0,!0,!0),Ad=dc(void 0,"2ex"),Ho=dc(void 0,"1oa",!0),Qi=dc(void 0,Symbol(),!0),se=hc?x_:"M",Q0={M:{value:0,configurable:!0,writable:!0,enumerable:!1}},e1=Object.defineProperties;function Wd(e,t){hc||se in e||e1(e,Q0),e[se]|=t}function ct(e,t){hc||se in e||e1(e,Q0),e[se]=t}function A_(e,t){ct(t,-30975&(0|e))}function Ld(e,t){ct(t,-30941&(34|e))}function $d(){return typeof BigInt=="function"}function lr(e){return Array.prototype.slice.call(e)}var Gd,Zo={},T_={};function p0(e){return!(!e||typeof e!="object"||e.g!==T_)}function qd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function t1(e,t){if(e!=null){if(typeof e=="string")e=e?new wn(e,Yi):Zi();else if(e.constructor!==wn)if(lc(e))e=e.length?new wn(new Uint8Array(e),Yi):Zi();else{if(!t)throw Error();e=void 0}}return e}function ec(e){return!(!Array.isArray(e)||e.length)&&!!(1&(0|e[se]))}var m0=[];function Yn(e){if(2&e)throw Error()}function Kd(e){return Qi?e[Qi]:void 0}ct(m0,55),Gd=Object.freeze(m0);var r1=Object.freeze({}),Xd=typeof Kn.BigInt=="function"&&typeof Kn.BigInt(0)=="bigint",Fd=e=>Xd?e>=R_&&e<=D_:e[0]==="-"?g0(e,I_):g0(e,P_),I_=Number.MIN_SAFE_INTEGER.toString(),R_=Xd?BigInt(Number.MIN_SAFE_INTEGER):void 0,P_=Number.MAX_SAFE_INTEGER.toString(),D_=Xd?BigInt(Number.MAX_SAFE_INTEGER):void 0;function g0(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 O_=typeof Uint8Array.prototype.slice=="function",n1,De=0,Ge=0;function y0(e){let t=e>>>0;De=t,Ge=(e-t)/4294967296>>>0}function eo(e){if(e<0){y0(-e);let[t,r]=Zd(De,Ge);De=t>>>0,Ge=r>>>0}else y0(e)}function i1(e){let t=n1||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ge=0,De=t.getUint32(0,!0)}function Jd(e,t){let r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Yo(e,t)}function Yd(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Jd(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 $d()?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+b0(r)+b0(e));return r}function b0(e){return e=String(e),"0000000".slice(e.length)+e}function uc(e){if(e.length<16)eo(Number(e));else if($d())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]=Zd(De,Ge);De=n,Ge=i}}}function Zd(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}var o1=typeof BigInt=="function"?BigInt.asIntN:void 0,B_=typeof BigInt=="function"?BigInt.asUintN:void 0,Go=Number.isSafeInteger,fc=Number.isFinite,tc=Math.trunc;function Qo(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function v0(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 L_=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Qd(e){switch(typeof e){case"bigint":return!0;case"number":return fc(e);case"string":return L_.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 fc(e)?0|e:void 0}function _0(e){if(e[0]==="-")return!1;let t=e.length;return t<20||t===20&&Number(e.substring(0,6))<184467}function s1(e){return e=tc(e),Go(e)||(eo(e),e=Yd(De,Ge)),e}function a1(e){var t=tc(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(uc(e),e=De,2147483648&(t=Ge))if($d())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=Zd(e,t);e="-"+Yo(r,n)}else e=Yo(e,t);return e}function Md(e){return e==null?e:typeof e=="bigint"?(Fd(e)?e=Number(e):(e=o1(64,e),e=Fd(e)?Number(e):String(e)),e):Qd(e)?typeof e=="number"?s1(e):a1(e):void 0}function F_(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(B_(64,e));if(Qd(e)){if(t==="string")return t=tc(Number(e)),Go(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),_0(e)||(uc(e),e=Yo(De,Ge))),e;if(t==="number")return(e=tc(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 _0(n=String(r))?n:(eo(r),Jd(De,Ge))})(e)}}function c1(e){if(typeof e!="string")throw Error();return e}function rc(e){if(e!=null&&typeof e!="string")throw Error();return e}function Sn(e){return e==null||typeof e=="string"?e:void 0}function l1(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 h1(e,t,r,n,i){if(e!=null){if(Array.isArray(e))e=ec(e)?void 0:i&&2&(0|e[se])?e:eu(e,t,r,n!==void 0,i);else if(qd(e)){let o={};for(let s in e)o[s]=h1(e[s],t,r,n,i);e=o}else e=t(e,n);return e}}function eu(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]=h1(n[a],t,r,s,i);return r&&((e=Kd(e))&&(n[Qi]=lr(e)),r(o,n)),n}function M_(e){return e.B===Zo?e.toJSON():(function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return Fd(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(ec(t))return}else{if(lc(t))return d0(t);if(t instanceof wn){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=d0(r)}}}return t})(e)}function U_(e){return eu(e,M_,void 0,void 0,!1)}var d1,N_;function qo(e,t,r){return e=u1(e,t[0],t[1],r?1:2),t!==d1&&r&&Wd(e,16384),e}function u1(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(qd(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 f1(e,t,r=Ld){if(e!=null){if(K0&&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):eu(e,f1,4&n?Ld:r,!0,!0))}return e.B===Zo&&(e=2&(n=0|(r=e.l)[se])?e:new e.constructor(pc(r,n,!0))),e}}function p1(e){let t=e.l;return new e.constructor(pc(t,0|t[se],!1))}function pc(e,t,r){let n=r||2&t?Ld:A_,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=Kd(o))&&(c[Qi]=lr(o)),c})(e,t,(o=>f1(o,i,n))),Wd(e,32|(r?2:0)),e}function tu(e){let t=e.l,r=0|t[se];return 2&r?new e.constructor(pc(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&&Ad!=null&&((i=(e=E_??={})[Ad]||0)>=4||(e[Ad]=i+1,Z0(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 m1(e){let t=0|(e=e.l)[se],r=Zn(e,t,1),n=t1(r,!0);return n!=null&&n!==r&<(e,t,1,n),n}function g1(e,t,r,n,i){let o=e.l,s=2&(e=0|o[se])?1:n;i=!!i;let a=0|(n=ru(o,e,t))[se];if(!(4&a)){4&a&&(n=lr(n),a=Qr(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=nu(a,e),r=-4097&(20|a),a=r&=-8193,ct(n,a),2&a&&Object.freeze(n)}return s===1||s===4&&32&a?Zr(a)||(i=a,a|=2,a!==i&&ct(n,a),Object.freeze(n)):(s===2&&Zr(a)&&(n=lr(n),a=Qr(a,e),a=kn(a,e,i),ct(n,a),e=lt(o,e,t,n)),Zr(a)||(t=a,a=kn(a,e,i),a!==t&&ct(n,a))),n}function ru(e,t,r,n){return e=Zn(e,t,r,n),Array.isArray(e)?e:Gd}function nu(e,t){return e===0&&(e=Qr(e,t)),1|e}function Zr(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function w0(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=Zr(i),a=s||Object.isFrozen(r);for(s||(i=0),a||(r=lr(r),o=0,i=kn(i=Qr(i,n),n,!0),a=!1),i|=21,s=0;s<r.length;s++){let c=r[s],l=c1(c);Object.is(c,l)||(a&&(r=lr(r),o=0,i=kn(i=Qr(i,n),n,!0),a=!1),r[s]=l)}i!==o&&(a&&(r=lr(r),i=kn(i=Qr(i,n),n,!0)),ct(r,i)),lt(e,n,t,r)}}function y1(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=ru(e,t,r,i))!==Gd;if(o||!s){let a=o=s?0|i[se]:0;(!s||2&a||Zr(a)||4&a&&!(32&a))&&(i=lr(i),a=Qr(a,t),t=lt(e,t,r,i)),a=-13&nu(a,t),a=kn(n?-17&a:16|a,t,!0),a!==o&&ct(i,a)}return i}function Td(e,t){var r=a2;return ou(iu(e=e.l),e,0|e[se],r)===t?t:-1}function iu(e){if(hc)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 b1(e,t,r,n){let i=iu(e),o=ou(i,e,t,r);return o!==n&&(o&&(t=lt(e,t,o)),i.set(r,n)),t}function ou(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 su(e,t,r,n){let i,o=0|e[se];if((n=Zn(e,o,r,n))!=null&&n.B===Zo)return(t=tu(n))!==n&<(e,o,r,t),t.l;if(Array.isArray(n)){let s=0|n[se];i=2&s?qo(pc(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 v1(e,t,r,n){let i=0|(e=e.l)[se];return(t=l1(n=Zn(e,i,r,n),t,i))!==n&&t!=null&<(e,i,r,t),t}function wr(e,t,r){if((t=v1(e,t,r,!1))==null)return t;let n=0|(e=e.l)[se];if(!(2&n)){let i=tu(t);i!==t&<(e,n,r,t=i)}return t}function _1(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=ru(e,t,1))[se];if(!(s=!!(4&c))){var l=n,h=t;let d=!!(2&(c=nu(c,t)));d&&(h|=2);let m=!d,p=!0,g=0,f=0;for(;g<l.length;g++){let b=l1(l[g],r,h);if(b instanceof r){if(!d){let v=!!(2&(0|b.l[se]));m&&=!v,p&&=v}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(Zr(c)&&(n=lr(n),c=Qr(c,t),t=lt(e,t,1,n)),r=n,o=c,l=0;l<r.length;l++)(c=r[l])!==(h=tu(c))&&(r[l]=h);o|=8,ct(r,o=r.length?-17&o:16|o),c=o}return a===1||a===4&&32&c?Zr(c)||(t=c,(c|=!n.length||16&c&&(!s||32&c)?2:2048)!==t&&ct(n,c),Object.freeze(n)):(a===2&&Zr(c)&&(ct(n=lr(n),c=kn(c=Qr(c,t),t,i)),t=lt(e,t,1,n)),Zr(c)||(e=c,(c=kn(c,t,i))!==e&&ct(n,c))),n}function au(e,t){let r=0|e.l[se];return _1(e,r,t,r1===void 0?2:4,!1,!(2&r))}function Sr(e,t,r,n){return n==null&&(n=void 0),pt(e,r,n)}function Id(e,t,r){var n=n2;r==null&&(r=void 0);e:{let i=0|(e=e.l)[se];if(Yn(i),r==null){let o=iu(e);if(ou(o,e,i,n)!==t)break e;o.set(n,0)}else i=b1(e,i,n,t);lt(e,i,t,r)}}function Qr(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 w1(e,t){var r=ku;let n=0|e.l[se];Yn(n),e=_1(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]),g1(e,t,Sn,2,!0).push(c1(r))}function S1(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function cu(){return Error("Failed to read varint, encoding is invalid.")}function k1(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function lu(e){if(typeof e=="string")return{buffer:J0(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:Hd(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 hu(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 cu()}function du(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 cu()}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 cu();return qn(e,r),i}function Ud(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 Nd(e){var t=Ud(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 z_(e){return Bt(e)}function Rd(e,t,{C:r=!1}={}){e.C=r,t&&(t=lu(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 k1(e.j,t)}function E1(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 k1(t,e.j-r);return e.g=n,r}function C1(e,t){if(t==0)return Zi();var r=E1(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):O_?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Zi():new wn(r,Yi)}var S0=[];function x1(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 S1(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 Ya(e){switch(e.i){case 0:e.i!=0?Ya(e):du(e.g);break;case 1:qn(e=e.g,e.g+8);break;case 2:if(e.i!=2)Ya(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(!x1(e))throw Error("Unmatched start-group tag: stream EOF");if(e.i==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}Ya(e)}break;default:throw S1(e.i,e.j)}}function mc(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 uu(e){var t=Bt(e.g)>>>0,r=E1(e=e.g,t);if(e=e.i,g_){var n,i=e;(n=Ed)||(n=Ed=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(Ga===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),Ga=!0}catch{Ga=!1}}throw!Ga&&(Ed=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=c0(c,r),r.length=0)}o=c0(c,r)}return o}function A1(e){let t=Bt(e.g)>>>0;return C1(e.g,t)}function fu(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 Xa=[];function j_(e){return e}var Ki;function T1(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=u1(e,t)}toJSON(){let e=!Ki;try{return e&&(Ki=U_),I1(this)}finally{e&&(Ki=void 0)}}u(){return!!(2&(0|this.l[se]))}};function I1(e){var t=e.l;{t=(e=Ki(t))!==t;let l=e.length;if(l){var r=e[l-1],n=qd(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)&&(ec(n)||p0(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||ec(o)||p0(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 k0(e){return e?/^\d+$/.test(e)?(uc(e),new zd(De,Ge)):null:V_||=new zd(0,0)}Ue.prototype.B=Zo,Ue.prototype.toString=function(){try{return Ki=j_,I1(this).toString()}finally{Ki=void 0}};var zd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},V_;function E0(e){return e?/^-?\d+$/.test(e)?(uc(e),new jd(De,Ge)):null:H_||=new jd(0,0)}var jd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},H_;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 gc(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 nc(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 yc(e,t){return kr(e,t,2),t=e.g.end(),to(e,t),t.push(e.i),t}function bc(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 vc(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 pu=Er(),R1=Er(),mu=Er(),gu=Er(),P1=Er(),D1=Er(),O1=Er(),B1=Er(),ro=class{constructor(e,t,r){this.g=e,this.i=t,e=pu,this.j=!!e&&r===e||!1}};function yu(e,t){return new ro(e,t,pu)}function L1(e,t,r,n,i){(t=N1(t,n))!=null&&(r=yc(e,r),i(t,e),bc(e,r))}var W_=yu((function(e,t,r,n,i){return e.i===2&&(mc(e,su(t,n,r),i),!0)}),L1),$_=yu((function(e,t,r,n,i){return e.i===2&&(mc(e,su(t,n,r,!0),i),!0)}),L1),_c=Symbol(),bu=Symbol(),C0=Symbol(),x0=Symbol(),F1,M1;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 d1||=[0,void 0,!0];case"number":return d>0?void 0:d===0?N_||=[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,F1??=o,M1??=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=W_,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 U1(e){return Array.isArray(e)?e[0]instanceof ro?e:[$_,e]:[e,void 0]}function N1(e,t){return e instanceof Ue?e.l:Array.isArray(e)?qo(e,t,!1):void 0}function vu(e,t,r,n){let i=r.g;e[t]=n?(o,s,a)=>i(o,s,a,n):i}function _u(e,t,r,n,i){let o=r.g,s,a;e[t]=(c,l,h)=>o(c,l,h,a||=Qn(bu,vu,_u,n).A,s||=wu(n),i)}function wu(e){let t=e[C0];if(t!=null)return t;let r=Qn(bu,vu,_u,e);return t=r.I?(n,i)=>F1(n,i,r):(n,i)=>{let o=0|n[se];for(;x1(i)&&i.i!=4;){var s=i.m,a=r[s];if(a==null){var c=r.H;c&&(c=c[s])&&(c=G_(c))!=null&&(a=r[s]=c)}a!=null&&a(i,n,s)||(s=(a=i).j,Ya(a),a.G?a=void 0:(c=a.g.g-s,a.g.g=s,a=C1(a.g,c)),s=n,a&&((c=s[Qi])?c.push(a):s[Qi]=[a]))}return 16384&o&&Wd(n,34),!0},e[C0]=t}function G_(e){let t=(e=U1(e))[0].g;if(e=e[1]){let r=wu(e),n=Qn(bu,vu,_u,e).A;return(i,o,s)=>t(i,o,s,n,r)}return t}function wc(e,t,r){e[t]=r.i}function Sc(e,t,r,n){let i,o,s=r.i;e[t]=(a,c,l)=>s(a,c,l,o||=Qn(_c,wc,Sc,n).A,i||=z1(n))}function z1(e){let t=e[x0];if(!t){let r=Qn(_c,wc,Sc,e);t=(n,i)=>j1(n,i,r),e[x0]=t}return t}function j1(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=A0(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=A0(r,i))&&a(t,o,i)}if(e=Kd(e))for(to(t,t.g.end()),r=0;r<e.length;r++)to(t,Hd(e[r])||new Uint8Array(0))}function A0(e,t){var r=e[t];if(r)return r;if((r=e.H)&&(r=r[t])){var n=(r=U1(r))[0].i;if(r=r[1]){let i=z1(r),o=Qn(_c,wc,Sc,r).A;r=e.I?M1(o,i):(s,a,c)=>n(s,a,c,o,i)}else r=n;return e[t]=r}}function kc(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 Ec(e,t,r){return new ro(e,t,r)}function St(e,t,r){lt(e,0|e[se],t,r)}function V1(e,t,r){if(t=(function(n){if(n==null)return n;let i=typeof n;if(i==="bigint")return String(o1(64,n));if(Qd(n)){if(i==="string")return a1(n);if(i==="number")return s1(n)}})(t),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 jd(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)}}function H1(e,t,r){(t=Xn(t))!=null&&t!=null&&(kr(e,r,0),gc(e.g,t))}function W1(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 $1(e,t,r){(t=Sn(t))!=null&&vc(e,r,$0(t))}function G1(e,t,r,n,i){(t=N1(t,n))!=null&&(r=yc(e,r),i(t,e),bc(e,r))}function q1(e,t,r){(t=t==null||typeof t=="string"||lc(t)||t instanceof wn?t:void 0)!=null&&vc(e,r,lu(t).buffer)}var q_=wt((function(e,t,r){if(e.i!==1)return!1;var n=e.g;e=Ud(n);let i=Ud(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=n1||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),De=r.getUint32(0,!0),Ge=r.getUint32(4,!0),nc(e,De),nc(e,Ge))}),Er()),K1=wt((function(e,t,r){return e.i===5&&(St(t,r,Nd(e.g)),!0)}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,5),e=e.g,i1(t),nc(e,De))}),D1),K_=Ec((function(e,t,r){return(e.i===5||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?fu(e,Nd,t):t.push(Nd(e.g)),!0)}),(function(e,t,r){if((t=kc(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,i1(t[n]),nc(r,De)}}),D1),ic=wt((function(e,t,r){return e.i===0&&(St(t,r,hu(e.g,Yd)),!0)}),V1,P1),Pd=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=hu(e.g,Yd))===0?void 0:e),!0)}),V1,P1),X_=wt((function(e,t,r){return e.i===0&&(St(t,r,hu(e.g,Jd)),!0)}),(function(e,t,r){if((t=F_(t))!=null&&(typeof t=="string"&&k0(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 zd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=k0(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)}),H1,gu),Su=Ec((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?fu(e,Bt,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=kc(Xn,t))!=null&&t.length){r=yc(e,r);for(let n=0;n<t.length;n++)gc(e.g,t[n]);bc(e,r)}}),gu),Gi=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g))===0?void 0:e),!0)}),H1,gu),Wt=wt((function(e,t,r){return e.i===0&&(St(t,r,du(e.g)),!0)}),W1,R1),Ji=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=du(e.g))===!1?void 0:e),!0)}),W1,R1),sr=Ec((function(e,t,r){return e.i===2&&(e=uu(e),es(t,0|t[se],r,!1).push(e),!0)}),(function(e,t,r){if((t=kc(Sn,t))!=null)for(let s=0;s<t.length;s++){var n=e,i=r,o=t[s];o!=null&&vc(n,i,$0(o))}}),mu),_n=wt((function(e,t,r){return e.i===2&&(St(t,r,(e=uu(e))===""?void 0:e),!0)}),$1,mu),Ze=wt((function(e,t,r){return e.i===2&&(St(t,r,uu(e)),!0)}),$1,mu),ar=(function(e,t,r=pu){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),mc(e,n,i),!0)}),(function(e,t,r,n,i){if(Array.isArray(t))for(let o=0;o<t.length;o++)G1(e,t[o],r,n,i)})),ft=yu((function(e,t,r,n,i,o){return e.i===2&&(b1(t,0|t[se],o,r),mc(e,t=su(t,n,r),i),!0)}),G1),X1=wt((function(e,t,r){return e.i===2&&(St(t,r,A1(e)),!0)}),q1,O1),J_=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 fc(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),gc(e.g,t))}),B1),oc=class{constructor(t,r){this.i=t,this.g=r,this.j=Sr,this.defaultValue=void 0}};function J1(e,t){return(r,n)=>{if(Xa.length){let o=Xa.pop();o.o(n),Rd(o.g,r,n),r=o}else r=new class{constructor(o,s){if(S0.length){let a=S0.pop();Rd(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,Rd(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;wu(t)(s,r);var i=o}finally{r.g.clear(),r.m=-1,r.i=-1,Xa.length<100&&Xa.push(r)}return i}}var T0=[0,_n,wt((function(e,t,r){return e.i===2&&(St(t,r,(e=A1(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&&vc(e,r,lu(t).buffer)))}if(Array.isArray(t))return}q1(e,t,r)}),O1)],Dd,I0=globalThis.trustedTypes;function R0(e){Dd===void 0&&(Dd=(function(){let r=null;if(!I0)return r;try{let n=i=>i;r=I0.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r})());var t=Dd;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function Y_(e,...t){if(t.length===0)return R0(e[0]);let r=e[0];for(let n=0;n<t.length;n++)r+=encodeURIComponent(t[n])+e[n+1];return R0(r)}var Y1=[0,En,Jn,Wt,-1,Su,Jn,-1],Z_=class extends Ue{constructor(e){super(e)}},Z1=[0,Wt,Ze,Wt,Jn,-1,Ec((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?fu(e,z_,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=kc(Xn,t))!=null&&t.length){r=yc(e,r);for(let n=0;n<t.length;n++)gc(e.g,t[n]);bc(e,r)}}),B1),Ze,-1,[0,Wt,-1],Jn,Wt,-1],Q1=[0,Ze,-2],P0=class extends Ue{constructor(e){super(e)}},e2=[0],t2=[0,En,Wt,1,Wt,-3],r2=class extends Ue{constructor(e){super(e,2)}},Cc={};Cc[336783863]=[0,Ze,Wt,-1,En,[0,[1,2,3,4,5,6,7,8],ft,e2,ft,Z1,ft,Q1,ft,t2,ft,Y1,ft,[0,Ze,-2],ft,[0,Ze,Jn],ft,[0,Jn,Ze]],[0,Ze],Wt,[0,[1,3],[2,4],ft,[0,Su],-1,ft,[0,sr],-1,ar,[0,Ze,-1]],Ze];var D0,O0=[0,Pd,-1,Ji,-3,Pd,Su,_n,Gi,Pd,-1,Ji,Gi,Ji,-2,_n],ku=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,7,e)}},Ko=[-1,{}],B0=[0,Ze,1,Ko],L0=[0,Ze,sr,Ko],Eu=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,1001,e)}};Eu.prototype.g=(D0=[-500,ar,[-500,_n,-1,sr,-3,[-2,Cc,Wt],ar,T0,Gi,-1,B0,L0,ar,[0,_n,Ji],_n,O0,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,B0,L0,ar,[0,_n,-1,Ko],sr,-2,O0,_n,-1,Ji,[0,Ji,J_],978,Ko,ar,T0],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}}}};j1(this.l,e,Qn(_c,wc,Sc,D0)),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 Q_=class extends Ue{constructor(e){super(e)}},e3=class extends Ue{constructor(e){super(e)}g(){return au(this,Q_)}},t3=[0,ar,[0,En,K1,Ze,-1]],F0=class extends Ue{constructor(e){super(e)}},M0=class extends Ue{constructor(e){super(e)}},n2=[1,2,3,4,5],sc=class extends Ue{constructor(e){super(e)}g(){return m1(this)!=null}i(){return Sn(_r(this,2))!=null}},ac=class extends Ue{constructor(e){super(e)}},i2=class extends Ue{constructor(e){super(e)}},o2=[0,[0,X1,Ze,[0,En,ic,-1],[0,X_,ic]],Wt,[0,n2,ft,t2,ft,Z1,ft,Y1,ft,e2,ft,Q1],Jn],r3=new oc(451755788,i2);Cc[451755788]=[0,o2,[0,Ze,En,K1,sr,-1],q_];var U0=class extends Ue{constructor(e){super(e)}},s2=class extends Ue{constructor(e){super(e)}},n3=new oc(487277289,s2);Cc[487277289]=[0,o2,[0,Wt,-1]];var i3=class extends Ue{constructor(e){super(e)}},o3=J1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,1,En,Ze,t3],ic]),N0=class extends Ue{constructor(e){super(e)}},s3=class extends Ue{constructor(e){super(e)}J(){let e=m1(this);return e??Zi()}},a3=class extends Ue{constructor(e){super(e)}},a2=[1,2],z0=J1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,a2,ft,[0,K_],ft,[0,X1],En,Ze],ic]);function c3(){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 j0(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 V0(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 l3=(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:c3()?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=>{V0(this,Object.keys(e),(i=>{V0(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}}),c2=class extends l3{};async function h3(e,t,r){return e=await(async(n,i,o,s)=>{if(i&&await j0(i),!self.ModuleFactory||o&&(await j0(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 l2(e,t,r){return h3(e,t,r)}function Od(e,t){let r=wr(e.baseOptions,sc,1)||new sc;typeof t=="string"?(pt(r,2,rc(t)),pt(r,1)):t instanceof Uint8Array&&(pt(r,1,t1(t,!1)),pt(r,2)),Sr(e.baseOptions,0,1,r)}function h2(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,sc,1)?.g()||wr(e.baseOptions,sc,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,M0,3);if(!o){var s=o=new M0;Id(s,4,new P0)}"delegate"in i&&(i.delegate==="GPU"?Id(i=o,2,s=new Z_):Id(i=o,4,s=new P0)),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),Od(e,"/model.dat"),e.v()}));if(r.modelAssetBuffer instanceof Uint8Array)Od(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=>{Od(e,n),e.v()}));return e.v(),Promise.resolve()}function H0(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 Za=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),H0(this)}finishProcessing(){this.g.finishProcessing(),H0(this)}close(){this.g.closeGraph()}};async function Xo(e,t,r){return l2(e,t,r)}Za.prototype.close=Za.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",Za);var cc=class extends Za{constructor(){super(...arguments),this.F=48e3}O(e){this.F=e}};function d3(e){let t={classifications:au(e,i3).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,e3,4)?.g()??[],Xn(_r(r,2))??0,Sn(_r(r,3))??"")))};return Md(_r(e,2))!=null&&(t.timestampMs=Md(_r(e,2))??0),t}cc.prototype.setDefaultSampleRate=cc.prototype.O;var or=class extends cc{constructor(e,t){super(new c2(e,t)),this.m=[],Sr(e=this.i=new i2,0,1,t=new ac)}get baseOptions(){return wr(this.i,ac,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,F0,2);if(r=r?p1(r):new F0,e.displayNamesLocale!==void 0?pt(r,1,rc(e.displayNamesLocale)):e.displayNamesLocale===void 0&&pt(r,1),e.maxResults!==void 0){var n=e.maxResults;if(n!=null){if(typeof n!="number"||!fc(n))throw f0();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?w0(r,4,e.categoryAllowlist):"categoryAllowlist"in e&&pt(r,4),e.categoryDenylist!==void 0?w0(r,5,e.categoryDenylist):"categoryDenylist"in e&&pt(r,5),Sr(t,0,2,r),h2(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 Eu;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"timestamped_classifications");let t=new r2;T1(t,r3,this.i);let r=new ku;y1(r,rc("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),w1(e,r),this.g.attachProtoVectorListener("timestamped_classifications",((n,i)=>{(function(o,s){s.forEach((a=>{a=o3(a),o.m.push(d3(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 W0(e){return{embeddings:au(e,a3).map((t=>{let r={headIndex:Xn(_r(t,3))??0??-1,headName:Sn(_r(t,4))??""??""};if(v1(t,N0,Td(t,1))!==void 0)r.floatEmbedding=g1(wr(t,N0,Td(t,1)),1,Qo,r1===void 0?2:4).slice();else{let n=new Uint8Array(0);r.quantizedEmbedding=wr(t,s3,Td(t,2))?.J()?.i()??n}return r})),timestampMs:Md(_r(e,2))??0}}or.prototype.classify=or.prototype.K,or.prototype.setOptions=or.prototype.o,or.createFromModelPath=function(e,t){return l2(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 Fr=class extends cc{constructor(e,t){super(new c2(e,t)),this.m=[],Sr(e=this.i=new s2,0,1,t=new ac)}get baseOptions(){return wr(this.i,ac,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,U0,2);return r=r?p1(r):new U0,e.l2Normalize!==void 0?pt(r,1,v0(e.l2Normalize)):"l2Normalize"in e&&pt(r,1),e.quantize!==void 0?pt(r,2,v0(e.quantize)):"quantize"in e&&pt(r,2),Sr(t,0,2,r),h2(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 Eu;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"embeddings_out"),Ot(e,15,"timestamped_embeddings_out");let t=new r2;T1(t,n3,this.i);let r=new ku;y1(r,rc("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),w1(e,r),this.g.attachProtoListener("embeddings_out",((n,i)=>{n=z0(n),this.m.push(W0(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=z0(o),this.m.push(W0(n));qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_embeddings_out",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}},Ja;Fr.prototype.embed=Fr.prototype.L,Fr.prototype.setOptions=Fr.prototype.o,Fr.createFromModelPath=function(e,t){return Xo(Fr,e,{baseOptions:{modelAssetPath:t}})},Fr.createFromModelBuffer=function(e,t){return Xo(Fr,e,{baseOptions:{modelAssetBuffer:t}})},Fr.createFromOptions=function(e,t){return Xo(Fr,e,t)};var u3=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 d2(){if(Ja===void 0)try{await WebAssembly.instantiate(u3),Ja=!0}catch{Ja=!1}return Ja}async function Wo(e,t=Y_``){let r=await d2()?"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 d2()};function f3(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 xc=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 Jr(this.proctoringId,this.backend))}async startRecording(){this.examStartTime=Date.now(),await this.createAudioClassifier(),this.audioRecorder=new $a(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=f3(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([p3],{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)}},p3=`
|
|
436
436
|
class AudioProcessor extends AudioWorkletProcessor {
|
|
437
437
|
bufferSize;
|
|
438
438
|
inputBuffer;
|
|
@@ -500,7 +500,7 @@ registerProcessor("audio-processor", AudioProcessor);
|
|
|
500
500
|
<circle cx="10" cy="10" r="9" stroke="#16A34A" stroke-width="2" fill="none"/>
|
|
501
501
|
<path d="M6 10L9 13L14 7" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
502
502
|
</svg>
|
|
503
|
-
`,this.applyStyles(v,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",flexShrink:"0"});let k=document.createElement("span");k.innerText=f,b.appendChild(v),b.appendChild(k),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}).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=vy[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 al=class{constructor(t){this.context=t;this.deviceData=null;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:20,realtimeUploadInterval:30}};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 Tc(this.context.credentials.cpf,this.backend)),this.appChecker=new sl(this.context,r=>this.onRealtimeAlertsCallback(r))}setOnStopSharingScreenCallback(t){this.onStopSharingScreenCallback=async()=>{me.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 Va(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 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.backend.stopRealtimeAlert({proctoringId:this.proctoringId,begin:r.begin,end:r.end,warningCategoryEnum:this.convertRealtimeTypeToWarningType(r.type),alertImageBase64:await this.allRecorders.cameraRecorder.getCurrentImageBase64()}))}}setOnBufferSizeErrorCallback(t){this.onBufferSizeErrorCallback=r=>t(r)}setDeviceCheckData(t){this.deviceData=t}createRecorders(t=ir){this.onChangeDevices();let r=new Yr({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},this.paramsConfig,this.backend,this.context.token),n=this.sessionOptions.captureScreen?new Ac({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 Wa({onFocusCallback:a=>this.onFocusAlertRecorderCallback(a),onLostFocusCallback:a=>this.onLostFocusAlertRecorderCallback(a),onRealtimeAlertCallback:a=>this.onRealtimeAlertsCallback(a)},t),o=new xc(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 Ha(this.proctoringSession,s),{cameraRecorder:r,screenRecorder:n,alertRecorder:i,noiseRecorder:o}}async login(){if(!this.context.credentials?.cpf)throw Qg;this.context.token=await this.auth.login()}async start(t=ir,r={}){try{if(this.context.token===void 0)throw Zg;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 e0}if(this.state!="Stop")throw Kg;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,me.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 t0}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];me.registerStart(this.proctoringId,!0,`Version: ${ns()}
|
|
503
|
+
`,this.applyStyles(v,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",flexShrink:"0"});let k=document.createElement("span");k.innerText=f,b.appendChild(v),b.appendChild(k),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=vy[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 al=class{constructor(t){this.context=t;this.deviceData=null;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 Tc(this.context.credentials.cpf,this.backend)),this.appChecker=new sl(this.context,r=>this.onRealtimeAlertsCallback(r))}setOnStopSharingScreenCallback(t){this.onStopSharingScreenCallback=async()=>{me.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 Va(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 Yr({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},this.paramsConfig,this.backend,this.context.token),n=this.sessionOptions.captureScreen?new Ac({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 Wa({onFocusCallback:a=>this.onFocusAlertRecorderCallback(a),onLostFocusCallback:a=>this.onLostFocusAlertRecorderCallback(a),onRealtimeAlertCallback:a=>this.onRealtimeAlertsCallback(a)},t),o=new xc(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 Ha(this.proctoringSession,s),{cameraRecorder:r,screenRecorder:n,alertRecorder:i,noiseRecorder:o}}async login(){if(!this.context.credentials?.cpf)throw Qg;this.context.token=await this.auth.login()}async start(t=ir,r={}){try{if(this.context.token===void 0)throw Zg;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 e0}if(this.state!="Stop")throw Kg;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,me.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 t0}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];me.registerStart(this.proctoringId,!0,`Version: ${ns()}
|
|
504
504
|
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&&me.registerStart(this.proctoringId,!1,`Token: ${this.context.token}
|
|
505
505
|
Version: ${ns()}
|
|
506
506
|
Navigator: ${navigator}
|