diff --git a/README.md b/README.md index 655f1a9..74f2c49 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,12 @@
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||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(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
'+h.localization("Room Name")+" | \n"+h.localization("Players")+' | \n\n |
\n | \n | \n |
'+h.localization("Player")+" | \n"+h.localization("Name")+" | \n\n |
1 | \n"+h.localization("Name")+" 1 | \n\n |
2 | \n"+h.localization("Name")+" 2 | \n\n |
3 | \n"+h.localization("Name")+" 3 | \n\n |
4 | \n"+h.localization("Name")+' 4 | \n\n |
\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||c").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 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,u=-7,d=n?i-1:0,f=n?-1:1,i=e[t+d];for(d+=f,a=i&(1<<-u)-1,i>>=-u,u+=s;0>=-u,u+=o;0>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:a-1,p=o?1:-1,a=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,r=l):(r=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-r))<1&&(r--,o*=2),2<=(t+=1<=r+u?d/o:d*Math.pow(2,1-u))*o&&(r++,o/=2),l<=r+u?(s=0,r=l):1<=r+u?(s=(t*o-1)*Math.pow(2,i),r+=u):(s=t*Math.pow(2,u-1)*Math.pow(2,i),r=0));8<=i;e[n+f]=255&s,f+=p,s/=256,i-=8);for(r=r<=this._reconnectionAttempts?(u("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1):(e=this.backoff.duration(),u("will wait %dms before reconnect attempt",e),this.reconnecting=!0,t=setTimeout(function(){n.skipReconnect||(u("attempting reconnect"),n.emitAll("reconnect_attempt",n.backoff.attempts),n.emitAll("reconnecting",n.backoff.attempts),n.skipReconnect||n.open(function(e){e?(u("reconnect attempt error"),n.reconnecting=!1,n.reconnect(),n.emitAll("reconnect_error",e.data)):(u("reconnect success"),n.onreconnect())}))},e),this.subs.push({destroy:function(){clearTimeout(t)}}))},p.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)}},function(e,t,n){var r=n(106),s=n(381),c=n(390),n=n(391);t.polling=function(e){var t,n,o=!1,i=!1,a=!1!==e.jsonp;if("undefined"!=typeof location&&(t="https:"===location.protocol,n=(n=location.port)||(t?443:80),o=e.hostname!==location.hostname||n!==e.port,i=e.secure!==t),e.xdomain=o,e.xscheme=i,"open"in new r(e)&&!e.forceJSONP)return new s(e);if(a)return new c(e);throw new Error("JSONP disabled")},t.websocket=n},function(e,t,n){var o=n(107),i=n(75),a=n(51),r=n(76),s=n(152),c=n(77)("engine.io-client:polling"),l=(e.exports=u,null!=new(n(106))({xdomain:!1}).responseType);function u(e){var t=e&&e.forceBase64;l&&!t||(this.supportsBinary=!1),o.call(this,e)}r(u,o),u.prototype.name="polling",u.prototype.doOpen=function(){this.poll()},u.prototype.pause=function(e){var t,n=this;function o(){c("paused"),n.readyState="paused",e()}this.readyState="pausing",this.polling||!this.writable?(t=0,this.polling&&(c("we are currently polling - waiting to pause"),t++,this.once("pollComplete",function(){c("pre-pause polling complete"),--t||o()})),this.writable||(c("we are currently writing - waiting to pause"),t++,this.once("drain",function(){c("pre-pause writing complete"),--t||o()}))):o()},u.prototype.poll=function(){c("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},u.prototype.onData=function(e){var o=this;c("polling got data %s",e),a.decodePayload(e,this.socket.binaryType,function(e,t,n){if("opening"===o.readyState&&o.onOpen(),"close"===e.type)return o.onClose(),!1;o.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():c('ignoring poll - transport state "%s"',this.readyState))},u.prototype.doClose=function(){var e=this;function t(){c("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(c("transport open - closing"),t()):(c("transport not open - deferring close"),this.once("open",t))},u.prototype.write=function(e){function t(){n.writable=!0,n.emit("drain")}var n=this;this.writable=!1;a.encodePayload(e,this.supportsBinary,function(e){n.doWrite(e,t)})},u.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=s()),this.supportsBinary||e.sid||(e.b64=1),e=i.encode(e),this.port&&("https"==t&&443!==Number(this.port)||"http"==t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e}},function(t,e,n){!function(a){var e=Object.prototype.toString,r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===e.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===e.call(File);t.exports=function e(t){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(var n=0,o=t.length;n
':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,"");$._FS.createPath("/",n.join("/"),!0,!0);for(var a=m[l].length-1;0<=a;--a)m[l][a]===o.toLowerCase()&&uFailed to start game'}try{r()}catch(e){}}},s=function(){var t=p,n=$.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){d(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,u=-7,d=n?i-1:0,f=n?-1:1,i=e[t+d];for(d+=f,a=i&(1<<-u)-1,i>>=-u,u+=s;0>=-u,u+=o;0>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:a-1,p=o?1:-1,a=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,r=l):(r=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-r))<1&&(r--,o*=2),2<=(t+=1<=r+u?d/o:d*Math.pow(2,1-u))*o&&(r++,o/=2),l<=r+u?(s=0,r=l):1<=r+u?(s=(t*o-1)*Math.pow(2,i),r+=u):(s=t*Math.pow(2,u-1)*Math.pow(2,i),r=0));8<=i;e[n+f]=255&s,f+=p,s/=256,i-=8);for(r=r<=this._reconnectionAttempts?(u("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1):(e=this.backoff.duration(),u("will wait %dms before reconnect attempt",e),this.reconnecting=!0,t=setTimeout(function(){n.skipReconnect||(u("attempting reconnect"),n.emitAll("reconnect_attempt",n.backoff.attempts),n.emitAll("reconnecting",n.backoff.attempts),n.skipReconnect||n.open(function(e){e?(u("reconnect attempt error"),n.reconnecting=!1,n.reconnect(),n.emitAll("reconnect_error",e.data)):(u("reconnect success"),n.onreconnect())}))},e),this.subs.push({destroy:function(){clearTimeout(t)}}))},p.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)}},function(e,t,n){var r=n(106),s=n(381),c=n(390),n=n(391);t.polling=function(e){var t,n,o=!1,i=!1,a=!1!==e.jsonp;if("undefined"!=typeof location&&(t="https:"===location.protocol,n=(n=location.port)||(t?443:80),o=e.hostname!==location.hostname||n!==e.port,i=e.secure!==t),e.xdomain=o,e.xscheme=i,"open"in new r(e)&&!e.forceJSONP)return new s(e);if(a)return new c(e);throw new Error("JSONP disabled")},t.websocket=n},function(e,t,n){var o=n(107),i=n(75),a=n(51),r=n(76),s=n(152),c=n(77)("engine.io-client:polling"),l=(e.exports=u,null!=new(n(106))({xdomain:!1}).responseType);function u(e){var t=e&&e.forceBase64;l&&!t||(this.supportsBinary=!1),o.call(this,e)}r(u,o),u.prototype.name="polling",u.prototype.doOpen=function(){this.poll()},u.prototype.pause=function(e){var t,n=this;function o(){c("paused"),n.readyState="paused",e()}this.readyState="pausing",this.polling||!this.writable?(t=0,this.polling&&(c("we are currently polling - waiting to pause"),t++,this.once("pollComplete",function(){c("pre-pause polling complete"),--t||o()})),this.writable||(c("we are currently writing - waiting to pause"),t++,this.once("drain",function(){c("pre-pause writing complete"),--t||o()}))):o()},u.prototype.poll=function(){c("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},u.prototype.onData=function(e){var o=this;c("polling got data %s",e),a.decodePayload(e,this.socket.binaryType,function(e,t,n){if("opening"===o.readyState&&o.onOpen(),"close"===e.type)return o.onClose(),!1;o.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():c('ignoring poll - transport state "%s"',this.readyState))},u.prototype.doClose=function(){var e=this;function t(){c("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(c("transport open - closing"),t()):(c("transport not open - deferring close"),this.once("open",t))},u.prototype.write=function(e){function t(){n.writable=!0,n.emit("drain")}var n=this;this.writable=!1;a.encodePayload(e,this.supportsBinary,function(e){n.doWrite(e,t)})},u.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=s()),this.supportsBinary||e.sid||(e.b64=1),e=i.encode(e),this.port&&("https"==t&&443!==Number(this.port)||"http"==t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e}},function(t,e,n){!function(a){var e=Object.prototype.toString,r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===e.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===e.call(File);t.exports=function e(t){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(var n=0,o=t.length;n
':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,"");$._FS.createPath("/",n.join("/"),!0,!0);for(var a=m[l].length-1;0<=a;--a)m[l][a]===o.toLowerCase()&&uFailed to start game'}try{r()}catch(e){}}},s=function(){var t=p,n=$.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){d(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
+![Allan Avatar]
+
+### Co-Owner
+
+***Various Fixes & Additions***
+
+**[![Badge Allan GitHub]][Allan GitHub]**
+
+**[![Badge Allan Website]][Allan Website]**
+
+
+
+
+
+
![Archiver Avatar]
***Documentation Design***
@@ -33,19 +48,7 @@
-
-
-![Allan Avatar]
-***Various Fixes & Additions***
-
-**[![Badge Allan GitHub]][Allan GitHub]**
-
-**[![Badge Allan Website]][Allan Website]**
-
-
-
-
[![Avatar Nekro]][GitHub Nekro]
[![Avatar Grey]][GitHub Grey]