From d53c2a615235a55c58c9a11125850d771556f06f Mon Sep 17 00:00:00 2001
From: allancoding <74841470+allancoding@users.noreply.github.com>
Date: Mon, 31 Jan 2022 12:03:46 -0700
Subject: [PATCH 01/25] Update README.md
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index f830bc7..5047955 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+# Allancoding's Version of Emulatorjs
# EmulatorJS
From cf9e190c9cd4640bf6c986ec920c233a71f73e78 Mon Sep 17 00:00:00 2001
From: allancoding <74841470+allancoding@users.noreply.github.com>
Date: Mon, 31 Jan 2022 12:04:41 -0700
Subject: [PATCH 02/25] Update README.md
---
README.md | 2 --
1 file changed, 2 deletions(-)
diff --git a/README.md b/README.md
index 5047955..e34892f 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,5 @@
# Allancoding's Version of Emulatorjs
-# EmulatorJS
-
Self-hosted **Javascript** emulation for various system.
From 710af0dbb44937ef323f11d555d74074dae2e7d6 Mon Sep 17 00:00:00 2001
From: allancoding <74841470+allancoding@users.noreply.github.com>
Date: Mon, 31 Jan 2022 12:09:40 -0700
Subject: [PATCH 03/25] Update emu-main.js
---
data/emu-main.js | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/data/emu-main.js b/data/emu-main.js
index 63b2e37..dd712b9 100644
--- a/data/emu-main.js
+++ b/data/emu-main.js
@@ -28,7 +28,7 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
'reset': 'Reset',
'disabled': 'Disabled',
'enabled': 'Enabled',
- 'playNow': 'Play Now'
+ 'playNow': 'Start Game'
},
'listeners': {
'play': null,
@@ -6036,3 +6036,14 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
_0x17edbf.default = _0x3dbc76;
}
+$(".ejs--73f9b4e94a7a1fe74e11107d5ab2ef").attr("id","start");
+$(".ejs--cbcfe0a1421cadac9a04c81d6431d6").attr("id","loding");
+$(".ejs--71527b6509aa48afce3ce1a11c02f0").attr("id","naming");
+$(".ejs--057800d021995e1347ec07cb748672").addClass("backg");
+$("#loding").attr("hidden","");
+$("#loding").hide();
+$("#start").on('touchstart click', function() {
+$(".ejs--057800d021995e1347ec07cb748672").removeClass("backg");
+$("#loding").show();
+$("#loding").removeAttr("hidden");
+$("div").remove(".ejs--f3a1903d935f6cf720d4a0498db62a");
From bb4a5bb0cd5c0d6edcbcf13a4e34094f5e055a99 Mon Sep 17 00:00:00 2001
From: allancoding <74841470+allancoding@users.noreply.github.com>
Date: Mon, 31 Jan 2022 14:32:21 -0700
Subject: [PATCH 04/25] Update emu-main.js
---
data/emu-main.js | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/data/emu-main.js b/data/emu-main.js
index dd712b9..9c91631 100644
--- a/data/emu-main.js
+++ b/data/emu-main.js
@@ -6036,14 +6036,22 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
_0x17edbf.default = _0x3dbc76;
}
-$(".ejs--73f9b4e94a7a1fe74e11107d5ab2ef").attr("id","start");
-$(".ejs--cbcfe0a1421cadac9a04c81d6431d6").attr("id","loding");
-$(".ejs--71527b6509aa48afce3ce1a11c02f0").attr("id","naming");
-$(".ejs--057800d021995e1347ec07cb748672").addClass("backg");
-$("#loding").attr("hidden","");
-$("#loding").hide();
-$("#start").on('touchstart click', function() {
-$(".ejs--057800d021995e1347ec07cb748672").removeClass("backg");
-$("#loding").show();
-$("#loding").removeAttr("hidden");
-$("div").remove(".ejs--f3a1903d935f6cf720d4a0498db62a");
+$(document).ready(function(){
+ $(".ejs--73f9b4e94a7a1fe74e11107d5ab2ef").attr("id","start");
+ $(".ejs--cbcfe0a1421cadac9a04c81d6431d6").attr("id","loding");
+ $(".ejs--71527b6509aa48afce3ce1a11c02f0").attr("id","naming");
+ $(".ejs--057800d021995e1347ec07cb748672").addClass("backg");
+ $("#loding").attr("hidden","");
+ $("#loding").hide();
+ $("#start").on('touchstart click', function() {
+ $(".ejs--057800d021995e1347ec07cb748672").removeClass("backg");
+ $("#loding").show();
+ $("#loding").removeAttr("hidden");
+ $("div").remove(".ejs--f3a1903d935f6cf720d4a0498db62a");
+ setTimeout(
+ function()
+ {
+ $("div").remove(".ejs--cbcfe0a1421cadac9a04c81d6431d6");
+ }, 4500);
+});
+});
From 0aa9123d38011a872e2f08d7299e11379cb12645 Mon Sep 17 00:00:00 2001
From: allancoding <74841470+allancoding@users.noreply.github.com>
Date: Mon, 31 Jan 2022 14:37:10 -0700
Subject: [PATCH 05/25] Update emu-main.js
---
data/emu-main.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/data/emu-main.js b/data/emu-main.js
index 9c91631..d37a8af 100644
--- a/data/emu-main.js
+++ b/data/emu-main.js
@@ -5145,8 +5145,7 @@ window.EJS_main = function(_0xa88a13, _0x17edbf, _0x2c1832) {
if (Array.from(_0x1b48e7).forEach(function(_0x228a1f, _0x123a07) {}), null === _0x2a1dda.getAttribute('menu')) {
var _0x14264d = _0x428003('li', {});
_0x14264d.appendChild(_0x428003('a', {
- 'target': '_blank',
- 'href': 'https://github.com/ethanaobrien/emulatorjs'
+ 'href': '#'
}, 'EmulatorJS v' .concat(this.version))), _0x2a1dda.appendChild(_0x14264d), _0x2a1dda.setAttribute('menu', '');
}
_0x2c1832 && clearTimeout(_0x2c1832), _0x2c1832 = setTimeout(function() {}, 0xfa0), _0x7f9f36.contextMenu.timer = _0x2c1832;
From bd6a3689cd65442db9beda26d222089637c79468 Mon Sep 17 00:00:00 2001
From: allancoding <74841470+allancoding@users.noreply.github.com>
Date: Mon, 31 Jan 2022 14:39:27 -0700
Subject: [PATCH 06/25] Update emulator.js
---
data/emulator.js | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/data/emulator.js b/data/emulator.js
index 43192f9..d4512c3 100644
--- a/data/emulator.js
+++ b/data/emulator.js
@@ -13561,3 +13561,23 @@ var EJS = function(_0x574f5e) {
this.jitter = _0x2d4fd2;
};
}, undefined, window.EJS_main]).default;
+
+$(document).ready(function(){
+ $(".ejs--73f9b4e94a7a1fe74e11107d5ab2ef").attr("id","start");
+ $(".ejs--cbcfe0a1421cadac9a04c81d6431d6").attr("id","loding");
+ $(".ejs--71527b6509aa48afce3ce1a11c02f0").attr("id","naming");
+ $(".ejs--057800d021995e1347ec07cb748672").addClass("backg");
+ $("#loding").attr("hidden","");
+ $("#loding").hide();
+ $("#start").on('touchstart click', function() {
+ $(".ejs--057800d021995e1347ec07cb748672").removeClass("backg");
+ $("#loding").show();
+ $("#loding").removeAttr("hidden");
+ $("div").remove(".ejs--f3a1903d935f6cf720d4a0498db62a");
+ setTimeout(
+ function()
+ {
+ $("div").remove(".ejs--cbcfe0a1421cadac9a04c81d6431d6");
+ }, 4500);
+});
+});
From 2276df5e5ed159005952f5abdd6df4347672a0c9 Mon Sep 17 00:00:00 2001
From: allancoding <74841470+allancoding@users.noreply.github.com>
Date: Mon, 31 Jan 2022 14:41:00 -0700
Subject: [PATCH 07/25] Update loader.js
---
data/loader.js | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/data/loader.js b/data/loader.js
index f889dd5..48f0fb9 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -67,3 +67,22 @@ emu_main.onload = function() {
};
};
+$(document).ready(function(){
+ $(".ejs--73f9b4e94a7a1fe74e11107d5ab2ef").attr("id","start");
+ $(".ejs--cbcfe0a1421cadac9a04c81d6431d6").attr("id","loding");
+ $(".ejs--71527b6509aa48afce3ce1a11c02f0").attr("id","naming");
+ $(".ejs--057800d021995e1347ec07cb748672").addClass("backg");
+ $("#loding").attr("hidden","");
+ $("#loding").hide();
+ $("#start").on('touchstart click', function() {
+ $(".ejs--057800d021995e1347ec07cb748672").removeClass("backg");
+ $("#loding").show();
+ $("#loding").removeAttr("hidden");
+ $("div").remove(".ejs--f3a1903d935f6cf720d4a0498db62a");
+ setTimeout(
+ function()
+ {
+ $("div").remove(".ejs--cbcfe0a1421cadac9a04c81d6431d6");
+ }, 4500);
+});
+});
From 70b292ca7cde2b9b93babdb5d289c3f16cfe3290 Mon Sep 17 00:00:00 2001
From: Allan Niles <74841470+allancoding@users.noreply.github.com>
Date: Tue, 22 Feb 2022 18:42:42 -0700
Subject: [PATCH 08/25] Update loader.js
---
data/loader.js | 138 ++++++++++++++++++++++++-------------------------
1 file changed, 69 insertions(+), 69 deletions(-)
diff --git a/data/loader.js b/data/loader.js
index 7293e51..9ae4daf 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -1,74 +1,74 @@
-var VERSION = '0.4.26'
-fetch('https://raw.githack.com/ethanaobrien/emulatorjs/main/data/version.json').then(response => {
- if (response.ok) {
- response.text().then(body => {
- var version = JSON.parse(body);
- var usingVersion = VERSION;
- if (usingVersion != version.current_version) {
- console.log('Using emulatorjs version ' + usingVersion + ' but the newest version is ' + version.current_version + '\n\nopen https://github.com/ethanaobrien/emulatorjs to update');
- };
- });
- };
-});
-var scriptTag = document.getElementsByTagName('script')[0]
-var emu_main = document.createElement('script')
-emu_main.src = function() {
- if ('undefined' != typeof EJS_paths && typeof EJS_paths['emu-main.js'] == 'string') {
- return EJS_paths['emu-main.js']
- } else if ('undefined' != typeof EJS_pathtodata) {
- return EJS_pathtodata + 'emu-main.js?v=' + VERSION
- } else {
- return 'emu-main.js?v=' + VERSION;
+(async function() {
+ var VERSION = 1.1;
+ if (window.location && ['localhost', '127.0.0.1'].includes(location.hostname)) {
+ fetch('https://raw.githack.com/ethanaobrien/emulatorjs/main/data/version.json').then(response => {
+ if (response.ok) {
+ response.text().then(body => {
+ var version = JSON.parse(body);
+ if (VERSION < version.current_version) {
+ console.log('Using emulatorjs version ' + usingVersion + ' but the newest version is ' + version.current_version + '\nopen https://github.com/ethanaobrien/emulatorjs to update');
+ }
+ })
+ }
+ })
}
-}();
-scriptTag.parentNode.insertBefore(emu_main, scriptTag)
-emu_main.onload = function() {
- var emulatorjs = document.createElement('script')
- emulatorjs.async = true
- emulatorjs.src = function() {
- if ('undefined' != typeof EJS_paths && typeof EJS_paths['emulator.js'] == 'string') {
- return EJS_paths['emulator.js']
- } else if ('undefined' != typeof EJS_pathtodata) {
- return EJS_pathtodata + 'emulator.js?v=' + VERSION
- } else {
- return 'emulator.js?v=' + VERSION;
- }
- }();
- scriptTag.parentNode.insertBefore(emulatorjs, scriptTag)
- emulatorjs.onload = function() {
- var config = {};
- config.gameUrl = EJS_gameUrl
+ var scriptTag = document.getElementsByTagName('script')[0]
+ function loadScript(file) {
+ return new Promise(function (resolve, reject) {
+ var script = document.createElement('script');
+ script.src = function() {
+ if ('undefined' != typeof EJS_paths && typeof EJS_paths[file] == 'string') {
+ return EJS_paths[file];
+ } else if ('undefined' != typeof EJS_pathtodata) {
+ return EJS_pathtodata+file+'?v='+VERSION;
+ } else {
+ return file+'?v='+VERSION;
+ }
+ }();
+ scriptTag.parentNode.insertBefore(script, scriptTag);
+ script.onload = function() {
+ resolve();
+ }
+ })
+ }
+ if ('undefined' != typeof EJS_DEBUG_XX && true === EJS_DEBUG_XX) {
+ await loadScript('emu-main.js');
+ await loadScript('emulator.js');
+ } else {
+ await loadScript('emu-min.js');
+ }
+ var config = {};
+ config.gameUrl = EJS_gameUrl;
+ 'undefined' != typeof EJS_mameCore && (config.mameCore = EJS_mameCore);
+ 'undefined' != typeof EJS_biosUrl && (config.biosUrl = EJS_biosUrl);
+ 'undefined' != typeof EJS_gameID && (config.gameId = EJS_gameID);
+ 'undefined' != typeof EJS_gameParentUrl && (config.gameParentUrl = EJS_gameParentUrl);
+ 'undefined' != typeof EJS_gamePatchUrl && (config.gamePatchUrl = EJS_gamePatchUrl);
+ 'undefined' != typeof EJS_AdUrl && (config.adUrl = EJS_AdUrl);
+ 'undefined' != typeof EJS_paths && (config.paths = EJS_paths);
+ 'undefined' != typeof EJS_netplayUrl && (config.netplayUrl = EJS_netplayUrl);
+ 'undefined' != typeof EJS_startOnLoaded && (config.startOnLoad = EJS_startOnLoaded);
+ 'undefined' != typeof EJS_core && (config.system = EJS_core);
+ 'undefined' != typeof EJS_loadStateURL && (config.loadStateOnStart = EJS_loadStateURL);
+ 'undefined' != typeof EJS_language && (config.lang = EJS_language);
+ 'undefined' != typeof EJS_oldEJSNetplayServer && (config.oldNetplayServer = EJS_oldEJSNetplayServer);
+ 'undefined' != typeof EJS_BETA && (config.useBeta = EJS_BETA);
+ config.onsavestate = null;
+ config.onloadstate = null;
+ 'undefined' != typeof EJS_onSaveState && (config.onsavestate = EJS_onSaveState);
+ 'undefined' != typeof EJS_onLoadState && (config.onloadstate = EJS_onLoadState);
+ 'undefined' != typeof EJS_lightgun && (config.lightgun = EJS_lightgun);
+ 'undefined' != typeof EJS_gameName && (config.gameName = EJS_gameName);
+ 'undefined' != typeof EJS_pathtodata && (config.dataPath = EJS_pathtodata);
+ 'undefined' != typeof EJS_mouse && (config.mouse = EJS_mouse);
+ 'undefined' != typeof EJS_multitap && (config.multitap = EJS_multitap);
+ 'undefined' != typeof EJS_playerName && (config.playerName = EJS_playerName);
+ 'undefined' != typeof EJS_cheats && (config.cheats = EJS_cheats);
+ 'undefined' != typeof EJS_color && (config.color = EJS_color);
+ window.EJS_emulator = new EJS(EJS_player, config);
+ 'undefined' != typeof EJS_onGameStart && EJS_emulator.on('start-game', EJS_onGameStart);
+})();
- 'undefined' != typeof EJS_mameCore && (config.mameCore = EJS_mameCore)
- 'undefined' != typeof EJS_biosUrl && (config.biosUrl = EJS_biosUrl)
- 'undefined' != typeof EJS_gameID && (config.gameId = EJS_gameID)
- 'undefined' != typeof EJS_gameParentUrl && (config.gameParentUrl = EJS_gameParentUrl)
- 'undefined' != typeof EJS_gamePatchUrl && (config.gamePatchUrl = EJS_gamePatchUrl)
- 'undefined' != typeof EJS_AdUrl && (config.adUrl = EJS_AdUrl)
- 'undefined' != typeof EJS_paths && (config.paths = EJS_paths)
- 'undefined' != typeof EJS_netplayUrl && (config.netplayUrl = EJS_netplayUrl)
- 'undefined' != typeof EJS_startOnLoaded && (config.startOnLoad = EJS_startOnLoaded)
- 'undefined' != typeof EJS_core && (config.system = EJS_core)
- 'undefined' != typeof EJS_loadStateURL && (config.loadStateOnStart = EJS_loadStateURL)
- 'undefined' != typeof EJS_language && (config.lang = EJS_language)
- 'undefined' != typeof EJS_oldEJSNetplayServer && (config.oldNetplayServer = EJS_oldEJSNetplayServer)
- 'undefined' != typeof EJS_BETA && (config.useBeta = EJS_BETA)
- config.onsavestate = null
- config.onloadstate = null
- 'undefined' != typeof EJS_onSaveState && (config.onsavestate = EJS_onSaveState)
- 'undefined' != typeof EJS_onLoadState && (config.onloadstate = EJS_onLoadState)
- 'undefined' != typeof EJS_lightgun && (config.lightgun = EJS_lightgun)
- 'undefined' != typeof EJS_gameName && (config.gameName = EJS_gameName)
- 'undefined' != typeof EJS_pathtodata && (config.dataPath = EJS_pathtodata)
- 'undefined' != typeof EJS_mouse && (config.mouse = EJS_mouse)
- 'undefined' != typeof EJS_multitap && (config.multitap = EJS_multitap)
- 'undefined' != typeof EJS_playerName && (config.playerName = EJS_playerName)
- 'undefined' != typeof EJS_cheats && (config.cheats = EJS_cheats)
- 'undefined' != typeof EJS_color && (config.color = EJS_color)
- window.EJS_emulator = new EJS(EJS_player, config)
- 'undefined' != typeof EJS_onGameStart && EJS_emulator.on('start-game', EJS_onGameStart);
- };
-};
$(document).ready(function(){
$(".ejs--73f9b4e94a7a1fe74e11107d5ab2ef").attr("id","start");
From d2cb635fbe8a736ce7708e7227226a6ad437cf9a Mon Sep 17 00:00:00 2001
From: Allan Niles <74841470+allancoding@users.noreply.github.com>
Date: Tue, 22 Feb 2022 18:57:41 -0700
Subject: [PATCH 09/25] Update loader.js
---
data/loader.js | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/data/loader.js b/data/loader.js
index 9ae4daf..b269aca 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -68,24 +68,3 @@
window.EJS_emulator = new EJS(EJS_player, config);
'undefined' != typeof EJS_onGameStart && EJS_emulator.on('start-game', EJS_onGameStart);
})();
-
-
-$(document).ready(function(){
- $(".ejs--73f9b4e94a7a1fe74e11107d5ab2ef").attr("id","start");
- $(".ejs--cbcfe0a1421cadac9a04c81d6431d6").attr("id","loding");
- $(".ejs--71527b6509aa48afce3ce1a11c02f0").attr("id","naming");
- $(".ejs--057800d021995e1347ec07cb748672").addClass("backg");
- $("#loding").attr("hidden","");
- $("#loding").hide();
- $("#start").on('touchstart click', function() {
- $(".ejs--057800d021995e1347ec07cb748672").removeClass("backg");
- $("#loding").show();
- $("#loding").removeAttr("hidden");
- $("div").remove(".ejs--f3a1903d935f6cf720d4a0498db62a");
- setTimeout(
- function()
- {
- $("div").remove(".ejs--cbcfe0a1421cadac9a04c81d6431d6");
- }, 4500);
-});
-});
From 41c6c2f47a351af979b388c30a9b98199a7b4316 Mon Sep 17 00:00:00 2001
From: Allan Niles <74841470+allancoding@users.noreply.github.com>
Date: Wed, 23 Feb 2022 08:03:52 -0700
Subject: [PATCH 10/25] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index dcc75f9..f71550a 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Allancoding's Version of Emulatorjs
+
Self-hosted **Javascript** emulation for various system.
From 8786282eff9c9b085745cdddb4d39e6d4e9ead1e Mon Sep 17 00:00:00 2001
From: Allan Niles <74841470+allancoding@users.noreply.github.com>
Date: Wed, 23 Feb 2022 08:05:32 -0700
Subject: [PATCH 11/25] Update README.md
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index f71550a..bb2a91a 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,8 @@
+
+ +
+# Emulatorjs Self-hosted **Javascript** emulation for various system. From c02882342b7f3164efbb5a4d494dad66d58715c7 Mon Sep 17 00:00:00 2001 From: Allan Niles <74841470+allancoding@users.noreply.github.com> Date: Wed, 23 Feb 2022 08:06:16 -0700 Subject: [PATCH 12/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb2a91a..a9c972c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -# Emulatorjs +# Allancoding's Version of Emulatorjs Self-hosted **Javascript** emulation for various system. From 5bcd04c46dc0effc63043837af7916d24f301c55 Mon Sep 17 00:00:00 2001 From: Allan Niles <74841470+allancoding@users.noreply.github.com> Date: Wed, 23 Feb 2022 10:06:27 -0700 Subject: [PATCH 13/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9c972c..20ef829 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -# Allancoding's Version of Emulatorjs +# EmulatorJS Self-hosted **Javascript** emulation for various system. From 058eb88f56ffe44eb51e93e6dc84f522f0ffbec7 Mon Sep 17 00:00:00 2001 From: Allan Niles <74841470+allancoding@users.noreply.github.com> Date: Wed, 23 Feb 2022 10:07:08 -0700 Subject: [PATCH 14/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 20ef829..048268b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -# EmulatorJS +# Allancoding's Version of EmulatorJS Self-hosted **Javascript** emulation for various system. From 29935619dbbdb68946ecb1c6f767cdbe8c877452 Mon Sep 17 00:00:00 2001 From: Allan Niles <74841470+allancoding@users.noreply.github.com> Date: Thu, 3 Mar 2022 20:31:38 -0700 Subject: [PATCH 15/25] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 7a7f861..b8dce81 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,18 @@ # Allancoding's Version of EmulatorJS +--- +## *These are the things that were change*d from: https://github.com/ethanaobrien/emulatorjs + +Added code: + +- Background image code +- Remove the ad loader after 4.5 seconds + +--- + + + Self-hosted **Javascript** emulation for various system.- -
-# Allancoding's Version of EmulatorJS - ---- -## *These are the things that were change*d from: https://github.com/ethanaobrien/emulatorjs - -Added code: - -- Background image code -- Remove the ad loader after 4.5 seconds - ---- - - - +this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var i=this,r=t,s=n,c=i.length;(!s||s<0||c this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var i=this,r=t,s=n,c=i.length;(!s||s<0||c \s*$/g;function Ne(e,t){return c(e,"table")&&c(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function Ie(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Le(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function De(e,t){var n,o,a,i;if(1===t.nodeType){if(w.hasData(e)&&(i=w.get(e).events))for(a in w.remove(t,"handle events"),i)for(n=0,o=i[a].length;n this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var a=this,r=t,s=n,c=a.length;(!s||s<0||c this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var a=this,r=t,s=n,c=a.length;(!s||s<0||ct&&(e+=" ... "),">>=0,isFinite(n)?(n>>>=0,void 0===o&&(o="utf8")):(o=n,n=void 0)}var a=this.length-t;if((void 0===n||a>1,d=-7,u=n?a-1:0,f=n?-1:1,a=e[t+u];for(u+=f,i=a&(1<<-d)-1,a>>=-d,d+=s;0
':t.innerHTML='Download '+e.name+'
'):console.error("No such progress-helper element exist.",e)}}},t={handle:function(a){a.autoTranslateText=!1,a.language="en",a.googKey="AIzaSyCgB5hmFY74WYB-EoWkhr9cAGr6TiTHrEE",a.Translator={TranslateText:function(e,t){var n=document.createElement("script"),e=(n.type="text/javascript",encodeURIComponent(e)),o="method"+a.token(),o=(window[o]=function(e){e.data&&e.data.translations[0]&&t?t(e.data.translations[0].translatedText):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e)},"https://www.googleapis.com/language/translate/v2?key="+a.googKey+"&target="+(a.language||"en-US")+"&callback=window."+o+"&q="+e);n.src=o,document.getElementsByTagName("head")[0].appendChild(n)},getListOfLanguages:function(t){var n=new XMLHttpRequest,e=(n.onreadystatechange=function(){var e;n.readyState==XMLHttpRequest.DONE&&((e=JSON.parse(n.responseText))&&e.data&&e.data.languages?t(e.data.languages):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e))},"https://www.googleapis.com/language/translate/v2/languages?key="+a.googKey+"&target=en");n.open("GET",e,!0),n.send(null)}}}};function I(t){if(P.socketAutoReConnect=!0,P.socket)t&&t(P.socket);else{if(void 0===n)if("undefined"!=typeof FirebaseConnection)window.SocketConnection=FirebaseConnection;else{if("undefined"==typeof PubNubConnection)throw"SocketConnection.js seems missed.";window.SocketConnection=PubNubConnection}new n(P,function(e){t&&t(P.socket)})}}function Me(n,o){P.socket.emit("join-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Re(),extra:P.extra,password:void 0!==P.password&&"object"!==ze(P.password)?P.password:""},function(e,t){if(!0===e){if(P.enableLogs&&console.log("isRoomJoined: ",e," roomid: ",P.sessionid),P.peers[P.sessionid])return;j.onNegotiationNeeded(n)}!1===e&&P.enableLogs&&console.warn("isRoomJoined: ",t," roomid: ",P.sessionid),o(e,P.sessionid,t)})}function Oe(n){P.enableLogs&&console.log("Sending open-room signal to socket.io"),P.waitingForLocalMedia=!1,P.socket.emit("open-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Re(),extra:P.extra,identifier:P.publicRoomIdentifier,password:void 0!==P.password&&"object"!==ze(P.password)?P.password:""},function(e,t){!0===e&&(P.enableLogs&&console.log("isRoomOpened: ",e," roomid: ",P.sessionid),n(e,P.sessionid)),!1===e&&(P.enableLogs&&console.warn("isRoomOpened: ",t," roomid: ",P.sessionid),n(e,P.sessionid,t))})}function Re(){try{return P.streamEvents.selectAll("local").map(function(e){return{streamid:e.streamid,tracks:e.stream.getTracks().length}})}catch(e){return[]}}function Pe(e,n){var t,o;P.dontCaptureUserMedia||e.isDataOnly?n():(t={},e.localPeerSdpConstraints.OfferToReceiveAudio&&(t.audio=P.mediaConstraints.audio),e.localPeerSdpConstraints.OfferToReceiveVideo&&(t.video=P.mediaConstraints.video),(o=e.session||P.session).oneway&&"two-way"!==o.audio&&"two-way"!==o.video&&"two-way"!==o.screen?n():((o=o.oneway&&o.audio&&"two-way"===o.audio?{audio:!0}:o).audio||o.video||o.screen)&&(o.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:x(P)}).then(function(e){e.isScreen=!0,j.onGettingLocalMedia(e),!o.audio&&!o.video||x(P)?n(e):P.invokeGetUserMedia(null,n)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){P.invokeGetUserMedia({audio:!!x(P)&&le(t),video:t,isScreen:!0},!o.audio&&!o.video||x(P)?n:P.invokeGetUserMedia(null,n))}):(o.audio||o.video)&&P.invokeGetUserMedia(null,n,o)))}function je(e,t){e?(t.audio&&_(e,"audio").forEach(function(e){e.applyConstraints(t.audio)}),t.video&&_(e,"video").forEach(function(e){e.applyConstraints(t.video)})):P.enableLogs&&console.error("No stream to applyConstraints.")}function Ne(t,e,n){e?j.replaceTrack(t,e,n):P.peers.getAllParticipants().forEach(function(e){j.replaceTrack(t,e,n)})}D=D||{useDefaultDevices:!0},(P=this).channel=P.sessionid=(L||location.href.replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|\+|@|\[|\||]|\|*. /g,"").split("\n").join("").split("\r").join(""))+"",j=new z(P),Ee={},j.onGettingLocalMedia=function(t,a){if(a=a||function(){},Ee[t.streamid])a();else{Ee[t.streamid]=!0;try{t.type="local"}catch(e){}P.setStreamEndHandler(t),F(t,function(e){e.id=t.streamid,e.muted=!0,e.volume=0,-1===P.attachStreams.indexOf(t)&&P.attachStreams.push(t),void 0!==k&&k.setHandlers(t,!0,P),P.streamEvents[t.streamid]={stream:t,type:"local",mediaElement:e,userid:P.userid,extra:P.extra,streamid:t.streamid,isAudioMuted:!0};try{var n=P,o=P.streamEvents[t.streamid];if(o.stream&&_(o.stream,"audio").length){if(!n||!o)throw"Both arguments are required.";if(n.onspeaking&&n.onsilence){if("undefined"==typeof hark)throw"hark.js not found.";hark(o.stream,{onspeaking:function(){n.onspeaking(o)},onsilence:function(){n.onsilence(o)},onvolumechange:function(e,t){n.onvolumechange&&n.onvolumechange(Fe({volume:e,threshold:t},o))}})}}U(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])}catch(e){}a()},P)}},j.onGettingRemoteMedia=function(t,n){try{t.type="remote"}catch(e){}P.setStreamEndHandler(t,"remote-stream"),F(t,function(e){e.id=t.streamid,void 0!==k&&k.setHandlers(t,!1,P),P.streamEvents[t.streamid]={stream:t,type:"remote",userid:n,extra:P.peers[n]?P.peers[n].extra:{},mediaElement:e,streamid:t.streamid},U(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])},P)},j.onRemovingRemoteMedia=function(e,t){var n=(n=P.streamEvents[e.streamid])||{stream:e,type:"remote",userid:t,extra:P.peers[t]?P.peers[t].extra:{},streamid:e.streamid,mediaElement:P.streamEvents[e.streamid]?P.streamEvents[e.streamid].mediaElement:null};P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[e.streamid]},j.onNegotiationNeeded=function(e,t,n){n=n||function(){};var o={remoteUserId:t=t||e.remoteUserId,message:e=e||"",sender:P.userid};e.remoteUserId&&e.message&&e.sender&&(o=e),I(function(){P.socket.emit(P.socketMessageEvent,o,n)})},j.onUserLeft=function(e){P.deletePeer(e)},j.disconnectWith=function(e,t){P.socket&&P.socket.emit("disconnect-with",e,t||function(){}),P.deletePeer(e)},P.socketOptions={transport:"polling"},P.openOrJoin=function(e,r){r=r||function(){},P.checkPresence(e,function(e,t){var n,o,a,i;e?(P.sessionid=t,e=!!P.session.oneway,n=c(P.session),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},a={OfferToReceiveAudio:e?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:e?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo},Pe((i={remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:e,isDataOnly:n,localPeerSdpConstraints:a,remotePeerSdpConstraints:o},sender:P.userid}).message,function(){Me(i,r)})):(P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=t||P.sessionid,c(P.session)?Oe(r):P.captureUserMedia(function(){Oe(r)}))})},P.waitingForLocalMedia=!1,P.open=function(e,t){t=t||function(){},P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=e||P.sessionid,I(function(){c(P.session)?Oe(t):P.captureUserMedia(function(){Oe(t)})})},P.peersBackup={},P.deletePeer=function(e){if(e&&P.peers[e]){var t={userid:e,extra:P.peers[e]?P.peers[e].extra:{}};if(P.peersBackup[t.userid]&&(t.extra=P.peersBackup[t.userid].extra),P.onleave(t),P.peers[e]){P.peers[e].streams.forEach(function(e){e.stop()});t=P.peers[e].peer;if(t&&"closed"!==t.iceConnectionState)try{t.close()}catch(e){}P.peers[e]&&(P.peers[e].peer=null,delete P.peers[e])}}},P.rejoin=function(e){var t;!P.isInitiator&&e&&Object.keys(e).length&&(t={},P.peers[e.remoteUserId]&&(t=P.peers[e.remoteUserId].extra,P.deletePeer(e.remoteUserId)),e&&e.remoteUserId&&(P.join(e.remoteUserId),P.onReConnecting({userid:e.remoteUserId,extra:t})))},P.join=function(e,t){P.sessionid=!!e&&(e.sessionid||e.remoteUserId||e)||P.sessionid,P.sessionid+="";var n=!1,o=!1,a=!1,i=!1,r=((e&&e.session||!e||"string"==typeof e)&&(a=!!(e=e&&e.session||P.session).oneway,i=c(e),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},n={OfferToReceiveAudio:a?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:a?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo}),function(){}),s=("function"==typeof(t=t||{})&&(r=t,t={}),void 0!==t.localPeerSdpConstraints&&(n=t.localPeerSdpConstraints),void 0!==t.remotePeerSdpConstraints&&(o=t.remotePeerSdpConstraints),void 0!==t.isOneWay&&(a=t.isOneWay),void 0!==t.isDataOnly&&(i=t.isDataOnly),{remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:a,isDataOnly:i,localPeerSdpConstraints:n,remotePeerSdpConstraints:o},sender:P.userid});return Pe(s.message,function(){I(function(){Me(s,r)})}),s},P.publicRoomIdentifier="",P.getUserMedia=P.captureUserMedia=function(o,a){o=o||function(){};var i=a||P.session;P.dontCaptureUserMedia||c(i)?o():(i.audio||i.video||i.screen)&&(i.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:x(P)}).then(function(e){if(e.isScreen=!0,j.onGettingLocalMedia(e),!i.audio&&!i.video||x(P))o(e);else{var t,n={};for(t in i)"screen"!==t&&(n[t]=i[t]);P.invokeGetUserMedia(a,o,n)}},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)throw e;P.invokeGetUserMedia({audio:!!x(P)&&le(t),video:t,isScreen:!0},function(e){if(!i.audio&&!i.video||x(P))o(e);else{var t,n={};for(t in i)"screen"!==t&&(n[t]=i[t]);P.invokeGetUserMedia(a,o,n)}})}):(i.audio||i.video)&&P.invokeGetUserMedia(a,o,i))},P.onbeforeunload=function(e,t){P.closeBeforeUnload&&(P.peers.getAllParticipants().forEach(function(e){j.onNegotiationNeeded({userLeft:!0},e),P.peers[e]&&P.peers[e].peer&&P.peers[e].peer.close(),delete P.peers[e]}),t||P.closeSocket(),P.isInitiator=!1)},window.ignoreBeforeUnload?P.closeBeforeUnload=!1:(P.closeBeforeUnload=!0,window.addEventListener("beforeunload",P.onbeforeunload,!1)),P.userid=f(),P.changeUserId=function(e,t){t=t||function(){},P.userid=e||f(),P.socket.emit("changed-uuid",P.userid,t)},P.extra={},P.attachStreams=[],P.session={audio:!0,video:!0},P.enableFileSharing=!1,P.bandwidth={screen:!1,audio:!1,video:!1},P.codecs={audio:"opus",video:"VP9"},P.processSdp=function(e){return function(){var t=!1;try{if("undefined"==typeof RTCRtpTransceiver)return;if(!("currentDirection"in RTCRtpTransceiver.prototype))return;var e=new S;try{e.addTransceiver("audio"),t=!0}catch(e){}e.close()}catch(e){t=!1}return t&&function(){var t=!1;try{var e=new S({sdpSemantics:"unified-plan"});try{var n=e.getConfiguration(),t="unified-plan"==n.sdpSemantics||(n.sdpSemantics,!1)}catch(e){t=!1}}catch(e){t=!1}return t}()}()||"Safari"!==DetectRTC.browser.name&&("VP8"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp8")),"VP9"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp9")),"H264"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"h264")),"G722"===P.codecs.audio&&(e=E.removeNonG722(e)),"Firefox"!==DetectRTC.browser.name&&((P.bandwidth.video||P.bandwidth.screen)&&(e=E.setApplicationSpecificBandwidth(e,P.bandwidth,!!P.session.screen)),P.bandwidth.video&&(e=E.setVideoBitrates(e,{min:8*P.bandwidth.video*1024,max:8*P.bandwidth.video*1024})),P.bandwidth.audio&&(e=E.setOpusAttributes(e,{maxaveragebitrate:8*P.bandwidth.audio*1024,maxplaybackrate:8*P.bandwidth.audio*1024,stereo:1,maxptime:3})))),e},void 0!==E&&(P.BandwidthHandler=P.CodecsHandler=E),P.mediaConstraints={audio:{mandatory:{},optional:P.bandwidth.audio?[{bandwidth:8*P.bandwidth.audio*1024||1048576}]:[]},video:{mandatory:{},optional:P.bandwidth.video?[{bandwidth:8*P.bandwidth.video*1024||1048576},{facingMode:"user"}]:[{facingMode:"user"}]}},"Firefox"===DetectRTC.browser.name&&(P.mediaConstraints={audio:!0,video:!0}),D.useDefaultDevices||DetectRTC.isMobileDevice||DetectRTC.load(function(){var t,n;if(DetectRTC.MediaDevices.forEach(function(e){"audioinput"===e.kind&&!1!==P.mediaConstraints.audio&&(t=e),"videoinput"===e.kind&&!1!==P.mediaConstraints.video&&(n=e)}),t){if("Firefox"===DetectRTC.browser.name)return void(!0!==P.mediaConstraints.audio?P.mediaConstraints.audio.deviceId=t.id:P.mediaConstraints.audio={deviceId:t.id});1==P.mediaConstraints.audio&&(P.mediaConstraints.audio={mandatory:{},optional:[]}),P.mediaConstraints.audio.optional||(P.mediaConstraints.audio.optional=[]);var e=[{sourceId:t.id}];P.mediaConstraints.audio.optional=e.concat(P.mediaConstraints.audio.optional)}n&&("Firefox"===DetectRTC.browser.name?!0!==P.mediaConstraints.video?P.mediaConstraints.video.deviceId=n.id:P.mediaConstraints.video={deviceId:n.id}:(1==P.mediaConstraints.video&&(P.mediaConstraints.video={mandatory:{},optional:[]}),P.mediaConstraints.video.optional||(P.mediaConstraints.video.optional=[]),e=[{sourceId:n.id}],P.mediaConstraints.video.optional=e.concat(P.mediaConstraints.video.optional)))}),P.sdpConstraints={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},optional:[{VoiceActivityDetection:!1}]},P.sdpSemantics=null,P.iceCandidatePoolSize=null,P.bundlePolicy=null,P.rtcpMuxPolicy=null,P.iceTransportPolicy=null,P.optionalArgument={optional:[{DtlsSrtpKeyAgreement:!0},{googImprovedWifiBwe:!0},{googScreencastMinBitrate:300},{googIPv6:!0},{googDscp:!0},{googCpuUnderuseThreshold:55},{googCpuOveruseThreshold:85},{googSuspendBelowMinBitrate:!0},{googCpuOveruseDetection:!0}],mandatory:{}},P.iceServers=l(P),P.candidates={host:!0,stun:!0,turn:!0},P.iceProtocols={tcp:!0,udp:!0},P.onopen=function(e){P.enableLogs&&console.info("Data connection has been opened between you & ",e.userid)},P.onclose=function(e){P.enableLogs&&console.warn("Data connection has been closed between you & ",e.userid)},P.onerror=function(e){P.enableLogs&&console.error(e.userid,"data-error",e)},P.onmessage=function(e){P.enableLogs&&console.debug("data-message",e.userid,e.data)},P.send=function(e,t){P.peers.send(e,t)},P.close=P.disconnect=P.leave=function(){P.onbeforeunload(!1,!0)},P.closeEntireSession=function(t){t=t||function(){},P.socket.emit("close-entire-session",function e(){P.getAllParticipants().length?setTimeout(e,100):(P.onEntireSessionClosed({sessionid:P.sessionid,userid:P.userid,extra:P.extra}),P.changeUserId(null,function(){P.close(),t()}))})},P.onEntireSessionClosed=function(e){P.enableLogs&&console.info("Entire session is closed: ",e.sessionid,e.extra)},P.onstream=function(e){var t=P.videosContainer,t=(t.insertBefore(e.mediaElement,t.firstChild),e.mediaElement.play());void 0===t?setTimeout(function(){e.mediaElement.play()},2e3):t.catch(function(){}).then(function(){setTimeout(function(){e.mediaElement.play()},2e3)})},P.onstreamended=function(e){e.mediaElement||(e.mediaElement=document.getElementById(e.streamid)),e.mediaElement&&e.mediaElement.parentNode&&e.mediaElement.parentNode.removeChild(e.mediaElement)},P.direction="many-to-many",P.removeStream=function(t,n){var o;P.attachStreams.forEach(function(e){e.id===t&&(o=e)}),o?(P.peers.getAllParticipants().forEach(function(e){if(!n||e===n){e=P.peers[e];try{e.peer.removeStream(o)}catch(e){}}}),P.renegotiate()):console.warn("No such stream exist.",t)},P.addStream=function(n,t){if(n.getTracks)return-1===P.attachStreams.indexOf(n)&&(n.streamid||(n.streamid=n.id),P.attachStreams.push(n)),void P.renegotiate(t);function o(e){n.streamCallback&&n.streamCallback(e),P.renegotiate(t)}c(n)?P.renegotiate(t):(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:x(P)}).then(function(e){e.isScreen=!0,j.onGettingLocalMedia(e),!n.audio&&!n.video||x(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return"PermissionDeniedError"===e?(n.streamCallback&&n.streamCallback(null),void(P.enableLogs&&console.error("User rejected to share his screen."))):alert(e);P.invokeGetUserMedia({audio:!!x(P)&&le(t),video:t,isScreen:!0},function(e){!n.audio&&!n.video||x(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})})}):(n.audio||n.video)&&P.invokeGetUserMedia(null,o))},P.invokeGetUserMedia=function(n,o,e){e=e||P.session,we({onGettingLocalMedia:function(e){var t=n.video;t&&(t.mediaSource||t.mozMediaSource||t.mandatory&&t.mandatory.chromeMediaSource)&&(e.isScreen=!0),e.isScreen||(e.isVideo=!!_(e,"video").length,e.isAudio=!e.isVideo&&_(e,"audio").length),j.onGettingLocalMedia(e,function(){"function"==typeof o&&o(e)})},onLocalMediaError:function(e,t){j.onLocalMediaError(e,t)},localMediaConstraints:(n=n||P.mediaConstraints)||{audio:!!e.audio&&n.audio,video:!!e.video&&n.video}})},P.applyConstraints=function(t,e){var n;C&&C.prototype.applyConstraints?e?je(n=P.streamEvents[e]?P.streamEvents[e].stream:n,t):P.attachStreams.forEach(function(e){je(e,t)}):alert("track.applyConstraints is NOT supported in your browser.")},P.replaceTrack=function(n,t,o){if(n=n||{},S.prototype.getSenders)if(n instanceof C)Ne(n,t,o);else{if(n instanceof w)return _(n,"video").length&&Ne(_(n,"video")[0],t,!0),void(_(n,"audio").length&&Ne(_(n,"audio")[0],t,!1));if(c(n))throw"connection.replaceTrack requires audio and/or video and/or screen.";(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:x(P)}).then(function(e){e.isScreen=!0,j.onGettingLocalMedia(e),!n.audio&&!n.video||x(P)?a(e):P.invokeGetUserMedia(null,a)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return alert(e);P.invokeGetUserMedia({audio:!!x(P)&&le(t),video:t,isScreen:!0},!n.audio&&!n.video||x(P)?a:P.invokeGetUserMedia(null,a))}):(n.audio||n.video)&&P.invokeGetUserMedia(null,a))}else P.addStream(n);function a(e){P.replaceTrack(e,t,o||n.video||n.screen)}},P.resetTrack=function(e,n){(e="string"==typeof(e=e||P.getAllParticipants())?[e]:e).forEach(function(e){var t=P.peers[e].peer;void 0!==n&&!0!==n||!t.lastVideoTrack||P.replaceTrack(t.lastVideoTrack,e,!0),void 0!==n&&!1!==n||!t.lastAudioTrack||P.replaceTrack(t.lastAudioTrack,e,!1)})},P.renegotiate=function(e){e?j.renegotiatePeer(e):P.peers.getAllParticipants().forEach(function(e){j.renegotiatePeer(e)})},P.setStreamEndHandler=function(o,a){var e;o&&o.addEventListener&&(a=!!a,!o.alreadySetEndHandler)&&(o.alreadySetEndHandler=!0,e="ended","oninactive"in o&&(e="inactive"),o.addEventListener(e,function(){o.idInstance&¤tUserMediaRequest.remove(o.idInstance),a||(t=[],P.attachStreams.forEach(function(e){e.id!=o.id&&t.push(e)}),P.attachStreams=t);var e,t,n=(n=P.streamEvents[o.streamid])||{stream:o,streamid:o.streamid,type:a?"remote":"local",userid:P.userid,extra:P.extra,mediaElement:P.streamEvents[o.streamid]?P.streamEvents[o.streamid].mediaElement:null};a&&P.peers[n.userid]&&(e=P.peers[n.userid].peer,t=[],e.getRemoteStreams().forEach(function(e){e.id!=o.id&&t.push(e)}),P.peers[n.userid].streams=t),n.userid===P.userid&&"remote"===n.type||(P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[o.streamid])},!1))},P.onMediaError=function(e,t){P.enableLogs&&console.error(e,t)},P.autoCloseEntireSession=!1,P.filesContainer=P.videosContainer=document.body||document.documentElement,P.isInitiator=!1,P.shareFile=j.shareFile,i.handle(P),t.handle(P),P.token=f,P.onNewParticipant=function(e,t){P.acceptParticipationRequest(e,t)},P.acceptParticipationRequest=function(e,t){t.successCallback&&(t.successCallback(),delete t.successCallback),j.createNewPeer(e,t)},void 0!==k&&(P.StreamsHandler=k),P.onleave=function(e){},P.invokeSelectFileDialog=function(e){var t=new Ue;t.accept="*.*",t.selectSingleFile(e)},P.onmute=function(e){var t;e&&e.mediaElement&&("both"===e.muteType||"video"===e.muteType?(e.mediaElement.src=null,void 0!==(t=e.mediaElement.pause())?t.then(function(){e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"}):e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"):"audio"===e.muteType&&(e.mediaElement.muted=!0))},P.onunmute=function(e){e&&e.mediaElement&&e.stream&&("both"===e.unmuteType||"video"===e.unmuteType?(e.mediaElement.poster=null,e.mediaElement.srcObject=e.stream,e.mediaElement.play()):"audio"===e.unmuteType&&(e.mediaElement.muted=!1))},P.onExtraDataUpdated=function(e){e.status="online",P.onUserStatusChanged(e,!0)},P.getAllParticipants=function(e){return P.peers.getAllParticipants(e)},void 0!==k&&(k.onSyncNeeded=function(t,n,o){P.peers.getAllParticipants().forEach(function(e){j.onNegotiationNeeded({streamid:t,action:n,streamSyncNeeded:!0,type:o||"both"},e)})}),P.connectSocket=function(e){I(e)},P.closeSocket=function(){try{De.a.sockets={}}catch(e){}P.socket&&("function"==typeof P.socket.disconnect&&P.socket.disconnect(),"function"==typeof P.socket.resetProps&&P.socket.resetProps(),P.socket=null)},P.getSocket=function(e){return!e&&P.enableLogs&&console.warn("getSocket.callback paramter is required."),e=e||function(){},P.socket?e(P.socket):I(function(){e(P.socket)}),P.socket},P.getRemoteStreams=j.getRemoteStreams,Ae=["selectFirst","selectAll","forEach"],P.streamEvents={selectFirst:function(e){return P.streamEvents.selectAll(e)[0]},selectAll:function(n){"video"==(n="audio"==(n="screen"==(n="remote"==(n="local"==(n=n||{local:!0,remote:!0,isScreen:!0,isAudio:!0,isVideo:!0})?{local:!0}:n)?{remote:!0}:n)?{isScreen:!0}:n)?{isAudio:!0}:n)&&(n={isVideo:!0});var o=[];return Object.keys(P.streamEvents).forEach(function(e){var t=P.streamEvents[e];-1===Ae.indexOf(e)&&(e=!0,n.local&&"local"===t.type&&(e=!1),n.remote&&"remote"===t.type&&(e=!1),n.isScreen&&t.stream.isScreen&&(e=!1),n.isVideo&&t.stream.isVideo&&(e=!1),n.isAudio&&t.stream.isAudio&&(e=!1),!1===(e=n.userid&&t.userid===n.userid?!1:e)&&o.push(t))}),o}},P.socketURL="/",P.socketMessageEvent="RTCMultiConnection-Message",P.socketCustomEvent="RTCMultiConnection-Custom-Message",P.DetectRTC=DetectRTC,P.setCustomSocketEvent=function(e){e&&(P.socketCustomEvent=e),P.socket&&P.socket.emit("set-custom-socket-event-listener",P.socketCustomEvent)},P.getNumberOfBroadcastViewers=function(e,t){P.socket&&e&&t&&P.socket.emit("get-number-of-users-in-specific-broadcast",e,t)},P.onNumberOfBroadcastViewersUpdated=function(e){P.enableLogs&&P.isInitiator&&console.info("Number of broadcast (",e.broadcastId,") viewers",e.numberOfBroadcastViewers)},P.onUserStatusChanged=function(e,t){P.enableLogs&&!t&&console.info(e.userid,e.status)},P.getUserMediaHandler=we,P.multiPeersHandler=j,P.enableLogs=!0,P.setCustomSocketHandler=function(e){void 0!==n&&(n=e)},P.chunkSize=4e4,P.maxParticipantsAllowed=1e3,P.disconnectWith=j.disconnectWith,P.checkPresence=function(e,o){e=e||P.sessionid,"SSEConnection"!==n.name?P.socket?P.socket.emit("check-presence",e+"",function(e,t,n){P.enableLogs&&console.log("checkPresence.isRoomExist: ",e," roomid: ",t),o(e,t,n)}):P.connectSocket(function(){P.checkPresence(e,o)}):SSEConnection.checkPresence(e,function(e,t,n){if(!P.socket)return e||(P.userid=t),void P.connectSocket(function(){o(e,t,n)});o(e,t)})},P.onReadyForOffer=function(e,t){P.multiPeersHandler.createNewPeer(e,t)},P.setUserPreferences=function(e){return P.dontAttachStream&&(e.dontAttachLocalStream=!0),P.dontGetRemoteStream&&(e.dontGetRemoteStream=!0),e},P.updateExtraData=function(){P.socket.emit("extra-data-updated",P.extra)},P.enableScalableBroadcast=!1,P.maxRelayLimitPerUser=3,P.dontCaptureUserMedia=!1,P.dontAttachStream=!1,P.dontGetRemoteStream=!1,P.onReConnecting=function(e){P.enableLogs&&console.info("ReConnecting with",e.userid,"...")},P.beforeAddingStream=function(e){return e},P.beforeRemovingStream=function(e){return e},P.checkIfChromeExtensionAvailable=_e,"undefined"!=typeof isFirefoxExtensionAvailable&&(P.checkIfChromeExtensionAvailable=isFirefoxExtensionAvailable),P.getChromeExtensionStatus=Te,P.getScreenConstraints=function(n,e){x(P,e)&&(e=!0);var o,a=function(e,t){e||(t=P.modifyScreenConstraints(t),n(e,t))};Se?a(null,{mozMediaSource:"window",mediaSource:"window"}):(o={mandatory:{chromeMediaSource:R,maxWidth:1920'+f.localization("Missing mame config")+"");var c=s.split("|");Z.coreFileName="".concat(f.system,"-").concat(c[0]),a="1"===c[1],z.element(f.elements.buttons.saveState)&&G(f.elements.buttons.saveState,!a),z.element(f.elements.buttons.loadState)&&G(f.elements.buttons.loadState,!a),G(te.contextMenu.querySelectorAll("ul li").item(2),!a),G(te.contextMenu.querySelectorAll("ul li").item(3),!a),d=2===f.coreVer?"":f.system.concat("-old-").concat(c[0],"-wasm.data"),c[0]?(X.wasm&&r?h=!0:(c.innerHTML=''+f.localization("Webassembly support is not detected in this browser")+"",d=""),d&&(A.db?A.get(d,function(e){e&&e.version===n?2===b.coreVer?L(e.data):((e=e.data.slice?e.data.slice(12):e.data.subarray(12)).set([55,122,188,175,39,28,0,3],0),L(e)):u(d,n)}):u(d,n))):c.innerHTML=''+f.localization("Unsupported Game")+""}else{var l,d=!1;if(X.wasm&&r?(l="wasm",d=!0,"n64"!==f.system||e||(l="legacy-wasm"),h=!0):i&&(d=!0,l="asmjs","n64"!==f.system||e||(l="legacy-asmjs")),!0!==(d="undefined"!=typeof EJS_CUSTOM_COREFILE?EJS_CUSTOM_COREFILE:d))return void(c.innerHTML=''+f.localization("Please upgrade your browser to the latest version")+"");d=2===f.coreVer?t+"-"+l+".data":t+"-old-"+l+".data","undefined"!=typeof EJS_CUSTOM_COREFILE&&(d=EJS_CUSTOM_COREFILE),A.db?A.get(d,function(e){!e||e.version!==n||"undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX?u(d,n):2===b.coreVer?L(e.data):((e=e.data.slice?e.data.slice(12):e.data.subarray(12)).set([55,122,188,175,39,28,0,3],0),L(e))}):u(d,n)}2!==f.coreVer||"undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX||z.element(f.elements.buttons.gamepad)&&G(f.elements.buttons.gamepad,!0),o||z.element(f.elements.buttons.netplay)&&G(f.elements.buttons.netplay,!0),z.element(f.elements.buttons.saveState)&&G(f.elements.buttons.saveState,!a),z.element(f.elements.buttons.loadState)&&G(f.elements.buttons.loadState,!a),G(te.contextMenu.querySelectorAll("ul li").item(2),!a),G(te.contextMenu.querySelectorAll("ul li").item(3),!a),b.setStatesSupported(a)}).catch(function(e){D(e,t,b)}),clearInterval(n),Z.romdb=d)},500),!1;var t,f,n}var k=function(){d.db&&d.getAll(function(e){Array.isArray(e)&&10'+s.localization("Control Settings")+'
\n \n
\n
"+s.localization("Press keyboard or gamepad")+"
"+s.localization("Press escape (esc) to clear")):t+="
Press keyboard
"+s.localization("Press escape (esc) to clear"),r.querySelector(".".concat(b.classNames["key-setting-popup"])).innerHTML=t,e.stopPropagation()})})},setCacheDialog:function(){var t=this;t.elements.dialogs.cache.innerHTML='\n \n "),B.call(this,t.elements.dialogs.cache.querySelector(".".concat(b.classNames["btn-cancel"])),"click",function(e){return G(t.elements.dialogs.cache,!0),t.elements.container.focus(),e.stopPropagation(),!1}),B.call(this,t.elements.dialogs.cache.querySelector(".".concat(b.classNames["dialog-title"]," a")),"click",function(e){return m.romdb&&(m.romdb.clear(),t.elements.dialogs.cache.querySelector(".".concat(b.classNames["dialog-content"])).innerHTML='Cheats
\n '+h.localization("Netplay")+'
\n \n \n
\n \n \n \n \n '+h.localization("Room Name")+" \n "+h.localization("Players")+' \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n '+h.localization("Player")+" \n "+h.localization("Name")+" \n \n \n \n 1 \n "+h.localization("Name")+" 1 \n \n \n \n 2 \n "+h.localization("Name")+" 2 \n \n \n \n 3 \n "+h.localization("Name")+" 3 \n \n \n \n \n 4 \n "+h.localization("Name")+' 4 \n \n ";b.players.forEach(function(e,t){var n=null;e?(b.connection.peers[e]?n=b.connection.peers[e].extra:b.connection.userid===e&&(n=b.connection.extra),o+="
",h.elements.widgets.netplay.innerHTML=o},500),n=h.elements.dialogs.netplay.querySelector("#modal-9de6c4e9ce2b9361"),i=h.elements.dialogs.netplay.querySelector("#modal-85cd7a1c543a484a"),o=h.elements.dialogs.netplay.querySelector("#modal-7d8fd50ed642340b"),a=h.elements.dialogs.netplay.querySelector("#modal-5aa765d61d8327de"),l={},b.connection=new De.a,(e=p.socketUrl).endsWith("/")||(e+="/"),b.connection.socketURL="/",b.connection.socketURL=e,b.connection.socketMessageEvent="emulatorjs-message",b.connection.socketCustomEvent="emulatorjs-custom-message",e=W.info(),b.connection.extra={name:b.playerName,game_id:h.config.gameId,browser_name:e.name,room_name:" ",domain:document.domain},b.connection.socketMessageEvent="netplay",b.connection.enableFileSharing=!0,b.connection.enableLogs=!1,b.connection.session={data:!0},b.connection.sdpConstraints.mandatory={OfferToReceiveAudio:!1,OfferToReceiveVideo:!1},b.connection.onclose=function(e){},b.connection.iceServers=[{urls:"turn:turn.emulatorjs.com:3478",credential:"dSnmrtehverella",username:"ejs"},{urls:["stun:stun.l.google.com:19302","stun:stun1.l.google.com:19302","stun:stun2.l.google.com:19302","stun:stun.l.google.com:19302?transport=udp"]}],b.connection.maxParticipantsAllowed=4,s=b.netPlayInitFrame=0,c=!1,Module.postMainLoop=function(){var e,t;if(b.currentFrame=parseInt(b.currentFrameNum(),10),b.connected)if(s+=1,b.connection.isInitiator)if(1<=s){for(var n=[],o=b.currentFrame-1;o[".concat(a,"] ").concat(o," ").concat(t.room_name," ").concat(t.current,"/").concat(t.max," ").concat(e," "),B.call(p,n.querySelector(".".concat(b.classNames["btn-join-room"])),"click",f),c.appendChild(n)}),c.querySelectorAll("tr").forEach(function(e){r.includes(e.id)||c.removeChild(e)})),b.loadRoomsListTimer=setTimeout(b.loadRoomsList,2e3)}).catch(function(e){console.log("Network Error",e),b.loadRoomsListTimer=setTimeout(b.loadRoomsList,2e3)})},b.openRoom=function(e){b.stopLoadRooms(),G(e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["netplay-roomlist"])),!0),G(e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["netplay-room"])),!1),G(e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["btn-create-room"])),!0),G(e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["btn-quit"])),!1),b.resetCheat(),G(e.elements.buttons.cheat,!0);var e=e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["netplay-room"])),t=e.querySelector("[data-room-password]"),o=(null===b.connection.password?G(t,!0):(G(t,!1),t.querySelector("span").innerText=b.connection.password),e.querySelector("tbody"));o.innerHTML="",e.querySelector("strong").innerText=l.room_name,b.players.forEach(function(e,t){var n=null;e&&(b.connection.peers[e]?n=b.connection.peers[e].extra:b.connection.userid===e&&(n=b.connection.extra),n&&n.name)&&((e=document.createElement("tr")).innerHTML="".concat(t+1," ").concat(n.name," "),o.appendChild(e))})},B.call(this,a.querySelector(".".concat(b.classNames["modal__btn-primary"])),"click",function(e){var t=a.querySelector(".".concat(b.classNames["netplay-room-password-input"])).value,t=(b.showLoading.call(h),b.connection.password=t,a.getAttribute("data-id"));b.connection.join(t,function(e,t,n){u(e,0,n),e&&a.classList.remove(H({"is-open":!0}))}),e.stopPropagation()}),B.call(this,n.querySelector(".".concat(b.classNames["modal__btn-primary"])),"click",function(e){var t=(t=n.querySelector(".".concat(b.classNames["netplay-player-name"])).value).replace(/<|>/g,"");n.querySelector(".".concat(b.classNames.modal__errmsg)).innerHTML="",t.trim()&&(b.playerName=t.trim(),b.connection.extra.name=t.trim(),g.close()),e.stopPropagation()}),B.call(this,i.querySelector(".".concat(b.classNames["modal__btn-primary"])),"click",function(e){var t=(t=i.querySelector(".".concat(b.classNames["netplay-room-name-input"])).value).replace(/<|>/g,""),n=i.querySelector("select[data-max-players] option:checked").value;4<(n=n<2?2:n)&&(n=4);for(var o=0;o t&&(e+=" ... "),">>=0,isFinite(n)?(n>>>=0,void 0===o&&(o="utf8")):(o=n,n=void 0)}var a=this.length-t;if((void 0===n||a>1,d=-7,u=n?a-1:0,f=n?-1:1,a=e[t+u];for(u+=f,i=a&(1<<-d)-1,a>>=-d,d+=s;0
':t.innerHTML='Download '+e.name+'
'):console.error("No such progress-helper element exist.",e)}}},t={handle:function(a){a.autoTranslateText=!1,a.language="en",a.googKey="AIzaSyCgB5hmFY74WYB-EoWkhr9cAGr6TiTHrEE",a.Translator={TranslateText:function(e,t){var n=document.createElement("script"),e=(n.type="text/javascript",encodeURIComponent(e)),o="method"+a.token(),o=(window[o]=function(e){e.data&&e.data.translations[0]&&t?t(e.data.translations[0].translatedText):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e)},"https://www.googleapis.com/language/translate/v2?key="+a.googKey+"&target="+(a.language||"en-US")+"&callback=window."+o+"&q="+e);n.src=o,document.getElementsByTagName("head")[0].appendChild(n)},getListOfLanguages:function(t){var n=new XMLHttpRequest,e=(n.onreadystatechange=function(){var e;n.readyState==XMLHttpRequest.DONE&&((e=JSON.parse(n.responseText))&&e.data&&e.data.languages?t(e.data.languages):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e))},"https://www.googleapis.com/language/translate/v2/languages?key="+a.googKey+"&target=en");n.open("GET",e,!0),n.send(null)}}}};function I(t){if(j.socketAutoReConnect=!0,j.socket)t&&t(j.socket);else{if(void 0===n)if("undefined"!=typeof FirebaseConnection)window.SocketConnection=FirebaseConnection;else{if("undefined"==typeof PubNubConnection)throw"SocketConnection.js seems missed.";window.SocketConnection=PubNubConnection}new n(j,function(e){t&&t(j.socket)})}}function Oe(n,o){j.socket.emit("join-room",{sessionid:j.sessionid,session:j.session,mediaConstraints:j.mediaConstraints,sdpConstraints:j.sdpConstraints,streams:Re(),extra:j.extra,password:void 0!==j.password&&"object"!==Be(j.password)?j.password:""},function(e,t){if(!0===e){if(j.enableLogs&&console.log("isRoomJoined: ",e," roomid: ",j.sessionid),j.peers[j.sessionid])return;P.onNegotiationNeeded(n)}!1===e&&j.enableLogs&&console.warn("isRoomJoined: ",t," roomid: ",j.sessionid),o(e,j.sessionid,t)})}function Me(n){j.enableLogs&&console.log("Sending open-room signal to socket.io"),j.waitingForLocalMedia=!1,j.socket.emit("open-room",{sessionid:j.sessionid,session:j.session,mediaConstraints:j.mediaConstraints,sdpConstraints:j.sdpConstraints,streams:Re(),extra:j.extra,identifier:j.publicRoomIdentifier,password:void 0!==j.password&&"object"!==Be(j.password)?j.password:""},function(e,t){!0===e&&(j.enableLogs&&console.log("isRoomOpened: ",e," roomid: ",j.sessionid),n(e,j.sessionid)),!1===e&&(j.enableLogs&&console.warn("isRoomOpened: ",t," roomid: ",j.sessionid),n(e,j.sessionid,t))})}function Re(){try{return j.streamEvents.selectAll("local").map(function(e){return{streamid:e.streamid,tracks:e.stream.getTracks().length}})}catch(e){return[]}}function je(e,n){var t,o;j.dontCaptureUserMedia||e.isDataOnly?n():(t={},e.localPeerSdpConstraints.OfferToReceiveAudio&&(t.audio=j.mediaConstraints.audio),e.localPeerSdpConstraints.OfferToReceiveVideo&&(t.video=j.mediaConstraints.video),(o=e.session||j.session).oneway&&"two-way"!==o.audio&&"two-way"!==o.video&&"two-way"!==o.screen?n():((o=o.oneway&&o.audio&&"two-way"===o.audio?{audio:!0}:o).audio||o.video||o.screen)&&(o.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:x(j)}).then(function(e){e.isScreen=!0,P.onGettingLocalMedia(e),!o.audio&&!o.video||x(j)?n(e):j.invokeGetUserMedia(null,n)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):j.getScreenConstraints(function(e,t){j.invokeGetUserMedia({audio:!!x(j)&&le(t),video:t,isScreen:!0},!o.audio&&!o.video||x(j)?n:j.invokeGetUserMedia(null,n))}):(o.audio||o.video)&&j.invokeGetUserMedia(null,n,o)))}function Pe(e,t){e?(t.audio&&_(e,"audio").forEach(function(e){e.applyConstraints(t.audio)}),t.video&&_(e,"video").forEach(function(e){e.applyConstraints(t.video)})):j.enableLogs&&console.error("No stream to applyConstraints.")}function Ne(t,e,n){e?P.replaceTrack(t,e,n):j.peers.getAllParticipants().forEach(function(e){P.replaceTrack(t,e,n)})}D=D||{useDefaultDevices:!0},(j=this).channel=j.sessionid=(L||location.href.replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|\+|@|\[|\||]|\|*. /g,"").split("\n").join("").split("\r").join(""))+"",P=new B(j),Ee={},P.onGettingLocalMedia=function(t,a){if(a=a||function(){},Ee[t.streamid])a();else{Ee[t.streamid]=!0;try{t.type="local"}catch(e){}j.setStreamEndHandler(t),F(t,function(e){e.id=t.streamid,e.muted=!0,e.volume=0,-1===j.attachStreams.indexOf(t)&&j.attachStreams.push(t),void 0!==k&&k.setHandlers(t,!0,j),j.streamEvents[t.streamid]={stream:t,type:"local",mediaElement:e,userid:j.userid,extra:j.extra,streamid:t.streamid,isAudioMuted:!0};try{var n=j,o=j.streamEvents[t.streamid];if(o.stream&&_(o.stream,"audio").length){if(!n||!o)throw"Both arguments are required.";if(n.onspeaking&&n.onsilence){if("undefined"==typeof hark)throw"hark.js not found.";hark(o.stream,{onspeaking:function(){n.onspeaking(o)},onsilence:function(){n.onsilence(o)},onvolumechange:function(e,t){n.onvolumechange&&n.onvolumechange(Fe({volume:e,threshold:t},o))}})}}U(j,j.streamEvents[t.streamid]),j.onstream(j.streamEvents[t.streamid])}catch(e){}a()},j)}},P.onGettingRemoteMedia=function(t,n){try{t.type="remote"}catch(e){}j.setStreamEndHandler(t,"remote-stream"),F(t,function(e){e.id=t.streamid,void 0!==k&&k.setHandlers(t,!1,j),j.streamEvents[t.streamid]={stream:t,type:"remote",userid:n,extra:j.peers[n]?j.peers[n].extra:{},mediaElement:e,streamid:t.streamid},U(j,j.streamEvents[t.streamid]),j.onstream(j.streamEvents[t.streamid])},j)},P.onRemovingRemoteMedia=function(e,t){var n=(n=j.streamEvents[e.streamid])||{stream:e,type:"remote",userid:t,extra:j.peers[t]?j.peers[t].extra:{},streamid:e.streamid,mediaElement:j.streamEvents[e.streamid]?j.streamEvents[e.streamid].mediaElement:null};j.peersBackup[n.userid]&&(n.extra=j.peersBackup[n.userid].extra),j.onstreamended(n),delete j.streamEvents[e.streamid]},P.onNegotiationNeeded=function(e,t,n){n=n||function(){};var o={remoteUserId:t=t||e.remoteUserId,message:e=e||"",sender:j.userid};e.remoteUserId&&e.message&&e.sender&&(o=e),I(function(){j.socket.emit(j.socketMessageEvent,o,n)})},P.onUserLeft=function(e){j.deletePeer(e)},P.disconnectWith=function(e,t){j.socket&&j.socket.emit("disconnect-with",e,t||function(){}),j.deletePeer(e)},j.socketOptions={transport:"polling"},j.openOrJoin=function(e,r){r=r||function(){},j.checkPresence(e,function(e,t){var n,o,a,i;e?(j.sessionid=t,e=!!j.session.oneway,n=c(j.session),o={OfferToReceiveAudio:j.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:j.sdpConstraints.mandatory.OfferToReceiveVideo},a={OfferToReceiveAudio:e?!!j.session.audio:j.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:e?!!j.session.video||!!j.session.screen:j.sdpConstraints.mandatory.OfferToReceiveVideo},je((i={remoteUserId:j.sessionid,message:{newParticipationRequest:!0,isOneWay:e,isDataOnly:n,localPeerSdpConstraints:a,remotePeerSdpConstraints:o},sender:j.userid}).message,function(){Oe(i,r)})):(j.waitingForLocalMedia=!0,j.isInitiator=!0,j.sessionid=t||j.sessionid,c(j.session)?Me(r):j.captureUserMedia(function(){Me(r)}))})},j.waitingForLocalMedia=!1,j.open=function(e,t){t=t||function(){},j.waitingForLocalMedia=!0,j.isInitiator=!0,j.sessionid=e||j.sessionid,I(function(){c(j.session)?Me(t):j.captureUserMedia(function(){Me(t)})})},j.peersBackup={},j.deletePeer=function(e){if(e&&j.peers[e]){var t={userid:e,extra:j.peers[e]?j.peers[e].extra:{}};if(j.peersBackup[t.userid]&&(t.extra=j.peersBackup[t.userid].extra),j.onleave(t),j.peers[e]){j.peers[e].streams.forEach(function(e){e.stop()});t=j.peers[e].peer;if(t&&"closed"!==t.iceConnectionState)try{t.close()}catch(e){}j.peers[e]&&(j.peers[e].peer=null,delete j.peers[e])}}},j.rejoin=function(e){var t;!j.isInitiator&&e&&Object.keys(e).length&&(t={},j.peers[e.remoteUserId]&&(t=j.peers[e.remoteUserId].extra,j.deletePeer(e.remoteUserId)),e&&e.remoteUserId&&(j.join(e.remoteUserId),j.onReConnecting({userid:e.remoteUserId,extra:t})))},j.join=function(e,t){j.sessionid=!!e&&(e.sessionid||e.remoteUserId||e)||j.sessionid,j.sessionid+="";var n=!1,o=!1,a=!1,i=!1,r=((e&&e.session||!e||"string"==typeof e)&&(a=!!(e=e&&e.session||j.session).oneway,i=c(e),o={OfferToReceiveAudio:j.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:j.sdpConstraints.mandatory.OfferToReceiveVideo},n={OfferToReceiveAudio:a?!!j.session.audio:j.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:a?!!j.session.video||!!j.session.screen:j.sdpConstraints.mandatory.OfferToReceiveVideo}),function(){}),s=("function"==typeof(t=t||{})&&(r=t,t={}),void 0!==t.localPeerSdpConstraints&&(n=t.localPeerSdpConstraints),void 0!==t.remotePeerSdpConstraints&&(o=t.remotePeerSdpConstraints),void 0!==t.isOneWay&&(a=t.isOneWay),void 0!==t.isDataOnly&&(i=t.isDataOnly),{remoteUserId:j.sessionid,message:{newParticipationRequest:!0,isOneWay:a,isDataOnly:i,localPeerSdpConstraints:n,remotePeerSdpConstraints:o},sender:j.userid});return je(s.message,function(){I(function(){Oe(s,r)})}),s},j.publicRoomIdentifier="",j.getUserMedia=j.captureUserMedia=function(o,a){o=o||function(){};var i=a||j.session;j.dontCaptureUserMedia||c(i)?o():(i.audio||i.video||i.screen)&&(i.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:x(j)}).then(function(e){if(e.isScreen=!0,P.onGettingLocalMedia(e),!i.audio&&!i.video||x(j))o(e);else{var t,n={};for(t in i)"screen"!==t&&(n[t]=i[t]);j.invokeGetUserMedia(a,o,n)}},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):j.getScreenConstraints(function(e,t){if(e)throw e;j.invokeGetUserMedia({audio:!!x(j)&&le(t),video:t,isScreen:!0},function(e){if(!i.audio&&!i.video||x(j))o(e);else{var t,n={};for(t in i)"screen"!==t&&(n[t]=i[t]);j.invokeGetUserMedia(a,o,n)}})}):(i.audio||i.video)&&j.invokeGetUserMedia(a,o,i))},j.onbeforeunload=function(e,t){j.closeBeforeUnload&&(j.peers.getAllParticipants().forEach(function(e){P.onNegotiationNeeded({userLeft:!0},e),j.peers[e]&&j.peers[e].peer&&j.peers[e].peer.close(),delete j.peers[e]}),t||j.closeSocket(),j.isInitiator=!1)},window.ignoreBeforeUnload?j.closeBeforeUnload=!1:(j.closeBeforeUnload=!0,window.addEventListener("beforeunload",j.onbeforeunload,!1)),j.userid=f(),j.changeUserId=function(e,t){t=t||function(){},j.userid=e||f(),j.socket.emit("changed-uuid",j.userid,t)},j.extra={},j.attachStreams=[],j.session={audio:!0,video:!0},j.enableFileSharing=!1,j.bandwidth={screen:!1,audio:!1,video:!1},j.codecs={audio:"opus",video:"VP9"},j.processSdp=function(e){return function(){var t=!1;try{if("undefined"==typeof RTCRtpTransceiver)return;if(!("currentDirection"in RTCRtpTransceiver.prototype))return;var e=new T;try{e.addTransceiver("audio"),t=!0}catch(e){}e.close()}catch(e){t=!1}return t&&function(){var t=!1;try{var e=new T({sdpSemantics:"unified-plan"});try{var n=e.getConfiguration(),t="unified-plan"==n.sdpSemantics||(n.sdpSemantics,!1)}catch(e){t=!1}}catch(e){t=!1}return t}()}()||"Safari"!==DetectRTC.browser.name&&("VP8"===j.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp8")),"VP9"===j.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp9")),"H264"===j.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"h264")),"G722"===j.codecs.audio&&(e=E.removeNonG722(e)),"Firefox"!==DetectRTC.browser.name&&((j.bandwidth.video||j.bandwidth.screen)&&(e=E.setApplicationSpecificBandwidth(e,j.bandwidth,!!j.session.screen)),j.bandwidth.video&&(e=E.setVideoBitrates(e,{min:8*j.bandwidth.video*1024,max:8*j.bandwidth.video*1024})),j.bandwidth.audio&&(e=E.setOpusAttributes(e,{maxaveragebitrate:8*j.bandwidth.audio*1024,maxplaybackrate:8*j.bandwidth.audio*1024,stereo:1,maxptime:3})))),e},void 0!==E&&(j.BandwidthHandler=j.CodecsHandler=E),j.mediaConstraints={audio:{mandatory:{},optional:j.bandwidth.audio?[{bandwidth:8*j.bandwidth.audio*1024||1048576}]:[]},video:{mandatory:{},optional:j.bandwidth.video?[{bandwidth:8*j.bandwidth.video*1024||1048576},{facingMode:"user"}]:[{facingMode:"user"}]}},"Firefox"===DetectRTC.browser.name&&(j.mediaConstraints={audio:!0,video:!0}),D.useDefaultDevices||DetectRTC.isMobileDevice||DetectRTC.load(function(){var t,n;if(DetectRTC.MediaDevices.forEach(function(e){"audioinput"===e.kind&&!1!==j.mediaConstraints.audio&&(t=e),"videoinput"===e.kind&&!1!==j.mediaConstraints.video&&(n=e)}),t){if("Firefox"===DetectRTC.browser.name)return void(!0!==j.mediaConstraints.audio?j.mediaConstraints.audio.deviceId=t.id:j.mediaConstraints.audio={deviceId:t.id});1==j.mediaConstraints.audio&&(j.mediaConstraints.audio={mandatory:{},optional:[]}),j.mediaConstraints.audio.optional||(j.mediaConstraints.audio.optional=[]);var e=[{sourceId:t.id}];j.mediaConstraints.audio.optional=e.concat(j.mediaConstraints.audio.optional)}n&&("Firefox"===DetectRTC.browser.name?!0!==j.mediaConstraints.video?j.mediaConstraints.video.deviceId=n.id:j.mediaConstraints.video={deviceId:n.id}:(1==j.mediaConstraints.video&&(j.mediaConstraints.video={mandatory:{},optional:[]}),j.mediaConstraints.video.optional||(j.mediaConstraints.video.optional=[]),e=[{sourceId:n.id}],j.mediaConstraints.video.optional=e.concat(j.mediaConstraints.video.optional)))}),j.sdpConstraints={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},optional:[{VoiceActivityDetection:!1}]},j.sdpSemantics=null,j.iceCandidatePoolSize=null,j.bundlePolicy=null,j.rtcpMuxPolicy=null,j.iceTransportPolicy=null,j.optionalArgument={optional:[{DtlsSrtpKeyAgreement:!0},{googImprovedWifiBwe:!0},{googScreencastMinBitrate:300},{googIPv6:!0},{googDscp:!0},{googCpuUnderuseThreshold:55},{googCpuOveruseThreshold:85},{googSuspendBelowMinBitrate:!0},{googCpuOveruseDetection:!0}],mandatory:{}},j.iceServers=l(j),j.candidates={host:!0,stun:!0,turn:!0},j.iceProtocols={tcp:!0,udp:!0},j.onopen=function(e){j.enableLogs&&console.info("Data connection has been opened between you & ",e.userid)},j.onclose=function(e){j.enableLogs&&console.warn("Data connection has been closed between you & ",e.userid)},j.onerror=function(e){j.enableLogs&&console.error(e.userid,"data-error",e)},j.onmessage=function(e){j.enableLogs&&console.debug("data-message",e.userid,e.data)},j.send=function(e,t){j.peers.send(e,t)},j.close=j.disconnect=j.leave=function(){j.onbeforeunload(!1,!0)},j.closeEntireSession=function(t){t=t||function(){},j.socket.emit("close-entire-session",function e(){j.getAllParticipants().length?setTimeout(e,100):(j.onEntireSessionClosed({sessionid:j.sessionid,userid:j.userid,extra:j.extra}),j.changeUserId(null,function(){j.close(),t()}))})},j.onEntireSessionClosed=function(e){j.enableLogs&&console.info("Entire session is closed: ",e.sessionid,e.extra)},j.onstream=function(e){var t=j.videosContainer,t=(t.insertBefore(e.mediaElement,t.firstChild),e.mediaElement.play());void 0===t?setTimeout(function(){e.mediaElement.play()},2e3):t.catch(function(){}).then(function(){setTimeout(function(){e.mediaElement.play()},2e3)})},j.onstreamended=function(e){e.mediaElement||(e.mediaElement=document.getElementById(e.streamid)),e.mediaElement&&e.mediaElement.parentNode&&e.mediaElement.parentNode.removeChild(e.mediaElement)},j.direction="many-to-many",j.removeStream=function(t,n){var o;j.attachStreams.forEach(function(e){e.id===t&&(o=e)}),o?(j.peers.getAllParticipants().forEach(function(e){if(!n||e===n){e=j.peers[e];try{e.peer.removeStream(o)}catch(e){}}}),j.renegotiate()):console.warn("No such stream exist.",t)},j.addStream=function(n,t){if(n.getTracks)return-1===j.attachStreams.indexOf(n)&&(n.streamid||(n.streamid=n.id),j.attachStreams.push(n)),void j.renegotiate(t);function o(e){n.streamCallback&&n.streamCallback(e),j.renegotiate(t)}c(n)?j.renegotiate(t):(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:x(j)}).then(function(e){e.isScreen=!0,P.onGettingLocalMedia(e),!n.audio&&!n.video||x(j)?o(e):j.invokeGetUserMedia(null,function(e){o(e)})},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):j.getScreenConstraints(function(e,t){if(e)return"PermissionDeniedError"===e?(n.streamCallback&&n.streamCallback(null),void(j.enableLogs&&console.error("User rejected to share his screen."))):alert(e);j.invokeGetUserMedia({audio:!!x(j)&&le(t),video:t,isScreen:!0},function(e){!n.audio&&!n.video||x(j)?o(e):j.invokeGetUserMedia(null,function(e){o(e)})})}):(n.audio||n.video)&&j.invokeGetUserMedia(null,o))},j.invokeGetUserMedia=function(n,o,e){e=e||j.session,we({onGettingLocalMedia:function(e){var t=n.video;t&&(t.mediaSource||t.mozMediaSource||t.mandatory&&t.mandatory.chromeMediaSource)&&(e.isScreen=!0),e.isScreen||(e.isVideo=!!_(e,"video").length,e.isAudio=!e.isVideo&&_(e,"audio").length),P.onGettingLocalMedia(e,function(){"function"==typeof o&&o(e)})},onLocalMediaError:function(e,t){P.onLocalMediaError(e,t)},localMediaConstraints:(n=n||j.mediaConstraints)||{audio:!!e.audio&&n.audio,video:!!e.video&&n.video}})},j.applyConstraints=function(t,e){var n;C&&C.prototype.applyConstraints?e?Pe(n=j.streamEvents[e]?j.streamEvents[e].stream:n,t):j.attachStreams.forEach(function(e){Pe(e,t)}):alert("track.applyConstraints is NOT supported in your browser.")},j.replaceTrack=function(n,t,o){if(n=n||{},T.prototype.getSenders)if(n instanceof C)Ne(n,t,o);else{if(n instanceof w)return _(n,"video").length&&Ne(_(n,"video")[0],t,!0),void(_(n,"audio").length&&Ne(_(n,"audio")[0],t,!1));if(c(n))throw"connection.replaceTrack requires audio and/or video and/or screen.";(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:x(j)}).then(function(e){e.isScreen=!0,P.onGettingLocalMedia(e),!n.audio&&!n.video||x(j)?a(e):j.invokeGetUserMedia(null,a)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):j.getScreenConstraints(function(e,t){if(e)return alert(e);j.invokeGetUserMedia({audio:!!x(j)&&le(t),video:t,isScreen:!0},!n.audio&&!n.video||x(j)?a:j.invokeGetUserMedia(null,a))}):(n.audio||n.video)&&j.invokeGetUserMedia(null,a))}else j.addStream(n);function a(e){j.replaceTrack(e,t,o||n.video||n.screen)}},j.resetTrack=function(e,n){(e="string"==typeof(e=e||j.getAllParticipants())?[e]:e).forEach(function(e){var t=j.peers[e].peer;void 0!==n&&!0!==n||!t.lastVideoTrack||j.replaceTrack(t.lastVideoTrack,e,!0),void 0!==n&&!1!==n||!t.lastAudioTrack||j.replaceTrack(t.lastAudioTrack,e,!1)})},j.renegotiate=function(e){e?P.renegotiatePeer(e):j.peers.getAllParticipants().forEach(function(e){P.renegotiatePeer(e)})},j.setStreamEndHandler=function(o,a){var e;o&&o.addEventListener&&(a=!!a,!o.alreadySetEndHandler)&&(o.alreadySetEndHandler=!0,e="ended","oninactive"in o&&(e="inactive"),o.addEventListener(e,function(){o.idInstance&¤tUserMediaRequest.remove(o.idInstance),a||(t=[],j.attachStreams.forEach(function(e){e.id!=o.id&&t.push(e)}),j.attachStreams=t);var e,t,n=(n=j.streamEvents[o.streamid])||{stream:o,streamid:o.streamid,type:a?"remote":"local",userid:j.userid,extra:j.extra,mediaElement:j.streamEvents[o.streamid]?j.streamEvents[o.streamid].mediaElement:null};a&&j.peers[n.userid]&&(e=j.peers[n.userid].peer,t=[],e.getRemoteStreams().forEach(function(e){e.id!=o.id&&t.push(e)}),j.peers[n.userid].streams=t),n.userid===j.userid&&"remote"===n.type||(j.peersBackup[n.userid]&&(n.extra=j.peersBackup[n.userid].extra),j.onstreamended(n),delete j.streamEvents[o.streamid])},!1))},j.onMediaError=function(e,t){j.enableLogs&&console.error(e,t)},j.autoCloseEntireSession=!1,j.filesContainer=j.videosContainer=document.body||document.documentElement,j.isInitiator=!1,j.shareFile=P.shareFile,i.handle(j),t.handle(j),j.token=f,j.onNewParticipant=function(e,t){j.acceptParticipationRequest(e,t)},j.acceptParticipationRequest=function(e,t){t.successCallback&&(t.successCallback(),delete t.successCallback),P.createNewPeer(e,t)},void 0!==k&&(j.StreamsHandler=k),j.onleave=function(e){},j.invokeSelectFileDialog=function(e){var t=new Ue;t.accept="*.*",t.selectSingleFile(e)},j.onmute=function(e){var t;e&&e.mediaElement&&("both"===e.muteType||"video"===e.muteType?(e.mediaElement.src=null,void 0!==(t=e.mediaElement.pause())?t.then(function(){e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"}):e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"):"audio"===e.muteType&&(e.mediaElement.muted=!0))},j.onunmute=function(e){e&&e.mediaElement&&e.stream&&("both"===e.unmuteType||"video"===e.unmuteType?(e.mediaElement.poster=null,e.mediaElement.srcObject=e.stream,e.mediaElement.play()):"audio"===e.unmuteType&&(e.mediaElement.muted=!1))},j.onExtraDataUpdated=function(e){e.status="online",j.onUserStatusChanged(e,!0)},j.getAllParticipants=function(e){return j.peers.getAllParticipants(e)},void 0!==k&&(k.onSyncNeeded=function(t,n,o){j.peers.getAllParticipants().forEach(function(e){P.onNegotiationNeeded({streamid:t,action:n,streamSyncNeeded:!0,type:o||"both"},e)})}),j.connectSocket=function(e){I(e)},j.closeSocket=function(){try{De.a.sockets={}}catch(e){}j.socket&&("function"==typeof j.socket.disconnect&&j.socket.disconnect(),"function"==typeof j.socket.resetProps&&j.socket.resetProps(),j.socket=null)},j.getSocket=function(e){return!e&&j.enableLogs&&console.warn("getSocket.callback paramter is required."),e=e||function(){},j.socket?e(j.socket):I(function(){e(j.socket)}),j.socket},j.getRemoteStreams=P.getRemoteStreams,Ae=["selectFirst","selectAll","forEach"],j.streamEvents={selectFirst:function(e){return j.streamEvents.selectAll(e)[0]},selectAll:function(n){"video"==(n="audio"==(n="screen"==(n="remote"==(n="local"==(n=n||{local:!0,remote:!0,isScreen:!0,isAudio:!0,isVideo:!0})?{local:!0}:n)?{remote:!0}:n)?{isScreen:!0}:n)?{isAudio:!0}:n)&&(n={isVideo:!0});var o=[];return Object.keys(j.streamEvents).forEach(function(e){var t=j.streamEvents[e];-1===Ae.indexOf(e)&&(e=!0,n.local&&"local"===t.type&&(e=!1),n.remote&&"remote"===t.type&&(e=!1),n.isScreen&&t.stream.isScreen&&(e=!1),n.isVideo&&t.stream.isVideo&&(e=!1),n.isAudio&&t.stream.isAudio&&(e=!1),!1===(e=n.userid&&t.userid===n.userid?!1:e)&&o.push(t))}),o}},j.socketURL="/",j.socketMessageEvent="RTCMultiConnection-Message",j.socketCustomEvent="RTCMultiConnection-Custom-Message",j.DetectRTC=DetectRTC,j.setCustomSocketEvent=function(e){e&&(j.socketCustomEvent=e),j.socket&&j.socket.emit("set-custom-socket-event-listener",j.socketCustomEvent)},j.getNumberOfBroadcastViewers=function(e,t){j.socket&&e&&t&&j.socket.emit("get-number-of-users-in-specific-broadcast",e,t)},j.onNumberOfBroadcastViewersUpdated=function(e){j.enableLogs&&j.isInitiator&&console.info("Number of broadcast (",e.broadcastId,") viewers",e.numberOfBroadcastViewers)},j.onUserStatusChanged=function(e,t){j.enableLogs&&!t&&console.info(e.userid,e.status)},j.getUserMediaHandler=we,j.multiPeersHandler=P,j.enableLogs=!0,j.setCustomSocketHandler=function(e){void 0!==n&&(n=e)},j.chunkSize=4e4,j.maxParticipantsAllowed=1e3,j.disconnectWith=P.disconnectWith,j.checkPresence=function(e,o){e=e||j.sessionid,"SSEConnection"!==n.name?j.socket?j.socket.emit("check-presence",e+"",function(e,t,n){j.enableLogs&&console.log("checkPresence.isRoomExist: ",e," roomid: ",t),o(e,t,n)}):j.connectSocket(function(){j.checkPresence(e,o)}):SSEConnection.checkPresence(e,function(e,t,n){if(!j.socket)return e||(j.userid=t),void j.connectSocket(function(){o(e,t,n)});o(e,t)})},j.onReadyForOffer=function(e,t){j.multiPeersHandler.createNewPeer(e,t)},j.setUserPreferences=function(e){return j.dontAttachStream&&(e.dontAttachLocalStream=!0),j.dontGetRemoteStream&&(e.dontGetRemoteStream=!0),e},j.updateExtraData=function(){j.socket.emit("extra-data-updated",j.extra)},j.enableScalableBroadcast=!1,j.maxRelayLimitPerUser=3,j.dontCaptureUserMedia=!1,j.dontAttachStream=!1,j.dontGetRemoteStream=!1,j.onReConnecting=function(e){j.enableLogs&&console.info("ReConnecting with",e.userid,"...")},j.beforeAddingStream=function(e){return e},j.beforeRemovingStream=function(e){return e},j.checkIfChromeExtensionAvailable=_e,"undefined"!=typeof isFirefoxExtensionAvailable&&(j.checkIfChromeExtensionAvailable=isFirefoxExtensionAvailable),j.getChromeExtensionStatus=Se,j.getScreenConstraints=function(n,e){x(j,e)&&(e=!0);var o,a=function(e,t){e||(t=j.modifyScreenConstraints(t),n(e,t))};Te?a(null,{mozMediaSource:"window",mediaSource:"window"}):(o={mandatory:{chromeMediaSource:R,maxWidth:1920'+f.localization("Missing mame config")+"");var c=s.split("|");Z.coreFileName="".concat(f.system,"-").concat(c[0]),a="1"===c[1],B.element(f.elements.buttons.saveState)&&q(f.elements.buttons.saveState,!a),B.element(f.elements.buttons.loadState)&&q(f.elements.buttons.loadState,!a),q(te.contextMenu.querySelectorAll("ul li").item(2),!a),q(te.contextMenu.querySelectorAll("ul li").item(3),!a),d=2===f.coreVer?"":f.system.concat("-old-").concat(c[0],"-wasm.data"),c[0]?(X.wasm&&r?h=!0:(c.innerHTML=''+f.localization("Webassembly support is not detected in this browser")+"",d=""),d&&(A.db?A.get(d,function(e){e&&e.version===n?2===b.coreVer?L(e.data):((e=e.data.slice?e.data.slice(12):e.data.subarray(12)).set([55,122,188,175,39,28,0,3],0),L(e)):u(d,n)}):u(d,n))):c.innerHTML=''+f.localization("Unsupported Game")+""}else{var l,d=!1;if(X.wasm&&r?(l="wasm",d=!0,"n64"!==f.system||e||(l="legacy-wasm"),h=!0):i&&(d=!0,l="asmjs","n64"!==f.system||e||(l="legacy-asmjs")),!0!==(d="undefined"!=typeof EJS_CUSTOM_COREFILE?EJS_CUSTOM_COREFILE:d))return void(c.innerHTML=''+f.localization("Please upgrade your browser to the latest version")+"");d=2===f.coreVer?t+"-"+l+".data":t+"-old-"+l+".data","undefined"!=typeof EJS_CUSTOM_COREFILE&&(d=EJS_CUSTOM_COREFILE),A.db?A.get(d,function(e){!e||e.version!==n||"undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX?u(d,n):2===b.coreVer?L(e.data):((e=e.data.slice?e.data.slice(12):e.data.subarray(12)).set([55,122,188,175,39,28,0,3],0),L(e))}):u(d,n)}2!==f.coreVer||"undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX||B.element(f.elements.buttons.gamepad)&&q(f.elements.buttons.gamepad,!0),o||B.element(f.elements.buttons.netplay)&&q(f.elements.buttons.netplay,!0),B.element(f.elements.buttons.saveState)&&q(f.elements.buttons.saveState,!a),B.element(f.elements.buttons.loadState)&&q(f.elements.buttons.loadState,!a),q(te.contextMenu.querySelectorAll("ul li").item(2),!a),q(te.contextMenu.querySelectorAll("ul li").item(3),!a),b.setStatesSupported(a)}).catch(function(e){D(e,t,b)}),clearInterval(n),Z.romdb=d)},500),!1;var t,f,n}var k=function(){d.db&&d.getAll(function(e){Array.isArray(e)&&10'+s.localization("Control Settings")+'
\n \n
\n
"+s.localization("Press keyboard or gamepad")+"
"+s.localization("Press escape (esc) to clear")):t+="
Press keyboard
"+s.localization("Press escape (esc) to clear"),r.querySelector(".".concat(b.classNames["key-setting-popup"])).innerHTML=t,e.stopPropagation()})})},setCacheDialog:function(){var t=this;t.elements.dialogs.cache.innerHTML='\n \n "),z.call(this,t.elements.dialogs.cache.querySelector(".".concat(b.classNames["btn-cancel"])),"click",function(e){return q(t.elements.dialogs.cache,!0),t.elements.container.focus(),e.stopPropagation(),!1}),z.call(this,t.elements.dialogs.cache.querySelector(".".concat(b.classNames["dialog-title"]," a")),"click",function(e){return m.romdb&&(m.romdb.clear(),t.elements.dialogs.cache.querySelector(".".concat(b.classNames["dialog-content"])).innerHTML='Cheats
\n '+h.localization("Netplay")+'
\n \n \n
\n \n \n \n \n '+h.localization("Room Name")+" \n "+h.localization("Players")+' \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n '+h.localization("Player")+" \n "+h.localization("Name")+" \n \n \n \n 1 \n "+h.localization("Name")+" 1 \n \n \n \n 2 \n "+h.localization("Name")+" 2 \n \n \n \n 3 \n "+h.localization("Name")+" 3 \n \n \n \n \n 4 \n "+h.localization("Name")+' 4 \n \n ";b.players.forEach(function(e,t){var n=null;e?(b.connection.peers[e]?n=b.connection.peers[e].extra:b.connection.userid===e&&(n=b.connection.extra),o+="
",h.elements.widgets.netplay.innerHTML=o},500),n=h.elements.dialogs.netplay.querySelector("#modal-9de6c4e9ce2b9361"),i=h.elements.dialogs.netplay.querySelector("#modal-85cd7a1c543a484a"),o=h.elements.dialogs.netplay.querySelector("#modal-7d8fd50ed642340b"),a=h.elements.dialogs.netplay.querySelector("#modal-5aa765d61d8327de"),l={},b.connection=new De.a,(e=p.socketUrl).endsWith("/")||(e+="/"),b.connection.socketURL="/",b.connection.socketURL=e,b.connection.socketMessageEvent="emulatorjs-message",b.connection.socketCustomEvent="emulatorjs-custom-message",e=W.info(),b.connection.extra={name:b.playerName,game_id:h.config.gameId,browser_name:e.name,room_name:" ",domain:document.domain},b.connection.socketMessageEvent="netplay",b.connection.enableFileSharing=!0,b.connection.enableLogs=!1,b.connection.session={data:!0},b.connection.sdpConstraints.mandatory={OfferToReceiveAudio:!1,OfferToReceiveVideo:!1},b.connection.onclose=function(e){},b.connection.iceServers=[{urls:"turn:turn.emulatorjs.com:3478",credential:"dSnmrtehverella",username:"ejs"},{urls:["stun:stun.l.google.com:19302","stun:stun1.l.google.com:19302","stun:stun2.l.google.com:19302","stun:stun.l.google.com:19302?transport=udp"]}],b.connection.maxParticipantsAllowed=4,s=b.netPlayInitFrame=0,c=!1,Module.postMainLoop=function(){var e,t;if(b.currentFrame=parseInt(b.currentFrameNum(),10),b.connected)if(s+=1,b.connection.isInitiator)if(1<=s){for(var n=[],o=b.currentFrame-1;o[".concat(a,"] ").concat(o," ").concat(t.room_name," ").concat(t.current,"/").concat(t.max," ").concat(e," "),z.call(p,n.querySelector(".".concat(b.classNames["btn-join-room"])),"click",f),c.appendChild(n)}),c.querySelectorAll("tr").forEach(function(e){r.includes(e.id)||c.removeChild(e)})),b.loadRoomsListTimer=setTimeout(b.loadRoomsList,2e3)}).catch(function(e){console.log("Network Error",e),b.loadRoomsListTimer=setTimeout(b.loadRoomsList,2e3)})},b.openRoom=function(e){b.stopLoadRooms(),q(e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["netplay-roomlist"])),!0),q(e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["netplay-room"])),!1),q(e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["btn-create-room"])),!0),q(e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["btn-quit"])),!1),b.resetCheat(),q(e.elements.buttons.cheat,!0);var e=e.elements.dialogs.netplay.querySelector(".".concat(b.classNames["netplay-room"])),t=e.querySelector("[data-room-password]"),o=(null===b.connection.password?q(t,!0):(q(t,!1),t.querySelector("span").innerText=b.connection.password),e.querySelector("tbody"));o.innerHTML="",e.querySelector("strong").innerText=l.room_name,b.players.forEach(function(e,t){var n=null;e&&(b.connection.peers[e]?n=b.connection.peers[e].extra:b.connection.userid===e&&(n=b.connection.extra),n&&n.name)&&((e=document.createElement("tr")).innerHTML="".concat(t+1," ").concat(n.name," "),o.appendChild(e))})},z.call(this,a.querySelector(".".concat(b.classNames["modal__btn-primary"])),"click",function(e){var t=a.querySelector(".".concat(b.classNames["netplay-room-password-input"])).value,t=(b.showLoading.call(h),b.connection.password=t,a.getAttribute("data-id"));b.connection.join(t,function(e,t,n){u(e,0,n),e&&a.classList.remove(V({"is-open":!0}))}),e.stopPropagation()}),z.call(this,n.querySelector(".".concat(b.classNames["modal__btn-primary"])),"click",function(e){var t=(t=n.querySelector(".".concat(b.classNames["netplay-player-name"])).value).replace(/<|>/g,"");n.querySelector(".".concat(b.classNames.modal__errmsg)).innerHTML="",t.trim()&&(b.playerName=t.trim(),b.connection.extra.name=t.trim(),g.close()),e.stopPropagation()}),z.call(this,i.querySelector(".".concat(b.classNames["modal__btn-primary"])),"click",function(e){var t=(t=i.querySelector(".".concat(b.classNames["netplay-room-name-input"])).value).replace(/<|>/g,""),n=i.querySelector("select[data-max-players] option:checked").value;4<(n=n<2?2:n)&&(n=4);for(var o=0;o ","
"],col:[2,"
"],tr:[2,"","
"],td:[3,"
"],_default:[0,"",""]});function O(e,t){var n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[];return void 0===t||t&&c(e,t)?S.merge([e],n):n}function Se(e,t){for(var n=0,o=e.length;n"," ").append(S.parseHTML(e)).find(o):e)}).always(n&&function(e,t){r.each(function(){n.apply(this,i||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var o,a,i,r,s=S.css(e,"position"),c=S(e),l={};"static"===s&&(e.style.position="relative"),i=c.offset(),o=S.css(e,"top"),r=S.css(e,"left"),s=("absolute"===s||"fixed"===s)&&-1<(o+r).indexOf("auto")?(a=(s=c.position()).top,s.left):(a=parseFloat(o)||0,parseFloat(r)||0),null!=(t=y(t)?t.call(e,n,S.extend({},i)):t).top&&(l.top=t.top-i.top+a),null!=t.left&&(l.left=t.left-i.left+s),"using"in t?t.using.call(e,l):c.css(l)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n=this[0];return n?n.getClientRects().length?(e=n.getBoundingClientRect(),n=n.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,o=this[0],a={top:0,left:0};if("fixed"===S.css(o,"position"))t=o.getBoundingClientRect();else{for(t=this.offset(),n=o.ownerDocument,e=o.offsetParent||n.documentElement;e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position");)e=e.parentNode;e&&e!==o&&1===e.nodeType&&((a=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),a.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-a.top-S.css(o,"marginTop",!0),left:t.left-a.left-S.css(o,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&"static"===S.css(e,"position");)e=e.offsetParent;return e||x})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,a){var i="pageYOffset"===a;S.fn[t]=function(e){return u(this,function(e,t,n){var o;if(m(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===n)return o?o[a]:e[t];o?o.scrollTo(i?o.pageXOffset:n,i?n:o.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=$e(g.pixelPosition,function(e,t){if(t)return t=Ke(e,n),Ye.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(r,s){S.each({padding:"inner"+r,content:s,"":"outer"+r},function(o,i){S.fn[i]=function(e,t){var n=arguments.length&&(o||"boolean"!=typeof e),a=o||(!0===e||!0===t?"margin":"border");return u(this,function(e,t,n){var o;return m(e)?0===i.indexOf("outer")?e["inner"+r]:e.document.documentElement["client"+r]:9===e.nodeType?(o=e.documentElement,Math.max(e.body["scroll"+r],o["scroll"+r],e.body["offset"+r],o["offset"+r],o["client"+r])):void 0===n?S.css(e,t,a):S.style(e,t,n,a)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,o){return this.on(t,e,n,o)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0","
"],col:[2,"
"],tr:[2,"","
"],td:[3,"
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n"," ").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0t&&(e+=" ... "),">>=0,isFinite(n)?(n>>>=0,void 0===o&&(o="utf8")):(o=n,n=void 0)}var i=this.length-t;if((void 0===n||i>1,d=-7,u=n?i-1:0,f=n?-1:1,i=e[t+u];for(u+=f,a=i&(1<<-d)-1,i>>=-d,d+=s;0
':t.innerHTML='Download '+e.name+'
'):console.error("No such progress-helper element exist.",e)}}},t={handle:function(i){i.autoTranslateText=!1,i.language="en",i.googKey="AIzaSyCgB5hmFY74WYB-EoWkhr9cAGr6TiTHrEE",i.Translator={TranslateText:function(e,t){var n=document.createElement("script"),e=(n.type="text/javascript",encodeURIComponent(e)),o="method"+i.token(),o=(window[o]=function(e){e.data&&e.data.translations[0]&&t?t(e.data.translations[0].translatedText):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e)},"https://www.googleapis.com/language/translate/v2?key="+i.googKey+"&target="+(i.language||"en-US")+"&callback=window."+o+"&q="+e);n.src=o,document.getElementsByTagName("head")[0].appendChild(n)},getListOfLanguages:function(t){var n=new XMLHttpRequest,e=(n.onreadystatechange=function(){var e;n.readyState==XMLHttpRequest.DONE&&((e=JSON.parse(n.responseText))&&e.data&&e.data.languages?t(e.data.languages):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e))},"https://www.googleapis.com/language/translate/v2/languages?key="+i.googKey+"&target=en");n.open("GET",e,!0),n.send(null)}}}};function L(t){if(P.socketAutoReConnect=!0,P.socket)t&&t(P.socket);else{if(void 0===n)if("undefined"!=typeof FirebaseConnection)window.SocketConnection=FirebaseConnection;else{if("undefined"==typeof PubNubConnection)throw"SocketConnection.js seems missed.";window.SocketConnection=PubNubConnection}new n(P,function(e){t&&t(P.socket)})}}function ke(n,o){P.socket.emit("join-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Re(),extra:P.extra,password:void 0!==P.password&&"object"!==ze(P.password)?P.password:""},function(e,t){if(!0===e){if(P.enableLogs&&console.log("isRoomJoined: ",e," roomid: ",P.sessionid),P.peers[P.sessionid])return;I.onNegotiationNeeded(n)}!1===e&&P.enableLogs&&console.warn("isRoomJoined: ",t," roomid: ",P.sessionid),o(e,P.sessionid,t)})}function Oe(n){P.enableLogs&&console.log("Sending open-room signal to socket.io"),P.waitingForLocalMedia=!1,P.socket.emit("open-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Re(),extra:P.extra,identifier:P.publicRoomIdentifier,password:void 0!==P.password&&"object"!==ze(P.password)?P.password:""},function(e,t){!0===e&&(P.enableLogs&&console.log("isRoomOpened: ",e," roomid: ",P.sessionid),n(e,P.sessionid)),!1===e&&(P.enableLogs&&console.warn("isRoomOpened: ",t," roomid: ",P.sessionid),n(e,P.sessionid,t))})}function Re(){try{return P.streamEvents.selectAll("local").map(function(e){return{streamid:e.streamid,tracks:e.stream.getTracks().length}})}catch(e){return[]}}function Pe(e,n){var t,o;P.dontCaptureUserMedia||e.isDataOnly?n():(t={},e.localPeerSdpConstraints.OfferToReceiveAudio&&(t.audio=P.mediaConstraints.audio),e.localPeerSdpConstraints.OfferToReceiveVideo&&(t.video=P.mediaConstraints.video),(o=e.session||P.session).oneway&&"two-way"!==o.audio&&"two-way"!==o.video&&"two-way"!==o.screen?n():((o=o.oneway&&o.audio&&"two-way"===o.audio?{audio:!0}:o).audio||o.video||o.screen)&&(o.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!o.audio&&!o.video||_(P)?n(e):P.invokeGetUserMedia(null,n)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},!o.audio&&!o.video||_(P)?n:P.invokeGetUserMedia(null,n))}):(o.audio||o.video)&&P.invokeGetUserMedia(null,n,o)))}function Ie(e,t){e?(t.audio&&S(e,"audio").forEach(function(e){e.applyConstraints(t.audio)}),t.video&&S(e,"video").forEach(function(e){e.applyConstraints(t.video)})):P.enableLogs&&console.error("No stream to applyConstraints.")}function Ne(t,e,n){e?I.replaceTrack(t,e,n):P.peers.getAllParticipants().forEach(function(e){I.replaceTrack(t,e,n)})}B=B||{useDefaultDevices:!0},(P=this).channel=P.sessionid=(D||location.href.replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|\+|@|\[|\||]|\|*. /g,"").split("\n").join("").split("\r").join(""))+"",I=new z(P),Ee={},I.onGettingLocalMedia=function(t,i){if(i=i||function(){},Ee[t.streamid])i();else{Ee[t.streamid]=!0;try{t.type="local"}catch(e){}P.setStreamEndHandler(t),j(t,function(e){e.id=t.streamid,e.muted=!0,e.volume=0,-1===P.attachStreams.indexOf(t)&&P.attachStreams.push(t),void 0!==M&&M.setHandlers(t,!0,P),P.streamEvents[t.streamid]={stream:t,type:"local",mediaElement:e,userid:P.userid,extra:P.extra,streamid:t.streamid,isAudioMuted:!0};try{var n=P,o=P.streamEvents[t.streamid];if(o.stream&&S(o.stream,"audio").length){if(!n||!o)throw"Both arguments are required.";if(n.onspeaking&&n.onsilence){if("undefined"==typeof hark)throw"hark.js not found.";hark(o.stream,{onspeaking:function(){n.onspeaking(o)},onsilence:function(){n.onsilence(o)},onvolumechange:function(e,t){n.onvolumechange&&n.onvolumechange(je({volume:e,threshold:t},o))}})}}F(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])}catch(e){}i()},P)}},I.onGettingRemoteMedia=function(t,n){try{t.type="remote"}catch(e){}P.setStreamEndHandler(t,"remote-stream"),j(t,function(e){e.id=t.streamid,void 0!==M&&M.setHandlers(t,!1,P),P.streamEvents[t.streamid]={stream:t,type:"remote",userid:n,extra:P.peers[n]?P.peers[n].extra:{},mediaElement:e,streamid:t.streamid},F(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])},P)},I.onRemovingRemoteMedia=function(e,t){var n=(n=P.streamEvents[e.streamid])||{stream:e,type:"remote",userid:t,extra:P.peers[t]?P.peers[t].extra:{},streamid:e.streamid,mediaElement:P.streamEvents[e.streamid]?P.streamEvents[e.streamid].mediaElement:null};P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[e.streamid]},I.onNegotiationNeeded=function(e,t,n){n=n||function(){};var o={remoteUserId:t=t||e.remoteUserId,message:e=e||"",sender:P.userid};e.remoteUserId&&e.message&&e.sender&&(o=e),L(function(){P.socket.emit(P.socketMessageEvent,o,n)})},I.onUserLeft=function(e){P.deletePeer(e)},I.disconnectWith=function(e,t){P.socket&&P.socket.emit("disconnect-with",e,t||function(){}),P.deletePeer(e)},P.socketOptions={transport:"polling"},P.openOrJoin=function(e,r){r=r||function(){},P.checkPresence(e,function(e,t){var n,o,i,a;e?(P.sessionid=t,e=!!P.session.oneway,n=c(P.session),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},i={OfferToReceiveAudio:e?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:e?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo},Pe((a={remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:e,isDataOnly:n,localPeerSdpConstraints:i,remotePeerSdpConstraints:o},sender:P.userid}).message,function(){ke(a,r)})):(P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=t||P.sessionid,c(P.session)?Oe(r):P.captureUserMedia(function(){Oe(r)}))})},P.waitingForLocalMedia=!1,P.open=function(e,t){t=t||function(){},P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=e||P.sessionid,L(function(){c(P.session)?Oe(t):P.captureUserMedia(function(){Oe(t)})})},P.peersBackup={},P.deletePeer=function(e){if(e&&P.peers[e]){var t={userid:e,extra:P.peers[e]?P.peers[e].extra:{}};if(P.peersBackup[t.userid]&&(t.extra=P.peersBackup[t.userid].extra),P.onleave(t),P.peers[e]){P.peers[e].streams.forEach(function(e){e.stop()});t=P.peers[e].peer;if(t&&"closed"!==t.iceConnectionState)try{t.close()}catch(e){}P.peers[e]&&(P.peers[e].peer=null,delete P.peers[e])}}},P.rejoin=function(e){var t;!P.isInitiator&&e&&Object.keys(e).length&&(t={},P.peers[e.remoteUserId]&&(t=P.peers[e.remoteUserId].extra,P.deletePeer(e.remoteUserId)),e&&e.remoteUserId&&(P.join(e.remoteUserId),P.onReConnecting({userid:e.remoteUserId,extra:t})))},P.join=function(e,t){P.sessionid=!!e&&(e.sessionid||e.remoteUserId||e)||P.sessionid,P.sessionid+="";var n=!1,o=!1,i=!1,a=!1,r=((e&&e.session||!e||"string"==typeof e)&&(i=!!(e=e&&e.session||P.session).oneway,a=c(e),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},n={OfferToReceiveAudio:i?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:i?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo}),function(){}),s=("function"==typeof(t=t||{})&&(r=t,t={}),void 0!==t.localPeerSdpConstraints&&(n=t.localPeerSdpConstraints),void 0!==t.remotePeerSdpConstraints&&(o=t.remotePeerSdpConstraints),void 0!==t.isOneWay&&(i=t.isOneWay),void 0!==t.isDataOnly&&(a=t.isDataOnly),{remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:i,isDataOnly:a,localPeerSdpConstraints:n,remotePeerSdpConstraints:o},sender:P.userid});return Pe(s.message,function(){L(function(){ke(s,r)})}),s},P.publicRoomIdentifier="",P.getUserMedia=P.captureUserMedia=function(o,i){o=o||function(){};var a=i||P.session;P.dontCaptureUserMedia||c(a)?o():(a.audio||a.video||a.screen)&&(a.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){if(e.isScreen=!0,I.onGettingLocalMedia(e),!a.audio&&!a.video||_(P))o(e);else{var t,n={};for(t in a)"screen"!==t&&(n[t]=a[t]);P.invokeGetUserMedia(i,o,n)}},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)throw e;P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},function(e){if(!a.audio&&!a.video||_(P))o(e);else{var t,n={};for(t in a)"screen"!==t&&(n[t]=a[t]);P.invokeGetUserMedia(i,o,n)}})}):(a.audio||a.video)&&P.invokeGetUserMedia(i,o,a))},P.onbeforeunload=function(e,t){P.closeBeforeUnload&&(P.peers.getAllParticipants().forEach(function(e){I.onNegotiationNeeded({userLeft:!0},e),P.peers[e]&&P.peers[e].peer&&P.peers[e].peer.close(),delete P.peers[e]}),t||P.closeSocket(),P.isInitiator=!1)},window.ignoreBeforeUnload?P.closeBeforeUnload=!1:(P.closeBeforeUnload=!0,window.addEventListener("beforeunload",P.onbeforeunload,!1)),P.userid=f(),P.changeUserId=function(e,t){t=t||function(){},P.userid=e||f(),P.socket.emit("changed-uuid",P.userid,t)},P.extra={},P.attachStreams=[],P.session={audio:!0,video:!0},P.enableFileSharing=!1,P.bandwidth={screen:!1,audio:!1,video:!1},P.codecs={audio:"opus",video:"VP9"},P.processSdp=function(e){return function(){var t=!1;try{if("undefined"==typeof RTCRtpTransceiver)return;if(!("currentDirection"in RTCRtpTransceiver.prototype))return;var e=new T;try{e.addTransceiver("audio"),t=!0}catch(e){}e.close()}catch(e){t=!1}return t&&function(){var t=!1;try{var e=new T({sdpSemantics:"unified-plan"});try{var n=e.getConfiguration(),t="unified-plan"==n.sdpSemantics||(n.sdpSemantics,!1)}catch(e){t=!1}}catch(e){t=!1}return t}()}()||"Safari"!==DetectRTC.browser.name&&("VP8"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp8")),"VP9"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp9")),"H264"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"h264")),"G722"===P.codecs.audio&&(e=E.removeNonG722(e)),"Firefox"!==DetectRTC.browser.name&&((P.bandwidth.video||P.bandwidth.screen)&&(e=E.setApplicationSpecificBandwidth(e,P.bandwidth,!!P.session.screen)),P.bandwidth.video&&(e=E.setVideoBitrates(e,{min:8*P.bandwidth.video*1024,max:8*P.bandwidth.video*1024})),P.bandwidth.audio&&(e=E.setOpusAttributes(e,{maxaveragebitrate:8*P.bandwidth.audio*1024,maxplaybackrate:8*P.bandwidth.audio*1024,stereo:1,maxptime:3})))),e},void 0!==E&&(P.BandwidthHandler=P.CodecsHandler=E),P.mediaConstraints={audio:{mandatory:{},optional:P.bandwidth.audio?[{bandwidth:8*P.bandwidth.audio*1024||1048576}]:[]},video:{mandatory:{},optional:P.bandwidth.video?[{bandwidth:8*P.bandwidth.video*1024||1048576},{facingMode:"user"}]:[{facingMode:"user"}]}},"Firefox"===DetectRTC.browser.name&&(P.mediaConstraints={audio:!0,video:!0}),B.useDefaultDevices||DetectRTC.isMobileDevice||DetectRTC.load(function(){var t,n;if(DetectRTC.MediaDevices.forEach(function(e){"audioinput"===e.kind&&!1!==P.mediaConstraints.audio&&(t=e),"videoinput"===e.kind&&!1!==P.mediaConstraints.video&&(n=e)}),t){if("Firefox"===DetectRTC.browser.name)return void(!0!==P.mediaConstraints.audio?P.mediaConstraints.audio.deviceId=t.id:P.mediaConstraints.audio={deviceId:t.id});1==P.mediaConstraints.audio&&(P.mediaConstraints.audio={mandatory:{},optional:[]}),P.mediaConstraints.audio.optional||(P.mediaConstraints.audio.optional=[]);var e=[{sourceId:t.id}];P.mediaConstraints.audio.optional=e.concat(P.mediaConstraints.audio.optional)}n&&("Firefox"===DetectRTC.browser.name?!0!==P.mediaConstraints.video?P.mediaConstraints.video.deviceId=n.id:P.mediaConstraints.video={deviceId:n.id}:(1==P.mediaConstraints.video&&(P.mediaConstraints.video={mandatory:{},optional:[]}),P.mediaConstraints.video.optional||(P.mediaConstraints.video.optional=[]),e=[{sourceId:n.id}],P.mediaConstraints.video.optional=e.concat(P.mediaConstraints.video.optional)))}),P.sdpConstraints={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},optional:[{VoiceActivityDetection:!1}]},P.sdpSemantics=null,P.iceCandidatePoolSize=null,P.bundlePolicy=null,P.rtcpMuxPolicy=null,P.iceTransportPolicy=null,P.optionalArgument={optional:[{DtlsSrtpKeyAgreement:!0},{googImprovedWifiBwe:!0},{googScreencastMinBitrate:300},{googIPv6:!0},{googDscp:!0},{googCpuUnderuseThreshold:55},{googCpuOveruseThreshold:85},{googSuspendBelowMinBitrate:!0},{googCpuOveruseDetection:!0}],mandatory:{}},P.iceServers=l(P),P.candidates={host:!0,stun:!0,turn:!0},P.iceProtocols={tcp:!0,udp:!0},P.onopen=function(e){P.enableLogs&&console.info("Data connection has been opened between you & ",e.userid)},P.onclose=function(e){P.enableLogs&&console.warn("Data connection has been closed between you & ",e.userid)},P.onerror=function(e){P.enableLogs&&console.error(e.userid,"data-error",e)},P.onmessage=function(e){P.enableLogs&&console.debug("data-message",e.userid,e.data)},P.send=function(e,t){P.peers.send(e,t)},P.close=P.disconnect=P.leave=function(){P.onbeforeunload(!1,!0)},P.closeEntireSession=function(t){t=t||function(){},P.socket.emit("close-entire-session",function e(){P.getAllParticipants().length?setTimeout(e,100):(P.onEntireSessionClosed({sessionid:P.sessionid,userid:P.userid,extra:P.extra}),P.changeUserId(null,function(){P.close(),t()}))})},P.onEntireSessionClosed=function(e){P.enableLogs&&console.info("Entire session is closed: ",e.sessionid,e.extra)},P.onstream=function(e){var t=P.videosContainer,t=(t.insertBefore(e.mediaElement,t.firstChild),e.mediaElement.play());void 0===t?setTimeout(function(){e.mediaElement.play()},2e3):t.catch(function(){}).then(function(){setTimeout(function(){e.mediaElement.play()},2e3)})},P.onstreamended=function(e){e.mediaElement||(e.mediaElement=document.getElementById(e.streamid)),e.mediaElement&&e.mediaElement.parentNode&&e.mediaElement.parentNode.removeChild(e.mediaElement)},P.direction="many-to-many",P.removeStream=function(t,n){var o;P.attachStreams.forEach(function(e){e.id===t&&(o=e)}),o?(P.peers.getAllParticipants().forEach(function(e){if(!n||e===n){e=P.peers[e];try{e.peer.removeStream(o)}catch(e){}}}),P.renegotiate()):console.warn("No such stream exist.",t)},P.addStream=function(n,t){if(n.getTracks)return-1===P.attachStreams.indexOf(n)&&(n.streamid||(n.streamid=n.id),P.attachStreams.push(n)),void P.renegotiate(t);function o(e){n.streamCallback&&n.streamCallback(e),P.renegotiate(t)}c(n)?P.renegotiate(t):(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!n.audio&&!n.video||_(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return"PermissionDeniedError"===e?(n.streamCallback&&n.streamCallback(null),void(P.enableLogs&&console.error("User rejected to share his screen."))):alert(e);P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},function(e){!n.audio&&!n.video||_(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})})}):(n.audio||n.video)&&P.invokeGetUserMedia(null,o))},P.invokeGetUserMedia=function(n,o,e){e=e||P.session,we({onGettingLocalMedia:function(e){var t=n.video;t&&(t.mediaSource||t.mozMediaSource||t.mandatory&&t.mandatory.chromeMediaSource)&&(e.isScreen=!0),e.isScreen||(e.isVideo=!!S(e,"video").length,e.isAudio=!e.isVideo&&S(e,"audio").length),I.onGettingLocalMedia(e,function(){"function"==typeof o&&o(e)})},onLocalMediaError:function(e,t){I.onLocalMediaError(e,t)},localMediaConstraints:(n=n||P.mediaConstraints)||{audio:!!e.audio&&n.audio,video:!!e.video&&n.video}})},P.applyConstraints=function(t,e){var n;C&&C.prototype.applyConstraints?e?Ie(n=P.streamEvents[e]?P.streamEvents[e].stream:n,t):P.attachStreams.forEach(function(e){Ie(e,t)}):alert("track.applyConstraints is NOT supported in your browser.")},P.replaceTrack=function(n,t,o){if(n=n||{},T.prototype.getSenders)if(n instanceof C)Ne(n,t,o);else{if(n instanceof w)return S(n,"video").length&&Ne(S(n,"video")[0],t,!0),void(S(n,"audio").length&&Ne(S(n,"audio")[0],t,!1));if(c(n))throw"connection.replaceTrack requires audio and/or video and/or screen.";(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!n.audio&&!n.video||_(P)?i(e):P.invokeGetUserMedia(null,i)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return alert(e);P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},!n.audio&&!n.video||_(P)?i:P.invokeGetUserMedia(null,i))}):(n.audio||n.video)&&P.invokeGetUserMedia(null,i))}else P.addStream(n);function i(e){P.replaceTrack(e,t,o||n.video||n.screen)}},P.resetTrack=function(e,n){(e="string"==typeof(e=e||P.getAllParticipants())?[e]:e).forEach(function(e){var t=P.peers[e].peer;void 0!==n&&!0!==n||!t.lastVideoTrack||P.replaceTrack(t.lastVideoTrack,e,!0),void 0!==n&&!1!==n||!t.lastAudioTrack||P.replaceTrack(t.lastAudioTrack,e,!1)})},P.renegotiate=function(e){e?I.renegotiatePeer(e):P.peers.getAllParticipants().forEach(function(e){I.renegotiatePeer(e)})},P.setStreamEndHandler=function(o,i){var e;o&&o.addEventListener&&(i=!!i,!o.alreadySetEndHandler)&&(o.alreadySetEndHandler=!0,e="ended","oninactive"in o&&(e="inactive"),o.addEventListener(e,function(){o.idInstance&¤tUserMediaRequest.remove(o.idInstance),i||(t=[],P.attachStreams.forEach(function(e){e.id!=o.id&&t.push(e)}),P.attachStreams=t);var e,t,n=(n=P.streamEvents[o.streamid])||{stream:o,streamid:o.streamid,type:i?"remote":"local",userid:P.userid,extra:P.extra,mediaElement:P.streamEvents[o.streamid]?P.streamEvents[o.streamid].mediaElement:null};i&&P.peers[n.userid]&&(e=P.peers[n.userid].peer,t=[],e.getRemoteStreams().forEach(function(e){e.id!=o.id&&t.push(e)}),P.peers[n.userid].streams=t),n.userid===P.userid&&"remote"===n.type||(P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[o.streamid])},!1))},P.onMediaError=function(e,t){P.enableLogs&&console.error(e,t)},P.autoCloseEntireSession=!1,P.filesContainer=P.videosContainer=document.body||document.documentElement,P.isInitiator=!1,P.shareFile=I.shareFile,a.handle(P),t.handle(P),P.token=f,P.onNewParticipant=function(e,t){P.acceptParticipationRequest(e,t)},P.acceptParticipationRequest=function(e,t){t.successCallback&&(t.successCallback(),delete t.successCallback),I.createNewPeer(e,t)},void 0!==M&&(P.StreamsHandler=M),P.onleave=function(e){},P.invokeSelectFileDialog=function(e){var t=new Fe;t.accept="*.*",t.selectSingleFile(e)},P.onmute=function(e){var t;e&&e.mediaElement&&("both"===e.muteType||"video"===e.muteType?(e.mediaElement.src=null,void 0!==(t=e.mediaElement.pause())?t.then(function(){e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"}):e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"):"audio"===e.muteType&&(e.mediaElement.muted=!0))},P.onunmute=function(e){e&&e.mediaElement&&e.stream&&("both"===e.unmuteType||"video"===e.unmuteType?(e.mediaElement.poster=null,e.mediaElement.srcObject=e.stream,e.mediaElement.play()):"audio"===e.unmuteType&&(e.mediaElement.muted=!1))},P.onExtraDataUpdated=function(e){e.status="online",P.onUserStatusChanged(e,!0)},P.getAllParticipants=function(e){return P.peers.getAllParticipants(e)},void 0!==M&&(M.onSyncNeeded=function(t,n,o){P.peers.getAllParticipants().forEach(function(e){I.onNegotiationNeeded({streamid:t,action:n,streamSyncNeeded:!0,type:o||"both"},e)})}),P.connectSocket=function(e){L(e)},P.closeSocket=function(){try{Be.a.sockets={}}catch(e){}P.socket&&("function"==typeof P.socket.disconnect&&P.socket.disconnect(),"function"==typeof P.socket.resetProps&&P.socket.resetProps(),P.socket=null)},P.getSocket=function(e){return!e&&P.enableLogs&&console.warn("getSocket.callback paramter is required."),e=e||function(){},P.socket?e(P.socket):L(function(){e(P.socket)}),P.socket},P.getRemoteStreams=I.getRemoteStreams,Ae=["selectFirst","selectAll","forEach"],P.streamEvents={selectFirst:function(e){return P.streamEvents.selectAll(e)[0]},selectAll:function(n){"video"==(n="audio"==(n="screen"==(n="remote"==(n="local"==(n=n||{local:!0,remote:!0,isScreen:!0,isAudio:!0,isVideo:!0})?{local:!0}:n)?{remote:!0}:n)?{isScreen:!0}:n)?{isAudio:!0}:n)&&(n={isVideo:!0});var o=[];return Object.keys(P.streamEvents).forEach(function(e){var t=P.streamEvents[e];-1===Ae.indexOf(e)&&(e=!0,n.local&&"local"===t.type&&(e=!1),n.remote&&"remote"===t.type&&(e=!1),n.isScreen&&t.stream.isScreen&&(e=!1),n.isVideo&&t.stream.isVideo&&(e=!1),n.isAudio&&t.stream.isAudio&&(e=!1),!1===(e=n.userid&&t.userid===n.userid?!1:e)&&o.push(t))}),o}},P.socketURL="/",P.socketMessageEvent="RTCMultiConnection-Message",P.socketCustomEvent="RTCMultiConnection-Custom-Message",P.DetectRTC=DetectRTC,P.setCustomSocketEvent=function(e){e&&(P.socketCustomEvent=e),P.socket&&P.socket.emit("set-custom-socket-event-listener",P.socketCustomEvent)},P.getNumberOfBroadcastViewers=function(e,t){P.socket&&e&&t&&P.socket.emit("get-number-of-users-in-specific-broadcast",e,t)},P.onNumberOfBroadcastViewersUpdated=function(e){P.enableLogs&&P.isInitiator&&console.info("Number of broadcast (",e.broadcastId,") viewers",e.numberOfBroadcastViewers)},P.onUserStatusChanged=function(e,t){P.enableLogs&&!t&&console.info(e.userid,e.status)},P.getUserMediaHandler=we,P.multiPeersHandler=I,P.enableLogs=!0,P.setCustomSocketHandler=function(e){void 0!==n&&(n=e)},P.chunkSize=4e4,P.maxParticipantsAllowed=1e3,P.disconnectWith=I.disconnectWith,P.checkPresence=function(e,o){e=e||P.sessionid,"SSEConnection"!==n.name?P.socket?P.socket.emit("check-presence",e+"",function(e,t,n){P.enableLogs&&console.log("checkPresence.isRoomExist: ",e," roomid: ",t),o(e,t,n)}):P.connectSocket(function(){P.checkPresence(e,o)}):SSEConnection.checkPresence(e,function(e,t,n){if(!P.socket)return e||(P.userid=t),void P.connectSocket(function(){o(e,t,n)});o(e,t)})},P.onReadyForOffer=function(e,t){P.multiPeersHandler.createNewPeer(e,t)},P.setUserPreferences=function(e){return P.dontAttachStream&&(e.dontAttachLocalStream=!0),P.dontGetRemoteStream&&(e.dontGetRemoteStream=!0),e},P.updateExtraData=function(){P.socket.emit("extra-data-updated",P.extra)},P.enableScalableBroadcast=!1,P.maxRelayLimitPerUser=3,P.dontCaptureUserMedia=!1,P.dontAttachStream=!1,P.dontGetRemoteStream=!1,P.onReConnecting=function(e){P.enableLogs&&console.info("ReConnecting with",e.userid,"...")},P.beforeAddingStream=function(e){return e},P.beforeRemovingStream=function(e){return e},P.checkIfChromeExtensionAvailable=Se,"undefined"!=typeof isFirefoxExtensionAvailable&&(P.checkIfChromeExtensionAvailable=isFirefoxExtensionAvailable),P.getChromeExtensionStatus=xe,P.getScreenConstraints=function(n,e){_(P,e)&&(e=!0);var o,i=function(e,t){e||(t=P.modifyScreenConstraints(t),n(e,t))};Te?i(null,{mozMediaSource:"window",mediaSource:"window"}):(o={mandatory:{chromeMediaSource:R,maxWidth:1920Failed to start game'}try{r()}catch(e){}}if(2===e.data.t){var n=e.data.file.split("/"),o=(i=n.pop()).split(".").pop(),i=i.replace(/\#/g,"");Z._FS.createPath("/",n.join("/"),!0,!0);for(var a=m[l].length-1;0<=a;--a)m[l][a]===o.toLowerCase()&&dFailed to start game'}try{r()}catch(e){}}},s=function(){var t=p,n=Z.loading.querySelector(".".concat(T.p3)),e=p.config,o=(e.gameId,e.gameUrl),i=e.system,e=("vbanext"==i&&(i="gba"),o.split("/")),l=e[e.length-1];(l=-1'+s.localization("Control Settings")+'
\n \n
\n
"+s.localization("Press keyboard or gamepad")+"
"+s.localization("Press escape (esc) to clear")):t+="
Press keyboard
"+s.localization("Press escape (esc) to clear"),r.querySelector(".".concat(v.classNames["key-setting-popup"])).innerHTML=t,e.stopPropagation()})})},setCacheDialog:function(){var t=this;t.elements.dialogs.cache.innerHTML='\n \n "),U.call(this,t.elements.dialogs.cache.querySelector(".".concat(v.classNames["btn-cancel"])),"click",function(e){return G(t.elements.dialogs.cache,!0),t.elements.container.focus(),e.stopPropagation(),!1}),U.call(this,t.elements.dialogs.cache.querySelector(".".concat(v.classNames["dialog-title"]," a")),"click",function(e){return m.romdb&&(m.romdb.clear(),t.elements.dialogs.cache.querySelector(".".concat(v.classNames["dialog-content"])).innerHTML='Cheats
\n '+h.localization("Netplay")+'
\n \n \n
\n \n \n \n \n '+h.localization("Room Name")+" \n "+h.localization("Players")+' \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n '+h.localization("Player")+" \n "+h.localization("Name")+" \n \n \n \n 1 \n "+h.localization("Name")+" 1 \n \n \n \n 2 \n "+h.localization("Name")+" 2 \n \n \n \n 3 \n "+h.localization("Name")+" 3 \n \n \n \n \n 4 \n "+h.localization("Name")+' 4 \n \n ";v.players.forEach(function(e,t){var n=null;e?(v.connection.peers[e]?n=v.connection.peers[e].extra:v.connection.userid===e&&(n=v.connection.extra),o+="
",h.elements.widgets.netplay.innerHTML=o},500),n=h.elements.dialogs.netplay.querySelector("#modal-9de6c4e9ce2b9361"),a=h.elements.dialogs.netplay.querySelector("#modal-85cd7a1c543a484a"),o=h.elements.dialogs.netplay.querySelector("#modal-7d8fd50ed642340b"),i=h.elements.dialogs.netplay.querySelector("#modal-5aa765d61d8327de"),l={},v.connection=new Le.a,(e=p.socketUrl).endsWith("/")||(e+="/"),v.connection.socketURL="/",v.connection.socketURL=e,v.connection.socketMessageEvent="emulatorjs-message",v.connection.socketCustomEvent="emulatorjs-custom-message",e=W.info(),v.connection.extra={name:v.playerName,game_id:h.config.gameId,browser_name:e.name,room_name:" ",domain:document.domain},v.connection.socketMessageEvent="netplay",v.connection.enableFileSharing=!0,v.connection.enableLogs=!1,v.connection.session={data:!0},v.connection.sdpConstraints.mandatory={OfferToReceiveAudio:!1,OfferToReceiveVideo:!1},v.connection.onclose=function(e){},v.connection.iceServers=[{urls:"turn:turn.emulatorjs.com:3478",credential:"dSnmrtehverella",username:"ejs"},{urls:["stun:stun.l.google.com:19302","stun:stun1.l.google.com:19302","stun:stun2.l.google.com:19302","stun:stun.l.google.com:19302?transport=udp"]}],v.connection.maxParticipantsAllowed=4,s=v.netPlayInitFrame=0,c=!1,Module.postMainLoop=function(){var e,t;if(v.currentFrame=parseInt(v.currentFrameNum(),10),v.connected)if(s+=1,v.connection.isInitiator)if(1<=s){for(var n=[],o=v.currentFrame-1;o[".concat(i,"] ").concat(o," ").concat(t.room_name," ").concat(t.current,"/").concat(t.max," ").concat(e," "),U.call(p,n.querySelector(".".concat(v.classNames["btn-join-room"])),"click",f),c.appendChild(n)}),c.querySelectorAll("tr").forEach(function(e){r.includes(e.id)||c.removeChild(e)})),v.loadRoomsListTimer=setTimeout(v.loadRoomsList,2e3)}).catch(function(e){console.log("Network Error",e),v.loadRoomsListTimer=setTimeout(v.loadRoomsList,2e3)})},v.openRoom=function(e){v.stopLoadRooms(),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-roomlist"])),!0),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-room"])),!1),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["btn-create-room"])),!0),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["btn-quit"])),!1),v.resetCheat(),G(e.elements.buttons.cheat,!0);var e=e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-room"])),t=e.querySelector("[data-room-password]"),o=(null===v.connection.password?G(t,!0):(G(t,!1),t.querySelector("span").innerText=v.connection.password),e.querySelector("tbody"));o.innerHTML="",e.querySelector("strong").innerText=l.room_name,v.players.forEach(function(e,t){var n=null;e&&(v.connection.peers[e]?n=v.connection.peers[e].extra:v.connection.userid===e&&(n=v.connection.extra),n&&n.name)&&((e=document.createElement("tr")).innerHTML="".concat(t+1," ").concat(n.name," "),o.appendChild(e))})},U.call(this,i.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=i.querySelector(".".concat(v.classNames["netplay-room-password-input"])).value,t=(v.showLoading.call(h),v.connection.password=t,i.getAttribute("data-id"));v.connection.join(t,function(e,t,n){u(e,0,n),e&&i.classList.remove(H({"is-open":!0}))}),e.stopPropagation()}),U.call(this,n.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=(t=n.querySelector(".".concat(v.classNames["netplay-player-name"])).value).replace(/<|>/g,"");n.querySelector(".".concat(v.classNames.modal__errmsg)).innerHTML="",t.trim()&&(v.playerName=t.trim(),v.connection.extra.name=t.trim(),g.close()),e.stopPropagation()}),U.call(this,a.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=(t=a.querySelector(".".concat(v.classNames["netplay-room-name-input"])).value).replace(/<|>/g,""),n=a.querySelector("select[data-max-players] option:checked").value;4<(n=n<2?2:n)&&(n=4);for(var o=0;o t&&(e+=" ... "),">>=0,isFinite(n)?(n>>>=0,void 0===o&&(o="utf8")):(o=n,n=void 0)}var i=this.length-t;if((void 0===n||i>1,d=-7,u=n?i-1:0,f=n?-1:1,i=e[t+u];for(u+=f,a=i&(1<<-d)-1,i>>=-d,d+=s;0
':t.innerHTML='Download '+e.name+'
'):console.error("No such progress-helper element exist.",e)}}},t={handle:function(i){i.autoTranslateText=!1,i.language="en",i.googKey="AIzaSyCgB5hmFY74WYB-EoWkhr9cAGr6TiTHrEE",i.Translator={TranslateText:function(e,t){var n=document.createElement("script"),e=(n.type="text/javascript",encodeURIComponent(e)),o="method"+i.token(),o=(window[o]=function(e){e.data&&e.data.translations[0]&&t?t(e.data.translations[0].translatedText):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e)},"https://www.googleapis.com/language/translate/v2?key="+i.googKey+"&target="+(i.language||"en-US")+"&callback=window."+o+"&q="+e);n.src=o,document.getElementsByTagName("head")[0].appendChild(n)},getListOfLanguages:function(t){var n=new XMLHttpRequest,e=(n.onreadystatechange=function(){var e;n.readyState==XMLHttpRequest.DONE&&((e=JSON.parse(n.responseText))&&e.data&&e.data.languages?t(e.data.languages):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e))},"https://www.googleapis.com/language/translate/v2/languages?key="+i.googKey+"&target=en");n.open("GET",e,!0),n.send(null)}}}};function L(t){if(P.socketAutoReConnect=!0,P.socket)t&&t(P.socket);else{if(void 0===n)if("undefined"!=typeof FirebaseConnection)window.SocketConnection=FirebaseConnection;else{if("undefined"==typeof PubNubConnection)throw"SocketConnection.js seems missed.";window.SocketConnection=PubNubConnection}new n(P,function(e){t&&t(P.socket)})}}function ke(n,o){P.socket.emit("join-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Re(),extra:P.extra,password:void 0!==P.password&&"object"!==ze(P.password)?P.password:""},function(e,t){if(!0===e){if(P.enableLogs&&console.log("isRoomJoined: ",e," roomid: ",P.sessionid),P.peers[P.sessionid])return;I.onNegotiationNeeded(n)}!1===e&&P.enableLogs&&console.warn("isRoomJoined: ",t," roomid: ",P.sessionid),o(e,P.sessionid,t)})}function Oe(n){P.enableLogs&&console.log("Sending open-room signal to socket.io"),P.waitingForLocalMedia=!1,P.socket.emit("open-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Re(),extra:P.extra,identifier:P.publicRoomIdentifier,password:void 0!==P.password&&"object"!==ze(P.password)?P.password:""},function(e,t){!0===e&&(P.enableLogs&&console.log("isRoomOpened: ",e," roomid: ",P.sessionid),n(e,P.sessionid)),!1===e&&(P.enableLogs&&console.warn("isRoomOpened: ",t," roomid: ",P.sessionid),n(e,P.sessionid,t))})}function Re(){try{return P.streamEvents.selectAll("local").map(function(e){return{streamid:e.streamid,tracks:e.stream.getTracks().length}})}catch(e){return[]}}function Pe(e,n){var t,o;P.dontCaptureUserMedia||e.isDataOnly?n():(t={},e.localPeerSdpConstraints.OfferToReceiveAudio&&(t.audio=P.mediaConstraints.audio),e.localPeerSdpConstraints.OfferToReceiveVideo&&(t.video=P.mediaConstraints.video),(o=e.session||P.session).oneway&&"two-way"!==o.audio&&"two-way"!==o.video&&"two-way"!==o.screen?n():((o=o.oneway&&o.audio&&"two-way"===o.audio?{audio:!0}:o).audio||o.video||o.screen)&&(o.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!o.audio&&!o.video||_(P)?n(e):P.invokeGetUserMedia(null,n)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},!o.audio&&!o.video||_(P)?n:P.invokeGetUserMedia(null,n))}):(o.audio||o.video)&&P.invokeGetUserMedia(null,n,o)))}function Ie(e,t){e?(t.audio&&S(e,"audio").forEach(function(e){e.applyConstraints(t.audio)}),t.video&&S(e,"video").forEach(function(e){e.applyConstraints(t.video)})):P.enableLogs&&console.error("No stream to applyConstraints.")}function Ne(t,e,n){e?I.replaceTrack(t,e,n):P.peers.getAllParticipants().forEach(function(e){I.replaceTrack(t,e,n)})}B=B||{useDefaultDevices:!0},(P=this).channel=P.sessionid=(D||location.href.replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|\+|@|\[|\||]|\|*. /g,"").split("\n").join("").split("\r").join(""))+"",I=new z(P),Ee={},I.onGettingLocalMedia=function(t,i){if(i=i||function(){},Ee[t.streamid])i();else{Ee[t.streamid]=!0;try{t.type="local"}catch(e){}P.setStreamEndHandler(t),j(t,function(e){e.id=t.streamid,e.muted=!0,e.volume=0,-1===P.attachStreams.indexOf(t)&&P.attachStreams.push(t),void 0!==M&&M.setHandlers(t,!0,P),P.streamEvents[t.streamid]={stream:t,type:"local",mediaElement:e,userid:P.userid,extra:P.extra,streamid:t.streamid,isAudioMuted:!0};try{var n=P,o=P.streamEvents[t.streamid];if(o.stream&&S(o.stream,"audio").length){if(!n||!o)throw"Both arguments are required.";if(n.onspeaking&&n.onsilence){if("undefined"==typeof hark)throw"hark.js not found.";hark(o.stream,{onspeaking:function(){n.onspeaking(o)},onsilence:function(){n.onsilence(o)},onvolumechange:function(e,t){n.onvolumechange&&n.onvolumechange(je({volume:e,threshold:t},o))}})}}F(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])}catch(e){}i()},P)}},I.onGettingRemoteMedia=function(t,n){try{t.type="remote"}catch(e){}P.setStreamEndHandler(t,"remote-stream"),j(t,function(e){e.id=t.streamid,void 0!==M&&M.setHandlers(t,!1,P),P.streamEvents[t.streamid]={stream:t,type:"remote",userid:n,extra:P.peers[n]?P.peers[n].extra:{},mediaElement:e,streamid:t.streamid},F(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])},P)},I.onRemovingRemoteMedia=function(e,t){var n=(n=P.streamEvents[e.streamid])||{stream:e,type:"remote",userid:t,extra:P.peers[t]?P.peers[t].extra:{},streamid:e.streamid,mediaElement:P.streamEvents[e.streamid]?P.streamEvents[e.streamid].mediaElement:null};P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[e.streamid]},I.onNegotiationNeeded=function(e,t,n){n=n||function(){};var o={remoteUserId:t=t||e.remoteUserId,message:e=e||"",sender:P.userid};e.remoteUserId&&e.message&&e.sender&&(o=e),L(function(){P.socket.emit(P.socketMessageEvent,o,n)})},I.onUserLeft=function(e){P.deletePeer(e)},I.disconnectWith=function(e,t){P.socket&&P.socket.emit("disconnect-with",e,t||function(){}),P.deletePeer(e)},P.socketOptions={transport:"polling"},P.openOrJoin=function(e,r){r=r||function(){},P.checkPresence(e,function(e,t){var n,o,i,a;e?(P.sessionid=t,e=!!P.session.oneway,n=c(P.session),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},i={OfferToReceiveAudio:e?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:e?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo},Pe((a={remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:e,isDataOnly:n,localPeerSdpConstraints:i,remotePeerSdpConstraints:o},sender:P.userid}).message,function(){ke(a,r)})):(P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=t||P.sessionid,c(P.session)?Oe(r):P.captureUserMedia(function(){Oe(r)}))})},P.waitingForLocalMedia=!1,P.open=function(e,t){t=t||function(){},P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=e||P.sessionid,L(function(){c(P.session)?Oe(t):P.captureUserMedia(function(){Oe(t)})})},P.peersBackup={},P.deletePeer=function(e){if(e&&P.peers[e]){var t={userid:e,extra:P.peers[e]?P.peers[e].extra:{}};if(P.peersBackup[t.userid]&&(t.extra=P.peersBackup[t.userid].extra),P.onleave(t),P.peers[e]){P.peers[e].streams.forEach(function(e){e.stop()});t=P.peers[e].peer;if(t&&"closed"!==t.iceConnectionState)try{t.close()}catch(e){}P.peers[e]&&(P.peers[e].peer=null,delete P.peers[e])}}},P.rejoin=function(e){var t;!P.isInitiator&&e&&Object.keys(e).length&&(t={},P.peers[e.remoteUserId]&&(t=P.peers[e.remoteUserId].extra,P.deletePeer(e.remoteUserId)),e&&e.remoteUserId&&(P.join(e.remoteUserId),P.onReConnecting({userid:e.remoteUserId,extra:t})))},P.join=function(e,t){P.sessionid=!!e&&(e.sessionid||e.remoteUserId||e)||P.sessionid,P.sessionid+="";var n=!1,o=!1,i=!1,a=!1,r=((e&&e.session||!e||"string"==typeof e)&&(i=!!(e=e&&e.session||P.session).oneway,a=c(e),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},n={OfferToReceiveAudio:i?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:i?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo}),function(){}),s=("function"==typeof(t=t||{})&&(r=t,t={}),void 0!==t.localPeerSdpConstraints&&(n=t.localPeerSdpConstraints),void 0!==t.remotePeerSdpConstraints&&(o=t.remotePeerSdpConstraints),void 0!==t.isOneWay&&(i=t.isOneWay),void 0!==t.isDataOnly&&(a=t.isDataOnly),{remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:i,isDataOnly:a,localPeerSdpConstraints:n,remotePeerSdpConstraints:o},sender:P.userid});return Pe(s.message,function(){L(function(){ke(s,r)})}),s},P.publicRoomIdentifier="",P.getUserMedia=P.captureUserMedia=function(o,i){o=o||function(){};var a=i||P.session;P.dontCaptureUserMedia||c(a)?o():(a.audio||a.video||a.screen)&&(a.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){if(e.isScreen=!0,I.onGettingLocalMedia(e),!a.audio&&!a.video||_(P))o(e);else{var t,n={};for(t in a)"screen"!==t&&(n[t]=a[t]);P.invokeGetUserMedia(i,o,n)}},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)throw e;P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},function(e){if(!a.audio&&!a.video||_(P))o(e);else{var t,n={};for(t in a)"screen"!==t&&(n[t]=a[t]);P.invokeGetUserMedia(i,o,n)}})}):(a.audio||a.video)&&P.invokeGetUserMedia(i,o,a))},P.onbeforeunload=function(e,t){P.closeBeforeUnload&&(P.peers.getAllParticipants().forEach(function(e){I.onNegotiationNeeded({userLeft:!0},e),P.peers[e]&&P.peers[e].peer&&P.peers[e].peer.close(),delete P.peers[e]}),t||P.closeSocket(),P.isInitiator=!1)},window.ignoreBeforeUnload?P.closeBeforeUnload=!1:(P.closeBeforeUnload=!0,window.addEventListener("beforeunload",P.onbeforeunload,!1)),P.userid=f(),P.changeUserId=function(e,t){t=t||function(){},P.userid=e||f(),P.socket.emit("changed-uuid",P.userid,t)},P.extra={},P.attachStreams=[],P.session={audio:!0,video:!0},P.enableFileSharing=!1,P.bandwidth={screen:!1,audio:!1,video:!1},P.codecs={audio:"opus",video:"VP9"},P.processSdp=function(e){return function(){var t=!1;try{if("undefined"==typeof RTCRtpTransceiver)return;if(!("currentDirection"in RTCRtpTransceiver.prototype))return;var e=new T;try{e.addTransceiver("audio"),t=!0}catch(e){}e.close()}catch(e){t=!1}return t&&function(){var t=!1;try{var e=new T({sdpSemantics:"unified-plan"});try{var n=e.getConfiguration(),t="unified-plan"==n.sdpSemantics||(n.sdpSemantics,!1)}catch(e){t=!1}}catch(e){t=!1}return t}()}()||"Safari"!==DetectRTC.browser.name&&("VP8"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp8")),"VP9"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp9")),"H264"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"h264")),"G722"===P.codecs.audio&&(e=E.removeNonG722(e)),"Firefox"!==DetectRTC.browser.name&&((P.bandwidth.video||P.bandwidth.screen)&&(e=E.setApplicationSpecificBandwidth(e,P.bandwidth,!!P.session.screen)),P.bandwidth.video&&(e=E.setVideoBitrates(e,{min:8*P.bandwidth.video*1024,max:8*P.bandwidth.video*1024})),P.bandwidth.audio&&(e=E.setOpusAttributes(e,{maxaveragebitrate:8*P.bandwidth.audio*1024,maxplaybackrate:8*P.bandwidth.audio*1024,stereo:1,maxptime:3})))),e},void 0!==E&&(P.BandwidthHandler=P.CodecsHandler=E),P.mediaConstraints={audio:{mandatory:{},optional:P.bandwidth.audio?[{bandwidth:8*P.bandwidth.audio*1024||1048576}]:[]},video:{mandatory:{},optional:P.bandwidth.video?[{bandwidth:8*P.bandwidth.video*1024||1048576},{facingMode:"user"}]:[{facingMode:"user"}]}},"Firefox"===DetectRTC.browser.name&&(P.mediaConstraints={audio:!0,video:!0}),B.useDefaultDevices||DetectRTC.isMobileDevice||DetectRTC.load(function(){var t,n;if(DetectRTC.MediaDevices.forEach(function(e){"audioinput"===e.kind&&!1!==P.mediaConstraints.audio&&(t=e),"videoinput"===e.kind&&!1!==P.mediaConstraints.video&&(n=e)}),t){if("Firefox"===DetectRTC.browser.name)return void(!0!==P.mediaConstraints.audio?P.mediaConstraints.audio.deviceId=t.id:P.mediaConstraints.audio={deviceId:t.id});1==P.mediaConstraints.audio&&(P.mediaConstraints.audio={mandatory:{},optional:[]}),P.mediaConstraints.audio.optional||(P.mediaConstraints.audio.optional=[]);var e=[{sourceId:t.id}];P.mediaConstraints.audio.optional=e.concat(P.mediaConstraints.audio.optional)}n&&("Firefox"===DetectRTC.browser.name?!0!==P.mediaConstraints.video?P.mediaConstraints.video.deviceId=n.id:P.mediaConstraints.video={deviceId:n.id}:(1==P.mediaConstraints.video&&(P.mediaConstraints.video={mandatory:{},optional:[]}),P.mediaConstraints.video.optional||(P.mediaConstraints.video.optional=[]),e=[{sourceId:n.id}],P.mediaConstraints.video.optional=e.concat(P.mediaConstraints.video.optional)))}),P.sdpConstraints={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},optional:[{VoiceActivityDetection:!1}]},P.sdpSemantics=null,P.iceCandidatePoolSize=null,P.bundlePolicy=null,P.rtcpMuxPolicy=null,P.iceTransportPolicy=null,P.optionalArgument={optional:[{DtlsSrtpKeyAgreement:!0},{googImprovedWifiBwe:!0},{googScreencastMinBitrate:300},{googIPv6:!0},{googDscp:!0},{googCpuUnderuseThreshold:55},{googCpuOveruseThreshold:85},{googSuspendBelowMinBitrate:!0},{googCpuOveruseDetection:!0}],mandatory:{}},P.iceServers=l(P),P.candidates={host:!0,stun:!0,turn:!0},P.iceProtocols={tcp:!0,udp:!0},P.onopen=function(e){P.enableLogs&&console.info("Data connection has been opened between you & ",e.userid)},P.onclose=function(e){P.enableLogs&&console.warn("Data connection has been closed between you & ",e.userid)},P.onerror=function(e){P.enableLogs&&console.error(e.userid,"data-error",e)},P.onmessage=function(e){P.enableLogs&&console.debug("data-message",e.userid,e.data)},P.send=function(e,t){P.peers.send(e,t)},P.close=P.disconnect=P.leave=function(){P.onbeforeunload(!1,!0)},P.closeEntireSession=function(t){t=t||function(){},P.socket.emit("close-entire-session",function e(){P.getAllParticipants().length?setTimeout(e,100):(P.onEntireSessionClosed({sessionid:P.sessionid,userid:P.userid,extra:P.extra}),P.changeUserId(null,function(){P.close(),t()}))})},P.onEntireSessionClosed=function(e){P.enableLogs&&console.info("Entire session is closed: ",e.sessionid,e.extra)},P.onstream=function(e){var t=P.videosContainer,t=(t.insertBefore(e.mediaElement,t.firstChild),e.mediaElement.play());void 0===t?setTimeout(function(){e.mediaElement.play()},2e3):t.catch(function(){}).then(function(){setTimeout(function(){e.mediaElement.play()},2e3)})},P.onstreamended=function(e){e.mediaElement||(e.mediaElement=document.getElementById(e.streamid)),e.mediaElement&&e.mediaElement.parentNode&&e.mediaElement.parentNode.removeChild(e.mediaElement)},P.direction="many-to-many",P.removeStream=function(t,n){var o;P.attachStreams.forEach(function(e){e.id===t&&(o=e)}),o?(P.peers.getAllParticipants().forEach(function(e){if(!n||e===n){e=P.peers[e];try{e.peer.removeStream(o)}catch(e){}}}),P.renegotiate()):console.warn("No such stream exist.",t)},P.addStream=function(n,t){if(n.getTracks)return-1===P.attachStreams.indexOf(n)&&(n.streamid||(n.streamid=n.id),P.attachStreams.push(n)),void P.renegotiate(t);function o(e){n.streamCallback&&n.streamCallback(e),P.renegotiate(t)}c(n)?P.renegotiate(t):(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!n.audio&&!n.video||_(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return"PermissionDeniedError"===e?(n.streamCallback&&n.streamCallback(null),void(P.enableLogs&&console.error("User rejected to share his screen."))):alert(e);P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},function(e){!n.audio&&!n.video||_(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})})}):(n.audio||n.video)&&P.invokeGetUserMedia(null,o))},P.invokeGetUserMedia=function(n,o,e){e=e||P.session,we({onGettingLocalMedia:function(e){var t=n.video;t&&(t.mediaSource||t.mozMediaSource||t.mandatory&&t.mandatory.chromeMediaSource)&&(e.isScreen=!0),e.isScreen||(e.isVideo=!!S(e,"video").length,e.isAudio=!e.isVideo&&S(e,"audio").length),I.onGettingLocalMedia(e,function(){"function"==typeof o&&o(e)})},onLocalMediaError:function(e,t){I.onLocalMediaError(e,t)},localMediaConstraints:(n=n||P.mediaConstraints)||{audio:!!e.audio&&n.audio,video:!!e.video&&n.video}})},P.applyConstraints=function(t,e){var n;C&&C.prototype.applyConstraints?e?Ie(n=P.streamEvents[e]?P.streamEvents[e].stream:n,t):P.attachStreams.forEach(function(e){Ie(e,t)}):alert("track.applyConstraints is NOT supported in your browser.")},P.replaceTrack=function(n,t,o){if(n=n||{},T.prototype.getSenders)if(n instanceof C)Ne(n,t,o);else{if(n instanceof w)return S(n,"video").length&&Ne(S(n,"video")[0],t,!0),void(S(n,"audio").length&&Ne(S(n,"audio")[0],t,!1));if(c(n))throw"connection.replaceTrack requires audio and/or video and/or screen.";(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!n.audio&&!n.video||_(P)?i(e):P.invokeGetUserMedia(null,i)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return alert(e);P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},!n.audio&&!n.video||_(P)?i:P.invokeGetUserMedia(null,i))}):(n.audio||n.video)&&P.invokeGetUserMedia(null,i))}else P.addStream(n);function i(e){P.replaceTrack(e,t,o||n.video||n.screen)}},P.resetTrack=function(e,n){(e="string"==typeof(e=e||P.getAllParticipants())?[e]:e).forEach(function(e){var t=P.peers[e].peer;void 0!==n&&!0!==n||!t.lastVideoTrack||P.replaceTrack(t.lastVideoTrack,e,!0),void 0!==n&&!1!==n||!t.lastAudioTrack||P.replaceTrack(t.lastAudioTrack,e,!1)})},P.renegotiate=function(e){e?I.renegotiatePeer(e):P.peers.getAllParticipants().forEach(function(e){I.renegotiatePeer(e)})},P.setStreamEndHandler=function(o,i){var e;o&&o.addEventListener&&(i=!!i,!o.alreadySetEndHandler)&&(o.alreadySetEndHandler=!0,e="ended","oninactive"in o&&(e="inactive"),o.addEventListener(e,function(){o.idInstance&¤tUserMediaRequest.remove(o.idInstance),i||(t=[],P.attachStreams.forEach(function(e){e.id!=o.id&&t.push(e)}),P.attachStreams=t);var e,t,n=(n=P.streamEvents[o.streamid])||{stream:o,streamid:o.streamid,type:i?"remote":"local",userid:P.userid,extra:P.extra,mediaElement:P.streamEvents[o.streamid]?P.streamEvents[o.streamid].mediaElement:null};i&&P.peers[n.userid]&&(e=P.peers[n.userid].peer,t=[],e.getRemoteStreams().forEach(function(e){e.id!=o.id&&t.push(e)}),P.peers[n.userid].streams=t),n.userid===P.userid&&"remote"===n.type||(P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[o.streamid])},!1))},P.onMediaError=function(e,t){P.enableLogs&&console.error(e,t)},P.autoCloseEntireSession=!1,P.filesContainer=P.videosContainer=document.body||document.documentElement,P.isInitiator=!1,P.shareFile=I.shareFile,a.handle(P),t.handle(P),P.token=f,P.onNewParticipant=function(e,t){P.acceptParticipationRequest(e,t)},P.acceptParticipationRequest=function(e,t){t.successCallback&&(t.successCallback(),delete t.successCallback),I.createNewPeer(e,t)},void 0!==M&&(P.StreamsHandler=M),P.onleave=function(e){},P.invokeSelectFileDialog=function(e){var t=new Fe;t.accept="*.*",t.selectSingleFile(e)},P.onmute=function(e){var t;e&&e.mediaElement&&("both"===e.muteType||"video"===e.muteType?(e.mediaElement.src=null,void 0!==(t=e.mediaElement.pause())?t.then(function(){e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"}):e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"):"audio"===e.muteType&&(e.mediaElement.muted=!0))},P.onunmute=function(e){e&&e.mediaElement&&e.stream&&("both"===e.unmuteType||"video"===e.unmuteType?(e.mediaElement.poster=null,e.mediaElement.srcObject=e.stream,e.mediaElement.play()):"audio"===e.unmuteType&&(e.mediaElement.muted=!1))},P.onExtraDataUpdated=function(e){e.status="online",P.onUserStatusChanged(e,!0)},P.getAllParticipants=function(e){return P.peers.getAllParticipants(e)},void 0!==M&&(M.onSyncNeeded=function(t,n,o){P.peers.getAllParticipants().forEach(function(e){I.onNegotiationNeeded({streamid:t,action:n,streamSyncNeeded:!0,type:o||"both"},e)})}),P.connectSocket=function(e){L(e)},P.closeSocket=function(){try{Be.a.sockets={}}catch(e){}P.socket&&("function"==typeof P.socket.disconnect&&P.socket.disconnect(),"function"==typeof P.socket.resetProps&&P.socket.resetProps(),P.socket=null)},P.getSocket=function(e){return!e&&P.enableLogs&&console.warn("getSocket.callback paramter is required."),e=e||function(){},P.socket?e(P.socket):L(function(){e(P.socket)}),P.socket},P.getRemoteStreams=I.getRemoteStreams,Ae=["selectFirst","selectAll","forEach"],P.streamEvents={selectFirst:function(e){return P.streamEvents.selectAll(e)[0]},selectAll:function(n){"video"==(n="audio"==(n="screen"==(n="remote"==(n="local"==(n=n||{local:!0,remote:!0,isScreen:!0,isAudio:!0,isVideo:!0})?{local:!0}:n)?{remote:!0}:n)?{isScreen:!0}:n)?{isAudio:!0}:n)&&(n={isVideo:!0});var o=[];return Object.keys(P.streamEvents).forEach(function(e){var t=P.streamEvents[e];-1===Ae.indexOf(e)&&(e=!0,n.local&&"local"===t.type&&(e=!1),n.remote&&"remote"===t.type&&(e=!1),n.isScreen&&t.stream.isScreen&&(e=!1),n.isVideo&&t.stream.isVideo&&(e=!1),n.isAudio&&t.stream.isAudio&&(e=!1),!1===(e=n.userid&&t.userid===n.userid?!1:e)&&o.push(t))}),o}},P.socketURL="/",P.socketMessageEvent="RTCMultiConnection-Message",P.socketCustomEvent="RTCMultiConnection-Custom-Message",P.DetectRTC=DetectRTC,P.setCustomSocketEvent=function(e){e&&(P.socketCustomEvent=e),P.socket&&P.socket.emit("set-custom-socket-event-listener",P.socketCustomEvent)},P.getNumberOfBroadcastViewers=function(e,t){P.socket&&e&&t&&P.socket.emit("get-number-of-users-in-specific-broadcast",e,t)},P.onNumberOfBroadcastViewersUpdated=function(e){P.enableLogs&&P.isInitiator&&console.info("Number of broadcast (",e.broadcastId,") viewers",e.numberOfBroadcastViewers)},P.onUserStatusChanged=function(e,t){P.enableLogs&&!t&&console.info(e.userid,e.status)},P.getUserMediaHandler=we,P.multiPeersHandler=I,P.enableLogs=!0,P.setCustomSocketHandler=function(e){void 0!==n&&(n=e)},P.chunkSize=4e4,P.maxParticipantsAllowed=1e3,P.disconnectWith=I.disconnectWith,P.checkPresence=function(e,o){e=e||P.sessionid,"SSEConnection"!==n.name?P.socket?P.socket.emit("check-presence",e+"",function(e,t,n){P.enableLogs&&console.log("checkPresence.isRoomExist: ",e," roomid: ",t),o(e,t,n)}):P.connectSocket(function(){P.checkPresence(e,o)}):SSEConnection.checkPresence(e,function(e,t,n){if(!P.socket)return e||(P.userid=t),void P.connectSocket(function(){o(e,t,n)});o(e,t)})},P.onReadyForOffer=function(e,t){P.multiPeersHandler.createNewPeer(e,t)},P.setUserPreferences=function(e){return P.dontAttachStream&&(e.dontAttachLocalStream=!0),P.dontGetRemoteStream&&(e.dontGetRemoteStream=!0),e},P.updateExtraData=function(){P.socket.emit("extra-data-updated",P.extra)},P.enableScalableBroadcast=!1,P.maxRelayLimitPerUser=3,P.dontCaptureUserMedia=!1,P.dontAttachStream=!1,P.dontGetRemoteStream=!1,P.onReConnecting=function(e){P.enableLogs&&console.info("ReConnecting with",e.userid,"...")},P.beforeAddingStream=function(e){return e},P.beforeRemovingStream=function(e){return e},P.checkIfChromeExtensionAvailable=Se,"undefined"!=typeof isFirefoxExtensionAvailable&&(P.checkIfChromeExtensionAvailable=isFirefoxExtensionAvailable),P.getChromeExtensionStatus=xe,P.getScreenConstraints=function(n,e){_(P,e)&&(e=!0);var o,i=function(e,t){e||(t=P.modifyScreenConstraints(t),n(e,t))};Te?i(null,{mozMediaSource:"window",mediaSource:"window"}):(o={mandatory:{chromeMediaSource:R,maxWidth:1920Failed to start game'}try{r()}catch(e){}}if(2===e.data.t){var n=e.data.file.split("/"),o=(i=n.pop()).split(".").pop(),i=i.replace(/\#/g,"");Z._FS.createPath("/",n.join("/"),!0,!0);for(var a=m[l].length-1;0<=a;--a)m[l][a]===o.toLowerCase()&&dFailed to start game'}try{r()}catch(e){}}},s=function(){var t=p,n=Z.loading.querySelector(".".concat(T.p3)),e=p.config,o=(e.gameId,e.gameUrl),i=e.system,e=("vbanext"==i&&(i="gba"),o.split("/")),l=e[e.length-1];(l=-1'+s.localization("Control Settings")+'
\n \n
\n
"+s.localization("Press keyboard or gamepad")+"
"+s.localization("Press escape (esc) to clear")):t+="
Press keyboard
"+s.localization("Press escape (esc) to clear"),r.querySelector(".".concat(v.classNames["key-setting-popup"])).innerHTML=t,e.stopPropagation()})})},setCacheDialog:function(){var t=this;t.elements.dialogs.cache.innerHTML='\n \n "),U.call(this,t.elements.dialogs.cache.querySelector(".".concat(v.classNames["btn-cancel"])),"click",function(e){return G(t.elements.dialogs.cache,!0),t.elements.container.focus(),e.stopPropagation(),!1}),U.call(this,t.elements.dialogs.cache.querySelector(".".concat(v.classNames["dialog-title"]," a")),"click",function(e){return m.romdb&&(m.romdb.clear(),t.elements.dialogs.cache.querySelector(".".concat(v.classNames["dialog-content"])).innerHTML='Cheats
\n '+h.localization("Netplay")+'
\n \n \n
\n \n \n \n \n '+h.localization("Room Name")+" \n "+h.localization("Players")+' \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n '+h.localization("Player")+" \n "+h.localization("Name")+" \n \n \n \n 1 \n "+h.localization("Name")+" 1 \n \n \n \n 2 \n "+h.localization("Name")+" 2 \n \n \n \n 3 \n "+h.localization("Name")+" 3 \n \n \n \n \n 4 \n "+h.localization("Name")+' 4 \n \n ";v.players.forEach(function(e,t){var n=null;e?(v.connection.peers[e]?n=v.connection.peers[e].extra:v.connection.userid===e&&(n=v.connection.extra),o+="
",h.elements.widgets.netplay.innerHTML=o},500),n=h.elements.dialogs.netplay.querySelector("#modal-9de6c4e9ce2b9361"),a=h.elements.dialogs.netplay.querySelector("#modal-85cd7a1c543a484a"),o=h.elements.dialogs.netplay.querySelector("#modal-7d8fd50ed642340b"),i=h.elements.dialogs.netplay.querySelector("#modal-5aa765d61d8327de"),l={},v.connection=new Le.a,(e=p.socketUrl).endsWith("/")||(e+="/"),v.connection.socketURL="/",v.connection.socketURL=e,v.connection.socketMessageEvent="emulatorjs-message",v.connection.socketCustomEvent="emulatorjs-custom-message",e=W.info(),v.connection.extra={name:v.playerName,game_id:h.config.gameId,browser_name:e.name,room_name:" ",domain:document.domain},v.connection.socketMessageEvent="netplay",v.connection.enableFileSharing=!0,v.connection.enableLogs=!1,v.connection.session={data:!0},v.connection.sdpConstraints.mandatory={OfferToReceiveAudio:!1,OfferToReceiveVideo:!1},v.connection.onclose=function(e){},v.connection.iceServers=[{urls:"turn:turn.emulatorjs.com:3478",credential:"dSnmrtehverella",username:"ejs"},{urls:["stun:stun.l.google.com:19302","stun:stun1.l.google.com:19302","stun:stun2.l.google.com:19302","stun:stun.l.google.com:19302?transport=udp"]}],v.connection.maxParticipantsAllowed=4,s=v.netPlayInitFrame=0,c=!1,Module.postMainLoop=function(){var e,t;if(v.currentFrame=parseInt(v.currentFrameNum(),10),v.connected)if(s+=1,v.connection.isInitiator)if(1<=s){for(var n=[],o=v.currentFrame-1;o[".concat(i,"] ").concat(o," ").concat(t.room_name," ").concat(t.current,"/").concat(t.max," ").concat(e," "),U.call(p,n.querySelector(".".concat(v.classNames["btn-join-room"])),"click",f),c.appendChild(n)}),c.querySelectorAll("tr").forEach(function(e){r.includes(e.id)||c.removeChild(e)})),v.loadRoomsListTimer=setTimeout(v.loadRoomsList,2e3)}).catch(function(e){console.log("Network Error",e),v.loadRoomsListTimer=setTimeout(v.loadRoomsList,2e3)})},v.openRoom=function(e){v.stopLoadRooms(),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-roomlist"])),!0),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-room"])),!1),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["btn-create-room"])),!0),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["btn-quit"])),!1),v.resetCheat(),G(e.elements.buttons.cheat,!0);var e=e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-room"])),t=e.querySelector("[data-room-password]"),o=(null===v.connection.password?G(t,!0):(G(t,!1),t.querySelector("span").innerText=v.connection.password),e.querySelector("tbody"));o.innerHTML="",e.querySelector("strong").innerText=l.room_name,v.players.forEach(function(e,t){var n=null;e&&(v.connection.peers[e]?n=v.connection.peers[e].extra:v.connection.userid===e&&(n=v.connection.extra),n&&n.name)&&((e=document.createElement("tr")).innerHTML="".concat(t+1," ").concat(n.name," "),o.appendChild(e))})},U.call(this,i.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=i.querySelector(".".concat(v.classNames["netplay-room-password-input"])).value,t=(v.showLoading.call(h),v.connection.password=t,i.getAttribute("data-id"));v.connection.join(t,function(e,t,n){u(e,0,n),e&&i.classList.remove(H({"is-open":!0}))}),e.stopPropagation()}),U.call(this,n.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=(t=n.querySelector(".".concat(v.classNames["netplay-player-name"])).value).replace(/<|>/g,"");n.querySelector(".".concat(v.classNames.modal__errmsg)).innerHTML="",t.trim()&&(v.playerName=t.trim(),v.connection.extra.name=t.trim(),g.close()),e.stopPropagation()}),U.call(this,a.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=(t=a.querySelector(".".concat(v.classNames["netplay-room-name-input"])).value).replace(/<|>/g,""),n=a.querySelector("select[data-max-players] option:checked").value;4<(n=n<2?2:n)&&(n=4);for(var o=0;o