e.rawStream;e.client.peerTrackHandler(e.peerId,e.rawStream)});this.peerConnection.addStream(this.client.localMediaStream.stream);f&&this.peerConnection.createOffer(g=>{e.peerConnection.setLocalDescription(g,()=>{e.client.descriptionHandler(e.peerId,JSON.stringify(g));1!=e.client.peerStateInitial&&(e.client.peerStateInitial=1)},h=>{console.error('Failed to set local description for "'+e.peerId+'"! '+h);2==e.client.peerStateInitial&&(e.client.peerStateInitial=0);e.client.signalDisconnect(e.peerId)})},
g=>{console.error('Failed to set create offer for "'+e.peerId+'"! '+g);2==e.client.peerStateInitial&&(e.client.peerStateInitial=0);e.client.signalDisconnect(e.peerId)});this.peerConnection.addEventListener("connectionstatechange",g=>{"disconnected"===e.peerConnection.connectionState?e.client.signalDisconnect(e.peerId):"connected"===e.peerConnection.connectionState?1!=e.client.peerState&&(e.client.peerState=1):"failed"===e.peerConnection.connectionState&&(2==e.client.peerState&&(e.client.peerState=
0),e.client.signalDisconnect(e.peerId))})}disconnect(){this.peerConnection.close()}mute(a){this.rawStream.getAudioTracks()[0].enabled=!a}setRemoteDescription(a){constb=this;try{constc=JSON.parse(a);this.peerConnection.setRemoteDescription(c,()=>{"offer"==c.type&&b.peerConnection.createAnswer(f=>{b.peerConnection.setLocalDescription(f,()=>{b.client.descriptionHandler(b.peerId,JSON.stringify(f));1!=b.client.peerStateDesc&&(b.client.peerStateDesc=1)},e=>{console.error('Failed to set local description for "'+
b.peerId+'"! '+e);2==b.client.peerStateDesc&&(b.client.peerStateDesc=0);b.client.signalDisconnect(b.peerId)})},f=>{console.error('Failed to create answer for "'+b.peerId+'"! '+f);2==b.client.peerStateDesc&&(b.client.peerStateDesc=0);b.client.signalDisconnect(b.peerId)})},f=>{console.error('Failed to set remote description for "'+b.peerId+'"! '+f);2==b.client.peerStateDesc&&(b.client.peerStateDesc=0);b.client.signalDisconnect(b.peerId)})}catch(c){console.error('Failed to parse remote description for "'+
b.peerId+'"! '+c),2==b.client.peerStateDesc&&(b.client.peerStateDesc=0),b.client.signalDisconnect(b.peerId)}}addICECandidate(a){try{this.peerConnection.addIceCandidate(newRTCIceCandidate(JSON.parse(a))),1!=this.client.peerStateIce&&(this.client.peerStateIce=1)}catch(b){console.error('Failed to parse ice candidate for "'+this.peerId+'"! '+b),2==this.client.peerStateIce&&(this.client.peerStateIce=0),this.client.signalDisconnect(this.peerId)}}}classd{constructor(){this.ICEServers=[];this.hasInit=!1;
{d.peerConnection.setLocalDescription(b,()=>{d.descriptionHandler(JSON.stringify(b))},c=>{console.error("Failed to set local description! "+c);d.readyState=-1;d.signalRemoteDisconnect(!1)})},b=>{console.error("Failed to set create offer! "+b);d.readyState=-1;d.signalRemoteDisconnect(!1)});this.peerConnection.addEventListener("connectionstatechange",b=>{"disconnected"===d.peerConnection.connectionState?d.signalRemoteDisconnect(!1):"connected"===d.peerConnection.connectionState?d.readyState=2:"failed"===
1!=b.client.peerStateDesc&&(b.client.peerStateDesc=1)},e=>{console.error('Failed to set local description for "'+b.peerId+'"! '+e);2==b.client.peerStateDesc&&(b.client.peerStateDesc=0);b.client.signalRemoteDisconnect(b.peerId)})},f=>{console.error('Failed to create answer for "'+b.peerId+'"! '+f);2==b.client.peerStateDesc&&(b.client.peerStateDesc=0);b.client.signalRemoteDisconnect(b.peerId)})},f=>{console.error('Failed to set remote description for "'+b.peerId+'"! '+f);2==b.client.peerStateDesc&&
(b.client.peerStateDesc=0);b.client.signalRemoteDisconnect(b.peerId)})}catch(c){console.error('Failed to parse remote description for "'+b.peerId+'"! '+c),2==b.client.peerStateDesc&&(b.client.peerStateDesc=0),b.client.signalRemoteDisconnect(b.peerId)}}addICECandidate(a){try{constb=JSON.parse(a);for(letcofb)this.peerConnection.addIceCandidate(newRTCIceCandidate(c));1!=this.client.peerStateIce&&(this.client.peerStateIce=1)}catch(b){console.error('Failed to parse ice candidate for "'+this.peerId+