Advertisement
Guest User

Untitled

a guest
Nov 11th, 2016
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     var n = this,
  3.         i = function() {};
  4.     if (function(t, n) {
  5.             var i = "VI_WEBRTC_STATE_IDLE",
  6.                 o = "VI_WEBRTC_STATE_WS_CONNECTING",
  7.                 s = "VI_WEBRTC_STATE_WS_CONNECTED",
  8.                 a = "VI_WEBRTC_STATE_WS_CONNECTED",
  9.                 r = t.VI_CALL_STATE_ALERTING = "ALERTING",
  10.                 c = t.VI_CALL_STATE_PROGRESSING = "PROGRESSING",
  11.                 l = t.VI_CALL_STATE_CONNECTED = "CONNECTED",
  12.                 d = t.VI_CALL_STATE_ENDED = "ENDED",
  13.                 h = 6e3,
  14.                 u = 1e4;
  15.             t.ZingayaAPI = function(t, n) {
  16.                 function f(e) {
  17.                     return J && (e.sdp = e.sdp.replace(/(a=mid:video.*\r\n)/g, "$1b=AS:" + J + "\r\n")), e
  18.                 }
  19.  
  20.                 function p() {
  21.                     B && (clearTimeout(B), B = null, G = setTimeout(Te, w))
  22.                 }
  23.                 var C, m, g, v, y, S, R, T, I, E, w = 3e4,
  24.                     M = [],
  25.                     O = [],
  26.                     A = !1 !== n,
  27.                     P = function() {
  28.                         return M.length ? M.pop() : document.createElement("audio")
  29.                     },
  30.                     b = function(e) {
  31.                         m(e, null), M.push(e)
  32.                     },
  33.                     N = function() {
  34.                         return O.length ? O.pop() : document.createElement("video")
  35.                     },
  36.                     U = function(e) {
  37.                         m(e, null), O.push(e)
  38.                     },
  39.                     _ = function(e) {
  40.                         if (e) {
  41.                             if (e.audioTracks) return e.audioTracks;
  42.                             if (e.getAudioTracks) return e.getAudioTracks()
  43.                         }
  44.                         return null
  45.                     },
  46.                     L = function(e) {
  47.                         if (e) {
  48.                             if (e.videoTracks) return e.videoTracks;
  49.                             if (e.getVideoTracks) return e.getVideoTracks()
  50.                         }
  51.                         return null
  52.                     },
  53.                     F = function(e, t) {
  54.                         if (e)
  55.                             for (var n in e) e[n].enabled = t
  56.                     },
  57.                     D = t === !0 ? !0 : !1,
  58.                     V = "wss",
  59.                     x = null,
  60.                     z = i,
  61.                     k = [],
  62.                     H = !1,
  63.                     W = !1,
  64.                     X = !0,
  65.                     j = null,
  66.                     G = null,
  67.                     B = null,
  68.                     q = 1,
  69.                     J = null;
  70.                 this.setVideoBandwidth = function(e) {
  71.                     J = e
  72.                 };
  73.                 var K, $, Z = function() {
  74.                         y = "undefined" != typeof webkitRTCPeerConnection, S = "undefined" != typeof mozRTCPeerConnection, R = "undefined" != typeof MediaStreamTrack && "undefined" != typeof MediaStreamTrack.getSources || navigator.mediaDevices && navigator.mediaDevices.enumerateDevices, T = null, I = null, E = null, S && (v = mozRTCIceCandidate, g = mozRTCPeerConnection, C = navigator.mozGetUserMedia.bind(navigator), m = function(e, t) {
  75.                             t ? (e.mozSrcObject = t, e.load(), e.play()) : (e.mozSrcObject = null, e.load())
  76.                         }), y && (g = webkitRTCPeerConnection, v = RTCIceCandidate, C = navigator.webkitGetUserMedia.bind(navigator), m = function(e, t) {
  77.                             t ? (e.src = URL.createObjectURL(t), e.load(), e.play()) : e.pause()
  78.                         })
  79.                     },
  80.                     Y = null,
  81.                     Q = {},
  82.                     ee = {},
  83.                     te = 0,
  84.                     ne = function(e) {
  85.                         "function" == typeof this.writeLog && this.writeLog(e)
  86.                     }.bind(this),
  87.                     ie = function(e) {
  88.                         "function" == typeof this.writeTrace && this.writeTrace(e)
  89.                     }.bind(this),
  90.                     oe = function(e) {
  91.                         return z != a ? (ne(e + " called while in state " + z), !1) : !0
  92.                     },
  93.                     se = {
  94.                         year: "numeric",
  95.                         month: "numeric",
  96.                         day: "numeric"
  97.                     };
  98.                 this.writeLog = function(e) {
  99.                     BXIM.webrtc.phoneLog("VI WebRTC: " + (new Date).toLocaleTimeString("en-US", se) + " " + e)
  100.                 }, this.writeTrace = function(e) {
  101.                     BXIM.webrtc.phoneLog("VI WebRTC: " + (new Date).toLocaleTimeString("en-US", se) + " " + e)
  102.                 }, this.onConnectionEstablished = null, this.onConnectionFailed = null, this.onConnectionClosed = null, this.onLoginSuccessful = null, this.onLoginFailed = null, this.onIncomingCall = null, this.onCallRinging = null, this.onCallMediaStarted = null, this.onCallConnected = null, this.onCallEnded = null, this.onCallFailed = null, this.onSIPInfoReceived = null, this.onInstantMessageReceived = null, this.onTransferComplete = null, this.onTransferFailed = null, this.onNetStatsReceived = null, this.onRTCStatsCollected = null, this.onHandleRoster = null, this.onHandleRosterPresence = null, this.onHandleMessage = null, this.onHandleSelfPresence = null, this.onHandleChatState = null, this.onHandleMessageEvent = null, this.onHandleMessageRemoved = null, this.onHandleMessageModified = null, this.onHandleSubscription = null, this.onHandleRosterItem = null, this.onCallRemoteFunctionError = null, this.onIMError = null, this.onIMRosterError = null, this.onMUCError = null, this.onMUCRoomCreation = null, this.onMUCSubject = null, this.onMUCInfo = null, this.onMUCMessage = null, this.onMUCInvitation = null, this.onMUCInviteDecline = null, this.onMUCParticipantPresence = null, this.onMUCNewParticipant = null, this.onMUCParticipantExit = null, this.onMUCRooms = null, this.onMUCParticipants = null, this.onMUCBanList = null, this.onMUCHistory = null, this.onMUCMessageModified = null, this.onMUCMessageRemoved = null, this.onMUCChatState = null, this.onHistory = null, this.onUCConnected = null, this.onUCDisconnected = null, this.onVoicemail = null, this.onCheckComplete = null, this.onRemoteScreenCaptureStarted = null, this.onCallICETimeout = null;
  103.                 var ae = function(e, t) {
  104.                         "function" == typeof this.onRTCStatsCollected && this.onRTCStatsCollected(e, t)
  105.                     }.bind(this),
  106.                     re = function(e, t) {
  107.                         "function" == typeof this.onRemoteScreenCaptureStarted && this.onRemoteScreenCaptureStarted(e, t)
  108.                     }.bind(this),
  109.                     ce = function(e) {
  110.                         "function" == typeof this.onCallICETimeout && this.onCallICETimeout(e)
  111.                     }.bind(this),
  112.                     le = function(e) {
  113.                         var t = {};
  114.                         for (var n in e)("X-" == n.substring(0, 2) || "VI-CallData" == n) && (t[n] = e[n]);
  115.                         return t
  116.                     },
  117.                     de = function(e) {
  118.                         for (var t in e)
  119.                             if ("X-DirectCall" == t) return "true" == e[t] ? !0 : !1;
  120.                         return !1
  121.                     },
  122.                     he = function() {
  123.                         te = 0;
  124.                         for (var e in Q) te++
  125.                     },
  126.                     ue = function(e) {
  127.                         Q[e.id()] = e, he()
  128.                     },
  129.                     fe = function(e) {
  130.                         delete Q[e], he()
  131.                     }.bind(this);
  132.                 Z();
  133.                 var pe = function(e) {
  134.                         for (var t = "", n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", i = 0; e > i; i++) t += n.charAt(Math.floor(Math.random() * n.length));
  135.                         return t
  136.                     },
  137.                     Ce = function() {};
  138.                 this.muteMicrophone = function(e) {
  139.                     H = e, Y && F(_(Y), !e)
  140.                 }, this.sendVideo = function(e) {
  141.                     X = e, Y && F(L(Y), e)
  142.                 }, this.mutePlayback = function(e) {
  143.                     W = e;
  144.                     for (var t in ee) ee[t].updateSpeakerMuteState()
  145.                 }, this.setPlaybackVolume = function(e) {
  146.                     q = e;
  147.                     for (var t in ee) ee[t].setPlaybackVolume(e)
  148.                 }, this.getCalls = function() {
  149.                     var e = [];
  150.                     for (var t in Q) e.push(t);
  151.                     return e
  152.                 }, this.setLocalVideoSink = function(e) {
  153.                     K = e, Y && m(e, Y)
  154.                 }, this.setRemoteSinksContainerId = function(e) {
  155.                     $ = e
  156.                 }, this.stopLocalStream = function() {
  157.                     Y && (Y.active && Y.getTracks().forEach(function(e) {
  158.                         e.stop()
  159.                     }), Y = null)
  160.                 }.bind(this), this.destroy = function() {
  161.                     this.disconnect(), this.stopLocalStream()
  162.                 }.bind(this), this.disconnect = function() {
  163.                     x && (Re(), x.onclose = null, x.close(), ve())
  164.                 }, this.useAudioSource = function(e, t, n) {
  165.                     R && (T = e, this.requestMedia(D, t, n, !0))
  166.                 }.bind(this), this.useVideoSource = function(e, t, n) {
  167.                     R && (I = e, this.requestMedia(!0, t, n, !0))
  168.                 }.bind(this), this.setConstraints = function(e, t, n, i) {
  169.                     E = e, i === !0 && this.requestMedia(D, t, n, D)
  170.                 }.bind(this), this.requestMedia = function(e, t, n, i) {
  171.                     var o, s = navigator.mediaDevices && navigator.mediaDevices.enumerateDevices && "undefined" == typeof MediaStreamTrack && "undefined" == typeof MediaStreamTrack.getSources ? "deviceId" : "sourceId";
  172.                     null === T && null === I ? o = {
  173.                         audio: !0,
  174.                         video: e === !0 ? !0 : !1
  175.                     } : null !== T && null !== I ? o = "sourceId" == s ? {
  176.                         audio: {
  177.                             mandatory: {
  178.                                 sourceId: T
  179.                             }
  180.                         },
  181.                         video: {
  182.                             mandatory: {
  183.                                 sourceId: I
  184.                             }
  185.                         }
  186.                     } : {
  187.                         audio: {
  188.                             deviceId: {
  189.                                 exact: T
  190.                             }
  191.                         },
  192.                         video: {
  193.                             deviceId: {
  194.                                 exact: I
  195.                             }
  196.                         }
  197.                     } : null !== T ? o = "sourceId" == s ? {
  198.                         audio: {
  199.                             mandatory: {
  200.                                 sourceId: T
  201.                             }
  202.                         },
  203.                         video: e === !0 ? !0 : !1
  204.                     } : {
  205.                         audio: {
  206.                             deviceId: {
  207.                                 exact: T
  208.                             }
  209.                         },
  210.                         video: e === !0 ? !0 : !1
  211.                     } : null !== I && (o = "sourceId" == s ? {
  212.                         audio: !0,
  213.                         video: {
  214.                             mandatory: {
  215.                                 sourceId: I
  216.                             }
  217.                         }
  218.                     } : {
  219.                         audio: !0,
  220.                         video: {
  221.                             deviceId: {
  222.                                 exact: I
  223.                             }
  224.                         }
  225.                     }), null !== E && (o.video = {}, "undefined" != typeof E.mandatory && (o.video.mandatory = E.mandatory), "undefined" != typeof E.optional ? (o.video.optional = E.optional, null !== I && ("sourceId" == s ? o.video.mandatory.sourceId = I : o.video.deviceId = {
  226.                         exact: I
  227.                     })) : null !== I && ("sourceId" == s ? o.video.mandatory.sourceId = I : o.video.deviceId = {
  228.                         exact: I
  229.                     })), Y && i && this.stopLocalStream(), "undefined" != typeof o.video.mandatory && "undefined" != typeof o.video.mandatory.chromeMediaSourceId && (o.audio = !1), C(o, function(e) {
  230.                         this.gUM_success(e, t)
  231.                     }.bind(this), function(e) {
  232.                         this.gUM_error(e, n)
  233.                     }.bind(this))
  234.                 }.bind(this), this.gUM_error = function(e, t) {
  235.                     ne("Media access rejected: " + e.name), "function" == typeof t && t(e.name)
  236.                 }.bind(this), this.gUM_success = function(e, t) {
  237.                     var n;
  238.                     if (Y) {
  239.                         Y.active && Y.getTracks().forEach(function(e) {
  240.                             e.stop()
  241.                         });
  242.                         for (n in ee) ee[n].setLocalStream(null)
  243.                     }
  244.                     ne("Media access granted"), Y = e, F(_(Y), !H), K && m(K, e);
  245.                     for (n in ee) ee[n].setLocalStream(Y);
  246.                     "function" == typeof t && t();
  247.                     for (n in Ie) Ee(n, Ie[n]);
  248.                     Ie = {}
  249.                 }.bind(this), this.shareScreen = function() {
  250.                     "undefined" != typeof getScreenId ? getScreenId(function(e, t, n) {
  251.                         C(n, function(e) {
  252.                             j = e;
  253.                             for (var t in ee) ee[t].isDirect() && ee[t].addScreenSharing(j)
  254.                         }, function(e) {
  255.                             ne(e)
  256.                         })
  257.                     }) : ne("No screensharing extension is available")
  258.                 }, this.getRemoteParty = function(e) {
  259.                     return Q[e] ? Q[e].getRemoteParty() : null
  260.                 }, this.getCallState = function(e) {
  261.                     return Q[e] ? Q[e].getState() : null
  262.                 }, this.setCallActive = function(e, t) {
  263.                     return Q[e] ? (t ? this.unholdCall(e) : this.holdCall(e), Q[e].setStreamsActive(t)) : void 0
  264.                 }, this.isCallActive = function(e) {
  265.                     return Q[e] ? Q[e].streamsAreActive() : !1
  266.                 }, this.connectTo = function(e, t, n, s) {
  267.                     if (z == i) try {
  268.                         x = new WebSocket(V + "://" + e + "/" + (s || "platform") + "?version=2&client=" + (S ? "firefox" : "chrome") + "&referrer=" + encodeURIComponent(t) + "&extra=" + encodeURIComponent(n) + "&video=" + (D === !0 ? "true" : "false") + "&q=" + pe(12)), z = o, x.onopen = Se, x.onclose = Re, x.onerror = ye, x.onmessage = Oe
  269.                     } catch (a) {
  270.                         ne("WebSocket Error: " + a)
  271.                     } else ne("Error: called connectTo while in state " + z)
  272.                 }.bind(this), this.startPreFlightCheck = function(e, t) {
  273.                     oe("__startPreFlightCheck") && Ne("__startPreFlightCheck", [!!e, !!t])
  274.                 }, this.login = function(e, t, n) {
  275.                     oe("login") && Ne("login", [e, t, n ? n : null])
  276.                 }, this.loginStage2 = function(e, t, n) {
  277.                     oe("loginStage2") && Ne("loginStage2", [e, t, n ? n : null])
  278.                 }, this.loginGenerateOneTimeKey = function(e) {
  279.                     oe("loginGenerateOneTimeKey") && Ne("loginGenerateOneTimeKey", [e])
  280.                 }, this.loginUsingOneTimeKey = function(e, t, n) {
  281.                     oe("loginUsingOneTimeKey") && Ne("loginUsingOneTimeKey", [e, t, n ? n : null])
  282.                 }, this.setOperatorACDStatus = function(e) {
  283.                     oe("setOperatorACDStatus") && Ne("setOperatorACDStatus", [e])
  284.                 }, this.callTo = function(e, t, n, i) {
  285.                     var o = pe(36);
  286.                     n = le("undefined" == typeof n ? {} : n);
  287.                     var s = new Pe(o, c, e, "");
  288.                     if (s.setHeaders(n), ue(s), de(n)) {
  289.                         var a = we(o, !0);
  290.                         a.outgoingCall()
  291.                     } else Ne("createCall", [-1, e, t, o, null, null, n, i]);
  292.                     return o
  293.                 }, this.transferCall = function(e, t) {
  294.                     for (var n = [e, t], i = 0; i < n.length; i++) {
  295.                         var o = Q[n[i]];
  296.                         if (!o) return void ne("ERROR: trying to transfer unknown call " + o.id());
  297.                         if (o.getState() != l) return void ne("ERROR: trying to transfer call " + o.id() + " in state " + o.getState())
  298.                     }
  299.                     Ne("transferCall", [e, t])
  300.                 }, this.hangupCall = function(e, t) {
  301.                     var n = Q[e];
  302.                     n ? n.getState() == r ? Ne("rejectCall", [e, !0, le(t)]) : Ne("disconnectCall", [e, le(t)]) : ne("ERROR: trying to hangup unknown call " + e)
  303.                 }, this.rejectCall = function(e, t, n) {
  304.                     var i = Q[e];
  305.                     i ? i.getState() == r ? Ne("rejectCall", [e, !0, le(n)]) : ne("ERROR: trying to reject call " + e + " in state " + i.getState()) : ne("ERROR: trying to reject unknown call " + e)
  306.                 }, this.answerCall = function(e, t) {
  307.                     var n = Q[e];
  308.                     if (n)
  309.                         if (n.getState() == r)
  310.                             if (de(n.getHeaders())) {
  311.                                 var i = n.getPeerConnection();
  312.                                 i.createAnswer()
  313.                             } else Ne("acceptCall", [e, le(t)]);
  314.                     else ne("ERROR: trying to answer call " + e + " in state " + n.getState());
  315.                     else ne("ERROR: trying to answer unknown call " + e)
  316.                 }, this.sendDigit = function(e, t) {
  317.                     var n = Q[e];
  318.                     n ? n.getState() == l ? Ne("sendDTMF", [e, t]) : ne("ERROR: trying to send digit to call " + e + " in state " + n.getState()) : ne("ERROR: trying to send digit to unknown call " + e)
  319.                 }, this.holdCall = function(e) {
  320.                     var t = Q[e];
  321.                     t ? t.getState() == l ? Ne("hold", [e]) : ne("ERROR: trying to hold call " + e + " in state " + t.getState()) : ne("ERROR: trying to hold unknown call " + e)
  322.                 }, this.unholdCall = function(e) {
  323.                     var t = Q[e];
  324.                     t ? t.getState() == l ? Ne("unhold", [e]) : ne("ERROR: trying to unhold call " + e + " in state " + t.getState()) : ne("ERROR: trying to unhold unknown call " + e)
  325.                 }, this.voicemailPromptFinished = function(e) {
  326.                     var t = Q[e];
  327.                     t ? Ne("promptFinished", [e]) : ne("ERROR: trying to record voicemail for unknown call " + e)
  328.                 }, this.sendSIPInfo = function(e, t, n, i, o) {
  329.                     var s = Q[e];
  330.                     s ? s.getState() == l || s.getState() == r || s.getState() == c ? Ne("sendSIPInfo", [e, t, n, i, le(o)]) : ne("ERROR: trying to send SIP Info to call " + e + " in state " + s.getState()) : ne("ERROR: trying to send SIP Info to unknown call " + e)
  331.                 };
  332.                 var me = this.sendSIPInfo.bind(this);
  333.                 this.setDesiredVideoBandwidth = function(e) {
  334.                     oe("setDesiredVideoBandwidth") && Ne("setDesiredVideoBandwidth", [e])
  335.                 }, this.sendInstantMessage = function(e, t) {
  336.                     this.sendSIPInfo(e, "application", "zingaya-im", t, {})
  337.                 }, this.sendTextMessage = function(e, t, n) {
  338.                     oe("sendMessage") && Ne("sendMessage", [e, t, n])
  339.                 }, this.editTextMessage = function(e, t, n) {
  340.                     oe("editMessage") && Ne("editMessage", [e, t, n])
  341.                 }, this.removeTextMessage = function(e, t) {
  342.                     oe("removeMessage") && Ne("removeMessage", [e, t])
  343.                 }, this.sendStatus = function(e, t) {
  344.                     oe("sendStatus") && Ne("sendStatus", [e, t])
  345.                 }, this.sendChatState = function(e, t) {
  346.                     oe("sendChatState") && Ne("sendChatState", [e, t])
  347.                 }, this.raiseMessageEvent = function(e, t, n) {
  348.                     oe("raiseMessageEvent") && Ne("raiseMessageEvent", [e, t, n])
  349.                 }, this.addRoster = function(e, t, n) {
  350.                     oe("addRoster") && Ne("addRoster", [e, t, n])
  351.                 }, this.addRosterItemGroup = function(e, t) {
  352.                     oe("addRosterItemGroup") && Ne("addRosterItemGroup", [e, t])
  353.                 }, this.delRosterItemGroup = function(e, t) {
  354.                     oe("delRosterItemGroup") && Ne("delRosterItemGroup", [e, t])
  355.                 }, this.moveRosterItemGroup = function(e, t, n) {
  356.                     oe("moveRosterItemGroup") && Ne("moveRosterItemGroup", [e, t, n])
  357.                 }, this.renameRosterItem = function(e, t) {
  358.                     oe("renameRosterItem") && Ne("renameRosterItem", [e, t])
  359.                 }, this.removeRoster = function(e) {
  360.                     oe("removeRoster") && Ne("removeRoster", [e])
  361.                 }, this.joinMUC = function(e, t, n) {
  362.                     oe("joinMUC") && Ne("joinMUC", [e, t, n])
  363.                 }, this.leaveMUC = function(e, t) {
  364.                     oe("leaveMUC") && Ne("leaveMUC", [e, t])
  365.                 }, this.sendMUCMessage = function(e, t, n) {
  366.                     oe("sendMUCMessage") && Ne("sendMUCMessage", [e, t, n])
  367.                 }, this.editMUCMessage = function(e, t, n) {
  368.                     oe("editMUCMessage") && Ne("editMUCMessage", [e, t, n])
  369.                 }, this.removeMUCMessage = function(e, t) {
  370.                     oe("removeMUCMessage") && Ne("removeMUCMessage", [e, t])
  371.                 }, this.inviteMUC = function(e, t, n) {
  372.                     oe("inviteMUC") && Ne("inviteMUC", [e, t, n])
  373.                 }, this.declineMUCinvitation = function(e, t, n) {
  374.                     oe("declineMUCinvitation") && Ne("declineMUCinvitation", [e, t, n])
  375.                 }, this.ucReconnect = function() {
  376.                     oe("ucReconnect") && Ne("ucReconnect", [])
  377.                 }, this.requestHistory = function(e, t, n, i) {
  378.                     "undefined" == typeof n && (n = !1), "undefined" == typeof i && (i = 100), "undefined" == typeof t && (t = ""), oe("requestHistory") && Ne("requestHistory", [e, t, n, i])
  379.                 }, this.requestMUCHistory = function(e, t, n, i) {
  380.                     "undefined" == typeof n && (n = !1), "undefined" == typeof i && (i = 100), "undefined" == typeof t && (t = ""), oe("requestMUCHistory") && Ne("requestMUCHistory", [e, t, n, i])
  381.                 }, this.setSubject = function(e, t) {
  382.                     oe("setSubject") && Ne("setSubject", [e, t])
  383.                 }, this.sendMUCChatState = function(e, t) {
  384.                     oe("sendMUCChatState") && Ne("sendMUCChatState", [e, t])
  385.                 }, this.kickMUCUser = function(e, t, n) {
  386.                     oe("kickMUCUser") && Ne("kickMUCUser", [e, t, n])
  387.                 }, this.banMUCUser = function(e, t, n) {
  388.                     oe("banMUCUser") && Ne("banMUCUser", [e, t, n])
  389.                 }, this.unbanMUCUser = function(e, t, n) {
  390.                     oe("unbanMUCUser") && Ne("unbanMUCUser", [e, t, n])
  391.                 }, this.getVideoElementId = function(e) {
  392.                     var t = Q[e];
  393.                     return t ? t.getVideoElementId() : void ne("ERROR: No such call " + e)
  394.                 }, this.getAudioElementId = function(e) {
  395.                     var t = Q[e];
  396.                     return t ? t.getAudioElementId() : void ne("ERROR: No such call " + e)
  397.                 }, this.getStats = function(e, t) {
  398.                     var n = ee[e];
  399.                     n && n.getStats(t)
  400.                 };
  401.                 var ge, ve = function() {
  402.                         for (var e in ee) ee[e].close();
  403.                         ee = {}, Q = {}, te = 0, G && clearTimeout(G), B && clearTimeout(B)
  404.                     },
  405.                     ye = function(e) {
  406.                         x.onclose = null, ne("WS error: " + e);
  407.                         var t = z == a,
  408.                             n = t ? this.onConnectionClosed : this.onConnectionFailed;
  409.                         z = i, ve(), "function" == typeof n && n(e)
  410.                     }.bind(this),
  411.                     Se = function() {
  412.                         z = s, ne("WS connected")
  413.                     }.bind(this),
  414.                     Re = function() {
  415.                         ne("WS closed");
  416.                         var e = z == a,
  417.                             t = e ? this.onConnectionClosed : this.onConnectionFailed;
  418.                         z = i, ve(), "function" == typeof t && t("Connection closed")
  419.                     }.bind(this),
  420.                     Te = function() {
  421.                         G = null, Ne("__ping", []), B = setTimeout(function() {
  422.                             if (te > 0) return void p();
  423.                             B = null, ne("WS closed");
  424.                             var e = z == a,
  425.                                 t = e ? this.onConnectionClosed : this.onConnectionFailed;
  426.                             z = i, ve(), "function" == typeof t && t("Connection closed")
  427.                         }.bind(this), w)
  428.                     }.bind(this),
  429.                     Ie = {},
  430.                     Ee = function(e, t) {
  431.                         var n = we(e, !1);
  432.                         n.start(t)
  433.                     },
  434.                     we = function(e, t) {
  435.                         BXIM.webrtc.phoneLog("createPeerConnection2 invoked"), ee[e] && ee[e].close();
  436.                         var n = new be(e, t);
  437.                         Q[e] && n.setStreamsActive(Q[e].streamsAreActive()), ee[e] = n, n.setLocalStream(Y), j && n.setScreenSharingStream(j);
  438.                         var i = Q[e];
  439.                         return i && (Q[e].setPeerConnection(n), n.setCall(i)), ee[e]
  440.                     },
  441.                     Me = null;
  442.                 ge = {
  443.                     __createPC: function(e, t) {
  444.                         !A || Y || "__default" == e ? Ee(e, t) : Ie[e] = t
  445.                     },
  446.                     __destroyPC: function(e) {
  447.                         ee[e] && (ee[e].close(), delete ee[e]), delete Ie[e]
  448.                     },
  449.                     __onPCStats: function(e, t) {
  450.                         ee[e] && "function" == typeof this.onNetStatsReceived && this.onNetStatsReceived(t)
  451.                     },
  452.                     __pong: function() {
  453.                         p()
  454.                     },
  455.                     __connectionSuccessful: function() {
  456.                         z == s && (z = a, "function" == typeof this.onConnectionEstablished && this.onConnectionEstablished(), G = setTimeout(Te, w))
  457.                     },
  458.                     loginSuccessful: function(e, t) {
  459.                         t && (Me = t.iceConfig), "function" == typeof this.onLoginSuccessful && this.onLoginSuccessful(e, t)
  460.                     },
  461.                     loginFailed: function(e, t) {
  462.                         "function" == typeof this.onLoginFailed && this.onLoginFailed({
  463.                             errorCode: e,
  464.                             oneTimeKey: t
  465.                         })
  466.                     },
  467.                     handleConnectionConnected: function(e, t, n) {
  468.                         var i = Q[e];
  469.                         if (i)
  470.                             if (i.canStartSendingCandidates(), i.getState() == c || i.getState() == r) {
  471.                                 if (i.setState(l), "undefined" == typeof n);
  472.                                 else {
  473.                                     var o = i.getPeerConnection();
  474.                                     o.onConnectionConnected(n)
  475.                                 }
  476.                                 "function" == typeof this.onCallConnected && this.onCallConnected(e, t)
  477.                             } else ne("WARNING: received handleConnectionConnected for call: " + e + " in invalid state: " + i.getState());
  478.                         else ne("WARNING: received handleConnectionConnected for unknown call: " + e)
  479.                     },
  480.                     stopRinging: function(e) {
  481.                         var t = Q[e];
  482.                         t ? (t.canStartSendingCandidates(), "function" == typeof this.onCallMediaStarted && this.onCallMediaStarted(e)) : ne("WARNING: received stopRinging for unknown call: " + e)
  483.                     },
  484.                     handleConnectionDisconnected: function(e, t) {
  485.                         var n = Q[e];
  486.                         n ? (n.setState(d), "function" == typeof this.onCallEnded && this.onCallEnded(e, t), fe(e)) : ne("WARNING: received handleConnectionDisconnected for unknown call: " + e)
  487.                     },
  488.                     handleConnectionFailed: function(e, t, n, i) {
  489.                         var o = Q[e];
  490.                         o ? o.getState() == c ? (o.setState(d), "function" == typeof this.onCallFailed && this.onCallFailed(e, t, n, i), fe(e)) : ne("WARNING: received handleConnectionFailed for call: " + e + " in invalid state: " + o.getState()) : ne("WARNING: received handleConnectionFailed for unknown call: " + e)
  491.                     },
  492.                     handleRingOut: function(e) {
  493.                         var t = Q[e];
  494.                         t ? (t.canStartSendingCandidates(), t.getState() == c ? "function" == typeof this.onCallRinging && this.onCallRinging(e) : ne("WARNING: received handleRingOut for call: " + e + " in invalid state: " + t.getState())) : ne("WARNING: received handleRingOut for unknown call: " + e)
  495.                     },
  496.                     handleIncomingConnection: function(e, t, n, i, o) {
  497.                         var s = new Pe(e, r, t, n);
  498.                         if (s.setHeaders(i), ue(s), de(i)) {
  499.                             var a = we(e, !0);
  500.                             a.onIncomingCall(o)
  501.                         } else ee[e] && s.setPeerConnection(ee[e]);
  502.                         "function" == typeof this.onIncomingCall ? this.onIncomingCall(e, t, n, i) : (this.rejectCall(e, 486), ne("WARNING: Received incoming call while no handler was specified"))
  503.                     },
  504.                     handleSIPInfo: function(e, t, n, i, o) {
  505.                         var s = Q[e];
  506.                         if (s)
  507.                             if (s.getState() == l || s.getState() == c || s.getState() == r)
  508.                                 if ("application" == t && "zingaya-im" == n) "function" == typeof this.onInstantMessageReceived && this.onInstantMessageReceived(e, i);
  509.                                 else if ("voximplant" == t && "sdpfrag" == n) {
  510.                             cands = JSON.parse(i);
  511.                             var a = s.getPeerConnection();
  512.                             for (var d in cands) a.addRemoteCandidate(cands[d][0], cands[d][1])
  513.                         } else if ("vi" == t && "sdpoffer" == n) {
  514.                             var a = s.getPeerConnection();
  515.                             a.setRemoteSDP(!0, i, o["X-ScreenStreamId"])
  516.                         } else if ("vi" == t && "sdpanswer" == n) {
  517.                             var a = s.getPeerConnection();
  518.                             a.setRemoteSDP(!1, i, o["X-ScreenStreamId"])
  519.                         } else "function" == typeof this.onSIPInfoReceived && this.onSIPInfoReceived(e, t + "/" + n, i, o);
  520.                         else ne("WARNING: received handleSIPInfo for call: " + e + " in invalid state: " + s.getState());
  521.                         else ne("WARNING: received handleSIPInfo for unknown call: " + e)
  522.                     },
  523.                     handleSipEvent: function() {},
  524.                     handleTransferStarted: function() {},
  525.                     handleTransferComplete: function(e) {
  526.                         var t = Q[e];
  527.                         t ? this.onTransferComplete && this.onTransferComplete(e) : ne("WARNING: received handleTransferComplete for unknown call: " + e)
  528.                     },
  529.                     handleTransferFailed: function(e) {
  530.                         var t = Q[e];
  531.                         t ? this.onTransferFailed && this.onTransferFailed(e) : ne("WARNING: received handleTransferFailed for unknown call: " + e)
  532.                     },
  533.                     handleRoster: function(e) {
  534.                         ie("handleRoster"), "function" == typeof this.onHandleRoster && this.onHandleRoster(e)
  535.                     },
  536.                     handleRosterItem: function(e, t, n, i, o) {
  537.                         ie("handleRosterItem id " + e + " resource " + n + " displayName " + i + " groups " + o), "function" == typeof this.onHandleRosterItem && this.onHandleRosterItem(e, t, n, i, o)
  538.                     },
  539.                     handleRosterPresence: function(e, t, n, i) {
  540.                         ie("handleRosterPresence"), "function" == typeof this.onHandleRosterPresence && this.onHandleRosterPresence(e, t, n, i)
  541.                     },
  542.                     handleMessage: function(e, t, n, i, o) {
  543.                         ie("handleMessage with id " + i + " from " + e + " to " + o + ": " + n), "function" == typeof this.onHandleMessage && this.onHandleMessage(e, t, n, i, o)
  544.                     },
  545.                     handleSelfPresence: function(e, t, n, i) {
  546.                         ie("handleSelfPresence from " + e + ": " + n), "function" == typeof this.onHandleSelfPresence && this.onHandleSelfPresence(e, t, n, i)
  547.                     },
  548.                     handleChatState: function(e, t, n) {
  549.                         ie("handleChatState from " + e + ": " + n), "function" == typeof this.onHandleChatState && this.onHandleChatState(e, t, n)
  550.                     },
  551.                     handleMessageEvent: function(e, t, n, i) {
  552.                         ie("handleMessageEvent from " + e + ": " + n), "function" == typeof this.onHandleMessageEvent && this.onHandleMessageEvent(e, t, n, i)
  553.                     },
  554.                     handleMessageModified: function(e, t, n, i) {
  555.                         ie("handleMessageModified message id " + t + " by " + e + " in chat with " + i + " msg " + n), "function" == typeof this.onHandleMessageModified && this.onHandleMessageModified(e, t, n, i)
  556.                     },
  557.                     handleMessageRemoved: function(e, t, n) {
  558.                         ie("handleMessageRemoved message id " + t + " by " + e + " in chat with " + n), "function" == typeof this.onHandleMessageRemoved && this.onHandleMessageRemoved(e, t, n)
  559.                     },
  560.                     handleSubscription: function(e, t, n, i) {
  561.                         ie("handleSubscription from " + e + ": " + n), "function" == typeof this.onHandleSubscription && this.onHandleSubscription(e, t, n, i)
  562.                     },
  563.                     onCallRemoteFunctionError: function(e, t, n, i) {
  564.                         ie("onCallRemoteFunctionError method " + e + " params " + t + " code " + n + " description " + i), "function" == typeof this.onCallRemoteFunctionError && this.onCallRemoteFunctionError(e, t, n, i)
  565.                     },
  566.                     handleError: function(e, t, n) {
  567.                         ie("handleError type " + e + " code " + t + " description " + n), "function" == typeof this.onIMError && this.onIMError(e, t, n)
  568.                     },
  569.                     handleUCConnected: function(e) {
  570.                         ie("handleUCConnected id " + e), "function" == typeof this.onUCConnected && this.onUCConnected(e)
  571.                     },
  572.                     handleUCDisconnected: function() {
  573.                         ie("handleUCDisconnected"), "function" == typeof this.onUCDisconnected && this.onUCDisconnected()
  574.                     },
  575.                     handleRosterError: function(e) {
  576.                         ie("handleRosterError code " + e), "function" == typeof this.onIMRosterError && this.onIMRosterError(e)
  577.                     },
  578.                     handleMUCError: function(e, t, n, i) {
  579.                         ie("handleMUCError room " + e + " operation " + t + " code " + n + " text " + i), "function" == typeof this.onMUCError && this.onMUCError(e, t, n, i)
  580.                     },
  581.                     handleMUCRoomCreation: function(e) {
  582.                         ie("handleMUCRoomCreation room " + e), "function" == typeof this.onMUCRoomCreation && this.onMUCRoomCreation(e)
  583.                     },
  584.                     handleMUCSubject: function(e, t, n, i) {
  585.                         ie("handleMUCSubject room " + e + " id " + t + " resource " + n + " subject " + i), "function" == typeof this.onMUCSubject && this.onMUCSubject(e, t, n, i)
  586.                     },
  587.                     handleMUCInfo: function(e, t, n, i) {
  588.                         ie("handleMUCInfo room " + e + " features " + t + " name " + n + " info " + i), "function" == typeof this.onMUCInfo && this.onMUCInfo(e, t, n, i)
  589.                     },
  590.                     handleMUCMessage: function(e, t, n, i, o, s, a) {
  591.                         ie("handleMUCMessage room " + e + " message_id " + n + " private " + t + " timestamp " + i + " from " + o + " resource " + s + " msg " + a), "function" == typeof this.onMUCMessage && this.onMUCMessage(e, n, t, i, o, s, a)
  592.                     },
  593.                     handleMUCInvitation: function(e, t, n, i, o, s) {
  594.                         ie("handleMUCInvitation room " + e + " from " + t + " reason " + n + " body " + i + " password " + o + " cont " + s), "function" == typeof this.onMUCInvitation && this.onMUCInvitation(e, t, n, i, o, s)
  595.                     },
  596.                     handleMUCInviteDecline: function(e, t, n) {
  597.                         ie("handleMUCInviteDecline room " + e + " invitee " + t + " reason " + n), "function" == typeof this.onMUCInviteDecline && this.onMUCInviteDecline(e, t, n)
  598.                     },
  599.                     handleMUCParticipantPresence: function(e, t, n, i) {
  600.                         ie("handleMUCParticipantPresence room " + e + " participant " + t + " presence " + n + " msg " + i), "function" == typeof this.onMUCParticipantPresence && this.onMUCParticipantPresence(e, t, n, i)
  601.                     },
  602.                     handleMUCParticipantJoin: function(e, t, n) {
  603.                         ie("handleMUCParticipantJoin room " + e + " participant " + t + " displayName " + n), "function" == typeof this.onMUCNewParticipant && this.onMUCNewParticipant(e, t, n)
  604.                     },
  605.                     handleMUCParticipantLeft: function(e, t) {
  606.                         ie("handleMUCParticipantLeft room " + e + " participant " + t), "function" == typeof this.onMUCParticipantExit && this.onMUCParticipantExit(e, t)
  607.                     },
  608.                     handleMUCRooms: function(e) {
  609.                         ie("handleMUCRooms rooms " + e), "function" == typeof this.onMUCRooms && this.onMUCRooms(e)
  610.                     },
  611.                     handleMUCParticipants: function(e, t) {
  612.                         ie("handleMUCParticipants room " + e + " list " + t), "function" == typeof this.onMUCParticipants && this.onMUCParticipants(e, t)
  613.                     },
  614.                     handleMUCBanList: function(e, t) {
  615.                         ie("handleMUCBanList room " + e + " list " + t), "function" == typeof this.onMUCBanList && this.onMUCBanList(e, t)
  616.                     },
  617.                     handleMUCHistory: function(e, t, n) {
  618.                         ie("handleMUCHistory room " + e + " mid " + t + " list " + n), "function" == typeof this.onMUCHistory && this.onMUCHistory(e, t, n)
  619.                     },
  620.                     handleMUCMessageModified: function(e, t, n, i, o, s, a) {
  621.                         ie("handleMUCMessageModified room " + e + " priv " + t + " mid " + n + " timestamp " + i + " from " + o + " resource " + s + " msg " + a), "function" == typeof this.onMUCMessageModified && this.onMUCMessageModified(e, t, n, i, o, s, a)
  622.                     },
  623.                     handleMUCMessageRemoved: function(e, t, n, i, o, s) {
  624.                         ie("handleMUCMessageRemoved room " + e + " priv " + t + " mid " + n + " timestamp " + i + " from " + o + " resource " + s), "function" == typeof this.onMUCMessageRemoved && this.onMUCMessageRemoved(e, t, n, i, o, s)
  625.                     },
  626.                     handleMUCChatState: function(e, t, n, i) {
  627.                         ie("handleMUCChatState room " + e + " from " + t + " resource " + n + " state " + i), "function" == typeof this.onMUCChatState && this.onMUCChatState(e, t, n, i)
  628.                     },
  629.                     handleHistory: function(e, t, n) {
  630.                         ie("handleHistory uri " + e + " mid " + t + " list " + n), "function" == typeof this.onHistory && this.onHistory(e, t, n)
  631.                     },
  632.                     handlePreFlightCheckResult: function(e, t, n) {
  633.                         this.onCheckComplete && this.onCheckComplete(e, t, n)
  634.                     },
  635.                     handleVoicemail: function(e) {
  636.                         this.onVoicemail && this.onVoicemail(e)
  637.                     },
  638.                     __connectionFailed: function() {
  639.                         z != i && this.disconnect()
  640.                     }
  641.                 };
  642.                 var Oe = function(e) {
  643.                         var t = JSON.parse(e.data),
  644.                             n = t.name,
  645.                             i = t.params;
  646.                         ie("Called local function " + n + " with params " + JSON.stringify(i)), "function" == typeof ge[n] ? ge[n].apply(this, i) : ne("Unknown function called: " + n), Ce()
  647.                     }.bind(this),
  648.                     Ae = function(e, t) {
  649.                         return "function" == typeof mozRTCSessionDescription ? new mozRTCSessionDescription({
  650.                             type: e,
  651.                             sdp: t
  652.                         }) : new RTCSessionDescription({
  653.                             type: e,
  654.                             sdp: t
  655.                         })
  656.                     },
  657.                     Pe = function(e, t, n, i) {
  658.                         var o, s, a = e,
  659.                             r = t,
  660.                             c = n,
  661.                             l = i,
  662.                             d = !0;
  663.                         this.id = function() {
  664.                             return a
  665.                         }, this.getRemoteParty = function() {
  666.                             return c
  667.                         }, this.getState = function() {
  668.                             return r
  669.                         }, this.setState = function(e) {
  670.                             r = e
  671.                         }, this.getDisplayName = function() {
  672.                             return l
  673.                         }, this.setPeerConnection = function(e) {
  674.                             BXIM.webrtc.phoneLog("Set peer connection: " + e), o = e
  675.                         }, this.getPeerConnection = function() {
  676.                             return BXIM.webrtc.phoneLog("Get peer connection: " + o), o
  677.                         }, this.setHeaders = function(e) {
  678.                             s = e
  679.                         }, this.getHeaders = function() {
  680.                             return s
  681.                         }, this.streamsAreActive = function() {
  682.                             return d
  683.                         }, this.setStreamsActive = function(e) {
  684.                             d = e, ee[a] && ee[a].setStreamsActive(e)
  685.                         }, this.getVideoElementId = function() {
  686.                             return o.getVideoElementId()
  687.                         }, this.getAudioElementId = function() {
  688.                             return o.getAudioElementId()
  689.                         }, this.canStartSendingCandidates = function() {
  690.                             o.canStartSendingCandidates()
  691.                         }, this.notifyICETimeout = function() {
  692.                             ce(a)
  693.                         }
  694.                     },
  695.                     be = function(t, n) {
  696.                         function i() {
  697.                             null === de && (de = setTimeout(function() {
  698.                                 de = null, he.length > 0 && me(l, "voximplant", "sdpfrag", JSON.stringify(he), {}), he = []
  699.                             }, 100))
  700.                         }
  701.  
  702.                         function o(e, t) {
  703.                             he.push([t, e]), ce && i()
  704.                         }
  705.                         var s = null,
  706.                             a = !1,
  707.                             r = null;
  708.                         n && (r = Me);
  709.                         var c = new g(r, {
  710.                             optional: [{
  711.                                 DtlsSrtpKeyAgreement: "true"
  712.                             }]
  713.                         });
  714.                         S && (c.removeStream = function(e) {
  715.                             e.forEach(function(e) {
  716.                                 c.removeTrack(e)
  717.                             })
  718.                         });
  719.                         var l = t,
  720.                             d = n;
  721.                         this.isDirect = function() {
  722.                             return d
  723.                         };
  724.                         var p, C = function(e) {
  725.                                 ne("PC [" + l + "]: " + e)
  726.                             },
  727.                             R = function(e) {
  728.                                 ie("PC [" + l + "]: " + e)
  729.                             },
  730.                             T = function(e) {
  731.                                 ne("PC [" + l + "] ERROR: " + e)
  732.                             };
  733.                         this.setCall = function(e) {
  734.                             p = e
  735.                         }, this.getCall = function() {
  736.                             return p
  737.                         };
  738.                         var I, E, w = null;
  739.                         if (I = P(), I.id = "vi_audio_" + l, I.volume = q, document.body.appendChild(I), D) {
  740.                             E = N(), E.id = "vi_video_" + l, E.width = 400, E.height = 300, E.volume = q;
  741.                             var M = $ ? document.getElementById($) : document.body;
  742.                             M.appendChild(E)
  743.                         }
  744.                         var O = null,
  745.                             A = null,
  746.                             V = !1,
  747.                             x = !1,
  748.                             z = null,
  749.                             j = null,
  750.                             G = null,
  751.                             B = !1,
  752.                             J = !0,
  753.                             K = null,
  754.                             Z = function() {
  755.                                 p && p.notifyICETimeout()
  756.                             }.bind(this);
  757.                         this.getStats = function(e) {
  758.                             G && z && c.getStats(function(e) {
  759.                                 var t = e.result();
  760.                                 for (var n in t) "ssrc" == t[n].type && (t[n].local == t[n] || !t[n].remote, t[n].remote == t[n] || !t[n].local)
  761.                             })
  762.                         }, this.getRemoteAudioStream = function() {
  763.                             return z
  764.                         }, this.getRemoteVideoStream = function() {
  765.                             return j
  766.                         }, this.getVideoElementId = function() {
  767.                             return E ? E.id : null
  768.                         }, this.getAudioElementId = function() {
  769.                             return I ? I.id : null
  770.                         }, this.setLocalStream = function(e) {
  771.                             if (!B && (G && (c.removeStream(S ? k : G), G = null), e)) {
  772.                                 G = e; {
  773.                                     "undefined" == typeof e.getAudioTracks ? e.audioTracks : e.getAudioTracks(), "undefined" == typeof e.getVideoTracks ? e.videoTracks : e.getVideoTracks()
  774.                                 }
  775.                                 G = e, S ? G.getTracks().forEach(function(e) {
  776.                                     k.push(c.addTrack(e, G))
  777.                                 }) : c.addStream(G), F(G.getAudioTracks(), !H), F(G.getVideoTracks(), X)
  778.                             }
  779.                         };
  780.                         var Y = function(e) {
  781.                             e && (K = e, c.addStream(K))
  782.                         };
  783.                         this.setScreenSharingStream = function(e) {
  784.                             K = e
  785.                         }, this.addScreenSharing = function(e) {
  786.                             B || (K && (c.removeStream(K), K = null), Y(e))
  787.                         }, this.onIncomingCall = function(e) {
  788.                             B || (O = Ae("offer", e), c.setRemoteDescription(O, function() {}, T))
  789.                         }, this.onConnectionConnected = function(e) {
  790.                             B || d && (O = Ae("answer", e), c.setRemoteDescription(O, function() {
  791.                                 s = setTimeout(Z, h)
  792.                             }, T))
  793.                         }, this.outgoingCall = function() {
  794.                             B || c.createOffer(function(e) {
  795.                                 f(e), A = e, c.setLocalDescription(Ae("offer", e.sdp), function() {
  796.                                     Q()
  797.                                 }, T)
  798.                             }, T)
  799.                         };
  800.                         var Q = function() {
  801.                             B || Ne("createCall", [-1, p.getRemoteParty(), !1, t, null, null, p.getHeaders(), "", A.sdp])
  802.                         };
  803.                         this.createAnswer = function() {
  804.                             B || (R("Calling createAnswer"), c.createAnswer(ee, T))
  805.                         };
  806.                         var ee = function(e) {
  807.                                 B || (f(e), V = -1 != e.sdp.indexOf("a=rtcp-mux"), c.setLocalDescription(e, function() {
  808.                                     A = e, x = !0, te()
  809.                                 }, T))
  810.                             }.bind(this),
  811.                             te = function() {
  812.                                 B || (s = setTimeout(Z, h), C("Sending local answer"), R("Local answer: " + A.sdp), d ? Ne("acceptCall", [l, le(p.getHeaders()), A.sdp]) : Ne("__confirmPC", [l, A.sdp]))
  813.                             },
  814.                             oe = !1,
  815.                             se = function() {
  816.                                 oe || (oe = !0)
  817.                             },
  818.                             ce = !1,
  819.                             de = null,
  820.                             he = [],
  821.                             ue = null,
  822.                             fe = null,
  823.                             pe = null;
  824.                         this.canStartSendingCandidates = function() {
  825.                             ce = !0, i()
  826.                         }, this.addRemoteCandidate = function(e, t) {
  827.                             c.addIceCandidate(new v({
  828.                                 candidate: t.substring(2),
  829.                                 sdpMLineIndex: e
  830.                             }), function() {
  831.                                 BXIM.webrtc.phoneLog("Added ice candidate")
  832.                             }, function(e) {
  833.                                 R("error adding ice candidate " + e)
  834.                             })
  835.                         };
  836.                         var Ce = function(e) {
  837.                             if (!B)
  838.                                 if (e.candidate) {
  839.                                     R("ICE candidate: " + e.candidate.candidate);
  840.                                     var t = e.candidate.candidate,
  841.                                         n = t; - 1 == n.indexOf("a=") && (n = "a=" + n), y && A && (A.sdp += n, A.sdp += "\r\n"), d ? o(n, e.candidate.sdpMLineIndex) : Ne("__addCandidate", [l, n, e.candidate.sdpMLineIndex])
  842.                                 } else C("End of candidates."), se()
  843.                         };
  844.                         this.setRemoteSDP = function(e, t, n) {
  845.                             "string" == typeof n && (ue = n), c.setRemoteDescription(Ae(e ? "offer" : "answer", t), function() {
  846.                                 e ? c.createAnswer(function(e) {
  847.                                     f(e), c.setLocalDescription(e, function() {
  848.                                         me(l, "vi", "sdpanswer", e.sdp, null), a = !1
  849.                                     }, function(e) {})
  850.                                 }, function(e) {
  851.                                     C("Error: " + e)
  852.                                 }) : a = !1
  853.                             }, function(e) {
  854.                                 C("Error: " + e)
  855.                             })
  856.                         };
  857.                         var ge = function() {
  858.                                 return B ? void C("Renegotiation requested on closed PeerConnection") : null === A ? void C("Renegotiation needed, but no local SD, skipping") : "connected" != c.iceConnectionState && "completed" != c.iceConnectionState ? (C("Renegotiation requested while ice state is " + c.iceConnectionState + ". Postponing"), void setTimeout(ge, 100)) : a ? void C("Renegotiation in progress. Queueing") : (C("Renegotiation started"), a = !0, void(d ? c.createOffer(function(e) {
  859.                                     f(e), C("New SDP: " + e.sdp), c.setLocalDescription(e, function() {
  860.                                         var t = {};
  861.                                         K && (t["X-ScreenStreamId"] = K.id), me(l, "vi", "sdpoffer", e.sdp, t)
  862.                                     }, function(e) {
  863.                                         C("Error: " + e)
  864.                                     })
  865.                                 }, function(e) {
  866.                                     C("ERROR: " + e)
  867.                                 }) : c.setRemoteDescription(O, function() {
  868.                                     return B ? void(a = !1) : void c.createAnswer(function(e) {
  869.                                         return B ? void(a = !1) : (f(e), A = e, void c.setLocalDescription(A, function() {
  870.                                             a = !1, C("Renegotiation successful")
  871.                                         }, function(e) {
  872.                                             a = !1, C("ERROR: " + e)
  873.                                         }))
  874.                                     }, function(e) {
  875.                                         a = !1, C("ERROR: " + e)
  876.                                     })
  877.                                 }, function(e) {
  878.                                     a = !1, C("ERROR: " + e)
  879.                                 })))
  880.                             },
  881.                             ve = function(t, n) {
  882.                                 navigator.mozGetUserMedia ? t.getStats(null, function(e) {
  883.                                     BXIM.webrtc.phoneLog(e);
  884.                                     var t = [];
  885.                                     e.forEach(function(e) {
  886.                                         ("inboundrtp" == e.type || "outboundrtp" == e.type) && t.push(e)
  887.                                     }), t.length > 0 && n(t)
  888.                                 }, function(t) {
  889.                                     C("ERROR: " + e)
  890.                                 }) : t.getStats(function(e) {
  891.                                     BXIM.webrtc.phoneLog(e);
  892.                                     var t = [];
  893.                                     e.result().forEach(function(e) {
  894.                                         var n = {};
  895.                                         e.names().forEach(function(t) {
  896.                                             n[t] = e.stat(t)
  897.                                         }), n.id = e.id, n.type = e.type, n.timestamp = e.timestamp, "ssrc" == n.type && t.push(n)
  898.                                     }), n(t)
  899.                                 })
  900.                             },
  901.                             ye = function(e) {
  902.                                 var t = L(e.stream).length > 0,
  903.                                     n = e.stream.id == ue;
  904.                                 if (C("Remote stream added " + e.stream.id + " " + (t ? "video" : "audio")), n) {
  905.                                     if (null == pe) {
  906.                                         pe = N(), pe.id = "vi_ss_" + l, pe.width = 400, pe.height = 300, pe.volume = 0;
  907.                                         var i = $ ? document.getElementById($) : document.body;
  908.                                         i.appendChild(pe)
  909.                                     }
  910.                                     fe = e.stream, m(pe, e.stream), re(l, pe.id)
  911.                                 } else t ? j = e.stream : z = e.stream, t ? E && m(E, e.stream) : m(I, e.stream), t || w || (w = setInterval(function() {
  912.                                     ve(c, function(e) {
  913.                                         ae(l, e)
  914.                                     })
  915.                                 }, u)), this.setStreamsActive(J)
  916.                             },
  917.                             Se = function(e) {},
  918.                             Re = function(e) {
  919.                                 if ("stable" == c.signalingState && null != K) {
  920.                                     var t = c.getLocalStreams();
  921.                                     for (var n in t)
  922.                                         if (t[n] == K) return;
  923.                                     Y(K)
  924.                                 }
  925.                             };
  926.                         this.setPlaybackVolume = function(e) {
  927.                             I && (I.volume = e), E && (E.volume = e)
  928.                         }, this.streamsAreActive = function() {
  929.                             return J
  930.                         }, this.setStreamsActive = function(e) {
  931.                             J = e, F(_(z), e && !W), F(_(j), e && !W), F(L(j), e), Ne("__muteLocal", [l, !e])
  932.                         }.bind(this), this.updateMicrophoneMuteState = function() {}, this.updateSpeakerMuteState = function() {
  933.                             z && F(_(z), J && !W)
  934.                         }, this.activateStreams = function() {
  935.                             B || this.setStreamsActive(!0)
  936.                         }, this.deactivateStreams = function() {
  937.                             B || this.setStreamsActive(!1)
  938.                         }, c.onicecandidate = Ce.bind(this), c.onaddstream = ye.bind(this), c.onnegotiationneeded = ge.bind(this), c.onremovestream = Se.bind(this), c.onsignalingstatechange = Re.bind(this), c.oniceconnectionstatechange = function() {
  939.                             ("completed" == c.iceConnectionState || "connected" == c.iceConnectionState && s) && (clearTimeout(s), s = null)
  940.                         }.bind(this), this.close = function() {
  941.                             B = !0, w && clearInterval(w), w = null, c.close(), I && (I.parentNode.removeChild(I),
  942.                                 b(I)), E && (E.parentNode.removeChild(E), U(E)), pe && (pe.parentNode.removeChild(pe), U(pe))
  943.                         }, this.start = function(e) {
  944.                             B || (O = Ae("offer", e), c.setRemoteDescription(O, function() {
  945.                                 c.createAnswer(function(e) {
  946.                                     f(e), BXIM.webrtc.phoneLog("Local answer created: " + e.sdp), V = -1 != e.sdp.indexOf("a=rtcp-mux"), c.setLocalDescription(e, function() {
  947.                                         A = e, x = !0, te()
  948.                                     }, T)
  949.                                 }, T)
  950.                             }, T))
  951.                         }
  952.                     },
  953.                     Ne = function(e, t) {
  954.                         ie("Called remote function " + e + " with params " + JSON.stringify(t)), x ? x.send(JSON.stringify({
  955.                             name: e,
  956.                             params: t
  957.                         })) : ne("ERROR: can't call remote function when not connected"), Ce()
  958.                     }
  959.             }
  960.         }(i), function(e, t) {
  961.             e.Config = {}, e.FlashVideoSettings = {}, e.VideoSettings = {}, e.AudioSourceInfo = {}, e.VideoSourceInfo = {}, e.AudioOutputInfo = {}, e.NetworkInfo = {}, e.SubscriptionRequestType = {
  962.                 Subscribe: 0,
  963.                 Unsubscribe: 1
  964.             }, e.ChatStateType = {
  965.                 Active: 1,
  966.                 Composing: 2,
  967.                 Paused: 4,
  968.                 Inactive: 8,
  969.                 Gone: 16,
  970.                 Invalid: 32
  971.             }, e.MessageEventType = {
  972.                 Offline: 1,
  973.                 Delivered: 2,
  974.                 Displayed: 4,
  975.                 Composing: 8,
  976.                 Invalid: 16,
  977.                 Cancel: 32
  978.             }, e.RosterItemEvent = {
  979.                 Added: 0,
  980.                 Removed: 1,
  981.                 Updated: 2,
  982.                 Subscribed: 3,
  983.                 Unsubscribed: 4
  984.             }, e.UserStatuses = {
  985.                 Online: 0,
  986.                 Chat: 1,
  987.                 Away: 2,
  988.                 DND: 3,
  989.                 XA: 4,
  990.                 Offline: 5
  991.             }, e.OperatorACDStatuses = {
  992.                 Offline: "OFFLINE",
  993.                 Online: "ONLINE",
  994.                 Ready: "READY",
  995.                 InService: "IN_SERVICE",
  996.                 AfterService: "AFTER_SERVICE",
  997.                 Timeout: "TIMEOUT",
  998.                 DND: "DND"
  999.             }, e.IMErrorType = {
  1000.                 RemoteFunctionError: "RemoteFunctionError",
  1001.                 Error: "Error",
  1002.                 RosterError: "RosterError"
  1003.             }, e.LoginOptions = {}, e.RosterItem = {}, e.ChatRoom = {}, e.ChatRoomInfo = {}, e.ChatRoomParticipant = {}, e.ParticipantInfo = {}, e.IMHistoryMessage = {}
  1004.         }(i), function(e, t) {
  1005.             e.Events = {
  1006.                 SDKReady: "SDKReady",
  1007.                 ConnectionEstablished: "ConnectionEstablished",
  1008.                 ConnectionFailed: "ConnectionFailed",
  1009.                 ConnectionClosed: "ConnectionClosed",
  1010.                 AuthResult: "AuthResult",
  1011.                 PlaybackFinished: "PlaybackFinished",
  1012.                 MicAccessResult: "MicAccessResult",
  1013.                 IncomingCall: "IncomingCall",
  1014.                 SourcesInfoUpdated: "SourcesInfoUpdated",
  1015.                 NetStatsReceived: "NetStatsReceived"
  1016.             }, e.CallEvents = {
  1017.                 Connected: "Connected",
  1018.                 Disconnected: "Disconnected",
  1019.                 Failed: "Failed",
  1020.                 ProgressToneStart: "ProgressToneStart",
  1021.                 ProgressToneStop: "ProgressToneStop",
  1022.                 MessageReceived: "MessageReceived",
  1023.                 InfoReceived: "InfoReceived",
  1024.                 TransferComplete: "TransferComplete",
  1025.                 TransferFailed: "TransferFailed",
  1026.                 RemoteScreenCaptureStarted: "RemoteScreenCaptureStarted",
  1027.                 ICETimeout: "ICETimeout",
  1028.                 RTCStatsReceived: "RTCStatsReceived"
  1029.             }, e.IMEvents = {
  1030.                 RosterReceived: "RosterReceived",
  1031.                 RosterItemChange: "RosterItemChange",
  1032.                 RosterPresenceUpdate: "RosterPresenceUpdate",
  1033.                 PresenceUpdate: "PresenceUpdate",
  1034.                 MessageReceived: "MessageReceived",
  1035.                 MessageModified: "MessageModified",
  1036.                 MessageRemoved: "MessageRemoved",
  1037.                 ChatStateUpdate: "ChatStateUpdate",
  1038.                 MessageStatus: "MessageStatus",
  1039.                 SubscriptionRequest: "SubscriptionRequest",
  1040.                 ChatHistoryReceived: "ChatHistoryReceived",
  1041.                 ChatRoomCreated: "ChatRoomCreated",
  1042.                 ChatRoomSubjectChange: "ChatRoomSubjectChange",
  1043.                 ChatRoomInfo: "ChatRoomInfo",
  1044.                 ChatRoomMessageReceived: "ChatRoomMessageReceived",
  1045.                 ChatRoomInvitation: "ChatRoomInvitation",
  1046.                 ChatRoomInviteDeclined: "ChatRoomInviteDeclined",
  1047.                 ChatRoomPresenceUpdate: "ChatRoomPresenceUpdate",
  1048.                 ChatRoomNewParticipant: "ChatRoomNewParticipant",
  1049.                 ChatRoomParticipantExit: "ChatRoomParticipantExit",
  1050.                 ChatRoomsDataReceived: "ChatRoomsDataReceived",
  1051.                 ChatRoomParticipants: "ChatRoomParticipants",
  1052.                 ChatRoomBanList: "ChatRoomBanList",
  1053.                 ChatRoomHistoryReceived: "ChatRoomHistoryReceived",
  1054.                 ChatRoomMessageModified: "ChatRoomMessageModified",
  1055.                 ChatRoomMessageRemoved: "ChatRoomMessageRemoved",
  1056.                 ChatRoomStateUpdate: "ChatRoomStateUpdate",
  1057.                 ChatRoomError: "ChatRoomError",
  1058.                 SystemError: "IMError",
  1059.                 UCConnected: "UCConnected",
  1060.                 UCDisconnected: "UCDisconnected"
  1061.             }
  1062.         }(i), function(e, t) {
  1063.             e.Call = function(e, t, n, i, o, s) {
  1064.                 var a = o,
  1065.                     r = e,
  1066.                     c = t,
  1067.                     l = n,
  1068.                     d = i,
  1069.                     h = s;
  1070.                 this.eventListeners = {}, this.call = function(e) {
  1071.                     return "undefined" == typeof e ? r : void(r = e)
  1072.                 }, this.__number = function(e) {
  1073.                     return "undefined" == typeof e ? c : void(c = e)
  1074.                 }, this.__displayName = function() {
  1075.                     return l
  1076.                 }, this.__headers = function() {
  1077.                     return d
  1078.                 }, this.RTC = function() {
  1079.                     return a
  1080.                 }, this.zingayaAPI = function() {
  1081.                     return h
  1082.                 }
  1083.             }, e.Call.prototype = {
  1084.                 id: function() {
  1085.                     return this.call()
  1086.                 },
  1087.                 number: function() {
  1088.                     return this.__number()
  1089.                 },
  1090.                 displayName: function() {
  1091.                     return this.__displayName()
  1092.                 },
  1093.                 headers: function() {
  1094.                     return this.__headers()
  1095.                 },
  1096.                 active: function() {
  1097.                     return this.RTC() ? this.zingayaAPI().isCallActive(this.call()) : e.Utils.swfMovie("voximplantSWF").isCallActive(this.call())
  1098.                 },
  1099.                 state: function() {
  1100.                     if (this.RTC()) return this.zingayaAPI().getCallState(this.call());
  1101.                     var t = e.Utils.swfMovie("voximplantSWF").getCallState(this.call()).toUpperCase();
  1102.                     switch (t) {
  1103.                         case "CONNECTING":
  1104.                             t = e.VI_CALL_STATE_ALERTING;
  1105.                             break;
  1106.                         case "CONNECTED_ON_HOLD":
  1107.                             t = e.VI_CALL_STATE_CONNECTED;
  1108.                             break;
  1109.                         case "DISCONNECTED":
  1110.                         case "FAILED":
  1111.                             t = e.VI_CALL_STATE_ENDED
  1112.                     }
  1113.                     return t
  1114.                 },
  1115.                 answer: function(t, n) {
  1116.                     if ("undefined" != typeof t && ("undefined" == typeof n && (n = {}), n["VI-CallData"] = t), this.RTC()) {
  1117.                         if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_ALERTING) throw new Error("NO_INCOMING_CALL");
  1118.                         this.zingayaAPI().answerCall(this.call(), n)
  1119.                     } else n = JSON.stringify(n), BXIM.webrtc.phoneLog("Accepting call, id " + this.call()), e.Utils.swfMovie("voximplantSWF").accept(this.call(), n)
  1120.                 },
  1121.                 decline: function(t) {
  1122.                     if (this.RTC()) {
  1123.                         if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_ALERTING) throw new Error("NO_INCOMING_CALL");
  1124.                         this.zingayaAPI().rejectCall(this.call(), 486, t)
  1125.                     } else t = e.Utils.stringifyExtraHeaders(t), e.Utils.swfMovie("voximplantSWF").reject(this.call(), t)
  1126.                 },
  1127.                 reject: function(e) {
  1128.                     this.decline(e)
  1129.                 },
  1130.                 hangup: function(t) {
  1131.                     if (this.RTC()) {
  1132.                         if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_CONNECTED && this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_PROGRESSING) throw new Error("WRONG_CALL_STATE");
  1133.                         this.zingayaAPI().hangupCall(this.call(), t)
  1134.                     } else t = e.Utils.stringifyExtraHeaders(t), e.Utils.swfMovie("voximplantSWF").disconnectCall(this.call(), t)
  1135.                 },
  1136.                 sendTone: function(t) {
  1137.                     if ("*" == t) t = 10;
  1138.                     else if ("#" == t) t = 11;
  1139.                     else if (t = parseInt(t), 0 > t || t > 9) throw new Error("WRONG_TONE_INPUT");
  1140.                     if (this.RTC()) {
  1141.                         if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_CONNECTED) throw new Error("CALL_NOT_CONNECTED");
  1142.                         this.zingayaAPI().sendDigit(this.call(), t)
  1143.                     } else e.Utils.swfMovie("voximplantSWF").sendDTMF(t, this.call())
  1144.                 },
  1145.                 mutePlayback: function() {
  1146.                     this.RTC() ? this.zingayaAPI().mutePlayback(!0) : e.Utils.swfMovie("voximplantSWF").muteIncomingAudio(this.call())
  1147.                 },
  1148.                 muteMicrophone: function() {
  1149.                     this.RTC() ? this.zingayaAPI().muteMicrophone(!0) : e.Utils.swfMovie("voximplantSWF").muteOutgoingAudio(this.call())
  1150.                 },
  1151.                 unmutePlayback: function() {
  1152.                     this.RTC() ? this.zingayaAPI().mutePlayback(!1) : e.Utils.swfMovie("voximplantSWF").unmuteIncomingAudio(this.call())
  1153.                 },
  1154.                 unmuteMicrophone: function() {
  1155.                     this.RTC() ? this.zingayaAPI().muteMicrophone(!1) : e.Utils.swfMovie("voximplantSWF").unmuteOutgoingAudio(this.call())
  1156.                 },
  1157.                 sendVideo: function(e) {},
  1158.                 showRemoteVideo: function(t) {
  1159.                     "undefined" == typeof t && (t = !0), this.RTC() ? document.getElementById(this.zingayaAPI().getVideoElementId(this.call())).style.display = t ? "block" : "none" : e.Utils.swfMovie("voximplantSWF").showRemoteVideo(this.call(), t)
  1160.                 },
  1161.                 setRemoteVideoPosition: function(t, n) {
  1162.                     if (this.RTC()) throw new Error("Please use CSS to position '#voximplantcontainer' element");
  1163.                     e.Utils.swfMovie("voximplantSWF").setRemoteViewPosition(this.call(), t, n)
  1164.                 },
  1165.                 setRemoteVideoSize: function(t, n) {
  1166.                     if (this.RTC()) throw new Error("Please use CSS to set size of '#voximplantcontainer' element");
  1167.                     e.Utils.swfMovie("voximplantSWF").setRemoteViewSize(this.call(), t, n)
  1168.                 },
  1169.                 sendInfo: function(t, n, i) {
  1170.                     var o, s, a = t.indexOf("/");
  1171.                     if (-1 == a ? (o = "application", s = t) : (o = t.substring(0, a), s = t.substring(a + 1)), this.RTC()) {
  1172.                         if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_CONNECTED) throw new Error("CALL_NOT_CONNECTED");
  1173.                         this.zingayaAPI().sendSIPInfo(this.call(), o, s, n, i)
  1174.                     } else i = e.Utils.stringifyExtraHeaders(i), e.Utils.swfMovie("voximplantSWF").sendSIPInfo(this.call(), o, s, n, i)
  1175.                 },
  1176.                 sendMessage: function(t) {
  1177.                     if (this.RTC()) {
  1178.                         if (this.zingayaAPI().getCallState(this.call()) != e.VI_CALL_STATE_CONNECTED) throw new Error("CALL_NOT_CONNECTED");
  1179.                         this.zingayaAPI().sendInstantMessage(this.call(), t)
  1180.                     } else e.Utils.swfMovie("voximplantSWF").sendMessage(this.call(), t)
  1181.                 },
  1182.                 setVideoSettings: function(t, n, i) {
  1183.                     this.RTC() ? this.zingayaAPI().setConstraints(t, n, i, !0) : this.useRTCOnly || ("[object Object]" == Object.prototype.toString.call(t) && (t = JSON.stringify(t)), e.Utils.swfMovie("voximplantSWF").setVideoSettings(t, this.call()))
  1184.                 },
  1185.                 getIncomingStreamInfo: function() {
  1186.                     if (this.RTC());
  1187.                     else if (!this.useRTCOnly) return JSON.parse(e.Utils.swfMovie("voximplantSWF").getIncomingStreamInfo(this.call()))
  1188.                 },
  1189.                 getOutgoingStreamInfo: function() {
  1190.                     if (this.RTC());
  1191.                     else if (!this.useRTCOnly) return JSON.parse(e.Utils.swfMovie("voximplantSWF").getOutgoingStreamInfo(this.call()))
  1192.                 },
  1193.                 getVideoElementId: function() {
  1194.                     return this.RTC() ? this.zingayaAPI().getVideoElementId(this.call()) : void 0
  1195.                 },
  1196.                 useAudioOutput: function(e) {
  1197.                     if (this.RTC()) {
  1198.                         var t = this.zingayaAPI().getVideoElementId(this.call()),
  1199.                             n = this.zingayaAPI().getAudioElementId(this.call());
  1200.                         document.getElementById(n).currentTime > 0 ? document.getElementById(n).setSinkId(e) : document.getElementById(t).currentTime > 0 && document.getElementById(t).setSinkId(e)
  1201.                     }
  1202.                 }
  1203.             }, e.Call.prototype.addEventListener = function(e, t) {
  1204.                 "undefined" == typeof this.eventListeners[e] && (this.eventListeners[e] = []), this.eventListeners[e].push(t)
  1205.             }, e.Call.prototype.removeEventListener = function(e, t) {
  1206.                 if ("undefined" != typeof this.eventListeners[e])
  1207.                     for (var n = 0; n < this.eventListeners[e].length; n++)
  1208.                         if (this.eventListeners[e][n] == t) {
  1209.                             this.eventListeners[e].splice(n, 1);
  1210.                             break
  1211.                         }
  1212.             }
  1213.         }(i), function(e, t) {
  1214.             e.Client = function() {
  1215.                 this.config = null, this.calls = [];
  1216.                 var n = e.Call;
  1217.                 delete e.Call;
  1218.                 var i = !1;
  1219.                 this.eventListeners = {}, this.progressToneScript = {
  1220.                     US: "440@-19,480@-19;*(2/4/1+2)",
  1221.                     RU: "425@-19;*(1/3/1)"
  1222.                 }, this.playingNow = !1, this.serversList = [];
  1223.                 var o = 100;
  1224.                 this.audioSourcesList = [], this.videoSourcesList = [], this.audioOutputsList = [], this.deviceEnumAPI = function() {
  1225.                     navigator.mediaDevices && navigator.mediaDevices.enumerateDevices ? navigator.mediaDevices.enumerateDevices().then(this.gotSources) : "undefined" != typeof MediaStreamTrack && "undefined" != typeof MediaStreamTrack.getSources && MediaStreamTrack.getSources(this.gotSources)
  1226.                 }, this.gotSources = function(e) {
  1227.                     0 !== this.audioSourcesList.length && (this.audioSourcesList = []), 0 !== this.videoSourcesList.length && (this.videoSourcesList = []), 0 !== this.audioOutputsList.length && (this.audioOutputsList = []);
  1228.                     for (var t = 0, n = 0, i = 0, o = 0; o != e.length; ++o) {
  1229.                         var s = e[o];
  1230.                         "audio" === s.kind || "audioinput" === s.kind ? (n++, this.audioSourcesList.push({
  1231.                             id: s.id || s.deviceId,
  1232.                             name: s.label || "Audio recording device " + n
  1233.                         })) : "video" === s.kind || "videoinput" === s.kind ? (t++, this.videoSourcesList.push({
  1234.                             id: s.id || s.deviceId,
  1235.                             name: s.label || "Video recording device " + t
  1236.                         })) : "audiooutput" === s.kind && (i++, this.audioOutputsList.push({
  1237.                             id: s.id || s.deviceId,
  1238.                             name: s.label || "Audio playback device " + i
  1239.                         }))
  1240.                     }
  1241.                     this.dispatchEvent({
  1242.                         name: "SourcesInfoUpdated"
  1243.                     })
  1244.                 }.bind(this), this.__init = function(i) {
  1245.                     function o() {
  1246.                         if (this.dispatchEvent({
  1247.                                 name: "SDKReady",
  1248.                                 version: e.version
  1249.                             }), -1 != navigator.userAgent.indexOf("Safari")) {
  1250.                             var t = document.getElementById(this.swfContainer);
  1251.                             null !== t && (t.style.minWidth = t.style.width = "215px")
  1252.                         }
  1253.                         for (var n = JSON.parse(e.Utils.swfMovie("voximplantSWF").audioSources()), i = JSON.parse(e.Utils.swfMovie("voximplantSWF").videoSources()), o = 0; o < n.length; o++) this.audioSourcesList.push({
  1254.                             id: o,
  1255.                             name: n[o]
  1256.                         });
  1257.                         for (o = 0; o < i.length; o++) this.videoSourcesList.push({
  1258.                             id: o,
  1259.                             name: i[o]
  1260.                         });
  1261.                         this.dispatchEvent({
  1262.                             name: "SourcesInfoUpdated"
  1263.                         })
  1264.                     }
  1265.                     if (null !== this.config) throw "VoxImplant.Client has been already initialized";
  1266.                     if (this.config = "undefined" != typeof i ? i : {}, this.useFlashOnly = this.config.useFlashOnly === !0 ? !0 : !1, this.useRTCOnly = this.config.useRTCOnly === !0 ? !0 : !1, this.RTCsupported = !1, this.micRequired = this.config.micRequired !== !1 ? !0 : !1, this.videoSupport = this.config.videoSupport !== !0 ? !1 : !0, this.videoConstraints = "undefined" != typeof this.config.videoConstraints ? this.config.videoConstraints : null, this.swfContainer = "undefined" != typeof this.config.swfContainer ? this.config.swfContainer : null, this.progressToneCountry = "undefined" != typeof this.config.progressToneCountry ? this.config.progressToneCountry : "US", this.progressTone = this.config.progressTone !== !0 ? !1 : !0, this.showFlashSettings = this.config.showFlashSettings === !0 ? !0 : !1, "undefined" != typeof this.config.serverIp && (this.serverIp = this.config.serverIp), "undefined" != typeof this.config.swfURL && (this.swfURL = this.config.swfURL), this.showDebugInfo = BXIM.webrtc.debug, this.imXSSprotection = "undefined" != typeof this.config.imXSSprotection ? this.config.imXSSprotection : !0, this.imAutoReconnect = "undefined" != typeof this.config.imAutoReconnect ? this.config.imAutoReconnect : !0, this.imReconnectInterval = "undefined" != typeof this.config.imReconnectInterval ? this.config.imReconnectInterval >= 2e3 ? this.config.imReconnectInterval : 2e3 : 3e3, this.imReconnectTs = 0, this.showWarnings = this.config.showWarnings !== !1 ? !0 : !1, "127.0.0.1" != window.location.hostname && "localhost" != window.location.hostname && "https:" != window.location.protocol && "undefined" != typeof console.error && this.showWarnings && console.error("WARNING: getUserMedia() is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details."), "undefined" != typeof webkitRTCPeerConnection || "undefined" != typeof mozRTCPeerConnection || "undefined" != typeof RTCPeerConnection)
  1267.                         if ("undefined" != typeof mozRTCPeerConnection) try {
  1268.                             {
  1269.                                 new mozRTCPeerConnection({
  1270.                                     iceServers: []
  1271.                                 })
  1272.                             }
  1273.                             this.RTCsupported = !0
  1274.                         } catch (s) {} else this.RTCsupported = !0;
  1275.                     var a;
  1276.                     if (this.RTCsupported && !this.useFlashOnly) null != window.location.href.match(/^file\:\/{3}.*$/g) && "undefined" != typeof console.error && this.showWarnings && console.error("WebRTC requires application to be loaded from a web server"), this.zingayaAPI = new e.ZingayaAPI(this.videoSupport, this.micRequired), delete e.ZingayaAPI, this.zingayaAPI.onConnectionEstablished = function() {
  1277.                         this.connectionState(!0), this.dispatchEvent({
  1278.                             name: "ConnectionEstablished"
  1279.                         })
  1280.                     }.bind(this), this.zingayaAPI.onConnectionFailed = function(e) {
  1281.                         this.connectionState(!1), this.serversList.length > 1 && "undefined" == typeof this.serverIp ? (this.serversList.splice(0, 1), this.connectTo(this.serversList[0], !0)) : this.dispatchEvent({
  1282.                             name: "ConnectionFailed",
  1283.                             message: e
  1284.                         })
  1285.                     }.bind(this), this.zingayaAPI.onConnectionClosed = function() {
  1286.                         this.connectionState(!1), this.__cleanup(), this.dispatchEvent({
  1287.                             name: "ConnectionClosed"
  1288.                         }), this.progressTone && this.stopProgressTone()
  1289.                     }.bind(this), this.zingayaAPI.onLoginSuccessful = function(e, t) {
  1290.                         this.dispatchEvent({
  1291.                             name: "AuthResult",
  1292.                             result: !0,
  1293.                             displayName: e,
  1294.                             options: t
  1295.                         })
  1296.                     }.bind(this), this.zingayaAPI.onLoginFailed = function(e) {
  1297.                         this.dispatchEvent({
  1298.                             name: "AuthResult",
  1299.                             result: !1,
  1300.                             code: e.errorCode,
  1301.                             key: e.oneTimeKey
  1302.                         })
  1303.                     }.bind(this), this.zingayaAPI.onCallConnected = function(e, t) {
  1304.                         this.getCall(e).dispatchEvent({
  1305.                             name: "Connected",
  1306.                             call: this.getCall(e),
  1307.                             headers: t
  1308.                         }), this.progressTone && this.stopProgressTone()
  1309.                     }.bind(this), this.zingayaAPI.onCallEnded = function(e, t) {
  1310.                         this.getCall(e).dispatchEvent({
  1311.                             name: "Disconnected",
  1312.                             call: this.getCall(e),
  1313.                             headers: t
  1314.                         }), this.removeCall(e), this.progressTone && this.stopProgressTone()
  1315.                     }.bind(this), this.zingayaAPI.onCallFailed = function(e, t, n, i) {
  1316.                         this.getCall(e).dispatchEvent({
  1317.                             name: "Failed",
  1318.                             call: this.getCall(e),
  1319.                             code: t,
  1320.                             reason: n,
  1321.                             headers: i
  1322.                         }), this.removeCall(e), this.progressTone && this.stopProgressTone()
  1323.                     }.bind(this), this.zingayaAPI.onMediaAccessGranted = function() {
  1324.                         this.deviceEnumAPI(), this.micRequired && this.zingayaAPI.connectTo(this.host, "platform"), this.dispatchEvent({
  1325.                             name: "MicAccessResult",
  1326.                             result: !0
  1327.                         })
  1328.                     }.bind(this), this.zingayaAPI.onMediaAccessRejected = function(e) {
  1329.                         this.dispatchEvent({
  1330.                             name: "MicAccessResult",
  1331.                             result: !1,
  1332.                             reason: e
  1333.                         })
  1334.                     }.bind(this), this.zingayaAPI.onIncomingCall = function(e, t, i, o) {
  1335.                         var s = new n(e, t, i, o, !0, this.zingayaAPI);
  1336.                         this.calls.length > 0 && this.zingayaAPI.setCallActive(e, !1), this.calls.push(s), this.dispatchEvent({
  1337.                             name: "IncomingCall",
  1338.                             call: s,
  1339.                             headers: o
  1340.                         })
  1341.                     }.bind(this), this.zingayaAPI.onCallRinging = function(e) {
  1342.                         this.getCall(e).dispatchEvent({
  1343.                             name: "ProgressToneStart",
  1344.                             call: this.getCall(e)
  1345.                         }), this.progressTone && this.playProgressTone()
  1346.                     }.bind(this), this.zingayaAPI.onCallMediaStarted = function(e) {
  1347.                         this.getCall(e).dispatchEvent({
  1348.                             name: "ProgressToneStop",
  1349.                             call: this.getCall(e)
  1350.                         }), this.progressTone && this.stopProgressTone()
  1351.                     }.bind(this), this.zingayaAPI.onRemoteScreenCaptureStarted = function(e, t) {
  1352.                         this.getCall(e).dispatchEvent({
  1353.                             name: "RemoteScreenCaptureStarted",
  1354.                             call: this.getCall(e),
  1355.                             videoElementId: t
  1356.                         })
  1357.                     }.bind(this), this.zingayaAPI.onInstantMessageReceived = function(e, t) {
  1358.                         this.getCall(e).dispatchEvent({
  1359.                             name: "MessageReceived",
  1360.                             call: this.getCall(e),
  1361.                             text: t
  1362.                         })
  1363.                     }.bind(this), this.zingayaAPI.onSIPInfoReceived = function(e, t, n, i) {
  1364.                         this.getCall(e).dispatchEvent({
  1365.                             name: "InfoReceived",
  1366.                             call: this.getCall(e),
  1367.                             mimeType: t,
  1368.                             body: n,
  1369.                             headers: i
  1370.                         })
  1371.                     }.bind(this), this.zingayaAPI.onTransferComplete = function(e) {
  1372.                         this.getCall(e).dispatchEvent({
  1373.                             name: "TransferComplete",
  1374.                             call: this.getCall(e)
  1375.                         })
  1376.                     }.bind(this), this.zingayaAPI.onTransferFailed = function(e) {
  1377.                         this.getCall(e).dispatchEvent({
  1378.                             name: "TransferFailed",
  1379.                             call: this.getCall(e)
  1380.                         })
  1381.                     }.bind(this), this.zingayaAPI.onNetStatsReceived = function(e) {
  1382.                         this.dispatchEvent({
  1383.                             name: "NetStatsReceived",
  1384.                             stats: e
  1385.                         })
  1386.                     }.bind(this), this.zingayaAPI.onRTCStatsCollected = function(e, t) {
  1387.                         null != this.getCall(e) && this.getCall(e).dispatchEvent({
  1388.                             name: "RTCStatsReceived",
  1389.                             stats: t
  1390.                         })
  1391.                     }.bind(this), this.zingayaAPI.onHandleRoster = function(e) {
  1392.                         this.dispatchEvent({
  1393.                             name: "RosterReceived",
  1394.                             roster: e
  1395.                         })
  1396.                     }.bind(this), this.zingayaAPI.onHandleRosterItem = function(e, t, n, i, o) {
  1397.                         this.dispatchEvent({
  1398.                             name: "RosterItemChange",
  1399.                             id: e,
  1400.                             resource: t,
  1401.                             type: n,
  1402.                             displayName: i,
  1403.                             groups: o
  1404.                         })
  1405.                     }.bind(this), this.zingayaAPI.onHandleRosterPresence = function(e, t, n, i) {
  1406.                         this.dispatchEvent({
  1407.                             name: "RosterPresenceUpdate",
  1408.                             id: e,
  1409.                             resource: t,
  1410.                             presence: n,
  1411.                             message: i
  1412.                         })
  1413.                     }.bind(this), this.zingayaAPI.onHandleMessage = function(t, n, i, o, s) {
  1414.                         this.imXSSprotection && (i = e.Utils.filterXSS(i)), this.dispatchEvent({
  1415.                             name: "MessageReceived",
  1416.                             id: t,
  1417.                             resource: n,
  1418.                             content: i,
  1419.                             message_id: o,
  1420.                             to: s
  1421.                         })
  1422.                     }.bind(this), this.zingayaAPI.onHandleSelfPresence = function(e, t, n, i) {
  1423.                         this.dispatchEvent({
  1424.                             name: "PresenceUpdate",
  1425.                             id: e,
  1426.                             resource: t,
  1427.                             presence: n,
  1428.                             message: i
  1429.                         })
  1430.                     }.bind(this), this.zingayaAPI.onHandleChatState = function(e, t, n) {
  1431.                         this.dispatchEvent({
  1432.                             name: "ChatStateUpdate",
  1433.                             id: e,
  1434.                             resource: t,
  1435.                             state: n
  1436.                         })
  1437.                     }.bind(this), this.zingayaAPI.onHandleMessageEvent = function(e, t, n, i) {
  1438.                         this.dispatchEvent({
  1439.                             name: "MessageStatus",
  1440.                             id: e,
  1441.                             resource: t,
  1442.                             type: n,
  1443.                             message_id: i
  1444.                         })
  1445.                     }.bind(this), this.zingayaAPI.onHandleMessageModified = function(t, n, i, o) {
  1446.                         this.imXSSprotection && (i = e.Utils.filterXSS(i)), this.dispatchEvent({
  1447.                             name: "MessageModified",
  1448.                             id: t,
  1449.                             message_id: n,
  1450.                             content: i,
  1451.                             to: o
  1452.                         })
  1453.                     }.bind(this), this.zingayaAPI.onHandleMessageRemoved = function(e, t, n) {
  1454.                         this.dispatchEvent({
  1455.                             name: "MessageRemoved",
  1456.                             id: e,
  1457.                             message_id: t,
  1458.                             to: n
  1459.                         })
  1460.                     }.bind(this), this.zingayaAPI.onHandleSubscription = function(e, t, n, i) {
  1461.                         this.dispatchEvent({
  1462.                             name: "SubscriptionRequest",
  1463.                             id: e,
  1464.                             resource: t,
  1465.                             type: n,
  1466.                             message: i
  1467.                         })
  1468.                     }.bind(this), this.zingayaAPI.onCallRemoteFunctionError = function(e, t, n, i) {
  1469.                         this.dispatchEvent({
  1470.                             name: "IMError",
  1471.                             errorType: "RemoteFunctionError",
  1472.                             errorData: {
  1473.                                 method: e,
  1474.                                 params: t,
  1475.                                 code: n,
  1476.                                 description: i
  1477.                             }
  1478.                         })
  1479.                     }.bind(this), this.zingayaAPI.onIMError = function(e, t, n) {
  1480.                         this.dispatchEvent({
  1481.                             name: "IMError",
  1482.                             errorType: "Error",
  1483.                             errorData: {
  1484.                                 type: e,
  1485.                                 code: t,
  1486.                                 description: n
  1487.                             }
  1488.                         })
  1489.                     }.bind(this), this.zingayaAPI.onUCConnected = function(e) {
  1490.                         this.imAutoReconnect === !0 && clearInterval(this.imReconnectTs), this.dispatchEvent({
  1491.                             name: "UCConnected",
  1492.                             id: e
  1493.                         })
  1494.                     }.bind(this), this.zingayaAPI.onUCDisconnected = function() {
  1495.                         this.imAutoReconnect === !0 && (clearInterval(this.imReconnectTs), this.imReconnectTs = setInterval(function() {
  1496.                             this.zingayaAPI.ucReconnect()
  1497.                         }.bind(this), this.imReconnectInterval)), this.dispatchEvent({
  1498.                             name: "UCDisconnected"
  1499.                         })
  1500.                     }.bind(this), this.zingayaAPI.onIMRosterError = function(e) {
  1501.                         this.dispatchEvent({
  1502.                             name: "IMError",
  1503.                             errorType: "RosterError",
  1504.                             errorData: {
  1505.                                 code: e
  1506.                             }
  1507.                         })
  1508.                     }.bind(this), this.zingayaAPI.onMUCError = function(e, t, n, i) {
  1509.                         this.dispatchEvent({
  1510.                             name: "ChatRoomError",
  1511.                             room: e,
  1512.                             operation: t,
  1513.                             code: n,
  1514.                             text: i
  1515.                         })
  1516.                     }.bind(this), this.zingayaAPI.onMUCRoomCreation = function(e) {
  1517.                         this.dispatchEvent({
  1518.                             name: "ChatRoomCreated",
  1519.                             room: e
  1520.                         })
  1521.                     }.bind(this), this.zingayaAPI.onMUCSubject = function(e, t, n, i) {
  1522.                         this.dispatchEvent({
  1523.                             name: "ChatRoomSubjectChange",
  1524.                             room: e,
  1525.                             id: t,
  1526.                             resource: n,
  1527.                             subject: i
  1528.                         })
  1529.                     }.bind(this), this.zingayaAPI.onMUCInfo = function(e, t, n, i) {
  1530.                         this.dispatchEvent({
  1531.                             name: "ChatRoomInfo",
  1532.                             room: e,
  1533.                             features: t,
  1534.                             room_name: n,
  1535.                             info: i
  1536.                         })
  1537.                     }.bind(this), this.zingayaAPI.onMUCMessage = function(t, n, i, o, s, a, r) {
  1538.                         this.imXSSprotection && (r = e.Utils.filterXSS(r)), this.dispatchEvent({
  1539.                             name: "ChatRoomMessageReceived",
  1540.                             room: t,
  1541.                             message_id: n,
  1542.                             private_message: i,
  1543.                             timestamp: o,
  1544.                             from: s,
  1545.                             resource: a,
  1546.                             content: r
  1547.                         })
  1548.                     }.bind(this), this.zingayaAPI.onMUCInvitation = function(e, t, n, i, o, s) {
  1549.                         this.dispatchEvent({
  1550.                             name: "ChatRoomInvitation",
  1551.                             room: e,
  1552.                             from: t,
  1553.                             reason: n,
  1554.                             body: i,
  1555.                             password: o,
  1556.                             cont: s
  1557.                         })
  1558.                     }.bind(this), this.zingayaAPI.onMUCInviteDecline = function(e, t, n) {
  1559.                         this.dispatchEvent({
  1560.                             name: "ChatRoomInviteDeclined",
  1561.                             room: e,
  1562.                             invitee: t,
  1563.                             reason: n
  1564.                         })
  1565.                     }.bind(this), this.zingayaAPI.onMUCParticipantPresence = function(e, t, n, i) {
  1566.                         this.dispatchEvent({
  1567.                             name: "ChatRoomPresenceUpdate",
  1568.                             room: e,
  1569.                             participant: t,
  1570.                             presence: n,
  1571.                             message: i
  1572.                         })
  1573.                     }.bind(this), this.zingayaAPI.onMUCNewParticipant = function(e, t, n) {
  1574.                         this.dispatchEvent({
  1575.                             name: "ChatRoomNewParticipant",
  1576.                             room: e,
  1577.                             participant: t,
  1578.                             displayName: n
  1579.                         })
  1580.                     }.bind(this), this.zingayaAPI.onMUCParticipantExit = function(e, t) {
  1581.                         this.dispatchEvent({
  1582.                             name: "ChatRoomParticipantExit",
  1583.                             room: e,
  1584.                             participant: t
  1585.                         })
  1586.                     }.bind(this), this.zingayaAPI.onMUCRooms = function(e) {
  1587.                         this.dispatchEvent({
  1588.                             name: "ChatRoomsDataReceived",
  1589.                             rooms: e
  1590.                         })
  1591.                     }.bind(this), this.zingayaAPI.onMUCParticipants = function(e, t) {
  1592.                         this.dispatchEvent({
  1593.                             name: "ChatRoomParticipants",
  1594.                             room: e,
  1595.                             participants: t
  1596.                         })
  1597.                     }.bind(this), this.zingayaAPI.onMUCBanList = function(e, t) {
  1598.                         this.dispatchEvent({
  1599.                             name: "ChatRoomBanList",
  1600.                             room: e,
  1601.                             participants: t
  1602.                         })
  1603.                     }.bind(this), this.zingayaAPI.onMUCHistory = function(t, n, i) {
  1604.                         this.imXSSprotection && i.forEach(function(t) {
  1605.                             t.body = e.Utils.filterXSS(t.body)
  1606.                         }), this.dispatchEvent({
  1607.                             name: "ChatRoomHistoryReceived",
  1608.                             room: t,
  1609.                             message_id: n,
  1610.                             messages: i
  1611.                         })
  1612.                     }.bind(this), this.zingayaAPI.onMUCMessageModified = function(t, n, i, o, s, a, r) {
  1613.                         this.imXSSprotection && (r = e.Utils.filterXSS(r)), this.dispatchEvent({
  1614.                             name: "ChatRoomMessageModified",
  1615.                             room: t,
  1616.                             private_message: n,
  1617.                             message_id: i,
  1618.                             timestamp: o,
  1619.                             from: s,
  1620.                             resource: a,
  1621.                             content: r
  1622.                         })
  1623.                     }.bind(this), this.zingayaAPI.onMUCMessageRemoved = function(e, t, n, i, o, s) {
  1624.                         this.dispatchEvent({
  1625.                             name: "ChatRoomMessageRemoved",
  1626.                             room: e,
  1627.                             private_message: t,
  1628.                             message_id: n,
  1629.                             timestamp: i,
  1630.                             from: o,
  1631.                             resource: s
  1632.                         })
  1633.                     }.bind(this), this.zingayaAPI.onMUCChatState = function(e, t, n, i) {
  1634.                         this.dispatchEvent({
  1635.                             name: "ChatRoomStateUpdate",
  1636.                             room: e,
  1637.                             from: t,
  1638.                             resource: n,
  1639.                             state: i
  1640.                         })
  1641.                     }.bind(this), this.zingayaAPI.onHistory = function(t, n, i) {
  1642.                         this.imXSSprotection && i.forEach(function(t) {
  1643.                             t.body = e.Utils.filterXSS(t.body)
  1644.                         }), this.dispatchEvent({
  1645.                             name: "ChatHistoryReceived",
  1646.                             id: t,
  1647.                             message_id: n,
  1648.                             messages: i
  1649.                         })
  1650.                     }.bind(this), this.zingayaAPI.onCallICETimeout = function(e) {
  1651.                         this.getCall(e).dispatchEvent({
  1652.                             name: "ICETimeout",
  1653.                             call: this.getCall(e)
  1654.                         })
  1655.                     }.bind(this), this.zingayaAPI.writeLog = function(e) {
  1656.                         if ("function" == typeof this.writeLog) this.writeLog(e);
  1657.                         else {
  1658.                             var t = {
  1659.                                 year: "numeric",
  1660.                                 month: "numeric",
  1661.                                 day: "numeric"
  1662.                             };
  1663.                             this.showDebugInfo && BXIM.webrtc.phoneLog("VI WebRTC: " + (new Date).toLocaleTimeString("en-US", t) + " " + e)
  1664.                         }
  1665.                     }.bind(this), this.zingayaAPI.writeTrace = function(e) {
  1666.                         if ("function" == typeof this.writeTrace) this.writeTrace(e);
  1667.                         else {
  1668.                             var t = {
  1669.                                 year: "numeric",
  1670.                                 month: "numeric",
  1671.                                 day: "numeric"
  1672.                             };
  1673.                             this.showDebugInfo && BXIM.webrtc.phoneLog("VI WebRTC: " + (new Date).toLocaleTimeString("en-US", t) + " " + e)
  1674.                         }
  1675.                     }.bind(this), checkDOMReady = function() {
  1676.                         "undefined" != typeof document && (clearInterval(a), this.dispatchEvent({
  1677.                             name: "SDKReady",
  1678.                             version: e.version
  1679.                         }), this.deviceEnumAPI())
  1680.                     }, a = setInterval(checkDOMReady.bind(this), 100);
  1681.                     else {
  1682.                         if (this.useRTCOnly) throw new Error("NO_WEBRTC_SUPPORT");
  1683.                         var r = function() {
  1684.                             function e() {
  1685.                                 if (!G) {
  1686.                                     try {
  1687.                                         var e = x.getElementsByTagName("body")[0].appendChild(v("span"));
  1688.                                         e.parentNode.removeChild(e)
  1689.                                     } catch (t) {
  1690.                                         return
  1691.                                     }
  1692.                                     G = !0;
  1693.                                     for (var n = H.length, i = 0; n > i; i++) H[i]()
  1694.                                 }
  1695.                             }
  1696.  
  1697.                             function n(e) {
  1698.                                 G ? e() : H[H.length] = e
  1699.                             }
  1700.  
  1701.                             function i(e) {
  1702.                                 if (typeof V.addEventListener != b) V.addEventListener("load", e, !1);
  1703.                                 else if (typeof x.addEventListener != b) x.addEventListener("load", e, !1);
  1704.                                 else if (typeof V.attachEvent != b) y(V, "onload", e);
  1705.                                 else if ("function" == typeof V.onload) {
  1706.                                     var t = V.onload;
  1707.                                     V.onload = function() {
  1708.                                         t(), e()
  1709.                                     }
  1710.                                 } else V.onload = e
  1711.                             }
  1712.  
  1713.                             function o() {
  1714.                                 k ? s() : a()
  1715.                             }
  1716.  
  1717.                             function s() {
  1718.                                 var e = x.getElementsByTagName("body")[0],
  1719.                                     t = v(N);
  1720.                                 t.setAttribute("type", L);
  1721.                                 var n = e.appendChild(t);
  1722.                                 if (n) {
  1723.                                     var i = 0;
  1724.                                     ! function() {
  1725.                                         if (typeof n.GetVariable != b) {
  1726.                                             var o = n.GetVariable("$version");
  1727.                                             o && (o = o.split(" ")[1].split(","), J.pv = [parseInt(o[0], 10), parseInt(o[1], 10), parseInt(o[2], 10)])
  1728.                                         } else if (10 > i) return i++, void setTimeout(arguments.callee, 10);
  1729.                                         e.removeChild(t), n = null, a()
  1730.                                     }()
  1731.                                 } else a()
  1732.                             }
  1733.  
  1734.                             function a() {
  1735.                                 var e = W.length;
  1736.                                 if (e > 0)
  1737.                                     for (var t = 0; e > t; t++) {
  1738.                                         var n = W[t].id,
  1739.                                             i = W[t].callbackFn,
  1740.                                             o = {
  1741.                                                 success: !1,
  1742.                                                 id: n
  1743.                                             };
  1744.                                         if (J.pv[0] > 0) {
  1745.                                             var s = g(n);
  1746.                                             if (s)
  1747.                                                 if (!S(W[t].swfVersion) || J.wk && J.wk < 312)
  1748.                                                     if (W[t].expressInstall && l()) {
  1749.                                                         var a = {};
  1750.                                                         a.data = W[t].expressInstall, a.width = s.getAttribute("width") || "0", a.height = s.getAttribute("height") || "0", s.getAttribute("class") && (a.styleclass = s.getAttribute("class")), s.getAttribute("align") && (a.align = s.getAttribute("align"));
  1751.                                                         for (var r = {}, u = s.getElementsByTagName("param"), f = u.length, p = 0; f > p; p++) "movie" != u[p].getAttribute("name").toLowerCase() && (r[u[p].getAttribute("name")] = u[p].getAttribute("value"));
  1752.                                                         d(a, r, n, i)
  1753.                                                     } else h(s), i && i(o);
  1754.                                             else T(n, !0), i && (o.success = !0, o.ref = c(n), i(o))
  1755.                                         } else if (T(n, !0), i) {
  1756.                                             var C = c(n);
  1757.                                             C && typeof C.SetVariable != b && (o.success = !0, o.ref = C), i(o)
  1758.                                         }
  1759.                                     }
  1760.                             }
  1761.  
  1762.                             function c(e) {
  1763.                                 var t = null,
  1764.                                     n = g(e);
  1765.                                 if (n && "OBJECT" == n.nodeName)
  1766.                                     if (typeof n.SetVariable != b) t = n;
  1767.                                     else {
  1768.                                         var i = n.getElementsByTagName(N)[0];
  1769.                                         i && (t = i)
  1770.                                     }
  1771.                                 return t
  1772.                             }
  1773.  
  1774.                             function l() {
  1775.                                 return !B && S("6.0.65") && (J.win || J.mac) && !(J.wk && J.wk < 312)
  1776.                             }
  1777.  
  1778.                             function d(e, t, n, i) {
  1779.                                 B = !0, M = i || null, O = {
  1780.                                     success: !1,
  1781.                                     id: n
  1782.                                 };
  1783.                                 var o = g(n);
  1784.                                 if (o) {
  1785.                                     "OBJECT" == o.nodeName ? (E = u(o), w = null) : (E = o, w = n), e.id = F, (typeof e.width == b || !/%$/.test(e.width) && parseInt(e.width, 10) < 310) && (e.width = "310"), (typeof e.height == b || !/%$/.test(e.height) && parseInt(e.height, 10) < 137) && (e.height = "137"), x.title = x.title.slice(0, 47) + " - Flash Player Installation";
  1786.                                     var s = J.ie && J.win ? "ActiveX" : "PlugIn",
  1787.                                         a = "MMredirectURL=" + V.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + s + "&MMdoctitle=" + x.title;
  1788.                                     if (typeof t.flashvars != b ? t.flashvars += "&" + a : t.flashvars = a, J.ie && J.win && 4 != o.readyState) {
  1789.                                         var r = v("div");
  1790.                                         n += "SWFObjectNew", r.setAttribute("id", n), o.parentNode.insertBefore(r, o), o.style.display = "none",
  1791.                                             function() {
  1792.                                                 4 == o.readyState ? o.parentNode.removeChild(o) : setTimeout(arguments.callee, 10)
  1793.                                             }()
  1794.                                     }
  1795.                                     f(e, t, n)
  1796.                                 }
  1797.                             }
  1798.  
  1799.                             function h(e) {
  1800.                                 if (J.ie && J.win && 4 != e.readyState) {
  1801.                                     var t = v("div");
  1802.                                     e.parentNode.insertBefore(t, e), t.parentNode.replaceChild(u(e), t), e.style.display = "none",
  1803.                                         function() {
  1804.                                             4 == e.readyState ? e.parentNode.removeChild(e) : setTimeout(arguments.callee, 10)
  1805.                                         }()
  1806.                                 } else e.parentNode.replaceChild(u(e), e)
  1807.                             }
  1808.  
  1809.                             function u(e) {
  1810.                                 var t = v("div");
  1811.                                 if (J.win && J.ie) t.innerHTML = e.innerHTML;
  1812.                                 else {
  1813.                                     var n = e.getElementsByTagName(N)[0];
  1814.                                     if (n) {
  1815.                                         var i = n.childNodes;
  1816.                                         if (i)
  1817.                                             for (var o = i.length, s = 0; o > s; s++) 1 == i[s].nodeType && "PARAM" == i[s].nodeName || 8 == i[s].nodeType || t.appendChild(i[s].cloneNode(!0))
  1818.                                     }
  1819.                                 }
  1820.                                 return t
  1821.                             }
  1822.  
  1823.                             function f(e, t, n) {
  1824.                                 var i, o = g(n);
  1825.                                 if (J.wk && J.wk < 312) return i;
  1826.                                 if (o)
  1827.                                     if (typeof e.id == b && (e.id = n), J.ie && J.win) {
  1828.                                         var s = "";
  1829.                                         for (var a in e) e[a] != Object.prototype[a] && ("data" == a.toLowerCase() ? t.movie = e[a] : "styleclass" == a.toLowerCase() ? s += ' class="' + e[a] + '"' : "classid" != a.toLowerCase() && (s += " " + a + '="' + e[a] + '"'));
  1830.                                         var r = "";
  1831.                                         for (var c in t) t[c] != Object.prototype[c] && (r += '<param name="' + c + '" value="' + t[c] + '" />');
  1832.                                         o.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + s + ">" + r + "</object>", X[X.length] = e.id, i = g(e.id)
  1833.                                     } else {
  1834.                                         var l = v(N);
  1835.                                         l.setAttribute("type", L);
  1836.                                         for (var d in e) e[d] != Object.prototype[d] && ("styleclass" == d.toLowerCase() ? l.setAttribute("class", e[d]) : "classid" != d.toLowerCase() && l.setAttribute(d, e[d]));
  1837.                                         for (var h in t) t[h] != Object.prototype[h] && "movie" != h.toLowerCase() && p(l, h, t[h]);
  1838.                                         o.parentNode.replaceChild(l, o), i = l
  1839.                                     }
  1840.                                 return i
  1841.                             }
  1842.  
  1843.                             function p(e, t, n) {
  1844.                                 var i = v("param");
  1845.                                 i.setAttribute("name", t), i.setAttribute("value", n), e.appendChild(i)
  1846.                             }
  1847.  
  1848.                             function C(e) {
  1849.                                 var t = g(e);
  1850.                                 t && "OBJECT" == t.nodeName && (J.ie && J.win ? (t.style.display = "none", function() {
  1851.                                     4 == t.readyState ? m(e) : setTimeout(arguments.callee, 10)
  1852.                                 }()) : t.parentNode.removeChild(t))
  1853.                             }
  1854.  
  1855.                             function m(e) {
  1856.                                 var t = g(e);
  1857.                                 if (t) {
  1858.                                     for (var n in t) "function" == typeof t[n] && (t[n] = null);
  1859.                                     t.parentNode.removeChild(t)
  1860.                                 }
  1861.                             }
  1862.  
  1863.                             function g(e) {
  1864.                                 var t = null;
  1865.                                 try {
  1866.                                     t = x.getElementById(e)
  1867.                                 } catch (n) {}
  1868.                                 return t
  1869.                             }
  1870.  
  1871.                             function v(e) {
  1872.                                 return x.createElement(e)
  1873.                             }
  1874.  
  1875.                             function y(e, t, n) {
  1876.                                 e.attachEvent(t, n), j[j.length] = [e, t, n]
  1877.                             }
  1878.  
  1879.                             function S(e) {
  1880.                                 var t = J.pv,
  1881.                                     n = e.split(".");
  1882.                                 return n[0] = parseInt(n[0], 10), n[1] = parseInt(n[1], 10) || 0, n[2] = parseInt(n[2], 10) || 0, t[0] > n[0] || t[0] == n[0] && t[1] > n[1] || t[0] == n[0] && t[1] == n[1] && t[2] >= n[2] ? !0 : !1
  1883.                             }
  1884.  
  1885.                             function R(e, t, n, i) {
  1886.                                 if (!J.ie || !J.mac) {
  1887.                                     var o = x.getElementsByTagName("head")[0];
  1888.                                     if (o) {
  1889.                                         var s = n && "string" == typeof n ? n : "screen";
  1890.                                         if (i && (A = null, P = null), !A || P != s) {
  1891.                                             var a = v("style");
  1892.                                             a.setAttribute("type", "text/css"), a.setAttribute("media", s), A = o.appendChild(a), J.ie && J.win && typeof x.styleSheets != b && x.styleSheets.length > 0 && (A = x.styleSheets[x.styleSheets.length - 1]), P = s
  1893.                                         }
  1894.                                         J.ie && J.win ? A && typeof A.addRule == N && A.addRule(e, t) : A && typeof x.createTextNode != b && A.appendChild(x.createTextNode(e + " {" + t + "}"))
  1895.                                     }
  1896.                                 }
  1897.                             }
  1898.  
  1899.                             function T(e, t) {
  1900.                                 if (q) {
  1901.                                     var n = t ? "visible" : "hidden";
  1902.                                     G && g(e) ? g(e).style.visibility = n : R("#" + e, "visibility:" + n)
  1903.                                 }
  1904.                             }
  1905.  
  1906.                             function I(e) {
  1907.                                 var t = /[\\\"<>\.;]/,
  1908.                                     n = null != t.exec(e);
  1909.                                 return n && typeof encodeURIComponent != b ? encodeURIComponent(e) : e
  1910.                             } {
  1911.                                 var E, w, M, O, A, P, b = "undefined",
  1912.                                     N = "object",
  1913.                                     U = "Shockwave Flash",
  1914.                                     _ = "ShockwaveFlash.ShockwaveFlash",
  1915.                                     L = "application/x-shockwave-flash",
  1916.                                     F = "SWFObjectExprInst",
  1917.                                     D = "onreadystatechange",
  1918.                                     V = window,
  1919.                                     x = document,
  1920.                                     z = navigator,
  1921.                                     k = !1,
  1922.                                     H = [o],
  1923.                                     W = [],
  1924.                                     X = [],
  1925.                                     j = [],
  1926.                                     G = !1,
  1927.                                     B = !1,
  1928.                                     q = !0,
  1929.                                     J = function() {
  1930.                                         var e = typeof x.getElementById != b && typeof x.getElementsByTagName != b && typeof x.createElement != b,
  1931.                                             t = z.userAgent.toLowerCase(),
  1932.                                             n = z.platform.toLowerCase(),
  1933.                                             i = /win/.test(n ? n : t),
  1934.                                             o = /mac/.test(n ? n : t),
  1935.                                             s = /webkit/.test(t) ? parseFloat(t.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : !1,
  1936.                                             a = !1,
  1937.                                             r = [0, 0, 0],
  1938.                                             c = null;
  1939.                                         if (typeof z.plugins != b && typeof z.plugins[U] == N) c = z.plugins[U].description, !c || typeof z.mimeTypes != b && z.mimeTypes[L] && !z.mimeTypes[L].enabledPlugin || (k = !0, a = !1, c = c.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), r[0] = parseInt(c.replace(/^(.*)\..*$/, "$1"), 10), r[1] = parseInt(c.replace(/^.*\.(.*)\s.*$/, "$1"), 10), r[2] = /[a-zA-Z]/.test(c) ? parseInt(c.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0);
  1940.                                         else if (typeof V.ActiveXObject != b) try {
  1941.                                             var l = new ActiveXObject(_);
  1942.                                             l && (c = l.GetVariable("$version"), c && (a = !0, c = c.split(" ")[1].split(","), r = [parseInt(c[0], 10), parseInt(c[1], 10), parseInt(c[2], 10)]))
  1943.                                         } catch (d) {}
  1944.                                         return {
  1945.                                             w3: e,
  1946.                                             pv: r,
  1947.                                             wk: s,
  1948.                                             ie: a,
  1949.                                             win: i,
  1950.                                             mac: o
  1951.                                         }
  1952.                                     }();
  1953.                                 ! function() {
  1954.                                     J.w3 && ((typeof x.readyState != b && "complete" == x.readyState || typeof x.readyState == b && (x.getElementsByTagName("body")[0] || x.body)) && e(), G || (typeof x.addEventListener != b && x.addEventListener("DOMContentLoaded", e, !1), J.ie && J.win && (x.attachEvent(D, function() {
  1955.                                         "complete" == x.readyState && (x.detachEvent(D, arguments.callee), e())
  1956.                                     }), V == top && ! function() {
  1957.                                         if (!G) {
  1958.                                             try {
  1959.                                                 x.documentElement.doScroll("left")
  1960.                                             } catch (t) {
  1961.                                                 return void setTimeout(arguments.callee, 0)
  1962.                                             }
  1963.                                             e()
  1964.                                         }
  1965.                                     }()), J.wk && ! function() {
  1966.                                         return G ? void 0 : /loaded|complete/.test(x.readyState) ? void e() : void setTimeout(arguments.callee, 0)
  1967.                                     }(), i(e)))
  1968.                                 }(),
  1969.                                 function() {
  1970.                                     J.ie && J.win && window.attachEvent("onunload", function() {
  1971.                                         for (var e = j.length, t = 0; e > t; t++) j[t][0].detachEvent(j[t][1], j[t][2]);
  1972.                                         for (var n = X.length, i = 0; n > i; i++) C(X[i]);
  1973.                                         for (var o in J) J[o] = null;
  1974.                                         J = null;
  1975.                                         for (var s in r) r[s] = null;
  1976.                                         r = null
  1977.                                     })
  1978.                                 }()
  1979.                             }
  1980.                             return {
  1981.                                 registerObject: function(e, t, n, i) {
  1982.                                     if (J.w3 && e && t) {
  1983.                                         var o = {};
  1984.                                         o.id = e, o.swfVersion = t, o.expressInstall = n, o.callbackFn = i, W[W.length] = o, T(e, !1)
  1985.                                     } else i && i({
  1986.                                         success: !1,
  1987.                                         id: e
  1988.                                     })
  1989.                                 },
  1990.                                 getObjectById: function(e) {
  1991.                                     return J.w3 ? c(e) : void 0
  1992.                                 },
  1993.                                 embedSWF: function(e, t, i, o, s, a, r, c, h, u) {
  1994.                                     var p = {
  1995.                                         success: !1,
  1996.                                         id: t
  1997.                                     };
  1998.                                     J.w3 && !(J.wk && J.wk < 312) && e && t && i && o && s ? (T(t, !1), n(function() {
  1999.                                         i += "", o += "";
  2000.                                         var n = {};
  2001.                                         if (h && typeof h === N)
  2002.                                             for (var C in h) n[C] = h[C];
  2003.                                         n.data = e, n.width = i, n.height = o;
  2004.                                         var m = {};
  2005.                                         if (c && typeof c === N)
  2006.                                             for (var g in c) m[g] = c[g];
  2007.                                         if (r && typeof r === N)
  2008.                                             for (var v in r) typeof m.flashvars != b ? m.flashvars += "&" + v + "=" + r[v] : m.flashvars = v + "=" + r[v];
  2009.                                         if (S(s)) {
  2010.                                             var y = f(n, m, t);
  2011.                                             n.id == t && T(t, !0), p.success = !0, p.ref = y
  2012.                                         } else {
  2013.                                             if (a && l()) return n.data = a, void d(n, m, t, u);
  2014.                                             T(t, !0)
  2015.                                         }
  2016.                                         u && u(p)
  2017.                                     })) : u && u(p)
  2018.                                 },
  2019.                                 switchOffAutoHideShow: function() {
  2020.                                     q = !1
  2021.                                 },
  2022.                                 ua: J,
  2023.                                 getFlashPlayerVersion: function() {
  2024.                                     return {
  2025.                                         major: J.pv[0],
  2026.                                         minor: J.pv[1],
  2027.                                         release: J.pv[2]
  2028.                                     }
  2029.                                 },
  2030.                                 hasFlashPlayerVersion: S,
  2031.                                 createSWF: function(e, n, i) {
  2032.                                     return J.w3 ? f(e, n, i) : t
  2033.                                 },
  2034.                                 showExpressInstall: function(e, t, n, i) {
  2035.                                     J.w3 && l() && d(e, t, n, i)
  2036.                                 },
  2037.                                 removeSWF: function(e) {
  2038.                                     J.w3 && C(e)
  2039.                                 },
  2040.                                 createCSS: function(e, t, n, i) {
  2041.                                     J.w3 && R(e, t, n, i)
  2042.                                 },
  2043.                                 addDomLoadEvent: n,
  2044.                                 addLoadEvent: i,
  2045.                                 getQueryParamValue: function(e) {
  2046.                                     var t = x.location.search || x.location.hash;
  2047.                                     if (t) {
  2048.                                         if (/\?/.test(t) && (t = t.split("?")[1]), null == e) return I(t);
  2049.  
  2050.                                         for (var n = t.split("&"), i = 0; i < n.length; i++)
  2051.                                             if (n[i].substring(0, n[i].indexOf("=")) == e) return I(n[i].substring(n[i].indexOf("=") + 1))
  2052.                                     }
  2053.                                     return ""
  2054.                                 },
  2055.                                 expressInstallCallback: function() {
  2056.                                     if (B) {
  2057.                                         var e = g(F);
  2058.                                         e && E && (e.parentNode.replaceChild(E, e), w && (T(w, !0), J.ie && J.win && (E.style.display = "block")), M && M(O)), B = !1
  2059.                                     }
  2060.                                 }
  2061.                             }
  2062.                         }();
  2063.                         if (createContainer = function() {
  2064.                                 if ("undefined" != typeof document) {
  2065.                                     var e;
  2066.                                     if (clearInterval(a), null !== this.swfContainer) {
  2067.                                         if (e = document.getElementById(this.swfContainer), null === e) throw new Error("NO_SWF_CONTAINER");
  2068.                                         e.offsetWidth < 215 && (e.style.minWidth = e.style.width = "215px"), e.offsetHeight < 138 && (e.style.minHeight = e.style.height = "138px")
  2069.                                     } else e = document.createElement("div"), this.swfContainer = e.id = "voximplantcontainer", e.style.minWidth = e.style.width = "215px", e.style.minHeight = e.style.height = "138px", document.body.firstChild ? document.body.insertBefore(e, document.body.firstChild) : document.body.appendChild(e); - 1 != navigator.userAgent.indexOf("Safari") && (e.style.minWidth = e.style.width = "310px");
  2070.                                     var t = document.createElement("div");
  2071.                                     t.id = "voximplantcontainerSWF", e.appendChild(t);
  2072.                                     var n = {
  2073.                                             id: "voximplantSWF",
  2074.                                             name: "voximplantSWF"
  2075.                                         },
  2076.                                         i = !1,
  2077.                                         s = {
  2078.                                             allowScriptAccess: "always",
  2079.                                             wmode: "window",
  2080.                                             allowFullScreen: "true"
  2081.                                         };
  2082.                                     window.voxImplantFlashAPIReady = o.bind(this);
  2083.                                     var c = ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.voximplant.com/VoxImplant-3.0.swf?ver=080515";
  2084.                                     "undefined" != typeof this.swfURL && (c = this.swfURL), r.embedSWF(c, "voximplantcontainerSWF", "100%", "100%", "11.3", "http://cdn.voximplant.com/expressInstall.swf", i, s, n)
  2085.                                 }
  2086.                             }, !r.hasFlashPlayerVersion("11.3")) throw new Error("OLD_FLASH_VERSION");
  2087.                         a = setInterval(createContainer.bind(this), 100)
  2088.                     }
  2089.                     window.VILog = function(e) {
  2090.                         if ("function" == typeof this.writeLog) this.writeLog(e);
  2091.                         else {
  2092.                             var t = {
  2093.                                 year: "numeric",
  2094.                                 month: "numeric",
  2095.                                 day: "numeric"
  2096.                             };
  2097.                             this.showDebugInfo && "undefined" != typeof console && BXIM.webrtc.phoneLog("VI FLASH: " + (new Date).toLocaleTimeString("en-US", t) + " " + e)
  2098.                         }
  2099.                     }.bind(this), window.VIConnectionEstablished = function() {
  2100.                         this.connectionState(!0), this.dispatchEvent({
  2101.                             name: "ConnectionEstablished"
  2102.                         })
  2103.                     }.bind(this), window.VIConnectionFailed = function() {
  2104.                         this.serversList.length > 1 && "undefined" == typeof this.serverIp ? (this.serversList.splice(0, 1), this.connectTo(this.serversList[0], !0)) : this.dispatchEvent({
  2105.                             name: "ConnectionFailed"
  2106.                         })
  2107.                     }.bind(this), window.VIConnectionClosed = function() {
  2108.                         this.connectionState(!1), this.__cleanup(), this.dispatchEvent({
  2109.                             name: "ConnectionClosed"
  2110.                         }), this.progressTone && this.stopProgressTone()
  2111.                     }.bind(this), window.VIAuthFailed = function(e, t) {
  2112.                         this.dispatchEvent({
  2113.                             name: "AuthResult",
  2114.                             result: !1,
  2115.                             code: e,
  2116.                             key: t
  2117.                         })
  2118.                     }.bind(this), window.VIAuthSuccessful = function(e, t) {
  2119.                         "string" == typeof t && (t = JSON.parse(t)), this.dispatchEvent({
  2120.                             name: "AuthResult",
  2121.                             result: !0,
  2122.                             displayName: e,
  2123.                             options: t
  2124.                         })
  2125.                     }.bind(this), window.VICallConnected = function(e, t) {
  2126.                         this.getCall(e).dispatchEvent({
  2127.                             name: "Connected",
  2128.                             call: this.getCall(e),
  2129.                             headers: null !== t ? JSON.parse(t) : {}
  2130.                         }), this.progressTone && this.stopProgressTone()
  2131.                     }.bind(this), window.VICallDisconnected = function(e, t) {
  2132.                         this.getCall(e).dispatchEvent({
  2133.                             name: "Disconnected",
  2134.                             call: this.getCall(e),
  2135.                             headers: null !== t ? JSON.parse(t) : {}
  2136.                         }), this.removeCall(e), this.progressTone && this.stopProgressTone()
  2137.                     }.bind(this), window.VICallFailed = function(e, t, n, i) {
  2138.                         this.getCall(e).dispatchEvent({
  2139.                             name: "Failed",
  2140.                             call: this.getCall(e),
  2141.                             code: t,
  2142.                             reason: n,
  2143.                             headers: null !== i ? JSON.parse(i) : {}
  2144.                         }), this.removeCall(e), this.progressTone && this.stopProgressTone()
  2145.                     }.bind(this), window.VIMicAccessResult = function(e) {
  2146.                         this.dispatchEvent({
  2147.                             name: "MicAccessResult",
  2148.                             result: e
  2149.                         })
  2150.                     }.bind(this), window.VIProgressToneStart = function(e) {
  2151.                         this.getCall(e).dispatchEvent({
  2152.                             name: "ProgressToneStart",
  2153.                             call: this.getCall(e)
  2154.                         }), this.progressTone && this.playProgressTone()
  2155.                     }.bind(this), window.VIProgressToneStop = function(e) {
  2156.                         this.getCall(e).dispatchEvent({
  2157.                             name: "ProgressToneStop",
  2158.                             call: this.getCall(e)
  2159.                         }), this.progressTone && this.stopProgressTone()
  2160.                     }.bind(this), window.VIIncomingCall = function(e, t, i, o) {
  2161.                         var s = new n(e, t, i, null !== o ? JSON.parse(o) : {}, !1);
  2162.                         this.calls.length > 0 && this.zingayaAPI.setCallActive(e, !1), this.calls.push(s), this.dispatchEvent({
  2163.                             name: "IncomingCall",
  2164.                             call: s,
  2165.                             headers: null !== o ? JSON.parse(o) : {}
  2166.                         })
  2167.                     }.bind(this), window.VISIPInfoReceived = function(e, t, n, i, o) {
  2168.                         "application" == t && "zingaya-im" == n ? this.getCall(e).dispatchEvent({
  2169.                             name: "MessageReceived",
  2170.                             call: this.getCall(e),
  2171.                             text: i
  2172.                         }) : (null !== o && (o = JSON.parse(o)), this.getCall(e).dispatchEvent({
  2173.                             name: "InfoReceived",
  2174.                             call: this.getCall(e),
  2175.                             mimeType: t + "/" + n,
  2176.                             body: i,
  2177.                             headers: o
  2178.                         }))
  2179.                     }.bind(this), window.VIToneScriptPlaybackStop = function() {
  2180.                         this.dispatchEvent({
  2181.                             name: "PlaybackFinished"
  2182.                         })
  2183.                     }.bind(this), window.VITransferComplete = function(e) {
  2184.                         this.getCall(e).dispatchEvent({
  2185.                             name: "TransferComplete",
  2186.                             call: this.getCall(e)
  2187.                         })
  2188.                     }.bind(this), window.VITransferFailed = function(e) {
  2189.                         this.getCall(e).dispatchEvent({
  2190.                             name: "TransferFailed",
  2191.                             call: this.getCall(e)
  2192.                         })
  2193.                     }.bind(this), window.VIPacketLossInfo = function(e) {
  2194.                         this.dispatchEvent({
  2195.                             name: "NetStatsReceived",
  2196.                             stats: {
  2197.                                 packetLoss: e
  2198.                             }
  2199.                         })
  2200.                     }.bind(this), window.VIHandleRoster = function(e, t) {
  2201.                         this.dispatchEvent({
  2202.                             name: "RosterReceived",
  2203.                             id: e,
  2204.                             roster: JSON.parse(t)
  2205.                         })
  2206.                     }.bind(this), window.VIHandleRosterPresence = function(e, t, n, i) {
  2207.                         this.dispatchEvent({
  2208.                             name: "RosterPresenceUpdate",
  2209.                             id: e,
  2210.                             resource: t,
  2211.                             presence: n,
  2212.                             message: i
  2213.                         })
  2214.                     }.bind(this), window.VIHandleMessage = function(e, t, n, i) {
  2215.                         if (this.imXSSprotection) {
  2216.                             var o = document.createElement("div");
  2217.                             o.appendChild(document.createTextNode(n)), n = o.innerHTML
  2218.                         }
  2219.                         this.dispatchEvent({
  2220.                             name: "MessageReceived",
  2221.                             id: e,
  2222.                             resource: t,
  2223.                             content: n,
  2224.                             message_id: i
  2225.                         })
  2226.                     }.bind(this), window.VIHandlePresence = function(e, t, n, i) {
  2227.                         this.dispatchEvent({
  2228.                             name: "PresenceUpdate",
  2229.                             id: e,
  2230.                             resource: t,
  2231.                             presence: n,
  2232.                             message: i
  2233.                         })
  2234.                     }.bind(this), window.VIHandleChateState = function(e, t, n) {
  2235.                         this.dispatchEvent({
  2236.                             name: "ChatStateUpdate",
  2237.                             id: e,
  2238.                             resource: t,
  2239.                             state: n
  2240.                         })
  2241.                     }.bind(this), window.VIHandleMessageEvent = function(e, t, n, i) {
  2242.                         this.dispatchEvent({
  2243.                             name: "MessageStatus",
  2244.                             id: e,
  2245.                             resource: t,
  2246.                             type: n,
  2247.                             message_id: i
  2248.                         })
  2249.                     }.bind(this), window.VIHandleRosterItem = function(e, t, n, i, o) {
  2250.                         this.dispatchEvent({
  2251.                             name: "RosterItemChange",
  2252.                             id: e,
  2253.                             resource: t,
  2254.                             type: n,
  2255.                             displayName: o
  2256.                         })
  2257.                     }.bind(this), window.VIHandleSubscription = function(e, t, n, i) {
  2258.                         this.dispatchEvent({
  2259.                             name: "SubscriptionRequest",
  2260.                             id: e,
  2261.                             resource: t,
  2262.                             type: n,
  2263.                             message: i
  2264.                         })
  2265.                     }.bind(this), window.VIHandleRemoteFunctionError = function(e, t, n, i) {
  2266.                         this.dispatchEvent({
  2267.                             name: "IMError",
  2268.                             errorType: "RemoteFunctionError",
  2269.                             errorData: {
  2270.                                 method: e,
  2271.                                 params: JSON.parse(t),
  2272.                                 code: n,
  2273.                                 description: i
  2274.                             }
  2275.                         })
  2276.                     }.bind(this), window.VIHandleIMError = function(e, t, n) {
  2277.                         this.dispatchEvent({
  2278.                             name: "IMError",
  2279.                             errorType: "Error",
  2280.                             errorData: {
  2281.                                 type: e,
  2282.                                 code: t,
  2283.                                 description: n
  2284.                             }
  2285.                         })
  2286.                     }.bind(this), window.VIHandleIMRosterError = function(e) {
  2287.                         this.dispatchEvent({
  2288.                             name: "IMError",
  2289.                             errorType: "RosterError",
  2290.                             errorData: {
  2291.                                 code: e
  2292.                             }
  2293.                         })
  2294.                     }.bind(this)
  2295.                 }, this.connectionState = function(e) {
  2296.                     return "undefined" == typeof e ? i : void(i = e)
  2297.                 }, this.getCall = function(e) {
  2298.                     for (var t = 0; t < this.calls.length; t++)
  2299.                         if (this.calls[t].call() == e) return this.calls[t];
  2300.                     return null
  2301.                 }, this.removeCall = function(e) {
  2302.                     for (var t = [], n = 0; n < this.calls.length; n++) this.calls[n].call() != e ? t.push(this.calls[n]) : delete this.calls[n];
  2303.                     this.calls = t
  2304.                 }, this.playProgressTone = function() {
  2305.                     null !== this.progressToneScript[this.progressToneCountry] && (this.playingNow || this.playToneScript(this.progressToneScript[this.progressToneCountry]), this.playingNow = !0)
  2306.                 }, this.stopProgressTone = function() {
  2307.                     this.playingNow && (this.stopPlayback(), this.playingNow = !1)
  2308.                 }, this.__call = function(t, i, o, s) {
  2309.                     if ("undefined" != typeof o && ("undefined" == typeof s && (s = {}), s["VI-CallData"] = o), !this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2310.                     var a, r;
  2311.                     return this.RTCsupported && !this.useFlashOnly ? (a = this.zingayaAPI.callTo(t, i, s), r = new n(a, t, "", s, !0, this.zingayaAPI), this.calls.length > 0 && this.zingayaAPI.setCallActive(a, !1)) : this.useRTCOnly || (s = JSON.stringify(s), a = e.Utils.swfMovie("voximplantSWF").call(t, i, null, s), r = new n(a, t, "", s, !1), this.calls.length > 0 && e.Utils.swfMovie("voximplantSWF").setCallActive(a, !1)), this.calls.push(r), r
  2312.                 }, this.__volume = function(e) {
  2313.                     return "undefined" == typeof e ? o : void(o = e)
  2314.                 }, this.__cleanup = function() {
  2315.                     if (this.calls.length > 0) {
  2316.                         var e, t = [];
  2317.                         for (e in this.calls) t.push(this.calls[e].id()), this.connectionState() && this.calls[e].hangup();
  2318.                         for (e in t) this.removeCall(t[e])
  2319.                     }
  2320.                 }
  2321.             }, e.Client.prototype = {
  2322.                 call: function(e, t, n, i) {
  2323.                     return this.__call(e, t, n, i)
  2324.                 },
  2325.                 config: function() {
  2326.                     return this.config
  2327.                 },
  2328.                 connect: function() {
  2329.                     "undefined" != typeof this.serverIp ? (host = this.serverIp, this.connectTo(host)) : (balancerResult = function(e) {
  2330.                         var t = String(e).indexOf(";"); - 1 == t ? host = e : (this.serversList = e.split(";"), host = this.serversList[0]), this.connectTo(host)
  2331.                     }, e.Utils.getServers(balancerResult.bind(this), !1, this))
  2332.                 },
  2333.                 connectTo: function(t, n) {
  2334.                     if (this.connectionState()) throw new Error("ALREADY_CONNECTED_TO_VOXIMPLANT");
  2335.                     this.host = t, this.RTCsupported && !this.useFlashOnly ? this.micRequired && n !== !0 ? (this.videoSupport && this.zingayaAPI.setConstraints(this.videoConstraints, null, null, !1), this.zingayaAPI.requestMedia(this.videoSupport, this.zingayaAPI.onMediaAccessGranted, this.zingayaAPI.onMediaAccessRejected)) : this.zingayaAPI.connectTo(t, "platform") : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").connect(t, n === !0 ? !1 : this.micRequired, this.micRequired && this.showFlashSettings)
  2336.                 },
  2337.                 disconnect: function() {
  2338.                     if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2339.                     this.__cleanup(), this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.destroy() : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").disconnect()
  2340.                 },
  2341.                 init: function(e) {
  2342.                     this.__init(e)
  2343.                 },
  2344.                 setOperatorACDStatus: function(t) {
  2345.                     if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2346.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.setOperatorACDStatus(t) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setOperatorACDStatus(t)
  2347.                 },
  2348.                 login: function(t, n, i) {
  2349.                     if (i = "undefined" != typeof i ? i : {}, i = e.Utils.extend({}, i), !this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2350.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.login(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").login(t, n, JSON.stringify(i))
  2351.                 },
  2352.                 loginWithCode: function(t, n, i) {
  2353.                     if (i = "undefined" != typeof i ? i : {}, i = e.Utils.extend({
  2354.                             serverPresenceControl: !1
  2355.                         }, i), !this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2356.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.loginStage2(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").loginStage2(t, n, JSON.stringify(i))
  2357.                 },
  2358.                 requestOneTimeLoginKey: function(t) {
  2359.                     if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2360.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.loginGenerateOneTimeKey(t) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").requestOneTimeLoginKey(t)
  2361.                 },
  2362.                 loginWithOneTimeKey: function(t, n, i) {
  2363.                     if (i = "undefined" != typeof i ? i : {}, i = e.Utils.extend({
  2364.                             serverPresenceControl: !1
  2365.                         }, i), !this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2366.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.loginUsingOneTimeKey(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").loginUsingOneTimeKey(t, n, JSON.stringify(i))
  2367.                 },
  2368.                 connected: function() {
  2369.                     return this.connectionState()
  2370.                 },
  2371.                 showLocalVideo: function(t) {
  2372.                     if ("undefined" == typeof t && (t = !0), this.RTCsupported && !this.useFlashOnly)
  2373.                         if (t)
  2374.                             if (null === document.getElementById("voximplantlocalvideo")) {
  2375.                                 var n = document.createElement("video");
  2376.                                 n.id = "voximplantlocalvideo", n.autoplay = "autoplay", n.muted = "true", document.body.firstChild ? document.body.insertBefore(n, document.body.firstChild) : document.body.appendChild(n), this.zingayaAPI.setLocalVideoSink(n)
  2377.                             } else document.getElementById("voximplantlocalvideo").style.display = "block";
  2378.                     else document.getElementById("voximplantlocalvideo").style.display = "none";
  2379.                     else this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").showLocalVideo(t)
  2380.                 },
  2381.                 setLocalVideoPosition: function(t, n) {
  2382.                     if (this.RTCsupported && !this.useFlashOnly) throw new Error("Please use CSS to position '#voximplantlocalvideo' element");
  2383.                     this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setSelfViewPosition(t, n)
  2384.                 },
  2385.                 setLocalVideoSize: function(t, n) {
  2386.                     if (this.RTCsupported && !this.useFlashOnly) throw new Error("Please use CSS to set size of '#voximplantlocalvideo' element");
  2387.                     this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setSelfViewSize(t, n)
  2388.                 },
  2389.                 setVideoSettings: function(t, n, i, o) {
  2390.                     if (this.RTCsupported && !this.useFlashOnly) this.zingayaAPI.setConstraints(t, function() {
  2391.                         null !== document.getElementById("voximplantlocalvideo") && this.zingayaAPI.setLocalVideoSink(document.getElementById("voximplantlocalvideo")), this.videoConstraints = t, "function" == typeof n && n()
  2392.                     }.bind(this), i, !0);
  2393.                     else if (!this.useRTCOnly) {
  2394.                         "[object Object]" == Object.prototype.toString.call(t) && (t = JSON.stringify(t));
  2395.                         try {
  2396.                             e.Utils.swfMovie("voximplantSWF").setVideoSettings(t)
  2397.                         } catch (s) {
  2398.                             "function" == typeof i && i()
  2399.                         }
  2400.                         "function" == typeof n && n()
  2401.                     }
  2402.                 },
  2403.                 setVideoBandwidth: function(e) {
  2404.                     this.RTCsupported && !this.useFlashOnly && (this.zingayaAPI.setVideoBandwidth(e), this.zingayaAPI.setDesiredVideoBandwidth(e))
  2405.                 },
  2406.                 playToneScript: function(t, n) {
  2407.                     this.RTCsupported && !this.useFlashOnly ? e.Utils.playToneScript(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").playToneScript(t, n)
  2408.                 },
  2409.                 stopPlayback: function() {
  2410.                     this.RTCsupported && !this.useFlashOnly ? e.Utils.stopPlayback() && this.dispatchEvent({
  2411.                         name: "PlaybackFinished"
  2412.                     }) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").stopPlayback()
  2413.                 },
  2414.                 volume: function(t) {
  2415.                     return "undefined" == typeof t ? this.__volume() : (t > 100 && (t = 100), 0 > t && (t = 0), this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.setPlaybackVolume(t / 100) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").changeIncomingAudioVolume(t), this.__volume(t), void 0)
  2416.                 },
  2417.                 audioSources: function() {
  2418.                     if (this.RTCsupported && !this.useFlashOnly && !this.deviceEnumAPI) throw new Error("NOT_SUPPORTED: enumerateDevices");
  2419.                     return this.audioSourcesList
  2420.                 },
  2421.                 videoSources: function() {
  2422.                     if (this.RTCsupported && !this.useFlashOnly && !this.deviceEnumAPI) throw new Error("NOT_SUPPORTED: enumerateDevices");
  2423.                     return this.videoSourcesList
  2424.                 },
  2425.                 audioOutputs: function() {
  2426.                     if (this.RTCsupported && !this.useFlashOnly && !this.deviceEnumAPI) throw new Error("NOT_SUPPORTED: enumerateDevices");
  2427.                     return this.audioOutputsList
  2428.                 },
  2429.                 useAudioSource: function(t, n, i) {
  2430.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.useAudioSource(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setAudioSource(t)
  2431.                 },
  2432.                 useVideoSource: function(t, n, i) {
  2433.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.useVideoSource(t, function() {
  2434.                         null !== document.getElementById("voximplantlocalvideo") && this.zingayaAPI.setLocalVideoSink(document.getElementById("voximplantlocalvideo")), "function" == typeof n && n()
  2435.                     }.bind(this), i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setVideoSource(t)
  2436.                 },
  2437.                 attachRecordingDevice: function(e, t) {
  2438.                     !this.RTCsupported || this.useFlashOnly || this.micRequired || this.zingayaAPI.requestMedia(this.videoSupport, e, t)
  2439.                 },
  2440.                 detachRecordingDevice: function() {
  2441.                     !this.RTCsupported || this.useFlashOnly || this.micRequired || this.zingayaAPI.stopLocalStream()
  2442.                 },
  2443.                 showFlashSettingsPanel: function(t) {
  2444.                     "undefined" == typeof t && (t = "default"), this.RTCsupported && !this.useFlashOnly || this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").showFlashSettings(t)
  2445.                 },
  2446.                 setCallActive: function(t, n) {
  2447.                     if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2448.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.setCallActive(t.call(), n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setCallActive(t.call(), n)
  2449.                 },
  2450.                 sendVideo: function(t) {
  2451.                     if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2452.                     "undefined" == typeof t && (t = !0), this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendVideo(t) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").sendVideo(t)
  2453.                 },
  2454.                 isRTCsupported: function() {
  2455.                     return this.RTCsupported
  2456.                 },
  2457.                 transferCall: function(t, n) {
  2458.                     if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2459.                     this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.transferCall(t.call(), n.call()) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").transferCall(t.call(), n.call())
  2460.                 },
  2461.                 setSwfColor: function(t) {
  2462.                     this.RTCsupported && !this.useFlashOnly || this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setStageColor(t)
  2463.                 },
  2464.                 setCodecPayload: function(t) {
  2465.                     this.RTCsupported && !this.useFlashOnly || this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").setCodecPayload(t)
  2466.                 },
  2467.                 startScreenSharing: function() {
  2468.                     this.RTCsupported && !this.useFlashOnly && this.zingayaAPI.shareScreen()
  2469.                 }
  2470.             }, e.Client.prototype.addEventListener = function(e, t) {
  2471.                 "undefined" == typeof this.eventListeners[e] && (this.eventListeners[e] = []), this.eventListeners[e].push(t)
  2472.             }, e.Client.prototype.removeEventListener = function(e, t) {
  2473.                 if ("undefined" != typeof this.eventListeners[e])
  2474.                     for (var n = 0; n < this.eventListeners[e].length; n++)
  2475.                         if (this.eventListeners[e][n] == t) {
  2476.                             this.eventListeners[e].splice(n, 1);
  2477.                             break
  2478.                         }
  2479.             }, e.Client.prototype.dispatchEvent = e.Call.prototype.dispatchEvent = function(e) {
  2480.                 var t = e.name;
  2481.                 if ("undefined" != typeof this.eventListeners[t])
  2482.                     for (var n = 0; n < this.eventListeners[t].length; n++) "function" == typeof this.eventListeners[t][n] && this.eventListeners[t][n](e)
  2483.             }
  2484.         }(i), function(e, t) {
  2485.             e.Client.prototype.addRosterItem = function(t, n, i) {
  2486.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2487.                 "undefined" == typeof i && (i = ""), this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.addRoster(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").addRosterItem(t, n, i)
  2488.             }, e.Client.prototype.removeRosterItem = function(t) {
  2489.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2490.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.removeRoster(t) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").removeRosterItem(t)
  2491.             }, e.Client.prototype.renameRosterItem = function(t, n) {
  2492.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2493.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.renameRosterItem(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").renameRosterItem(t, n)
  2494.             }, e.Client.prototype.addRosterItemGroup = function(t, n) {
  2495.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2496.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.addRosterItemGroup(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").addRosterItemGroup(t, n)
  2497.             }, e.Client.prototype.removeRosterItemGroup = function(t, n) {
  2498.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2499.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.delRosterItemGroup(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").delRosterItemGroup(t, n)
  2500.             }, e.Client.prototype.moveRosterItemGroup = function(t, n, i) {
  2501.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2502.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.moveRosterItemGroup(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").moveRosterItemGroup(t, n, i)
  2503.             }, e.Client.prototype.sendInstantMessage = function(t, n) {
  2504.                 var i = e.Utils.generateUUID();
  2505.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2506.                 return this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendTextMessage(t, n, i) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").sendInstantMessage(t, n, i), i
  2507.             }, e.Client.prototype.editInstantMessage = function(e, t, n) {
  2508.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2509.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.editTextMessage(e, t, n) : !this.useRTCOnly
  2510.             }, e.Client.prototype.removeInstantMessage = function(e, t) {
  2511.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2512.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.removeTextMessage(e, t) : !this.useRTCOnly
  2513.             }, e.Client.prototype.setChatState = function(t, n) {
  2514.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2515.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendChatState(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").sendChatState(t, n)
  2516.             }, e.Client.prototype.setMessageStatus = function(t, n, i) {
  2517.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2518.                 if ("string" == typeof i) i = [i];
  2519.                 else if (!Array.isArray(i)) throw new Error("message_id should be string or array");
  2520.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.raiseMessageEvent(t, n, JSON.stringify(i)) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").raiseMessageEvent(t, n, JSON.stringify(i))
  2521.             }, e.Client.prototype.setPresenceStatus = function(t, n) {
  2522.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2523.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendStatus(t, n) : this.useRTCOnly || e.Utils.swfMovie("voximplantSWF").sendStatus(t, n)
  2524.             }, e.Client.prototype.createChatRoom = function(t, n) {
  2525.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2526.                 var i = e.Utils.generateUUID();
  2527.                 return this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.joinMUC(i, t, n) : !this.useRTCOnly, i
  2528.             }, e.Client.prototype.joinChatRoom = function(e, t) {
  2529.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2530.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.joinMUC(e, t) : !this.useRTCOnly
  2531.             }, e.Client.prototype.acceptChatRoomInvite = e.Client.prototype.joinChatRoom, e.Client.prototype.leaveChatRoom = function(e, t) {
  2532.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2533.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.leaveMUC(e, t) : !this.useRTCOnly
  2534.             }, e.Client.prototype.sendChatRoomMessage = function(t, n) {
  2535.                 var i = e.Utils.generateUUID();
  2536.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2537.                 return this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendMUCMessage(t, n, i) : !this.useRTCOnly, i
  2538.             }, e.Client.prototype.editChatRoomMessage = function(e, t, n) {
  2539.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2540.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.editMUCMessage(e, t, n) : !this.useRTCOnly
  2541.             }, e.Client.prototype.removeChatRoomMessage = function(e, t) {
  2542.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2543.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.removeMUCMessage(e, t) : !this.useRTCOnly
  2544.             }, e.Client.prototype.inviteToChatRoom = function(e, t, n, i) {
  2545.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2546.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.inviteMUC(e, t, n, i) : !this.useRTCOnly
  2547.             }, e.Client.prototype.declineChatRoomInvite = function(e, t, n) {
  2548.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2549.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.declineMUCinvitation(e, t, n) : !this.useRTCOnly
  2550.             }, e.Client.prototype.setChatRoomSubject = function(e, t) {
  2551.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2552.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.setSubject(e, t) : !this.useRTCOnly
  2553.             }, e.Client.prototype.removeChatRoomUser = function(e, t, n) {
  2554.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2555.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.kickMUCUser(e, t, n) : !this.useRTCOnly
  2556.             }, e.Client.prototype.banChatRoomUser = function(e, t, n) {
  2557.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2558.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.banMUCUser(e, t, n) : !this.useRTCOnly
  2559.             }, e.Client.prototype.unbanChatRoomUser = function(e, t, n) {
  2560.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2561.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.unbanMUCUser(e, t, n) : !this.useRTCOnly
  2562.             }, e.Client.prototype.getInstantMessagingHistory = function(e, t, n, i) {
  2563.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2564.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.requestHistory(e, t, n, i) : !this.useRTCOnly
  2565.             }, e.Client.prototype.getChatRoomHistory = function(e, t, n, i) {
  2566.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2567.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.requestMUCHistory(e, t, n, i) : !this.useRTCOnly
  2568.             }, e.Client.prototype.setChatRoomState = function(e, t) {
  2569.                 if (!this.connectionState()) throw new Error("NOT_CONNECTED_TO_VOXIMPLANT");
  2570.                 this.RTCsupported && !this.useFlashOnly ? this.zingayaAPI.sendMUCChatState(e, t) : !this.useRTCOnly
  2571.             }
  2572.         }(i), Function.prototype.bind || (Function.prototype.bind = function(e) {
  2573.             if ("function" != typeof this) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
  2574.             var t = Array.prototype.slice.call(arguments, 1),
  2575.                 n = this,
  2576.                 i = function() {},
  2577.                 o = function() {
  2578.                     return n.apply(this instanceof i && e ? this : e, t.concat(Array.prototype.slice.call(arguments)))
  2579.                 };
  2580.             return i.prototype = this.prototype, o.prototype = new i, o
  2581.         }), !window.JSON) throw new Error("Unsupported browser");
  2582.     ! function(e, n) {
  2583.         e.Utils = {
  2584.             source: null,
  2585.             extend: function(e) {
  2586.                 var t = {},
  2587.                     n = function(e) {
  2588.                         for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n])
  2589.                     };
  2590.                 n(arguments[0]);
  2591.                 for (var i = 1; i < arguments.length; i++) {
  2592.                     var o = arguments[i];
  2593.                     n(o)
  2594.                 }
  2595.                 return t
  2596.             },
  2597.             swfMovie: function(e) {
  2598.                 return -1 != navigator.appName.indexOf("Microsoft") ? window[e] : document[e]
  2599.             },
  2600.             stringifyExtraHeaders: function(e) {
  2601.                 return e = "[object Object]" == Object.prototype.toString.call(e) ? JSON.stringify(e) : null
  2602.             },
  2603.             cadScript: function(e) {
  2604.                 var t = e.split(";");
  2605.                 return t.map(function(e) {
  2606.                     if (0 !== e.length) {
  2607.                         var t = e.match(/\([0-9\/\.,\*\+]*\)$/),
  2608.                             n = e.substring(0, t.index),
  2609.                             i = t.pop();
  2610.                         if (t.length) throw new Error("cadence script should be of the form `%f(%f/%f[,%f/%f])`");
  2611.                         if (n = "*" === n ? 1 / 0 : parseFloat(n), isNaN(n)) throw new Error("cadence length should be of the form `%f`");
  2612.                         return i = i.slice(1, i.length - 1).split(",").map(function(e) {
  2613.                             try {
  2614.                                 var t = e.split("/");
  2615.                                 if (t.length > 3) throw new Error;
  2616.                                 return t = t.map(function(e, t) {
  2617.                                     if (2 === t) {
  2618.                                         var n = e.split("+").map(function(e) {
  2619.                                             var t = parseInt(e, 10);
  2620.                                             if (isNaN(t)) throw new Error;
  2621.                                             return t - 1
  2622.                                         });
  2623.                                         return n
  2624.                                     }
  2625.                                     var i;
  2626.                                     if ("*" == e && (i = 1 / 0), i = i ? i : parseFloat(e, 10), isNaN(i)) throw new Error;
  2627.                                     return i
  2628.                                 }), {
  2629.                                     on: t[0],
  2630.                                     off: t[1],
  2631.                                     frequencies: t[2]
  2632.                                 }
  2633.                             } catch (n) {
  2634.                                 throw new Error("cadence segments should be of the form `%f/%f[%d[+%d]]`")
  2635.                             }
  2636.                         }), {
  2637.                             duration: n,
  2638.                             sections: i
  2639.                         }
  2640.                     }
  2641.                 })
  2642.             },
  2643.             freqScript: function(e) {
  2644.                 var t = e.split(",");
  2645.                 return t.map(function(e) {
  2646.                     try {
  2647.                         var t = e.split("@"),
  2648.                             n = parseInt(t.shift()),
  2649.                             i = parseFloat(t.shift());
  2650.                         if (t.length) throw Error();
  2651.                         return {
  2652.                             frequency: n,
  2653.                             decibels: i
  2654.                         }
  2655.                     } catch (o) {
  2656.                         throw new Error("freqScript pairs are expected to be of the form `%d@%f[,%d@%f]`")
  2657.                     }
  2658.                 })
  2659.             },
  2660.             toneScript: function(t) {
  2661.                 var n = t.split(";"),
  2662.                     i = e.Utils.freqScript(n.shift()),
  2663.                     o = e.Utils.cadScript(n.join(";"));
  2664.                 return {
  2665.                     frequencies: i,
  2666.                     cadences: o
  2667.                 }
  2668.             },
  2669.             playToneScript: function(n, i) {
  2670.                 if ("undefined" != typeof window.AudioContext || "undefined" != typeof window.webkitAudioContext) {
  2671.                     window.AudioContext = window.AudioContext || window.webkitAudioContext;
  2672.                     var o = new AudioContext,
  2673.                         s = e.Utils.toneScript(n),
  2674.                         a = [],
  2675.                         r = 0;
  2676.                     processCadence = function(e) {
  2677.                         r += e.duration != 1 / 0 ? e.duration : 20;
  2678.                         for (var t = 0; t < e.sections.length; t++) processSection(e.sections[t], e.duration)
  2679.                     }, processSection = function(e, n) {
  2680.                         if (t = n != 1 / 0 ? n : n = 20, 0 !== e.off && e.off != 1 / 0)
  2681.                             for (; t > 0;) addSound(e.frequencies, e.on), t -= e.on, addSilence(e.off), t -= e.off, t = parseInt(10 * t) / 10;
  2682.                         else addSound(e.frequencies, n)
  2683.                     }, addSilence = function(e) {
  2684.                         for (var t = 0; t < o.sampleRate * e; t++) a.push(0)
  2685.                     }, addSound = function(e, t) {
  2686.                         for (var n = 0; n < o.sampleRate * t; n++) {
  2687.                             for (var i = 0, r = 0; r < e.length; r++) i += Math.pow(10, s.frequencies[e[r]].decibels / 20) * Math.sin((a.length + n) * (3.14159265359 / o.sampleRate) * s.frequencies[e[r]].frequency), 10 > n && (i *= n / 10), n > o.sampleRate * t - 10 && (i *= (o.sampleRate * t - n) / 10);
  2688.                             a.push(i)
  2689.                         }
  2690.                     }, this.source = o.createBufferSource();
  2691.                     for (var c = 0; c < s.cadences.length; c++) s.cadences[c].duration == 1 / 0 && (this.source.loop = !0), processCadence(s.cadences[c]);
  2692.                     this.source.connect(o.destination), sndBuffer = o.createBuffer(1, r * o.sampleRate, o.sampleRate), bufferData = sndBuffer.getChannelData(0);
  2693.                     for (var l = 0; l < r * o.sampleRate; l++) bufferData[l] = a[l];
  2694.                     a = null, this.source.buffer = sndBuffer, i === !0 && (this.source.loop = !0), this.source.start(0)
  2695.                 }
  2696.             },
  2697.             stopPlayback: function() {
  2698.                 return null !== this.source ? (this.source.stop(0), this.source = null, !0) : !1
  2699.             },
  2700.             sendRequest: function(e, t, n, i) {
  2701.                 var o = !1,
  2702.                     s = function() {
  2703.                         for (var e = [function() {
  2704.                                 return new XDomainRequest
  2705.                             }, function() {
  2706.                                 return new XMLHttpRequest
  2707.                             }, function() {
  2708.                                 return new ActiveXObject("Msxml2.XMLHTTP")
  2709.                             }, function() {
  2710.                                 return new ActiveXObject("Msxml3.XMLHTTP")
  2711.                             }, function() {
  2712.                                 return new ActiveXObject("Microsoft.XMLHTTP")
  2713.                             }], t = !1, n = 0; n < e.length; n++) {
  2714.                             try {
  2715.                                 t = e[n](), 0 === n && (o = !0)
  2716.                             } catch (i) {
  2717.                                 continue
  2718.                             }
  2719.                             break
  2720.                         }
  2721.                         return t
  2722.                     },
  2723.                     a = s();
  2724.                 if (a) {
  2725.                     var r = i ? "POST" : "GET";
  2726.                     if (o) a.onerror = function() {
  2727.                         n(a)
  2728.                     }, a.ontimeout = function() {
  2729.                         n(a)
  2730.                     }, a.onload = function() {
  2731.                         t(a)
  2732.                     }, a.open(r, e), a.timeout = 5e3, a.send();
  2733.                     else {
  2734.                         if (a.open(r, e, !0), i && a.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), a.onreadystatechange = function() {
  2735.                                 return 4 == a.readyState ? 200 != a.status && 304 != a.status ? void n(a) : void t(a) : void 0
  2736.                             }, 4 == a.readyState) return;
  2737.                         a.send(i)
  2738.                     }
  2739.                 }
  2740.             },
  2741.             getServers: function(t, n, i) {
  2742.                 function o(o) {
  2743.                     null !== o ? t(o) : n !== !0 ? e.Utils.getServers(t, !0, i) : i.dispatchEvent({
  2744.                         name: "ConnectionFailed",
  2745.                         message: "VoxImplant Cloud is unavailable"
  2746.                     })
  2747.                 }
  2748.                 var s = "https:" == document.location.protocol ? "https://" : "http://";
  2749.                 balancer_url = n === !0 ? s + "balancer2.voximplant.com/getNearestHost" : s + "balancer.voximplant.com/getNearestHost", e.Utils.sendRequest(balancer_url, function(e) {
  2750.                     o(e.responseText)
  2751.                 }, function(e) {
  2752.                     o(null)
  2753.                 })
  2754.             },
  2755.             generateUUID: function() {
  2756.                 var t = e.Utils._gri,
  2757.                     n = e.Utils._ha;
  2758.                 return n(t(32), 8) + "-" + n(t(16), 4) + "-" + n(16384 | t(12), 4) + "-" + n(32768 | t(14), 4) + "-" + n(t(48), 12)
  2759.             },
  2760.             _gri: function(e) {
  2761.                 return 0 > e ? 0 / 0 : 30 >= e ? 0 | Math.random() * (1 << e) : 53 >= e ? (0 | Math.random() * (1 << 30)) + (0 | Math.random() * (1 << e - 30)) * (1 << 30) : 0 / 0
  2762.             },
  2763.             _ha: function(e, t) {
  2764.                 for (var n = e.toString(16), i = t - n.length, o = "0"; i > 0; i >>>= 1, o += o) 1 & i && (n = o + n);
  2765.                 return n
  2766.             },
  2767.             filterXSS: function(e) {
  2768.                 var t = document.createElement("div");
  2769.                 return t.appendChild(document.createTextNode(e)), e = t.innerHTML
  2770.             }
  2771.         }, e.getInstance = function() {
  2772.             return e._clientInstance
  2773.         }, e.version = e.Client.prototype.version = "3.5.17994", e._clientInstance || (e._clientInstance = new e.Client, delete e.Client)
  2774.     }(i), "undefined" != typeof exports ? (exports["default"] = exports.VoxImplant = i, "undefined" != typeof module && module.exports && (exports = module.exports = exports["default"])) : n.VoxImplant = i
  2775. }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement