Your IP : 3.145.97.150
(function(){if(BX.IM)return;BX.IM=function(e,t){if(typeof BX.message("USER_TZ_AUTO")=="undefined"||BX.message("USER_TZ_AUTO")=="Y")BX.message({USER_TZ_OFFSET:-(new Date).getTimezoneOffset()*60-parseInt(BX.message("SERVER_TZ_OFFSET"))});if(typeof BX.MessengerCommon!="undefined")BX.MessengerCommon.setBxIm(this);this.mobileVersion=false;this.mobileAction="none";this.revision=80;this.ieVersion=BX.browser.DetectIeVersion();this.errorMessage="";this.animationSupport=true;this.context=t.context;this.design=t.design;this.bitrixNetwork=t.bitrixNetwork;this.bitrixNetwork2=t.bitrixNetwork2;this.bitrixOpenLines=t.bitrixOpenLines;this.bitrix24=t.bitrix24;this.isAdmin=t.isAdmin;this.bitrixIntranet=t.bitrixIntranet;this.bitrix24net=t.bitrix24net;this.bitrixXmpp=t.bitrixXmpp;this.bitrixMobile=t.bitrixMobile;this.colors=t.colors;this.ppStatus=t.ppStatus;this.ppServerStatus=this.ppStatus?t.ppServerStatus:false;this.updateStateInterval=t.updateStateInterval;this.desktopStatus=t.desktopStatus||false;this.desktopVersion=t.desktopVersion;this.desktopProtocolVersion=2;this.xmppStatus=t.xmppStatus;this.lastRecordId=0;this.userId=t.userId;this.userEmail=t.userEmail;this.userColor=t.userColor;this.userGender=t.userGender;this.userExtranet=t.userExtranet;this.options=t.options||{};this.path=t.path;this.language=t.language||"en";this.init=typeof t.init!="undefined"?t.init:true;this.windowFocus=true;this.windowFocusTimeout=null;this.extraBind=null;this.extraOpen=false;this.dialogOpen=false;this.notifyOpen=false;this.adjustSizeTimeout=null;this.tryConnect=true;this.openSettingsFlag=typeof t.openSettings!="undefined"?t.openSettings:false;this.popupConfirm=null;this.settings=t.settings;this.settingsDisabled={};this.settingsView=t.settingsView||{common:{},notify:{},privacy:{}};this.settingsNotifyBlocked=t.settingsNotifyBlocked||{};this.settingsTableConfig={};this.settingsSaveCallback={};this.settingsCameraTestMediaStream=null;this.settingsLevelMeter=null;this.saveSettingsTimeout={};this.popupSettings=null;if(t.users&&t.users[this.userId])t.users[this.userId].status=this.settings.status;this.pathToAjax=t.path.im?t.path.im:"/bitrix/components/bitrix/im.messenger/im.ajax.php";this.pathToCallAjax=t.path.call?t.path.call:"/bitrix/components/bitrix/im.messenger/call.ajax.php";this.pathToFileAjax=t.path.file?t.path.file:"/bitrix/components/bitrix/im.messenger/file.ajax.php";this.pathToBlankImage="/bitrix/js/im/images/blank.gif";this.audio={};this.audio.reminder=null;this.audio.newMessage1=null;this.audio.newMessage2=null;this.audio.send=null;this.audio.dialtone=null;this.audio.ringtone=null;this.audio.start=null;this.audio.stop=null;this.audio.current=null;this.audio.timeout={};this.mailCount=t.mailCount;this.notifyCount=t.notifyCount||0;this.messageCount=t.messageCount||0;this.quirksMode=BX.browser.IsIE()&&!BX.browser.IsDoctype()&&(/MSIE 8/.test(navigator.userAgent)||/MSIE 9/.test(navigator.userAgent));this.platformName=BX.browser.IsMac()?"OS X":/windows/.test(navigator.userAgent.toLowerCase())?"Windows":"";if(BX.browser.IsIE()&&!BX.browser.IsIE9()&&/MSIE 7/i.test(navigator.userAgent))this.errorMessage=BX.message("IM_M_OLD_BROWSER");if(this.context=="DESKTOP"||this.context=="FULLSCREEN"||this.context=="PAGE"||this.context=="DIALOG"||this.context=="LINES"){BX.desktop.init({context:this.context,design:this.design})}this.desktop=new BX.IM.Desktop(this,{desktop:t.desktop});this.webrtc=new BX.IM.WebRTC(this,{desktopClass:this.desktop,callServerEnabled:t.webrtc&&t.webrtc.callServerEnabled=="Y"||false,phoneEnabled:t.webrtc&&t.webrtc.phoneEnabled||false,phoneCanCallUserNumber:t.webrtc&&t.webrtc.phoneCanCallUserNumber||false,phoneSipAvailable:t.webrtc&&t.webrtc.phoneSipAvailable||0,phoneDeviceActive:t.webrtc&&t.webrtc.phoneDeviceActive||"N",phoneDeviceCall:t.webrtc&&t.webrtc.phoneDeviceCall||"Y",phoneCrm:t.phoneCrm&&t.phoneCrm||{},phoneInitiateCallViaRestApp:t.webrtc&&t.webrtc.phoneInitiateCallViaRestApp=="Y"||false,turnServer:t.webrtc&&t.webrtc.turnServer||"",turnServerFirefox:t.webrtc&&t.webrtc.turnServerFirefox||"",turnServerLogin:t.webrtc&&t.webrtc.turnServerLogin||"",turnServerPassword:t.webrtc&&t.webrtc.turnServerPassword||"",panel:e!=null?e:BX.create("div")});this.desktop.webrtc=this.webrtc;if(this.init){if(this.desktop.ready()){this.windowTitle=this.bitrixIntranet?!BX.browser.IsMac()?BX.message("IM_DESKTOP_B24_TITLE"):BX.message("IM_DESKTOP_B24_OSX_TITLE"):BX.message("IM_WM");BX.desktop.setWindowTitle(this.windowTitle)}else{this.windowTitle=document.title}}for(var s in t.notify){t.notify[s].date=parseInt(t.notify[s].date)+parseInt(BX.message("USER_TZ_OFFSET"));if(parseInt(s)>this.lastRecordId)this.lastRecordId=parseInt(s)}for(var s in t.message){t.message[s].date=parseInt(t.message[s].date)+parseInt(BX.message("USER_TZ_OFFSET"));if(parseInt(s)>this.lastRecordId)this.lastRecordId=parseInt(s)}for(var s in t.recent){t.recent[s].date=parseInt(t.recent[s].date)+parseInt(BX.message("USER_TZ_OFFSET"))}if(BX.browser.SupportLocalStorage()){BX.addCustomEvent(window,"onLocalStorageSet",BX.proxy(this.storageSet,this));var i=BX.localStorage.get("lri");if(parseInt(i)>this.lastRecordId)this.lastRecordId=parseInt(i);BX.garbage(function(){BX.localStorage.set("lri",this.lastRecordId,60)},this)}this.notifyManager=new BX.IM.NotifyManager(this,{});this.notify=new BX.Notify(this,{desktopClass:this.desktop,webrtcClass:this.webrtc,domNode:e!=null?e:BX.create("div"),counters:t.counters||{},mailCount:t.mailCount||0,notify:t.notify||{},unreadNotify:t.unreadNotify||{},flashNotify:t.flashNotify||{},countNotify:t.countNotify||0,loadNotify:t.loadNotify});this.webrtc.notify=this.notify;this.desktop.notify=this.notify;this.disk=new BX.IM.DiskManager(this,{notifyClass:this.notify,desktopClass:this.desktop,files:t.files||{},enable:t.disk&&t.disk.enable});this.notify.disk=this.disk;this.webrtc.disk=this.disk;this.desktop.disk=this.disk;this.messenger=new BX.Messenger(this,{openChatEnable:t.openChatEnable,updateStateInterval:t.updateStateInterval,notifyClass:this.notify,webrtcClass:this.webrtc,desktopClass:this.desktop,diskClass:this.disk,externalRecentList:t.externalRecentList,recent:t.recent,users:t.users||{},businessUsers:t.businessUsers||false,openlines:t.openlines||false,groups:t.groups||{},userChatBlockStatus:t.userChatBlockStatus||{},userInGroup:t.userInGroup||{},woGroups:t.woGroups||{},woUserInGroup:t.woUserInGroup||{},currentTab:t.currentTab||0,generalChatId:t.generalChatId||0,canSendMessageGeneralChat:t.canSendMessageGeneralChat||false,chat:t.chat||{},userInChat:t.userInChat||{},userChat:t.userChat||{},hrphoto:t.hrphoto||{},message:t.message||{},showMessage:t.showMessage||{},unreadMessage:t.unreadMessage||{},flashMessage:t.flashMessage||{},countMessage:t.countMessage||0,bot:t.bot||{},command:t.command||[],smile:t.smile||false,smileSet:t.smileSet||false,history:t.history||{},openMessenger:typeof t.openMessenger!="undefined"?t.openMessenger:false,openHistory:typeof t.openHistory!="undefined"?t.openHistory:false,openNotify:typeof t.openNotify!="undefined"?t.openNotify:false});this.webrtc.messenger=this.messenger;this.notify.messenger=this.messenger;this.desktop.messenger=this.messenger;this.disk.messenger=this.messenger;if(this.init){BX.addCustomEvent(window,"onImUpdateCounterNotify",BX.proxy(this.updateCounter,this));BX.addCustomEvent(window,"onImUpdateCounterMessage",BX.proxy(this.updateCounter,this));BX.addCustomEvent(window,"onImUpdateCounterMail",BX.proxy(this.updateCounter,this));BX.addCustomEvent(window,"onImUpdateCounter",BX.proxy(this.updateCounter,this));BX.bind(window,"blur",BX.delegate(function(){this.changeFocus(false)},this));BX.bind(window,"focus",this.setFocusFunction=BX.delegate(function(){if(this.windowFocus)return false;if(this.desktop.ready()&&!BX.desktop.isActiveWindow())return false;this.changeFocus(true);if(this.isFocus()&&this.messenger.unreadMessage[this.messenger.currentTab]&&this.messenger.unreadMessage[this.messenger.currentTab].length>0)BX.MessengerCommon.readMessage(this.messenger.currentTab);if(this.isFocus("notify")){if(this.notify.unreadNotifyLoad)this.notify.loadNotify();else if(this.notify.notifyUpdateCount>0)this.notify.viewNotifyAll()}},this));if(this.desktop.ready())BX.bind(window,"click",this.setFocusFunction);BX.addCustomEvent("onPullEvent-xmpp",BX.delegate(function(e,t){if(e=="lastActivityDate"){this.xmppStatus=t.timestamp>0}},this));this.updateCounter();BX.onCustomEvent(window,"onImInit",[this])}if(this.openSettingsFlag!==false)this.openSettings(this.openSettingsFlag=="true"?{}:{onlyPanel:this.openSettingsFlag.toString().toLowerCase()})};BX.IM.prototype.isFocus=function(e){e=typeof e=="undefined"?"dialog":e;if(!this.desktop.run()&&(this.messenger==null||this.messenger.popupMessenger==null))return false;if(e=="dialog"){if(this.desktop.ready()&&BX.desktop.getCurrentTab()!="im"&&BX.desktop.getCurrentTab()!="im-phone")return false;if(this.messenger&&!BX.MessengerCommon.isScrollMax(this.messenger.popupMessengerBody,200))return false;if(this.dialogOpen==false)return false}else if(e=="notify"){if(this.desktop.ready()&&BX.desktop.getCurrentTab()!="notify"&&BX.desktop.getCurrentTab()!="im-phone")return false;if(this.notifyOpen==false)return false}if(this.quirksMode||BX.browser.IsIE()&&!BX.browser.IsIE9())return true;return this.windowFocus};BX.IM.prototype.changeFocus=function(e){this.windowFocus=typeof e=="boolean"?e:false;return this.windowFocus};BX.IM.prototype.playSound=function(e,t){t=t?true:false;if(!t&&(!this.init||this.webrtc.callActive))return false;var s={stop:true,start:true,dialtone:true,ringtone:true,error:true};if(!this.settings.enableSound&&!s[e])return false;BX.localStorage.set("mps",true,1);try{this.stopSound();this.audio.current=this.audio[e];var i=this.audio[e].play();if(window.Promise&&i instanceof Promise){i.catch(function(e){BXIM.audio.current=null})}}catch(a){this.audio.current=null}};BX.IM.prototype.repeatSound=function(e,t){t=parseInt(t)||1e3;t=t>=1e3?t:1e3;BX.localStorage.set("mrs",{sound:e,time:t},1);if(this.audio.timeout[e])clearTimeout(this.audio.timeout[e]);if(this.desktop.ready()||!this.desktopStatus)this.playSound(e);this.audio.timeout[e]=setTimeout(BX.delegate(function(){this.repeatSound(e,t)},this),t)};BX.IM.prototype.stopRepeatSound=function(e,t){t=t!=false;if(t)BX.localStorage.set("mrss",{sound:e},1);if(this.audio.timeout[e])clearTimeout(this.audio.timeout[e]);if(!this.audio[e])return false;this.audio[e].pause();this.audio[e].currentTime=0};BX.IM.prototype.stopSound=function(){if(this.audio.current){this.audio.current.pause();this.audio.current.currentTime=0}};BX.IM.prototype.autoHide=function(e){if(this.autoHideDisable)return true;e=e||window.event;if(e.which==1){if(this.popupSettings!=null)this.popupSettings.destroy();else if(this.messenger.popupHistory!=null)this.messenger.popupHistory.destroy();else if(BX.DiskFileDialog&&BX.DiskFileDialog.popupWindow!=null)BX.DiskFileDialog.popupWindow.destroy();else if(!this.webrtc.callInit&&this.messenger.popupMessenger!=null)this.messenger.popupMessenger.destroy()}};BX.IM.prototype.updateCounter=function(e,t){if(t=="MESSAGE")this.messageCount=e;else if(t=="NOTIFY")this.notifyCount=e;else if(t=="MAIL")this.mailCount=e;var s=0;if(this.notifyCount>0)s+=parseInt(this.notifyCount);if(this.messageCount>0)s+=parseInt(this.messageCount);if(this.desktop.run()){var i="";if(s>99)i="99+";else if(s>0)i=s;var a=BX.message("IM_DESKTOP_UNREAD_EMPTY");if(this.notifyCount>0&&this.messageCount>0)a=BX.message("IM_DESKTOP_UNREAD_MESSAGES_NOTIFY");else if(this.notifyCount>0)a=BX.message("IM_DESKTOP_UNREAD_NOTIFY");else if(this.messageCount>0)a=BX.message("IM_DESKTOP_UNREAD_MESSAGES");else if(this.notify!=null&&this.notify.getCounter("**")>0)a=BX.message("IM_DESKTOP_UNREAD_LF");BX.desktop.setIconTooltip(a);BX.desktop.setIconBadge(i,this.messageCount>0);if(this.notify!=null){var n=this.notify.getCounter("**");BX.desktop.setTabBadge("im-lf",n)}}BX.onCustomEvent(window,"onImUpdateSumCounters",[s,"SUM"]);if(this.settings.status!="dnd"&&!this.desktopStatus&&s>0){if(!this.desktop.ready()&&document.title!="("+s+") "+this.windowTitle)document.title="("+s+") "+this.windowTitle;if(this.messageCount>0)BX.addClass(this.notify.panelButtonMessage,"bx-notifier-message-new");else BX.removeClass(this.notify.panelButtonMessage,"bx-notifier-message-new")}else{if(!this.desktop.ready()&&document.title!=this.windowTitle)document.title=this.windowTitle;if(this.messageCount<=0||this.settings.status=="dnd"||this.desktopStatus)BX.removeClass(this.notify.panelButtonMessage,"bx-notifier-message-new")}};BX.IM.prototype.openNotify=function(e){force=e&&e.force==true;setTimeout(BX.delegate(function(){this.notify.openNotify(false,force)},this),200)};BX.IM.prototype.closeNotify=function(){BX.onCustomEvent(window,"onImNotifyWindowClose",[]);if(this.messenger.popupMessenger!=null&&!this.webrtc.callInit)this.messenger.popupMessenger.destroy()};BX.IM.prototype.toggleNotify=function(){if(this.isOpenNotify())this.closeNotify();else this.openNotify()};BX.IM.prototype.isOpenNotify=function(){return this.notifyOpen};BX.IM.prototype.callTo=function(e,t){t=!(typeof t!="undefined"&&!t);BX.desktopUtils.runningCheck(function(){BX.desktopUtils.goToBx("bx://callto/"+(t?"video":"audio")+"/"+e+(BXIM.bitrix24net?"/bitrix24net/Y":""))},BX.delegate(function(){this.webrtc.callInvite(e,t)},this))};BX.IM.prototype.phoneTo=function(e,t){t=t?t:{};if(typeof t!="object"){try{t=JSON.parse(t)}catch(s){t={}}}if(this.webrtc.phoneInitiateCallViaRestApp){BX.MessengerCommon.phoneStartCallViaRestApp(e,t);return true}if(!this.desktop.ready()&&this.desktopStatus&&this.desktopVersion>=18){var i="";if(t){for(var a in t){i=i+"!!"+a+"!!"+t[a]}i="/params/"+i.substr(2)}if(this.webrtc.popupKeyPad)this.webrtc.popupKeyPad.close();if(e!=""){this.webrtc.phoneNumberLast=e;this.setLocalConfig("phone_last",e)}BX.desktopUtils.runningCheck(function(){BX.desktopUtils.goToBx("bx://callto/phone/"+escape(e)+i)},BX.delegate(function(){this.webrtc.phoneCall(e,t)},this))}else{this.webrtc.phoneCall(e,t)}return true};BX.IM.prototype.checkCallSupport=function(){return this.webrtc.callSupport()};BX.IM.prototype.openMessenger=function(e){if(e&&e.toString().substr(0,4)=="imol"){this.messenger.linesOpenMessenger(e.toString().substr(5))}else{setTimeout(BX.delegate(function(){this.messenger.openMessenger(e)},this),200)}};BX.IM.prototype.closeMessenger=function(){if(this.messenger.popupMessenger!=null&&!this.webrtc.callInit)this.messenger.popupMessenger.destroy()};BX.IM.prototype.isOpenMessenger=function(){return this.dialogOpen};BX.IM.prototype.toggleMessenger=function(){if(this.isOpenMessenger())this.closeMessenger();else if(this.extraOpen&&!this.isOpenNotify())this.closeMessenger();else this.openMessenger(this.messenger.currentTab)};BX.IM.prototype.openHistory=function(e){if(e&&e.toString().substr(0,4)=="imol"){this.messenger.linesOpenHistory(e.toString().substr(5))}else{setTimeout(BX.delegate(function(){this.messenger.openHistory(e)},this),200)}};BX.IM.prototype.openContactList=function(){this.messenger.openMessenger(false);setTimeout(BX.delegate(function(){this.messenger.popupContactListSearchInput.focus()},this),200);return false};BX.IM.prototype.closeContactList=function(){return false};BX.IM.prototype.isOpenContactList=function(){return false};BX.IM.prototype.checkRevision=function(e){e=parseInt(e);if(typeof e=="number"&&this.revision<e){if(this.desktop.run()){console.log("NOTICE: Window reload, because REVISION UP ("+this.revision+" -> "+e+")");BX.desktop.windowReload()}else{if(this.isOpenMessenger()){this.closeMessenger();this.openMessenger()}this.errorMessage=BX.message("IM_M_OLD_REVISION").replace("#WM_NAME#",BX.message("IM_WM"));this.tryConnect=false}return false}return true};BX.IM.prototype.openSettings=function(e){if(this.messenger&&this.messenger.popupMessengerConnectionStatusState!="online")return false;e=typeof e=="object"?e:{};if(this.popupSettings!=null||!this.messenger)return false;if(!this.desktop.run())this.messenger.setClosingByEsc(false);this.settingsSaveCallback={};this.settingsTableConfig={};var t=[];if(this.colors){for(var s in this.colors){t.push({title:this.colors[s],value:s})}}this.settingsView.common={title:BX.message("IM_SETTINGS_COMMON"),settings:[{title:BX.message("IM_M_VIEW_LAST_MESSAGE_OFF"),type:"checkbox",name:"viewLastMessage",checked:!this.settings.viewLastMessage,saveCallback:BX.delegate(function(e){BX.MessengerCommon.recentListRedraw();return!e.checked},this)},{title:BX.message("IM_M_VIEW_OFFLINE_OFF"),type:"checkbox",name:"viewOffline",checked:!this.settings.viewOffline,saveCallback:BX.delegate(function(e){return!e.checked},this)},{title:BX.message("IM_M_VIEW_GROUP_OFF"),type:"checkbox",name:"viewGroup",checked:!this.settings.viewGroup,saveCallback:BX.delegate(function(e){return!e.checked},this)},{type:"space"},{title:BX.message("IM_M_LLM"),type:"checkbox",name:"loadLastMessage",checked:this.settings.loadLastMessage},{title:BX.message("IM_M_LLN"),type:"checkbox",name:"loadLastNotify",checked:this.settings.loadLastNotify},{title:BX.message("IM_M_NAR"),type:"checkbox",name:"notifyAutoRead",checked:this.settings.notifyAutoRead},{type:"space"},{title:BX.message("IM_M_DESKTOP_BIG_SMILE_ON"),type:"checkbox",name:"enableBigSmile",checked:this.settings.enableBigSmile},{title:BX.message("IM_M_ENABLE_SOUND"),type:"checkbox",name:"enableSound",checked:this.settings.enableSound},this.desktop.ready()?{title:BX.message("IM_M_ENABLE_BIRTHDAY"),type:"checkbox",checked:this.desktop.birthdayStatus(),callback:BX.delegate(function(){this.desktop.birthdayStatus(!this.desktop.birthdayStatus())},this)}:null,{title:BX.message("IM_M_ENABLE_ONLINE_NOTIFY"),type:"checkbox",checked:this.settings.trackStatus.indexOf("all")>-1,callback:BX.delegate(function(){if(BX.proxy_context.checked){this.messenger.startTrackStatus("all")}else{this.messenger.stopTrackStatus("all")}},this)},{title:BX.message("IM_M_KEY_SEND"),type:"select",name:"sendByEnter",value:this.settings.sendByEnter?"Y":"N",items:[{title:BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter",value:"N"},{title:"Enter",value:"Y"}],saveCallback:BX.delegate(function(e){return e[e.selectedIndex].value=="Y"},this)},{type:"space"},this.colors?{title:BX.message("IM_M_USER_COLOR"),name:"userColor",type:"select",value:this.userColor,items:t,skipSave:"Y",saveCallback:BX.delegate(function(e){BX.MessengerCommon.setColor(e.options[e.selectedIndex].value)},this)}:null,this.desktop.ready()?{title:BX.message("IM_M_DESKTOP_AUTORUN_ON"),type:"checkbox",checked:BX.desktop.autorunStatus(),callback:BX.delegate(function(){BX.desktop.autorunStatus(!BX.desktop.autorunStatus())},this)}:null]};this.settingsView.notify={title:BX.message("IM_SETTINGS_NOTIFY"),settings:[{type:"notifyControl"},{type:"table",name:"notify",show:this.settings.notifyScheme=="expert"},{type:"table",name:"simpleNotify",show:this.settings.notifyScheme=="simple"}]};this.settingsTableConfig["notify"]={condition:BX.delegate(function(){return this.settingsTableConfig["notify"].rows.length>0},this),headers:["",BX.message("IM_SETTINGS_NOTIFY_SITE"),this.bitrixXmpp?BX.message("IM_SETTINGS_NOTIFY_XMPP"):false,BX.message("IM_SETTINGS_NOTIFY_EMAIL"),this.bitrixMobile?BX.message("IM_SETTINGS_NOTIFY_PUSH"):false],rows:[],error_rows:BX.create("div",{props:{className:" bx-messenger-content-item-progress bx-messenger-content-item-progress-with-text"},html:BX.message("IM_SETTINGS_LOAD")})};this.settingsTableConfig["simpleNotify"]={condition:BX.delegate(function(){return this.settingsTableConfig["simpleNotify"].rows.length>0},this),headers:[BX.message("IM_SETTINGS_SNOTIFY"),""],rows:[]};this.settingsView.privacy={title:BX.message("IM_SETTINGS_PRIVACY"),condition:BX.delegate(function(){return!this.bitrixIntranet},this),settings:[{title:BX.message("IM_SETTINGS_PRIVACY_MESS"),name:"privacyMessage",type:"select",items:[{title:BX.message("IM_SETTINGS_SELECT_1"),value:"all"},{title:BX.message("IM_SETTINGS_SELECT_2"),value:"contact"}],value:this.settings.privacyMessage},{title:BX.message("IM_SETTINGS_PRIVACY_CALL"),name:"privacyCall",type:"select",items:[{title:BX.message("IM_SETTINGS_SELECT_1"),value:"all"},{title:BX.message("IM_SETTINGS_SELECT_2"),value:"contact"}],value:this.settings.privacyCall},{title:BX.message("IM_SETTINGS_PRIVACY_CHAT"),name:"privacyChat",type:"select",items:[{title:BX.message("IM_SETTINGS_SELECT_1_2"),value:"all"},{title:BX.message("IM_SETTINGS_SELECT_2_2"),value:"contact"}],value:this.settings.privacyChat},{title:BX.message("IM_SETTINGS_PRIVACY_SEARCH"),name:"privacySearch",type:"select",items:[{title:BX.message("IM_SETTINGS_SELECT_1_3"),value:"all"},{title:BX.message("IM_SETTINGS_SELECT_2_3"),value:"contact"}],value:this.settings.privacySearch},this.bitrix24net?{title:BX.message("IM_SETTINGS_PRIVACY_PROFILE"),name:"privacyProfile",type:"select",items:[{title:BX.message("IM_SETTINGS_SELECT_1_3"),value:"all"},{title:BX.message("IM_SETTINGS_SELECT_2_3"),value:"contact"},{title:BX.message("IM_SETTINGS_SELECT_3_3"),value:"nobody"}],value:this.settings.privacyProfile}:null]};this.settingsView.hardware={title:BX.message("IM_SETTINGS_HARDWARE"),settings:[{title:BX.message("IM_SETTINGS_HARDWARE_MICROPHONE"),type:"select",name:"defaultMicrophone",items:{},callback:this.changeHardwareSettings.bind(this),saveCallback:function(e){if(!localStorage)return e.value;localStorage.setItem("bx-im-settings-default-microphone",e.value)}},{type:"space"},{title:"microphoneLevel",type:"html",value:'<div id="bx-messenger-settings-hardware-microphone-level" class="bx-messenger-settings-level-meter-container"></div>'},{title:BX.message("IM_SETTINGS_HARDWARE_AUTO_PARAMETERS_MICROPHONE"),type:"checkbox",name:"enableMicAutoParameters",checked:this.webrtc.enableMicAutoParameters,saveCallback:function(e){if(!localStorage)return e.checked;localStorage.setItem("bx-im-settings-enable-mic-auto-parameters",e.checked?"Y":"N")}},{type:"space"},{title:BX.message("IM_SETTINGS_HARDWARE_CAMERA"),type:"select",name:"defaultCamera",items:{},callback:this.changeHardwareSettings.bind(this),saveCallback:function(e){if(!localStorage)return e.value;localStorage.setItem("bx-im-settings-default-camera",e.value)}},{type:"space"},{title:"cameraImage",type:"html",value:'<div id="bx-messenger-settings-hardware-camera-image"></div>'}],click:BX.delegate(this.showHardwareSettings,this)};BX.onCustomEvent(this,"prepareSettingsView",[]);if(e.onlyPanel&&!this.settingsView[e.onlyPanel])return false;this.popupSettingsButtonSave=new BX.PopupWindowButton({text:BX.message("IM_SETTINGS_SAVE"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){this.popupSettingsButtonSave.setClassName("popup-window-button");this.popupSettingsButtonSave.setName(BX.message("IM_SETTINGS_WAIT"));BX.hide(this.popupSettingsButtonClose.buttonNode);this.saveFormSettings();this.closeHardwareSettings()},this)}});this.popupSettingsButtonClose=new BX.PopupWindowButton({text:BX.message("IM_SETTINGS_CLOSE"),className:"popup-window-button-close",events:{click:BX.delegate(function(){this.popupSettings.close();BX.hide(this.popupSettingsButtonSave.buttonNode);BX.hide(this.popupSettingsButtonClose.buttonNode);this.closeHardwareSettings()},this)}});this.popupSettingsBody=BX.create("div",{props:{className:"bx-messenger-settings"+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},children:this.prepareSettings({onlyPanel:e.onlyPanel?e.onlyPanel:false,active:e.active?e.active:false})});if(this.desktop.ready()){if(this.init){this.desktop.openSettings(this.popupSettingsBody,"BXIM.openSettings("+JSON.stringify(e)+"); BX.desktop.resize(); ",e);return false}else{this.popupSettings=new BX.PopupWindowDesktop;BX.addClass(this.popupSettingsBody,"bx-messenger-mark");this.desktop.drawOnPlaceholder(this.popupSettingsBody)}}else{this.popupSettings=new BX.PopupWindow("bx-messenger-popup-settings",null,{autoHide:false,zIndex:200,overlay:{opacity:50,backgroundColor:"#000000"},buttons:[this.popupSettingsButtonSave,this.popupSettingsButtonClose],draggable:{restrict:true},closeByEsc:true,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupSettings=null;if(!this.desktop.run()&&this.messenger.popupMesseger==null)BX.bind(document,"click",BX.proxy(this.autoHide,this));this.closeHardwareSettings();this.messenger.setClosingByEsc(true)},this)},titleBar:e.onlyPanel?this.settingsView[e.onlyPanel].title:BX.message("IM_SETTINGS"),closeIcon:true,contentNoPaddings:true,contentColor:"white",content:this.popupSettingsBody});this.popupSettings.show();BX.addClass(this.popupSettings.popupContainer,"bx-messenger-mark");BX.bind(this.popupSettings.popupContainer,"click",BX.MessengerCommon.preventDefault)}BX.bindDelegate(this.popupSettingsBody,"click",{className:"bx-messenger-settings-tab"},BX.delegate(function(){BX.onCustomEvent(window,"onImSettingsTabShow",[BX.proxy_context.getAttribute("data-name")]);var e=BX.findChildrenByClassName(BX.proxy_context.parentNode,"bx-messenger-settings-tab",false);for(var t=0;t<e.length;t++)BX.removeClass(e[t],"bx-messenger-settings-tab-active");BX.addClass(BX.proxy_context,"bx-messenger-settings-tab-active");var e=BX.findChildrenByClassName(BX.proxy_context.parentNode.nextSibling,"bx-messenger-settings-content",false);for(var t=0;t<e.length;t++){if(parseInt(BX.proxy_context.getAttribute("data-id"))==t)BX.addClass(e[t],"bx-messenger-settings-content-active");else BX.removeClass(e[t],"bx-messenger-settings-content-active")}if(this.desktop.ready())this.desktop.autoResize()},this));if(this.settings.notifyScheme=="simple")this.GetSimpleNotifySettings();else this.GetNotifySettings();if(!this.desktop.ready())BX.bind(document,"click",BX.proxy(this.autoHide,this))};BX.IM.prototype.prepareSettings=function(e){e=typeof e=="object"?e:{};var t=[];var s=[];var i=true;var a=0;for(var n in this.settingsView){if(this.settingsView[n].condition&&!this.settingsView[n].condition())continue;var r={};if(this.settingsView[n].click)r={click:BX.delegate(this.settingsView[n].click,this)};if(e.active&&this.settingsView[e.active]){if(e.active==n)i=true;else i=false}if(i){BX.onCustomEvent(window,"onImSettingsTabShow",[n])}s.push(BX.create("div",{attrs:{"data-id":a+"","data-name":n},props:{className:"bx-messenger-settings-tab"+(i?" bx-messenger-settings-tab-active":"")},html:this.settingsView[n].title,events:r}));i=false;a++}t.push(BX.create("div",{style:{display:!e.onlyPanel?"block":"none"},props:{className:"bx-messenger-settings-tabs"},children:s}));var s=[];var i=true;for(var n in this.settingsView){if(this.settingsView[n].condition&&!this.settingsView[n].condition())continue;if(e.active&&this.settingsView[e.active]){if(e.active==n)i=true;else i=false}var o=[];if(this.settingsView[n].settings){var l=[];for(var p=0;p<this.settingsView[n].settings.length;p++){if(typeof this.settingsView[n].settings[p]!="object"||this.settingsView[n].settings[p]===null)continue;if(this.settingsView[n].settings[p].condition&&!this.settingsView[n].settings[p].condition())continue;if(this.settingsView[n].settings[p].type=="notifyControl"||this.settingsView[n].settings[p].type=="table"||this.settingsView[n].settings[p].type=="space"){l.push(BX.create("tr",{children:[BX.create("td",{attrs:{colspan:2},children:this.prepareSettingsItem(this.settingsView[n].settings[p])})]}))}else if(this.settingsView[n].settings[p].type==="html"){l.push(BX.create("tr",{children:[BX.create("td",{attrs:{colspan:2},children:this.prepareSettingsItem(this.settingsView[n].settings[p])})]}))}else{l.push(BX.create("tr",{children:[BX.create("td",{attrs:{width:"55%"},html:this.settingsView[n].settings[p].title}),BX.create("td",{attrs:{width:"45%"},children:this.prepareSettingsItem(this.settingsView[n].settings[p])})]}))}}if(l.length>0)o.push(BX.create("table",{attrs:{cellpadding:"0",cellspacing:"0",border:"0",width:"100%"},props:{className:"bx-messenger-settings-table bx-messenger-settings-table-style-"+n},children:l}))}s.push(BX.create("div",{style:{display:e.onlyPanel?e.onlyPanel==n?"block":"none":""},props:{id:"bx-messenger-settings-content-"+n,className:"bx-messenger-settings-content"+(i?" bx-messenger-settings-content-active":"")},children:o}));i=false}t.push(BX.create("div",{props:{className:"bx-messenger-settings-contents"},children:s}));if(this.desktop.ready()){t.push(BX.create("div",{props:{className:"popup-window-buttons"},children:[this.popupSettingsButtonSave.buttonNode,this.popupSettingsButtonClose.buttonNode]}))}return t};BX.IM.prototype.prepareSettingsTable=function(e){var t=this.settingsTableConfig[e];if(!t.error_rows&&t.condition&&!BX.delegate(t.condition,this)())return null;var s=[];var i=[];for(var a=0;a<t.headers.length;a++){if(typeof t.headers[a]=="boolean")continue;i.push(BX.create("th",{html:t.headers[a]}))}if(i.length>0)s.push(BX.create("tr",{children:i}));if(t.error_rows&&t.condition&&!t.condition()){s.push(BX.create("tr",{children:[BX.create("td",{attrs:{colspan:t.headers.length},style:{textAlign:"center"},children:[t.error_rows]})]}));t.rows=[]}for(var a=0;a<t.rows.length;a++){var n=[];for(var r=0;r<t.rows[a].length;r++){if(typeof t.rows[a][r]!="object"||t.rows[a][r]===null)continue;var o={};var l={};if(t.rows[a][r].type=="separator"){o={colspan:t.headers.length};l={className:"bx-messenger-settings-table-sep"}}else if(t.rows[a][r].type=="error"){o={colspan:t.headers.length};l={className:"bx-messenger-settings-table-error"}}if(typeof this.settingsDisabled[(a,r,t.rows[a][r].name)]!="undefined"){a,r,t.rows[a][r].disabled=this.settingsDisabled[(a,r,t.rows[a][r].name)]}n.push(BX.create("td",{attrs:o,props:l,children:this.prepareSettingsItem(t.rows[a][r])}))}if(n.length>0)s.push(BX.create("tr",{children:n}))}var p=null;if(s.length>0)p=BX.create("table",{attrs:{cellpadding:"0",cellspacing:"0",border:"0"},props:{className:"bx-messenger-settings-table-extra bx-messenger-settings-table-extra-"+e},children:s});return p};BX.IM.prototype.prepareSettingsItem=function(e){var t=[];var s=BX.clone(e);if(s.type=="space"){t.push(BX.create("span",{props:{className:"bx-messenger-settings-space"}}))}if(s.type=="text"||s.type=="separator"||s.type=="error"){t.push(BX.create("span",{html:s.title}))}if(s.type=="html"){t.push(BX.create("div",{html:s.value}))}if(s.type=="link"){if(s.callback)var i={click:s.callback};t.push(BX.create("span",{props:{className:"bx-messenger-settings-link"},attrs:s.attrs,html:s.title,events:i}))}if(s.type=="checkbox"){if(s.callback)var i={change:s.callback};if(typeof s.checked=="undefined")s.checked=this.settings[s.name]!=false;var a={type:"checkbox",name:s.name?s.name:false,id:s.id?s.id:"",checked:s.checked==true?"true":false,disabled:s.disabled==true?"true":false};if(!s.skipSave&&s.name)a["data-save"]=1;var n=BX.create("input",{attrs:a,events:i});t.push(n);if(s.saveCallback)this.settingsSaveCallback[s.name]=s.saveCallback}else if(s.type=="select"){if(s.callback)var i={change:s.callback};var r=[];for(var o=0;o<s.items.length;o++){r.push(BX.create("option",{attrs:{value:s.items[o].value,selected:s.value==s.items[o].value?"true":false},html:s.items[o].title}))}var a={name:s.name};if(s.name)a["data-save"]=1;var n=BX.create("select",{attrs:a,events:i,children:r});t.push(n);if(s.saveCallback)this.settingsSaveCallback[s.name]=s.saveCallback}else if(s.type=="table"){t.push(BX.create("div",{attrs:{id:"bx-messenger-settings-table-"+s.name,className:"bx-messenger-settings-table-"+s.name},style:{display:s.show?"block":"none"},children:[this.prepareSettingsTable(s.name)]}))}else if(s.type=="notifyControl"){var l=BX.delegate(function(){if(BX.proxy_context.value=="simple"){BX.hide(BX("bx-messenger-settings-table-notify"));BX.show(BX("bx-messenger-settings-table-simpleNotify"));BX.show(BX("bx-messenger-settings-notify-clients"));this.GetSimpleNotifySettings()}else{BX.show(BX("bx-messenger-settings-table-notify"));BX.hide(BX("bx-messenger-settings-table-simpleNotify"));BX.hide(BX("bx-messenger-settings-notify-clients"));this.GetNotifySettings()}},this);t.push(BX.create("div",{props:{className:"bx-messenger-settings-notify-type"},children:[BX.create("input",{attrs:{
id:"notifySchemeSimpleValue","data-save":1,type:"radio",name:"notifyScheme",value:"simple",checked:this.settings.notifyScheme=="simple"},events:{change:l}}),BX.create("label",{attrs:{"for":"notifySchemeSimpleValue"},html:" "+BX.message("IM_SETTINGS_NS_1")+" "}),BX.create("input",{attrs:{id:"notifySchemeExpertValue","data-save":1,type:"radio",name:"notifyScheme",value:"expert",checked:this.settings.notifyScheme=="expert"},events:{change:l}}),BX.create("label",{attrs:{"for":"notifySchemeExpertValue"},html:" "+BX.message("IM_SETTINGS_NS_2")+" "})]}));t.push(BX.create("div",{attrs:{id:"bx-messenger-settings-notify-clients"},style:{display:this.settings.notifyScheme=="simple"?"block":"none"},props:{className:"bx-messenger-settings-notify-clients"},children:[BX.create("div",{props:{className:"bx-messenger-settings-notify-clients-title"},html:BX.message("IM_SETTINGS_NC_1_NEW")}),BX.create("div",{props:{className:"bx-messenger-settings-notify-clients-item"},children:[BX.create("input",{attrs:{"data-save":1,type:"checkbox",id:"notifySchemeSendSite",name:"notifySchemeSendSite",value:"Y",checked:this.settings.notifySchemeSendSite},events:{change:function(e){if(!this.checked){BX("notifySchemeSendEmail").checked=false}else{BX("notifySchemeSendEmail").checked=true}}}}),BX.create("label",{attrs:{"for":"notifySchemeSendSite"},html:" "+BX.message("IM_SETTINGS_NC_2")+"<br />"})]}),this.bitrixXmpp?BX.create("div",{props:{className:"bx-messenger-settings-notify-clients-item"},children:[BX.create("input",{attrs:{"data-save":1,type:"checkbox",id:"notifySchemeSendXmpp",name:"notifySchemeSendXmpp",value:"Y",checked:this.settings.notifySchemeSendXmpp}}),BX.create("label",{attrs:{"for":"notifySchemeSendXmpp"},html:" "+BX.message("IM_SETTINGS_NC_3")+"<br />"})]}):null,BX.create("div",{props:{className:"bx-messenger-settings-notify-clients-item"},children:[BX.create("input",{attrs:{"data-save":1,type:"checkbox",id:"notifySchemeSendEmail",name:"notifySchemeSendEmail",value:"Y",checked:this.settings.notifySchemeSendEmail},events:{change:function(e){if(this.checked){BX("notifySchemeSendSite").checked=true}}}}),BX.create("label",{attrs:{"for":"notifySchemeSendEmail"},html:" "+BX.message("IM_SETTINGS_NC_4").replace("#MAIL#",this.userEmail)+""})]}),this.bitrixMobile?BX.create("div",{props:{className:"bx-messenger-settings-notify-clients-item"},children:[BX.create("input",{attrs:{"data-save":1,type:"checkbox",id:"notifySchemeSendPush",name:"notifySchemeSendPush",value:"Y",checked:this.settings.notifySchemeSendPush}}),BX.create("label",{attrs:{"for":"notifySchemeSendPush"},html:" "+BX.message("IM_SETTINGS_NC_5")+"<br />"})]}):null]}))}return t};BX.IM.prototype.showHardwareSettings=function(){var e=this;var t={micSelect:document.querySelector("[name=defaultMicrophone]"),camSelect:document.querySelector("[name=defaultCamera]"),audioLevel:BX("bx-messenger-settings-hardware-microphone-level"),cameraImage:BX("bx-messenger-settings-hardware-camera-image"),video:BX("bx-messenger-settings-hardware-camera-image-video")};if(this.settingsCameraTestMediaStream){return}if(!t.micSelect||!t.camSelect){return}t.micSelect.style.minWidth="200px";t.camSelect.style.minWidth="200px";if(!t.video){t.video=BX.create("video",{attrs:{id:"bx-messenger-settings-hardware-camera-image-video"}});t.cameraImage.appendChild(t.video);t.video.addEventListener("loadedmetadata",function(){if(e.desktop.ready()){BX.desktop.resize()}})}if(!this.webrtc.enabled){console.log("webrtc is not supported");return}var s={audio:{deviceId:this.webrtc.defaultMicrophone?{exact:this.webrtc.defaultMicrophone}:undefined},video:{deviceId:this.webrtc.defaultCamera?{exact:this.webrtc.defaultCamera}:undefined}};navigator.mediaDevices.getUserMedia(s).catch(function(t){if(window.localStorage){window.localStorage.removeItem("bx-im-settings-default-camera");window.localStorage.removeItem("bx-im-settings-default-microphone");e.webrtc.readDefaults()}s={audio:{},video:{}};return navigator.mediaDevices.getUserMedia(s)}).then(function(s){e.settingsCameraTestMediaStream=s;e.settingsLevelMeter=new BX.IM.LevelMeter(t.audioLevel);if(e.settingsLevelMeter.supported)e.settingsLevelMeter.attachMediaStream(s);t.video.src=window.URL.createObjectURL(s);t.video.play();t.video.muted=true;if(e.desktop.ready()){BX.desktop.resize()}return navigator.mediaDevices.enumerateDevices()}).then(function(s){var i=function(){var t=e.settingsCameraTestMediaStream.getVideoTracks();if(t.length>0&&t[0].label)return t[0].label;else return""}();var a=function(){var t=e.settingsCameraTestMediaStream.getAudioTracks();if(t.length>0&&t[0].label)return t[0].label;else return""}();return new Promise(function(n,r){if(s&&t.micSelect.options.length==0&&t.camSelect.options.length==0){s.forEach(function(s){var n;if(s.kind=="audioinput"){n=BX.create("option",{text:s.label,attrs:{value:s.deviceId}});if(s.label==""){if(s.deviceId=="default"){s.label=BX.message("IM_SETTINGS_HARDWARE_DEFAULT_MICROPHONE")}else{return}}if(s.label===a||s.deviceId===e.webrtc.defaultMicrophone){n.selected=true}t.micSelect.options.add(n)}else if(s.kind=="videoinput"){n=BX.create("option",{text:s.label,attrs:{value:s.deviceId}});if(s.label===i||s.deviceId===e.webrtc.defaultCamera){n.selected=true}t.camSelect.options.add(n)}});n()}else{r()}})}).catch(function(e){console.log("could not access user hardware");console.log(e)})};BX.IM.prototype.changeHardwareSettings=function(){var e=this;var t={micSelect:document.querySelector("[name=defaultMicrophone]"),camSelect:document.querySelector("[name=defaultCamera]"),audioLevel:BX("bx-messenger-settings-hardware-microphone-level"),cameraImage:BX("bx-messenger-settings-hardware-camera-image"),video:BX("bx-messenger-settings-hardware-camera-image-video")};if(this.settingsCameraTestMediaStream){BX.webrtc.stopMediaStream(this.settingsCameraTestMediaStream);this.settingsCameraTestMediaStream=null}if(this.settingsLevelMeter){this.settingsLevelMeter.stop()}var s={audio:{deviceId:t.micSelect.value?{exact:t.micSelect.value}:undefined},video:{deviceId:t.camSelect.value?{exact:t.camSelect.value}:undefined}};navigator.mediaDevices.getUserMedia(s).then(function(s){e.settingsCameraTestMediaStream=s;if(e.settingsLevelMeter.supported)e.settingsLevelMeter.attachMediaStream(s);t.video.src=window.URL.createObjectURL(s);t.video.play();if(e.desktop.ready()){BX.desktop.resize()}}).catch(function(e){console.log("could not access user hardware",e)})};BX.IM.prototype.closeHardwareSettings=function(){if(this.settingsCameraTestMediaStream)BX.webrtc.stopMediaStream(this.settingsCameraTestMediaStream);if(this.settingsLevelMeter)this.settingsLevelMeter.stop();this.settingsCameraTestMediaStream=null;this.webrtc.readDefaults()};BX.IM.prototype.saveSetting=function(e,t){this.settings[e]=t;var s={};s[e]=t;this.saveSettings(s);return true};BX.IM.prototype.saveSettings=function(e){var t="";for(var s in e){this.settings[s]=e[s];t=t+s}BX.localStorage.set("ims",JSON.stringify(this.settings),5);if(this.saveSettingsTimeout[t])clearTimeout(this.saveSettingsTimeout[t]);this.saveSettingsTimeout[t]=setTimeout(BX.delegate(function(){BX.ajax({url:this.pathToAjax+"?SETTINGS_SAVE&V="+this.revision,method:"POST",dataType:"json",timeout:30,data:{IM_SETTING_SAVE:"Y",IM_AJAX_CALL:"Y",SETTINGS:JSON.stringify(e),sessid:BX.bitrix_sessid()}});delete this.saveSettingsTimeout[t]},this),700)};BX.IM.prototype.saveFormSettings=function(){var e=BX.findChildren(this.popupSettingsBody,{attribute:"data-save"},true);for(var t=0;t<e.length;t++){if(e[t].tagName=="INPUT"&&e[t].type=="checkbox"){if(typeof this.settingsSaveCallback[e[t].name]=="function")this.settings[e[t].name]=this.settingsSaveCallback[e[t].name](e[t]);else this.settings[e[t].name]=e[t].checked}else if(e[t].tagName=="INPUT"&&e[t].type=="radio"&&e[t].checked){if(typeof this.settingsSaveCallback[e[t].name]=="function")this.settings[e[t].name]=this.settingsSaveCallback[e[t].name](e[t]);else this.settings[e[t].name]=e[t].value}else if(e[t].tagName=="SELECT"){if(typeof this.settingsSaveCallback[e[t].name]=="function")this.settings[e[t].name]=this.settingsSaveCallback[e[t].name](e[t]);else this.settings[e[t].name]=e[t][e[t].selectedIndex].value}}var s=this.settings["notifyScheme"]=="simple"?{}:{notify:{}};for(var i in this.settings){if(i.substr(0,7)=="notify|"){if(this.settingsDisabled[i])continue;if(s["notify"])s["notify"][i.substr(7)]=this.settings[i]}else{s[i]=this.settings[i]}}if(this.desktop.ready()){BX.desktop.onCustomEvent("bxSaveSettings",[this.settings])}else{BX.localStorage.set("ims",JSON.stringify(this.settings),5)}if(this.messenger!=null){BX.MessengerCommon.userListRedraw(true);if(this.messenger.popupMessengerTextareaSendType)this.messenger.popupMessengerTextareaSendType.innerHTML=this.settings.sendByEnter?"Enter":BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter"}BX.ajax({url:this.pathToAjax+"?SETTINGS_FORM_SAVE&V="+this.revision,method:"POST",dataType:"json",timeout:30,data:{IM_SETTINGS_SAVE:"Y",IM_AJAX_CALL:"Y",SETTINGS:JSON.stringify(s),sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(){BX.MessengerCommon.drawTab(this.messenger.currentTab,true);this.popupSettings.close()},this),onfailure:BX.delegate(function(){this.popupSettingsButtonSave.setClassName("popup-window-button popup-window-button-accept");this.popupSettingsButtonSave.setName(BX.message("IM_SETTINGS_SAVE"));BX.show(this.popupSettingsButtonClose.buttonNode)},this)})};BX.IM.prototype.GetNotifySettings=function(){BX.ajax({url:this.pathToAjax+"?SETTINGS_NOTIFY_LOAD&V="+this.revision,method:"POST",dataType:"json",timeout:30,data:{IM_SETTINGS_NOTIFY_LOAD:"Y",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(e.ERROR==""){if(this.settings.notifyScheme=="simple"){for(var t in e.VALUES){if(t.substr(0,10)=="important|"){continue}if(t.substr(0,9)=="disabled|"){this.settingsDisabled["notify|"+t.substr(9)]=e.VALUES[t];continue}if(!BX("notifySchemeSendSite").checked&&t.substr(0,5)=="site|")e.VALUES[t]=false;else if(this.bitrixXmpp&&!BX("notifySchemeSendXmpp").checked&&t.substr(0,5)=="xmpp|")e.VALUES[t]=false;else if(!BX("notifySchemeSendEmail").checked&&t.substr(0,6)=="email|")e.VALUES[t]=false;else if(this.bitrixMobile&&!BX("notifySchemeSendPush").checked&&t.substr(0,5)=="push|")e.VALUES[t]=false;this.settings["notify|"+t]=e.VALUES[t]}}else{for(var t in e.VALUES){if(t.substr(0,10)=="important|"){continue}if(t.substr(0,9)=="disabled|"){this.settingsDisabled["notify|"+t.substr(9)]=e.VALUES[t];continue}this.settings["notify|"+t]=e.VALUES[t]}}var s=[];if(e.NAMES["im"]){s.push([{type:"separator",title:e.NAMES["im"].NAME}]);for(var i in e.NAMES["im"]["NOTIFY"]){var a=e.NAMES["im"]["NOTIFY"][i];s.push([{type:"text",title:a},{type:"checkbox",id:"notifyId|site|im|"+i,name:"notify|site|im|"+i,callback:function(e){if(BX(this.id.replace("|site|","|email|")).disabled){return true}if(!this.checked){BX(this.id.replace("|site|","|email|")).checked=false}else{BX(this.id.replace("|site|","|email|")).checked=true}}},this.bitrixXmpp?{type:"checkbox",name:"notify|xmpp|im|"+i}:false,{type:"checkbox",id:"notifyId|email|im|"+i,name:"notify|email|im|"+i,callback:function(e){if(BX(this.id.replace("|email|","|site|")).disabled){return true}if(this.checked){BX(this.id.replace("|email|","|site|")).checked=true}}},this.bitrixMobile?{type:"checkbox",name:"notify|push|im|"+i}:false])}}for(var n in e.NAMES){if(n=="im")continue;s.push([{type:"separator",title:e.NAMES[n].NAME}]);for(var i in e.NAMES[n]["NOTIFY"]){var a=e.NAMES[n]["NOTIFY"][i];s.push([{type:"text",title:a},{type:"checkbox",id:"notifyId|site|"+n+"|"+i,name:"notify|site|"+n+"|"+i,callback:function(e){if(BX(this.id.replace("|site|","|email|")).disabled){return true}if(!this.checked){BX(this.id.replace("|site|","|email|")).checked=false}else{BX(this.id.replace("|site|","|email|")).checked=true}}},this.bitrixXmpp?{type:"checkbox",name:"notify|xmpp|"+n+"|"+i}:false,{type:"checkbox",id:"notifyId|email|"+n+"|"+i,name:"notify|email|"+n+"|"+i,callback:function(e){if(BX(this.id.replace("|email|","|site|")).disabled){return true}if(this.checked){BX(this.id.replace("|email|","|site|")).checked=true}}},this.bitrixMobile?{type:"checkbox",name:"notify|push|"+n+"|"+i}:false])}}this.settingsTableConfig["notify"].rows=s}else{this.settingsTableConfig["notify"].rows=[[{type:"error",title:BX.message("IM_M_ERROR")}]]}BX("bx-messenger-settings-table-notify").innerHTML="";BX.adjust(BX("bx-messenger-settings-table-notify"),{children:[this.prepareSettingsTable("notify")]});if(e.ERROR!="")this.settingsTableConfig["notify"].rows=[];if(this.desktop.ready())this.desktop.autoResize()},this),onfailure:BX.delegate(function(){this.settingsTableConfig["notify"].rows=[[{type:"error",title:BX.message("IM_M_ERROR")}]];BX("bx-messenger-settings-table-notify").innerHTML="";BX.adjust(BX("bx-messenger-settings-table-notify"),{children:[this.prepareSettingsTable("notify")]});this.settingsTableConfig["notify"].rows=[];if(this.desktop.ready())this.desktop.autoResize()},this)})};BX.IM.prototype.GetSimpleNotifySettings=function(){BX.ajax({url:this.pathToAjax+"?SETTINGS_SIMPLE_NOTIFY_LOAD&V="+this.revision,method:"POST",dataType:"json",timeout:30,data:{IM_SETTINGS_SIMPLE_NOTIFY_LOAD:"Y",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(e.ERROR==""){var t=[];for(var s in e.VALUES){t.push([{type:"separator",title:e.NAMES[s]?e.NAMES[s].NAME:"-"}]);for(var i in e.VALUES[s]){var a=e.NAMES[s]?e.NAMES[s]["NOTIFY"][i]:"-";t.push([{type:"text",title:a},{type:"link",title:BX.message("IM_SETTINGS_SNOTIFY_ENABLE"),attrs:{"data-settingName":s+"|"+i},callback:BX.delegate(function(){this.removeSimpleNotify(BX.proxy_context)},this)}]);this.settingsNotifyBlocked[s+"|"+i]=true}}this.settingsTableConfig["simpleNotify"].rows=t}else{this.settingsTableConfig["simpleNotify"].rows=[[{type:"error",title:BX.message("IM_M_ERROR")}]]}BX("bx-messenger-settings-table-simpleNotify").innerHTML="";BX.adjust(BX("bx-messenger-settings-table-simpleNotify"),{children:[this.prepareSettingsTable("simpleNotify")]});if(e.ERROR!="")this.settingsTableConfig["simpleNotify"].rows=[];if(this.desktop.ready())this.desktop.autoResize()},this),onfailure:BX.delegate(function(){this.settingsTableConfig["simpleNotify"].rows=[[{type:"error",title:BX.message("IM_M_ERROR")}]];if(BX("bx-messenger-settings-table-simpleNotify")){BX("bx-messenger-settings-table-simpleNotify").innerHTML="";BX.adjust(BX("bx-messenger-settings-table-simpleNotify"),{children:[this.prepareSettingsTable("simpleNotify")]})}this.settingsTableConfig["simpleNotify"].rows=[];if(this.desktop.ready())this.desktop.autoResize()},this)})};BX.IM.prototype.removeSimpleNotify=function(e){var t=e.parentNode.parentNode.parentNode;if(!e.parentNode.parentNode.nextSibling&&e.parentNode.parentNode.previousSibling.childNodes[0].className!="bx-messenger-settings-table-sep"){BX.remove(e.parentNode.parentNode)}else if(e.parentNode.parentNode.previousSibling&&e.parentNode.parentNode.previousSibling.childNodes[0].className!="bx-messenger-settings-table-sep"){BX.remove(e.parentNode.parentNode)}else if(e.parentNode.parentNode.nextSibling&&e.parentNode.parentNode.nextSibling.childNodes[0].className!="bx-messenger-settings-table-sep"){BX.remove(e.parentNode.parentNode)}else if(e.parentNode.parentNode.previousSibling.childNodes[0].className=="bx-messenger-settings-table-sep"&&!e.parentNode.parentNode.nextSibling){BX.remove(e.parentNode.parentNode.previousSibling);BX.remove(e.parentNode.parentNode)}else if(e.parentNode.parentNode.previousSibling.childNodes[0].className=="bx-messenger-settings-table-sep"&&e.parentNode.parentNode.nextSibling.childNodes[0].className=="bx-messenger-settings-table-sep"){BX.remove(e.parentNode.parentNode.previousSibling);BX.remove(e.parentNode.parentNode)}if(t.childNodes.length<=1)BX.remove(t);this.notify.blockNotifyType(e.getAttribute("data-settingName"));if(this.desktop.ready())this.desktop.autoResize()};BX.IM.prototype.openConfirm=function(e,t,s){if(this.popupConfirm!=null)this.popupConfirm.destroy();if(typeof e=="object")e='<div class="bx-messenger-confirm-title">'+e.title+"</div>"+e.message;s=s!==false;if(typeof t=="undefined"||typeof t=="object"&&t.length<=0){t=[new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(e){this.popupWindow.close();BX.PreventDefault(e)}}})]}this.popupConfirm=new BX.PopupWindow("bx-notifier-popup-confirm",null,{zIndex:200,autoHide:t===false,buttons:t,closeByEsc:t===false,overlay:s,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupConfirm=null},this)},content:BX.create("div",{props:{className:t===false?" bx-messenger-confirm-without-buttons":"bx-messenger-confirm"},html:e})});BX.addClass(this.popupConfirm.popupContainer,"bx-messenger-mark");this.popupConfirm.show();BX.bind(this.popupConfirm.popupContainer,"click",BX.MessengerCommon.preventDefault);BX.bind(this.popupConfirm.contentContainer,"click",BX.PreventDefault);BX.bind(this.popupConfirm.overlay.element,"click",BX.PreventDefault)};BX.IM.getSelectionText=function(){var e="";if(window.getSelection){e=window.getSelection().toString()}else{e=document.selection.createRange().text}return e};BX.IM.prototype.getLocalConfig=function(e,t){if(this.desktop.ready()){return BX.desktop.getLocalConfig(e,t)}t=typeof t=="undefined"?null:t;if(!BX.browser.SupportLocalStorage()){return t}if(this.desktop.run()&&!this.desktop.ready())e="full-"+e;var s=BX.localStorage.get(e);if(s==null){return t}if(typeof s=="string"&&s.length>0){try{s=JSON.parse(s)}catch(i){s=t}}return s};BX.IM.prototype.setLocalConfig=function(e,t,s){if(this.desktop.run()){if(this.desktop.ready())return BX.desktop.setLocalConfig(e,t)}s=s||86400;if(typeof t=="object")t=JSON.stringify(t);else if(typeof t=="boolean")t=t?"true":"false";else if(typeof t=="undefined")t="";else if(typeof t!="string")t=t+"";if(!BX.browser.SupportLocalStorage())return false;if(this.desktop.run()&&!this.desktop.ready())e="full-"+e;BX.localStorage.set(e,t,s);return true};BX.IM.prototype.removeLocalConfig=function(e){if(this.desktop.ready()){return BX.desktop.removeLocalConfig(e)}if(!BX.browser.SupportLocalStorage())return false;if(this.desktop.run()&&!this.desktop.ready())e="full-"+e;BX.localStorage.remove(e);return true};BX.IM.prototype.storageSet=function(e){if(e.key=="mps"){this.stopSound()}else if(e.key=="mrs"){this.repeatSound(e.value.sound,e.value.time)}else if(e.key=="mrss"){this.stopRepeatSound(e.value.sound,false)}}})();(function(){if(BX.Notify)return;BX.Notify=function(e,t){this.BXIM=e;this.settings={};this.params=t||{};this.windowInnerSize={};this.windowScrollPos={};this.sendAjaxTry=0;this.webrtc=t.webrtcClass;this.desktop=t.desktopClass;this.panel=t.domNode;if(this.desktop.run())BX.hide(this.panel);BX.bind(this.panel,"click",BX.MessengerCommon.preventDefault);this.notifyCount=t.countNotify;this.notifyUpdateCount=t.countNotify;this.counters=t.counters;this.mailCount=t.mailCount;this.notifyAnswerBlock={};this.notifyAnswerText={};this.notifyHistoryPage=0;this.notifyHistoryLoad=false;this.notifyBody=null;this.notify=t.notify;this.notifyLoad=false;this.unreadNotify=t.unreadNotify;this.unreadNotifyLoad=t.loadNotify;this.flashNotify=t.flashNotify;this.initNotifyCount=t.countNotify;this.confirmDisabledButtons=false;if(this.unreadNotifyLoad){for(var s in this.notify)this.initNotifyCount--}if(BX.browser.IsDoctype())BX.addClass(this.panel,"bx-notifier-panel-doc");else BX.addClass(document.body,"bx-no-doctype");if(BX.browser.IsAndroid()||BX.browser.IsIOS())BX.addClass(document.body,"bx-im-mobile");this.panelButtonCall=BX.findChildByClassName(this.panel,"bx-notifier-call");if(!this.webrtc.phoneEnabled){BX.style(this.panelButtonCall,"display","none")}this.panelButtonNetwork=BX.findChildByClassName(this.panel,"bx-notifier-network");this.panelButtonNetworkCount=BX.findChildByClassName(this.panelButtonNetwork,"bx-notifier-indicator-count");if(this.panelButtonNetwork!=null){if(this.BXIM.bitrixNetwork){this.panelButtonNetwork.href="https://www.bitrix24.net/";this.panelButtonNetwork.setAttribute("target","_blank");if(this.panelButtonNetworkCount!=null)this.panelButtonNetworkCount.innerHTML=""}else{BX.style(this.panelButtonNetwork,"display","none");this.panelButtonNetworkCount.innerHTML=""}}this.panelButtonNotify=BX.findChildByClassName(this.panel,"bx-notifier-notify");this.panelButtonNotifyCount=BX.findChildByClassName(this.panelButtonNotify,"bx-notifier-indicator-count");if(this.panelButtonNotifyCount!=null)this.panelButtonNotifyCount.innerHTML="";this.panelButtonMessage=BX.findChildByClassName(this.panel,"bx-notifier-message");this.panelButtonMessageCount=BX.findChildByClassName(this.panelButtonMessage,"bx-notifier-indicator-count");if(this.panelButtonMessageCount!=null)this.panelButtonMessageCount.innerHTML="";this.panelButtonMail=BX.findChildByClassName(this.panel,"bx-notifier-mail");this.panelButtonMailCount=BX.findChildByClassName(this.panelButtonMail,"bx-notifier-indicator-count");if(this.panelButtonMail!=null){this.panelButtonMail.href=this.BXIM.path.mail;this.panelButtonMail.setAttribute("target","_blank");if(this.panelButtonMessageCount!=null)this.panelButtonMailCount.innerHTML=""}this.panelDragLabel=BX.findChildByClassName(this.panel,"bx-notifier-drag");this.messenger=null;this.messengerNotifyButton=null;this.messengerNotifyButtonCount=null;this.popupNotifyItem=null;this.popupNotifySize=387;this.popupNotifySizeMin=317;this.popupNotifyButtonFilter=null;this.popupNotifyButtonFilterBox=null;this.popupHistoryFilterVisible=false;this.popupNotifyMore=null;this.dragged=false;this.dragPageX=0;this.dragPageY=0;if(this.BXIM.init){if(this.desktop.run()){BX.desktop.addTab({id:"notify",title:BX.message("IM_SETTINGS_NOTIFY"),order:110,target:"im",events:{open:BX.delegate(function(){this.openNotify(false,true)},this)}})}this.panel.appendChild(this.BXIM.audio.reminder=BX.create("audio",{props:{className:"bx-notify-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/reminder.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/reminder.mp3",type:"audio/mpeg"}})]}));if(typeof this.BXIM.audio.reminder.play=="undefined"){this.BXIM.settings.enableSound=false}if(BX.browser.SupportLocalStorage()){BX.addCustomEvent(window,"onLocalStorageSet",BX.proxy(this.storageSet,this));var i=BX.localStorage.get("npp");this.BXIM.settings.panelPositionHorizontal=!!i?i.h:this.BXIM.settings.panelPositionHorizontal;this.BXIM.settings.panelPositionVertical=!!i?i.v:this.BXIM.settings.panelPositionVertical;var a=BX.localStorage.get("mfn");if(a){for(var s in this.flashNotify)if(this.flashNotify[s]!=a[s]&&a[s]==false)this.flashNotify[s]=false}BX.garbage(function(){BX.localStorage.set("mfn",this.flashNotify,15)},this)}BX.bind(this.panelButtonNotify,"click",BX.proxy(function(){this.toggleNotify()},this.BXIM));if(this.webrtc.phoneEnabled){BX.bind(this.panelButtonCall,"click",BX.delegate(this.webrtc.openKeyPad,this.webrtc));BX.bind(window,"scroll",BX.delegate(function(){if(this.webrtc.popupKeyPad)this.webrtc.popupKeyPad.close()},this))}BX.bind(this.panelDragLabel,"mousedown",BX.proxy(this._startDrag,this));BX.bind(this.panelDragLabel,"dobleclick",BX.proxy(this._stopDrag,this));this.updateNotifyMailCount();if(!this.desktop.run()){this.adjustPosition({resize:true});BX.bind(window,"resize",BX.proxy(function(){this.closePopup();this.adjustPosition({resize:true})},this));if(!BX.browser.IsDoctype())BX.bind(window,"scroll",BX.proxy(function(){this.adjustPosition({scroll:true})},this))}setTimeout(BX.delegate(function(){this.newNotify();this.updateNotifyCounters();this.updateNotifyCount()},this),500)}BX.addCustomEvent(window,"onSonetLogCounterClear",BX.proxy(function(e){var t={};t[e]=0;this.updateNotifyCounters(t)},this))};BX.Notify.prototype.getCounter=function(e){if(typeof e!="string")return false;e=e.toString();if(e=="im_notify")return this.notifyCount;if(e=="im_message")return this.BXIM.messageCount;return this.counters[e]?this.counters[e]:0};BX.Notify.prototype.updateNotifyCounters=function(e,t){t=t!=false;if(typeof e=="object"){for(var s in e)this.counters[s]=e[s]}BX.onCustomEvent(window,"onImUpdateCounter",[this.counters]);if(t)BX.localStorage.set("nuc",this.counters,5)};BX.Notify.prototype.updateNotifyMailCount=function(e,t){t=t!=false;if(typeof e!="undefined"||parseInt(e)>0)this.mailCount=parseInt(e);if(this.mailCount>0)BX.removeClass(this.panelButtonMail,"bx-notifier-hide");else BX.addClass(this.panelButtonMail,"bx-notifier-hide");var s="";if(this.mailCount>99)s="99+";else if(this.mailCount>0)s=this.mailCount;if(this.panelButtonMailCount!=null){this.panelButtonMailCount.innerHTML=s;this.adjustPosition({resize:true,timeout:500})}BX.onCustomEvent(window,"onImUpdateCounterMail",[this.mailCount,"MAIL"]);if(t)BX.localStorage.set("numc",this.mailCount,5)};BX.Notify.prototype.updateNotifyCount=function(e){e=e!=false;var t=0;var s=0;if(this.unreadNotifyLoad)t=this.initNotifyCount;for(var i in this.unreadNotify){if(this.unreadNotify[i]==null)continue;var a=this.notify[this.unreadNotify[i]];if(!a)continue;if(a.type!=1)s++;t++}var n="";if(t>99)n="99+";else if(t>0)n=t;if(this.panelButtonNotifyCount!=null){this.panelButtonNotifyCount.innerHTML=n;this.adjustPosition({resize:true,timeout:500})}if(this.messengerNotifyButtonCount!=null)this.messengerNotifyButtonCount.innerHTML=parseInt(n)>0?'<span class="bx-messenger-cl-count-digit">'+n+"</span>":"";if(this.desktop.run())BX.desktop.setTabBadge("notify",t);this.notifyCount=parseInt(t);this.notifyUpdateCount=parseInt(s);BX.onCustomEvent(window,"onImUpdateCounterNotify",[this.notifyCount,"NOTIFY"]);if(e)BX.localStorage.set("nunc",{unread:this.unreadNotify,flash:this.flashNotify},5)};BX.Notify.prototype.changeUnreadNotify=function(e,t){t=t!=false;var s=false;for(var i in e){if(!this.BXIM.xmppStatus&&this.BXIM.settings.status!="dnd")this.flashNotify[e[i]]=true;else this.flashNotify[e[i]]=false;this.unreadNotify[e[i]]=e[i];s=true}this.newNotify(t);if(s&&this.BXIM.notifyOpen)this.openNotify(true);this.updateNotifyCount(t)};BX.Notify.prototype.viewNotify=function(e,t,s){if(parseInt(e)<=0)return false;t=t===false?false:true;s=s===false?false:true;var i=this.notify[e];if(i&&i.type!=1){if(t){delete this.unreadNotify[e]}else{this.unreadNotify[e]=e}}delete this.flashNotify[e];BX.localStorage.set("mfn",this.flashNotify,80);if(s){BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_VIEW&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:{IM_NOTIFY_VIEW:"Y",ID:parseInt(e),READ:t?"Y":"N",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})}if(this.BXIM.notifyOpen){var i=BX.findChildByClassName(document.body,"bx-notifier-item-"+e);if(t){BX.removeClass(i,"bx-notifier-item-new")}else{BX.addClass(i,"bx-notifier-item-new")}}this.updateNotifyCount(false);return true};BX.Notify.prototype.viewNotifyAll=function(){if(this.BXIM.settings.notifyAutoRead){var e=0;for(var t in this.unreadNotify){var s=this.notify[t];if(s&&s.type!=1)delete this.unreadNotify[t];delete this.flashNotify[t];e=e<t?t:e}if(parseInt(e)<=0)return false;BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_VIEWED&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:{IM_NOTIFY_VIEWED:"Y",MAX_ID:parseInt(e),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});if(this.BXIM.notifyOpen){var i=BX.findChildrenByClassName(this.popupNotifyItem,"bx-notifier-item-new",false);if(i!=null){setTimeout(function(){for(var e=0;e<i.length;e++){if(i[e].getAttribute("data-notifyType")!=1){BX.removeClass(i[e],"bx-notifier-item-new")}}},500)}}this.updateNotifyCount(false)}else{for(var t in this.unreadNotify){delete this.flashNotify[t]}}BX.localStorage.set("mfn",this.flashNotify,80);return true};BX.Notify.prototype.newNotify=function(e){e=e!=false;var t=[];var s=[];var i=[];for(var a in this.flashNotify){if(this.flashNotify[a]===true){i.push(parseInt(a));this.flashNotify[a]=false}}var n={};i.sort(BX.delegate(function(e,t){if(!this.notify[e]||!this.notify[t]){return 0}var s=parseInt(this.notify[e].date);var i=parseInt(this.notify[t].date);var a=parseInt(this.notify[e].type);var n=parseInt(this.notify[t].type);if(a==1&&n!=1){return-1}else if(n==1&&a!=1){return 1}else if(i>s){return 1}else if(i<s){return-1}else{return 0}},this));for(var a=0;a<i.length;a++){var r=BX.clone(this.notify[i[a]]);if(r&&r.userId&&r.userName)n[r.userId]=r.userName;r.text=r.text.replace(/\[CHAT=([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,s){return s});r=this.createNotify(r,true);if(r!==false){t.push(r);r=this.notify[i[a]];s.push({title:r.userName?BX.util.htmlspecialcharsback(r.userName):BX.message("IM_NOTIFY_WINDOW_NEW_TITLE"),text:BX.util.htmlspecialcharsback(r.text).split("<br />").join("\n").replace(/<\/?[^>]+>/gi,""),icon:r.userAvatar?r.userAvatar:"",tag:"im-notify-"+r.tag})}}if(t.length>5){var o="";for(var a in n)o+=", <i>"+n[a]+"</i>";var r={id:0,type:4,date:+new Date/1e3,tag:"",original_tag:"",title:BX.message("IM_NM_NOTIFY_1").replace("#COUNT#",t.length),text:o.length>0?BX.message("IM_NM_NOTIFY_2").replace("#USERS#",o.substr(2)):BX.message("IM_NM_NOTIFY_3")};r=this.createNotify(r,true);BX.style(r,"cursor","pointer");t=[r];s=[{id:"",title:BX.message("IM_NM_NOTIFY_1").replace("#COUNT#",t.length),text:o.length>0?BX.message("IM_NM_NOTIFY_2").replace("#USERS#",BX.util.htmlspecialcharsback(o.substr(2))).replace(/<\/?[^>]+>/gi,""):BX.message("IM_NM_NOTIFY_3")}]}if(t.length==0)return false;if(this.desktop.ready())BX.desktop.flashIcon(false);this.closePopup();if(this.BXIM.context=="LINES"||this.BXIM.context=="DIALOG"){return false}if(!(!this.desktop.ready()&&this.desktop.run())&&(this.BXIM.settings.status=="dnd"||!this.desktop.ready()&&this.BXIM.desktopStatus))return false;if(e&&!this.BXIM.xmppStatus)this.BXIM.playSound("reminder");if(e&&this.desktop.ready()){for(var a=0;a<t.length;a++){var l=t[a].getAttribute("data-notifyId");var p='var notify = BX.findChildByClassName(document.body, "bx-notifier-item");'+'BX.bind(BX.findChildByClassName(notify, "bx-notifier-item-delete"), "click", function(event){ if (this.getAttribute("data-notifyType") != 1) { BX.desktop.onCustomEvent("main", "bxImClickCloseNotify", [this.getAttribute("data-notifyId")]); } BX.desktop.windowCommand("close"); BX.MessengerCommon.preventDefault(event); });'+(t[a].id>0?"":'BX.bind(notify, "click", function(event){ BX.desktop.onCustomEvent("main", "bxImClickNotify", []); BX.desktop.windowCommand("close"); BX.MessengerCommon.preventDefault(event); });')+'BX.bindDelegate(notify, "click", {className: "bx-notifier-item-button"}, BX.delegate(function(){ '+'BX.desktop.windowCommand("freeze");'+'notifyId = BX.proxy_context.getAttribute("data-id");'+"BXIM.notify.confirmRequest({"+'"notifyId": notifyId,'+'"notifyValue": BX.proxy_context.getAttribute("data-value"),'+'"notifyURL": BX.proxy_context.getAttribute("data-url"),'+'"notifyTag": BXIM.notify.notify[notifyId] && BXIM.notify.notify[notifyId].tag? BXIM.notify.notify[notifyId].tag: null,'+'"groupDelete": BX.proxy_context.getAttribute("data-group") == null? false: true,'+"}, true);"+'BX.desktop.onCustomEvent("main", "bxImClickConfirmNotify", [notifyId]); '+"}, BXIM.notify));"+'BX.bind(notify, "contextmenu", function(){ BX.desktop.windowCommand("close")});';this.desktop.openNewNotify(l,t[a],p)}}else if(e&&!this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){for(var a=0;a<s.length;a++){var r=s[a];r.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};r.onclick=function(){window.focus();top.BXIM.openNotify();this.close()};this.BXIM.notifyManager.nativeNotify(r)}}else{if(this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){BX.localStorage.set("mnnb",true,1)}for(var a=0;a<t.length;a++){this.BXIM.notifyManager.add({html:t[a],tag:t[a].id>0?"im-notify-"+this.notify[t[a].getAttribute("data-notifyId")].tag:"",originalTag:t[a].id>0?this.notify[t[a].getAttribute("data-notifyId")].original_tag:"",notifyId:t[a].getAttribute("data-notifyId"),notifyType:t[a].getAttribute("data-notifyType"),click:t[a].id>0?null:BX.delegate(function(e){
this.openNotify();e.close()},this),close:BX.delegate(function(e){if(e.notifyParams.notifyType!=1&&e.notifyParams.notifyId)this.viewNotify(e.notifyParams.notifyId)},this)})}}return true};BX.Notify.prototype.confirmRequest=function(e,t){if(this.confirmDisabledButtons)return false;t=t==true;e.notifyOriginTag=this.notify[e.notifyId]?this.notify[e.notifyId].original_tag:"";if(BX.MessengerCommon.isMobile()){if(e.groupDelete&&e.notifyTag!=null){for(var s in this.notify){if(this.notify[s].tag==e.notifyTag)delete this.notify[s]}}else{delete this.notify[e.notifyId]}}this.updateNotifyCount();if(t&&this.desktop.ready())BX.desktop.windowCommand("freeze");else BX.hide(BX.proxy_context.parentNode.parentNode.parentNode);BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_CONFIRM&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_NOTIFY_CONFIRM:"Y",NOTIFY_ID:e.notifyId,NOTIFY_VALUE:e.notifyValue,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(s){if(e.notifyURL!=null){if(t&&this.desktop.ready())BX.desktop.browse(e.notifyURL);else location.href=e.notifyURL;this.confirmDisabledButtons=true}if(!BX.MessengerCommon.isMobile()&&this.notify[e.notifyId]&&s.MESSAGES){this.notify[e.notifyId].confirmMessages=s.MESSAGES}BX.onCustomEvent(window,"onImConfirmNotify",[{NOTIFY_ID:e.notifyId,NOTIFY_TAG:e.notifyOriginTag,NOTIFY_VALUE:e.notifyValue,NOTIFY_MESSAGES:s.MESSAGES}]);if(t&&this.desktop.ready())BX.desktop.windowCommand("close")},this),onfailure:BX.delegate(function(){if(t&&this.desktop.ready())BX.desktop.windowCommand("close")},this)});if(e.groupDelete)BX.localStorage.set("nrgn",e.notifyTag,5);else BX.localStorage.set("nrn",e.notifyId,5);return false};BX.Notify.prototype.drawNotify=function(e,t){t=t==true;var s=typeof e=="object"?e:BX.clone(this.notify);var i={};var a={};for(var n in s){if(s[n].tag!=""&&s[n].params.CAN_ANSWER!="Y"){if(!a[s[n].tag]||!a[s[n].tag][s[n].userId]){if(a[s[n].tag]){if(!a[s[n].tag][s[n].userId])a[s[n].tag][s[n].userId]=s[n].id;if(parseInt(i[s[n].tag].date)<=parseInt(s[n].date)){s[n].groupped=true;delete s[i[s[n].tag].id];i[s[n].tag]=s[n]}else{s[i[s[n].tag].id].groupped=true;delete s[n]}}else{a[s[n].tag]={};a[s[n].tag][s[n].userId]=s[n].id;i[s[n].tag]=s[n]}}else{if(parseInt(i[s[n].tag].date)<=parseInt(s[n].date)){s[n].groupped=true;delete s[i[s[n].tag].id];i[s[n].tag]=s[n]}else{s[i[s[n].tag].id].groupped=true;delete s[n]}}}}var r=[];var o=[];for(var n in s){o.push(parseInt(n))}o.sort(function(e,t){if(!s[e]||!s[t]){return 0}var i=parseInt(s[e].date);var a=parseInt(s[t].date);var n=typeof s[e].confirmMessages=="undefined"?parseInt(s[e].type):2;var r=typeof s[t].confirmMessages=="undefined"?parseInt(s[t].type):2;if(n==1&&r!=1){return-1}else if(r==1&&n!=1){return 1}else if(a>i){return 1}else if(a<i){return-1}else{return 0}});for(var n=0;n<o.length;n++){var l=s[o[n]];if(l.groupped){l.otherCount=0;if(this.notify[l.id]){this.notify[l.id].otherItems=[];for(var p in a[l.tag]){if(this.notify[l.id].userId!=p)this.notify[l.id].otherItems.push(a[l.tag][p])}l.otherCount=this.notify[l.id].otherItems.length}if(l.otherCount>0&&l.type==2)l.type=3}l=this.createNotify(l);if(l!==false)r.push(l)}if(r.length==0){if(this.messenger.popupMessengerConnectionStatusState!="online"){r.push(BX.create("div",{attrs:{style:"padding-top: 231px; margin-bottom: 45px;"},props:{className:"bx-messenger-box-empty bx-notifier-content-empty",id:"bx-notifier-content-empty"},html:BX.message("IM_NOTIFY_ERROR")}));r.push(BX.create("a",{attrs:{href:"#notifyHistory",id:"bx-notifier-content-link-history"},props:{className:"bx-notifier-content-link-history bx-notifier-content-link-history-empty"},children:[BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_NOTIFY_HISTORY_2")})]}));this.notifyLoad=false}else if(this.BXIM.settings.loadLastNotify&&!this.notifyLoad||this.unreadNotifyLoad){r.push(BX.create("div",{attrs:{style:"padding-top: 162px;"},props:{className:"bx-notifier-content-load",id:"bx-notifier-content-load"},children:[BX.create("div",{props:{className:"bx-notifier-content-load-block bx-notifier-item"},children:[BX.create("span",{props:{className:"bx-notifier-content-load-block-img"}}),BX.create("span",{props:{className:"bx-notifier-content-load-block-text"},html:BX.message("IM_NOTIFY_LOAD_NOTIFY")})]})]}))}else if(!t&&!this.BXIM.settings.loadLastNotify){r.push(BX.create("div",{attrs:{style:"padding-top: 231px; margin-bottom: 45px;"},props:{className:"bx-messenger-box-empty bx-notifier-content-empty",id:"bx-notifier-content-empty"},html:BX.message("IM_NOTIFY_EMPTY_2")}));r.push(BX.create("a",{attrs:{href:"#notifyHistory",id:"bx-notifier-content-link-history"},props:{className:"bx-notifier-content-link-history bx-notifier-content-link-history-empty"},children:[BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_NOTIFY_HISTORY")})]}))}else if(!t){r.push(BX.create("div",{attrs:{style:"padding-top: 231px; margin-bottom: 45px;"},props:{className:"bx-messenger-box-empty bx-notifier-content-empty",id:"bx-notifier-content-empty"},html:BX.message("IM_NOTIFY_EMPTY_3")}));r.push(BX.create("a",{attrs:{href:"#notifyHistory",id:"bx-notifier-content-link-history"},props:{className:"bx-notifier-content-link-history bx-notifier-content-link-history-empty"},children:[BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_NOTIFY_HISTORY_LATE")})]}))}if(this.BXIM.settings.loadLastNotify)return r}else if(!t){r.push(BX.create("a",{attrs:{href:"#notifyHistory",id:"bx-notifier-content-link-history"},props:{className:"bx-notifier-content-link-history bx-notifier-content-link-history-empty"},children:[BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_NOTIFY_HISTORY_LATE")})]}))}return r};BX.Notify.prototype.openNotify=function(e,t){e=e==true;t=t==true;if(this.messenger.popupMessenger==null){this.messenger.openMessenger(false)}if(this.BXIM.notifyOpen&&!t){if(!e){this.messenger.extraClose(true);return false}}else{this.BXIM.dialogOpen=false;this.BXIM.notifyOpen=true;if(!this.desktop.run()){this.messengerNotifyButton.className="bx-messenger-cl-notify-button bx-messenger-cl-notify-button-active"}}this.messenger.closeMenuPopup();this.webrtc.callOverlayToggleSize(true);var s=this.drawNotify();this.notifyBody=BX.create("div",{props:{className:"bx-notifier-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-panel"},children:[BX.create("span",{props:{className:"bx-messenger-panel-avatar bx-messenger-avatar-notify"}}),BX.create("span",{props:{className:"bx-messenger-panel-title bx-messenger-panel-title-middle"},html:BX.message("IM_NOTIFY_WINDOW_TITLE")})]}),this.popupNotifyButtonFilterBox=BX.create("div",{props:{className:"bx-messenger-panel-filter-box"},style:{display:"none"},children:[BX.create("div",{props:{className:"bx-messenger-filter-name"},html:BX.message("IM_PANEL_FILTER_NAME")}),this.popupHistorySearchDateWrap=BX.create("div",{props:{className:"bx-messenger-filter-date bx-messenger-input-wrap bx-messenger-filter-date-notify"},html:'<span class="bx-messenger-input-date"></span><a class="bx-messenger-input-close" href="#close"></a><input type="text" class="bx-messenger-input" value="" tabindex="1002" placeholder="'+BX.message("IM_PANEL_FILTER_DATE")+'" />'})]}),this.popupNotifyItem=BX.create("div",{props:{className:"bx-notifier-item-wrap"},style:{height:this.popupNotifySize+"px"},children:s})]});this.messenger.extraOpen(this.notifyBody);this.BXIM.notifyManager.nativeNotifyAccessForm();if(this.unreadNotifyLoad)this.loadNotify();else if(!this.notifyLoad&&this.BXIM.settings.loadLastNotify)this.notifyHistory();if(!e&&this.BXIM.isFocus("notify")&&this.notifyUpdateCount>0)this.viewNotifyAll();BX.bind(this.popupNotifyItem,"scroll",BX.delegate(function(){if(this.messenger.popupPopupMenu!=null){if(BX.util.in_array(this.messenger.popupPopupMenu.uniquePopupId.replace("bx-messenger-popup-",""),["copypaste","copylink","notifyDelete","notify","external-data"])){this.messenger.popupPopupMenu.close()}}},this));BX.bind(BX("bx-notifier-content-link-history"),"click",BX.delegate(this.notifyHistory,this));BX.bind(this.popupNotifyItem,"click",BX.delegate(this.closePopup,this));BX.bind(this.notifyBody,"click",BX.delegate(function(e){BX.MessengerCommon.contactListSearchClear(e)},BX.MessengerCommon));BX.bindDelegate(this.popupNotifyItem,"click",{className:"bx-messenger-ajax"},BX.delegate(function(){if(BX.proxy_context.getAttribute("data-entity")=="user"){this.messenger.openPopupExternalData(BX.proxy_context,"user",true,{ID:BX.proxy_context.getAttribute("data-userId")})}else if(BX.proxy_context.getAttribute("data-entity")=="chat"){this.messenger.openPopupExternalData(BX.proxy_context,"chat",true,{ID:BX.proxy_context.getAttribute("data-chatId")})}else if(BX.proxy_context.getAttribute("data-entity")=="network"){this.messenger.openMessenger("network"+BX.proxy_context.getAttribute("data-networkId"))}},this));BX.bindDelegate(this.popupNotifyItem,"click",{className:"bx-notifier-item-help"},BX.proxy(function(e){if(this.popupNotifyMore!=null)this.popupNotifyMore.destroy();else{var t=this.notify[BX.proxy_context.getAttribute("data-help")];if(!t.otherItems)return false;var s='<span class="bx-notifier-item-help-popup">';for(var i=0;i<t.otherItems.length;i++){var a=BX.MessengerCommon.isBlankAvatar(this.notify[t.otherItems[i]].userAvatar)?'style="background-color: '+this.notify[t.otherItems[i]].userColor+'"':"";var n=BX.MessengerCommon.getUserParam(this.notify[t.otherItems[i]].userId);s+='<a class="bx-notifier-item-help-popup-img" href="'+this.notify[t.otherItems[i]].userLink+'" onclick="BXIM.openMessenger('+this.notify[t.otherItems[i]].userId+'); return false;" target="_blank">'+'<span class="bx-notifier-popup-avatar bx-notifier-popup-avatar-status-'+n.status+'">'+'<img class="bx-notifier-popup-avatar-img'+(BX.MessengerCommon.isBlankAvatar(this.notify[t.otherItems[i]].userAvatar)?" bx-notifier-popup-avatar-img-default":"")+'" src="'+this.notify[t.otherItems[i]].userAvatar+'" '+a+">"+"</span>"+'<span class="bx-notifier-item-help-popup-name '+(n.extranet?" bx-notifier-popup-avatar-extranet":"")+'">'+BX.MessengerCommon.prepareText(this.notify[t.otherItems[i]].userName)+"</span>"+"</a>"}s+="</span>";this.popupNotifyMore=new BX.PopupWindow("bx-notifier-other-window",BX.proxy_context,{zIndex:200,lightShadow:true,offsetTop:-2,offsetLeft:3,autoHide:true,closeByEsc:true,bindOptions:{position:"top"},events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.proxy(function(){this.popupNotifyMore=null},this)},content:BX.create("div",{props:{className:"bx-messenger-popup-menu"},html:s})});this.popupNotifyMore.setAngle({});this.popupNotifyMore.show();BX.bind(this.popupNotifyMore.popupContainer,"click",BX.MessengerCommon.preventDefault)}return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupNotifyItem,"click",{className:"bx-notifier-answer-reply"},BX.proxy(function(e){if(!BX.proxy_context)return;if(!this.toggleNotifyAnswer(BX.proxy_context.parentNode))return true;return BX.PreventDefault(e)},this));var i=BX.findChildByClassName(this.popupNotifyItem,"bx-notifier-answer-box-open");if(i){var a=i.firstChild.nextSibling.firstChild;a.focus();a.selectionStart=a.value.length+1;a.selectionEnd=a.value.length+1}BX.bindDelegate(this.popupNotifyItem,"click",{className:"bx-notifier-answer-button"},BX.proxy(function(e){if(!BX.proxy_context)return;this.sendNotifyAnswer(BX.proxy_context.parentNode);return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupNotifyItem,"click",{className:"bx-notifier-item-delete"},BX.proxy(function(e){if(!BX.proxy_context)return;BX.proxy_context.setAttribute("id","bx-notifier-item-delete-"+BX.proxy_context.getAttribute("data-notifyId"));this.deleteNotify(BX.proxy_context.getAttribute("data-notifyId"));return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupNotifyItem,"click",{className:"bx-notifier-item-button-confirm"},BX.proxy(function(e){if(this.messenger.popupMessengerConnectionStatusState!="online")return false;var t=BX.proxy_context.getAttribute("data-id");this.confirmRequest({notifyId:t,notifyValue:BX.proxy_context.getAttribute("data-value"),notifyURL:BX.proxy_context.getAttribute("data-url"),notifyTag:this.notify[t]&&this.notify[t].tag?this.notify[t].tag:null,groupDelete:BX.proxy_context.getAttribute("data-group")!=null});this.openNotify(true);if(BX.MessengerCommon.isMobile()){if(BX.proxy_context.parentNode.parentNode.parentNode.previousSibling==null&&BX.proxy_context.parentNode.parentNode.parentNode.nextSibling==null)this.openNotify(true);else if(BX.proxy_context.parentNode.parentNode.parentNode.previousSibling==null&&BX.proxy_context.parentNode.parentNode.parentNode.nextSibling.tagName.toUpperCase()=="A")this.openNotify(true);else BX.remove(BX.proxy_context.parentNode.parentNode.parentNode)}return BX.PreventDefault(e)},this));if(this.desktop.ready()){BX.bindDelegate(this.popupNotifyItem,"contextmenu",{className:"bx-notifier-item-content"},BX.delegate(function(e){this.messenger.openPopupMenu(e,"notify",false);return BX.PreventDefault(e)},this))}else{BX.bindDelegate(this.popupNotifyItem,"contextmenu",{className:"bx-notifier-item-delete"},BX.proxy(function(e){if(!BX.proxy_context)return;BX.proxy_context.setAttribute("id","bx-notifier-item-delete-"+BX.proxy_context.getAttribute("data-notifyId"));this.messenger.openPopupMenu(BX.proxy_context,"notifyDelete");return BX.PreventDefault(e)},this))}BX.bindDelegate(this.popupNotifyItem,"dblclick",{className:"bx-notifier-item"},BX.delegate(function(e){if(!BX.proxy_context)return;var t=BX.proxy_context.getAttribute("data-notifyId");if(this.unreadNotify[t]){this.viewNotify(t,true)}else{this.viewNotify(t,false)}return BX.PreventDefault(e)},this));if(false&&!this.BXIM.settings.notifyAutoRead){BX.bindDelegate(this.popupNotifyItem,"click",{className:"bx-notifier-item-text-link"},BX.delegate(function(e){var t=BX.proxy_context.parentNode.parentNode.parentNode.getAttribute("data-notifyId");if(this.unreadNotify[t]){this.viewNotify(t,true)}},this))}return false};BX.Notify.prototype.deleteNotify=function(e){var t=BX("bx-notifier-item-delete-"+e);var s=false;if(this.notify[e]){s=true;var i=null;if(this.notify[e].tag){i=this.notify[e].tag}if(this.notify[e].type==1){s=false}var a=!(t.getAttribute("data-group")==null||i==null);if(a){for(var n in this.notify){if(this.notify[n].tag==i)delete this.notify[n]}}else{delete this.notify[e]}}this.updateNotifyCount();if(s){this.skipMassDelete=true;var r={};if(a)r={IM_NOTIFY_GROUP_REMOVE:"Y",NOTIFY_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()};else r={IM_NOTIFY_REMOVE:"Y",NOTIFY_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()};BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_REMOVE&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:r,onsuccess:BX.delegate(function(e){setTimeout(BX.delegate(function(){this.skipMassDelete=false},this),2e3)},this)});if(a)BX.localStorage.set("nrgn",i,5);else BX.localStorage.set("nrn",e,5)}if(t.parentNode.parentNode.previousSibling==null&&t.parentNode.parentNode.nextSibling==null){this.openNotify(true)}else if(t.parentNode.parentNode.previousSibling==null&&t.parentNode.parentNode.nextSibling.tagName.toUpperCase()=="A"){this.notifyLoad=false;this.notifyHistoryPage=0;this.openNotify(true)}else{BX.remove(t.parentNode.parentNode)}return true};BX.Notify.prototype.blockNotifyType=function(e){var t=typeof this.BXIM.settingsNotifyBlocked[e]=="undefined";BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_BLOCK_TYPE&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_NOTIFY_BLOCK_TYPE:"Y",BLOCK_TYPE:e,BLOCK_RESULT:t?"Y":"N",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});if(t){this.BXIM.settingsNotifyBlocked[e]=true;this.BXIM.settings["site|".settingName]=false;this.BXIM.settings["xmpp|".settingName]=false;this.BXIM.settings["email|".settingName]=false}else{delete this.BXIM.settingsNotifyBlocked[e];this.BXIM.settings["site|".settingName]=true;this.BXIM.settings["xmpp|".settingName]=true;this.BXIM.settings["email|".settingName]=true}return true};BX.Notify.prototype.closeNotify=function(){if(!this.desktop.run()){this.messengerNotifyButton.className="bx-messenger-cl-notify-button"}this.BXIM.notifyOpen=false;this.popupNotifyItem=null;BX.unbindAll(this.popupNotifyButtonFilter);BX.unbindAll(this.popupNotifyItem)};BX.Notify.prototype.loadNotify=function(e){if(this.loadNotityBlock)return false;e=e!=false;this.loadNotityBlock=true;BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_LOAD&V="+this.BXIM.revision,method:"POST",dataType:"json",lsId:"IM_NOTIFY_LOAD",lsTimeout:5,timeout:30,data:{IM_NOTIFY_LOAD:"Y",IM_AUTO_READ:this.BXIM.settings.notifyAutoRead?"Y":"N",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(t){this.loadNotityBlock=false;this.unreadNotifyLoad=false;this.notifyLoad=true;var s={};if(typeof t.NOTIFY=="object"){for(var i in t.NOTIFY){t.NOTIFY[i].date=parseInt(t.NOTIFY[i].date)+parseInt(BX.message("USER_TZ_OFFSET"));s[i]=this.notify[i]=t.NOTIFY[i];this.BXIM.lastRecordId=parseInt(i)>this.BXIM.lastRecordId?parseInt(i):this.BXIM.lastRecordId;if(this.BXIM.settings.notifyAutoRead){if(t.NOTIFY[i].type!="1"){delete this.unreadNotify[i]}else{this.unreadNotify[i]=i}}else{this.unreadNotify[i]=i}}}if(e){this.openNotify(true);if(this.BXIM.settings.loadLastNotify)this.notifyHistory();BX.localStorage.set("nln",true,5)}this.updateNotifyCount()},this),onfailure:BX.delegate(function(){this.loadNotityBlock=false},this)})};BX.Notify.prototype.notifyHistory=function(e){e=e||window.event;if(this.notifyHistoryLoad)return false;if(this.messenger&&this.messenger.popupMessengerConnectionStatusState!="online")return false;if(BX("bx-notifier-content-link-history")){BX("bx-notifier-content-link-history").innerHTML='<span class="bx-notifier-item-button bx-notifier-item-button-white">'+BX.message("IM_NOTIFY_LOAD_NOTIFY")+"..."+"</span>"}this.notifyHistoryLoad=true;BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_HISTORY_LOAD_MORE&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_NOTIFY_HISTORY_LOAD_MORE:"Y",PAGE:!this.BXIM.settings.loadLastNotify&&this.notifyHistoryPage==0?1:this.notifyHistoryPage,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(e&&e.BITRIX_SESSID){BX.message({bitrix_sessid:e.BITRIX_SESSID})}if(e.ERROR==""){this.notifyLoad=true;BX.remove(BX("bx-notifier-content-load"));this.sendAjaxTry=0;var t={};var s=0;if(typeof e.NOTIFY=="object"){for(var i in e.NOTIFY){e.NOTIFY[i].date=parseInt(e.NOTIFY[i].date)+parseInt(BX.message("USER_TZ_OFFSET"));if(!this.notify[i])t[i]=e.NOTIFY[i];if(!this.notify[i]){this.notify[i]=BX.clone(e.NOTIFY[i])}s++}}if(this.popupNotifyItem){if(BX("bx-notifier-content-link-history"))BX.remove(BX("bx-notifier-content-link-history"));if(s>0){if(BX("bx-notifier-content-empty"))BX.remove(BX("bx-notifier-content-empty"));var t=this.drawNotify(t,true);for(var i=0;i<t.length;i++){this.popupNotifyItem.appendChild(t[i])}if(s<20&&this.notifyHistoryPage>0){BX.remove(BX("bx-notifier-content-link-history"))}else{this.popupNotifyItem.appendChild(BX.create("a",{attrs:{href:"#notifyHistory",id:"bx-notifier-content-link-history"},events:{click:BX.delegate(this.notifyHistory,this)},props:{className:"bx-notifier-content-link-history"},children:[BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_NOTIFY_HISTORY_LATE")})]}));if(s>=20&&this.notifyHistoryPage==0)this.notifyHistoryPage=1}}else if(s<=0&&this.notifyHistoryPage==0){if(BX("bx-notifier-content-link-history"))BX.remove(BX("bx-notifier-content-link-history"));this.popupNotifyItem.innerHTML="";this.popupNotifyItem.appendChild(BX.create("div",{attrs:{style:"padding-top: 210px; margin-bottom: 20px;"},props:{className:"bx-messenger-box-empty bx-notifier-content-empty",id:"bx-notifier-content-empty"},html:BX.message("IM_NOTIFY_EMPTY_3")}));this.popupNotifyItem.appendChild(BX.create("a",{attrs:{href:"#notifyHistory",id:"bx-notifier-content-link-history"},events:{click:BX.delegate(this.notifyHistory,this)},props:{className:"bx-notifier-content-link-history bx-notifier-content-link-history-empty"},children:[BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_NOTIFY_HISTORY_LATE")})]}))}else{if(this.popupNotifyItem.innerHTML==""){this.popupNotifyItem.appendChild(BX.create("div",{attrs:{style:"padding-top: 210px; margin-bottom: 20px;"},props:{className:"bx-messenger-box-empty bx-notifier-content-empty",id:"bx-notifier-content-empty"},html:BX.message("IM_NOTIFY_EMPTY_3")}))}}}this.notifyHistoryLoad=false;this.notifyHistoryPage++}else{if(e.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<2){this.sendAjaxTry++;BX.message({bitrix_sessid:e.BITRIX_SESSID});setTimeout(BX.delegate(function(){this.notifyHistoryLoad=false;this.notifyHistory()},this),2e3);BX.onCustomEvent(window,"onImError",[e.ERROR,e.BITRIX_SESSID])}else if(e.ERROR=="AUTHORIZE_ERROR"){this.sendAjaxTry++;if(this.desktop.ready()){setTimeout(BX.delegate(function(){this.notifyHistoryLoad=false;this.notifyHistory()},this),1e4)}BX.onCustomEvent(window,"onImError",[e.ERROR])}}},this),onfailure:BX.delegate(function(){this.notifyHistoryLoad=false;this.sendAjaxTry=0},this)});if(e)return BX.PreventDefault(e);else return true};BX.Notify.prototype.adjustPosition=function(e){if(this.desktop.run())return false;e=e||{};e.timeout=typeof e.timeout=="number"?parseInt(e.timeout):0;clearTimeout(this.adjustPositionTimeout);this.adjustPositionTimeout=setTimeout(BX.delegate(function(){e.scroll=e.scroll||!BX.browser.IsDoctype();e.resize=e.resize||false;if(!this.windowScrollPos.scrollLeft)this.windowScrollPos={scrollLeft:0,scrollTop:0};if(e.scroll)this.windowScrollPos=BX.GetWindowScrollPos();if(e.resize||!this.windowInnerSize.innerWidth){this.windowInnerSize=BX.GetWindowInnerSize();if(this.BXIM.settings.panelPositionVertical=="bottom"&&typeof window.scroll=="function"&&!(BX.browser.IsAndroid()||BX.browser.IsIOS())){if(typeof window.scrollX!="undefined"&&typeof window.scrollY!="undefined"){var t=window.scrollX;window.scroll(1,window.scrollY);this.windowInnerSize.innerHeight+=window.scrollX==1?-16:0;window.scroll(t,window.scrollY)}else{var s=document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft;var i=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;var t=s;window.scroll(1,i);s=document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft;this.windowInnerSize.innerHeight+=s==1?-16:0;window.scroll(t,i)}}}if(e.scroll||e.resize){if(this.BXIM.settings.panelPositionHorizontal=="left")this.panel.style.left=this.windowScrollPos.scrollLeft+25+"px";else if(this.BXIM.settings.panelPositionHorizontal=="center")this.panel.style.left=(this.windowScrollPos.scrollLeft+this.windowInnerSize.innerWidth-this.panel.offsetWidth)/2+"px";else if(this.BXIM.settings.panelPositionHorizontal=="right")this.panel.style.left=this.windowScrollPos.scrollLeft+this.windowInnerSize.innerWidth-this.panel.offsetWidth-35+"px";if(this.BXIM.settings.panelPositionVertical=="top"){this.panel.style.top=this.windowScrollPos.scrollTop+"px";if(BX.hasClass(this.panel,"bx-notifier-panel-doc"))this.panel.className="bx-notifier-panel bx-notifier-panel-top bx-notifier-panel-doc";else this.panel.className="bx-notifier-panel bx-notifier-panel-top"}else if(this.BXIM.settings.panelPositionVertical=="bottom"){if(BX.hasClass(this.panel,"bx-notifier-panel-doc"))this.panel.className="bx-notifier-panel bx-notifier-panel-bottom bx-notifier-panel-doc";else this.panel.className="bx-notifier-panel bx-notifier-panel-bottom";this.panel.style.top=this.windowScrollPos.scrollTop+this.windowInnerSize.innerHeight-this.panel.offsetHeight+"px"}}},this),e.timeout)};BX.Notify.prototype.move=function(e,t){var s=parseInt(this.panel.style.left)+e;var i=parseInt(this.panel.style.top)+t;if(s<0)s=0;var a=BX.GetWindowScrollSize();var n=this.panel.offsetWidth;var r=this.panel.offsetHeight;if(s>a.scrollWidth-n)s=a.scrollWidth-n;if(i>a.scrollHeight-r)i=a.scrollHeight-r;if(i<0)i=0;this.panel.style.left=s+"px";this.panel.style.top=i+"px"};BX.Notify.prototype._startDrag=function(e){e=e||window.event;BX.fixEventPageXY(e);this.dragPageX=e.pageX;this.dragPageY=e.pageY;this.dragged=false;this.closePopup();BX.bind(document,"mousemove",BX.proxy(this._moveDrag,this));BX.bind(document,"mouseup",BX.proxy(this._stopDrag,this));if(document.body.setCapture)document.body.setCapture();document.body.ondrag=BX.False;document.body.onselectstart=BX.False;document.body.style.cursor="move";document.body.style.MozUserSelect="none";this.panel.style.MozUserSelect="none";BX.addClass(this.panel,"bx-notifier-panel-drag-"+(this.BXIM.settings.panelPositionVertical=="top"?"top":"bottom"));return BX.PreventDefault(e)};BX.Notify.prototype._moveDrag=function(e){e=e||window.event;BX.fixEventPageXY(e);if(this.dragPageX==e.pageX&&this.dragPageY==e.pageY)return;this.move(e.pageX-this.dragPageX,e.pageY-this.dragPageY);this.dragPageX=e.pageX;this.dragPageY=e.pageY;if(!this.dragged){BX.onCustomEvent(this,"onPopupDragStart");this.dragged=true}BX.onCustomEvent(this,"onPopupDrag")};BX.Notify.prototype._stopDrag=function(e){if(document.body.releaseCapture)document.body.releaseCapture();BX.unbind(document,"mousemove",BX.proxy(this._moveDrag,this));BX.unbind(document,"mouseup",BX.proxy(this._stopDrag,this));document.body.ondrag=null;document.body.onselectstart=null;document.body.style.cursor="";document.body.style.MozUserSelect="";this.panel.style.MozUserSelect="";BX.removeClass(this.panel,"bx-notifier-panel-drag-"+(this.BXIM.settings.panelPositionVertical=="top"?"top":"bottom"));BX.onCustomEvent(this,"onPopupDragEnd");var t=BX.GetWindowScrollPos();this.BXIM.settings.panelPositionVertical=this.windowInnerSize.innerHeight/2>(e.pageY-t.scrollTop||e.y)?"top":"bottom";if(this.windowInnerSize.innerWidth/3>(e.pageX-t.scrollLeft||e.x))this.BXIM.settings.panelPositionHorizontal="left";else if(this.windowInnerSize.innerWidth/3*2<(e.pageX-t.scrollLeft||e.x))this.BXIM.settings.panelPositionHorizontal="right";else this.BXIM.settings.panelPositionHorizontal="center";this.BXIM.saveSettings({panelPositionVertical:this.BXIM.settings.panelPositionVertical,panelPositionHorizontal:this.BXIM.settings.panelPositionHorizontal});BX.localStorage.set("npp",{v:this.BXIM.settings.panelPositionVertical,h:this.BXIM.settings.panelPositionHorizontal});this.adjustPosition({resize:true});this.dragged=false;return BX.PreventDefault(e)};BX.Notify.prototype.closePopup=function(){if(this.popupNotifyMore!=null)this.popupNotifyMore.destroy();if(this.messenger!=null&&this.messenger.popupPopupMenu!=null)this.messenger.popupPopupMenu.destroy()};BX.Notify.prototype.createNotify=function(e,t){var s=false;if(!e)return false;t=t==true;e.text=e.text.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,function(e,t,s){var i="";t=parseInt(t);if(t>0&&typeof BXIM!="undefined")i='<span class="bx-messenger-ajax '+(t==BXIM.userId?"bx-messenger-ajax-self":"")+'" data-entity="user" data-userId="'+t+'">'+s+"</span>";else i=s;return i});e.text=e.text.replace(/\[CHAT=([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,s){var i="";t=parseInt(t);if(t>0)i='<span class="bx-messenger-ajax" data-entity="chat" data-chatId="'+t+'">'+s+"</span>";else i=s;return i});e.text=e.text.replace(/<a(.*?)>(.*?)<\/a>/gi,BX.delegate(function(e,t,s){if(this.desktop.run()){t=t.replace('target="_self"','target="_blank"')}return"<a"+t+' class="bx-notifier-item-text-link">'+s+"</a>"},this));var i=this.unreadNotify[e.id]&&!t?" bx-notifier-item-new":"";e.userAvatar=e.userAvatar?e.userAvatar:this.BXIM.pathToBlankImage;var a=e.params&&e.params.ATTACH?BX.MessengerCommon.drawAttach(0,0,e.params.ATTACH):[];if(a.length>0){a=BX.create("div",{props:{className:"bx-messenger-attach-box"},children:a})}else{a=null}if(e.type==1&&typeof e.buttons!="undefined"&&e.buttons.length>0){var n=[];var r=false;if(typeof e.confirmMessages!="undefined"){r=true;for(var o=0;o<e.confirmMessages.length;o++){n.push(BX.create("div",{props:{className:"bx-notifier-item-confirm-message"},html:e.confirmMessages[o]}))}}else{for(var o=0;o<e.buttons.length;o++){var l=e.buttons[o].TYPE=="accept"?"accept":e.buttons[o].TYPE=="cancel"?"cancel":"default";var p={"data-id":e.id,"data-value":e.buttons[o].VALUE};if(e.grouped)p["data-group"]="Y";if(e.buttons[o].URL)p["data-url"]=e.buttons[o].URL;n.push(BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-confirm bx-notifier-item-button-"+l},attrs:p,html:e.buttons[o].TITLE}))}}s=BX.create("div",{attrs:{"data-notifyId":e.id,"data-notifyType":e.type},props:{className:"bx-notifier-item bx-notifier-item-"+e.id+" "+i},children:[BX.create("span",{props:{className:"bx-notifier-item-content"},children:[BX.create("span",{props:{className:"bx-notifier-item-avatar"},children:[BX.create("img",{props:{className:"bx-notifier-item-avatar-img"+(BX.MessengerCommon.isBlankAvatar(e.userAvatar)?" bx-notifier-item-avatar-img-default":"")},attrs:{src:e.userAvatar,style:BX.MessengerCommon.isBlankAvatar(e.userAvatar)?"background-color: "+e.userColor:""}})]}),!r?BX.create("span",{props:{className:"bx-notifier-item-delete bx-notifier-item-delete-fake"}}):BX.create("a",{attrs:{href:"#","data-notifyId":e.id,"data-notifyType":e.type,title:BX.message("IM_NOTIFY_DELETE_1")},props:{className:"bx-notifier-item-delete"}}),BX.create("span",{props:{className:"bx-notifier-item-date"},html:BX.MessengerCommon.formatDate(e.date)}),e.userName?BX.create("span",{props:{className:"bx-notifier-item-name"},html:'<a href="'+e.userLink+'" onclick="if (BXIM.init) { BXIM.openMessenger('+e.userId+'); return false; } ">'+BX.MessengerCommon.prepareText(e.userName)+"</a>"}):null,BX.create("span",{props:{className:"bx-notifier-item-text"},html:e.text}),a,BX.create("span",{props:{className:"bx-notifier-item-button-wrap"},children:n})]})]})}else if(e.type==2||e.type==1&&typeof e.buttons!="undefined"&&e.buttons.length<=0){s=BX.create("div",{attrs:{"data-notifyId":e.id,"data-notifyType":e.type},props:{className:"bx-notifier-item bx-notifier-item-"+e.id+" "+i},children:[BX.create("span",{props:{className:"bx-notifier-item-content"},children:[BX.create("span",{props:{className:"bx-notifier-item-avatar"},children:[BX.create("img",{props:{className:"bx-notifier-item-avatar-img"+(BX.MessengerCommon.isBlankAvatar(e.userAvatar)?" bx-notifier-item-avatar-img-default":"")},attrs:{src:e.userAvatar,style:BX.MessengerCommon.isBlankAvatar(e.userAvatar)?"background-color: "+e.userColor:""}})]}),BX.create("a",{attrs:{href:"#","data-notifyId":e.id,"data-notifyType":e.type,title:BX.message("IM_NOTIFY_DELETE_1")},props:{className:"bx-notifier-item-delete"}}),BX.create("span",{props:{className:"bx-notifier-item-date"},html:BX.MessengerCommon.formatDate(e.date)}),BX.create("span",{props:{className:"bx-notifier-item-name"},html:'<a href="'+e.userLink+'" onclick="if (BXIM.init) { BXIM.openMessenger('+e.userId+'); return false; } ">'+BX.MessengerCommon.prepareText(e.userName)+"</a>"}),BX.create("span",{props:{className:"bx-notifier-item-text"},html:e.text}),a,this.drawNotifyAnswer(e)]})]})}else if(e.type==3){s=BX.create("div",{attrs:{"data-notifyId":e.id,"data-notifyType":e.type},props:{className:"bx-notifier-item bx-notifier-item-"+e.id+" "+i},children:[BX.create("span",{props:{className:"bx-notifier-item-content"},children:[BX.create("span",{props:{className:"bx-notifier-item-avatar-group"},children:[BX.create("span",{props:{className:"bx-notifier-item-avatar"},children:[BX.create("img",{props:{className:"bx-notifier-item-avatar-img"+(BX.MessengerCommon.isBlankAvatar(e.userAvatar)?" bx-notifier-item-avatar-img-default":"")},attrs:{src:e.userAvatar,style:BX.MessengerCommon.isBlankAvatar(e.userAvatar)?"background-color: "+e.userColor:""}})]})]}),BX.create("a",{attrs:{href:"#","data-notifyId":e.id,
"data-group":"Y","data-notifyType":e.type,title:BX.message("IM_NOTIFY_DELETE_1")},props:{className:"bx-notifier-item-delete"}}),BX.create("span",{props:{className:"bx-notifier-item-date"},html:BX.MessengerCommon.formatDate(e.date)}),BX.create("span",{props:{className:"bx-notifier-item-name"},html:BX.message("IM_NOTIFY_GROUP_NOTIFY").replace("#USER_NAME#",'<a href="'+e.userLink+'" onclick="if (BXIM.init) { BXIM.openMessenger('+e.userId+'); return false;} ">'+BX.MessengerCommon.prepareText(e.userName)+"</a>").replace("#U_START#",'<span class="bx-notifier-item-help" data-help="'+e.id+'">').replace("#U_END#","</span>").replace("#COUNT#",e.otherCount)}),BX.create("span",{props:{className:"bx-notifier-item-text"},html:e.text}),a,this.drawNotifyAnswer(e)]})]})}else{s=BX.create("div",{attrs:{"data-notifyId":e.id,"data-notifyType":e.type},props:{className:"bx-notifier-item bx-notifier-item-"+e.id+" "+i},children:[BX.create("span",{props:{className:"bx-notifier-item-content"},children:[BX.create("span",{props:{className:"bx-notifier-item-avatar"},children:[BX.create("img",{props:{className:"bx-notifier-item-avatar-img bx-notifier-item-avatar-img-default-2"},attrs:{src:e.userAvatar}})]}),BX.create("a",{attrs:{href:"#","data-notifyId":e.id,"data-notifyType":e.type,title:BX.message("IM_NOTIFY_DELETE_1")},props:{className:"bx-notifier-item-delete"}}),BX.create("span",{props:{className:"bx-notifier-item-date"},html:BX.MessengerCommon.formatDate(e.date)}),e.title&&e.title.length>0?BX.create("span",{props:{className:"bx-notifier-item-name"},html:BX.MessengerCommon.prepareText(e.title)}):null,BX.create("span",{props:{className:"bx-notifier-item-text"},html:e.text}),a,this.drawNotifyAnswer(e)]})]})}return s};BX.Notify.prototype.drawNotifyAnswer=function(e){var t=null;if(typeof e.params=="object"&&e.params.CAN_ANSWER!="Y")return t;value=this.notifyAnswerText[e.id]?this.notifyAnswerText[e.id]:"";t=BX.create("div",{props:{className:"bx-notifier-item-text"},children:[BX.create("div",{props:{className:"bx-notifier-answer-link"},children:[BX.create("span",{props:{className:"bx-notifier-answer-reply bx-messenger-ajax"},html:BX.message("IM_N_REPLY")})]}),BX.create("div",{attrs:{"data-id":e.id},props:{className:"bx-notifier-answer-box"+(value?" bx-notifier-answer-box-open":"")},children:[BX.create("span",{props:{className:"bx-notifier-answer-progress"}}),BX.create("span",{props:{className:"bx-notifier-answer-input"},children:[BX.create("input",{attrs:{type:"text",value:value,"data-id":e.id},events:{keydown:BX.delegate(function(e){if(e.keyCode==13){this.sendNotifyAnswer(BX.proxy_context.parentNode.parentNode)}else if(e.keyCode==27){if(BX.proxy_context.value!=""){BX.proxy_context.value="";this.notifyAnswerText[BX.proxy_context.getAttribute("data-id")]=""}else{this.toggleNotifyAnswer(BX.proxy_context.parentNode.parentNode.previousSibling)}return BX.MessengerCommon.preventDefault(e)}},this),keyup:BX.delegate(function(e){this.notifyAnswerText[BX.proxy_context.getAttribute("data-id")]=BX.proxy_context.value},this)},props:{className:"bx-messenger-input"}})]}),BX.create("a",{attrs:{href:"#send"},props:{className:"bx-notifier-answer-button"}})]}),BX.create("div",{props:{className:"bx-notifier-answer-text"},html:BX.message("IM_N_REPLY_TEXT")})]});return t};BX.Notify.prototype.toggleNotifyAnswer=function(e){var t=e.nextSibling.getAttribute("data-id");if(this.notifyAnswerBlock[t])return false;BX.toggleClass(e.nextSibling,"bx-notifier-answer-box-open");BX.removeClass(e.nextSibling.nextSibling,"bx-notifier-answer-text-show");var s=BX.findChildByClassName(e.nextSibling,"bx-messenger-input");if(s){s.focus()}return true};BX.Notify.prototype.sendNotifyAnswer=function(e,t){var s=e.getAttribute("data-id");if(this.notifyAnswerBlock[s])return true;var i=BX.findChildByClassName(e,"bx-messenger-input");if(!i)return false;i.value=BX.util.trim(i.value);if(i.value==""){return true}if(!this.BXIM.init&&this.desktop.ready())BX.desktop.windowCommand("freeze");this.notifyAnswerBlock[s]=true;this.notifyAnswerText[s]=i.value;i.disabled=true;BX.addClass(e,"bx-notifier-answer-box-send");BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_ANSWER&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_NOTIFY_ANSWER:"Y",NOTIFY_ID:s,NOTIFY_ANSWER:i.value,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(t){BX.removeClass(e,"bx-notifier-answer-box-error");BX.removeClass(e,"bx-notifier-answer-box-send");this.notifyAnswerBlock[s]=false;this.notifyAnswerText[s]="";var i=BX.findChildByClassName(e,"bx-messenger-input");if(i){i.disabled=false}if(t.ERROR==""){BX.removeClass(e,"bx-notifier-answer-box-open");BX.addClass(e.nextSibling,"bx-notifier-answer-text-show");if(t.MESSAGES&&t.MESSAGES.length>0){e.nextSibling.innerHTML=t.MESSAGES.join("<br/>")}if(i){i.value=""}if(!this.BXIM.init&&this.desktop.ready())BX.desktop.windowCommand("close")}else{BX.addClass(e,"bx-notifier-answer-box-error")}},this),onfailure:BX.delegate(function(){BX.addClass(e,"bx-notifier-answer-box-error");BX.removeClass(e,"bx-notifier-answer-box-send");this.notifyAnswerBlock[s]=false;var t=BX.findChildByClassName(e,"bx-messenger-input");if(t){t.disabled=false}},this)});return true};BX.Notify.prototype.storageSet=function(e){if(e.key=="npp"){var t=BX.localStorage.get(e.key);this.BXIM.settings.panelPositionHorizontal=!!t?t.h:this.BXIM.settings.panelPositionHorizontal;this.BXIM.settings.panelPositionVertical=!!t?t.v:this.BXIM.settings.panelPositionVertical;this.adjustPosition({resize:true})}else if(e.key=="nun"){this.notify=e.value}else if(e.key=="nrn"){delete this.notify[e.value];this.updateNotifyCount(false)}else if(e.key=="nrgn"){for(var s in this.notify){if(this.notify[s].tag==e.value)delete this.notify[s]}this.updateNotifyCount()}else if(e.key=="numc"){this.updateNotifyMailCount(e.value,false)}else if(e.key=="nuc"){this.updateNotifyCounters(e.value,false)}else if(e.key=="nunc"){setTimeout(BX.delegate(function(){this.unreadNotify=e.value.unread;this.flashNotify=e.value.flash;this.updateNotifyCount(false)},this),500)}else if(e.key=="nln"){this.loadNotify(false)}}})();(function(){if(BX.Messenger)return;BX.Messenger=function(e,t){this.BXIM=e;this.BXIM.messenger=this;this.settings={};this.params=t||{};this.realSearch=!this.BXIM.userExtranet||!this.BXIM.bitrixIntranet&&!this.BXIM.bitrix24net;this.realSearchFound=true;this.updateStateCount=1;this.sendAjaxTry=0;this.updateStateVeryFastCount=0;this.updateStateFastCount=0;this.updateStateStepDefault=this.BXIM.ppStatus?parseInt(t.updateStateInterval):60;this.updateStateStep=this.updateStateStepDefault;this.updateStateTimeout=null;this.redrawContactListTimeout={};this.redrawRecentListTimeout=null;this.floatDateTimeout=null;this.readMessageTimeout={};this.readMessageTimeoutSend=null;this.webrtc=t.webrtcClass;this.notify=t.notifyClass;this.desktop=t.desktopClass;this.bot=t.bot;this.command=t.command;this.commandPopup=null;this.commandListen=false;this.commandList=[];this.commandSelect="";this.commandSelectIndex=1;this.smile=t.smile;this.smileSet=t.smileSet;this.smileCurrentSet=this.BXIM.getLocalConfig("smiles-current-set",0)||[];this.smileRecentId=1;this.getRecentSmiles();this.recentListIndex=[];if(t.recent){this.recent=t.recent;this.recentListLoad=true}else{this.recent=[];this.recentListLoad=false}this.recentListExternal=null;if(t.externalRecentList){this.recentListExternal=BX(t.externalRecentList)}this.popupTooltip=null;this.users=t.users;this.businessUsers=t.businessUsers;this.openlines=t.openlines;this.groups=t.groups;this.userInGroup=t.userInGroup;this.woGroups=t.woGroups;this.woUserInGroup=t.woUserInGroup;this.currentTab=t.currentTab;this.generalChatId=t.generalChatId;this.canSendMessageGeneralChat=t.canSendMessageGeneralChat;this.redrawTab={};this.loadLastMessageTimeout={};this.showMessage=t.showMessage;this.unreadMessage=t.unreadMessage;this.flashMessage=t.flashMessage;this.disk=t.diskClass;this.disk.messenger=this;this.popupMessengerFileForm=null;this.popupMessengerFileDropZone=null;this.popupMessengerFileButton=null;this.popupMessengerFileFormChatId=null;this.popupMessengerFileFormInput=null;this.openChatEnable=t.openChatEnable;this.chat=t.chat;this.userChat=t.userChat;this.userInChat=t.userInChat;this.userChatBlockStatus=t.userChatBlockStatus;this.blockJoinChat={};this.hrphoto=t.hrphoto;this.chatPublicWatch=0;this.chatPublicWatchAdd=false;this.phones={};this.errorMessage={};this.message=t.message;this.messageTmpIndex=0;this.history=t.history;this.textareaHistory={};this.textareaHistoryTimeout=null;this.messageCount=t.countMessage;this.sendMessageFlag=0;this.sendMessageTmp={};this.sendMessageTmpTimeout={};this.popupSettings=null;this.popupSettingsBody=null;this.popupChatDialog=null;this.popupChatDialogContactListElements=null;this.popupChatDialogContactListSearch=null;this.popupChatDialogContactListElementsType="";this.popupChatDialogContactListSearchLastText="";this.popupChatDialogDestElements=null;this.popupChatDialogUsers={};this.popupChatDialogSendBlock=false;this.renameChatDialogFlag=false;this.renameChatDialogInput=null;this.popupKeyPad=null;this.popupHistory=null;this.popupHistoryElements=null;this.popupHistoryItems=null;this.popupHistoryItemsSize=475;this.popupHistorySearchDateWrap=null;this.popupHistorySearchWrap=null;this.popupHistoryFilesSearchWrap=null;this.popupHistoryButtonDeleteAll=null;this.popupHistoryButtonFilter=null;this.popupHistoryButtonFilterBox=null;this.popupHistoryFilterVisible=true;this.popupHistoryBodyWrap=null;this.popupHistoryFilesItems=null;this.popupHistoryFilesBodyWrap=null;this.popupHistorySearchInput=null;this.historyUserId=0;this.historyChatId=0;this.historyDateSearch="";this.historySearch="";this.historyLastSearch={};this.historySearchBegin=false;this.historySearchTimeout=null;this.historyFilesSearch="";this.historyFilesLastSearch={};this.historyFilesSearchBegin=false;this.historyFilesSearchTimeout=null;this.historyWindowBlock=false;this.historyMessageSplit="------------------------------------------------------";this.historyOpenPage={};this.historyLoadFlag={};this.historyEndOfList={};this.historyFilesOpenPage={};this.historyFilesLoadFlag={};this.historyFilesEndOfList={};this.popupMessenger=null;this.popupMessengerWindow={};this.popupMessengerExtra=null;this.popupMessengerTopLine=null;this.popupMessengerDesktopTimeout=null;this.popupMessengerFullWidth=864;this.popupMessengerMinWidth=864;this.popupMessengerFullHeight=454;this.popupMessengerMinHeight=384;this.popupMessengerDialog=null;this.popupMessengerBody=null;this.popupMessengerBodyDialog=null;this.popupMessengerBodyAnimation=null;this.popupMessengerBodySize=316;this.popupMessengerBodySizeMin=246;this.popupMessengerBodyWrap=null;this.popupMessengerLikeBlock={};this.popupMessengerLikeBlockTimeout={};this.popupMessengerConnectionStatusState="online";this.popupMessengerConnectionStatusStateText="online";this.popupMessengerConnectionStatus=null;this.popupMessengerConnectionStatusText=null;this.popupMessengerConnectionStatusTimeout=null;this.popupMessengerEditForm=null;this.popupMessengerEditFormTimeout=null;this.popupMessengerEditTextarea=null;this.popupMessengerEditMessageId=0;this.popupMessengerPanel=null;this.popupMessengerPanelAvatar=null;this.popupMessengerPanelButtonCall1=null;this.popupMessengerPanelButtonCall2=null;this.popupMessengerPanelButtonCall3=null;this.popupMessengerPanelTitle=null;this.popupMessengerPanelStatus=null;this.popupMessengerPanelChat=null;this.popupMessengerPanelCall=null;this.popupMessengerPanelChatTitle=null;this.popupMessengerPanelUsers=null;this.popupMessengerTextareaPlace=null;this.popupMessengerTextarea=null;this.popupMessengerTextareaSendType=null;this.popupMessengerTextareaResize={};this.popupMessengerTextareaSize=30;this.popupMessengerLastMessage=0;this.mentionList={};this.mentionListen=false;this.mentionDelimiter="";this.readedList={};this.writingList={};this.writingListTimeout={};this.writingSendList={};this.writingSendListTimeout={};this.contactListPanelStatus=null;this.contactListSearchText="";this.contactListSearchLastText="";this.popupPopupMenu=null;this.popupPopupMenuDateCreate=0;this.popupSmileMenu=null;this.popupSmileMenuGallery=null;this.popupSmileMenuSet=null;this.chatList=false;this.recentList=true;this.contactList=false;this.contactListShowed={};this.openMessengerFlag=false;this.openChatFlag=false;this.openNetworkFlag=false;this.openCallFlag=false;this.contactListLoad=false;this.popupContactListSize=254;this.popupContactListSearchInput=null;this.popupContactListSearchClose=null;this.popupContactListWrap=null;this.popupContactListElements=null;this.popupContactListElementsSize=this.BXIM.design=="DESKTOP"?368:334;this.popupContactListElementsSizeMin=this.BXIM.design=="DESKTOP"?298:264;this.popupContactListElementsWrap=null;this.contactListPanelSettings=null;this.linesTransferUser=0;this.enableGroupChat=this.BXIM.ppStatus?true:false;if(this.BXIM.init){if(this.desktop.run()){BX.desktop.setUserInfo(BX.MessengerCommon.getUserParam());BX.desktop.addTab({id:"im",title:BX.message("IM_DESKTOP_OPEN_MESSENGER").replace("#COUNTER#",""),order:100,events:{open:BX.delegate(function(){if(!this.BXIM.dialogOpen)this.openMessenger(this.currentTab)},this)}});if(this.webrtc.phoneSupport()){BX.desktop.addTab({id:"im-phone",title:BX.message("IM_PHONE_DESC"),order:120,target:"im",events:{open:BX.delegate(this.webrtc.openKeyPad,this.webrtc),close:BX.delegate(function(){if(this.webrtc.popupKeyPad)this.webrtc.popupKeyPad.close()},this)}})}}BX.addCustomEvent("onPullError",BX.delegate(function(e,t){if(e=="AUTHORIZE_ERROR"){if(this.desktop.ready()){this.connectionStatus("connecting")}else{this.connectionStatus("offline")}}else if(e=="RECONNECT"&&(t==1008||t==1006)){this.connectionStatus("connecting")}},this));BX.addCustomEvent("OnDesktopTabChange",BX.delegate(function(){this.closeMenuPopup()},this));BX.addCustomEvent("onImError",BX.delegate(function(e,t){if(e=="AUTHORIZE_ERROR"||e=="SEND_ERROR"&&t=="AUTHORIZE_ERROR"){if(this.desktop.ready()){this.connectionStatus("connecting")}else{this.connectionStatus("offline")}}},this));BX.addCustomEvent("onPullStatus",BX.delegate(function(e){this.connectionStatus(e=="offline"?"offline":"online")},this));BX.bind(window,"online",BX.delegate(function(){this.connectionStatus("online")},this));BX.bind(window,"offline",BX.delegate(function(){this.connectionStatus("offline")},this));this.notify.panel.appendChild(this.BXIM.audio.newMessage1=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/new-message-1.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/new-message-1.mp3",type:"audio/mpeg"}})]}));this.notify.panel.appendChild(this.BXIM.audio.newMessage2=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/new-message-2.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/new-message-2.mp3",type:"audio/mpeg"}})]}));this.notify.panel.appendChild(this.BXIM.audio.send=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/send.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/send.mp3",type:"audio/mpeg"}})]}));if(typeof this.BXIM.audio.send.play=="undefined"){this.BXIM.settings.enableSound=false}for(var s in this.unreadMessage){if(typeof this.flashMessage[s]=="undefined")this.flashMessage[s]={};for(var i=this.unreadMessage[s].length-1;i>=0;i--){BX.localStorage.set("mum",{userId:s,message:this.message[this.unreadMessage[s][i]]},5)}}BX.localStorage.set("muum",this.unreadMessage,5);BX.bind(this.notify.panelButtonMessage,"click",BX.delegate(function(){if(this.BXIM.messageCount<=0)this.BXIM.toggleMessenger();else this.BXIM.openMessenger()},this));var a=this.BXIM.getLocalConfig("global_msz_v2",false);if(a&&(!this.desktop.run()||this.desktop.ready())){this.popupMessengerFullWidth=parseInt(a.wz);this.popupMessengerTextareaSize=parseInt(a.ta2);this.popupMessengerBodySize=parseInt(a.b)>0?parseInt(a.b):this.popupMessengerBodySize;this.popupHistoryItemsSize=parseInt(a.hi);this.popupMessengerFullHeight=parseInt(a.fz);this.popupContactListElementsSize=parseInt(a.ez);this.notify.popupNotifySize=parseInt(a.nz);this.popupHistoryFilterVisible=a.hf;if(this.desktop.ready()){BX.desktop.setWindowSize({Width:parseInt(a.dw),Height:parseInt(a.dh)});this.desktop.initHeight=parseInt(a.dh)}}else{if(this.desktop.ready()){BX.desktop.setWindowSize({Width:BX.desktop.initWidth,Height:BX.desktop.initHeight});this.desktop.initHeight=BX.desktop.initHeight}else if(this.desktop.run()){this.desktop.initHeight=BX.desktop.initHeight}}if(this.desktop.run()){this.desktop.adjustSize();BX.MessengerCommon.redrawDateMarks();BX.bind(window,"resize",BX.delegate(function(){this.adjustSize();BX.MessengerCommon.redrawDateMarks()},this.desktop))}if(BX.browser.SupportLocalStorage()){var n=BX.localStorage.get("mcr2");if(n){for(var s in n.users)this.users[s]=n.users[s];for(var s in n.hrphoto)this.hrphoto[s]=n.hrphoto[s];for(var s in n.chat)this.chat[s]=n.chat[s];for(var s in n.userInChat)this.userInChat[s]=n.userInChat[s];this.callInit=true;setTimeout(BX.delegate(function(){this.webrtc.callNotifyWait(n.callChatId,n.callUserId,n.callVideo,n.callToGroup)},this),500)}BX.addCustomEvent(window,"onLocalStorageSet",BX.delegate(this.storageSet,this));this.textareaHistory=BX.localStorage.get("mtah")||{};this.mentionList=BX.localStorage.get("mtam")||{};this.currentTab=this.currentTab||BX.localStorage.get("mct");this.messageTmpIndex=BX.localStorage.get("mti")||0;var r=BX.localStorage.get("mfm");if(r){for(var s in this.flashMessage)for(var o in this.flashMessage[s])if(r[s]&&this.flashMessage[s][o]!=r[s][o]&&r[s][o]==false)this.flashMessage[s][o]=false}BX.garbage(function(){BX.localStorage.set("mti",this.messageTmpIndex,15);BX.localStorage.set("mtah",this.textareaHistory,15);BX.localStorage.set("mtam",this.mentionList,15);BX.localStorage.set("mct",this.currentTab,15);BX.localStorage.set("mfm",this.flashMessage,15);BX.localStorage.set("mcls",this.contactListSearchText+"",15);if(this.desktop.ready()&&(window.innerWidth<BX.desktop.minWidth||window.innerHeight<BX.desktop.minHeight))return false;this.BXIM.setLocalConfig("global_msz_v2",{wz:this.popupMessengerFullWidth,ta2:this.popupMessengerTextareaSize,b:this.popupMessengerBodySize,cl:this.popupContactListSize,hi:this.popupHistoryItemsSize,fz:this.popupMessengerFullHeight,ez:this.popupContactListElementsSize,nz:this.notify.popupNotifySize,hf:this.popupHistoryFilterVisible,dw:window.innerWidth,dh:window.innerHeight,place:"garbage"})},this)}else{var l=this.BXIM.getLocalConfig("mtah",false);if(l){this.textareaHistory=l;this.BXIM.removeLocalConfig("mtah")}var p=this.BXIM.getLocalConfig("mtam",false);if(p){this.textareaHistory=p;this.BXIM.removeLocalConfig("mtam")}var h=this.BXIM.getLocalConfig("mct",false);if(h){this.currentTab=h;this.BXIM.removeLocalConfig("mct")}BX.garbage(function(){this.BXIM.setLocalConfig("mct",this.currentTab);this.BXIM.setLocalConfig("mtah",this.textareaHistory);this.BXIM.setLocalConfig("mtam",this.mentionList);if(this.desktop.ready()&&(window.innerWidth<BX.desktop.minWidth||window.innerHeight<BX.desktop.minHeight))return false;this.BXIM.setLocalConfig("global_msz_v2",{wz:this.popupMessengerFullWidth,ta2:this.popupMessengerTextareaSize,b:this.popupMessengerBodySize,cl:this.popupContactListSize,hi:this.popupHistoryItemsSize,fz:this.popupMessengerFullHeight,ez:this.popupContactListElementsSize,nz:this.notify.popupNotifySize,hf:this.popupHistoryFilterVisible,dw:window.innerWidth,dh:window.innerHeight,place:"garbage"})},this)}BX.MessengerCommon.pullEvent();BX.addCustomEvent("onPullError",BX.delegate(function(e){if(e=="AUTHORIZE_ERROR")this.sendAjaxTry++},this));var s=0;for(var c in this.users){if(this.users[c].birthday&&c!=this.BXIM.userId){this.message[c+"birthday"]={id:c+"birthday",senderId:0,recipientId:c,date:BX.MessengerCommon.getNowDate(true),text:BX.message("IM_M_BIRTHDAY_MESSAGE").replace("#USER_NAME#",'<img src="/bitrix/js/im/images/blank.gif" class="bx-messenger-birthday-icon"><strong>'+this.users[c].name+"</strong>")};if(!this.showMessage[c])this.showMessage[c]=[];this.showMessage[c].push(c+"birthday");this.showMessage[c].sort(BX.delegate(function(e,t){if(!this.message[e]||!this.message[t]){return 0}var s=parseInt(this.message[e].date);var i=parseInt(this.message[t].date);if(s<i){return-1}else if(s>i){return 1}else{if(e<t){return-1}else if(e>t){return 1}else{return 0}}},this));var u=this.showMessage[c][this.showMessage[c].length-1];BX.MessengerCommon.recentListAdd({userId:c,id:this.message[u].id,date:parseInt(this.message[u].date)-parseInt(BX.message("USER_TZ_OFFSET"))+s,recipientId:this.message[u].recipientId,senderId:this.message[u].senderId,text:u==c+"birthday"?BX.message("IM_M_BIRTHDAY_MESSAGE_SHORT").replace("#USER_NAME#",this.users[c].name):this.message[u].text,params:{}},true);this.recent.sort(BX.delegate(function(e,t){if(!this.message[e.id]||!this.message[t.id]){return 0}var s=parseInt(this.message[e.id].date);var i=parseInt(this.message[t.id].date);if(s>i){return-1}else if(s<i){return 1}else{if(e>t){return-1}else if(e<t){return 1}else{return 0}}},this));var d=this.BXIM.getLocalConfig("birthdayPopup"+(new Date).getFullYear(),{});if(this.desktop.birthdayStatus()&&!d[c]){this.message[c+"birthdayPopup"]={id:c+"birthdayPopup",senderId:0,recipientId:c,date:BX.MessengerCommon.getNowDate(true),text:BX.message("IM_M_BIRTHDAY_MESSAGE_SHORT").replace("#USER_NAME#",this.users[c].name)};if(this.desktop.ready()){if(!this.unreadMessage[c])this.unreadMessage[c]=[];this.unreadMessage[c].push(c+"birthdayPopup");if(!this.flashMessage[c])this.flashMessage[c]={};this.flashMessage[c][c+"birthdayPopup"]=true}d[c]=true;this.BXIM.removeLocalConfig("birthdayPopup"+((new Date).getFullYear()-1));this.BXIM.setLocalConfig("birthdayPopup"+(new Date).getFullYear(),d)}}s++}this.updateState();if(t.openMessenger!==false)this.openMessenger(t.openMessenger);else if(this.openMessengerFlag)this.openMessenger(this.currentTab);if(t.openHistory!==false)this.openHistory(t.openHistory);if(t.openNotify!==false)this.BXIM.openNotify();if(this.BXIM.settings.status!="dnd")this.newMessage();this.updateMessageCount()}else{if(t.openMessenger!==false)this.BXIM.openMessenger(t.openMessenger);if(t.openHistory!==false)this.BXIM.openHistory(t.openHistory)}};BX.Messenger.prototype.openMessenger=function(e){if(this.BXIM.errorMessage!=""){this.BXIM.openConfirm(this.BXIM.errorMessage);return false}if(this.BXIM.popupSettings!=null&&!this.desktop.run())this.BXIM.popupSettings.close();if(this.popupMessenger!=null&&this.dialogOpen&&this.currentTab==e&&e!=0)return false;if(this.popupMessengerEditForm)this.editMessageCancel();if(e&&e.toString().toLowerCase()=="general"){this.currentTab="chat"+this.generalChatId;e=this.currentTab}BX.localStorage.set("mcam",true,5);if(typeof e=="undefined"||e==null){e=0}if(this.currentTab==null)this.currentTab=0;this.openChatFlag=false;this.openNetworkFlag=false;this.openLinesFlag=false;this.openCallFlag=false;var t=false;if(typeof e=="boolean"){e=0}else if(e==0){t=true;for(var s in this.unreadMessage){e=s;t=false;break}if(e==0&&this.currentTab!=null){if(this.users[this.currentTab]&&this.users[this.currentTab].id)e=this.currentTab;else if(this.chat[this.currentTab.toString().substr(4)]&&this.chat[this.currentTab.toString().substr(4)].id)e=this.currentTab}if(e.toString().substr(0,4)=="chat"){BX.MessengerCommon.getUserParam(e);this.openChatFlag=true;if(this.chat[e.toString().substr(4)].type=="call")this.openCallFlag=true;else if(this.chat[e.toString().substr(4)].type=="lines")this.openLinesFlag=true}else{e=parseInt(e)}}else if(e.toString().substr(0,4)=="chat"){BX.MessengerCommon.getUserParam(e);this.openChatFlag=true;if(this.chat[e.toString().substr(4)].type=="call")this.openCallFlag=true;else if(this.chat[e.toString().substr(4)].type=="lines")this.openLinesFlag=true}else if(e.toString().substr(0,7)=="network"){BX.MessengerCommon.getUserParam(e);this.openNetworkFlag=true}else if(this.users[e]&&this.users[e].id){e=parseInt(e)}else{e=parseInt(e);if(isNaN(e)){e=0}else{BX.MessengerCommon.getUserParam(e)}}if(this.openNetworkFlag){}else if(!this.openChatFlag&&typeof e!="number"){e=0}if(this.openChatFlag||e>0){this.currentTab=e;this.BXIM.notifyManager.closeByTag("im-message-"+e);BX.localStorage.set("mct",this.currentTab,15)}if(this.desktop.run()&&BX.desktop.currentTab!="im"){BX.desktop.changeTab("im")}if(this.popupMessenger!=null){BX.MessengerCommon.openDialog(e,this.BXIM.dialogOpen?false:true);if(!(BX.browser.IsAndroid()||BX.browser.IsIOS()||window!=window.top)){if(t&&this.popupContactListSearchInput!=null)this.popupContactListSearchInput.focus();else if(this.popupMessengerTextarea)this.popupMessengerTextarea.focus()}return false}var i={width:this.popupMessengerFullWidth+"px"};if(this.desktop.run()){i={};if(!BX.desktop.contentFullWindow){var a=BX.desktop.content.offsetHeight-this.popupMessengerFullHeight;this.popupContactListElementsSize=this.popupContactListElementsSize+a;this.popupMessengerBodySize=this.popupMessengerBodySize+a;this.popupMessengerFullHeight=this.popupMessengerFullHeight+a;this.notify.popupNotifySize=this.notify.popupNotifySize+a}}this.popupMessengerContent=BX.create("div",{props:{className:"bx-messenger-box bx-messenger-mark bx-messenger-global-context-"+this.BXIM.context.toLowerCase()+" "+(this.webrtc.callInit?" bx-messenger-call"+(this.callOverlayMinimize?"":" bx-messenger-call-maxi"):"")+(this.desktop.run()?" bx-messenger-box-desktop":"")+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},style:i,children:[this.popupContactListWrap=BX.create("div",{props:{className:"bx-messenger-box-contact bx-messenger-box-contact-normal"},style:{width:this.popupContactListSize+"px"},children:[BX.create("div",{props:{className:"bx-messenger-cl-search"},children:[this.popupContactListCreateChat=BX.create("span",{props:{className:"bx-messenger-input-search-create"}}),BX.create("div",{props:{className:"bx-messenger-input-wrap bx-messenger-cl-search-wrap"},children:[this.popupContactListSearchClose=BX.create("a",{attrs:{href:"#close"},props:{className:"bx-messenger-input-close"}}),this.popupContactListSearchInput=BX.create("input",{attrs:{type:"text",placeholder:BX.message("IM_M_SEARCH"),value:this.contactListSearchText},props:{className:"bx-messenger-input"}})]})]}),this.popupContactListElements=BX.create("div",{props:{className:"bx-messenger-cl"},style:{height:this.popupContactListElementsSize+"px"},children:[this.popupContactListElementsWrap=BX.create("div",{props:{className:"bx-messenger-cl-wrap bx-messenger-recent-wrap"}})]}),this.BXIM.design=="DESKTOP"?null:BX.create("div",{props:{className:"bx-messenger-cl-notify-wrap"},children:[this.notify.messengerNotifyButton=BX.create("div",{props:{className:"bx-messenger-cl-notify-button"},events:{click:BX.delegate(this.notify.openNotify,this.notify)},children:[BX.create("span",{props:{className:"bx-messenger-cl-notify-text"},html:BX.message("IM_NOTIFY_BUTTON_TITLE")}),this.notify.messengerNotifyButtonCount=BX.create("span",{props:{className:"bx-messenger-cl-count"},html:parseInt(this.notify.notifyCount)>0?'<span class="bx-messenger-cl-count-digit">'+this.notify.notifyCount+"</span>":""})]}),this.popupContactListSearchCall=!this.webrtc.phoneSupport()?null:BX.create("div",{props:{className:"bx-messenger-cl-phone-button"},children:[BX.create("span",{props:{className:"bx-messenger-cl-phone-text"},html:BX.message("IM_PHONE_BUTTON_TITLE")})]})]}),BX.create("div",{props:{className:"bx-messenger-cl-panel"},children:[BX.create("div",{props:{className:"bx-messenger-cl-panel-wrap"},children:[this.contactListPanelStatus=BX.create("span",{props:{className:"bx-messenger-cl-panel-status-wrap bx-messenger-cl-panel-status-"+BX.MessengerCommon.getUserStatus()},html:'<span class="bx-messenger-cl-panel-status"></span><span class="bx-messenger-cl-panel-status-text">'+BX.message("IM_STATUS_"+BX.MessengerCommon.getUserStatus().toUpperCase())+'</span><span class="bx-messenger-cl-panel-status-arrow"></span>'}),BX.create("span",{props:{className:"bx-messenger-cl-panel-right-wrap"},children:[this.contactListPanelSettings=this.BXIM.design=="DESKTOP"?null:BX.create("span",{props:{title:BX.message("IM_SETTINGS"),className:"bx-messenger-cl-panel-settings-wrap"}})]})]})]})]}),this.popupMessengerDialog=BX.create("div",{props:{className:"bx-messenger-box-dialog"},style:{marginLeft:this.popupContactListSize+"px"},children:[this.popupMessengerPanel=BX.create("div",{props:{className:"bx-messenger-panel bx-messenger-context-user "+(this.openChatFlag?" bx-messenger-hide":"")},children:[BX.create("a",{attrs:{href:this.users[this.currentTab]?this.users[this.currentTab].profile:BX.MessengerCommon.getUserParam().profile},props:{className:"bx-messenger-panel-avatar bx-messenger-panel-avatar-status-"+BX.MessengerCommon.getUserStatus(this.users[this.currentTab]?this.currentTab:"")},children:[this.popupMessengerPanelAvatar=BX.create("img",{attrs:{src:this.BXIM.pathToBlankImage},props:{className:"bx-messenger-panel-avatar-img bx-messenger-panel-avatar-img-default"}}),BX.create("span",{props:{className:"bx-messenger-panel-avatar-status"}})],events:{mouseover:BX.delegate(function(e){if(this.users[this.currentTab]){BX.proxy_context.title=BX.MessengerCommon.getUserStatus(this.currentTab,true)}},this)}}),BX.create("a",{attrs:{href:"#history",title:BX.message("IM_M_OPEN_HISTORY_2")},props:{className:"bx-messenger-panel-button bx-messenger-panel-history"},events:{click:BX.delegate(function(e){this.openHistory(this.currentTab);BX.PreventDefault(e)},this)}}),this.popupMessengerPanelMute=BX.create("a",{attrs:{href:"#block",title:this.muteButtonStatus(this.currentTab)?BX.message("IM_M_USER_BLOCK_ON"):BX.message("IM_M_USER_BLOCK_OFF")},props:{className:"bx-messenger-panel-button bx-messenger-panel-mute"},events:{click:BX.delegate(function(e){BX.MessengerCommon.muteMessageChat(this.currentTab);BX.PreventDefault(e)},this)}}),this.enableGroupChat?BX.create("a",{attrs:{href:"#chat",title:BX.message("IM_M_CHAT_TITLE")},props:{className:"bx-messenger-panel-button bx-messenger-panel-chat"},html:BX.message("IM_M_CHAT_BTN_JOIN"),events:{click:BX.delegate(function(e){this.openChatDialog({type:"CHAT_ADD",bind:BX.proxy_context});BX.PreventDefault(e)},this)}}):null,this.popupMessengerPanelButtonCall1=this.callButton(),BX.create("span",{props:{className:"bx-messenger-panel-title"},children:[this.popupMessengerPanelTitle=BX.create("a",{props:{className:"bx-messenger-panel-title-link"+(this.users[this.currentTab]&&this.users[this.currentTab].extranet?" bx-messenger-user-extranet":this.users[this.currentTab]&&this.users[this.currentTab].bot?this.bot[this.currentTab]&&this.bot[this.currentTab].type=="network"?" bx-messenger-user-network":" bx-messenger-user-bot":"")},attrs:{href:this.users[this.currentTab]?this.users[this.currentTab].profile:BX.MessengerCommon.getUserParam().profile},html:this.users[this.currentTab]?this.users[this.currentTab].name:""})]}),this.popupMessengerPanelStatus=BX.create("span",{props:{className:"bx-messenger-panel-desc"},html:BX.MessengerCommon.getUserPosition(this.currentTab)})]}),this.popupMessengerPanelChat=BX.create("div",{props:{className:"bx-messenger-panel bx-messenger-context-chat "+(this.openChatFlag&&!this.openCallFlag?"":" bx-messenger-hide")},children:[this.popupMessengerPanelAvatarForm2=BX.create("form",{attrs:{action:this.BXIM.pathToFileAjax},props:{className:"bx-messenger-panel-avatar bx-messenger-panel-avatar-chat"},children:[BX.create("div",{props:{className:"bx-messenger-panel-avatar-progress"},html:'<div class="bx-messenger-panel-avatar-progress-image"></div>'}),BX.create("input",{attrs:{type:"hidden",name:"IM_AVATAR_UPDATE",value:"Y"}}),this.popupMessengerPanelAvatarId2=BX.create("input",{attrs:{type:"hidden",name:"CHAT_ID",value:this.currentTab.toString().substr(4)
}}),BX.create("input",{attrs:{type:"hidden",name:"IM_AJAX_CALL",value:"Y"}}),this.popupMessengerPanelAvatarUpload2=this.disk.lightVersion||!this.BXIM.ppServerStatus?null:BX.create("input",{attrs:{type:"file",title:BX.message("IM_M_AVATAR_UPLOAD")},props:{className:"bx-messenger-panel-avatar-upload"}}),this.popupMessengerPanelAvatar2=BX.create("img",{attrs:{src:this.BXIM.pathToBlankImage},props:{className:"bx-messenger-panel-avatar-img bx-messenger-panel-avatar-img-default"}}),this.popupMessengerPanelCrm=BX.create("span",{props:{className:"bx-messenger-panel-avatar-crm"}}),this.popupMessengerPanelStatus2=BX.create("span",{props:{className:"bx-messenger-panel-avatar-status"}})]}),this.popupOpenLinesMenu=BX.create("span",{attrs:{title:BX.message("IM_P_MENU")},props:{className:"bx-messenger-panel-button bx-messenger-panel-menu"},events:{click:BX.delegate(function(e){this.openPopupMenu(BX.proxy_context,"openLinesMenu");BX.PreventDefault(e)},this)}}),BX.create("a",{attrs:{href:"#history",title:BX.message("IM_M_OPEN_HISTORY_2")},props:{className:"bx-messenger-panel-button bx-messenger-panel-history"},events:{click:BX.delegate(function(e){this.openHistory(this.currentTab);BX.PreventDefault(e)},this)}}),this.popupMessengerPanelMute2=BX.create("a",{attrs:{href:"#mute",title:this.muteButtonStatus(this.currentTab)?BX.message("IM_M_CHAT_MUTE_ON_2"):BX.message("IM_M_CHAT_MUTE_OFF_2")},props:{className:"bx-messenger-panel-button bx-messenger-panel-mute "+(this.muteButtonStatus(this.currentTab)?" bx-messenger-panel-unmute":"")},events:{click:BX.delegate(function(e){BX.MessengerCommon.muteMessageChat(this.currentTab);BX.PreventDefault(e)},this)}}),this.popupOpenLinesTransfer=BX.create("span",{attrs:{title:BX.message("IM_P_TRANSFER")},props:{className:"bx-messenger-panel-button bx-messenger-panel-transfer"},events:{click:BX.delegate(function(e){this.linesOpenTransferDialog({bind:BX.proxy_context});BX.PreventDefault(e)},this)}}),this.enableGroupChat?BX.create("a",{attrs:{href:"#chat",title:BX.message("IM_M_CHAT_TITLE")},props:{className:"bx-messenger-panel-button bx-messenger-panel-chat"},html:BX.message("IM_M_CHAT_BTN_JOIN"),events:{click:BX.delegate(function(e){this.openChatDialog({chatId:this.currentTab.toString().substr(4),type:"CHAT_EXTEND",bind:BX.proxy_context});BX.PreventDefault(e)},this)}}):null,this.popupMessengerPanelButtonCall2=this.callButton(),BX.create("span",{props:{className:"bx-messenger-panel-title bx-messenger-panel-title-chat"},children:[this.popupMessengerPanelChatTitle=BX.create("span",{props:{className:""},html:this.chat[this.currentTab.toString().substr(4)]?this.chat[this.currentTab.toString().substr(4)].name:BX.message("IM_CL_LOAD")})]}),BX.create("span",{props:{className:"bx-messenger-panel-desc"},children:[this.popupMessengerPanelUsers=BX.create("div",{props:{className:"bx-messenger-panel-chat-users"},html:BX.message("IM_CL_LOAD")})]})]}),this.popupMessengerPanelCall=BX.create("div",{props:{className:"bx-messenger-panel bx-messenger-context-call "+(this.openChatFlag&&this.openCallFlag?"":" bx-messenger-hide")},children:[this.popupMessengerPanelAvatarForm3=BX.create("form",{attrs:{action:this.BXIM.pathToFileAjax},props:{className:"bx-messenger-panel-avatar bx-messenger-panel-avatar-call"},children:[BX.create("div",{props:{className:"bx-messenger-panel-avatar-progress"},html:'<div class="bx-messenger-panel-avatar-progress-image"></div>'}),BX.create("input",{attrs:{type:"hidden",name:"IM_AVATAR_UPDATE",value:"Y"}}),this.popupMessengerPanelAvatarId3=BX.create("input",{attrs:{type:"hidden",name:"CHAT_ID",value:this.currentTab.toString().substr(4)}}),BX.create("input",{attrs:{type:"hidden",name:"IM_AJAX_CALL",value:"Y"}}),this.popupMessengerPanelAvatarUpload3=this.disk.lightVersion||!this.BXIM.ppServerStatus?null:BX.create("input",{attrs:{type:"file",title:BX.message("IM_M_AVATAR_UPLOAD_2")},props:{className:"bx-messenger-panel-avatar-upload"}}),this.popupMessengerPanelAvatar3=BX.create("img",{attrs:{src:this.BXIM.pathToBlankImage},props:{className:"bx-messenger-panel-avatar-img bx-messenger-panel-avatar-img-default"}}),this.popupMessengerPanelStatus3=BX.create("span",{props:{className:"bx-messenger-panel-avatar-status bx-messenger-panel-avatar-status-chat"}})]}),BX.create("a",{attrs:{href:"#history",title:BX.message("IM_M_OPEN_HISTORY_2")},props:{className:"bx-messenger-panel-button bx-messenger-panel-history"},events:{click:BX.delegate(function(e){this.openHistory(this.currentTab);BX.PreventDefault(e)},this)}}),this.popupMessengerPanelMute3=BX.create("a",{attrs:{href:"#mute",title:this.muteButtonStatus(this.currentTab)?BX.message("IM_M_CHAT_MUTE_ON_2"):BX.message("IM_M_CHAT_MUTE_OFF_2")},props:{className:"bx-messenger-panel-button bx-messenger-panel-mute "+(this.muteButtonStatus(this.currentTab)?" bx-messenger-panel-unmute":"")},events:{click:BX.delegate(function(e){BX.MessengerCommon.muteMessageChat(this.currentTab);BX.PreventDefault(e)},this)}}),this.popupMessengerPanelButtonCall3=this.callButton("call"),this.popupMessengerPanelCallTitle=BX.create("span",{props:{className:"bx-messenger-panel-title"},html:this.chat[this.currentTab.toString().substr(4)]?this.chat[this.currentTab.toString().substr(4)].name:BX.message("IM_CL_LOAD")}),BX.create("span",{props:{className:"bx-messenger-panel-desc"},html:BX.message("IM_PHONE_DESC")})]}),this.popupMessengerConnectionStatus=BX.create("div",{props:{className:"bx-messenger-connection-status "+(this.popupMessengerConnectionStatusState=="online"?"bx-messenger-connection-status-hide":"bx-messenger-connection-status-show bx-messenger-connection-status-"+this.popupMessengerConnectionStatusState)},children:[BX.create("div",{props:{className:"bx-messenger-connection-status-wrap"},children:[this.popupMessengerConnectionStatusText=BX.create("span",{props:{className:"bx-messenger-connection-status-text"},html:this.popupMessengerConnectionStatusStateText}),BX.create("span",{props:{className:"bx-messenger-connection-status-text-reload"},children:[BX.create("span",{props:{className:"bx-messenger-connection-status-text-reload-title"},html:BX.message("IM_CS_RELOAD")}),BX.create("span",{props:{className:"bx-messenger-connection-status-text-reload-hotkey"},html:BX.browser.IsMac()?"⌘+R":"Ctrl+R"})],events:{click:function(){location.reload()}}})]})]}),this.popupMessengerEditForm=BX.create("div",{props:{className:"bx-messenger-editform bx-messenger-editform-disable"},children:[BX.create("div",{props:{className:"bx-messenger-editform-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-editform-textarea"},children:[this.popupMessengerEditTextarea=BX.create("textarea",{props:{value:"",className:"bx-messenger-editform-textarea-input"},style:{height:"70px"}})]}),BX.create("div",{props:{className:"bx-messenger-editform-buttons"},children:[BX.create("span",{props:{className:"popup-window-button popup-window-button-accept"},children:[BX.create("span",{props:{className:"popup-window-button-left"}}),BX.create("span",{props:{className:"popup-window-button-text"},html:BX.message("IM_M_CHAT_BTN_EDIT")}),BX.create("span",{props:{className:"popup-window-button-right"}})],events:{click:BX.delegate(function(e){BX.MessengerCommon.editMessageAjax(this.popupMessengerEditMessageId,this.popupMessengerEditTextarea.value)},this)}}),BX.create("span",{props:{className:"popup-window-button"},children:[BX.create("span",{props:{className:"popup-window-button-left"}}),BX.create("span",{props:{className:"popup-window-button-text"},html:BX.message("IM_M_CHAT_BTN_CANCEL")}),BX.create("span",{props:{className:"popup-window-button-right"}})],events:{click:BX.delegate(function(e){this.editMessageCancel()},this)}}),BX.create("span",{props:{className:"bx-messenger-editform-progress"},html:BX.message("IM_MESSAGE_EDIT_TEXT")})]})]})]}),this.popupMessengerBodyDialog=BX.create("div",{props:{className:"bx-messenger-body-dialog bxu-file-input-over"},children:[this.popupMessengerFileDropZone=!this.disk.enable?null:BX.create("div",{props:{className:"bx-messenger-file-dropzone"},children:[BX.create("div",{props:{className:"bx-messenger-file-dropzone-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-file-dropzone-icon"}}),BX.create("div",{props:{className:"bx-messenger-file-dropzone-text"},html:BX.message("IM_F_DND_TEXT")})]})]}),this.popupMessengerBody=BX.create("div",{props:{className:"bx-messenger-body"},style:{height:this.popupMessengerBodySize+"px"},children:[this.popupMessengerBodyWrap=BX.create("div",{props:{className:"bx-messenger-body-wrap"}})]}),this.popupMessengerTextareaPlace=BX.create("div",{props:{className:"bx-messenger-textarea-place"},children:[BX.create("div",{props:{className:"bx-messenger-textarea-open-lines"},children:[BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text-box"},children:[BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text-box-element"},children:[this.popupMessengerTextareaOpenLinesText=BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text"},html:BX.message("IM_OL_INVITE_TEXT")})]})]}),BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-join-box"},children:[this.popupMessengerTextareaOpenLinesAnswer=BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-answer bx-notifier-item-button bx-notifier-item-button-confirm bx-notifier-item-button-accept"},html:BX.message("IM_OL_INVITE_ANSWER")}),this.popupMessengerTextareaOpenLinesSkip=BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-skip bx-notifier-item-button bx-notifier-item-button-confirm bx-notifier-item-button-cancel"},html:BX.message("IM_OL_INVITE_SKIP")}),BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-transfer bx-notifier-item-button bx-notifier-item-button-confirm bx-notifier-item-button-transfer"},html:BX.message("IM_OL_INVITE_TRANSFER"),events:{click:BX.delegate(function(e){this.linesOpenTransferDialog({bind:BX.proxy_context});BX.PreventDefault(e)},this)}})]})]}),BX.create("div",{props:{className:"bx-messenger-textarea-open-invite"},children:[BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text-box"},children:[BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text-box-element"},children:[this.popupMessengerTextareaOpenText=BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text"},html:BX.message(this.BXIM.bitrixIntranet?"IM_O_INVITE_TEXT":"IM_O_INVITE_TEXT_SITE")})]})]}),this.popupMessengerTextareaOpenJoin=BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-join bx-notifier-item-button bx-notifier-item-button-confirm bx-notifier-item-button-accept"},html:BX.message("IM_O_INVITE_JOIN")})]}),BX.create("div",{props:{className:"bx-messenger-textarea-general-invite"},children:[BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text-box"},children:[BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text-box-element"},children:[this.popupMessengerTextareaGeneralText=BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-text"}})]})]}),this.popupMessengerTextareaGeneralJoin=BX.create("div",{props:{className:"bx-messenger-textarea-open-invite-join bx-notifier-item-button bx-notifier-item-button-confirm bx-notifier-item-button-accept"},html:BX.message("IM_G_JOIN_"+this.BXIM.userGender)})]}),BX.create("div",{props:{className:"bx-messenger-textarea-resize"},events:{mousedown:BX.delegate(this.resizeTextareaStart,this)}}),BX.create("div",{props:{className:"bx-messenger-textarea-send"},children:[BX.create("a",{attrs:{href:"#send"},props:{className:"bx-messenger-textarea-send-button"},events:{click:BX.delegate(this.sendMessage,this)}}),this.popupMessengerTextareaSendType=BX.create("span",{attrs:{title:BX.message("IM_M_SEND_TYPE_TITLE")},props:{className:"bx-messenger-textarea-cntr-enter"},html:this.BXIM.settings.sendByEnter?"Enter":BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter",events:{click:BX.delegate(function(){this.BXIM.settings.sendByEnter=this.BXIM.settings.sendByEnter?false:true;this.BXIM.saveSettings({sendByEnter:this.BXIM.settings.sendByEnter});BX.proxy_context.innerHTML=this.BXIM.settings.sendByEnter?"Enter":BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter"},this)}})]}),this.popupMessengerHiddenModeButton=BX.create("div",{attrs:{title:BX.message("IM_HIDDEN_MODE_MENU")},props:{className:"bx-messenger-textarea-hidden"},events:{click:BX.delegate(function(e){this.linesToggleSilentMode();return BX.PreventDefault(e)},this)}}),this.BXIM.context=="LINES"?null:BX.create("div",{attrs:{title:BX.message("IM_ANSWERS_MENU")},props:{className:"bx-messenger-textarea-answers"},events:{click:BX.delegate(function(e){this.openAnswersMenu();return BX.PreventDefault(e)},this)}}),this.BXIM.context=="LINES"?null:BX.create("div",{attrs:{title:BX.message("IM_FORMS_MENU")},props:{className:"bx-messenger-textarea-forms"},events:{click:BX.delegate(function(e){this.openFormsMenu();return BX.PreventDefault(e)},this)}}),this.popupMessengerSmileButton=BX.create("div",{attrs:{title:BX.message("IM_SMILE_MENU")},props:{className:"bx-messenger-textarea-smile"},events:{click:BX.delegate(function(e){this.openSmileMenu();return BX.PreventDefault(e)},this)}}),this.BXIM.context=="LINES"?null:BX.create("div",{attrs:{title:BX.message("IM_COMMAND_MENU")},props:{className:"bx-messenger-textarea-command"},events:{click:BX.delegate(function(e){this.openCommandDialog();return BX.PreventDefault(e)},this)}}),this.BXIM.context=="LINES"?null:BX.create("div",{attrs:{title:BX.message("IM_MENTION_MENU")},props:{className:"bx-messenger-textarea-mention"},events:{click:BX.delegate(function(e){this.openMentionDialog({delay:0});return BX.PreventDefault(e)},this)}}),this.popupMessengerFileButton=!this.disk.enable?null:BX.create("div",{attrs:{title:BX.message("IM_F_UPLOAD_MENU")},props:{className:"bx-messenger-textarea-file"+(this.disk.lightVersion?" bx-messenger-textarea-file-light":"")},children:[BX.create("div",{attrs:{title:this.BXIM.ieVersion>1?BX.message("IM_F_UPLOAD_MENU"):" "},props:{className:"bx-messenger-textarea-file-popup"+(this.BXIM.context=="LINES"?" bx-messenger-textarea-file-popup-short":"")},children:[this.popupMessengerFileForm=BX.create("form",{attrs:{action:this.BXIM.pathToFileAjax,style:this.disk.lightVersion?"z-index: 0":""},props:{className:"bx-messenger-textarea-file-form"},children:[BX.create("input",{attrs:{type:"hidden",name:"IM_FILE_UPLOAD",value:"Y"}}),this.popupMessengerFileFormChatId=BX.create("input",{attrs:{type:"hidden",name:"CHAT_ID",value:0}}),this.popupMessengerFileFormRegChatId=BX.create("input",{attrs:{type:"hidden",name:"REG_CHAT_ID",value:0}}),this.popupMessengerFileFormRegMessageId=BX.create("input",{attrs:{type:"hidden",name:"REG_MESSAGE_ID",value:0}}),this.popupMessengerFileFormRegParams=BX.create("input",{attrs:{type:"hidden",name:"REG_PARAMS",value:""}}),BX.create("input",{attrs:{type:"hidden",name:"IM_AJAX_CALL",value:"Y"}}),this.popupMessengerFileFormInput=BX.create("input",{attrs:{type:"file",multiple:"true",title:this.BXIM.ieVersion>1?BX.message("IM_F_UPLOAD_MENU"):" "},props:{className:"bx-messenger-textarea-file-popup-input"}})]}),this.disk.lightVersion?null:BX.create("div",{props:{className:"bx-messenger-popup-menu-item"},html:BX.message("IM_F_UPLOAD_MENU_1")}),this.disk.lightVersion||this.BXIM.context=="LINES"?null:BX.create("div",{props:{className:"bx-messenger-menu-hr"}}),this.BXIM.context=="LINES"?null:BX.create("div",{props:{className:"bx-messenger-popup-menu-item"},html:BX.message("IM_F_UPLOAD_MENU_2"),events:{click:BX.delegate(function(){this.disk.openFileDialog()},this)}}),BX.create("div",{props:{className:"bx-messenger-textarea-file-popup-arrow"}})]})],events:{click:BX.delegate(function(e){if(this.popupMessengerConnectionStatusState!="online")return false;if(BX.hasClass(this.popupMessengerFileButton,"bx-messenger-textarea-file-active")){setTimeout(BX.delegate(function(){this.closePopupFileMenu()},this),100)}else{if(parseInt(this.popupMessengerFileFormChatId.value)<=0||this.popupMessengerFileFormInput.getAttribute("disabled"))return false;this.closeMenuPopup();this.popupPopupMenuDateCreate=+new Date;BX.addClass(this.popupMessengerFileButton,"bx-messenger-textarea-file-active");if(this.desktop.run()){BX.addClass(this.popupMessengerFileButton,"bx-messenger-textarea-file-desktop")}this.setClosingByEsc(false)}},this)}}),BX.create("div",{props:{className:"bx-messenger-textarea"},children:[this.popupMessengerTextarea=BX.create("textarea",{props:{value:this.textareaHistory[e]?this.textareaHistory[e]:"",className:"bx-messenger-textarea-input"},style:{height:this.popupMessengerTextareaSize+"px"}}),this.popupMessengerTextareaPlaceholder=BX.create("div",{props:{className:"bx-messenger-textarea-placeholder"},html:BX.message("IM_M_TA_TEXT")})]}),BX.create("div",{props:{className:"bx-messenger-textarea-clear"}}),this.BXIM.desktop.run()&&!this.BXIM.desktop.ready()?null:BX.create("span",{props:{className:"bx-messenger-resize"},events:this.BXIM.desktop.run()?{}:{mousedown:BX.delegate(this.resizeWindowStart,this)}})]})]})]}),this.popupMessengerExtra=BX.create("div",{props:{className:"bx-messenger-box-extra"},style:{marginLeft:this.popupContactListSize+"px",height:this.popupMessengerFullHeight+"px"}})]});this.textareaCheckText();this.BXIM.dialogOpen=true;if(this.desktop.run()){this.popupMessenger=new BX.PopupWindowDesktop(this.BXIM);BX.desktop.setTabContent("im",this.popupMessengerContent);BX.bind(this.popupMessengerContent,"click",BX.delegate(this.closePopupFileMenu,this));this.disk.chatDialogInit();this.disk.chatAvatarInit()}else{this.popupMessenger=new BX.PopupWindow("bx-messenger-popup-messenger",null,{lightShadow:true,autoHide:false,closeByEsc:true,overlay:{opacity:50,backgroundColor:"#000000"},draggable:{restrict:true},events:{onPopupShow:BX.delegate(function(){this.disk.chatDialogInit();this.disk.chatAvatarInit()},this),onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){if(this.BXIM.popupSettings!=null)this.BXIM.popupSettings.close();if(this.webrtc.callInit){this.webrtc.callCommand(this.webrtc.callChatId,"decline",{ACTIVE:this.callActive?"Y":"N",INITIATOR:this.initiator?"Y":"N"});this.webrtc.callAbort()}this.closeMenuPopup();this.popupMessenger=null;this.popupMessengerContent=null;this.mentionListen=false;this.mentionDelimiter="";this.BXIM.extraOpen=false;this.BXIM.dialogOpen=false;this.BXIM.notifyOpen=false;clearTimeout(this.popupMessengerDesktopTimeout);this.setUpdateStateStep();BX.unbind(document,"click",BX.proxy(this.BXIM.autoHide,this.BXIM));BX.unbind(window,"keydown",BX.proxy(this.closePopupFileMenuKeydown,this));this.webrtc.callOverlayClose()},this)},titleBar:{content:BX.create("div")},closeIcon:{top:"10px",right:"13px"},content:this.popupMessengerContent,noAllPaddings:true,contentColor:"white"});this.popupMessenger.show();BX.bind(this.popupMessenger.popupContainer,"click",BX.MessengerCommon.preventDefault);if(this.webrtc.ready()){BX.addCustomEvent(this.popupMessenger,"onPopupDragStart",BX.delegate(function(){if(this.webrtc.callDialogAllow!=null)this.webrtc.callDialogAllow.destroy()},this))}BX.bind(document,"click",BX.proxy(this.BXIM.autoHide,this.BXIM));BX.bind(window,"keydown",BX.proxy(this.closePopupFileMenuKeydown,this));BX.addCustomEvent(this.popupMessenger,"onPopupFullscreenEnter",BX.delegate(function(){BX.addClass(this.popupMessengerContent,"bx-messenger-fullscreen");this.messengerFullscreenStatus=true;this.resizeMainWindow();if(BX.browser.IsChrome()){setTimeout(BX.delegate(function(){this.resizeMainWindow()},this),100)}this.popupMessengerBody.scrollTop=this.popupMessengerBody.scrollHeight-this.popupMessengerBody.offsetHeight},this));BX.addCustomEvent(this.popupMessenger,"onPopupFullscreenLeave",BX.delegate(function(){BX.removeClass(this.popupMessengerContent,"bx-messenger-fullscreen");if(BX.browser.IsChrome()){BX.addClass(this.popupMessengerContent,"bx-messenger-fullscreen-chrome-hack");setTimeout(BX.delegate(function(){BX.removeClass(this.popupMessengerContent,"bx-messenger-fullscreen-chrome-hack")},this),100)}this.resizeMainWindow();this.popupMessengerBody.scrollTop=this.popupMessengerBody.scrollHeight-this.popupMessengerBody.offsetHeight},this))}this.popupMessengerTopLine=BX.create("div",{props:{className:"bx-messenger-box-topline"}});this.popupMessengerContent.insertBefore(this.popupMessengerTopLine,this.popupMessengerContent.firstChild);if(!this.desktop.run()&&this.BXIM.bitrixIntranet&&this.BXIM.platformName!=""&&this.BXIM.settings.bxdNotify){clearTimeout(this.popupMessengerDesktopTimeout);this.popupMessengerDesktopTimeout=setTimeout(BX.delegate(function(){var e=BX.delegate(function(){window.open(BX.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");this.BXIM.settings.bxdNotify=false;this.BXIM.saveSettings({bxdNotify:this.BXIM.settings.bxdNotify});this.hideTopLine()},this);var t=BX.delegate(function(){this.BXIM.settings.bxdNotify=false;this.BXIM.saveSettings({bxdNotify:this.BXIM.settings.bxdNotify});this.hideTopLine()},this);this.showTopLine(BX.message("IM_DESKTOP_INSTALL").replace("#WM_NAME#",BX.message("IM_WM")).replace("#OS#",this.BXIM.platformName),[{title:BX.message("IM_DESKTOP_INSTALL_Y"),callback:e},{title:BX.message("IM_DESKTOP_INSTALL_N"),callback:t}])},this),15e3)}if(this.webrtc.callNotify!=null){if(this.webrtc.ready()){this.setClosingByEsc(false);BX.addClass(BX("bx-messenger-popup-messenger"),"bx-messenger-popup-messenger-dont-close");BX.removeClass(this.webrtc.callNotify.contentContainer.children[0],"bx-messenger-call-overlay-float");this.popupMessengerContent.insertBefore(this.webrtc.callNotify.contentContainer.children[0],this.popupMessengerContent.firstChild);this.webrtc.callNotify.close();BX.style(this.webrtc.callOverlay,"width",(this.popupMessengerExtra.style.display=="block"?this.popupMessengerExtra.offsetWidth+1:this.popupMessengerDialog.offsetWidth+1)+"px")}else{this.webrtc.callOverlayClose(false)}}BX.MessengerCommon.userListRedraw();if(this.BXIM.quirksMode){this.popupContactListWrap.style.position="absolute";this.popupContactListWrap.style.display="block"}this.setUpdateStateStep();if(!(BX.browser.IsAndroid()||BX.browser.IsIOS()||window!=window.top)&&this.popupMessenger!=null){if(t&&this.popupContactListSearchInput!=null){setTimeout(BX.delegate(function(){this.popupContactListSearchInput.focus()},this),50)}else{setTimeout(BX.delegate(function(){this.popupMessengerTextarea.focus()},this),50)}}if(this.webrtc.phoneEnabled&&this.BXIM.design!="DESKTOP"){BX.bind(this.popupContactListSearchCall,"click",BX.delegate(this.webrtc.openKeyPad,this.webrtc))}BX.bind(this.popupContactListWrap,"mouseover",BX.delegate(function(e){if(this.popupContactListHovered||this.popupContactListActive)return false;clearTimeout(this.popupContactListWrapAnimation);this.popupContactListWrapAnimation=setTimeout(BX.delegate(function(){BX.addClass(this.popupContactListWrap,"bx-messenger-box-contact-hover");clearTimeout(this.popupContactListWrapAnimation);this.popupContactListWrapAnimation=setTimeout(BX.delegate(function(){BX.removeClass(this.popupContactListWrap,"bx-messenger-box-contact-normal")},this),100)},this),2e3);this.popupContactListHovered=true},this));BX.bind(this.popupContactListWrap,"mouseout",BX.delegate(function(e){if(!this.popupContactListHovered||this.popupContactListActive)return false;clearTimeout(this.popupContactListWrapAnimation);this.popupContactListWrapAnimation=setTimeout(BX.delegate(function(){BX.addClass(this.popupContactListWrap,"bx-messenger-box-contact-normal");clearTimeout(this.popupContactListWrapAnimation);this.popupContactListWrapAnimation=setTimeout(BX.delegate(function(){BX.removeClass(this.popupContactListWrap,"bx-messenger-box-contact-hover")},this),50)},this),400);this.popupContactListHovered=false},this));BX.bind(this.popupContactListCreateChat,"click",BX.delegate(function(e){if(!this.recentList){this.recentList=true;BX.MessengerCommon.recentListRedraw()}this.openPopupMenu(e.currentTarget,"createChat");return BX.PreventDefault(e)},this));BX.bind(this.popupContactListSearchClose.parentNode,"click",BX.delegate(function(){this.popupContactListSearchInput.focus()},this));BX.bind(this.popupMessengerDialog,"click",BX.delegate(function(e){if(this.recentList&&!this.chatList&&!this.contactList){return false}BX.MessengerCommon.contactListSearchClear(e)},this));BX.bind(this.popupContactListSearchClose,"click",BX.delegate(function(e){BX.MessengerCommon.contactListSearchClear(e);return BX.PreventDefault(e)},BX.MessengerCommon));BX.bind(this.popupContactListSearchInput,"click",BX.delegate(function(e){if(this.contactListSearchText.length==0&&!this.contactList&&e.altKey==true){clearTimeout(this.BXIM.messenger.redrawChatListTimeout);BX.MessengerCommon.contactListRedraw()}},this));BX.bind(this.popupContactListSearchInput,"focus",BX.delegate(function(e){clearTimeout(this.BXIM.messenger.redrawChatListTimeout);this.BXIM.messenger.redrawChatListTimeout=setTimeout(BX.delegate(function(){if(this.contactListSearchText.length==0&&!this.chatList&&!this.contactList){BX.MessengerCommon.chatListRedraw()}},this),100);this.setClosingByEsc(false)},this));BX.bind(this.popupContactListSearchInput,"blur",BX.delegate(function(){if(this.contactListSearchText.length==0&&!this.popupContactListHovered&&!this.recentList){this.setClosingByEsc(true)}},this));if(this.desktop.ready()){BX.bind(this.popupContactListSearchInput,"contextmenu",BX.delegate(function(e){this.openPopupMenu(e,"copypaste",false,{spell:true});return BX.PreventDefault(e)},this))}BX.bind(this.popupContactListSearchInput,"keyup",BX.delegate(BX.MessengerCommon.contactListSearch,BX.MessengerCommon));BX.bind(this.popupMessengerPanelChatTitle,"click",BX.delegate(this.renameChatDialog,this));BX.bindDelegate(this.popupMessengerPanelUsers,"click",{className:"bx-messenger-panel-chat-user"},BX.delegate(function(e){this.openPopupMenu(BX.proxy_context,"chatUser");return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupMessengerPanelUsers,"click",{className:"bx-notifier-popup-user-more"},BX.delegate(function(e){if(this.popupChatUsers!=null){this.popupChatUsers.destroy();return false}var t=this.currentTab.toString().substr(4);var s='<span class="bx-notifier-item-help-popup">';for(var i=parseInt(BX.proxy_context.getAttribute("data-last-item"));i<this.userInChat[t].length;i++){if(this.userInChat[t][i]){var a=BX.MessengerCommon.isBlankAvatar(this.users[this.userInChat[t][i]].avatar)?'style="background-color: '+this.users[this.userInChat[t][i]].color+'"':"";s+='<span class="bx-notifier-item-help-popup-img bx-messenger-panel-chat-user" data-userId="'+this.userInChat[t][i]+'">'+'<span class="bx-notifier-popup-avatar bx-notifier-popup-avatar-status-'+BX.MessengerCommon.getUserStatus(this.userInChat[t][i])+'">'+'<img class="bx-notifier-popup-avatar-img'+(BX.MessengerCommon.isBlankAvatar(this.users[this.userInChat[t][i]].avatar)?" bx-notifier-popup-avatar-img-default":"")+'" src="'+this.users[this.userInChat[t][i]].avatar+'" '+a+">"+"</span>"+'<span class="bx-notifier-item-help-popup-name '+(this.users[this.userInChat[t][i]].extranet?" bx-notifier-popup-avatar-extranet":"")+'">'+this.users[this.userInChat[t][i]].name+"</span>"+"</span>"}}s+="</span>";this.popupChatUsers=new BX.PopupWindow("bx-messenger-popup-chat-users",BX.proxy_context,{zIndex:200,lightShadow:true,offsetTop:-2,offsetLeft:3,autoHide:true,closeByEsc:true,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.proxy(function(){this.popupChatUsers=null},this)},content:BX.create("div",{props:{className:"bx-messenger-popup-menu"+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},html:s})});this.popupChatUsers.setAngle({offset:BX.proxy_context.offsetWidth});this.popupChatUsers.show();BX.bindDelegate(this.popupChatUsers.popupContainer,"click",{className:"bx-messenger-panel-chat-user"},BX.delegate(function(e){this.openPopupMenu(BX.proxy_context,"chatUser");return BX.PreventDefault(e)},this));return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupContactListElements,"contextmenu",{className:"bx-messenger-cl-item"},BX.delegate(function(e){this.openPopupMenu(BX.proxy_context,"contactList");return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupContactListElements,"click",{className:"bx-messenger-cl-item"},BX.delegate(BX.MessengerCommon.contactListClickItem,BX.MessengerCommon));BX.bindDelegate(this.popupContactListElements,"click",{className:"bx-messenger-chatlist-group-add"},BX.delegate(function(e){if(!this.recentList){this.recentList=true;BX.MessengerCommon.recentListRedraw()}this.openChatCreateForm(BX.proxy_context.getAttribute("data-type"))},this));BX.bindDelegate(this.popupContactListElements,"click",{className:"bx-messenger-chatlist-more"},BX.delegate(function(e){if(BX.hasClass(BX.proxy_context.parentNode.parentNode,"bx-messenger-chatlist-show-all")){this.contactListShowed[BX.proxy_context.getAttribute("data-id")]=false;BX.proxy_context.innerHTML=BX.proxy_context.getAttribute("data-text");BX.removeClass(BX.proxy_context.parentNode.parentNode,"bx-messenger-chatlist-show-all");var t=BX.pos(BX.proxy_context,true);this.popupContactListElements.scrollTop=t.top-100}else{this.contactListShowed[BX.proxy_context.getAttribute("data-id")]=true;BX.proxy_context.innerHTML=BX.message("IM_CL_HIDE");BX.addClass(BX.proxy_context.parentNode.parentNode,"bx-messenger-chatlist-show-all")}},this));BX.bind(this.popupContactListElements,"scroll",BX.delegate(function(){if(this.popupPopupMenu!=null&&this.popupPopupMenuDateCreate+500<+new Date&&this.popupPopupMenu.uniquePopupId.replace("bx-messenger-popup-","")=="contactList"){this.popupPopupMenu.close()}},this));BX.bindDelegate(this.popupContactListElements,"click",{className:"bx-messenger-cl-group-title"},BX.delegate(BX.MessengerCommon.contactListToggleGroup,BX.MessengerCommon));BX.bind(this.contactListPanelStatus,"click",BX.delegate(function(e){this.openPopupMenu(this.contactListPanelStatus,"status");return BX.PreventDefault(e)},this));if(this.contactListPanelSettings){BX.bind(this.contactListPanelSettings,"click",BX.delegate(function(e){this.BXIM.openSettings();BX.PreventDefault(e)},this))}if(this.contactListPanelFull){BX.bind(this.contactListPanelFull,"click",BX.delegate(function(e){this.popupMessenger.enterFullScreen();BX.PreventDefault(e)},this))}BX.bind(this.popupMessengerEditTextarea,"focus",BX.delegate(function(){this.setClosingByEsc(false)},this));BX.bind(this.popupMessengerEditTextarea,"blur",BX.delegate(function(){this.setClosingByEsc(true)},this));BX.bind(this.popupMessengerEditTextarea,"keydown",BX.delegate(function(e){this.textareaPrepareText(BX.proxy_context,e,BX.delegate(function(){BX.MessengerCommon.editMessageAjax(this.popupMessengerEditMessageId,this.popupMessengerEditTextarea.value)},this),BX.delegate(function(){this.editMessageCancel()},this))},this));if(this.desktop.ready()){BX.bind(this.popupMessengerEditTextarea,"contextmenu",BX.delegate(function(e){this.openPopupMenu(e,"copypaste",false,{spell:true});return BX.PreventDefault(e)},this));BX.bind(this.popupMessengerTextarea,"contextmenu",BX.delegate(function(e){this.openPopupMenu(e,"copypaste",false,{spell:true});return BX.PreventDefault(e)},this));BX.bind(this.popupMessengerEditTextarea,"click",BX.delegate(function(e){if(!(e.metaKey||e.ctrlKey)||!this.desktop.enableInVersion(34))return false;var t=BX.desktop.clipboardSelected(this.popupMessengerEditTextarea,true);if(!t.text)return false;BXDesktopSystem.SpellCheckWord(t.text,BX.delegate(function(e,t){if(e||t.length<=0)return false;var s=BX.desktop.clipboardSelected(this.popupMessengerEditTextarea,true);BX.desktop.clipboardReplaceText(this.popupMessengerEditTextarea,s.selectionStart,s.selectionEnd,t[0])},this))},this));BX.bind(this.popupMessengerTextarea,"click",BX.delegate(function(e){if(!(e.metaKey||e.ctrlKey)||!this.desktop.enableInVersion(34))return false;var t=BX.desktop.clipboardSelected(this.popupMessengerTextarea,true);if(!t.text)return false;
BXDesktopSystem.SpellCheckWord(t.text,BX.delegate(function(e,t){if(e||t.length<=0)return false;var s=BX.desktop.clipboardSelected(this.popupMessengerTextarea,true);BX.desktop.clipboardReplaceText(this.popupMessengerTextarea,s.selectionStart,s.selectionEnd,t[0])},this))},this))}BX.bind(this.popupMessengerTextarea,"focus",BX.delegate(function(){this.textareaCheckText();this.setClosingByEsc(false);BX.addClass(this.popupMessengerTextarea.parentNode,"bx-messenger-textarea-focus");BX.onCustomEvent(window,"onImTextareaFocus",[true])},this));BX.bind(this.popupMessengerTextarea,"blur",BX.delegate(function(){this.textareaCheckText();this.setClosingByEsc(true);BX.removeClass(this.popupMessengerTextarea.parentNode,"bx-messenger-textarea-focus");BX.onCustomEvent(window,"onImTextareaFocus",[false])},this));BX.bind(this.popupMessengerTextarea,"keydown",BX.delegate(function(e){this.textareaPrepareText(BX.proxy_context,e,BX.delegate(this.sendMessage,this),BX.delegate(function(){if(BX.util.trim(this.popupMessengerEditTextarea.value).length<=0){this.popupMessengerEditTextarea.value="";if(this.popupMessenger&&!this.webrtc.callInit&&this.popupMessengerEditTextarea.value.length<=0)this.popupMessenger.destroy()}else{this.popupMessengerEditTextarea.value=""}},this))},this));BX.bind(this.popupMessengerTextarea,"keyup",BX.delegate(this.textareaCheckText,this));if(this.desktop.ready()){BX.bindDelegate(this.popupMessengerBodyWrap,"contextmenu",{className:"bx-messenger-content-item-content"},BX.delegate(function(e){this.openPopupMenu(e,"dialogContext",false);return BX.PreventDefault(e)},this))}BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-content-item-avatar-button"},BX.delegate(function(e){var t=BX.proxy_context.parentNode.parentNode.getAttribute("data-senderId");if(!this.users[t]||this.users[t].fake)return false;var s=BX.util.htmlspecialcharsback(this.users[t].name);if(e.metaKey||e.ctrlKey){s="[USER="+t+"]"+s+"[/USER]"}else{BX.MessengerCommon.addMentionList(this.currentTab,s,t)}this.insertTextareaText(this.popupMessengerTextarea," "+s+" ",false);this.popupMessengerTextarea.focus();return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-content-item-menu"},BX.delegate(function(e){if(e.metaKey||e.ctrlKey){var t=BX.proxy_context.nextSibling.id.replace("im-message-","");if(this.message[t]&&this.users[this.message[t].senderId].name){var s=[];if(this.message[t].text){s.push(BX.MessengerCommon.prepareTextBack(this.message[t].text))}if(this.message[t].params&&this.message[t].params.FILE_ID){for(var i=0;i<this.message[t].params.FILE_ID.length;i++){var a=this.message[t].params.FILE_ID[i];var n=this.message[t].chatId;if(this.disk.files[n][a]){s.push("["+BX.message("IM_F_FILE")+": "+this.disk.files[n][a].name+"]")}}}if(s.length>0){this.insertQuoteText(this.users[this.message[t].senderId].name,this.message[t].date,s.join("\n"))}}}else{this.openPopupMenu(BX.proxy_context,"dialogMenu")}return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-content-like-digit"},BX.delegate(function(e){var t=BX.proxy_context.parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("data-blockmessageid");if(t.substr(0,4)=="temp"||!this.message[t].params||!this.message[t].params["LIKE"]||this.message[t].params["LIKE"].length<=0)return false;if(this.popupChatUsers!=null){this.popupChatUsers.destroy();return false}var s='<span class="bx-notifier-item-help-popup">';for(var i=0;i<this.message[t].params["LIKE"].length;i++){if(this.users[this.message[t].params["LIKE"][i]]){var a=BX.MessengerCommon.isBlankAvatar(this.users[this.message[t].params["LIKE"][i]].avatar)?'style="background-color: '+this.users[this.message[t].params["LIKE"][i]].color+'"':"";s+='<span class="bx-notifier-item-help-popup-img bx-messenger-panel-chat-user" data-userId="'+this.message[t].params["LIKE"][i]+'">'+'<span class="bx-notifier-popup-avatar bx-notifier-popup-avatar-status-'+BX.MessengerCommon.getUserStatus(this.message[t].params["LIKE"][i])+'">'+'<img class="bx-notifier-popup-avatar-img'+(BX.MessengerCommon.isBlankAvatar(this.users[this.message[t].params["LIKE"][i]].avatar)?" bx-notifier-popup-avatar-img-default":"")+'" src="'+this.users[this.message[t].params["LIKE"][i]].avatar+'" '+a+">"+"</span>"+'<span class="bx-notifier-item-help-popup-name '+(this.users[this.message[t].params["LIKE"][i]].extranet?" bx-notifier-popup-avatar-extranet":"")+'">'+this.users[this.message[t].params["LIKE"][i]].name+"</span>"+"</span>"}}s+="</span>";this.popupChatUsers=new BX.PopupWindow("bx-messenger-popup-like-users",BX.proxy_context,{zIndex:200,lightShadow:true,offsetTop:-2,offsetLeft:3,autoHide:true,closeByEsc:true,bindOptions:{position:"top"},events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.proxy(function(){this.popupChatUsers=null},this)},content:BX.create("div",{props:{className:"bx-messenger-popup-menu"+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},html:s})});this.popupChatUsers.setAngle({offset:BX.proxy_context.offsetWidth});this.popupChatUsers.show();BX.bindDelegate(this.popupChatUsers.popupContainer,"click",{className:"bx-messenger-panel-chat-user"},BX.delegate(function(e){this.openPopupMenu(BX.proxy_context,"chatUser");return BX.PreventDefault(e)},this));return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-keyboard-button-text"},BX.delegate(BX.MessengerCommon.clickButtonKeyboard,BX.MessengerCommon));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-content-like-button"},BX.delegate(function(e){var t=this.currentTab.toString().substr(4);if(this.openChatFlag&&!BX.MessengerCommon.userInChat(t)){return false}var s=BX.proxy_context.parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("data-blockmessageid");BX.MessengerCommon.messageLike(s);return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-attach-delete"},BX.delegate(function(e){var t=BX.proxy_context.getAttribute("data-messageId");var s=BX.proxy_context.getAttribute("data-attachId");var i=BX.proxy_context.getAttribute("data-action");if(i=="url"){BX.MessengerCommon.messageUrlAttachDelete(t,s)}return BX.PreventDefault(e)},this));BX.bind(this.popupMessengerTextareaOpenJoin,"click",BX.delegate(function(){if(this.currentTab.substr(0,4)!="chat")return false;var e=this.currentTab.substr(4);BX.MessengerCommon.joinToChat(e);return true},this));BX.bind(this.popupMessengerTextareaGeneralJoin,"click",BX.delegate(function(){this.BXIM.settings.generalNotify=false;this.BXIM.saveSettings({generalNotify:this.BXIM.settings.generalNotify});this.redrawChatHeader({userRedraw:false});this.popupMessengerTextarea.focus();return true},this));BX.bind(this.popupMessengerTextareaOpenLinesAnswer,"click",BX.delegate(function(){if(this.currentTab.substr(0,4)!="chat")return false;var e=this.currentTab.substr(4);BX.MessengerCommon.linesAnswer(e);return true},this));BX.bind(this.popupMessengerTextareaOpenLinesSkip,"click",BX.delegate(function(){if(this.currentTab.substr(0,4)!="chat")return false;var e=this.currentTab.substr(4);BX.MessengerCommon.linesSkip(e);return true},this));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-ajax"},BX.delegate(function(){if(BX.proxy_context.getAttribute("data-entity")=="readedList"){this.openPopupExternalData(BX.proxy_context,"readedList",true,{TAB:this.BXIM.messenger.currentTab})}else if(BX.proxy_context.getAttribute("data-entity")=="user"){this.openPopupExternalData(BX.proxy_context,"user",true,{ID:BX.proxy_context.getAttribute("data-userId")})}else if(BX.proxy_context.getAttribute("data-entity")=="chat"){this.openPopupExternalData(BX.proxy_context,"chat",true,{ID:BX.proxy_context.getAttribute("data-chatId")})}else if(BX.proxy_context.getAttribute("data-entity")=="network"){this.openMessenger("network"+BX.proxy_context.getAttribute("data-networkId"))}else if(this.webrtc.phoneSupport()&&BX.proxy_context.getAttribute("data-entity")=="phoneCallHistory"){this.openPopupExternalData(BX.proxy_context,"phoneCallHistory",true,{ID:BX.proxy_context.getAttribute("data-historyID")})}},this));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-command"},BX.delegate(function(){if(BX.proxy_context.getAttribute("data-entity")=="send"){this.popupMessengerTextarea.value=BX.proxy_context.getAttribute("data-command");this.sendMessage(this.currentTab)}else if(BX.proxy_context.getAttribute("data-entity")=="put"){this.popupMessengerTextarea.focus();this.insertTextareaText(this.popupMessengerTextarea,BX.proxy_context.getAttribute("data-command")+" ",false)}else if(BX.proxy_context.getAttribute("data-entity")=="call"){this.BXIM.phoneTo(BX.proxy_context.getAttribute("data-command"))}},this));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-content-item-date"},BX.delegate(function(){if(this.openLinesFlag){this.tooltip(BX.proxy_context,BX.message("IM_TIP_OL_SYSTEM"),{offsetLeft:20})}},this));BX.bind(this.popupMessengerBody,"scroll",BX.delegate(function(){this.isBodyScroll=true;if(this.unreadMessage[this.currentTab]&&this.unreadMessage[this.currentTab].length>0&&BX.MessengerCommon.isScrollMax(this.popupMessengerBody,200)&&this.BXIM.isFocus()){clearTimeout(this.readMessageTimeout);this.readMessageTimeout=setTimeout(BX.delegate(function(){BX.MessengerCommon.readMessage(this.currentTab)},this),100)}clearTimeout(this.bodyScrollTimeout);this.bodyScrollTimeout=setTimeout(BX.delegate(function(){this.isBodyScroll=false},this),100);BX.MessengerCommon.redrawDateMarks();BX.MessengerCommon.loadHistory(this.currentTab,false);if(this.popupPopupMenu!=null){if(this.popupPopupMenuDateCreate+500<+new Date&&BX.util.in_array(this.popupPopupMenu.uniquePopupId.replace("bx-messenger-popup-",""),["copypaste","copylink","dialogContext","dialogMenu","external-data"])){this.popupPopupMenu.close()}else if(false&&BX.util.in_array(this.popupPopupMenu.uniquePopupId.replace("bx-messenger-popup-",""),["dialogMenu","external-data"])){this.popupPopupMenu.adjustPosition()}}if(this.popupChatUsers!=null&&this.popupChatUsers.uniquePopupId.replace("bx-messenger-popup-","")=="like-users"){this.popupChatUsers.close()}},this));BX.bindDelegate(this.popupMessengerBodyWrap,"click",{className:"bx-messenger-content-item-error"},BX.delegate(BX.MessengerCommon.sendMessageRetry,BX.MessengerCommon));if(e==0){this.extraOpen(BX.create("div",{attrs:{style:"padding-top: 300px"},props:{className:"bx-messenger-box-empty"},html:BX.message("IM_M_EMPTY")}))}else{BX.MessengerCommon.openDialog(e)}};BX.Messenger.prototype.tooltip=function(e,t,s){if(this.popupTooltip!=null)this.popupTooltip.close();s=s||{};s.offsetLeft=s.offsetLeft||0;s.offsetTop=s.offsetTop||this.desktop.ready()?0:-10;this.popupTooltip=new BX.PopupWindow("bx-messenger-tooltip",e,{lightShadow:true,autoHide:true,darkMode:true,offsetLeft:s.offsetLeft,offsetTop:s.offsetTop,closeIcon:{},bindOptions:{position:"top"},events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupTooltip=null},this)},zIndex:200,content:BX.create("div",{props:{style:"padding-right: 5px;"},html:t})});this.popupTooltip.setAngle({offset:23,position:"bottom"});this.popupTooltip.show();return true};BX.Messenger.prototype.dialogStatusRedraw=function(e){if(this.popupMessenger==null)return false;e=e||{};this.popupMessengerPanelButtonCall1.className=this.callButtonStatus(this.currentTab);this.popupMessengerPanelButtonCall2.className=this.callButtonStatus(this.currentTab);this.popupMessengerPanelButtonCall3.className=this.phoneButtonStatus();if(this.popupMessengerFileButton)BX.show(this.popupMessengerFileButton);this.popupMessengerPanel.className=this.openChatFlag?"bx-messenger-panel bx-messenger-context-user bx-messenger-hide":"bx-messenger-panel bx-messenger-context-user";if(this.openChatFlag){var t=false;if(this.renameChatDialogFlag)t=true;this.redrawChatHeader(e)}else if(this.users[this.currentTab]){if(this.popupMessengerFileFormChatId){this.popupMessengerFileFormChatId.value=this.userChat[this.currentTab]?this.userChat[this.currentTab]:0;if(false&&this.users[this.currentTab].bot){this.popupMessengerFileFormInput.setAttribute("disabled",true);if(this.popupMessengerFileButton)BX.hide(this.popupMessengerFileButton)}else{if(parseInt(this.popupMessengerFileFormChatId.value)>0){this.popupMessengerFileFormInput.removeAttribute("disabled")}else{this.popupMessengerFileFormInput.setAttribute("disabled",true)}}}if(this.openChatFlag){this.popupMessengerPanelMute.title=this.muteButtonStatus(this.currentTab)?BX.message("IM_M_CHAT_MUTE_ON_2"):BX.message("IM_M_CHAT_MUTE_OFF_2")}else{this.popupMessengerPanelMute.title=this.muteButtonStatus(this.currentTab)?BX.message("IM_M_USER_BLOCK_OFF"):BX.message("IM_M_USER_BLOCK_ON")}this.popupMessengerPanelMute.className="bx-messenger-panel-button bx-messenger-panel-mute "+(this.muteButtonStatus(this.currentTab)?" bx-messenger-panel-unmute":"");this.popupMessengerPanelAvatar.parentNode.href=this.users[this.currentTab].profile;this.popupMessengerPanelAvatar.parentNode.className="bx-messenger-panel-avatar bx-messenger-panel-avatar-status-"+BX.MessengerCommon.getUserStatus(this.currentTab);this.popupMessengerPanelAvatar.parentNode.title=BX.MessengerCommon.getUserStatus(this.currentTab,true);this.popupMessengerPanelAvatar.src=this.users[this.currentTab].avatar?this.users[this.currentTab].avatar:this.BXIM.pathToBlankImage;this.popupMessengerPanelAvatar.className="bx-messenger-panel-avatar-img"+(BX.MessengerCommon.isBlankAvatar(this.popupMessengerPanelAvatar.src)?" bx-messenger-panel-avatar-img-default":"");BX.style(this.popupMessengerPanelAvatar,"background-color",BX.MessengerCommon.isBlankAvatar(this.popupMessengerPanelAvatar.src)&&this.users[this.currentTab].color?this.users[this.currentTab].color:"");this.popupMessengerPanelTitle.href=this.users[this.currentTab].profile;this.popupMessengerPanelTitle.innerHTML=this.users[this.currentTab].name;if(this.BXIM.userId==this.currentTab){this.popupMessengerPanelTitle.innerHTML=this.popupMessengerPanelTitle.innerHTML+" (<b><i>"+BX.message("IM_YOU")+"</i></b>)"}this.popupMessengerPanelStatus.innerHTML=BX.MessengerCommon.getUserPosition(this.currentTab);var s=[];if(this.users[this.currentTab].extranet){BX.addClass(this.popupMessengerPanelTitle,"bx-messenger-user-extranet");BX.addClass(this.popupMessengerDialog,"bx-messenger-dialog-extranet");BX.removeClass(this.popupMessengerPanelTitle,"bx-messenger-user-bot");BX.removeClass(this.popupMessengerPanelTitle,"bx-messenger-user-network");s.push("bx-messenger-chat-livechat");s.push("bx-messenger-chat-lines");s.push("bx-messenger-dialog-bot");s.push("bx-messenger-dialog-network");s.push("bx-messenger-dialog-self")}else if(this.users[this.currentTab].bot){if(this.bot[this.currentTab]&&this.bot[this.currentTab].type=="network"){BX.addClass(this.popupMessengerPanelTitle,"bx-messenger-user-network");BX.addClass(this.popupMessengerDialog,"bx-messenger-dialog-network");BX.removeClass(this.popupMessengerPanelTitle,"bx-messenger-user-bot");BX.removeClass(this.popupMessengerDialog,"bx-messenger-dialog-bot")}else{BX.addClass(this.popupMessengerPanelTitle,"bx-messenger-user-bot");BX.addClass(this.popupMessengerDialog,"bx-messenger-dialog-bot");BX.removeClass(this.popupMessengerPanelTitle,"bx-messenger-user-network");BX.removeClass(this.popupMessengerDialog,"bx-messenger-dialog-network")}BX.removeClass(this.popupMessengerPanelTitle,"bx-messenger-user-extranet");s.push("bx-messenger-chat-livechat");s.push("bx-messenger-chat-lines");s.push("bx-messenger-dialog-extranet");s.push("bx-messenger-dialog-self")}else{BX.removeClass(this.popupMessengerPanelTitle,"bx-messenger-user-extranet");BX.removeClass(this.popupMessengerPanelTitle,"bx-messenger-user-bot");BX.removeClass(this.popupMessengerPanelTitle,"bx-messenger-user-network");s.push("bx-messenger-dialog-bot");s.push("bx-messenger-dialog-network");s.push("bx-messenger-chat-livechat");s.push("bx-messenger-chat-lines");s.push("bx-messenger-dialog-extranet");if(this.BXIM.userId==this.currentTab){BX.addClass(this.popupMessengerDialog,"bx-messenger-dialog-self")}else{s.push("bx-messenger-dialog-self")}}this.popupMessengerTextarea.disabled=false;s.push("bx-messenger-chat-guest");s.push("bx-messenger-chat-open");s.push("bx-messenger-chat-chat");s.push("bx-messenger-chat-general");s.push("bx-messenger-chat-general-first-open");s.push("bx-messenger-chat-general-access");BX.removeClass(this.popupMessengerDialog,s.join(" "))}return true};BX.Messenger.prototype.muteButtonStatus=function(e){var t=0;if(e.toString().substr(0,4)=="chat"){t=e.toString().substr(4)}else{t=this.userChat[e]}return this.userChatBlockStatus[t]&&this.userChatBlockStatus[t][this.BXIM.userId]=="Y"};BX.Messenger.prototype.callButton=function(e){var t=null;if(e=="call"){t=BX.create("span",{props:{className:this.phoneButtonStatus()},children:[BX.create("a",{attrs:{href:"#call",title:BX.message("IM_PHONE_CALL")},props:{className:"bx-messenger-panel-button bx-messenger-panel-call-audio"},events:{click:BX.delegate(function(e){if(this.webrtc.callInit)return false;var t=this.chat[this.currentTab.toString().substr(4)];if(t.call_number){this.BXIM.phoneTo(t.call_number)}else{this.webrtc.openKeyPad()}BX.PreventDefault(e)},this)},html:BX.message("IM_PHONE_CALL")})]})}else{t=BX.create("span",{props:{className:this.callButtonStatus(this.currentTab)},children:[BX.create("a",{attrs:{href:"#call",title:BX.message("IM_M_CALL_VIDEO")},props:{className:"bx-messenger-panel-button bx-messenger-panel-call-video"},events:{click:BX.delegate(function(e){if(!this.webrtc.callInit)this.BXIM.callTo(this.currentTab,true);BX.PreventDefault(e)},this)},html:BX.message("IM_M_CALL_VIDEO")}),BX.create("a",{attrs:{href:"#callMenu"},props:{className:"bx-messenger-panel-call-menu"},events:{click:BX.delegate(function(e){if(!this.webrtc.callInit)this.openPopupMenu(BX.proxy_context,"callMenu");BX.PreventDefault(e)},this)}})]})}return t};BX.Messenger.prototype.callButtonStatus=function(e){e=e.toString();var t="bx-messenger-panel-button-box bx-messenger-panel-call-hide";if(this.openChatFlag&&this.chat[e.substr(4)]&&(this.chat[e.substr(4)].type=="lines"||this.chat[e.substr(4)].type=="livechat")){}else if(this.BXIM.ppServerStatus&&(!this.users[e]||!this.users[e].network)){t=!this.webrtc.callSupport(e,this)||this.webrtc.callInit?"bx-messenger-panel-button-box bx-messenger-panel-call-disabled":"bx-messenger-panel-button-box bx-messenger-panel-call-enabled"}return t};BX.Messenger.prototype.phoneButtonStatus=function(){var e="bx-messenger-panel-call-hide";if(this.BXIM.ppServerStatus)e=this.webrtc.phoneSupport()?"bx-messenger-panel-call-enabled":"bx-messenger-panel-call-disabled";return"bx-messenger-panel-call-phone "+e};BX.Messenger.prototype.openChatCreateForm=function(e){this.currentTab="create";var t=[];var s="";var i="";if(e=="chat"){s="#49afdf";t=[BX.create("div",{props:{className:"bx-messenger-box-create-icon bx-messenger-box-create-icon-"+e},children:[BX.create("div",{props:{className:"bx-messenger-box-create-icon-image"}})]}),BX.create("div",{props:{className:"bx-messenger-box-create-title"},html:BX.message("IM_CL_CHAT_2")}),BX.create("div",{props:{className:"bx-messenger-box-create-text"},html:BX.message(this.BXIM.bitrixIntranet?"IM_C_ABOUT_CHAT":"IM_C_ABOUT_CHAT_CHAT").split("#BR#").join("<br />").replace("#PROFILE_END#","</a>").replace("#PROFILE_START#",'<a href="'+BXIM.path.profile+'edit/" target="_blank">')})]}else if(e=="open"&&(!this.BXIM.userExtranet||this.openChatEnable)){s="#a7c131";t=[BX.create("div",{props:{className:"bx-messenger-box-create-icon bx-messenger-box-create-icon-"+e},children:[BX.create("div",{props:{className:"bx-messenger-box-create-icon-image"}})]}),BX.create("div",{props:{className:"bx-messenger-box-create-title"},html:BX.message("IM_CL_OPEN_CHAT")}),BX.create("div",{props:{className:"bx-messenger-box-create-text"},html:BX.message(this.BXIM.bitrixIntranet?"IM_C_ABOUT_OPEN":"IM_C_ABOUT_OPEN_SITE").split("#BR#").join("<br />").replace("#PROFILE_END#","</a>").replace("#PROFILE_START#",'<a href="'+BXIM.path.profile+'edit/" target="_blank">').replace("#CHAT_END#","</b>").replace("#CHAT_START#","<b>")})]}else{e="private";s=this.users[this.BXIM.userId].color;t=[BX.create("div",{props:{className:"bx-messenger-box-create-icon bx-messenger-box-create-icon-"+e},children:[BX.create("div",{props:{className:"bx-messenger-box-create-icon-image"}})]}),BX.create("div",{props:{className:"bx-messenger-box-create-title"},html:BX.message("IM_CL_PRIVATE_CHAT")}),BX.create("div",{props:{className:"bx-messenger-box-create-text"},html:BX.message(this.BXIM.bitrixIntranet?"IM_C_ABOUT_PRIVATE":"IM_C_ABOUT_PRIVATE_SITE").split("#BR#").join("<br />").replace("#PROFILE_END#","</a>").replace("#PROFILE_START#",'<a href="'+BXIM.path.profile+'edit/" target="_blank">')})]}if(this.chatCreateForm&&!BX.browser.IsIE11()){this.extraOpen(this.chatCreateForm);if(this.chatCreateFormAvatar.parentNode){this.chatCreateFormAvatar.parentNode.className="bx-messenger-panel-avatar bx-messenger-panel-avatar-"+e}BX.style(this.chatCreateFormAvatar,"background-color",s);this.chatCreateType=e;this.chatCreateUsers={};this.chatCreateFormDescription.innerHTML="";BX.adjust(this.chatCreateFormDescription,{children:t});BX.MessengerCommon.clearMentionList("create");this.chatCreateFormChatTitle.value="";this.chatCreateFormUsersInput.value="";this.chatCreateFormUsersDest.innerHTML="";this.popupCreateChatTextarea.value="";this.textareaCheckText({textarea:"createChat"});BX.style(this.chatCreateFormBody,"height",this.popupMessengerBodySize+"px");BX.style(this.popupCreateChatTextarea,"height",this.popupMessengerTextareaSize+"px");if(e=="open"){BX.addClass(this.chatCreateFormUsersInput.parentNode.parentNode,"bx-messenger-hide");BX.removeClass(this.chatCreateFormChatTitle.parentNode.parentNode,"bx-messenger-hide")}else{BX.addClass(this.chatCreateFormChatTitle.parentNode.parentNode,"bx-messenger-hide");BX.removeClass(this.chatCreateFormUsersInput.parentNode.parentNode,"bx-messenger-hide");BX.removeClass(this.chatCreateFormUsersInput,"bx-messenger-hide");BX.addClass(this.chatCreateFormUsersInput,"bx-messenger-input-dest-empty")}if(this.chatCreateUsers.length>0&&this.popupCreateChatTextarea.value.length>0){this.popupCreateChatTextarea.focus()}else{if(e=="open"){this.chatCreateFormChatTitle.focus()}else{this.chatCreateFormUsersInput.focus()}}}else{this.chatCreateType=e;this.chatCreateUsers={};BX.MessengerCommon.clearMentionList("create");this.chatCreateForm=BX.create("div",{props:{className:"bx-messenger-box-create"},children:[BX.create("div",{props:{className:"bx-messenger-panel"},children:[BX.create("div",{props:{className:"bx-messenger-panel-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-panel-avatar bx-messenger-panel-avatar-"+e},children:[this.chatCreateFormAvatar=BX.create("img",{attrs:{src:this.BXIM.pathToBlankImage,style:"background-color: "+s},props:{className:"bx-messenger-panel-avatar-img bx-messenger-panel-avatar-img-default"}})]}),BX.create("span",{props:{className:"bx-messenger-panel-title bx-messenger-panel-create-chat "+(e=="open"?"bx-messenger-hide":"")},children:[BX.create("div",{props:{className:"bx-messenger-input-wrap bx-messenger-panel-create-input"},children:[this.chatCreateFormUsersDest=BX.create("span",{props:{className:"bx-messenger-dest-items"}}),this.chatCreateFormUsersInput=BX.create("input",{props:{className:"bx-messenger-input bx-messenger-input-dest-empty"},attrs:{type:"text",value:"",placeholder:BX.message("IM_C_PRIVATE_TITLE")}})]})]}),BX.create("span",{props:{className:"bx-messenger-panel-title bx-messenger-panel-create-chat "+(e!="open"?"bx-messenger-hide":"")},children:[BX.create("div",{props:{className:"bx-messenger-input-wrap bx-messenger-panel-create-input"},children:[this.chatCreateFormChatTitle=BX.create("input",{props:{className:"bx-messenger-input bx-messenger-input-dest-empty"},attrs:{type:"text",value:"",placeholder:BX.message("IM_C_CHAT_TITLE")}})]})]})]})]}),BX.create("div",{props:{className:"bx-messenger-body-dialog"},children:[this.chatCreateFormBody=BX.create("div",{props:{className:"bx-messenger-body"},style:{height:this.popupMessengerBodySize+"px"},children:[BX.create("div",{props:{className:"bx-messenger-box-create-desc"},children:[this.chatCreateFormDescription=BX.create("div",{props:{className:"bx-messenger-box-create-desc-wrap"},children:t})]})]}),BX.create("div",{props:{className:"bx-messenger-textarea-place"},children:[BX.create("div",{props:{className:"bx-messenger-textarea-resize"}}),BX.create("div",{props:{className:"bx-messenger-textarea-send"},children:[BX.create("a",{attrs:{href:"#send"},props:{className:"bx-messenger-textarea-send-button"},events:{click:BX.delegate(function(){this.createChat(this.chatCreateType,this.chatCreateUsers,this.popupCreateChatTextarea.value)},this)}}),BX.create("span",{attrs:{title:BX.message("IM_M_SEND_TYPE_TITLE")},props:{className:"bx-messenger-textarea-cntr-enter"},html:this.BXIM.settings.sendByEnter?"Enter":BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter",events:{click:BX.delegate(function(){this.BXIM.settings.sendByEnter=this.BXIM.settings.sendByEnter?false:true;this.BXIM.saveSettings({sendByEnter:this.BXIM.settings.sendByEnter});BX.proxy_context.innerHTML=this.BXIM.settings.sendByEnter?"Enter":BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter";this.popupMessengerTextareaSendType.innerHTML=BX.proxy_context.innerHTML},this)}})]}),BX.create("div",{attrs:{title:BX.message("IM_SMILE_MENU")},props:{className:"bx-messenger-textarea-smile"},events:{click:BX.delegate(function(e){this.openSmileMenu({textarea:"createChat"});return BX.PreventDefault(e)},this)}}),BX.create("div",{attrs:{title:BX.message("IM_MENTION_MENU")},props:{className:"bx-messenger-textarea-mention"},events:{click:BX.delegate(function(e){this.openMentionDialog({delay:0,textarea:"createChat"});return BX.PreventDefault(e)},this)}}),!this.disk.enable?null:BX.create("div",{attrs:{title:BX.message("IM_F_UPLOAD_MENU")},props:{className:"bx-messenger-textarea-file"},events:{click:BX.delegate(function(e){this.BXIM.openConfirm(BX.message("IM_F_ERR_NC"))},this)}}),BX.create("div",{props:{className:"bx-messenger-textarea"},children:[this.popupCreateChatTextarea=BX.create("textarea",{props:{value:"",className:"bx-messenger-textarea-input"},style:{height:this.popupMessengerTextareaSize+"px"}}),BX.create("div",{props:{className:"bx-messenger-textarea-placeholder"},html:BX.message("IM_M_TA_TEXT")})]}),BX.create("div",{props:{className:"bx-messenger-textarea-clear"}})]})]})]});if(this.desktop.ready()){BX.bind(this.popupCreateChatTextarea,"contextmenu",BX.delegate(function(e){this.openPopupMenu(e,"copypaste",false,{spell:true});return BX.PreventDefault(e)},this))}BX.bind(this.popupCreateChatTextarea,"focus",BX.delegate(function(){this.textareaCheckText({textarea:"createChat"});this.setClosingByEsc(false);BX.addClass(this.popupCreateChatTextarea.parentNode,"bx-messenger-textarea-focus")},this));BX.bind(this.popupCreateChatTextarea,"blur",BX.delegate(function(){this.textareaCheckText({textarea:"createChat"});this.setClosingByEsc(true);BX.removeClass(this.popupCreateChatTextarea.parentNode,"bx-messenger-textarea-focus")},this));BX.bind(this.chatCreateFormChatTitle,"keydown",BX.delegate(function(e){this.textareaPrepareText(BX.proxy_context,e,BX.delegate(function(){this.createChat(this.chatCreateType,this.chatCreateUsers,this.popupCreateChatTextarea.value)},this),function(){})},this));BX.bind(this.chatCreateFormChatTitle,"keydown",BX.delegate(function(e){if(e.keyCode==9||e.keyCode==13){this.popupCreateChatTextarea.focus();return BX.PreventDefault(e)}},this));BX.bind(this.popupCreateChatTextarea,"keydown",BX.delegate(function(e){this.textareaPrepareText(BX.proxy_context,e,BX.delegate(function(){this.createChat(this.chatCreateType,this.chatCreateUsers,this.popupCreateChatTextarea.value)},this),function(){})},this));BX.bind(this.popupCreateChatTextarea,"keyup",BX.delegate(function(){this.textareaCheckText({textarea:"createChat"})},this));if(this.desktop.ready()){BX.bindDelegate(this.popupMessengerBodyWrap,"contextmenu",{className:"bx-messenger-content-item-content"},BX.delegate(function(e){this.openPopupMenu(e,"dialogContext",false);return BX.PreventDefault(e)},this))}this.extraOpen(this.chatCreateForm);if(e=="open"){this.chatCreateFormChatTitle.focus()}else{this.chatCreateFormUsersInput.focus();BX.bind(this.chatCreateFormUsersInput,"keyup",BX.delegate(function(e){if(!this.popupChatDialog&&this.chatCreateFormUsersInput.value.length>0){this.openChatDialog({type:"CHAT_CREATE",bind:this.chatCreateFormUsersInput,bindResult:this.chatCreateFormUsersDest,bindSearch:this.chatCreateFormUsersInput,bindUsersList:this.chatCreateUsers,skipBind:this.chatCreateFormSkipDialogBind});this.chatCreateFormSkipDialogBind=true}},this))}}};BX.Messenger.prototype.createChat=function(e,t,s){if(this.BXIM.popupConfirm!=null){this.BXIM.popupConfirm.destroy();return false}if(e=="private"){var i=0;for(var a in t){i=t[a].id}if(i){this.openMessenger(i);this.popupMessengerTextarea.value=BX.MessengerCommon.prepareMention("create",s);this.sendMessage(i)}else{this.chatCreateFormUsersInput.focus();return false}}else{if(e=="open"){if(BX.util.trim(this.chatCreateFormChatTitle.value)==""){this.chatCreateFormChatTitle.focus();return false}this.sendRequestChatDialog({action:"CHAT_CREATE",type:"open",title:this.chatCreateFormChatTitle.value,message:BX.MessengerCommon.prepareMention("create",s)})}else{if(BX.MessengerCommon.countObject(t)<=0){this.chatCreateFormUsersInput.focus();return false}var n=[];for(var a in t)n.push(a);this.sendRequestChatDialog({action:"CHAT_CREATE",type:"chat",users:n,message:BX.MessengerCommon.prepareMention("create",s)})}}return false};BX.Messenger.prototype.kickFromChat=function(e,t){if(!this.chat[e]&&this.chat[e].owner!=this.BXIM.userId&&!this.userId[t])return false;BX.ajax({url:this.BXIM.pathToAjax+"?CHAT_LEAVE&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:{IM_CHAT_LEAVE:"Y",CHAT_ID:e,USER_ID:t,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(e.ERROR==""){for(var s=0;s<this.userInChat[e.CHAT_ID].length;s++)if(this.userInChat[e.CHAT_ID][s]==t)delete this.userInChat[e.CHAT_ID][s];if(this.popupMessenger!=null)BX.MessengerCommon.userListRedraw();if(!this.BXIM.ppServerStatus)BX.PULL.updateState(true);BX.localStorage.set("mclk",{chatId:e.CHAT_ID,userId:e.USER_ID},5)}},this)})};BX.Messenger.prototype.redrawChatHeader=function(e){if(!this.openChatFlag)return false;var t=this.currentTab.toString().substr(4);if(!this.chat[t])return false;e=e||{};e.userRedraw=e.userRedraw||true;if(this.popupMessengerFileFormChatId){this.popupMessengerFileFormChatId.value=t;if(parseInt(this.popupMessengerFileFormChatId.value)>0){this.popupMessengerFileFormInput.removeAttribute("disabled")}else{this.popupMessengerFileFormInput.setAttribute("disabled",true)}}this.renameChatDialogFlag=false;var s=[];var i=[];if(this.chat[t].type=="call"){this.popupMessengerPanelAvatar3.src=this.chat[t].avatar?this.chat[t].avatar:this.BXIM.pathToBlankImage;this.popupMessengerPanelAvatar3.className="bx-messenger-panel-avatar-img"+(BX.MessengerCommon.isBlankAvatar(this.popupMessengerPanelAvatar3.src)?" bx-messenger-panel-avatar-img-default":"");BX.style(this.popupMessengerPanelAvatar3,"background-color",BX.MessengerCommon.isBlankAvatar(this.popupMessengerPanelAvatar3.src)&&this.chat[t].color?this.chat[t].color:"");if(this.popupMessengerPanelCallTitle)this.popupMessengerPanelCallTitle.innerHTML=this.chat[t].name;this.popupMessengerPanelAvatarId3.value=t;this.disk.avatarFormIsBlocked(t,"popupMessengerPanelAvatarUpload3",this.popupMessengerPanelAvatarForm3);this.popupMessengerPanelMute3.title=this.muteButtonStatus(this.currentTab)?BX.message("IM_M_CHAT_MUTE_ON_2"):BX.message("IM_M_CHAT_MUTE_OFF_2");
this.popupMessengerPanelMute3.className="bx-messenger-panel-button bx-messenger-panel-mute "+(this.muteButtonStatus(this.currentTab)?" bx-messenger-panel-unmute":"");s.push("bx-messenger-chat-guest");s.push("bx-messenger-chat-open");s.push("bx-messenger-chat-general");s.push("bx-messenger-chat-general-first-open");s.push("bx-messenger-chat-general-access");BX.style(this.popupOpenLinesTransfer,"display","none");BX.removeClass(this.popupMessengerDialog,s.join(" "));this.popupMessengerPanelChat.className="bx-messenger-panel bx-messenger-context-chat bx-messenger-hide";this.popupMessengerPanelCall.className="bx-messenger-panel bx-messenger-context-call"}else{this.popupMessengerPanelMute2.title=this.muteButtonStatus(this.currentTab)?BX.message("IM_M_CHAT_MUTE_ON_2"):BX.message("IM_M_CHAT_MUTE_OFF_2");this.popupMessengerPanelMute2.className="bx-messenger-panel-button bx-messenger-panel-mute "+(this.muteButtonStatus(this.currentTab)?" bx-messenger-panel-unmute":"");var a=BX.MessengerCommon.isBlankAvatar(this.popupMessengerPanelAvatar2.src);this.popupMessengerPanelAvatar2.src=this.chat[t].avatar?this.chat[t].avatar:this.BXIM.pathToBlankImage;this.popupMessengerPanelAvatar2.className="bx-messenger-panel-avatar-img"+(a?" bx-messenger-panel-avatar-img-default":"");BX.style(this.popupMessengerPanelAvatar2,"background-color",BX.MessengerCommon.isBlankAvatar(this.popupMessengerPanelAvatar2.src)&&this.chat[t].color?this.chat[t].color:"");if(this.popupMessengerPanelChatTitle.className.indexOf("bx-messenger-chat-edit")==-1){this.popupMessengerPanelChatTitle.innerHTML=this.chat[t].name}this.popupMessengerPanelAvatarId2.value=t;this.disk.avatarFormIsBlocked(t,"popupMessengerPanelAvatarUpload2",this.popupMessengerPanelAvatarForm2);this.popupMessengerPanelAvatarForm2.className="bx-messenger-panel-avatar";if(this.chat[t].type=="lines"||this.chat[t].type=="livechat"||this.chat[t].type=="chat"){var n=false;if(this.chat[t].type=="livechat"){var r=BX.MessengerCommon.linesGetSession(t);BX.addClass(this.popupMessengerPanelAvatarForm2,"bx-messenger-panel-avatar-lines");BX.addClass(this.popupMessengerPanelAvatarForm2,"bx-messenger-panel-avatar-livechat");i.push("bx-messenger-chat-livechat");s.push("bx-messenger-chat-chat");s.push("bx-messenger-chat-lines");BX.style(this.popupOpenLinesTransfer,"display","none")}else if(this.chat[t].type=="lines"){this.openLinesFlag=true;var r=BX.MessengerCommon.linesGetSession(t);BX.addClass(this.popupMessengerPanelAvatarForm2,"bx-messenger-panel-avatar-lines");BX.addClass(this.popupMessengerPanelAvatarForm2,"bx-messenger-panel-avatar-"+BX.MessengerCommon.linesGetSource(t));i.push("bx-messenger-chat-lines");s.push("bx-messenger-chat-chat");s.push("bx-messenger-chat-livechat");if(this.chat[t].owner==0){BX.style(this.popupOpenLinesTransfer,"display","none");n=true}else if(this.chat[t].owner==this.BXIM.userId&&r.wait!="Y"){BX.style(this.popupOpenLinesTransfer,"display","block")}else{BX.style(this.popupOpenLinesTransfer,"display","none")}if(this.chat[t].entity_data_3=="Y"){BX.addClass(this.popupMessengerHiddenModeButton,"bx-messenger-textarea-hidden-active")}else{BX.removeClass(this.popupMessengerHiddenModeButton,"bx-messenger-textarea-hidden-active")}}else{this.openLinesFlag=false;BX.addClass(this.popupMessengerPanelAvatarForm2,"bx-messenger-panel-avatar-chat");BX.style(this.popupOpenLinesTransfer,"display","none");i.push("bx-messenger-chat-chat");s.push("bx-messenger-chat-livechat");s.push("bx-messenger-chat-lines")}if(this.chat[t].fake){n=true}if(n){i.push("bx-messenger-chat-guest")}else{s.push("bx-messenger-chat-guest")}this.popupMessengerTextarea.disabled=n;s.push("bx-messenger-chat-open");s.push("bx-messenger-chat-general");s.push("bx-messenger-chat-general-first-open");s.push("bx-messenger-chat-general-access")}else{BX.addClass(this.popupMessengerPanelAvatarForm2,"bx-messenger-panel-avatar-open");BX.style(this.popupOpenLinesTransfer,"display","none");i.push("bx-messenger-chat-open");s.push("bx-messenger-chat-chat");s.push("bx-messenger-chat-livechat");s.push("bx-messenger-chat-lines");var n=false;if(t==this.generalChatId){i.push("bx-messenger-chat-general");if(!this.canSendMessageGeneralChat){i.push("bx-messenger-chat-general-access");this.popupMessengerTextareaGeneralText.innerHTML=BX.message("IM_G_ACCESS");n=true}else if(this.BXIM.settings.generalNotify){i.push("bx-messenger-chat-general-first-open");this.popupMessengerTextareaGeneralText.innerHTML=BX.message("IM_G_JOIN").replace("#LINK_START#",'<a href="'+BX.message("IM_G_JOIN_LINK")+'" target="_blank" style="margin-left: 10px; text-decoration: underline;">').replace("#LINK_END#","</a>").replace("#ICON#",'<span class="bx-messenger-icon-notify-mute" onclick="BX.MessengerCommon.muteMessageChat(\'chat'+this.generalChatId+"');\"></span>");n=true}else{s.push("bx-messenger-chat-general-first-open");s.push("bx-messenger-chat-general-access")}}else{s.push("bx-messenger-chat-general");s.push("bx-messenger-chat-general-first-open");s.push("bx-messenger-chat-general-access")}if(this.chat[t].fake||n){this.popupMessengerTextarea.disabled=true}else if(BX.MessengerCommon.userInChat(t)){this.popupMessengerTextarea.disabled=false;s.push("bx-messenger-chat-guest")}else{this.popupMessengerTextarea.disabled=true;i.push("bx-messenger-chat-guest")}}BX.addClass(this.popupMessengerDialog,i.join(" "));BX.removeClass(this.popupMessengerDialog,s.join(" "));if(a)BX.addClass(this.popupMessengerPanelStatus2,"bx-messenger-panel-avatar-status-hide");else BX.removeClass(this.popupMessengerPanelStatus2,"bx-messenger-panel-avatar-status-hide");this.popupMessengerPanelChat.className="bx-messenger-panel bx-messenger-context-chat";this.popupMessengerPanelCall.className="bx-messenger-panel bx-messenger-context-call bx-messenger-hide"}this.popupMessengerPanel.className="bx-messenger-panel bx-messenger-context-user bx-messenger-hide";if(!this.userInChat[t]){this.popupMessengerPanelUsers.innerHTML=this.chat[t].fake?BX.message("IM_CL_LOAD"):BX.message("IM_C_EMPTY");return false}if(e.userRedraw){var o=false;this.popupMessengerPanelUsers.innerHTML="";this.userInChat[t].sort(BX.delegate(function(e,s){if(!this.users[e]||!this.users[s])return 0;p=0;if(this.users[e].status!="offline"){p+=20}if(this.chat[t].owner==e){p+=10}if(this.users[e].status=="online"){p+=5}if(this.users[e].status=="mobile"){p+=3}if(this.users[e].avatar!="/bitrix/js/im/images/blank.gif"){p+=5}if(e<s){p+=1}ii=0;if(this.users[s].status!="offline"){ii+=20}if(this.chat[t].owner==s){ii+=10}if(this.users[s].status=="online"){ii+=5}if(this.users[s].status=="mobile"){ii+=3}if(this.users[s].avatar!="/bitrix/js/im/images/blank.gif"){ii+=5}if(s<e){ii+=1}if(p<ii){return 1}else if(p>ii){return-1}else{return 0}},this));var l=this.chat[t].extranet;if(this.chat[t].extranet==""){l=false;for(var p=0;p<this.userInChat[t].length;p++){l=this.users[this.userInChat[t][p]]&&this.users[this.userInChat[t][p]].extranet}}if(this.chat[t].type=="livechat"){BX.removeClass(this.popupMessengerDialog,"bx-messenger-dialog-extranet");BX.removeClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-extranet");BX.addClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-title-lines")}else if(this.chat[t].type=="lines"){BX.removeClass(this.popupMessengerDialog,"bx-messenger-dialog-extranet");BX.removeClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-extranet");BX.addClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-title-lines");if(r.crm=="Y"){BX.style(this.popupMessengerPanelCrm,"display","inline-block")}else{BX.style(this.popupMessengerPanelCrm,"display","none")}}else if(this.chat[t].extranet){BX.addClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-extranet");BX.addClass(this.popupMessengerDialog,"bx-messenger-dialog-extranet");BX.style(this.popupMessengerPanelCrm,"display","none")}else{BX.removeClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-extranet");BX.removeClass(this.popupMessengerDialog,"bx-messenger-dialog-extranet");BX.removeClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-title-lines");BX.style(this.popupMessengerPanelCrm,"display","none")}BX.removeClass(this.popupMessengerDialog,"bx-messenger-dialog-bot");BX.removeClass(this.popupMessengerDialog,"bx-messenger-dialog-network");var h=Math.floor(this.popupMessengerPanelUsers.offsetWidth/135);if(h>=this.userInChat[t].length){for(var p=0;p<this.userInChat[t].length&&p<h;p++){var c=this.users[this.userInChat[t][p]];if(c){var u=BX.MessengerCommon.isBlankAvatar(c.avatar)?'style="background-color: '+c.color+'"':"";this.popupMessengerPanelUsers.innerHTML+='<span class="bx-messenger-panel-chat-user" data-userId="'+c.id+'">'+'<span class="bx-notifier-popup-avatar bx-notifier-popup-avatar-status-'+BX.MessengerCommon.getUserStatus(c.id)+(this.chat[t].owner==c.id?" bx-notifier-popup-avatar-owner":"")+(c.extranet?" bx-notifier-popup-avatar-extranet":"")+'">'+'<img class="bx-notifier-popup-avatar-img'+(BX.MessengerCommon.isBlankAvatar(c.avatar)?" bx-notifier-popup-avatar-img-default":"")+'" src="'+c.avatar+'" '+u+">"+'<span class="bx-notifier-popup-avatar-status-icon"></span>'+"</span>"+'<span class="bx-notifier-popup-user-name'+(c.extranet?" bx-messenger-panel-chat-user-name-extranet":"")+'">'+c.name+"</span>"+"</span>";o=true}}}else{h=Math.floor((this.popupMessengerPanelUsers.offsetWidth-10)/32);for(var p=0;p<this.userInChat[t].length&&p<h;p++){var c=this.users[this.userInChat[t][p]];if(c){var u=BX.MessengerCommon.isBlankAvatar(c.avatar)?'style="background-color: '+c.color+'"':"";this.popupMessengerPanelUsers.innerHTML+='<span class="bx-messenger-panel-chat-user" data-userId="'+c.id+'">'+'<span class="bx-notifier-popup-avatar bx-notifier-popup-avatar-status-'+BX.MessengerCommon.getUserStatus(c.id)+(this.chat[t].owner==c.id?" bx-notifier-popup-avatar-owner":"")+(c.extranet?" bx-notifier-popup-avatar-extranet":"")+'">'+'<img class="bx-notifier-popup-avatar-img'+(BX.MessengerCommon.isBlankAvatar(c.avatar)?" bx-notifier-popup-avatar-img-default":"")+'" src="'+c.avatar+'" title="'+c.name+'" '+u+">"+'<span class="bx-notifier-popup-avatar-status-icon"></span>'+"</span>"+"</span>";o=true}}if(o&&this.userInChat[t].length>h)this.popupMessengerPanelUsers.innerHTML+='<span class="bx-notifier-popup-user-more" data-last-item="'+p+'">'+BX.message("IM_M_CHAT_MORE_USER").replace("#USER_COUNT#",this.userInChat[t].length-h)+"</span>"}if(!o){this.popupMessengerPanelUsers.innerHTML=BX.message("IM_CL_LOAD")}}};BX.Messenger.prototype.updateChatAvatar=function(e,t){if(this.chat[e]&&t&&t.length>0){this.chat[e].avatar=t;this.dialogStatusRedraw();BX.MessengerCommon.userListRedraw()}return true};BX.Messenger.prototype.renameChatDialog=function(){var e=this.currentTab.toString().substr(4);if(this.renameChatDialogFlag||!BX.MessengerCommon.userInChat(e)||this.generalChatId==e)return false;this.renameChatDialogFlag=true;BX.addClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-edit");this.popupMessengerPanelChatTitle.innerHTML="";BX.adjust(this.popupMessengerPanelChatTitle,{children:[BX.create("div",{props:{className:"bx-messenger-input-wrap bx-messenger-panel-title-chat-input"},children:[this.renameChatDialogInput=BX.create("input",{props:{className:"bx-messenger-input"},attrs:{type:"text",value:BX.util.htmlspecialcharsback(this.chat[e].name)}})]})]});this.renameChatDialogInput.focus();BX.bind(this.renameChatDialogInput,"blur",BX.delegate(function(){BX.removeClass(this.popupMessengerPanelChatTitle,"bx-messenger-chat-edit");BX.MessengerCommon.renameChat(e,this.renameChatDialogInput.value);BX.remove(this.renameChatDialogInput);this.renameChatDialogInput=null;this.popupMessengerPanelChatTitle.innerHTML=this.chat[e].name;this.renameChatDialogFlag=false},this));BX.bind(this.renameChatDialogInput,"keydown",BX.delegate(function(t){if(t.keyCode==27&&!this.desktop.ready()){this.renameChatDialogInput.value=this.chat[e].name;this.popupMessengerTextarea.focus();return BX.PreventDefault(t)}else if(t.keyCode==9||t.keyCode==13){this.popupMessengerTextarea.focus();return BX.PreventDefault(t)}},this))};BX.Messenger.prototype.openMentionDialog=function(e){if(this.popupSmileMenu!=null){this.popupSmileMenu.destroy()}if(this.popupChatDialog!=null){this.popupChatDialog.close();return false}e=e||{};e.delay=e.delay||300;e.textarea=e.textarea||"default";var t=e.textarea=="createChat"?this.popupCreateChatTextarea:this.popupMessengerTextarea;t.focus();if(t.value.substr(-1)!="@"){this.insertTextareaText(t,"@")}this.mentionListen=true;this.mentionDelimiter="@";this.openChatDialog({type:"MENTION",bind:t,focus:false,delimiter:this.mentionDelimiter,delay:e.delay});this.setClosingByEsc(false)};BX.Messenger.prototype.openChatDialog=function(e){if(!this.enableGroupChat)return false;if(this.popupChatDialog!=null){this.popupChatDialog.close();return false}if(this.popupTransferDialog!=null){this.popupTransferDialog.close();return false}this.closePopupFileMenu();if(this.popupPopupMenu!=null)this.popupPopupMenu.destroy();if(this.popupSmileMenu!=null){this.popupSmileMenu.destroy()}if(this.commandPopup!=null){this.commandPopup.destroy()}if(e.type=="CHAT_EXTEND"&&this.popupMessengerTextarea.disabled){return false}var t=null;if(e.type=="CHAT_ADD"||e.type=="CHAT_EXTEND"||e.type=="CALL_INVITE_USER"||e.type=="MENTION"||e.type=="CHAT_CREATE")this.popupChatDialogDestType=e.type;else return false;var s=5;var i={offset:this.desktop.run()?39:210};var a=this.desktop.run()?this.webrtc.callActive?5:0:this.webrtc.callActive?-162:-170;this.popupChatDialogEmptyCallback=function(){};this.popupChatDialogExceptUsers=[];if(typeof e.chatId!="undefined"&&this.userInChat[e.chatId]){this.popupChatDialogExceptUsers=this.userInChat[e.chatId]}if(e.type=="MENTION"){e.maxUsers=1;s=this.desktop.run()?15:10;a=-10;i={offset:39}}else if(e.type=="CHAT_CREATE"){if(this.chatCreateType=="private"){e.maxUsers=1}this.popupChatDialogDestElements=e.bindResult;this.popupChatDialogContactListSearch=e.bindSearch;this.popupChatDialogUsers=e.bindUsersList;for(var n in this.popupChatDialogUsers){this.popupChatDialogExceptUsers.push(this.popupChatDialogUsers[n].id)}this.popupChatDialogEmptyCallback=BX.delegate(function(){if(this.popupChatDialog)this.popupChatDialog.close()},this)}this.popupChatDialogMaxChatUsers=typeof e.maxUsers=="undefined"?1e6:parseInt(e.maxUsers);if(typeof e.chatId!="undefined"&&this.userInChat[e.chatId]){this.popupChatDialogMaxChatUsers=this.popupChatDialogMaxChatUsers-this.userInChat[e.chatId].length}e.skipBind=typeof e.skipBind=="undefined"?false:e.skipBind;var r=e.bind?e.bind:null;this.popupChatDialog=new BX.PopupWindow("bx-messenger-popup-newchat",r,{lightShadow:true,closeIcon:true,offsetTop:s,offsetLeft:a,autoHide:true,bindOptions:e.type=="MENTION"?{position:"top"}:{},buttons:e.type=="MENTION"||e.type=="CHAT_CREATE"?[]:[new BX.PopupWindowButton({text:BX.message("IM_M_CHAT_BTN_JOIN"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){if(this.popupChatDialogDestType=="CHAT_ADD"){var e=[this.currentTab];for(var t in this.popupChatDialogUsers)e.push(t);this.sendRequestChatDialog({action:this.popupChatDialogDestType,users:e})}else if(this.popupChatDialogDestType=="CHAT_EXTEND"){var e=[];for(var t in this.popupChatDialogUsers)e.push(t);this.sendRequestChatDialog({action:this.popupChatDialogDestType,chatId:this.currentTab.toString().substr(4),users:e})}else if(this.popupChatDialogDestType=="CALL_INVITE_USER"){var e=[];for(var t in this.popupChatDialogUsers)e.push(t);this.webrtc.callInviteUserToChat(e)}},this)}}),new BX.PopupWindowButton({text:BX.message("IM_M_CHAT_BTN_CANCEL"),events:{click:BX.delegate(function(){this.popupChatDialog.close()},this)}})],closeByEsc:true,zIndex:200,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupChatDialog=null;this.mentionListen=false;this.mentionDelimiter="";this.popupChatDialogDestType="";if(e.type!="CHAT_CREATE"){this.popupChatDialogUsers={}}if(e.type=="MENTION"||e.type=="CHAT_CREATE"){BX.proxy_context.bindElement.focus()}else{this.popupChatDialogContactListElementsType="";this.popupChatDialogContactListElements=null}},this)},content:BX.create("div",{props:{className:"bx-messenger-popup-newchat-wrap bx-messenger-popup-newchat-wrap-style-"+e.type+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},children:[BX.create("div",{props:{className:"bx-messenger-popup-newchat-caption"},html:e.type=="MENTION"?BX.message("IM_MENTION_MENU"):BX.message("IM_M_CHAT_TITLE")}),e.type=="CHAT_CREATE"?null:BX.create("div",{props:{className:"bx-messenger-popup-newchat-box bx-messenger-popup-newchat-dest bx-messenger-popup-newchat-dest-even"+(e.type=="MENTION"?" bx-messenger-hide":"")},children:[this.popupChatDialogDestElements=BX.create("span",{props:{className:"bx-messenger-dest-items"}}),this.popupChatDialogContactListSearch=BX.create("input",{props:{className:"bx-messenger-input"},attrs:{type:"text",placeholder:BX.message(this.BXIM.bitrixIntranet?"IM_M_SEARCH_PLACEHOLDER_CP":"IM_M_SEARCH_PLACEHOLDER"),value:""}})]}),this.popupChatDialogContactListElements=BX.create("div",{props:{className:"bx-messenger-popup-newchat-box bx-messenger-popup-newchat-cl bx-messenger-recent-wrap"},children:BX.create("div",{props:{className:"bx-messenger-cl-item-load"},html:BX.message("IM_CL_LOAD")})}),e.type!="CHAT_EXTEND"?null:BX.create("div",{props:{className:"bx-messenger-popup-newchat-checkbox"},children:[this.popupChatDialogShowHistory=BX.create("input",{props:{className:"bx-messenger-checkbox"},attrs:{id:"popupChatDialogShowHistory",type:"checkbox",checked:this.BXIM.options.chatExtendShowHistory?"true":"",name:"popupChatDialogShowHistory"}}),BX.create("label",{attrs:{"for":"popupChatDialogShowHistory"},props:{className:"bx-messenger-checkbox-label"},html:BX.message("IM_M_CHAT_SHOW_HISTORY")})]})]})});this.popupChatDialog.setAngle(i);this.popupChatDialog.show();BX.addClass(this.popupChatDialog.popupContainer,"bx-messenger-mark");this.popupChatDialogContactListElementsType=e.type;BX.MessengerCommon.contactListPrepareSearch("popupChatDialogContactListElements",this.popupChatDialogContactListElements,this.popupChatDialogContactListSearch.value,{viewOffline:true,viewChat:false,viewOpenChat:this.popupChatDialogDestType=="MENTION",exceptUsers:this.popupChatDialogExceptUsers,timeout:0,callback:{empty:this.popupChatDialogEmptyCallback}});if(!e.skipBind&&e.type!="MENTION"){this.popupChatDialogContactListSearch.focus();BX.bind(this.popupChatDialogContactListSearch,"keyup",BX.delegate(function(e){if(e.keyCode==16||e.keyCode==18||e.keyCode==20||e.keyCode==244||e.keyCode==91)return false;if(e.keyCode==37||e.keyCode==39)return true;if(this.popupChatDialogContactListSearch.value!=this.popupChatDialogContactListSearchLastText||this.popupChatDialogContactListSearch.value==""){if(this.popupChatDialogContactListSearch.value==""&&this.popupChatDialog&&this.popupChatDialogDestType=="CHAT_CREATE"){this.popupChatDialog.close();return false}}else if(e.keyCode==224||e.keyCode==18||e.keyCode==17){return true}if(e.keyCode==8&&this.popupChatDialogContactListSearch.value==""){var t=null;var s=BX.util.objectSort(this.popupChatDialogUsers,"date","asc");for(var i=0;i<s.length;i++){t=s[i].id}if(t){delete this.popupChatDialogUsers[t];this.redrawChatDialogDest()}}if(e.keyCode==27&&this.popupChatDialogContactListSearch.value!="")BX.MessengerCommon.preventDefault(e);if(e.keyCode==27){if(this.BXIM.messenger.realSearch){this.BXIM.messenger.realSearchFound=true}this.popupChatDialogContactListSearch.value=""}if(e.keyCode==38||e.keyCode==40){return true}if(e.keyCode==13&&this.popupChatDialogContactListSearch.value!=""){if(this.BXIM.messenger.realSearch){this.BXIM.messenger.realSearchFound=true}var a=BX.findChildByClassName(this.popupChatDialogContactListElements,"bx-messenger-cl-item");if(a){if(this.popupChatDialogContactListSearch.value!=""){this.popupChatDialogContactListSearch.value=""}if(this.popupChatDialogUsers[a.getAttribute("data-userId")])delete this.popupChatDialogUsers[a.getAttribute("data-userId")];else this.popupChatDialogUsers[a.getAttribute("data-userId")]={id:a.getAttribute("data-userId"),date:+new Date};this.redrawChatDialogDest();if(this.popupChatDialogDestType=="CHAT_CREATE"){if(this.popupChatDialog)this.popupChatDialog.close()}}}this.popupChatDialogContactListSearchLastText=this.popupChatDialogContactListSearch.value;if(this.BXIM.messenger.realSearch){this.BXIM.messenger.realSearchFound=this.popupChatDialogContactListSearch.value.length<3}BX.MessengerCommon.contactListPrepareSearch("popupChatDialogContactListElements",this.popupChatDialogContactListElements,this.popupChatDialogContactListSearch.value,{viewOffline:true,viewChat:false,viewOpenChat:this.popupChatDialogDestType=="MENTION",exceptUsers:this.popupChatDialogExceptUsers,timeout:100,callback:{empty:this.popupChatDialogEmptyCallback}});BX.MessengerCommon.contactListRealSearch(this.popupChatDialogContactListSearch.value,BX.delegate(function(){BX.MessengerCommon.contactListPrepareSearch("popupChatDialogContactListElements",this.popupChatDialogContactListElements,this.popupChatDialogContactListSearch.value,{viewOffline:true,viewChat:false,viewOpenChat:this.popupChatDialogDestType=="MENTION",exceptUsers:this.popupChatDialogExceptUsers,timeout:100,callback:{empty:this.popupChatDialogEmptyCallback}})},this));if(this.popupChatDialog)this.popupChatDialog.adjustPosition()},this));BX.bindDelegate(this.popupChatDialogDestElements,"click",{className:"bx-messenger-dest-del"},BX.delegate(function(){delete this.popupChatDialogUsers[BX.proxy_context.getAttribute("data-userId")];if(BX.MessengerCommon.countObject(this.popupChatDialogUsers)<this.popupChatDialogMaxChatUsers)BX.show(this.popupChatDialogContactListSearch);this.redrawChatDialogDest()},this))}BX.bindDelegate(this.popupChatDialogContactListElements,"click",{className:"bx-messenger-cl-item"},BX.delegate(function(t){if(this.popupChatDialogContactListSearch.value!=""){this.popupChatDialogContactListSearch.value="";if(this.popupChatDialogDestType!="MENTION"&&this.popupChatDialogDestType!="CHAT_CREATE"){BX.MessengerCommon.contactListPrepareSearch("popupChatDialogContactListElements",this.popupChatDialogContactListElements,this.popupChatDialogContactListSearch.value,{viewOffline:true,viewChat:false,viewOpenChat:false,exceptUsers:this.popupChatDialogExceptUsers})}}if(this.popupChatDialogUsers[BX.proxy_context.getAttribute("data-userId")]){delete this.popupChatDialogUsers[BX.proxy_context.getAttribute("data-userId")]}else{if(BX.MessengerCommon.countObject(this.popupChatDialogUsers)==this.popupChatDialogMaxChatUsers)return false;this.popupChatDialogUsers[BX.proxy_context.getAttribute("data-userId")]={id:BX.proxy_context.getAttribute("data-userId"),date:+new Date}}if(this.popupChatDialogDestType=="MENTION"){var s=r.value.substr(0,r.selectionEnd);s=s.substr(s.lastIndexOf(e.delimiter),r.selectionEnd-s.lastIndexOf(e.delimiter));r.value=r.value.replace(s,BX.proxy_context.getAttribute("data-name")+" ");BX.MessengerCommon.addMentionList(this.currentTab,BX.proxy_context.getAttribute("data-name"),BX.proxy_context.getAttribute("data-userId"));if(this.popupChatDialog)this.popupChatDialog.close()}else{this.redrawChatDialogDest()}if(this.popupChatDialogDestType=="CHAT_CREATE"){if(this.popupChatDialog)this.popupChatDialog.close()}return BX.PreventDefault(t)},this))};BX.Messenger.prototype.redrawChatDialogDest=function(){var e="";var t=0;var s=0;var i=BX.util.objectSort(this.popupChatDialogUsers,"date","asc");for(var a=0;a<i.length;a++){s=i[a].id;t++;e+='<span class="bx-messenger-dest-block'+(this.users[s].extranet?" bx-messenger-dest-block-extranet":"")+'">'+'<span class="bx-messenger-dest-text">'+this.users[s].name+"</span>"+'<span class="bx-messenger-dest-del" data-userId="'+s+'"></span></span>'}this.popupChatDialogDestElements.innerHTML=e;this.popupChatDialogDestElements.parentNode.scrollTop=this.popupChatDialogDestElements.parentNode.offsetHeight;if(this.popupChatDialogDestType!="CHAT_CREATE"){if(BX.util.even(t))BX.addClass(this.popupChatDialogDestElements.parentNode,"bx-messenger-popup-newchat-dest-even");else BX.removeClass(this.popupChatDialogDestElements.parentNode,"bx-messenger-popup-newchat-dest-even")}var n=BX.MessengerCommon.countObject(this.popupChatDialogUsers);if(n>=this.popupChatDialogMaxChatUsers){BX.addClass(this.popupChatDialogContactListSearch,"bx-messenger-hide");if(this.popupChatDialogDestType=="CHAT_CREATE"){if(this.popupChatDialog)this.popupChatDialog.close();this.popupCreateChatTextarea.focus()}}else{BX.removeClass(this.popupChatDialogContactListSearch,"bx-messenger-hide");if(this.popupChatDialog)this.popupChatDialog.adjustPosition();this.popupChatDialogContactListSearch.focus()}if(n){BX.removeClass(this.popupChatDialogContactListSearch,"bx-messenger-input-dest-empty")}else{BX.addClass(this.popupChatDialogContactListSearch,"bx-messenger-input-dest-empty")}};BX.Messenger.prototype.sendRequestChatDialog=function(e){if(this.popupChatDialogSendBlock)return false;if(typeof e!="object")return false;e.type=e.type=="open"?"open":"chat";e.users=e.users||[];e.message=e.message||"";e.title=e.title||"";var t=[];for(var s=0;s<e.users.length;s++){if(e.users[s].toString().substr(0,7)!="network"){e.users[s]=parseInt(e.users[s]);if(e.users[s]<0)continue}if(t.indexOf&&t.indexOf(e.users[s])>=0)continue;if(e.users[s]==this.BXIM.userId)continue;if(e.chatId&&this.userInChat[e.chatId].indexOf&&this.userInChat[e.chatId].indexOf(e.users[s].toString())>=0)continue;t.push(e.users[s])}e.users=t;var i="";if(e.action=="CHAT_CREATE"&&e.type=="chat"&&e.users.length<1){i=BX.message("IM_M_CHAT_ERROR_1")}if(e.action=="CHAT_ADD"&&e.type=="chat"&&e.users.length<=1){if(e.users[0]&&this.users[e.users[0]]){this.openMessenger(e.users[0]);if(this.popupChatDialog!=null)this.popupChatDialog.close();return false}else{i=BX.message("IM_M_CHAT_ERROR_1")}}else if(e.action=="CHAT_EXTEND"&&e.users.length==0){if(this.popupChatDialog!=null)this.popupChatDialog.close();return false}if(e.action=="CHAT_CREATE"){e.action="CHAT_ADD"}if(i!=""){this.BXIM.openConfirm(i);return false}this.popupChatDialogSendBlock=true;if(this.popupChatDialog!=null)this.popupChatDialog.buttons[0].setClassName("popup-window-button-disable");var a=false;if(e.action=="CHAT_ADD")a={IM_CHAT_ADD:"Y",TYPE:e.type,TITLE:e.title,MESSAGE:e.message,USERS:JSON.stringify(e.users),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()};else if(e.action=="CHAT_EXTEND")a={IM_CHAT_EXTEND:"Y",CHAT_ID:e.chatId,HISTORY:this.popupChatDialogShowHistory.checked?"Y":"N",USERS:JSON.stringify(e.users),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()};if(!a)return false;BX.ajax({url:this.BXIM.pathToAjax+"?"+e.action+"&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:a,onsuccess:BX.delegate(function(e){this.popupChatDialogSendBlock=false;if(this.popupChatDialog!=null)this.popupChatDialog.buttons[0].setClassName("popup-window-button-accept");if(e.ERROR==""){if(!this.BXIM.ppServerStatus)BX.PULL.updateState(true);if(e.CHAT_ID){if(this.BXIM.ppServerStatus&&this.currentTab!="chat"+e.CHAT_ID){this.openMessenger("chat"+e.CHAT_ID)}else if(!this.BXIM.ppServerStatus&&this.currentTab!="chat"+e.CHAT_ID){setTimeout(BX.delegate(function(){this.openMessenger("chat"+e.CHAT_ID)},this),500)}}this.popupChatDialogSendBlock=false;if(this.popupChatDialog!=null)this.popupChatDialog.close()}else{this.BXIM.openConfirm(e.ERROR)}},this)})};BX.Messenger.prototype.openContactList=function(){return this.openMessenger()};BX.Messenger.prototype.openPopupMenu=function(e,t,s,i){i=i?i:{};var a=i.closeSmiles===false?false:true;if(a&&this.popupSmileMenu!=null)this.popupSmileMenu.destroy();this.closePopupFileMenu();if(this.popupPopupMenu!=null){this.popupPopupMenu.destroy();return false}var n=0;var r=13;var o=[];var l={};var p={offset:4};this.popupPopupMenuStyle="";if(i.offsetTop)n=i.offsetTop;if(i.offsetLeft)r=i.offsetLeft;if(i.anglePosition)p.position=i.anglePosition;if(t=="createChat"){l={position:"bottom"};if(i.openDesktop){o=[{icon:"bx-messenger-cc-private",text:BX.message("IM_CL_PRIVATE_CHAT"),onclick:BX.delegate(function(){BX.desktopUtils.goToBx("bx://chat/create/private");this.closeMenuPopup()},this)},{icon:"bx-messenger-cc-chat",text:BX.message("IM_CL_CHAT_2"),onclick:BX.delegate(function(){BX.desktopUtils.goToBx("bx://chat/create/chat");this.closeMenuPopup()},this)},this.BXIM.userExtranet||!this.openChatEnable?null:{icon:"bx-messenger-cc-open",text:BX.message("IM_CL_OPEN_CHAT"),onclick:BX.delegate(function(){BX.desktopUtils.goToBx("bx://chat/create/open");this.closeMenuPopup()},this)}]}else if(i.openMessenger){o=[{icon:"bx-messenger-cc-private",text:BX.message("IM_CL_PRIVATE_CHAT"),onclick:BX.delegate(function(){this.openMessenger();this.openChatCreateForm("private");this.closeMenuPopup()},this)},{icon:"bx-messenger-cc-chat",text:BX.message("IM_CL_CHAT_2"),onclick:BX.delegate(function(){this.openMessenger();this.openChatCreateForm("chat");this.closeMenuPopup()},this)},this.BXIM.userExtranet||!this.openChatEnable?null:{icon:"bx-messenger-cc-open",text:BX.message("IM_CL_OPEN_CHAT"),onclick:BX.delegate(function(){this.openMessenger();this.openChatCreateForm("open");this.closeMenuPopup()},this)}]}else{o=[{icon:"bx-messenger-cc-private",text:BX.message("IM_CL_PRIVATE_CHAT"),onclick:BX.delegate(function(){this.openChatCreateForm("private");this.closeMenuPopup()},this)},{icon:"bx-messenger-cc-chat",text:BX.message("IM_CL_CHAT_2"),onclick:BX.delegate(function(){this.openChatCreateForm("chat");this.closeMenuPopup()},this)},this.BXIM.userExtranet||!this.openChatEnable?null:{icon:"bx-messenger-cc-open",text:BX.message("IM_CL_OPEN_CHAT"),onclick:BX.delegate(function(){this.openChatCreateForm("open");this.closeMenuPopup()},this)}]}}else if(t=="openLinesMenu"){var h=this.currentTab.toString().substr(4);var c=this.chat[h].owner==this.BXIM.userId;var u=BX.MessengerCommon.linesGetSession(h);n=5;r=14;o=[c&&u.wait=="N"?{icon:"bx-messenger-menu-pin",text:BX.message(u.pin=="Y"?"IM_M_OL_PIN_OFF":"IM_M_OL_PIN_ON"),onclick:BX.delegate(function(){this.linesTogglePinMode();this.closeMenuPopup()},this)}:null,c&&u.crm!="Y"?{icon:"bx-messenger-menu-crm",text:BX.message("IM_M_OL_ADD_LEAD"),onclick:BX.delegate(function(){this.linesCreateLead();this.closeMenuPopup()},this)}:null,u.crmLink?{icon:"bx-messenger-menu-crm",text:BX.message("IM_M_OL_GOTO_CRM"),href:u.crmLink,target:"_blank",onclick:BX.delegate(function(){this.closeMenuPopup()},this)}:null,c&&u.wait=="N"?{icon:"bx-messenger-menu-close",text:BX.message("IM_M_OL_CLOSE"),onclick:BX.delegate(function(){this.linesCloseDialog();this.closeMenuPopup()},this)}:null,{icon:"bx-messenger-menu-history-2",text:BX.message("IM_M_HISTORY"),onclick:BX.delegate(function(){this.openHistory(this.currentTab);this.closeMenuPopup()},this)}]}else if(t=="status"){r=9;l={position:"top"};o=[{icon:"bx-messenger-status-online",text:BX.message("IM_STATUS_ONLINE"),onclick:BX.delegate(function(){this.setStatus("online");this.closeMenuPopup()},this)},{icon:"bx-messenger-status-away",text:BX.message("IM_STATUS_AWAY"),onclick:BX.delegate(function(){this.setStatus("away");this.closeMenuPopup()},this)},{icon:"bx-messenger-status-dnd",text:BX.message("IM_STATUS_DND"),onclick:BX.delegate(function(){this.setStatus("dnd");this.closeMenuPopup()},this)}]}else if(t=="iconMenu"){var d=e.getAttribute("data-id");o=[{text:BX.message("IM_MENU_DELETE"),onclick:BX.delegate(function(t){this.removeRecentSmile(d);BX.remove(e);this.popupPopupMenu.close();return BX.PreventDefault(t)},this)}]}else if(t=="notifyDelete"){var m=e.getAttribute("data-notifyId");var g=this.notify.notify[m].settingName;var f=typeof this.BXIM.settingsNotifyBlocked[g]=="undefined"?BX.message("IM_NOTIFY_DELETE_2"):BX.message("IM_NOTIFY_DELETE_3");if(typeof i.applyToDom!="undefined"){e=i.applyToDom}o=[this.notify.unreadNotify[m]?{text:BX.message("IM_MENU_READ"),onclick:BX.delegate(function(){this.notify.viewNotify(m,true);this.closeMenuPopup()},this)}:null,!this.notify.unreadNotify[m]?{text:BX.message("IM_MENU_UNREAD"),onclick:BX.delegate(function(){this.notify.viewNotify(m,false);
this.closeMenuPopup()},this)}:null,{text:BX.message("IM_NOTIFY_DELETE_1"),onclick:BX.delegate(function(){this.notify.deleteNotify(m);this.closeMenuPopup()},this)},{text:f,onclick:BX.delegate(function(){this.notify.blockNotifyType(g);this.closeMenuPopup()},this)}]}else if(t=="callMenu"){n=2;r=20;o=[{icon:"bx-messenger-menu-call-video",text:BX.message("IM_M_CALL_VIDEO"),onclick:BX.delegate(function(){this.webrtc.callInvite(this.currentTab,true);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-call-voice",text:BX.message("IM_M_CALL_VOICE"),onclick:BX.delegate(function(){this.BXIM.callTo(this.currentTab,false);this.closeMenuPopup()},this)}];if(this.BXIM.webrtc.callServerEnabled){o.push({separator:true});o.push({icon:"bx-messenger-menu-call-video",text:BX.message("IM_CALL_EXPERIMENTAL_BUTTON"),onclick:BX.delegate(function(){this.BXIM.webrtc.callInviteExperimental(this.currentTab,true);this.closeMenuPopup()},this)})}if(this.BXIM.webrtc.phoneCanCallUserNumber&&!this.openChatFlag&&this.phones[this.currentTab]){o.push({separator:true});if(this.phones[this.currentTab].PERSONAL_MOBILE){o.push({type:"call",text:BX.message("IM_PHONE_PERSONAL_MOBILE"),phone:BX.util.htmlspecialchars(this.phones[this.currentTab].PERSONAL_MOBILE),onclick:BX.delegate(function(){this.BXIM.phoneTo(this.phones[this.currentTab].PERSONAL_MOBILE);this.closeMenuPopup()},this)})}if(this.phones[this.currentTab].PERSONAL_PHONE){o.push({type:"call",text:BX.message("IM_PHONE_PERSONAL_PHONE"),phone:BX.util.htmlspecialchars(this.phones[this.currentTab].PERSONAL_PHONE),onclick:BX.delegate(function(){this.BXIM.phoneTo(this.phones[this.currentTab].PERSONAL_PHONE);this.closeMenuPopup()},this)})}if(this.phones[this.currentTab].WORK_PHONE){o.push({type:"call",text:BX.message("IM_PHONE_WORK_PHONE"),phone:BX.util.htmlspecialchars(this.phones[this.currentTab].WORK_PHONE),onclick:BX.delegate(function(){this.BXIM.phoneTo(this.phones[this.currentTab].WORK_PHONE);this.closeMenuPopup()},this)})}if(this.phones[this.currentTab].INNER_PHONE){o.push({type:"call",text:BX.message("IM_PHONE_INNER_PHONE"),phone:BX.util.htmlspecialchars(this.phones[this.currentTab].INNER_PHONE),onclick:BX.delegate(function(){this.BXIM.phoneTo(this.phones[this.currentTab].INNER_PHONE);this.closeMenuPopup()},this)})}}}else if(t=="callPhoneMenu"){n=2;r=25;o=[{icon:"bx-messenger-menu-call-"+(i.video?"video":"voice"),text:"<b>"+BX.message("IM_M_CALL_BTN_RECALL_3")+"</b>",onclick:BX.delegate(function(){this.webrtc.callInvite(i.userId,i.video)},this)}];o.push({separator:true});if(this.phones[i.userId]&&this.BXIM.webrtc.phoneCanCallUserNumber){o.push({separator:true});if(this.phones[i.userId].PERSONAL_MOBILE){o.push({type:"call",text:BX.message("IM_PHONE_PERSONAL_MOBILE"),phone:BX.util.htmlspecialchars(this.phones[i.userId].PERSONAL_MOBILE),onclick:BX.delegate(function(){this.BXIM.phoneTo(this.phones[i.userId].PERSONAL_MOBILE);this.closeMenuPopup()},this)})}if(this.phones[i.userId].PERSONAL_PHONE){o.push({type:"call",text:BX.message("IM_PHONE_PERSONAL_PHONE"),phone:BX.util.htmlspecialchars(this.phones[i.userId].PERSONAL_PHONE),onclick:BX.delegate(function(){this.BXIM.phoneTo(this.phones[i.userId].PERSONAL_PHONE);this.closeMenuPopup()},this)})}if(this.phones[i.userId].WORK_PHONE){o.push({type:"call",text:BX.message("IM_PHONE_WORK_PHONE"),phone:BX.util.htmlspecialchars(this.phones[i.userId].WORK_PHONE),onclick:BX.delegate(function(){this.BXIM.phoneTo(this.phones[i.userId].WORK_PHONE);this.closeMenuPopup()},this)})}}}else if(t=="callTransferMenu"){n=2;r=25;o=[{icon:"bx-messenger-menu-call-voice",text:BX.message("IM_PHONE_INNER_CALL"),onclick:BX.delegate(function(){this.BXIM.webrtc.phoneTransferType="user";this.BXIM.webrtc.phoneTransferPhone="";this.BXIM.webrtc.sendInviteTransfer()},this)}];if(this.phones[i.userId]){o.push({separator:true});if(this.phones[i.userId].PERSONAL_MOBILE){o.push({type:"call",text:BX.message("IM_PHONE_PERSONAL_MOBILE"),phone:BX.util.htmlspecialchars(this.phones[i.userId].PERSONAL_MOBILE),onclick:BX.delegate(function(){this.closeMenuPopup();this.BXIM.webrtc.phoneTransferType="phone";this.BXIM.webrtc.phoneTransferPhone=this.phones[i.userId].PERSONAL_MOBILE;this.BXIM.webrtc.sendInviteTransfer()},this)})}if(this.phones[i.userId].PERSONAL_PHONE){o.push({type:"call",text:BX.message("IM_PHONE_PERSONAL_PHONE"),phone:BX.util.htmlspecialchars(this.phones[i.userId].PERSONAL_PHONE),onclick:BX.delegate(function(){this.closeMenuPopup();this.BXIM.webrtc.phoneTransferType="phone";this.BXIM.webrtc.phoneTransferPhone=this.phones[i.userId].PERSONAL_PHONE;this.BXIM.webrtc.sendInviteTransfer()},this)})}if(this.phones[i.userId].WORK_PHONE){o.push({type:"call",text:BX.message("IM_PHONE_WORK_PHONE"),phone:BX.util.htmlspecialchars(this.phones[i.userId].WORK_PHONE),onclick:BX.delegate(function(){this.closeMenuPopup();this.BXIM.webrtc.phoneTransferType="phone";this.BXIM.webrtc.phoneTransferPhone=this.phones[i.userId].WORK_PHONE;this.BXIM.webrtc.sendInviteTransfer()},this)})}}}else if(t=="chatUser"){var B=e.getAttribute("data-userId");var h=this.currentTab.toString().substr(4);var c=this.chat[h].owner==this.BXIM.userId;if(B==this.BXIM.userId){var X=h==this.generalChatId||this.chat[h].type=="lines"&&(this.chat[h].owner==0||this.chat[h].owner==this.BXIM.userId);o=[{icon:"bx-messenger-menu-profile",text:BX.message("IM_M_OPEN_PROFILE"),href:this.BXIM.path.profile,onclick:BX.delegate(function(){this.closeMenuPopup()},this)},X?null:{icon:"bx-messenger-menu-chat-exit",text:BX.message("IM_M_CHAT_EXIT"),onclick:BX.delegate(function(){BX.MessengerCommon.leaveFromChat(h);this.closeMenuPopup()},this)}]}else if(this.chat[h].type=="lines"&&this.users[B].connector){var u=BX.MessengerCommon.linesGetSession(h);o=[{icon:"bx-messenger-menu-chat-put",text:BX.message("IM_M_CHAT_PUT"),onclick:BX.delegate(function(){this.insertTextareaText(this.popupMessengerTextarea," "+BX.util.htmlspecialcharsback(this.users[B].name)+" ",false);BX.MessengerCommon.addMentionList(this.currentTab,BX.util.htmlspecialcharsback(this.users[B].name),B);this.popupMessengerTextarea.focus();this.closeMenuPopup()},this)},c&&u.crm!="Y"?{icon:"bx-messenger-menu-crm",text:BX.message("IM_M_OL_ADD_LEAD"),onclick:BX.delegate(function(){this.linesCreateLead();this.closeMenuPopup()},this)}:null,u.crmLink?{icon:"bx-messenger-menu-crm",text:BX.message("IM_M_OL_GOTO_CRM"),href:u.crmLink,target:"_blank",onclick:BX.delegate(function(){this.closeMenuPopup()},this)}:null]}else{var y=this.chat[h].owner==this.BXIM.userId;var b=true;if(h!=this.generalChatId){b=BX.MessengerCommon.userInChat(h)}else if(!this.canSendMessageGeneralChat||this.BXIM.settings.generalNotify){b=false}if(y&&this.chat[h].type=="open"){y=this.users[B].extranet?true:false}o=[!b?null:{icon:"bx-messenger-menu-chat-put",text:BX.message("IM_M_CHAT_PUT"),onclick:BX.delegate(function(){this.insertTextareaText(this.popupMessengerTextarea," "+BX.util.htmlspecialcharsback(this.users[B].name)+" ",false);BX.MessengerCommon.addMentionList(this.currentTab,BX.util.htmlspecialcharsback(this.users[B].name),B);this.popupMessengerTextarea.focus();this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-write",text:BX.message("IM_M_WRITE_MESSAGE"),onclick:BX.delegate(function(){this.openMessenger(B);this.closeMenuPopup()},this)},!this.webrtc.callSupport(B,this)||this.webrtc.callInit?null:{icon:"bx-messenger-menu-video",text:BX.message("IM_M_CALL_VIDEO"),onclick:BX.delegate(function(){this.BXIM.callTo(B,true);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-history",text:BX.message("IM_M_OPEN_HISTORY"),onclick:BX.delegate(function(){this.openHistory(B);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-profile",text:BX.message("IM_M_OPEN_PROFILE"),href:this.users[B].profile,onclick:BX.delegate(function(){this.closeMenuPopup()},this)},y?{icon:"bx-messenger-menu-chat-exit",text:BX.message("IM_M_CHAT_KICK"),onclick:BX.delegate(function(){this.kickFromChat(h,B);this.closeMenuPopup()},this)}:{}]}}else if(t=="contactList"){n=2;r=25;var B=e.getAttribute("data-userId");var I=e.getAttribute("data-userIsChat");if(this.recentList||I){var M=BX.message("IM_M_CHAT_MUTE_OFF");var v=false;if(I){v=true}else if(this.users[B].extranet){v=true}if(v&&this.muteButtonStatus(B)){M=BX.message("IM_M_CHAT_MUTE_ON")}hideItem=BX.MessengerCommon.userInChat(B.toString().substr(4))?false:true;o=[{icon:"bx-messenger-menu-write",text:BX.message("IM_M_WRITE_MESSAGE"),onclick:BX.delegate(function(){this.openMessenger(B);this.closeMenuPopup()},this)},!this.webrtc.callSupport(B,this)||this.webrtc.callInit||I&&(this.chat[B.toString().substr(4)].type=="call"||this.chat[B.toString().substr(4)].type=="lines")?null:{icon:"bx-messenger-menu-video",text:BX.message("IM_M_CALL_VIDEO"),onclick:BX.delegate(function(){this.BXIM.callTo(B,true);this.closeMenuPopup()},this)},hideItem&&!I?null:{icon:"bx-messenger-menu-history",text:BX.message("IM_M_OPEN_HISTORY"),onclick:BX.delegate(function(){this.openHistory(B);this.closeMenuPopup()},this)},!I?{icon:"bx-messenger-menu-profile",text:BX.message("IM_M_OPEN_PROFILE"),href:this.users[B].profile,onclick:BX.delegate(function(){this.closeMenuPopup()},this)}:{},!hideItem&&v?{icon:"bx-messenger-menu-chat-mute",text:M,onclick:BX.delegate(function(){BX.MessengerCommon.muteMessageChat(B);this.closeMenuPopup()},this)}:{},!hideItem&&I&&this.chat[B.toString().substr(4)].type!="call"&&B.toString().substr(4)!=this.generalChatId?{icon:"bx-messenger-menu-chat-rename",text:BX.message("IM_M_CHAT_RENAME"),onclick:BX.delegate(function(){if(this.currentTab!=B){this.openMessenger(B)}else{this.renameChatDialog()}this.closeMenuPopup()},this)}:{},I&&(B.toString().substr(4)==this.generalChatId||!this.recentList)?null:{icon:"bx-messenger-menu-hide-"+(I?"chat":"dialog"),text:BX.message("IM_M_HIDE_"+(I?this.chat[B.toString().substr(4)].type=="call"?"CALL":"CHAT":"DIALOG")),onclick:BX.delegate(function(){BX.MessengerCommon.recentListHide(B);this.closeMenuPopup()},this)},!hideItem&&I&&this.chat[B.toString().substr(4)].type!="call"&&this.chat[B.toString().substr(4)].type!="lines"&&B.toString().substr(4)!=this.generalChatId?{icon:"bx-messenger-menu-chat-exit",text:BX.message("IM_M_CHAT_EXIT"),onclick:BX.delegate(function(){BX.MessengerCommon.leaveFromChat(B.toString().substr(4));this.closeMenuPopup()},this)}:{}]}else{o=[{icon:"bx-messenger-menu-write",text:BX.message("IM_M_WRITE_MESSAGE"),onclick:BX.delegate(function(){this.openMessenger(B);this.closeMenuPopup()},this)},!I&&(!this.webrtc.callSupport(B,this)||this.webrtc.callInit)?null:{icon:"bx-messenger-menu-video",text:BX.message("IM_M_CALL_VIDEO"),onclick:BX.delegate(function(){this.BXIM.callTo(B,true);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-history",text:BX.message("IM_M_OPEN_HISTORY"),onclick:BX.delegate(function(){this.openHistory(B);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-profile",text:BX.message("IM_M_OPEN_PROFILE"),href:this.users[B].profile,onclick:BX.delegate(function(){this.closeMenuPopup()},this)}]}}else if(t=="dialogContext"||t=="dialogMenu"){var C=[];if(t=="dialogMenu"){this.popupPopupMenuStyle="bx-messenger-content-item-menu-hover";p={offset:13};if(e.nextSibling){C=[e.nextSibling]}}else{var x=false;if(e.target.className.indexOf("bx-messenger-file")>=0||e.target.className.indexOf("bx-bxu-proper-canvas")>=0){var T=BX.findParent(e.target,{className:"bx-messenger-file-box"});if(T&&T.previousSibling){x=true;C=[T.previousSibling]}}if(!x){if(BX.hasClass(e.target,"bx-messenger-message")){C=[e.target]}else if(e.target.className.indexOf("bx-messenger-content-quote")>=0){C=BX.findParent(e.target,{className:"bx-messenger-message"});C=[C]}else{C=BX.findChildrenByClassName(e.target,"bx-messenger-message")}if(C.length<=0){C=BX.findParent(e.target,{className:"bx-messenger-message"});if(!C){if(e.target.className.substr(0,19)=="bx-messenger-attach"){var S=BX.findParent(e.target,{className:"bx-messenger-attach-box"});C=S.previousSibling}}C=[C]}}}if(C.length<=0||!C[C.length-1])return false;var _=BX.message("IM_M_SYSTEM_USER");var N=C[C.length-1].id.replace("im-message-","");if(this.message[N].senderId&&this.users[this.message[N].senderId])_=this.users[this.message[N].senderId].name;if(N.substr(0,4)=="temp")return false;var E=this.message[N].date;var k=t=="dialogContext"?BX.desktop.clipboardSelected():{text:"",selectionStart:0,selectionEnd:0};var A=false;var w="";var B=this.message[N].senderId;if(this.openChatFlag&&this.message[N].senderId!=this.BXIM.userId&&this.users[this.message[N].senderId]){w=this.users[this.message[N].senderId].name}var O=null;var L="";if(t=="dialogContext"&&(e.target.tagName=="SPAN"&&e.target.parentNode.parentNode.tagName=="A"||e.target.tagName=="CANVAS"&&e.target.parentNode.tagName=="A"||e.target.tagName=="IMG"&&e.target.parentNode.tagName=="A"||e.target.tagName=="A")){if(e.target.tagName=="A")L=e.target.href;else if(e.target.parentNode.tagName=="A")L=e.target.parentNode.href;else if(e.target.parentNode.parentNode.tagName=="A")L=e.target.parentNode.parentNode.href;if(L.indexOf("/desktop_app/")<0)A=true}else if(t=="dialogContext"&&e.target.tagName=="IMG"&&e.target.classList.contains("bx-icon")){O=e.target.src}var D=this.message[N].params.FILE_ID&&this.message[N].params.FILE_ID.length>0&&BX.clipboard.isCopySupported();var P=false;if(t=="dialogContext"&&BX.desktop){P=true}var R=false;var H=false;if(BX.MessengerCommon.checkEditMessage(N)){R=true;H=true}if(this.openChatFlag&&this.message[N].chatId&&!BX.MessengerCommon.userInChat(this.message[N].chatId)){return false}var U=false;if(this.openChatFlag&&this.message[N].chatId&&this.generalChatId==this.message[N].chatId){if(this.BXIM.isAdmin&&!this.message[N].isNowDeleted){H=true}if(!this.canSendMessageGeneralChat){U=true}}o=[w.length<=0||U?null:{text:BX.message("IM_MENU_ANSWER"),onclick:BX.delegate(function(e){this.insertTextareaText(this.popupMessengerTextarea," "+BX.util.htmlspecialcharsback(w)+" ",false);BX.MessengerCommon.addMentionList(this.currentTab,BX.util.htmlspecialcharsback(w),B);setTimeout(BX.delegate(function(){this.popupMessengerTextarea.focus()},this),200);this.closeMenuPopup()},this)},w.length<=0||U?null:{separator:true},A?{text:BX.message("IM_MENU_COPY3"),onclick:BX.delegate(function(){BX.clipboard.copy(L);this.closeMenuPopup()},this)}:null,D?{text:BX.message("IM_MENU_COPY_FILE"),onclick:BX.delegate(function(){var e="";for(var t=0;t<this.message[N].params.FILE_ID.length;t++){e=e+"[DISK="+this.message[N].params.FILE_ID[t]+"]"}BX.clipboard.copy(e);this.closeMenuPopup()},this)}:null,O?{text:BX.message("IM_SETTINGS_SAVE"),onclick:BX.delegate(function(){this.addRecentSmile(this.message[N].text,O);this.closeMenuPopup()},this)}:null,O||D||A&&this.message[N].text?{separator:true}:null,B==this.BXIM.userId||k.text.length>0?null:{text:BX.message("IM_MENU_UNREAD"),onclick:BX.delegate(function(){BX.MessengerCommon.unreadMessage(N);this.closeMenuPopup()},this)},B==this.BXIM.userId?null:{separator:true},k.text.length<=0||U?null:{text:BX.message("IM_MENU_QUOTE"),onclick:BX.delegate(function(){var e=BX.IM.getSelectionText();this.insertQuoteText(_,E,e);this.closeMenuPopup()},this)},U||!this.message[N].text&&this.message[N].params.FILE_ID.length<=0?null:{text:BX.message("IM_MENU_QUOTE2"),onclick:BX.delegate(function(){var e=[];for(var t=0;t<C.length;t++){var s=C[t].id.replace("im-message-","");if(this.message[s]){if(this.message[s].text){e.push(BX.MessengerCommon.prepareTextBack(this.message[s].text))}if(this.message[s].params&&this.message[s].params.FILE_ID){for(var i=0;i<this.message[s].params.FILE_ID.length;i++){var a=this.message[s].params.FILE_ID[i];var n=this.message[s].chatId;if(this.disk.files[n][a]){e.push("["+BX.message("IM_F_FILE")+": "+this.disk.files[n][a].name+"]")}}}}}if(e.length>0){this.insertQuoteText(_,E,e.join("\n"))}this.closeMenuPopup()},this)},P&&(k.text.length||this.message[N].text)?{separator:true}:null,!P||k.text.length<=0?null:{text:BX.message("IM_MENU_COPY"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy();this.closeMenuPopup()},this)},!P||!this.message[N].text?null:{text:BX.message("IM_MENU_COPY2"),onclick:BX.delegate(function(){var e=[];for(var t=0;t<C.length;t++){var s=C[t].id.replace("im-message-","");if(this.message[s]){if(this.message[s].text){e.push(BX.MessengerCommon.prepareTextBack(this.message[s].text))}if(this.message[s].params&&this.message[s].params.FILE_ID){for(var i=0;i<this.message[s].params.FILE_ID.length;i++){var a=this.message[s].params.FILE_ID[i];var n=this.message[s].chatId;if(this.disk.files[n][a]){e.push("["+BX.message("IM_F_FILE")+": "+this.disk.files[n][a].name+"]")}}}}}if(e.length>0){BX.desktop.clipboardCopy(BX.delegate(function(t){return this.insertQuoteText(_,E,e.join("\n"),false)},this))}this.closeMenuPopup()},this)},R||H?{separator:true}:null,!R||this.message[N].senderId!=this.BXIM.userId?null:{text:BX.message("IM_MENU_EDIT"),onclick:BX.delegate(function(){this.editMessage(N);this.closeMenuPopup()},this)},!H?null:{text:BX.message("IM_M_HISTORY_DELETE"),onclick:BX.delegate(function(){this.deleteMessage(N);this.closeMenuPopup()},this)}]}else if(t=="history"){var C=[];if(e.target.className=="bx-messenger-history-item"){C=[e.target]}else if(e.target.className.indexOf("bx-messenger-content-quote")>=0){C=BX.findParent(e.target,{className:"bx-messenger-history-item"});C=[C]}else{C=BX.findChildrenByClassName(e.target,"bx-messenger-history-item")}if(C.length<=0){C=BX.findParent(e.target,{className:"bx-messenger-history-item"});C=[C]}if(C.length<=0||!C[C.length-1])return false;var _=BX.message("IM_M_SYSTEM_USER");var N=C[C.length-1].getAttribute("data-messageId");if(this.message[N].senderId&&this.users[this.message[N].senderId])_=this.users[this.message[N].senderId].name;var E=this.message[N].date;var k=BX.desktop.clipboardSelected();var A=false;var L="";if(e.target.tagName=="IMG"&&e.target.parentNode.tagName=="A"||e.target.tagName=="A"){if(e.target.tagName=="A")L=e.target.href;else L=e.target.parentNode.href;if(L.indexOf("/desktop_app/")<0||L.indexOf("/desktop_app/show.file.php")>=0)A=true}o=[A?{text:BX.message("IM_MENU_COPY3"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy(BX.delegate(function(){return L},this));this.closeMenuPopup()},this)}:null,A?{separator:true}:null,k.text.length<=0?null:{text:BX.message("IM_MENU_QUOTE"),onclick:BX.delegate(function(){var e=BX.IM.getSelectionText();this.insertQuoteText(_,E,e);this.closeMenuPopup()},this)},{text:BX.message("IM_MENU_QUOTE2"),onclick:BX.delegate(function(){var e=[];for(var t=0;t<C.length;t++){var s=C[t].getAttribute("data-messageId");if(this.message[s]){if(this.message[s].text){e.push(BX.MessengerCommon.prepareTextBack(this.message[s].text))}if(this.message[s].params&&this.message[s].params.FILE_ID){for(var i=0;i<this.message[s].params.FILE_ID.length;i++){var a=this.message[s].params.FILE_ID[t];var n=this.message[s].chatId;if(this.disk.files[n][a]){e.push("["+BX.message("IM_F_FILE")+": "+this.disk.files[n][a].name+"]")}}}}}if(e.length>0){this.insertQuoteText(_,E,e.join("\n"))}this.closeMenuPopup()},this)},{separator:true},k.text.length<=0?null:{text:BX.message("IM_MENU_COPY"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy();this.closeMenuPopup()},this)},{text:BX.message("IM_MENU_COPY2"),onclick:BX.delegate(function(){var e=[];for(var t=0;t<C.length;t++){var s=C[t].getAttribute("data-messageId");if(this.message[s]){if(this.message[s].text){e.push(BX.MessengerCommon.prepareTextBack(this.message[s].text))}if(this.message[s].params&&this.message[s].params.FILE_ID){for(var i=0;i<this.message[s].params.FILE_ID.length;i++){var a=this.message[s].params.FILE_ID[i];var n=this.message[s].chatId;if(this.disk.files[n][a]){e.push("["+BX.message("IM_F_FILE")+": "+this.disk.files[n][a].name+"]")}}}}}if(e.length>0){BX.desktop.clipboardCopy(BX.delegate(function(t){return this.insertQuoteText(_,E,e.join("\n"),false)},this))}this.closeMenuPopup()},this)}]}else if(t=="historyFileMenu"){n=4;r=8;this.popupPopupMenuStyle="bx-messenger-file-active";var F=i.fileId;var h=i.chatId;var W=this.desktop.ready()?"desktop":"default";var G=true;if(!this.disk.files[h][F])return false;var Y=this.disk.files[h][F].authorId!=this.BXIM.userId;o=[G?{text:BX.message("IM_F_DOWNLOAD"),href:this.disk.files[h][F].urlDownload[W],target:"_blank",onclick:BX.delegate(function(){this.closeMenuPopup()},this)}:null,{text:BX.message("IM_F_DOWNLOAD_DISK"),onclick:BX.delegate(function(){this.disk.saveToDisk(h,F,{boxId:"im-file-history-panel"});this.closeMenuPopup()},this)},this.chat[h]&&this.chat[h].type=="open"&&Y?null:{text:BX.message("IM_F_DELETE"),onclick:BX.delegate(function(){this.BXIM.openConfirm(Y?BX.message("IM_F_DELETE_SELF_CONFIRM"):BX.message("IM_F_DELETE_CONFIRM"),[new BX.PopupWindowButton({text:BX.message("IM_F_DELETE_CONFIRM_YES"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){this.disk.deleteFile(h,F,{boxId:"im-file-history-panel"});BX.proxy_context.popupWindow.close()},this)}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})],true);this.closeMenuPopup()},this)}]}else if(t=="notify"){if(e.target.className=="bx-notifier-item-delete"){e.target.setAttribute("id","bx-notifier-item-delete-"+e.target.getAttribute("data-notifyId"));this.openPopupMenu(e.target,"notifyDelete");return false}var k=BX.desktop.clipboardSelected();var A=false;if(e.target.tagName=="A"&&(e.target.href.indexOf("/desktop_app/")<0||L.indexOf("/desktop_app/show.file.php")>=0)){A=true;var L=e.target.href}else if(e.target.parentNode.tagName=="A"&&(e.target.parentNode.href.indexOf("/desktop_app/")<0||L.indexOf("/desktop_app/show.file.php")>=0)){A=true;var L=e.target.parentNode.href}if(!A&&k.text.length<=0){var m=e.target.getAttribute("data-notifyId");if(!m){m=e.target.parentNode.parentNode.getAttribute("data-notifyId");if(!m){m=e.target.parentNode.getAttribute("data-notifyId")}}if(m){e.target.setAttribute("data-notifyId",m);this.openPopupMenu(e.target,"notifyDelete",false,{applyToDom:e})}return false}o=[A?{text:BX.message("IM_MENU_COPY3"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy(BX.delegate(function(){return L},this));this.closeMenuPopup()},this)}:null,A?{separator:true}:null,k.text.length<=0?null:{text:BX.message("IM_MENU_COPY"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy();this.closeMenuPopup()},this)}]}else if(t=="copylink"){if(e.target.tagName!="A"||e.target.href.indexOf("/desktop_app/")>=0&&e.target.href.indexOf("/desktop_app/show.file.php")<0)return false;o=[{text:BX.message("IM_MENU_COPY3"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy(BX.delegate(function(t){return e.target.href},this));this.closeMenuPopup()},this)}]}else if(t=="copypaste"){if(i.spell&&!this.desktop.enableInVersion(34)){i.spell=false}o=[];var k=BX.desktop.clipboardSelected(e.target,i.spell);if(!k.text){i.spell=false}if(i.spell){if(i.spellReady){for(var V=0;V<i.suggest.length;V++){dataParams={suggest:i.suggest[V],selectionStart:k.selectionStart,selectionEnd:k.selectionEnd};o.push({text:i.suggest[V],slim:true,bold:true,dataParams:dataParams,onclick:BX.delegate(function(){var t=JSON.parse(BX.proxy_context.getAttribute("data-params"));setTimeout(function(){BX.desktop.clipboardReplaceText(e.target,t.selectionStart,t.selectionEnd,t.suggest)},50);this.closeMenuPopup()},this)});if(V==5)break}if(o.length<=0){o.push({text:BX.message("IM_MENU_SUGGEST_EMPTY"),bold:true,slim:true})}o.push({separator:true})}else{BXDesktopSystem.SpellCheckWord(k.text,BX.delegate(function(t,s){this.openPopupMenu(e,"copypaste",false,{spell:!t,spellReady:true,suggest:s})},this))}}if(!i.spell||i.spellReady){if(k.text.length){o.push({text:BX.message("IM_MENU_CUT"),onclick:BX.delegate(function(){BX.desktop.clipboardCut();this.closeMenuPopup()},this)}),o.push({text:BX.message("IM_MENU_COPY"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy();this.closeMenuPopup()},this)}),o.push({text:BX.message("IM_MENU_DELETE"),onclick:BX.delegate(function(){BX.desktop.clipboardDelete();this.closeMenuPopup()},this)})}else{o.push({text:BX.message("IM_MENU_PASTE"),onclick:BX.delegate(function(){BX.desktop.clipboardPaste();this.closeMenuPopup()},this)})}l={position:"top"}}}else{o=[]}if(o.length<=0){return false}var z=true;for(var V=0;V<o.length;V++){if(o[V]){z=false}}if(z){o=[{text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),onclick:BX.delegate(function(){this.closeMenuPopup()},this)}]}else{var j=false;for(var V=0;V<o.length;V++){if(o[V]){if(o[V].separator){o[V]=null}else{break}}}}this.popupPopupMenuDateCreate=+new Date;this.popupPopupMenu=new BX.PopupWindow("bx-messenger-popup-"+t,e,{lightShadow:true,offsetTop:n,offsetLeft:r,autoHide:true,closeByEsc:true,zIndex:200,bindOptions:l,events:{onPopupClose:BX.delegate(function(){if(this.popupPopupMenuStyle){if(this.popupPopupMenuStyle=="bx-messenger-file-active")BX.removeClass(this.popupPopupMenu.bindElement.parentNode,this.popupPopupMenuStyle);else BX.removeClass(this.popupPopupMenu.bindElement,this.popupPopupMenuStyle)}if(this.popupPopupMenuDateCreate+1e3<+new Date)BX.proxy_context.destroy()},this),onPopupDestroy:BX.delegate(function(){if(this.popupPopupMenuStyle){if(this.popupPopupMenuStyle=="bx-messenger-file-active")BX.removeClass(this.popupPopupMenu.bindElement.parentNode,this.popupPopupMenuStyle);else BX.removeClass(this.popupPopupMenu.bindElement,this.popupPopupMenuStyle)}this.popupPopupMenu=null},this)},content:BX.create("div",{props:{className:"bx-messenger-popup-menu"},children:[BX.create("div",{props:{className:"bx-messenger-popup-menu-items"},children:BX.Messenger.MenuPrepareList(o)})]})});if(s!==false)this.popupPopupMenu.setAngle(p);this.popupPopupMenu.show();if(this.popupPopupMenuStyle){if(this.popupPopupMenuStyle=="bx-messenger-file-active")BX.addClass(e.parentNode,this.popupPopupMenuStyle);else BX.addClass(e,this.popupPopupMenuStyle)}BX.bind(this.popupPopupMenu.popupContainer,"click",BX.MessengerCommon.preventDefault);if(t=="dialogContext"||t=="notify"||t=="history"||t=="copypaste"){BX.bind(this.popupPopupMenu.popupContainer,"mousedown",function(e){e.target.click()})}return false};BX.Messenger.prototype.closePopupFileMenu=function(){if(this.popupMessengerFileButton==null)return false;if(this.popupPopupMenuDateCreate+100>+new Date)return false;if(BX.hasClass(this.popupMessengerFileButton,"bx-messenger-textarea-file-active")){BX.removeClass(this.popupMessengerFileButton,"bx-messenger-textarea-file-active");this.setClosingByEsc(true)}};BX.Messenger.prototype.closePopupFileMenuKeydown=function(e){if(e.keyCode==27){setTimeout(BX.delegate(function(){this.closePopupFileMenu()},this),100)}};BX.Messenger.prototype.openPopupExternalData=function(e,t,s,i){if(this.popupSmileMenu!=null)this.popupSmileMenu.destroy();if(this.popupPopupMenu!=null){this.popupPopupMenu.destroy();return false}this.popupPopupMenuDateCreate=+new Date;var a=this.desktop.ready()?0:0;var n=10;var r={position:"top"};var o={width:"272px",height:"100px"};var l={IM_GET_EXTERNAL_DATA:"Y",TYPE:t,TS:this.popupPopupMenuDateCreate,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()};var p=BX.create("div",{attrs:{id:"bx-messenger-external-data"},props:{className:"bx-messenger-external-data"},style:o,children:[BX.create("div",{props:{className:"bx-messenger-external-data-load"},html:BX.message("IM_CL_LOAD")})]});if(t=="user"){o={width:"272px",height:"100px"};l["USER_ID"]=parseInt(i["ID"]);if(this.users[l["USER_ID"]]&&!this.users[l["USER_ID"]].fake){l=false}}else if(t=="chat"){o={width:"272px",height:"100px"};l["CHAT_ID"]=parseInt(i["ID"]);if(this.chat[l["CHAT_ID"]]&&!this.chat[l["CHAT_ID"]].fake){l=false}}else if(t=="phoneCallHistory"){o={width:"239px",height:"122px"};l["HISTORY_ID"]=parseInt(i["ID"])}else if(t=="readedList"){l=false;var h=[];var c=0;var u=0;for(var d in this.BXIM.messenger.readedList[this.BXIM.messenger.currentTab]){if(d==this.BXIM.userId)continue;if(!u||u>this.BXIM.messenger.readedList[this.BXIM.messenger.currentTab][d].date){c=d;u=this.BXIM.messenger.readedList[this.BXIM.messenger.currentTab][d].date}h.push({userId:d,date:this.BXIM.messenger.readedList[this.BXIM.messenger.currentTab][d].date})}var m='<span class="bx-notifier-item-help-popup">';for(var g=0;g<h.length;g++){if(h[g].userId==c)continue;var f=BX.MessengerCommon.isBlankAvatar(this.BXIM.messenger.users[h[g].userId].avatar)?'style="background-color: '+this.BXIM.messenger.users[h[g].userId].color+'"':"";m+='<span class="bx-notifier-item-help-popup-img bx-messenger-panel-chat-user" data-userId="'+h[g].userId+'" title="'+BX.MessengerCommon.formatDate(h[g].date)+'">'+'<span class="bx-notifier-popup-avatar bx-notifier-popup-avatar-status-'+BX.MessengerCommon.getUserStatus(h[g].userId)+'">'+'<img class="bx-notifier-popup-avatar-img'+(BX.MessengerCommon.isBlankAvatar(this.BXIM.messenger.users[h[g].userId].avatar)?" bx-notifier-popup-avatar-img-default":"")+'" src="'+this.BXIM.messenger.users[h[g].userId].avatar+'" '+f+">"+"</span>"+'<span class="bx-notifier-item-help-popup-name '+(this.BXIM.messenger.users[h[g].userId].extranet?" bx-notifier-popup-avatar-extranet":"")+'">'+this.BXIM.messenger.users[h[g].userId].name+"</span>"+"</span>"}m+="</span>";p=BX.create("div",{props:{className:"bx-messenger-popup-menu"},html:m})}else{return false}this.popupPopupMenu=new BX.PopupWindow("bx-messenger-popup-external-data",e,{lightShadow:true,offsetTop:a,offsetLeft:n,autoHide:true,closeByEsc:true,zIndex:200,bindOptions:r,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupPopupMenu=null},this)},content:p});if(s!==false)this.popupPopupMenu.setAngle({offset:4});this.popupPopupMenu.show();if(l){BX.ajax({url:this.BXIM.pathToAjax+"?GET_EXTERNAL_DATA&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:l,onsuccess:BX.delegate(function(e){if(e.ERROR){e.TYPE="noAccess"}else if(e.TYPE=="chat"){for(var t in e.CHAT){this.chat[t]=e.CHAT[t]}for(var t in e.USER_IN_CHAT){this.userInChat[t]=e.USER_IN_CHAT[t]}for(var t in e.USER_BLOCK_CHAT){this.userChatBlockStatus[t]=e.USER_BLOCK_CHAT[t]}}else if(e.TYPE=="user"){for(var t in e.USERS){this.users[t]=e.USERS[t]}for(var t in e.PHONES){this.phones[t]={};for(var s in e.PHONES[t]){this.phones[t][s]=BX.util.htmlspecialcharsback(e.PHONES[t][s])}}for(var t in e.USER_IN_GROUP){if(typeof this.userInGroup[t]=="undefined"){this.userInGroup[t]=e.USER_IN_GROUP[t]}else{for(var s=0;s<e.USER_IN_GROUP[t].users.length;s++)this.userInGroup[t].users.push(e.USER_IN_GROUP[t].users[s]);this.userInGroup[t].users=BX.util.array_unique(this.userInGroup[t].users)}}for(var t in e.WO_USER_IN_GROUP){if(typeof this.woUserInGroup[t]=="undefined"){this.woUserInGroup[t]=e.WO_USER_IN_GROUP[t]}else{for(var s=0;s<e.WO_USER_IN_GROUP[t].users.length;s++)this.woUserInGroup[t].users.push(e.WO_USER_IN_GROUP[t].users[s]);this.woUserInGroup[t].users=BX.util.array_unique(this.woUserInGroup[t].users)}}}e.TS=parseInt(e.TS);if(e.TS>0&&e.TS!=this.popupPopupMenuDateCreate||!this.popupPopupMenu)return false;this.drawExternalData(e.TYPE,e)},this),onfailure:BX.delegate(function(){if(this.popupPopupMenu)this.popupPopupMenu.destroy()},this)})}else{if(t=="user")this.drawExternalData("user",{USER_ID:i["ID"]});else if(t=="chat")this.drawExternalData("chat",{CHAT_ID:i["ID"]})}if(this.popupPopupMenu)BX.bind(this.popupPopupMenu.popupContainer,"click",BX.PreventDefault);return false};BX.Messenger.prototype.drawExternalData=function(e,t){if(!BX("bx-messenger-external-data"))return false;if(e=="noAccess"){BX("bx-messenger-external-data").innerHTML=BX.message("IM_M_USER_NO_ACCESS")}else if(e=="user"){if(!this.users[t["USER_ID"]]){if(this.popupPopupMenu)this.popupPopupMenu.destroy();return false}BX("bx-messenger-external-data").innerHTML="";BX.adjust(BX("bx-messenger-external-data"),{children:[BX.create("div",{props:{className:"bx-messenger-external-avatar"},children:[BX.create("div",{props:{className:"bx-messenger-panel-avatar bx-messenger-panel-avatar-status-"+BX.MessengerCommon.getUserStatus(t["USER_ID"])},children:[BX.create("img",{attrs:{src:this.users[t["USER_ID"]].avatar,
style:BX.MessengerCommon.isBlankAvatar(this.users[t["USER_ID"]].avatar)?"background-color: "+this.users[t["USER_ID"]].color:""},props:{className:"bx-messenger-panel-avatar-img"+(BX.MessengerCommon.isBlankAvatar(this.users[t["USER_ID"]].avatar)?" bx-messenger-panel-avatar-img-default":"")}}),BX.create("span",{attrs:{title:BX.MessengerCommon.getUserStatus(t["USER_ID"],true)},props:{className:"bx-messenger-panel-avatar-status"}})]}),BX.create("span",{props:{className:"bx-messenger-panel-title"},html:this.users[t["USER_ID"]].extranet?'<div class="bx-messenger-user-extranet">'+this.users[t["USER_ID"]].name+"</div>":this.users[t["USER_ID"]].bot?'<div class="'+(this.bot[t["USER_ID"]].type=="network"?"bx-messenger-user-network":"bx-messenger-user-bot")+'">'+this.users[t["USER_ID"]].name+"</div>":this.users[t["USER_ID"]].name}),BX.create("span",{props:{className:"bx-messenger-panel-desc"},html:BX.MessengerCommon.getUserPosition(t["USER_ID"])})]}),BX.create("div",{props:{className:"bx-messenger-external-data-buttons"},children:[BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_M_WRITE_MESSAGE"),events:{click:BX.delegate(function(e){this.popupPopupMenu.destroy();this.openMessenger(t["USER_ID"])},this)}}),BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_M_CALL_BTN_HISTORY"),events:{click:BX.delegate(function(){this.popupPopupMenu.destroy();this.openHistory(t["USER_ID"])},this)}})]})]})}else if(e=="chat"){if(!this.chat[t["CHAT_ID"]]){if(this.popupPopupMenu)this.popupPopupMenu.destroy();return false}var s=BX.message("IM_CL_CHAT_2");if(this.chat[t["CHAT_ID"]].type=="call"){s=BX.message("IM_CL_PHONE")}else if(this.chat[t["CHAT_ID"]].type=="lines"){s=BX.message("IM_CL_LINES")}else if(this.chat[t["CHAT_ID"]].type=="livechat"){s=BX.message("IM_CL_LINES")}else if(this.chat[t["CHAT_ID"]].type=="open"){s=BX.message("IM_CL_OPEN_CHAT")}BX("bx-messenger-external-data").innerHTML="";BX.adjust(BX("bx-messenger-external-data"),{children:[BX.create("div",{props:{className:"bx-messenger-external-avatar"},children:[BX.create("div",{props:{className:"bx-messenger-panel-avatar bx-messenger-panel-avatar-"+this.chat[t["CHAT_ID"]].type},children:[BX.create("img",{attrs:{src:this.chat[t["CHAT_ID"]].avatar,style:BX.MessengerCommon.isBlankAvatar(this.chat[t["CHAT_ID"]].avatar)?"background-color: "+this.chat[t["CHAT_ID"]].color:""},props:{className:"bx-messenger-panel-avatar-img"+(BX.MessengerCommon.isBlankAvatar(this.chat[t["CHAT_ID"]].avatar)?" bx-messenger-panel-avatar-img-default":"")}})]}),BX.create("span",{props:{className:"bx-messenger-panel-title"},html:this.chat[t["CHAT_ID"]].extranet?'<div class="bx-messenger-user-extranet">'+this.chat[t["CHAT_ID"]].name+"</div>":this.chat[t["CHAT_ID"]].name}),BX.create("span",{props:{className:"bx-messenger-panel-desc"},html:s})]}),BX.create("div",{props:{className:"bx-messenger-external-data-buttons"},children:[BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_M_OPEN_CHAT"),events:{click:BX.delegate(function(e){this.popupPopupMenu.destroy();this.openMessenger("chat"+t["CHAT_ID"])},this)}}),BX.create("span",{props:{className:"bx-notifier-item-button bx-notifier-item-button-white"},html:BX.message("IM_M_CALL_BTN_HISTORY"),events:{click:BX.delegate(function(){this.popupPopupMenu.destroy();this.openHistory("chat"+t["CHAT_ID"])},this)}})]})]})}else if(e=="phoneCallHistory"){var i=false;if(t["CALL_RECORD_HTML"]){var i={HTML:BX.message("CALL_RECORD_ERROR"),SCRIPT:[]};if(!this.desktop.ready())i=BX.processHTML(t["CALL_RECORD_HTML"],false)}BX("bx-messenger-external-data").innerHTML="";BX.adjust(BX("bx-messenger-external-data"),{children:[BX.create("div",{props:{className:"bx-messenger-record"},children:[BX.create("div",{props:{className:"bx-messenger-record-phone-box"},children:[BX.create("span",{props:{className:"bx-messenger-record-icon bx-messenger-record-icon-"+t["CALL_ICON"]},attrs:{title:t["INCOMING_TEXT"]}}),BX.create("span",{props:{className:"bx-messenger-record-phone"},html:(t["PHONE_NUMBER"]&&t["PHONE_NUMBER"].toString().length>=10?"+":"")+t["PHONE_NUMBER"]})]}),BX.create("div",{props:{className:"bx-messenger-record-reason"},html:t["CALL_FAILED_REASON"]}),BX.create("div",{props:{className:"bx-messenger-record-stats"},children:[BX.create("span",{props:{className:"bx-messenger-record-time"},html:t["CALL_DURATION_TEXT"]}),BX.create("span",{props:{className:"bx-messenger-record-cost"},html:t["COST_TEXT"]})]}),i?BX.create("div",{props:{className:"bx-messenger-record-box"},children:[BX.create("span",{props:{className:"bx-messenger-record-player"},html:i.HTML})]}):null]})]});if(i){for(var a=0;a<i.SCRIPT.length;a++){BX.evalGlobal(i.SCRIPT[a].JS)}}}};BX.Messenger.prototype.openHistory=function(e){if(this.popupMessengerConnectionStatusState!="online")return false;if(this.historyWindowBlock)return false;this.historyLastSearch[e]="";if(!this.historyEndOfList[e])this.historyEndOfList[e]={};if(!this.historyLoadFlag[e])this.historyLoadFlag[e]={};if(this.popupHistory!=null)this.popupHistory.destroy();var t=0;var s=0;var i=this.BXIM.disk.enable;var a=false;if(e.toString().substr(0,4)=="chat"){a=true;t=parseInt(e.toString().substr(4));if(t<=0)return false}else{e=parseInt(e);if(e<=0)return false;t=this.userChat[e]?this.userChat[e]:0}this.historyFilesEndOfList[t]=false;this.historyFilesLoadFlag[t]=false;this.historyUserId=e;this.historyChatId=t;if(!this.desktop.run())this.setClosingByEsc(false);this.popupHistoryPanel=null;var n=this.redrawHistoryPanel(e,t);if(!a&&this.users[e]&&i){i=!this.users[e].bot}this.popupHistoryElements=BX.create("div",{props:{className:"bx-messenger-history"+(i?" bx-messenger-history-with-disk":"")+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},children:[this.popupHistoryPanel=BX.create("div",{props:{className:"bx-messenger-panel-wrap"},children:n}),BX.create("div",{props:{className:"bx-messenger-history-types"},children:[BX.create("span",{props:{className:"bx-messenger-history-type bx-messenger-history-type-message"},children:[this.popupHistoryButtonFilterBox=BX.create("div",{props:{className:"bx-messenger-panel-filter-box"},style:{display:"block"},children:[BX.create("div",{props:{className:"bx-messenger-filter-name"},html:BX.message("IM_HISTORY_FILTER_NAME")}),this.popupHistorySearchDateWrap=BX.create("div",{props:{className:"bx-messenger-filter-date bx-messenger-input-wrap"},html:'<span class="bx-messenger-input-date"></span><a class="bx-messenger-input-close" href="#close"></a><input type="text" class="bx-messenger-input" value="" tabindex="1003" placeholder="'+BX.message("IM_PANEL_FILTER_DATE")+'" />'}),this.popupHistorySearchWrap=BX.create("div",{props:{className:"bx-messenger-filter-text bx-messenger-history-filter-text bx-messenger-input-wrap"},html:'<a class="bx-messenger-input-close" href="#close"></a><input type="text" class="bx-messenger-input" tabindex="1000" placeholder="'+BX.message("IM_PANEL_FILTER_TEXT")+'" value="" />'})]}),this.popupHistoryItems=BX.create("div",{props:{className:"bx-messenger-history-items"},style:{height:this.popupHistoryItemsSize+"px"},children:[this.popupHistoryBodyWrap=BX.create("div",{props:{className:"bx-messenger-history-items-wrap"}})]})]}),BX.create("span",{props:{className:"bx-messenger-history-type bx-messenger-history-type-disk"},children:[this.popupHistoryFilesButtonFilterBox=BX.create("div",{props:{className:"bx-messenger-panel-filter-box"},style:{display:"block"},children:[this.popupHistoryFilesSearchWrap=BX.create("div",{props:{className:"bx-messenger-filter-text bx-messenger-input-wrap"},html:'<a class="bx-messenger-input-close" href="#close"></a><input type="text" tabindex="1002" class="bx-messenger-input" placeholder="'+BX.message("IM_F_FILE_SEARCH")+'" value="" />'})]}),this.popupHistoryFilesItems=BX.create("div",{props:{className:"bx-messenger-history-items"},style:{height:this.popupHistoryItemsSize+"px"},children:[this.popupHistoryFilesBodyWrap=BX.create("div",{props:{className:"bx-messenger-history-items-wrap"}})]})]})]})]});if(this.BXIM.init&&this.desktop.ready()){this.desktop.openHistory(e,this.popupHistoryElements,"BXIM.openHistory('"+e+"');");return false}else if(this.desktop.ready()){this.popupHistory=new BX.PopupWindowDesktop;this.desktop.drawOnPlaceholder(this.popupHistoryElements)}else{this.popupHistory=new BX.PopupWindow("bx-messenger-popup-history",null,{autoHide:false,zIndex:100,draggable:{restrict:true},closeByEsc:true,bindOptions:{position:"top"},events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupHistory=null;this.historySearch="";this.setClosingByEsc(true);this.closeMenuPopup();var e=BX.calendar.get();if(e){e.Close()}},this)},titleBar:{content:BX.create("span",{props:{className:"bx-messenger-title"},html:BX.message("IM_M_HISTORY")})},closeIcon:{right:"13px"},content:this.popupHistoryElements,contentColor:"white",noAllPaddings:true});this.popupHistory.show();BX.bind(this.popupHistory.popupContainer,"click",BX.MessengerCommon.preventDefault)}this.drawHistory(this.historyUserId);if(i){this.drawHistoryFiles(this.historyChatId)}if(this.desktop.ready()){BX.bind(this.popupHistorySearchInput,"contextmenu",BX.delegate(function(e){this.openPopupMenu(e,"copypaste",false);return BX.PreventDefault(e)},this));BX.bindDelegate(this.popupHistoryElements,"contextmenu",{className:"bx-messenger-history-item"},BX.delegate(function(e){this.openPopupMenu(e,"history",false);return BX.PreventDefault(e)},this))}BX.bindDelegate(this.popupHistoryElements,"click",{className:"bx-messenger-ajax"},BX.delegate(function(){if(BX.proxy_context.getAttribute("data-entity")=="user"){this.openPopupExternalData(BX.proxy_context,"user",true,{ID:BX.proxy_context.getAttribute("data-userId")})}else if(BX.proxy_context.getAttribute("data-entity")=="chat"){this.openPopupExternalData(BX.proxy_context,"chat",true,{ID:BX.proxy_context.getAttribute("data-chatId")})}else if(BX.proxy_context.getAttribute("data-entity")=="network"){this.openMessenger("network"+BX.proxy_context.getAttribute("data-networkId"))}else if(BX.proxy_context.getAttribute("data-entity")=="phoneCallHistory"){this.openPopupExternalData(BX.proxy_context,"phoneCallHistory",true,{ID:BX.proxy_context.getAttribute("data-historyID")})}},this));BX.bindDelegate(this.popupHistoryPanel,"click",{className:"bx-messenger-panel-basket"},BX.delegate(function(){this.BXIM.openConfirm(BX.message("IM_M_HISTORY_DELETE_ALL_CONFIRM"),[new BX.PopupWindowButton({text:BX.message("IM_M_HISTORY_DELETE_ALL"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){this.deleteAllHistory(e);BX.proxy_context.popupWindow.close()},this)}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})],true)},this));this.popupHistorySearchInput=BX.findChildByClassName(this.popupHistorySearchWrap,"bx-messenger-input");this.popupHistorySearchInputClose=BX.findChildByClassName(this.popupHistorySearchInput.parentNode,"bx-messenger-input-close");this.popupHistorySearchDateInput=BX.findChildByClassName(this.popupHistorySearchDateWrap,"bx-messenger-input");this.popupHistorySearchDateInputClose=BX.findChildByClassName(this.popupHistorySearchDateInput.parentNode,"bx-messenger-input-close");BX.bind(this.popupHistorySearchDateInput,"focus",BX.delegate(function(e){BX.calendar({node:BX.proxy_context,field:BX.proxy_context,bTime:false,callback_after:BX.delegate(this.newHistoryDateSearch,this)});return BX.PreventDefault(e)},this));BX.bind(this.popupHistorySearchDateInput,"click",BX.delegate(function(e){BX.calendar({node:BX.proxy_context,field:BX.proxy_context,bTime:false,callback_after:BX.delegate(this.newHistoryDateSearch,this)});return BX.PreventDefault(e)},this));BX.bind(this.popupHistorySearchDateInputClose,"click",BX.delegate(function(e){this.popupHistorySearchDateInput.value="";this.historyDateSearch="";this.historyLastSearch[this.historyUserId]="";this.drawHistory(this.historyUserId,false,false)},this));if(this.popupHistoryFilterVisible&&!BX.browser.IsAndroid()&&!BX.browser.IsIOS())BX.focus(this.popupHistorySearchInput);BX.bind(this.popupHistorySearchInputClose,"click",BX.delegate(function(e){this.popupHistorySearchInput.value="";this.historySearch="";this.historyLastSearch[this.historyUserId]="";this.drawHistory(this.historyUserId,false,false);return BX.PreventDefault(e)},this));BX.bind(this.popupHistorySearchInput,"keyup",BX.delegate(this.newHistorySearch,this));BX.bind(this.popupHistoryItems,"scroll",BX.delegate(function(){BX.MessengerCommon.loadHistory(e)},this));if(this.disk.enable){BX.bindDelegate(this.popupHistoryFilesBodyWrap,"click",{className:"bx-messenger-file-menu"},BX.delegate(function(e){var t=BX.proxy_context.parentNode.parentNode.getAttribute("data-fileId");var s=BX.proxy_context.parentNode.parentNode.getAttribute("data-chatId");this.openPopupMenu(BX.proxy_context,"historyFileMenu",true,{fileId:t,chatId:s});return BX.PreventDefault(e)},this));this.popupHistoryFilesSearchInput=BX.findChildByClassName(this.popupHistoryFilesSearchWrap,"bx-messenger-input");this.popupHistoryFilesSearchInputClose=BX.findChildByClassName(this.popupHistoryFilesSearchInput.parentNode,"bx-messenger-input-close");BX.bind(this.popupHistoryFilesSearchInputClose,"click",BX.delegate(function(e){this.popupHistoryFilesSearchInput.value="";this.historyFilesSearch="";this.historyFilesLastSearch[this.historyChatId]="";this.drawHistoryFiles(this.historyChatId,false,false);return BX.PreventDefault(e)},this));BX.bind(this.popupHistoryFilesSearchInput,"keyup",BX.delegate(this.newHistoryFilesSearch,this));BX.bind(this.popupHistoryFilesItems,"scroll",BX.delegate(function(){this.loadHistoryFiles(this.historyChatId)},this))}};BX.Messenger.prototype.loadHistoryFiles=function(e,t){if(this.historyFilesLoadFlag[e])return;if(this.historyFilesSearch!="")return;if(t&&this.popupHistoryFilesItems.offsetHeight>this.popupHistoryFilesBodyWrap.offsetHeight-100){}else if(!(this.popupHistoryFilesItems.scrollTop>this.popupHistoryFilesItems.scrollHeight-this.popupHistoryFilesItems.offsetHeight-100)){return}if(!this.historyFilesEndOfList[e]){this.historyFilesLoadFlag[e]=true;if(this.popupHistoryFilesBodyWrap.childNodes.length>0)this.historyFilesOpenPage[e]=Math.floor(this.popupHistoryFilesBodyWrap.childNodes.length/15)+1;else this.historyFilesOpenPage[e]=1;var s=null;this.popupHistoryFilesBodyWrap.appendChild(s=BX.create("div",{props:{className:"bx-messenger-content-load-more-history"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-img"}}),BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_F_LOAD_FILES")})]}));BX.ajax({url:this.BXIM.pathToAjax+"?HISTORY_FILES_LOAD_MORE&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_HISTORY_FILES_LOAD:"Y",CHAT_ID:e,PAGE_ID:this.historyFilesOpenPage[e],IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(s)BX.remove(s);this.historyFilesLoadFlag[e.CHAT_ID]=false;if(e.FILES.length==0){this.historyFilesEndOfList[e.CHAT_ID]=true;return}var t=0;for(var i in e.FILES){if(!this.disk.files[e.CHAT_ID])this.disk.files[e.CHAT_ID]={};if(!this.disk.files[e.CHAT_ID][i]){e.FILES[i].date=parseInt(e.FILES[i].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.disk.files[e.CHAT_ID][i]=e.FILES[i]}t++}if(t<15){this.historyFilesEndOfList[e.CHAT_ID]=true}for(var i in e.FILES){var a=this.disk.files[e.CHAT_ID][i];if(a&&!BX("im-file-history-panel-"+a.id)){var n=this.disk.drawHistoryFiles(e.CHAT_ID,a.id,{getElement:"Y"});if(n)this.popupHistoryFilesBodyWrap.appendChild(n)}}},this),onfailure:function(){if(s)BX.remove(s)}})}};BX.Messenger.prototype.deleteAllHistory=function(e){BX.ajax({url:this.BXIM.pathToAjax+"?HISTORY_REMOVE_ALL&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_HISTORY_REMOVE_ALL:"Y",USER_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});BX.localStorage.set("mhra",e,5);this.history[e]=[];this.showMessage[e]=[];this.popupHistoryBodyWrap.innerHTML="";this.popupHistoryBodyWrap.appendChild(BX.create("div",{props:{className:"bx-messenger-content-history-empty"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_M_NO_MESSAGE")})]}));if(this.desktop.ready())BX.desktop.onCustomEvent("main","bxImClearHistory",[e]);else if(this.BXIM.init)BX.MessengerCommon.drawTab(e)};BX.Messenger.prototype.drawMessageHistory=function(e){if(typeof e!="object")return null;if(typeof e.params!="object"){e.params={}}var t=e.senderId==0;if(e.system&&e.system=="Y"){t=true;e.senderId=0}var s=e.params&&e.params.IS_EDITED=="Y";var i=e.params&&e.params.IS_DELETED=="Y";var a=BX.MessengerCommon.diskDrawFiles(e.chatId,e.params.FILE_ID,{status:["done","error"],boxId:"im-file-history"});if(a.length>0){a=BX.create("div",{props:{className:"bx-messenger-file-box"+(e.text!=""?" bx-messenger-file-box-with-message":"")},children:a})}else{a=null}if(a==null&&e.text.length<=0){resultNode=BX.create("div",{attrs:{"data-messageId":e.id},props:{className:"bx-messenger-history-item-text bx-messenger-item-skipped"}})}else{var n="";var r="";if(e.senderId>0&&this.users[e.senderId]){n=this.users[e.senderId].avatar;r=this.users[e.senderId].color}resultNode=BX.create("div",{attrs:{"data-messageId":e.id},props:{className:"bx-messenger-history-item"+(e.senderId==0?" bx-messenger-history-item-3":e.senderId==this.BXIM.userId?"":" bx-messenger-history-item-2")},children:[BX.create("div",{props:{className:"bx-messenger-history-hide"},html:this.historyMessageSplit}),BX.create("span",{props:{className:"bx-messenger-history-item-avatar"},children:[BX.create("img",{props:{className:"bx-messenger-content-item-avatar-img"+(BX.MessengerCommon.isBlankAvatar(n)?" bx-messenger-content-item-avatar-img-default":"")},attrs:{src:e.senderId>0?n:this.BXIM.pathToBlankImage,style:e.senderId>0&&BX.MessengerCommon.isBlankAvatar(n)&&r?"background-color: "+r:""}})]}),BX.create("div",{props:{className:"bx-messenger-history-item-name"},html:(this.users[e.senderId]?this.users[e.senderId].name:BX.message("IM_M_SYSTEM_USER"))+' <span class="bx-messenger-history-hide">[</span><span class="bx-messenger-history-item-date">'+BX.MessengerCommon.formatDate(e.date,BX.MessengerCommon.getDateFormatType("MESSAGE"))+'</span><span class="bx-messenger-history-hide">]</span>'}),BX.create("div",{attrs:{id:"im-message-history-"+e.id},props:{className:"bx-messenger-history-item-text"+(i?" bx-messenger-message-deleted":" ")+(i||s?" bx-messenger-message-edited":"")},html:BX.MessengerCommon.prepareText(e.text,false,true,true)}),a,BX.create("div",{props:{className:"bx-messenger-history-hide"},html:"<br />"}),BX.create("div",{props:{className:"bx-messenger-history-hide"},html:this.historyMessageSplit})]})}return resultNode};BX.Messenger.prototype.drawHistory=function(e,t,s){if(this.popupHistory==null)return false;s=typeof s=="undefined"?true:s;var i=false;var a=0;if(e.toString().substr(0,4)=="chat"){i=true;a=e.toString().substr(4)}var n=[];var r=false;this.popupHistoryBodyWrap.innerHTML="";var o=this.historySearch.length>0;var t=!t?this.history:t;if(t[e]&&(!i&&this.users[e]||i&&this.chat[a])){var l=BX.util.array_unique(t[e]);var p={};l.sort(BX.delegate(function(e,t){e=parseInt(e);t=parseInt(t);if(!this.message[e]||!this.message[t]){return 0}var s=parseInt(this.message[e].date);var i=parseInt(this.message[t].date);if(s>i){return-1}else if(s<i){return 1}else{if(e>t){return-1}else if(e<t){return 1}else{return 0}}},this));for(var h=0;h<l.length;h++){if(o&&this.message[t[e][h]].text.toLowerCase().indexOf((this.historySearch+"").toLowerCase())<0)continue;var c=BX.MessengerCommon.formatDate(this.message[t[e][h]].date,BX.MessengerCommon.getDateFormatType("MESSAGE_TITLE"));if(!BX("bx-im-history-"+c)&&!p[c]){p[c]=true;n.push(BX.create("div",{props:{className:"bx-messenger-content-group bx-messenger-content-group-history"},children:[BX.create("div",{attrs:{id:"bx-im-history-"+c},props:{className:"bx-messenger-content-group-title"+(this.BXIM.language=="ru"?" bx-messenger-lowercase":"")},html:c})]}))}var u=this.drawMessageHistory(this.message[t[e][h]]);if(u)n.push(u)}if(n.length<=0){if(!this.historySearchBegin){r=true;n=[BX.create("div",{props:{className:"bx-messenger-content-history-empty"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_M_NO_MESSAGE")})]})]}}}else if(this.showMessage[e]&&this.showMessage[e].length<=0){r=true;n=[BX.create("div",{props:{className:"bx-messenger-content-history-empty"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_M_NO_MESSAGE")})]})]}if(n.length>0){BX.adjust(this.popupHistoryBodyWrap,{children:n});this.popupHistoryItems.scrollTop=0}if(s&&(!this.showMessage[e]||this.showMessage[e]&&this.showMessage[e].length<20)){if(r)this.popupHistoryFilesBodyWrap.innerHTML="";this.popupHistoryBodyWrap.appendChild(BX.create("div",{props:{className:BX.findChildrenByClassName(this.popupHistoryBodyWrap,"bx-messenger-history-item-text").length>0?"bx-messenger-content-load-more-history":"bx-messenger-content-load-history"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-img"}}),BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_M_LOAD_MESSAGE")})]}));BX.ajax({url:this.BXIM.pathToAjax+"?HISTORY_LOAD&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,timeout:30,data:{IM_HISTORY_LOAD:"Y",USER_ID:e,USER_LOAD:i?this.chat[e.toString().substr(4)]&&this.chat[e.toString().substr(4)].fake?"Y":"N":this.users[e]&&this.users[e].fake?"Y":"N",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(a){if(a&&a.BITRIX_SESSID){BX.message({bitrix_sessid:a.BITRIX_SESSID})}if(a.ERROR==""){if(!i){if(!this.userChat[e]){this.userChat[e]=a.CHAT_ID}}for(var n in a.FILES){if(!this.disk.files[a.CHAT_ID])this.disk.files[a.CHAT_ID]={};if(this.disk.files[a.CHAT_ID][n])continue;a.FILES[n].date=parseInt(a.FILES[n].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.disk.files[a.CHAT_ID][n]=a.FILES[n]}this.showMessage[e]=[];this.sendAjaxTry=0;for(var n in a.MESSAGE){a.MESSAGE[n].date=parseInt(a.MESSAGE[n].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.message[n]=a.MESSAGE[n];if(this.BXIM.settings.loadLastMessage)this.showMessage[e].push(n)}for(var n in a.USERS_MESSAGE){if(this.history[n])this.history[n]=BX.util.array_merge(this.history[n],a.USERS_MESSAGE[n]);else this.history[n]=a.USERS_MESSAGE[n]}if(!i&&this.users[e]&&!this.users[e].fake||i&&this.chat[a.CHAT_ID]&&!this.chat[a.CHAT_ID].fake){BX.cleanNode(this.popupHistoryBodyWrap);if(!a.USERS_MESSAGE[e]||a.USERS_MESSAGE[e].length<=0){this.popupHistoryBodyWrap.appendChild(BX.create("div",{props:{className:"bx-messenger-content-history-empty"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_M_NO_MESSAGE")})]}))}else{for(var n=0;n<a.USERS_MESSAGE[e].length;n++){var r=BX.MessengerCommon.formatDate(this.message[a.USERS_MESSAGE[e][n]].date,BX.MessengerCommon.getDateFormatType("MESSAGE_TITLE"));if(!BX("bx-im-history-"+r)){this.popupHistoryBodyWrap.appendChild(BX.create("div",{props:{className:"bx-messenger-content-group bx-messenger-content-group-history"},children:[BX.create("div",{attrs:{id:"bx-im-history-"+r},props:{className:"bx-messenger-content-group-title"+(this.BXIM.language=="ru"?" bx-messenger-lowercase":"")},html:r})]}))}var o=this.drawMessageHistory(this.message[a.USERS_MESSAGE[e][n]]);if(o)this.popupHistoryBodyWrap.appendChild(o)}}if(this.BXIM.settings.loadLastMessage&&this.currentTab==e)BX.MessengerCommon.drawTab(this.currentTab,true)}else{if(i&&this.chat[a.USER_ID.substr(4)].fake)this.chat[a.USER_ID.toString().substr(4)].name=BX.message("IM_M_USER_NO_ACCESS");if(!i){BX.MessengerCommon.getUserParam(e,true);this.users[e].name=BX.message("IM_M_USER_NO_ACCESS")}for(var n in a.USERS){this.users[n]=a.USERS[n]}for(var n in a.USER_IN_GROUP){if(typeof this.userInGroup[n]=="undefined"){this.userInGroup[n]=a.USER_IN_GROUP[n]}else{for(var l=0;l<a.USER_IN_GROUP[n].users.length;l++)this.userInGroup[n].users.push(a.USER_IN_GROUP[n].users[l]);this.userInGroup[n].users=BX.util.array_unique(this.userInGroup[n].users)}}for(var n in a.WO_USER_IN_GROUP){if(typeof this.woUserInGroup[n]=="undefined"){this.woUserInGroup[n]=a.WO_USER_IN_GROUP[n]}else{for(var l=0;l<a.WO_USER_IN_GROUP[n].users.length;l++)this.woUserInGroup[n].users.push(a.WO_USER_IN_GROUP[n].users[l]);this.woUserInGroup[n].users=BX.util.array_unique(this.woUserInGroup[n].users)}}for(var n in a.CHAT){this.chat[n]=a.CHAT[n]}for(var n in a.USER_IN_CHAT){this.userInChat[n]=a.USER_IN_CHAT[n]}for(var n in a.USER_BLOCK_CHAT){this.userChatBlockStatus[n]=a.USER_BLOCK_CHAT[n]}if(!i)BX.MessengerCommon.userListRedraw();this.dialogStatusRedraw();this.drawHistory(e,false,false)}if(this.historyChatId==0){this.historyChatId=a.CHAT_ID;this.drawHistoryFiles(this.historyChatId)}this.redrawHistoryPanel(e,i?a.USER_ID.substr(4):0)}else{if(a.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<2){this.sendAjaxTry++;setTimeout(BX.delegate(function(){this.drawHistory(e,t,s)},this),1e3);BX.onCustomEvent(window,"onImError",[a.ERROR,a.BITRIX_SESSID])}else if(a.ERROR=="AUTHORIZE_ERROR"){this.sendAjaxTry++;if(this.desktop.ready()){setTimeout(BX.delegate(function(){this.drawHistory(e,t,s)},this),1e4)}BX.onCustomEvent(window,"onImError",[a.ERROR])}}},this),onfailure:BX.delegate(function(){this.sendAjaxTry=0},this)})}};BX.Messenger.prototype.redrawHistoryPanel=function(e,t){var s=e.toString().substr(0,4)=="chat"?true:false;var i=null;BX.MessengerCommon.getUserParam(e);if(s){i=BX.create("div",{props:{className:"bx-messenger-panel bx-messenger-panel-bg2"},children:[BX.create("span",{props:{className:"bx-messenger-panel-avatar bx-messenger-panel-avatar-"+this.chat[t].type},children:[BX.create("img",{attrs:{src:this.chat[t].avatar,style:BX.MessengerCommon.isBlankAvatar(this.chat[t].avatar)?"background-color: "+this.chat[t].color:""},props:{className:"bx-messenger-panel-avatar-img"+(BX.MessengerCommon.isBlankAvatar(this.chat[t].avatar)?" bx-messenger-panel-avatar-img-default":"")}})]}),this.popupHistoryButtonDeleteAll=this.chat[t].type=="open"||this.chat[t].type=="lines"?null:BX.create("a",{attrs:{title:BX.message("IM_M_HISTORY_DELETE_ALL")},props:{className:"bx-messenger-panel-basket"}}),BX.create("span",{props:{className:"bx-messenger-panel-title bx-messenger-panel-title-middle"},html:this.chat[t].name})]})}else{i=BX.create("div",{props:{className:"bx-messenger-panel bx-messenger-panel-bg2"},children:[BX.create("a",{attrs:{href:this.users[e].profile},props:{className:"bx-messenger-panel-avatar bx-messenger-panel-avatar-status-"+BX.MessengerCommon.getUserStatus(e)},children:[BX.create("img",{attrs:{src:this.users[e].avatar,style:BX.MessengerCommon.isBlankAvatar(this.users[e].avatar)?"background-color: "+this.users[e].color:""},props:{className:"bx-messenger-panel-avatar-img"+(BX.MessengerCommon.isBlankAvatar(this.users[e].avatar)?" bx-messenger-panel-avatar-img-default":"")}}),BX.create("span",{attrs:{title:BX.MessengerCommon.getUserStatus(e,true)},props:{className:"bx-messenger-panel-avatar-status"}})]}),this.popupHistoryButtonDeleteAll=e==this.BXIM.userId?null:BX.create("a",{props:{className:"bx-messenger-panel-basket"}}),BX.create("span",{props:{className:"bx-messenger-panel-title"},html:this.users[e].extranet?'<div class="bx-messenger-user-extranet">'+this.users[e].name+"</div>":this.users[e].bot?'<div class="'+(this.bot[e].type=="network"?"bx-messenger-user-network":"bx-messenger-user-bot")+'">'+this.users[e].name+"</div>":this.users[e].name}),BX.create("span",{props:{className:"bx-messenger-panel-desc"},html:BX.MessengerCommon.getUserPosition(e)})]})}if(this.popupHistoryPanel){this.popupHistoryPanel.innerHTML="";BX.adjust(this.popupHistoryPanel,{children:[i]})}else{return[i]}};BX.Messenger.prototype.drawHistoryFiles=function(e,t,s){if(this.popupHistory==null)return false;s=typeof s=="undefined"?true:s;var i=this.historyFilesSearch.length>0;var t=!t?this.disk.files[e]:t;var a=[];var n=false;if(t){var r=BX.util.objectSort(t,"date","desc");for(var o=0;o<r.length;o++){if(i&&r[o].name.toLowerCase().indexOf((this.historyFilesSearch+"").toLowerCase())<0)continue;var l=this.disk.drawHistoryFiles(e,r[o].id,{getElement:"Y"});if(l)a.push(l)}if(a.length<=0){if(!this.historyFilesSearchBegin){n=true;a=[BX.create("div",{props:{className:"bx-messenger-content-history-empty"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_F_NO_FILES_2")})]})]}}if(a.length>=15){s=false}}else if(e==0){n=true;a=[BX.create("div",{props:{className:this.popupHistoryFilesBodyWrap.childNodes.length>0?"bx-messenger-content-load-more-history":"bx-messenger-content-load-history"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-img"}}),BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_F_LOAD_FILES")})]})]}else{n=true;a=[BX.create("div",{props:{className:"bx-messenger-content-history-empty"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_F_NO_FILES_2")})]})]}this.popupHistoryFilesBodyWrap.innerHTML="";if(a.length>0){BX.adjust(this.popupHistoryFilesBodyWrap,{children:a});this.popupHistoryFilesItems.scrollTop=0}if(s&&e>0){if(n)this.popupHistoryFilesBodyWrap.innerHTML="";this.popupHistoryFilesBodyWrap.appendChild(BX.create("div",{props:{className:this.popupHistoryFilesBodyWrap.childNodes.length>0?"bx-messenger-content-load-more-history":"bx-messenger-content-load-history"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-img"}}),BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_F_LOAD_FILES")})]}));BX.ajax({url:this.BXIM.pathToAjax+"?HISTORY_FILES_LOAD&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,timeout:30,data:{IM_HISTORY_FILES_LOAD:"Y",CHAT_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(i){if(i&&i.BITRIX_SESSID){BX.message({bitrix_sessid:i.BITRIX_SESSID})}if(i.ERROR==""){for(var a in i.FILES){if(!this.disk.files[i.CHAT_ID])this.disk.files[i.CHAT_ID]={};i.FILES[a].date=parseInt(i.FILES[a].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.disk.files[i.CHAT_ID][a]=i.FILES[a]}this.drawHistoryFiles(i.CHAT_ID,false,false)}else{if(i.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<2){this.sendAjaxTry++;BX.message({bitrix_sessid:i.BITRIX_SESSID});setTimeout(BX.delegate(function(){this.drawHistoryFiles(e,t,s)},this),1e3);BX.onCustomEvent(window,"onImError",[i.ERROR,i.BITRIX_SESSID])}else if(i.ERROR=="AUTHORIZE_ERROR"){this.sendAjaxTry++;if(this.desktop.ready()){setTimeout(BX.delegate(function(){this.drawHistoryFiles(e,t,s)},this),1e4)}BX.onCustomEvent(window,"onImError",[i.ERROR])}}},this),onfailure:BX.delegate(function(){this.sendAjaxTry=0},this)})}};BX.Messenger.prototype.newHistorySearch=function(e){e=e||window.event;if(e.keyCode==27&&this.historySearch!="")BX.MessengerCommon.preventDefault(e);if(e.keyCode==27)this.popupHistorySearchInput.value="";this.historySearch=this.popupHistorySearchInput.value;if(this.historyLastSearch[this.historyUserId]==this.historySearch){return false}this.historyLastSearch[this.historyUserId]=this.historySearch;if(this.popupHistorySearchInput.value.length<=3){this.historySearch="";this.drawHistory(this.historyUserId,false,false);return false}this.popupHistorySearchDateInput.value="";this.historyDateSearch="";this.historySearchBegin=true;this.drawHistory(this.historyUserId,false,false);var t=BX.findChildByClassName(this.popupHistoryBodyWrap,"bx-messenger-content-load-history");if(t)BX.remove(t);var t=BX.findChildByClassName(this.popupHistoryBodyWrap,"bx-messenger-content-history-empty");if(t)BX.remove(t);
var s=null;this.popupHistoryBodyWrap.appendChild(s=BX.create("div",{props:{className:this.popupHistoryBodyWrap.childNodes.length>0?"bx-messenger-content-load-more-history":"bx-messenger-content-load-history"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-img"}}),BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_M_LOAD_MESSAGE")})]}));clearTimeout(this.historySearchTimeout);if(this.popupHistorySearchInput.value!=""){this.historySearchTimeout=setTimeout(BX.delegate(function(){BX.ajax({url:this.BXIM.pathToAjax+"?HISTORY_SEARCH&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_HISTORY_SEARCH:"Y",USER_ID:this.historyUserId,SEARCH:this.popupHistorySearchInput.value,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(s)BX.remove(s);this.historySearchBegin=false;if(e.ERROR!="")return false;if(e.MESSAGE.length==0){var t={};t[e.USER_ID]=[];this.drawHistory(e.USER_ID,t,false);return}for(var i in e.MESSAGE){e.MESSAGE[i].date=parseInt(e.MESSAGE[i].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.message[i]=e.MESSAGE[i]}for(var i in e.FILES){if(!this.disk.files[e.CHAT_ID])this.disk.files[e.CHAT_ID]={};e.FILES[i].date=parseInt(e.FILES[i].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.disk.files[e.CHAT_ID][i]=e.FILES[i]}this.drawHistory(e.USER_ID,e.USERS_MESSAGE,false)},this),onfailure:BX.delegate(function(){if(s)BX.remove(s);this.historySearchBegin=false},this)})},this),1500)}return BX.PreventDefault(e)};BX.Messenger.prototype.newHistoryDateSearch=function(e){this.historyDateSearch=this.popupHistorySearchDateInput.value;if(this.historyLastSearch[this.historyUserId]==this.historyDateSearch){return false}this.historyLastSearch[this.historyUserId]=this.historyDateSearch;if(this.historyDateSearch.length<=3){this.historyDateSearch="";this.drawHistory(this.historyUserId,false,false);return false}this.popupHistorySearchInput.value="";this.historySearch="";this.historySearchBegin=true;var t=null;this.popupHistoryBodyWrap.innerHTML="";this.popupHistoryBodyWrap.appendChild(t=BX.create("div",{props:{className:this.popupHistoryBodyWrap.childNodes.length>0?"bx-messenger-content-load-more-history":"bx-messenger-content-load-history"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-img"}}),BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_M_LOAD_MESSAGE")})]}));clearTimeout(this.historySearchTimeout);if(this.historyDateSearch!=""){this.historySearchTimeout=setTimeout(BX.delegate(function(){BX.ajax({url:this.BXIM.pathToAjax+"?HISTORY_DATE_SEARCH&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_HISTORY_DATE_SEARCH:"Y",USER_ID:this.historyUserId,DATE:this.historyDateSearch,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(t)BX.remove(t);this.historySearchBegin=false;if(e.ERROR!="")return false;if(e.MESSAGE.length==0){var s={};s[e.USER_ID]=[];this.drawHistory(e.USER_ID,s,false);return}for(var i in e.MESSAGE){e.MESSAGE[i].date=parseInt(e.MESSAGE[i].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.message[i]=e.MESSAGE[i]}for(var i in e.FILES){if(!this.disk.files[e.CHAT_ID])this.disk.files[e.CHAT_ID]={};e.FILES[i].date=parseInt(e.FILES[i].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.disk.files[e.CHAT_ID][i]=e.FILES[i]}this.drawHistory(e.USER_ID,e.USERS_MESSAGE,false)},this),onfailure:BX.delegate(function(){if(t)BX.remove(t);this.historySearchBegin=false},this)})},this),1500)}};BX.Messenger.prototype.newHistoryFilesSearch=function(e){e=e||window.event;if(e.keyCode==27&&this.historyFilesSearch!="")BX.MessengerCommon.preventDefault(e);if(e.keyCode==27)this.popupHistoryFilesSearchInput.value="";this.historyFilesSearch=this.popupHistoryFilesSearchInput.value;if(this.historyFilesLastSearch[this.historyChatId]==this.historyFilesSearch){return false}this.historyFilesLastSearch[this.historyChatId]=this.historyFilesSearch;if(this.popupHistoryFilesSearchInput.value.length<=3){this.historyFilesSearch="";this.drawHistoryFiles(this.historyChatId,false,false);return false}this.historyFilesSearchBegin=true;this.historySearch=this.popupHistorySearchInput.value;this.drawHistoryFiles(this.historyChatId,false,false);var t=BX.findChildByClassName(this.popupHistoryFilesBodyWrap,"bx-messenger-content-load-history");if(t)BX.remove(t);var t=BX.findChildByClassName(this.popupHistoryFilesBodyWrap,"bx-messenger-content-history-empty");if(t)BX.remove(t);var s=null;this.popupHistoryFilesBodyWrap.appendChild(s=BX.create("div",{props:{className:this.popupHistoryFilesBodyWrap.childNodes.length>0?"bx-messenger-content-load-more-history":"bx-messenger-content-load-history"},children:[BX.create("span",{props:{className:"bx-messenger-content-load-img"}}),BX.create("span",{props:{className:"bx-messenger-content-load-text"},html:BX.message("IM_F_LOAD_FILES")})]}));clearTimeout(this.historyFilesSearchTimeout);if(this.popupHistoryFilesSearchInput.value!=""){this.historyFilesSearchTimeout=setTimeout(BX.delegate(function(){BX.ajax({url:this.BXIM.pathToAjax+"?HISTORY_FILES_SEARCH&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_HISTORY_FILES_SEARCH:"Y",CHAT_ID:this.historyChatId,SEARCH:this.popupHistoryFilesSearchInput.value,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(s)BX.remove(s);this.historyFilesSearchBegin=false;if(e.ERROR!="")return false;if(e.FILES.length==0){this.drawHistoryFiles(e.CHAT_ID,false,false);return}var t=false;for(var i in e.FILES){if(!this.disk.files[e.CHAT_ID])this.disk.files[e.CHAT_ID]={};if(!this.disk.files[e.CHAT_ID][i])e.FILES[i].fromSearch=true;e.FILES[i].date=parseInt(e.FILES[i].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.disk.files[e.CHAT_ID][i]=e.FILES[i];t=true}this.drawHistoryFiles(e.CHAT_ID,t?e.FILES:false,false)},this),onfailure:BX.delegate(function(){if(s)BX.remove(s);this.historyFilesSearchBegin=false},this)})},this),1500)}return BX.PreventDefault(e)};BX.Messenger.prototype.setUpdateStateStep=function(e){e=e!=false;var t=this.updateStateStepDefault;if(!this.BXIM.ppStatus){if(this.popupMessenger!=null){t=20;if(this.updateStateVeryFastCount>0){t=5;this.updateStateVeryFastCount--}else if(this.updateStateFastCount>0){t=10;this.updateStateFastCount--}}}this.updateStateStep=parseInt(t);if(e)BX.localStorage.set("uss",this.updateStateStep,5);this.updateState()};BX.Messenger.prototype.updateState=function(e,t,s){if(!this.BXIM.tryConnect||this.popupMessengerConnectionStatusState=="offline")return false;e=e==true;t=t!=false;s=s||"UPDATE_STATE";clearTimeout(this.updateStateTimeout);this.updateStateTimeout=setTimeout(BX.delegate(function(){if(this.desktop.ready()){var e="IM UPDATE STATE: sending ajax"+(s=="UPDATE_STATE"?"":" ("+s+")")+" ["+this.updateStateCount+"]";BX.desktop.log("phone."+this.BXIM.userEmail+".log",e);console.log(e)}var i=BX.ajax({url:this.BXIM.pathToAjax+"?"+s+"&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,lsId:"IM_UPDATE_STATE",lsTimeout:1,timeout:30,data:{IM_UPDATE_STATE:"Y",OPEN_MESSENGER:this.popupMessenger!=null?1:0,TAB:this.currentTab,FM:JSON.stringify(this.flashMessage),FN:JSON.stringify(this.notify.flashNotify),SITE_ID:BX.message("SITE_ID"),IM_AJAX_CALL:"Y",DESKTOP:this.desktop.ready()?"Y":"N",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(t)BX.localStorage.set("mus",true,5);if(this.desktop.ready()){var i="";if(e.ERROR==""){i="IM UPDATE STATE: success request ["+this.updateStateCount+"]"}else{i="IM UPDATE STATE: bad request ("+e.ERROR+") ["+this.updateStateCount+"]"}BX.desktop.log("phone."+this.BXIM.userEmail+".log",i);console.log(i)}this.updateStateCount++;if(e&&e.BITRIX_SESSID){BX.message({bitrix_sessid:e.BITRIX_SESSID})}if(e&&e.ERROR==""){if(!this.BXIM.checkRevision(e.REVISION))return false;if(this.BXIM.desktopDisk){this.BXIM.desktopDisk.checkRevision(e.DISK_REVISION)}BX.message({SERVER_TIME:e.SERVER_TIME});this.notify.updateNotifyCounters(e.COUNTERS,t);this.notify.updateNotifyMailCount(e.MAIL_COUNTER,t);if(!this.BXIM.xmppStatus&&e.XMPP_STATUS&&e.XMPP_STATUS=="Y")this.BXIM.xmppStatus=true;if(!this.BXIM.desktopStatus&&e.DESKTOP_STATUS&&e.DESKTOP_STATUS=="Y")this.BXIM.desktopStatus=true;var a=false;if(!(e.ONLINE.length<=0)){var n={};for(var r in this.users){if(typeof e.ONLINE[r]=="undefined"){if(this.users[r].status!="offline"){n[r]=this.users[r].status;this.users[r].status="offline";this.users[r].idle=0;this.users[r].mobileLastDate=0;a=true}}else{if(this.users[r].status!=e.ONLINE[r].status){n[r]=this.users[r].status;this.users[r].status=e.ONLINE[r].status;a=true}if(this.users[r].idle!=e.ONLINE[r].idle){this.users[r].idle=e.ONLINE[r].idle;a=true}if(this.users[r].mobileLastDate!=e.ONLINE[r].mobileLastDate){this.users[r].mobileLastDate=e.ONLINE[r].mobileLastDate;a=true}}}}if(typeof e.FILES!="undefined"){for(var o in e.FILES){if(!this.disk.files[o])this.disk.files[o]={};for(var r in e.FILES[o]){e.FILES[o][r].date=parseInt(e.FILES[o][r].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.disk.files[o][r]=e.FILES[o][r]}}}if(typeof e.MESSAGE!="undefined")for(var r in e.MESSAGE)e.MESSAGE[r].date=parseInt(e.MESSAGE[r].date)+parseInt(BX.message("USER_TZ_OFFSET"));BX.MessengerCommon.updateStateVar(e,t);if(typeof e.USERS_MESSAGE!="undefined")a=true;if(a){this.dialogStatusRedraw();BX.MessengerCommon.userListRedraw()}if(typeof e.NOTIFY!="undefined"){for(var r in e.NOTIFY){e.NOTIFY[r].date=parseInt(e.NOTIFY[r].date)+parseInt(BX.message("USER_TZ_OFFSET"));this.notify.notify[r]=e.NOTIFY[r];this.BXIM.lastRecordId=parseInt(r)>this.BXIM.lastRecordId?parseInt(r):this.BXIM.lastRecordId}for(var r in e.FLASH_NOTIFY)if(typeof this.notify.flashNotify[r]=="undefined")this.notify.flashNotify[r]=e.FLASH_NOTIFY[r];this.notify.changeUnreadNotify(e.UNREAD_NOTIFY,t)}if(BX.PULL&&e.PULL_CONFIG){BX.PULL.updateChannelID(e.PULL_CONFIG);BX.PULL.tryConnect()}this.setUpdateStateStep(false)}else if(e.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<=2){this.sendAjaxTry++;setTimeout(BX.delegate(function(){this.updateState(true,t,s)},this),2e3);BX.onCustomEvent(window,"onImError",[e.ERROR,e.BITRIX_SESSID])}else if(s!="UPDATE_STATE_RECONNECT"){if(e.ERROR=="AUTHORIZE_ERROR"){this.sendAjaxTry++;if(this.desktop.ready()){setTimeout(BX.delegate(function(){this.updateState(true,t,s)},this),1e4)}BX.onCustomEvent(window,"onImError",[e.ERROR])}else if(this.sendAjaxTry<5){this.sendAjaxTry++;if(this.sendAjaxTry>=2&&!this.BXIM.desktop.ready()){BX.onCustomEvent(window,"onImError",[e.ERROR]);return false}setTimeout(BX.delegate(function(){this.updateState(true,t,s)},this),6e4);BX.onCustomEvent(window,"onImError",[e.ERROR])}else{}}},this),onfailure:BX.delegate(function(){if(this.desktop.ready()){var e="IM UPDATE STATE: failure request (code: "+i.status+") ["+this.updateStateCount+"]";BX.desktop.log("phone."+this.BXIM.userEmail+".log",e);console.log(e)}this.updateStateCount++;this.sendAjaxTry=0;this.setUpdateStateStep(false);try{if(typeof i=="object"&&i.status==0&&s!="UPDATE_STATE_RECONNECT")BX.onCustomEvent(window,"onImError",["CONNECT_ERROR"])}catch(t){}},this)})},this),e?150:this.updateStateStep*1e3)};BX.Messenger.prototype.updateStateLight=function(e,t){if(!this.BXIM.tryConnect||this.popupMessengerConnectionStatusState=="offline")return false;e=e==true;t=t!=false;clearTimeout(this.updateStateTimeout);this.updateStateTimeout=setTimeout(BX.delegate(function(){BX.ajax({url:this.BXIM.pathToAjax+"?UPDATE_STATE_LIGHT&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,lsId:"IM_UPDATE_STATE_LIGHT",lsTimeout:1,timeout:this.updateStateStepDefault>10?this.updateStateStepDefault-2:10,data:{IM_UPDATE_STATE_LIGHT:"Y",SITE_ID:BX.message("SITE_ID"),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(s){if(t)BX.localStorage.set("musl",true,5);if(s&&s.BITRIX_SESSID){BX.message({bitrix_sessid:s.BITRIX_SESSID})}if(s&&s.ERROR==""){if(!this.BXIM.checkRevision(s.REVISION))return false;BX.message({SERVER_TIME:s.SERVER_TIME});this.notify.updateNotifyCounters(s.COUNTERS,t);if(BX.PULL&&s.PULL_CONFIG){BX.PULL.updateChannelID(s.PULL_CONFIG);BX.PULL.tryConnect()}this.updateStateLight(e,t)}else{if(s.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<=2){this.sendAjaxTry++;setTimeout(BX.delegate(function(){this.updateStateLight(true,t)},this),2e3);BX.onCustomEvent(window,"onImError",[s.ERROR,s.BITRIX_SESSID])}else if(s.ERROR=="AUTHORIZE_ERROR"){this.sendAjaxTry++;if(this.desktop.ready()){setTimeout(BX.delegate(function(){this.updateStateLight(true,t)},this),1e4)}BX.onCustomEvent(window,"onImError",[s.ERROR])}else if(this.sendAjaxTry<5){this.sendAjaxTry++;if(this.sendAjaxTry>=2&&!this.BXIM.desktop.ready()){BX.onCustomEvent(window,"onImError",[s.ERROR]);return false}setTimeout(BX.delegate(function(){this.updateStateLight(true,t)},this),6e4);BX.onCustomEvent(window,"onImError",[s.ERROR])}}},this),onfailure:BX.delegate(function(){this.sendAjaxTry=0;this.setUpdateStateStep(false);try{if(typeof _ajax=="object"&&_ajax.status==0)BX.onCustomEvent(window,"onImError",["CONNECT_ERROR"])}catch(e){}},this)})},this),e?150:this.updateStateStepDefault*1e3)};BX.Messenger.prototype.setClosingByEsc=function(e){if(this.popupMessenger==null)return false;if(e){if(!this.webrtc.callInit){this.popupMessenger.setClosingByEsc(true)}}else{this.popupMessenger.setClosingByEsc(false)}};BX.Messenger.prototype.extraOpen=function(e){this.setClosingByEsc(false);if(!this.BXIM.extraBind){BX.bind(window,"keydown",this.BXIM.extraBind=BX.proxy(function(e){if(e.keyCode==27){this.extraClose(true)}},this))}this.BXIM.extraOpen=true;this.BXIM.dialogOpen=false;BX.style(this.popupMessengerDialog,"display","none");BX.style(this.popupMessengerExtra,"display","block");this.popupMessengerExtra.innerHTML="";BX.adjust(this.popupMessengerExtra,{children:[e]});this.resizeMainWindow()};BX.Messenger.prototype.extraClose=function(e,t){setTimeout(BX.delegate(function(){this.setClosingByEsc(true)},this),200);if(this.BXIM.extraBind){BX.unbind(window,"keydown",this.BXIM.extraBind);this.BXIM.extraBind=null}this.BXIM.extraOpen=false;this.BXIM.dialogOpen=true;e=e==true;t=t!=false;if(this.BXIM.notifyOpen)this.notify.closeNotify();this.closeMenuPopup();if(this.currentTab==0){this.extraOpen(BX.create("div",{attrs:{style:"padding-top: 300px"},props:{className:"bx-messenger-box-empty"},html:BX.message("IM_M_EMPTY")}))}else{BX.style(this.popupMessengerDialog,"display","block");BX.style(this.popupMessengerExtra,"display","none");this.popupMessengerExtra.innerHTML="";if(e){this.openChatFlag=this.currentTab.toString().substr(0,4)=="chat";BX.MessengerCommon.openDialog(this.currentTab,false,t)}}this.resizeMainWindow()};BX.Messenger.prototype.sendMessage=function(e){if(this.popupMessengerConnectionStatusState!="online")return false;e=typeof e=="string"||typeof e=="number"?e:this.currentTab;BX.MessengerCommon.endSendWriting(e);this.popupMessengerTextarea.value=this.popupMessengerTextarea.value.replace(" "," ");this.popupMessengerTextarea.value=BX.util.trim(this.popupMessengerTextarea.value);if(this.popupMessengerTextarea.value.length==0)return false;if(this.BXIM.language=="ru"&&BX.correctText&&this.BXIM.settings.correctText){this.popupMessengerTextarea.value=BX.correctText(this.popupMessengerTextarea.value)}this.addRecentSmile(this.popupMessengerTextarea.value);this.popupMessengerTextarea.value=this.popupMessengerTextarea.value.replace(/\[icon\=(\d+)([^\]]*)\]/gi,BX.delegate(function(e,t){t="icon"+t;var s="";if(this.smile[t].WIDTH==this.smile[t].HEIGHT){s=s+" size="+this.smile[t].WIDTH}else{if(this.smile[t].WIDTH){s=s+" width="+this.smile[t].WIDTH}if(this.smile[t].HEIGHT){s=s+" height="+this.smile[t].NAME}}if(this.smile[t].NAME){s=s+" title="+this.smile[t].NAME}return"[icon="+this.smile[t].IMAGE+s+"]"},this));if(this.popupMessengerTextarea.value=="/clear"){this.popupMessengerTextarea.value="";this.textareaCheckText();this.textareaHistory[this.currentTab]="";this.showMessage[this.currentTab]=[];BX.MessengerCommon.drawTab(this.currentTab,true);if(this.desktop.ready())console.log("NOTICE: User use /clear");return false}else if(this.popupMessengerTextarea.value=="/webrtcDebug"||this.popupMessengerTextarea.value=="/webrtcDebug on"||this.popupMessengerTextarea.value=="/webrtcDebug off"){if(this.popupMessengerTextarea.value=="/webrtcDebug")this.webrtc.debug=this.webrtc.debug?false:true;else if(this.popupMessengerTextarea.value=="/webrtcDebug on")this.webrtc.debug=true;else if(this.popupMessengerTextarea.value=="/webrtcDebug off")this.webrtc.debug=false;if(this.webrtc.debug){this.tooltip(this.popupMessengerTextareaSendType.previousSibling,BX.message("IM_TIP_WEBRTC_ON"))}else{this.tooltip(this.popupMessengerTextareaSendType.previousSibling,BX.message("IM_TIP_WEBRTC_OFF"))}if(BX.PULL&&BX.PULL.returnPrivateVar("_revision")>=14){BX.PULL.capturePullEvent(this.webrtc.debug)}this.textareaHistory[this.currentTab]="";this.popupMessengerTextarea.value="";this.textareaCheckText();if(console&&console.log)console.log("NOTICE: User use /webrtcDebug and TURN "+(this.webrtc.debug?"ON":"OFF")+" debug");if(this.desktop.ready()&&!this.webrtc.debug){BX.desktop.windowReload()}return false}else if(this.popupMessengerTextarea.value=="/windowReload"){this.textareaHistory[this.currentTab]="";this.popupMessengerTextarea.value="";this.textareaCheckText();location.reload();if(this.desktop.ready())console.log("NOTICE: User use /windowReload");return false}else if(this.popupMessengerTextarea.value=="/correctText on"||this.popupMessengerTextarea.value=="/correctText off"){if(this.popupMessengerTextarea.value=="/correctText on"){this.BXIM.settings.correctText=true;this.tooltip(this.popupMessengerTextareaSendType.previousSibling,BX.message("IM_TIP_AC_ON"))}else{this.BXIM.settings.correctText=false;this.tooltip(this.popupMessengerTextareaSendType.previousSibling,BX.message("IM_TIP_AC_OFF"))}this.BXIM.saveSettings({correctText:this.BXIM.settings.correctText});console.log("NOTICE: User use /correctText");return false}else if(this.popupMessengerTextarea.value=="/getChatId"){var t=0;if(this.openChatFlag){t=this.currentTab.toString().substr(4)}else{t=this.userChat[this.currentTab]}this.tooltip(this.popupMessengerTextareaSendType.previousSibling,BX.message("IM_CHAT_ID_IS").replace("#CHAT_ID#","<b>"+t+"</b>"));console.log("NOTICE: User use /getChatId");this.popupMessengerTextarea.value="";this.textareaCheckText();return false}else if(this.popupMessengerTextarea.value.indexOf("/startTrackStatus")==0||this.popupMessengerTextarea.value.indexOf("/stopTrackStatus")==0){var s=this.popupMessengerTextarea.value.split(" ")[1];if(!s&&!this.openChatFlag){s=this.currentTab}if(s=="all"||this.users[s]){if(this.popupMessengerTextarea.value.indexOf("/startTrackStatus")==0){this.startTrackStatus(s);this.tooltip(this.popupMessengerTextareaSendType.previousSibling,BX.message("IM_M_S_ON"));console.log("NOTICE: User use /startTrackStatus "+s)}else{this.stopTrackStatus(s);this.tooltip(this.popupMessengerTextareaSendType.previousSibling,BX.message("IM_M_S_OFF"));console.log("NOTICE: User use /stopTrackStatus "+s)}}this.popupMessengerTextarea.value="";this.textareaCheckText();return false}else if(this.popupMessengerTextarea.value.indexOf("/color")==0){var i=this.popupMessengerTextarea.value.split(" ")[1];if(i&&this.openChatFlag){BX.MessengerCommon.setColor(i,this.currentTab.toString().substr(4))}this.popupMessengerTextarea.value="";this.textareaCheckText();return false}else if(this.popupMessengerTextarea.value.indexOf("/rename")==0){var a=this.popupMessengerTextarea.value.substr(8);if(a&&this.openChatFlag){BX.MessengerCommon.renameChat(this.currentTab.toString().substr(4),a)}this.popupMessengerTextarea.value="";this.textareaCheckText();return false}if(this.desktop.ready()){if(this.popupMessengerTextarea.value=="/openDeveloperTools"){this.textareaHistory[this.currentTab]="";this.popupMessengerTextarea.value="";this.textareaCheckText();BX.desktop.openDeveloperTools();console.log("NOTICE: User use /openDeveloperTools");return false}else if(this.popupMessengerTextarea.value=="/clearWindowSize"){BX.desktop.setWindowSize({Width:BX.desktop.initWidth,Height:BX.desktop.initHeight});this.BXIM.setLocalConfig("global_msz_v2",false);BX.desktop.apiReady=false;location.reload();if(this.desktop.ready())console.log("NOTICE: User use /clearWindowSize");return false}}if(this.popupMessengerTextarea.value=="/showOnlyChat"){BX.MessengerCommon.recentListRedraw({showOnlyChat:true});this.textareaHistory[this.currentTab]="";this.popupMessengerTextarea.value="";this.textareaCheckText();return false}var t=e.toString().substr(0,4)=="chat"?e.toString().substr(4):this.userChat[e]?this.userChat[e]:0;if(this.errorMessage[e]){BX.MessengerCommon.sendMessageRetry();this.errorMessage[e]=false}this.popupMessengerTextarea.value=BX.MessengerCommon.prepareMention(e,this.popupMessengerTextarea.value);var n=this.messageTmpIndex;this.message["temp"+n]={id:"temp"+n,chatId:t,senderId:this.BXIM.userId,recipientId:e,date:BX.MessengerCommon.getNowDate(),text:BX.MessengerCommon.prepareText(this.popupMessengerTextarea.value,true)};if(!this.showMessage[e])this.showMessage[e]=[];this.showMessage[e].push("temp"+n);this.messageTmpIndex++;BX.localStorage.set("mti",this.messageTmpIndex,5);if(this.popupMessengerTextarea==null||e!=this.currentTab)return false;clearTimeout(this.textareaHistoryTimeout);if(!BX.browser.IsAndroid()&&!BX.browser.IsIOS())BX.focus(this.popupMessengerTextarea);var r=BX.findChildByClassName(this.popupMessengerBodyWrap,"bx-messenger-content-load");if(r)BX.remove(r);var o=BX.findChildByClassName(this.popupMessengerBodyWrap,"bx-messenger-content-empty");if(o)BX.remove(o);BX.MessengerCommon.drawMessage(e,this.message["temp"+n]);BX.MessengerCommon.sendMessageAjax(n,e,this.popupMessengerTextarea.value,e.toString().substr(0,4)=="chat");if(this.BXIM.settings.status!="dnd"){this.BXIM.playSound("send")}this.textareaHistory[this.currentTab]="";this.popupMessengerTextarea.value="";this.textareaCheckText();setTimeout(BX.delegate(function(){this.popupMessengerTextarea.value="";this.textareaCheckText()},this),0);return true};BX.Messenger.prototype.textareaCheckText=function(e){e=e||{};e.textarea=e.textarea||"default";var t=e.textarea=="createChat"?this.popupCreateChatTextarea:this.popupMessengerTextarea;if(t.value.length>0){if(t.parentNode.parentNode.className.indexOf("bx-messenger-textarea-with-text")==-1){BX.addClass(t.parentNode.parentNode,"bx-messenger-textarea-with-text")}}else{if(t.parentNode&&t.parentNode.perentNode&&t.parentNode.parentNode.className.indexOf("bx-messenger-textarea-with-text")>=0){BX.removeClass(t.parentNode.parentNode,"bx-messenger-textarea-with-text")}}};BX.Messenger.prototype.openCommandDialog=function(){var e=this.popupMessengerTextarea;if(e.selectionStart==0||e.value.charCodeAt(e.selectionStart-1)==10||e.value.charCodeAt(e.selectionStart-1)==13){if(e.value.substr(-1)!="/"){this.insertTextareaText(e,"/")}}else{if(e.value.substr(-1)!="/"){this.insertTextareaText(e,"\n");this.insertTextareaText(e,"/")}}e.focus();var t=e.selectionStart;e.value.substr(0);this.textareaCommandListUpdate("")};BX.Messenger.prototype.textareaCommandListUpdate=function(e){if(e===false){this.commandListen=false;this.commandSelect="";this.commandSelectIndex=1;if(this.commandPopup)this.commandPopup.close()}else{this.commandListen=true;this.commandList=BX.MessengerCommon.prepareCommandList(e);if(this.commandList.length>0){this.commandSelectIndex=1;this.commandSelect=this.commandList[this.commandSelectIndex].command==">>"?this.commandList[this.commandSelectIndex].command:this.commandList[this.commandSelectIndex].command.substr(1);var t=false;if(!this.commandPopup){this.commandPopup=new BX.PopupWindow("bx-messenger-command",this.popupMessengerTextareaPlace,{lightShadow:true,autoHide:true,offsetLeft:5,bindOptions:{position:"top"},zIndex:200,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){if(this.commandPopup){this.commandPopup=null;this.textareaCommandListUpdate(false)}},this)},content:BX.create("div",{props:{className:"bx-messenger-command-popup "+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},children:[BX.create("div",{props:{className:"bx-messenger-command-popup-header"},children:[BX.create("span",{props:{className:"bx-messenger-command-popup-title"},html:BX.message("IM_COMMAND_TITLE")}),BX.create("span",{props:{className:"bx-messenger-command-popup-help"},children:[BX.create("span",{props:{className:"bx-messenger-command-popup-help-item"},html:BX.message("IM_COMMAND_H_1")}),BX.create("span",{props:{className:"bx-messenger-command-popup-help-item"},html:BX.message("IM_COMMAND_H_2")}),BX.create("span",{props:{className:"bx-messenger-command-popup-help-item"},html:BX.message("IM_COMMAND_H_3")})]})]}),this.commandPopupList=BX.create("div",{props:{className:"bx-messenger-command-popup-list"},html:this.textareaCommandListItems()})]})});this.commandPopup.setAngle({offset:5});t=true}if(t){this.commandPopup.show();BX.bindDelegate(this.commandPopupList,"click",{className:"bx-messenger-command-popup-item"},BX.delegate(function(){var e=BX.proxy_context.getAttribute("data-id");var t="";for(var s=0;s<this.command.length;s++){if(this.command[s].id==e){t=this.command[s].command.substr(1)}}this.commandSelect=t;this.textareaCommandClick()},this));BX.bindDelegate(this.commandPopupList,"mouseover",{className:"bx-messenger-command-popup-item"},BX.delegate(function(){var e=BX.proxy_context.getAttribute("data-id");if(!e){return true}var t="";for(var s=0;s<this.command.length;s++){if(this.command[s].id==e){t=this.command[s].command.substr(1)}}this.commandSelectIndex=parseInt(BX.proxy_context.getAttribute("data-index"));this.commandSelect=t;var i=BX.findChildByClassName(this.commandPopupList,"bx-messenger-command-popup-item-selected");if(i){BX.removeClass(i,"bx-messenger-command-popup-item-selected")}BX.addClass(BX.proxy_context,"bx-messenger-command-popup-item-selected");t="/"+this.commandSelect;var a=this.popupMessengerTextarea;var n=a.value.substr(0,a.selectionStart).lastIndexOf("/");var r=a.value.substr(a.selectionStart);var o=a.value.substr(0,n);a.value=o+t+""+r;a.selectionStart=n+t.length;a.selectionEnd=a.selectionStart},this))}else if(this.commandList.length>0){this.commandPopupList.innerHTML=this.textareaCommandListItems();this.commandPopup.adjustPosition({forceBindPosition:true,position:"top"})}}else{this.commandSelectIndex=0;this.commandSelect=e;if(this.commandPopup){var s=this.commandPopup;this.commandPopup=null;s.close()}}}};BX.Messenger.prototype.textareaCommandListItems=function(){var e="";var t=false;for(var s=0;s<this.commandList.length;s++){if(this.commandList[s].type=="category"){e+='<div class="bx-messenger-command-popup-item-category">'+this.commandList[s].title+"</div>"}else{e+='<div class="bx-messenger-command-popup-item bx-messenger-command-popup-item-'+s+" "+(this.commandSelectIndex==s?"bx-messenger-command-popup-item-selected":"")+'" data-id="'+this.commandList[s].id+'" data-index="'+s+'">'+'<span class="bx-messenger-command-popup-item-text">'+'<span class="bx-messenger-command-popup-item-command">'+this.commandList[s].command+"</span>"+'<span class="bx-messenger-command-popup-item-params">'+this.commandList[s].params+"</span>"+"</span>"+'<span class="bx-messenger-command-popup-item-title">'+this.commandList[s].title+"</span>"+"</div>"}}return e};BX.Messenger.prototype.textareaCommandClick=function(){var e="";if(this.commandSelect){e=this.commandSelect==">>"?">> ":"/"+this.commandSelect+" "}var t=this.popupMessengerTextarea;var s=t.value.substr(0,t.selectionStart).lastIndexOf("/");var i=t.value.substr(t.selectionStart);var a=t.value.substr(0,s);t.value=a+e+i;t.selectionStart=s+e.length;t.selectionEnd=t.selectionStart;this.textareaCommandListUpdate(false);t.focus()};BX.Messenger.prototype.textareaCommandSelect=function(e){if(this.commandList.length<=0||this.commandList.length==2){return this.commandSelect}if(e=="up"){if(this.commandSelectIndex==1){this.commandSelectIndex=this.commandList.length-1}else{this.commandSelectIndex-=1;if(this.commandList[this.commandSelectIndex].type=="category"){this.commandSelectIndex-=1}}}else{if(this.commandSelectIndex==this.commandList.length-1){this.commandSelectIndex=1}else{this.commandSelectIndex+=1;if(this.commandList[this.commandSelectIndex].type=="category"){this.commandSelectIndex+=1}}}this.commandSelect=this.commandList[this.commandSelectIndex].command==">>"?this.commandList[this.commandSelectIndex].command:this.commandList[this.commandSelectIndex].command.substr(1);var t=BX.findChildByClassName(this.commandPopupList,"bx-messenger-command-popup-item-selected");if(t){BX.removeClass(t,"bx-messenger-command-popup-item-selected")}t=BX.findChildByClassName(this.commandPopupList,"bx-messenger-command-popup-item-"+this.commandSelectIndex);if(t){BX.addClass(t,"bx-messenger-command-popup-item-selected");var s=BX.MessengerCommon.isElementVisibleOnScreen(t,this.commandPopupList,true);if(!s.top||!s.bottom){var i=0;if(this.commandSelectIndex==this.commandList.length-1){i=this.commandPopupList.scrollHeight}else if(this.commandSelectIndex>1){if(e=="up"){i=this.commandPopupList.scrollTop-s.coords.top*-1}else{i=this.commandPopupList.scrollTop+s.coords.top-this.commandPopupList.offsetHeight+t.offsetHeight}}if(this.commandPopupListAnimation!=null){this.commandPopupListAnimation.stop()}(this.commandPopupListAnimation=new BX.easing({duration:400,start:{scroll:this.commandPopupList.scrollTop},finish:{scroll:i},transition:BX.easing.makeEaseInOut(BX.easing.transitions.quart),step:BX.delegate(function(e){this.commandPopupList.scrollTop=e.scroll},this)})).animate()}}return this.commandSelect};BX.Messenger.prototype.textareaPrepareText=function(e,t,s,i){var a=true;if(this.commandListen){if(t.altKey==true||t.ctrlKey==true||t.metaKey==true){return BX.PreventDefault(t)}else if(t.keyCode==8){var n=e.value.substr(e.selectionStart-1,1);if(n=="/"){this.textareaCommandListUpdate(false)}else{setTimeout(BX.delegate(function(){var t=e.value.substr(0,e.selectionStart).lastIndexOf("/")+1;var s=e.value.substr(t,e.selectionStart-t);this.textareaCommandListUpdate(s)},this),10)}}else if(t.keyCode==27){this.commandListen=false;var r=e.value.substr(0,e.selectionStart).lastIndexOf("/");var o=e.value.substr(e.selectionStart);var l=e.value.substr(0,r+1);e.value=l+o;e.selectionStart=r+1;e.selectionEnd=e.selectionStart;this.textareaCommandListUpdate(false);return BX.PreventDefault(t)}else if(t.keyCode==9){this.textareaCommandSelect("down");command="/"+this.commandSelect;var r=e.value.substr(0,e.selectionStart).lastIndexOf("/");var o=e.value.substr(e.selectionStart);var l=e.value.substr(0,r);e.value=l+command+""+o;e.selectionStart=r+command.length;e.selectionEnd=e.selectionStart;return BX.PreventDefault(t)}else if(t.keyCode==39||t.keyCode==37){return BX.PreventDefault(t)}else if(t.keyCode==38||t.keyCode==40){if(t.keyCode==38){this.textareaCommandSelect("up")}else if(t.keyCode==40){this.textareaCommandSelect("down")}command="/"+this.commandSelect;var r=e.value.substr(0,e.selectionStart).lastIndexOf("/");var o=e.value.substr(e.selectionStart);var l=e.value.substr(0,r);e.value=l+command+o;e.selectionStart=r+command.length;e.selectionEnd=e.selectionStart;return BX.PreventDefault(t)}else if(t.keyCode==13||t.keyCode==32){this.textareaCommandClick();return BX.PreventDefault(t)}else{setTimeout(BX.delegate(function(){var t=e.value.substr(0,e.selectionStart).lastIndexOf("/")+1;var s=e.value.substr(e.value.substr(0,e.selectionStart).lastIndexOf("/")+1,e.selectionStart-t);this.textareaCommandListUpdate(s)},this),10)}}else if(this.mentionListen){if(t.keyCode==27){this.mentionListen=false;this.mentionDelimiter="";return BX.PreventDefault(t)}else if(t.keyCode==13){this.popupContactListSearchInput.value="";var p=BX.findChildByClassName(this.popupChatDialogContactListElements,"bx-messenger-cl-item");if(p){p.getAttribute("data-userId");var h=e.value.substr(0,e.selectionEnd);h=h.substr(h.lastIndexOf(this.mentionDelimiter),e.selectionEnd-h.lastIndexOf(this.mentionDelimiter));
e.value=e.value.replace(h,p.getAttribute("data-name")+" ");BX.MessengerCommon.addMentionList(this.currentTab,p.getAttribute("data-name"),p.getAttribute("data-userId"));this.popupChatDialog.close()}return BX.PreventDefault(t)}else{setTimeout(BX.delegate(function(){var t=e.value.substr(0,e.selectionEnd);var s=t.lastIndexOf(this.mentionDelimiter);var i=e.selectionEnd-t.lastIndexOf(this.mentionDelimiter);t=t.substr(s,i);if(t.length<=0||s<0){if(this.popupChatDialog)this.popupChatDialog.close();return false}t=t.substr(1);if(t.substr(0,1)==" "){if(this.popupChatDialog)this.popupChatDialog.close();return false}else if(t.length<=3&&t.substr(0,1).substr(0,1).match(/\d$/)){if(this.popupChatDialog)this.popupChatDialog.close();return false}this.popupChatDialogContactListSearch.value=t;BX.MessengerCommon.contactListPrepareSearch("popupChatDialogContactListElements",this.popupChatDialogContactListElements,this.popupChatDialogContactListSearch.value,{viewOffline:true,viewChat:false,viewOpenChat:true,exceptUsers:[],timeout:100,callback:{empty:BX.delegate(function(){this.popupChatDialog.close();return false},this)}})},this),10)}}else if(t.altKey==true&&t.ctrlKey==true){}else if(t.shiftKey==true&&(t.keyCode==61||t.keyCode==50||t.keyCode==187||t.keyCode==187)||t.keyCode==107){var c=this.BXIM.messenger.openChatFlag&&this.BXIM.messenger.chat[this.BXIM.messenger.currentTab.toString().substr(4)]&&this.BXIM.messenger.chat[this.BXIM.messenger.currentTab.toString().substr(4)].type=="livechat";if(!this.mentionListen&&!c){setTimeout(BX.delegate(function(){var t=e.value.substr(e.selectionEnd-1,1);if(!(t=="@"||t=="+"))return false;this.mentionListen=true;this.mentionDelimiter=t;this.openChatDialog({type:"MENTION",bind:e,focus:false,delimiter:t});this.setClosingByEsc(false)},this),300)}}else if(t.metaKey==true||t.ctrlKey==true){var u={66:"b",83:"s",73:"i",85:"u"};if(u[t.keyCode]||t.keyCode==84||!this.desktop.ready()&&BX.browser.IsChrome()&&t.keyCode==69){var r=e.selectionStart;var d=e.selectionEnd;resultText=e.value.substring(r,d);if(t.keyCode==84||!this.desktop.ready()&&BX.browser.IsChrome()&&t.keyCode==69){if(r==d){r=0;d=e.value.length;resultText=e.value}e.value=e.value.substring(0,r)+BX.correctText(resultText,{replace_way:"AUTO",mixed:true})+e.value.substring(d,e.value.length);e.selectionStart=r;e.selectionEnd=d}else{if(r==d){return BX.PreventDefault(t)}resultTagStart=e.value.substring(r,r+3);resultTagEnd=e.value.substring(d-4,d);if(resultTagStart.toLowerCase()=="["+u[t.keyCode]+"]"&&resultTagEnd.toLowerCase()=="[/"+u[t.keyCode]+"]"){e.value=e.value.substring(0,r)+e.value.substring(r+3,d-4)+e.value.substring(d,e.value.length);e.selectionStart=r;e.selectionEnd=d-7}else{e.value=e.value.substring(0,r)+"["+u[t.keyCode]+"]"+resultText+"[/"+u[t.keyCode]+"]"+e.value.substring(d,e.value.length);e.selectionStart=r;e.selectionEnd=d+7}}return BX.PreventDefault(t)}}else if((t.keyCode==191||t.keyCode==111||t.keyCode==220)&&e==this.popupMessengerTextarea){if(e.selectionStart==0||e.value.charCodeAt(e.selectionStart-1)==10||e.value.charCodeAt(e.selectionStart-1)==13){setTimeout(BX.delegate(function(){var t=e.value.substr(e.selectionEnd-1,1);if(t=="/"){this.textareaCommandListUpdate("")}},this),300)}}if(t.keyCode==9){this.insertTextareaText(e," ");return BX.PreventDefault(t)}if(t.keyCode==27&&!this.desktop.ready()){if(t.shiftKey){i()}else if(e==this.popupCreateChatTextarea){if(this.popupCreateChatTextarea.value==""){i()}else{return BX.PreventDefault(t)}}else if(e!=this.popupMessengerTextarea||this.popupMessengerTextarea.value==""){i()}}else if(t.keyCode==38&&this.popupMessengerLastMessage>0&&BX.util.trim(e.value).length<=0){this.editMessage(this.popupMessengerLastMessage)}else if(this.BXIM.settings.sendByEnter==true&&(t.ctrlKey==true||t.altKey==true)&&t.keyCode==13)this.insertTextareaText(e,"\n");else if(this.BXIM.settings.sendByEnter==true&&t.shiftKey==false&&t.keyCode==13)a=s();else if(this.BXIM.settings.sendByEnter==false&&t.ctrlKey==true&&t.keyCode==13)a=s();else if(this.BXIM.settings.sendByEnter==false&&(t.metaKey==true||t.altKey==true)&&t.keyCode==13&&BX.browser.IsMac())a=s();clearTimeout(this.textareaHistoryTimeout);this.textareaHistoryTimeout=setTimeout(BX.delegate(function(){this.textareaHistory[this.currentTab]=this.popupMessengerTextarea.value},this),200);if(BX.util.trim(e.value).length>2)BX.MessengerCommon.sendWriting(this.currentTab);if(!a)return BX.PreventDefault(t)};BX.Messenger.prototype.openAnswersMenu=function(e){this.BXIM.openConfirm(BX.message("IM_OL_ANSWERS_SOON"),[new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})],true)};BX.Messenger.prototype.openFormsMenu=function(e){this.BXIM.openConfirm(BX.message("IM_OL_FORMS_SOON"),[new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})],true)};BX.Messenger.prototype.addRecentSmile=function(e,t){t=t||"";if(this.desktop.ready()&&BX.browser.IsMac()&&!this.desktop.enableInVersion(36))return false;var s=e.match(/\[icon\=([^\]]*)\]/gi);if(s&&s.length){var i=[];var a=this.BXIM.getLocalConfig("smiles-recent",[])||[];for(var n=0;n<a.length;n++){i.push(a[n].IMAGE)}for(var n=0;n<s.length;n++){var r=s[n];var o=r.match(/icon\=(\S+[^\s.,> )\];\'\"!?])/i);if(o&&o[1]){o=o[1];if(i&&i.indexOf(o)>-1||o.match(/^(\d+)$/)){continue}}else{continue}if(t&&o!=t){continue}var l={IMAGE:o,HEIGHT:20,WIDTH:20,NAME:""};var p=r.match(/size\=(\d+)/i);if(p&&p[1]){l["WIDTH"]=p[1];l["HEIGHT"]=p[1]}else{var h=r.match(/width\=(\d+)/i);if(h&&h[1]){l["WIDTH"]=h[1]}var c=r.match(/height\=(\d+)/i);if(c&&c[1]){l["HEIGHT"]=c[1]}if(l["WIDTH"]&&!l["HEIGHT"]){l["HEIGHT"]=l["WIDTH"]}else if(l["HEIGHT"]&&!l["WIDTH"]){l["WIDTH"]=l["HEIGHT"]}else{l["WIDTH"]=20;l["HEIGHT"]=20}}var u=r.match(/title\=(.*[^\s\]])/i);if(u&&u[1]){u=u[1];if(u.indexOf("width=")>-1){u=u.substr(0,u.indexOf("width="))}if(u.indexOf("height=")>-1){u=u.substr(0,u.indexOf("height="))}if(u.indexOf("size=")>-1){u=u.substr(0,u.indexOf("size="))}if(u){u=BX.util.trim(u);l["NAME"]=u}}a.push(l);this.injectRecentSmile(l)}this.BXIM.setLocalConfig("smiles-recent",a,26e5)}return s?s.length:0};BX.Messenger.prototype.removeRecentSmile=function(e){if(this.desktop.ready()&&BX.browser.IsMac()&&!this.desktop.enableInVersion(36))return false;var t="";if(this.smile[e]){t=this.smile[e].IMAGE}if(t){var s=[];var i=this.BXIM.getLocalConfig("smiles-recent",[])||[];for(var a=0;a<i.length;a++){if(t!=i[a].IMAGE){s.push(i[a])}}this.BXIM.setLocalConfig("smiles-recent",s,26e5);delete this.smile[e]}return true};BX.Messenger.prototype.getRecentSmiles=function(){if(this.desktop.ready()&&BX.browser.IsMac()&&!this.desktop.enableInVersion(36))return false;if(!this.smileSet)return false;this.smileSet.push({ID:"icons",NAME:BX.message("IM_ICON_SET"),PARENT_ID:0,TYPE:"G"});var e=this.BXIM.getLocalConfig("smiles-recent",[])||[];if(e.length<=0){return true}this.smileRecentId=e.length+1;for(var t=0;t<e.length;t++){this.injectRecentSmile(e[t])}};BX.Messenger.prototype.injectRecentSmile=function(e){var t=BX.clone(e);if(typeof t!="object")return false;t.TITLE=t.NAME;if(!t.TITLE){t.TITLE=t.IMAGE.substring(t.IMAGE.lastIndexOf("/")+1);t.TITLE=t.TITLE.substring(0,t.TITLE.lastIndexOf("."))}this.smile["icon"+this.smileRecentId]={NAME:t.NAME,HEIGHT:t.HEIGHT>100?100:t.HEIGHT,WIDTH:t.WIDTH>100?100:t.WIDTH,IMAGE:t.IMAGE,TYPING:"[icon="+this.smileRecentId+" title="+t.TITLE+"]",SET_ID:"icons"};this.smileRecentId++};BX.Messenger.prototype.openSmileMenu=function(e){e=e||{};e.textarea=e.textarea||"default";this.closePopupFileMenu();if(this.popupPopupMenu!=null)this.popupPopupMenu.destroy();if(this.popupChatDialog!=null){this.popupChatDialog.destroy()}if(this.popupSmileMenu!=null){this.popupSmileMenu.destroy();return false}if(this.commandPopup!=null){this.commandPopup.destroy()}if(this.smile==false){this.tooltip(this.popupMessengerSmileButton,BX.message("IM_SMILE_NA"),{offsetLeft:-20});return false}var t={};for(var s in this.smile){if(!t[this.smile[s].SET_ID])t[this.smile[s].SET_ID]=[];var i=BX.util.htmlspecialcharsback(this.smile[s].TYPING);t[this.smile[s].SET_ID].push(BX.create("img",{props:{className:"bx-messenger-smile-gallery-image"},attrs:{"data-id":s,"data-code":i,"data-textarea":e.textarea,style:"width: "+this.smile[s].WIDTH+"px; height: "+this.smile[s].HEIGHT+"px",src:this.smile[s].IMAGE,alt:this.smile[s].TYPING,title:BX.util.htmlspecialcharsback(this.smile[s].NAME)}}))}var a=0;var n=[];var r=[BX.create("span",{props:{className:"bx-messenger-smile-nav-name"},html:BX.message("IM_SMILE_SET")})];if(!this.smileSet[this.smileCurrentSet]||typeof t[this.smileSet[this.smileCurrentSet]["ID"]]=="undefined"){this.smileCurrentSet=0}var s=0;var o="";for(var l=0;l<this.smileSet.length;l++){if(typeof t[this.smileSet[l]["ID"]]=="undefined")continue;s=this.smileSet[l]["ID"];o=this.smileSet[l]["NAME"];n.push(BX.create("span",{attrs:{"data-set-id":s},props:{className:"bx-messenger-smile-gallery-set"+(a!=this.smileCurrentSet?" bx-messenger-smile-gallery-set-hide":"")},children:t[s]}));r.push(BX.create("span",{attrs:{"data-set-id":s,title:BX.util.htmlspecialcharsback(o)},props:{className:"bx-messenger-smile-nav-item"+(a==this.smileCurrentSet?" bx-messenger-smile-nav-item-active":"")}}));a++}this.popupSmileMenu=new BX.PopupWindow("bx-messenger-popup-smile",this.popupMessengerSmileButton,{lightShadow:false,offsetTop:0,offsetLeft:-38,autoHide:true,closeByEsc:true,bindOptions:{position:"top"},zIndex:200,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupSmileMenu=null},this)},content:BX.create("div",{props:{className:"bx-messenger-smile"+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},children:[this.popupSmileMenuGallery=BX.create("div",{props:{className:"bx-messenger-smile-gallery"},children:n}),this.popupSmileMenuSet=BX.create("div",{props:{className:"bx-messenger-smile-nav"+(a<=1?" bx-messenger-smile-nav-disabled":"")},children:r})]})});this.popupSmileMenu.setAngle({offset:74});this.popupSmileMenu.show();BX.bindDelegate(this.popupSmileMenuGallery,"click",{className:"bx-messenger-smile-gallery-image"},BX.delegate(function(){var e=BX.proxy_context.getAttribute("data-textarea")=="createChat"?this.popupCreateChatTextarea:this.popupMessengerTextarea;this.insertTextareaText(e," "+BX.proxy_context.getAttribute("data-code")+" ",false);this.popupSmileMenu.close();e.focus()},this));BX.bindDelegate(this.popupSmileMenuGallery,"contextmenu",{className:"bx-messenger-smile-gallery-image"},BX.delegate(function(e){var t=BX.proxy_context.getAttribute("data-code").match(/\[icon\=([^\]]*)\]/gi);if(t){this.openPopupMenu(BX.proxy_context,"iconMenu",true,{closeSmiles:false});return BX.PreventDefault(e)}},this));BX.bindDelegate(this.popupSmileMenuSet,"click",{className:"bx-messenger-smile-nav-item"},BX.delegate(function(){if(BX.hasClass(BX.proxy_context,"bx-messenger-smile-nav-item-active"))return false;var e=BX.findChildrenByClassName(this.popupSmileMenuGallery,"bx-messenger-smile-gallery-set",false);var t=BX.findChildrenByClassName(this.popupSmileMenuSet,"bx-messenger-smile-nav-item",false);for(var s=0;s<t.length;s++){if(BX.proxy_context==t[s]){BX.removeClass(e[s],"bx-messenger-smile-gallery-set-hide");BX.addClass(t[s],"bx-messenger-smile-nav-item-active");this.smileCurrentSet=s;this.BXIM.setLocalConfig("smiles-current-set",s)}else{BX.addClass(e[s],"bx-messenger-smile-gallery-set-hide");BX.removeClass(t[s],"bx-messenger-smile-nav-item-active")}}},this));BX.onCustomEvent("onImOpenSmileMenu",[]);return false};BX.Messenger.prototype.connectionStatus=function(e,t){t=typeof t=="undefined"?true:t;if(!(e=="online"||e=="connecting"||e=="offline"))return false;if(this.popupMessengerConnectionStatusState==e)return false;this.popupMessengerConnectionStatusState=e;var s="";if(e=="offline"){this.popupMessengerConnectionStatusStateText=BX.message("IM_CS_OFFLINE");s="bx-messenger-connection-status-offline"}else if(e=="connecting"){this.popupMessengerConnectionStatusStateText=BX.message("IM_CS_CONNECTING");s="bx-messenger-connection-status-connecting"}else if(e=="online"){this.popupMessengerConnectionStatusStateText=BX.message("IM_CS_ONLINE");s="bx-messenger-connection-status-online"}clearTimeout(this.popupMessengerConnectionStatusTimeout);if(!this.popupMessengerConnectionStatus)return false;if(e=="online"){if(t){if(this.redrawTab[this.currentTab]){BX.MessengerCommon.openDialog(this.currentTab)}else{this.updateState(true,false,"UPDATE_STATE_RECONNECT")}}clearTimeout(this.popupMessengerConnectionStatusTimeout);this.popupMessengerConnectionStatusTimeout=setTimeout(BX.delegate(function(){BX.removeClass(this.popupMessengerConnectionStatus,"bx-messenger-connection-status-show");this.popupMessengerConnectionStatusTimeout=setTimeout(BX.delegate(function(){BX.removeClass(this.popupMessengerConnectionStatus,"bx-messenger-connection-status-hide")},this),1e3)},this),4e3)}this.popupMessengerConnectionStatus.className="bx-messenger-connection-status bx-messenger-connection-status-show "+s;this.popupMessengerConnectionStatusText.innerHTML=this.popupMessengerConnectionStatusStateText;return true};BX.Messenger.prototype.editMessage=function(e){if(!BX.MessengerCommon.checkEditMessage(e))return false;BX.removeClass(this.popupMessengerEditForm,"bx-messenger-editform-disable");BX.removeClass(this.popupMessengerEditForm,"bx-messenger-editform-hide");BX.addClass(this.popupMessengerEditForm,"bx-messenger-editform-show");this.popupMessengerEditMessageId=e;this.popupMessengerEditTextarea.value=BX.MessengerCommon.prepareTextBack(this.message[e].text,true);this.popupMessengerEditTextarea.value=this.popupMessengerEditTextarea.value.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,BX.delegate(function(e,t,s){BX.MessengerCommon.addMentionList(this.currentTab,s,parseInt(t));return s},this));this.popupMessengerEditTextarea.value=this.popupMessengerEditTextarea.value.replace(/\[CHAT=([0-9]{1,})\](.*?)\[\/CHAT\]/gi,BX.delegate(function(e,t,s){BX.MessengerCommon.addMentionList(this.currentTab,s,"chat"+parseInt(t));return s},this));clearTimeout(this.popupMessengerEditFormTimeout);this.popupMessengerEditFormTimeout=setTimeout(BX.delegate(function(){if(!this.popupMessengerEditTextarea)return false;this.popupMessengerEditTextarea.focus();this.popupMessengerEditTextarea.selectionStart=this.popupMessengerEditTextarea.value.length;this.popupMessengerEditTextarea.selectionEnd=this.popupMessengerEditTextarea.value.length},this),200)};BX.Messenger.prototype.editMessageCancel=function(){this.popupMessengerEditTextarea.value="";if(BX.hasClass(this.popupMessengerEditForm,"bx-messenger-editform-disable"))return false;this.popupMessengerEditMessageId=0;BX.removeClass(this.popupMessengerEditForm,"bx-messenger-editform-show");BX.addClass(this.popupMessengerEditForm,"bx-messenger-editform-hide");clearTimeout(this.popupMessengerEditFormTimeout);this.popupMessengerEditFormTimeout=setTimeout(BX.delegate(function(){BX.removeClass(this.popupMessengerEditForm,"bx-messenger-editform-hide");BX.addClass(this.popupMessengerEditForm,"bx-messenger-editform-disable")},this),500);this.popupMessengerTextarea.focus();this.popupMessengerTextarea.selectionStart=this.popupMessengerTextarea.value.length;this.popupMessengerTextarea.selectionEnd=this.popupMessengerTextarea.value.length};BX.Messenger.prototype.deleteMessage=function(e,t){if(t!==false){this.BXIM.openConfirm(BX.message("IM_M_HISTORY_DELETE_CONFIRM"),[new BX.PopupWindowButton({text:BX.message("IM_M_HISTORY_DELETE"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){this.deleteMessage(e,false);BX.proxy_context.popupWindow.close()},this)}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})],true)}else{BX.MessengerCommon.deleteMessageAjax(e)}};BX.Messenger.prototype.startTrackStatus=function(e){if(e!="all")e=parseInt(e).toString();var t=this.BXIM.settings.trackStatus?this.BXIM.settings.trackStatus.split(","):[];if(t.indexOf(e)<0){t.push(e);this.BXIM.saveSettings({trackStatus:t.join(",")})}return true};BX.Messenger.prototype.stopTrackStatus=function(e){if(e!="all")e=parseInt(e).toString();var t=this.BXIM.settings.trackStatus?this.BXIM.settings.trackStatus.split(","):[];if(t.indexOf(e)>=0){var s=[];for(var i=0;i<t.length;i++){if(t[i]==e)continue;s.push(t[i])}t=s;this.BXIM.saveSettings({trackStatus:t.join(",")})}return true};BX.Messenger.prototype.getTrackStatus=function(e){var t=this.BXIM.settings.trackStatus?this.BXIM.settings.trackStatus.split(","):[];var s=false;if(this.BXIM.settings.status=="dnd"&&t.indexOf(e.toString())<0){s=false}else{s=t.indexOf(e.toString())>=0||t.indexOf("all")>=0}return s};BX.Messenger.prototype.insertQuoteMessage=function(e){var t=[];var s=true;var i="";var a="";var n=BX.findChildren(e.parentNode.nextSibling.firstChild,{tagName:"span"},false);for(var r=0;r<n.length;r++){var o=n[r].id.replace("im-message-","");if(this.message[o]){if(s){if(this.users[this.message[o].senderId]){i=this.users[this.message[o].senderId].name;a=this.message[o].date}s=false}var l=this.message[o].text.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,BX.delegate(function(e,t,s){return s},this));l=l.replace(/\[CHAT=([0-9]{1,})\](.*?)\[\/CHAT\]/gi,BX.delegate(function(e,t,s){return s},this));l=l.replace(/\[SEND(?:=(.+?))?\](.+?)?\[\/SEND\]/gi,BX.delegate(function(e,t,s){return s?s:t},this));l=l.replace(/\[PUT(?:=(.+?))?\](.+?)?\[\/PUT\]/gi,BX.delegate(function(e,t,s){return s?s:t},this));l=l.replace(/\[CALL(?:=(.+?))?\](.+?)?\[\/CALL\]/gi,BX.delegate(function(e,t,s){return s?s:t},this));l=l.replace(/\[ATTACH=([0-9]{1,})\]/gi,BX.delegate(function(e,t,s){return"["+BX.message("IM_F_ATTACH")+"]"},this));t.push(BX.MessengerCommon.prepareTextBack(l))}}this.insertQuoteText(i,a,t.join("\n"))};BX.Messenger.prototype.insertQuoteText=function(e,t,s,i){s=s.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,BX.delegate(function(e,t,s){return s},this));s=s.replace(/\[CHAT=([0-9]{1,})\](.*?)\[\/CHAT\]/gi,BX.delegate(function(e,t,s){return s},this));s=s.replace(/\[SEND(?:=(.+?))?\](.+?)?\[\/SEND\]/gi,BX.delegate(function(e,t,s){return s?s:t},this));s=s.replace(/\[PUT(?:=(.+?))?\](.+?)?\[\/PUT\]/gi,BX.delegate(function(e,t,s){return s?s:t},this));s=s.replace(/\[CALL(?:=(.+?))?\](.+?)?\[\/CALL\]/gi,BX.delegate(function(e,t,s){return s?s:t},this));s=s.replace(/\[ATTACH=([0-9]{1,})\]/gi,BX.delegate(function(e,t,s){return"["+BX.message("IM_F_ATTACH")+"]"},this));var a=[];a.push((this.popupMessengerTextarea&&this.popupMessengerTextarea.value.length>0?"\n":"")+this.historyMessageSplit);a.push(BX.util.htmlspecialcharsback(e)+" ["+BX.MessengerCommon.formatDate(t)+"]");a.push(s);a.push(this.historyMessageSplit+"\n");if(i!==false){this.insertTextareaText(this.popupMessengerTextarea,a.join("\n"),false);setTimeout(BX.delegate(function(){this.popupMessengerTextarea.scrollTop=this.popupMessengerTextarea.scrollHeight;this.popupMessengerTextarea.focus()},this),100)}else{return a.join("\n")}};BX.Messenger.prototype.insertTextareaText=function(e,t,s){if(!e&&opener.BXIM.messenger.popupMessengerTextarea)e=opener.BXIM.messenger.popupMessengerTextarea;if(e.selectionStart||e.selectionStart=="0"){var i=e.selectionStart;var a=e.selectionEnd;e.value=e.value.substring(0,i)+t+e.value.substring(a,e.value.length);s=s!=false;if(s){e.selectionStart=i+1;e.selectionEnd=i+1}else if(BX.browser.IsChrome()||BX.browser.IsSafari()||this.desktop.ready()){e.selectionStart=e.value.length+1;e.selectionEnd=e.value.length+1}}if(document.selection&&document.documentMode&&document.documentMode<=8){e.focus();var n=document.selection.createRange();n.text=t}};BX.Messenger.prototype.resizeTextareaStart=function(e){if(this.webrtc.callOverlayFullScreen)return false;if(!e)e=window.event;this.popupMessengerTextareaResize.wndSize=BX.GetWindowScrollPos();this.popupMessengerTextareaResize.pos=BX.pos(this.popupMessengerTextarea);this.popupMessengerTextareaResize.y=e.clientY+this.popupMessengerTextareaResize.wndSize.scrollTop;this.popupMessengerTextareaResize.textOffset=this.popupMessengerTextarea.offsetHeight;this.popupMessengerTextareaResize.bodyOffset=this.popupMessengerBody.offsetHeight;BX.bind(document,"mousemove",BX.proxy(this.resizeTextareaMove,this));BX.bind(document,"mouseup",BX.proxy(this.resizeTextareaStop,this));if(document.body.setCapture)document.body.setCapture();document.onmousedown=BX.False;var t=document.body;t.ondrag=t.onselectstart=BX.False;t.style.MozUserSelect="none";t.style.cursor="move";BX.onCustomEvent("onImResizeTextarea",[]);this.closeMenuPopup()};BX.Messenger.prototype.resizeTextareaMove=function(e){if(!e)e=window.event;var t=BX.GetWindowScrollPos();var s=e.clientX+t.scrollLeft;var i=e.clientY+t.scrollTop;if(this.popupMessengerTextareaResize.y==i)return;var a=Math.max(Math.min(-(i-this.popupMessengerTextareaResize.pos.top)+this.popupMessengerTextareaResize.textOffset,143),30);this.popupMessengerTextareaSize=a;this.popupMessengerTextarea.style.height=a+"px";this.popupMessengerBodySize=this.popupMessengerTextareaResize.textOffset-a+this.popupMessengerTextareaResize.bodyOffset;this.popupMessengerBody.style.height=this.popupMessengerBodySize+"px";this.resizeMainWindow();this.popupMessengerTextareaResize.x=s;this.popupMessengerTextareaResize.y=i};BX.Messenger.prototype.resizeTextareaStop=function(){if(document.body.releaseCapture)document.body.releaseCapture();BX.unbind(document,"mousemove",BX.proxy(this.resizeTextareaMove,this));BX.unbind(document,"mouseup",BX.proxy(this.resizeTextareaStop,this));document.onmousedown=null;this.popupMessengerBody.scrollTop=this.popupMessengerBody.scrollHeight-this.popupMessengerBody.offsetHeight;var e=document.body;e.ondrag=e.onselectstart=null;e.style.MozUserSelect="";e.style.cursor="";clearTimeout(this.BXIM.adjustSizeTimeout);this.BXIM.adjustSizeTimeout=setTimeout(BX.delegate(function(){this.BXIM.setLocalConfig("global_msz_v2",{wz:this.popupMessengerFullWidth,ta2:this.popupMessengerTextareaSize,b:this.popupMessengerBodySize,cl:this.popupContactListSize,hi:this.popupHistoryItemsSize,fz:this.popupMessengerFullHeight,ez:this.popupContactListElementsSize,nz:this.notify.popupNotifySize,hf:this.popupHistoryFilterVisible,dw:window.innerWidth,dh:window.innerHeight,place:"taMove"})},this),500)};BX.Messenger.prototype.resizeWindowStart=function(){if(this.webrtc.callOverlayFullScreen)return false;if(this.popupMessengerTopLine)BX.remove(this.popupMessengerTopLine);this.popupMessengerWindow.pos=BX.pos(this.popupMessengerContent);this.popupMessengerWindow.mb=this.popupMessengerBodySize;this.popupMessengerWindow.nb=this.notify.popupNotifySize;BX.bind(document,"mousemove",BX.proxy(this.resizeWindowMove,this));BX.bind(document,"mouseup",BX.proxy(this.resizeWindowStop,this));if(document.body.setCapture)document.body.setCapture();document.onmousedown=BX.False;var e=document.body;e.ondrag=e.onselectstart=BX.False;e.style.MozUserSelect="none";e.style.cursor="move";this.closeMenuPopup();this.BXIM.autoHideDisable=true};BX.Messenger.prototype.resizeWindowMove=function(e){if(!e)e=window.event;var t=BX.GetWindowScrollPos();var s=e.clientX+t.scrollLeft;var i=e.clientY+t.scrollTop;this.popupMessengerFullHeight=Math.max(Math.min(i-this.popupMessengerWindow.pos.top,1e3),this.popupMessengerMinHeight);this.popupMessengerFullWidth=Math.max(Math.min(s-this.popupMessengerWindow.pos.left,1200),this.popupMessengerMinWidth);this.popupMessengerContent.style.height=this.popupMessengerFullHeight+"px";this.popupMessengerContent.style.width=this.popupMessengerFullWidth+"px";var a=this.popupMessengerFullHeight-Math.max(Math.min(this.popupMessengerWindow.pos.height,1e3),this.popupMessengerMinHeight);this.popupMessengerBodySize=this.popupMessengerWindow.mb+a;if(this.popupMessengerBody!=null)this.popupMessengerBody.style.height=this.popupMessengerBodySize+"px";if(this.popupMessengerExtra!=null)this.popupMessengerExtra.style.height=this.popupMessengerFullHeight+"px";this.notify.popupNotifySize=Math.max(this.popupMessengerWindow.nb+(this.popupMessengerBodySize-this.popupMessengerWindow.mb),this.notify.popupNotifySizeMin);if(this.notify.popupNotifyItem!=null)this.notify.popupNotifyItem.style.height=this.notify.popupNotifySize+"px";if(this.webrtc.callOverlay){BX.style(this.webrtc.callOverlay,"transition","none");BX.style(this.webrtc.callOverlay,"width",(this.popupMessengerExtra.style.display=="block"?this.popupMessengerExtra.offsetWidth-1:this.popupMessengerDialog.offsetWidth-1)+"px");BX.style(this.webrtc.callOverlay,"height",this.popupMessengerFullHeight-1+"px")}this.BXIM.messenger.redrawChatHeader();this.resizeMainWindow()};BX.Messenger.prototype.resizeWindowStop=function(){if(document.body.releaseCapture)document.body.releaseCapture();BX.unbind(document,"mousemove",BX.proxy(this.resizeWindowMove,this));BX.unbind(document,"mouseup",BX.proxy(this.resizeWindowStop,this));document.onmousedown=null;this.popupMessengerBody.scrollTop=this.popupMessengerBody.scrollHeight-this.popupMessengerBody.offsetHeight;var e=document.body;e.ondrag=e.onselectstart=null;e.style.MozUserSelect="";e.style.cursor="";if(this.webrtc.callOverlay)BX.style(this.webrtc.callOverlay,"transition","");clearTimeout(this.BXIM.adjustSizeTimeout);this.BXIM.adjustSizeTimeout=setTimeout(BX.delegate(function(){this.BXIM.setLocalConfig("global_msz_v2",{wz:this.popupMessengerFullWidth,ta2:this.popupMessengerTextareaSize,b:this.popupMessengerBodySize,cl:this.popupContactListSize,hi:this.popupHistoryItemsSize,fz:this.popupMessengerFullHeight,ez:this.popupContactListElementsSize,nz:this.notify.popupNotifySize,hf:this.popupHistoryFilterVisible,dw:window.innerWidth,dh:window.innerHeight,place:"winMove"});this.BXIM.autoHideDisable=false},this),500)};BX.Messenger.prototype.newMessage=function(e){e=e!=false;var t=[];var s=[];var i=0;var a={};var n=0;for(var r in this.flashMessage){var o=false;var l=false;if(this.BXIM.isFocus()&&this.popupMessenger!=null&&r==this.currentTab){o=true;n++}else if(r.toString().substr(0,4)=="chat"||this.users[r]&&this.users[r].extranet){if(this.muteButtonStatus(r)){l=true}}if(o||l){for(var p in this.flashMessage[r]){if(this.flashMessage[r][p]!==false){this.flashMessage[r][p]=false;i++}}continue}var h={};for(var p in this.flashMessage[r]){if(this.flashMessage[r][p]===false||h[r]){this.flashMessage[r][p]=false;continue}h[r]=true;var c=this.message[p].recipientId.toString().substr(0,4)=="chat";var u=this.message[p].recipientId;var d=c&&this.chat[u.substr(4)].type=="call";var m=c&&this.chat[u.substr(4)].type=="lines";var g=this.message[p].system=="Y";var f=!c&&this.message[p].senderId==0?r:this.message[p].senderId;var B=this.message[p].text_mobile?this.message[p].text_mobile:this.message[p].text;if(r!=this.BXIM.userId)a[r]=c?this.chat[u.substr(4)].name:this.users[f].name;B=B.replace(/------------------------------------------------------(.*?)------------------------------------------------------/gim,"["+BX.message("IM_M_QUOTE_BLOCK")+"]");B=B.replace(/\[ATTACH=([0-9]{1,})\]/gi,BX.delegate(function(e,t,s){return"["+BX.message("IM_F_ATTACH")+"]"},this));if(B.length>150){B=B.substr(0,150);var X=B.lastIndexOf(" ");if(X<140)B=B.substr(0,X)+"...";else B=B.substr(0,140)+"..."}if(B==""){if(this.message[p].params["FILE_ID"]&&this.message[p].params["FILE_ID"].length>0)B="["+BX.message("IM_F_FILE")+"]";else if(this.message[p].params["ATTACH"]&&this.message[p].params["ATTACH"].length>0)B="["+BX.message("IM_F_ATTACH")+"]"}if(c){var y=u.substr(4);var b=BX.MessengerCommon.isBlankAvatar(this.chat[y].avatar)?"background-color: "+this.chat[y].color:"";var I=3;if(d){I=4}else if(m){I=7}else if(this.generalChatId==y){I=6}else if(this.chat[u.substr(4)].type=="open"){I=5}}else{var b=BX.MessengerCommon.isBlankAvatar(this.users[f].avatar)?"background-color: "+this.users[f].color:""}var M=BX.create("div",{attrs:{"data-userId":c?u:f,"data-messageId":p},props:{className:"bx-notifier-item bx-notifier-item-"+p+" "},children:[BX.create("span",{props:{className:"bx-notifier-item-content"},children:[BX.create("span",{props:{className:"bx-notifier-item-avatar"},children:[BX.create("img",{props:{className:"bx-notifier-item-avatar-img"+(BX.MessengerCommon.isBlankAvatar(c?this.chat[u.substr(4)].avatar:this.users[f].avatar)?c?" bx-notifier-item-avatar-img-default-"+I:" bx-notifier-item-avatar-img-default":"")},attrs:{src:c?this.chat[u.substr(4)].avatar:this.users[f].avatar,style:b}})]}),BX.create("a",{attrs:{href:"#","data-messageId":p},props:{className:"bx-notifier-item-delete"}}),BX.create("span",{props:{className:"bx-notifier-item-date"},html:BX.MessengerCommon.formatDate(this.message[p].date)}),BX.create("span",{props:{className:"bx-notifier-item-name"},html:c?this.chat[u.substr(4)].name:this.users[f].name}),BX.create("span",{props:{className:"bx-notifier-item-text"},html:(c&&f>0?"<i>"+this.users[f].name+"</i>: ":"")+BX.MessengerCommon.prepareText(B,false,true)})]})]});if(!this.BXIM.xmppStatus||this.BXIM.xmppStatus&&c){t.push(M);B=BX.util.htmlspecialcharsback(B);B=B.split("<br />").join("\n");B=B.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,function(e,t,s){return s});B=B.replace(/\[CHAT=([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,s){return s});B=B.replace(/\[PCH=([0-9]{1,})\](.*?)\[\/PCH\]/gi,function(e,t,s){return s});B=B.replace(/\[SEND(?:=(.+?))?\](.+?)?\[\/SEND\]/gi,function(e,t,s){return s?s:t});B=B.replace(/\[PUT(?:=(.+?))?\](.+?)?\[\/PUT\]/gi,function(e,t,s){return s?s:t});B=B.replace(/\[CALL(?:=(.+?))?\](.+?)?\[\/CALL\]/gi,function(e,t,s){return s?s:t});B=B.replace(/\[ATTACH=([0-9]{1,})\]/gi,function(e,t,s){return""});s.push({id:c?u:f,title:BX.util.htmlspecialcharsback(c?this.chat[u.substr(4)].name:this.users[f].name),text:(c&&f>0?this.users[f].name+": ":"")+B,icon:c?this.chat[u.substr(4)].avatar:this.users[f].avatar,tag:"im-messenger-"+(c?u:f)})}this.flashMessage[r][p]=false}}if(this.BXIM.context=="LINES"||this.BXIM.context=="DIALOG"){return false}if(!(!this.desktop.ready()&&this.desktop.run())&&!this.desktop.ready()&&this.BXIM.desktopStatus)return false;if(t.length>5){var v="";for(var r in a)v+=", <i>"+a[r]+"</i>";var C={id:0,type:4,date:+new Date/1e3,title:BX.message("IM_NM_MESSAGE_1").replace("#COUNT#",t.length),text:BX.message("IM_NM_MESSAGE_2").replace("#USERS#",v.substr(2))};t=[];t.push(this.notify.createNotify(C,true));s=[];s.push({id:"",title:BX.message("IM_NM_MESSAGE_1").replace("#COUNT#",t.length),text:BX.message("IM_NM_MESSAGE_2").replace("#USERS#",BX.util.htmlspecialcharsback(v.substr(2))).replace(/<\/?[^>]+>/gi,"")})}else if(t.length==0){if(n>0&&this.desktop.ready())BX.desktop.flashIcon();if(e&&n>0&&this.BXIM.settings.status!="dnd"){this.BXIM.playSound("newMessage2")}return false}if(this.desktop.ready())BX.desktop.flashIcon();if(this.desktop.ready()){for(var r=0;r<t.length;r++){var x=t[r].getAttribute("data-messageId");var T='var notify = BX.findChildByClassName(document.body, "bx-notifier-item");'+'notify.style.cursor = "pointer";'+'BX.bind(notify, "click", function(){BX.desktop.onCustomEvent("main", "bxImClickNewMessage", [notify.getAttribute("data-userId")]); BX.desktop.windowCommand("close")});'+'BX.bind(BX.findChildByClassName(notify, "bx-notifier-item-delete"), "click", function(event){ BX.desktop.onCustomEvent("main", "bxImClickCloseMessage", [notify.getAttribute("data-userId")]); BX.desktop.windowCommand("close"); BX.MessengerCommon.preventDefault(event); });'+'BX.bind(notify, "contextmenu", function(){ BX.desktop.windowCommand("close")});';this.desktop.openNewMessage(x,t[r],T)}}else if(e&&!this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){for(var r=0;r<s.length;r++){var C=s[r];C.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};C.onclick=function(){window.focus();top.BXIM.openMessenger(C.id);this.close()};this.BXIM.notifyManager.nativeNotify(C)}}else{if(this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){BX.localStorage.set("mnnb",true,1);
}for(var r=0;r<t.length;r++){this.BXIM.notifyManager.add({html:t[r],tag:"im-message-"+t[r].getAttribute("data-userId"),userId:t[r].getAttribute("data-userId"),click:BX.delegate(function(e){this.openMessenger(e.notifyParams.userId);e.close()},this),close:BX.delegate(function(e){BX.MessengerCommon.readMessage(e.notifyParams.userId)},this)})}}if(this.desktop.ready())BX.desktop.flashIcon();if(e){this.BXIM.playSound("newMessage1")}};BX.Messenger.prototype.showNotifyBlock=function(e){var t=e.recipientId.toString().substr(0,4)=="chat";var s=e.recipientId;var a=t&&this.chat[s.substr(4)]&&this.chat[s.substr(4)].type=="call";var n=t&&this.chat[s.substr(4)]&&this.chat[s.substr(4)].type=="lines";var r=!t&&e.senderId==0?i:e.senderId;var o=e.text_mobile?e.text_mobile:e.text;if(!e.id)e.id="custom-"+ +new Date;if(e.date)e.date=BX.MessengerCommon.getNowDate();o=o.replace(/------------------------------------------------------(.*?)------------------------------------------------------/gim,"["+BX.message("IM_M_QUOTE_BLOCK")+"]");if(o.length>150){o=o.substr(0,150);var l=o.lastIndexOf(" ");if(l<140)o=o.substr(0,l)+"...";else o=o.substr(0,140)+"..."}if(o==""&&e.params["FILE_ID"].length>0){o="["+BX.message("IM_F_FILE")+"]"}if(t){var p=s.substr(4);var h=BX.MessengerCommon.isBlankAvatar(this.chat[p].avatar)?"background-color: "+this.chat[p].color:"";var c=3;if(a){c=4}else if(n){c=7}else if(this.generalChatId==p){c=6}else if(this.chat[s.substr(4)].type=="open"){c=5}}else{var h=BX.MessengerCommon.isBlankAvatar(this.users[r].avatar)?"background-color: "+this.users[r].color:""}var u=BX.create("div",{attrs:{"data-userId":t?s:r,"data-messageId":e.id},props:{className:"bx-notifier-item bx-notifier-item-"+e.id+" "},children:[BX.create("span",{props:{className:"bx-notifier-item-content"},children:[BX.create("span",{props:{className:"bx-notifier-item-avatar"},children:[BX.create("img",{props:{className:"bx-notifier-item-avatar-img"+(BX.MessengerCommon.isBlankAvatar(t?this.chat[s.substr(4)].avatar:this.users[r].avatar)?t?" bx-notifier-item-avatar-img-default-"+c:" bx-notifier-item-avatar-img-default":"")},attrs:{src:t?this.chat[s.substr(4)].avatar:this.users[r].avatar,style:h}})]}),BX.create("a",{attrs:{href:"#","data-messageId":e.id},props:{className:"bx-notifier-item-delete"}}),e.date?BX.create("span",{props:{className:"bx-notifier-item-date"},html:BX.MessengerCommon.formatDate(e.date)}):BX.create("span"),BX.create("span",{props:{className:"bx-notifier-item-name"},html:t?this.chat[s.substr(4)].name:this.users[r].name}),BX.create("span",{props:{className:"bx-notifier-item-text"},html:(t&&r>0?"<i>"+this.users[r].name+"</i>: ":"")+BX.MessengerCommon.prepareText(o,false,true)})]})]});if(!this.BXIM.xmppStatus||this.BXIM.xmppStatus&&t){o=BX.util.htmlspecialcharsback(o);o=o.split("<br />").join("\n");o=o.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,function(e,t,s){return s});o=o.replace(/\[CHAT=([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,s){return s});o=o.replace(/\[PCH=([0-9]{1,})\](.*?)\[\/PCH\]/gi,function(e,t,s){return s});o=o.replace(/\[SEND(?:=(.+?))?\](.+?)?\[\/SEND\]/gi,function(e,t,s){return s?s:t});o=o.replace(/\[PUT(?:=(.+?))?\](.+?)?\[\/PUT\]/gi,function(e,t,s){return s?s:t});o=o.replace(/\[CALL(?:=(.+?))?\](.+?)?\[\/CALL\]/gi,function(e,t,s){return s?s:t});o=o.replace(/\[ATTACH=([0-9]{1,})\]/gi,function(e,t,s){return""});notifyTextObject={id:t?s:r,title:BX.util.htmlspecialcharsback(t?this.chat[s.substr(4)].name:this.users[r].name),text:(t&&r>0?this.users[r].name+": ":"")+o,icon:t?this.chat[s.substr(4)].avatar:this.users[r].avatar,tag:"im-messenger-"+(t?s:r)}}else{return false}if(!(!this.desktop.ready()&&this.desktop.run())&&!this.desktop.ready()&&this.BXIM.desktopStatus)return false;if(this.desktop.ready()){var d='var notify = BX.findChildByClassName(document.body, "bx-notifier-item");'+'notify.style.cursor = "pointer";'+'BX.bind(notify, "click", function(){BX.desktop.onCustomEvent("main", "bxImClickNewMessage", [notify.getAttribute("data-userId")]); BX.desktop.windowCommand("close")});'+'BX.bind(BX.findChildByClassName(notify, "bx-notifier-item-delete"), "click", function(event){ BX.desktop.onCustomEvent("main", "bxImClickCloseMessage", [notify.getAttribute("data-userId")]); BX.desktop.windowCommand("close"); BX.MessengerCommon.preventDefault(event); });'+'BX.bind(notify, "contextmenu", function(){ BX.desktop.windowCommand("close")});';this.desktop.openNewMessage(u.getAttribute("data-messageId"),u,d)}else if(!this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){var m=notifyTextObject;m.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};m.onclick=function(){window.focus();top.BXIM.openMessenger(m.id);this.close()};this.BXIM.notifyManager.nativeNotify(m)}else{this.BXIM.notifyManager.add({html:u,tag:"im-message-"+u.getAttribute("data-userId"),userId:u.getAttribute("data-userId"),click:BX.delegate(function(e){this.openMessenger(e.notifyParams.userId);e.close()},this),close:BX.delegate(function(e){BX.MessengerCommon.readMessage(e.notifyParams.userId)},this)})}return true};BX.Messenger.prototype.updateMessageCount=function(e){e=e!=false;var t=0;var s=0;for(var i in this.unreadMessage){if(i.toString().substr(0,4)=="chat"){s=i.toString().substr(4);if(!this.userChatBlockStatus[s]||this.userChatBlockStatus[s][this.BXIM.userId]!="Y"){t=t+this.unreadMessage[i].length}}else{t=t+this.unreadMessage[i].length}}if(e)BX.localStorage.set("mumc",{unread:this.unreadMessage,flash:this.flashMessage},5);if(this.messageCount!=t)BX.onCustomEvent(window,"onImUpdateCounterMessage",[t,"MESSAGE"]);this.messageCount=t;var a="";if(this.messageCount>99)a="99+";else if(this.messageCount>0)a=this.messageCount;if(this.notify.panelButtonMessageCount!=null){this.notify.panelButtonMessageCount.innerHTML=a;this.notify.adjustPosition({resize:true,timeout:500})}if(this.desktop.run()){if(this.messageCount==0)BX.hide(this.notify.panelButtonMessage);else BX.show(this.notify.panelButtonMessage);BX.desktop.setTabBadge("im",this.messageCount)}this.BXIM.messageCount=this.messageCount;return this.messageCount};BX.Messenger.prototype.setStatus=function(e,t){t=t!=false;if(!e)return false;e=e.toLowerCase();this.users[this.BXIM.userId].status=e;this.BXIM.updateCounter();if(this.contactListPanelStatus!=null&&!BX.hasClass(this.contactListPanelStatus,"bx-messenger-cl-panel-status-"+e)){this.contactListPanelStatus.className="bx-messenger-cl-panel-status-wrap bx-messenger-cl-panel-status-"+e;var s=BX.findChildByClassName(this.contactListPanelStatus,"bx-messenger-cl-panel-status-text");s.innerHTML=BX.message("IM_STATUS_"+e.toUpperCase());if(t){this.BXIM.saveSettings({status:e});BX.onCustomEvent(this,"onStatusChange",[e]);BX.localStorage.set("mms",e,5)}}if(this.desktop.ready())BX.desktop.setIconStatus(e)};BX.Messenger.prototype.resizeMainWindow=function(){if(this.desktop.run())return false;if(this.popupMessengerExtra.style.display=="block")this.popupContactListElementsSize=this.popupMessengerExtra.offsetHeight-120;else this.popupContactListElementsSize=this.popupMessengerDialog.offsetHeight-120;this.popupContactListElements.style.height=this.popupContactListElementsSize+"px"};BX.Messenger.prototype.showTopLine=function(e,t){if(typeof e!="string")return false;var s=[];if(typeof t=="object"){var i=[];for(var a=0;a<t.length;a++)i.push(BX.create("span",{props:{className:"bx-messenger-box-topline-button"},html:t[a].title,events:{click:t[a].callback}}));s.push(BX.create("span",{props:{className:"bx-messenger-box-topline-buttons"},children:i}))}s.push(BX.create("span",{props:{className:"bx-messenger-box-topline-text"},children:[BX.create("span",{props:{className:"bx-messenger-box-topline-text-inner"},html:e})]}));this.popupMessengerTopLine.innerHTML="";BX.adjust(this.popupMessengerTopLine,{children:s});BX.addClass(this.popupMessengerTopLine,"bx-messenger-box-topline-show");return true};BX.Messenger.prototype.hideTopLine=function(){BX.removeClass(this.popupMessengerTopLine,"bx-messenger-box-topline-show")};BX.Messenger.prototype.closeMenuPopup=function(){if(this.popupPopupMenu!=null&&this.popupPopupMenuDateCreate+100<+new Date)this.popupPopupMenu.close();if(this.popupSmileMenu!=null)this.popupSmileMenu.close();if(this.notify.popupNotifyMore!=null)this.notify.popupNotifyMore.destroy();if(this.popupChatUsers!=null)this.popupChatUsers.close();if(this.webrtc.popupKeyPad!=null)this.webrtc.popupKeyPad.destroy();if(this.popupChatDialog!=null)this.popupChatDialog.destroy();if(this.popupTransferDialog!=null)this.popupTransferDialog.destroy();if(this.popupTooltip!=null)this.popupTooltip.destroy();if(this.commandPopup!=null)this.commandPopup.close();this.closePopupFileMenu()};BX.Messenger.MenuPrepareList=function(e){var t=[];for(var s=0;s<e.length;s++){var i=e[s];if(i==null)continue;if(!i.separator&&(!i.text||!BX.type.isNotEmptyString(i.text)))continue;if(i.separator){t.push(BX.create("div",{props:{className:"bx-messenger-menu-hr"}}))}else if(i.type=="call"){var a=BX.create("a",{props:{className:"bx-messenger-popup-menu-item"},attrs:{title:i.title?i.title:"",href:i.href?i.href:"",target:i.target?i.target:"","data-params":i.dataParams?JSON.stringify(i.dataParams):""},events:i.onclick&&BX.type.isFunction(i.onclick)?{click:i.onclick}:null,html:'<div class="bx-messenger-popup-menu-item-call"><span class="bx-messenger-popup-menu-item-left"></span><span class="bx-messenger-popup-menu-item-title">'+i.text+'</span><span class="bx-messenger-popup-menu-right"></span></div>'+'<div><span class="bx-messenger-popup-menu-item-left"></span><span class="bx-messenger-popup-menu-item-text">'+i.phone+'</span><span class="bx-messenger-popup-menu-right"></span></div>'});if(i.href)a.href=i.href;t.push(a)}else{var a=BX.create("a",{props:{className:"bx-messenger-popup-menu-item"+(i.bold?" bx-messenger-popup-menu-item-bold":"")+(i.slim?" bx-messenger-popup-menu-item-slim":"")+(BX.type.isNotEmptyString(i.className)?" "+i.className:"")},attrs:{title:i.title?i.title:"",href:i.href?i.href:"",target:i.target?i.target:"","data-params":i.dataParams?JSON.stringify(i.dataParams):""},events:i.onclick&&BX.type.isFunction(i.onclick)?{click:i.onclick}:null,html:'<span class="bx-messenger-popup-menu-item-left"></span>'+(i.icon?'<span class="bx-messenger-popup-menu-item-icon '+i.icon+'"></span>':"")+'<span class="bx-messenger-popup-menu-item-text">'+i.text+'</span><span class="bx-messenger-popup-menu-right"></span>'});if(i.href)a.href=i.href;t.push(a)}}return t};BX.Messenger.prototype.storageSet=function(e){if(e.key=="ims"){if(this.BXIM.settings.viewOffline!=e.value.viewOffline||this.BXIM.settings.viewGroup!=e.value.viewGroup)BX.MessengerCommon.userListRedraw(true);if(this.BXIM.settings.sendByEnter!=e.value.sendByEnter&&this.popupMessengerTextareaSendType)this.popupMessengerTextareaSendType.innerHTML=this.BXIM.settings.sendByEnter?"Enter":BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter";if(this.BXIM.settings.sendByEnter!=e.value.sendByEnter&&this.popupMessengerTextareaSendType)this.popupMessengerTextareaSendType.innerHTML=this.BXIM.settings.sendByEnter?"Enter":BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter";BX.MessengerCommon.drawTab(this.currentTab,true);this.BXIM.settings=e.value}else if(e.key=="mus"){this.updateState(true,false)}else if(e.key=="musl"){this.updateStateLight(true,false)}else if(e.key=="mms"){this.setStatus(e.value,false)}else if(e.key=="mct"){}else if(e.key=="mrlr"){BX.MessengerCommon.recentListHide(e.value.userId,false)}else if(e.key=="mrd"){this.BXIM.settings.viewGroup=e.value.viewGroup;this.BXIM.settings.viewOffline=e.value.viewOffline;BX.MessengerCommon.userListRedraw()}else if(e.key=="mgp"){var t=this.contactListSearchText!=null&&this.contactListSearchText.length>0?false:this.BXIM.settings.viewGroup;if(t&&this.groups[e.value.id])this.groups[e.value.id].status=e.value.status;else if(!t&&this.woGroups[e.value.id])this.woGroups[e.value.id].status=e.value.status;BX.MessengerCommon.userListRedraw()}else if(e.key=="mrm"){BX.MessengerCommon.readMessage(e.value,false,false)}else if(e.key=="mcl"){BX.MessengerCommon.leaveFromChat(e.value,false)}else if(e.key=="mcl2"){BX.MessengerCommon.muteMessageChat(e.value.dialogId,e.value.mute,false)}else if(e.key=="mclk"){this.kickFromChat(e.value.chatId,e.value.userId)}else if(e.key=="mes"){this.BXIM.settings.enableSound=e.value}else if(e.key=="mti"){if(e.value>this.messageTmpIndex)this.messageTmpIndex=e.value}else if(e.key=="mns"){if(this.popupContactListSearchInput!=null)this.popupContactListSearchInput.value=e.value!=null?e.value+"":"";this.contactListSearchText=e.value!=null?e.value+"":""}else if(e.key=="msm"){if(this.message[e.value.id])return;this.message[e.value.id]=e.value;if(this.history[e.value.recipientId])this.history[e.value.recipientId].push(e.value.id);else this.history[e.value.recipientId]=[e.value.id];if(this.showMessage[e.value.recipientId])this.showMessage[e.value.recipientId].push(e.value.id);else this.showMessage[e.value.recipientId]=[e.value.id];BX.MessengerCommon.updateStateVar(e.value,false,false);BX.MessengerCommon.drawTab(e.value.recipientId,true)}else if(e.key=="uss"){this.updateStateStep=parseInt(e.value)}else if(e.key=="mumc"){setTimeout(BX.delegate(function(){var t=false;if(this.popupMessenger!=null&&this.BXIM.isFocus()){delete e.value.unread[this.currentTab];t=true}this.unreadMessage=e.value.unread;this.flashMessage=e.value.flash;this.updateMessageCount(t)},this),500)}else if(e.key=="mum"){this.message[e.value.message.id]=e.value.message;if(this.showMessage[e.value.userId]){this.showMessage[e.value.userId].push(e.value.message.id);this.showMessage[e.value.userId]=BX.util.array_unique(this.showMessage[e.value.userId])}else this.showMessage[e.value.userId]=[e.value.message.id];BX.MessengerCommon.drawMessage(e.value.userId,e.value.message,this.currentTab==e.value.userId)}else if(e.key=="muum"){BX.MessengerCommon.changeUnreadMessage(e.value,false)}else if(e.key=="mcam"&&!this.BXIM.ppServerStatus){if(this.popupMessenger!=null&&!this.webrtc.callInit)this.popupMessenger.close()}};BX.Messenger.prototype.linesOpenHistory=function(e){BX.MessengerCommon.linesGetSessionHistory(e)};BX.Messenger.prototype.linesShowHistory=function(e,t){if(this.popupMessengerConnectionStatusState!="online")return false;if(this.historyWindowBlock)return false;if(this.popupHistory!=null)this.popupHistory.destroy();var e=e;var s=this.BXIM.disk.enable;s=false;this.popupHistoryPanel=null;var i=this.redrawHistoryPanel("chat"+e,e);this.popupHistoryElements=BX.create("div",{props:{className:"bx-messenger-history"+(s?" bx-messenger-history-with-disk":"")+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")},children:[this.popupHistoryPanel=BX.create("div",{props:{className:"bx-messenger-panel-wrap"},children:i}),BX.create("div",{props:{className:"bx-messenger-history-types"},children:[BX.create("span",{props:{className:"bx-messenger-history-type bx-messenger-history-type-message"},children:[this.popupHistoryItems=BX.create("div",{props:{className:"bx-messenger-history-items"},style:{height:this.popupHistoryItemsSize+"px"},children:[this.popupHistoryBodyWrap=BX.create("div",{props:{className:"bx-messenger-history-items-wrap"}})]})]}),BX.create("span",{props:{className:"bx-messenger-history-type bx-messenger-history-type-disk"},children:[this.popupHistoryFilesItems=BX.create("div",{props:{className:"bx-messenger-history-items"},style:{height:this.popupHistoryItemsSize+"px"},children:[this.popupHistoryFilesBodyWrap=BX.create("div",{props:{className:"bx-messenger-history-items-wrap"}})]})]})]})]});this.popupHistory=new BX.PopupWindow("bx-messenger-popup-history",null,{autoHide:false,zIndex:100,draggable:{restrict:true},closeByEsc:true,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupHistory=null;this.historySearch="";this.setClosingByEsc(true);this.closeMenuPopup();var e=BX.calendar.get();if(e){e.Close()}},this)},titleBar:{content:BX.create("span",{props:{className:"bx-messenger-title"},html:BX.message("IM_M_HISTORY")})},closeIcon:{right:"13px"},content:this.popupHistoryElements,contentColor:"white",noAllPaddings:true});this.popupHistory.show();BX.bind(this.popupHistory.popupContainer,"click",BX.MessengerCommon.preventDefault);this.drawHistory("chat"+e,t.HISTORY,false);if(s){this.drawHistoryFiles(e,t.FILES,false)}BX.bindDelegate(this.popupHistoryElements,"click",{className:"bx-messenger-ajax"},BX.delegate(function(){if(BX.proxy_context.getAttribute("data-entity")=="user"){this.openPopupExternalData(BX.proxy_context,"user",true,{ID:BX.proxy_context.getAttribute("data-userId")})}else if(BX.proxy_context.getAttribute("data-entity")=="chat"){this.openPopupExternalData(BX.proxy_context,"chat",true,{ID:BX.proxy_context.getAttribute("data-chatId")})}else if(BX.proxy_context.getAttribute("data-entity")=="network"){this.openMessenger("network"+BX.proxy_context.getAttribute("data-networkId"))}else if(BX.proxy_context.getAttribute("data-entity")=="phoneCallHistory"){this.openPopupExternalData(BX.proxy_context,"phoneCallHistory",true,{ID:BX.proxy_context.getAttribute("data-historyID")})}},this));if(this.disk.enable){BX.bindDelegate(this.popupHistoryFilesBodyWrap,"click",{className:"bx-messenger-file-menu"},BX.delegate(function(e){var t=BX.proxy_context.parentNode.parentNode.getAttribute("data-fileId");var s=BX.proxy_context.parentNode.parentNode.getAttribute("data-chatId");this.openPopupMenu(BX.proxy_context,"historyFileMenu",true,{fileId:t,chatId:s});return BX.PreventDefault(e)},this))}};BX.Messenger.prototype.linesOpenMessenger=function(e){BX.MessengerCommon.linesStartSession(e)};BX.Messenger.prototype.linesCreateLead=function(){var e=this.currentTab.toString().substr(4);var t=BX.MessengerCommon.linesGetSession(e);if(t.crm=="N"){BX.MessengerCommon.linesCreateLead(e)}};BX.Messenger.prototype.linesCloseDialog=function(){var e=this.currentTab.toString().substr(4);var t=BX.MessengerCommon.linesGetSession(e);if(t.wait=="N"){BX.MessengerCommon.linesCloseDialog(e)}};BX.Messenger.prototype.linesTogglePinMode=function(){var e=this.currentTab.toString().substr(4);var t;var s=BX.MessengerCommon.linesGetSession(e);if(s.pin=="Y"){t="N"}else{t="Y"}BX.MessengerCommon.linesActivatePinMode(e,t)};BX.Messenger.prototype.linesToggleSilentMode=function(){var e=this.currentTab.toString().substr(4);var t;if(this.chat[e].entity_data_3=="Y"){BX.removeClass(this.popupMessengerHiddenModeButton,"bx-messenger-textarea-hidden-active");t="N"}else{BX.addClass(this.popupMessengerHiddenModeButton,"bx-messenger-textarea-hidden-active");t="Y"}BX.MessengerCommon.linesActivateSilentMode(e,t)};BX.Messenger.prototype.linesOpenTransferDialog=function(e){if(this.popupTransferDialog!=null){this.popupTransferDialog.close();return false}if(this.popupChatDialog!=null){this.popupChatDialog.close();return false}this.linesTransferUser=0;var t=e.bind?e.bind:null;e.maxUsers=1;this.popupTransferDialog=new BX.PopupWindow("bx-messenger-popup-transfer",t,{lightShadow:true,offsetTop:5,offsetLeft:this.desktop.run()?5:-162,autoHide:true,buttons:[new BX.PopupWindowButton({text:BX.message("IM_OL_INVITE_TRANSFER"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){var e=this.currentTab.toString().substr(4);this.linesSendTransfer(e)},this)}}),new BX.PopupWindowButton({text:BX.message("IM_M_CHAT_BTN_CANCEL"),events:{click:BX.delegate(function(){this.popupTransferDialog.close()},this)}})],closeByEsc:true,zIndex:200,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupTransferDialog=null;this.popupTransferDialogContactListElements=null},this)},content:BX.create("div",{props:{className:"bx-messenger-popup-newchat-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-popup-newchat-caption"},html:BX.message("IM_OL_TRANSFER_TEXT")}),BX.create("div",{props:{className:"bx-messenger-popup-newchat-box bx-messenger-popup-newchat-dest bx-messenger-popup-newchat-dest-even"},children:[this.popupTransferDialogDestElements=BX.create("span",{props:{className:"bx-messenger-dest-items"}}),this.popupTransferDialogContactListSearch=BX.create("input",{props:{className:"bx-messenger-input"},attrs:{type:"text",placeholder:BX.message(this.BXIM.bitrixIntranet?"IM_M_SEARCH_PLACEHOLDER_CP":"IM_M_SEARCH_PLACEHOLDER"),value:""}})]}),this.popupTransferDialogContactListElements=BX.create("div",{props:{className:"bx-messenger-popup-newchat-box bx-messenger-popup-newchat-cl bx-messenger-recent-wrap"},children:[]})]})});BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.popupTransferDialogContactListElements,this.popupTransferDialogContactListSearch.value,{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOfflineWithPhones:false});this.popupTransferDialog.setAngle({offset:this.desktop.run()?32:198});this.popupTransferDialog.show();this.popupTransferDialogContactListSearch.focus();BX.addClass(this.popupTransferDialog.popupContainer,"bx-messenger-mark");BX.bind(this.popupTransferDialog.popupContainer,"click",BX.PreventDefault);BX.bind(this.popupTransferDialogContactListSearch,"keyup",BX.delegate(function(t){if(t.keyCode==16||t.keyCode==17||t.keyCode==18||t.keyCode==20||t.keyCode==244||t.keyCode==224||t.keyCode==91)return false;if(t.keyCode==27&&this.popupTransferDialogContactListSearch.value!="")BX.MessengerCommon.preventDefault(t);if(t.keyCode==27){this.popupTransferDialogContactListSearch.value=""}if(t.keyCode==8){var s=null;var i=BX.util.objectSort(this.popupChatDialogUsers,"date","asc");for(var a=0;a<i.length;a++){s=i[a].id}if(s){delete this.popupChatDialogUsers[s];this.linesRedrawTransferDialogDest()}}if(t.keyCode==13){this.popupTransferDialogContactListSearch.value="";var n=BX.findChildByClassName(this.popupTransferDialogContactListElements,"bx-messenger-cl-item");if(n){if(this.popupTransferDialogContactListSearch.value!=""){this.popupTransferDialogContactListSearch.value=""}if(this.linesTransferUser>0){e.maxUsers=e.maxUsers+1;if(e.maxUsers>0)BX.show(this.popupTransferDialogContactListSearch);this.linesTransferUser=0}else{if(e.maxUsers>0){e.maxUsers=e.maxUsers-1;if(e.maxUsers<=0)BX.hide(this.popupTransferDialogContactListSearch);this.linesTransferUser=n.getAttribute("data-userId")}}this.linesRedrawTransferDialogDest()}}BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.popupTransferDialogContactListElements,this.popupTransferDialogContactListSearch.value,{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOfflineWithPhones:false,timeout:100})},this));BX.bindDelegate(this.popupTransferDialogDestElements,"click",{className:"bx-messenger-dest-del"},BX.delegate(function(){this.linesTransferUser=0;e.maxUsers=e.maxUsers+1;if(e.maxUsers>0)BX.show(this.popupTransferDialogContactListSearch);this.linesRedrawTransferDialogDest()},this));BX.bindDelegate(this.popupTransferDialogContactListElements,"click",{className:"bx-messenger-cl-item"},BX.delegate(function(t){if(this.popupTransferDialogContactListSearch.value!=""){this.popupTransferDialogContactListSearch.value="";BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.popupTransferDialogContactListElements,"",{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOfflineWithPhones:false})}if(this.linesTransferUser>0){e.maxUsers=e.maxUsers+1;this.linesTransferUser=0}else{if(e.maxUsers<=0)return false;e.maxUsers=e.maxUsers-1;this.linesTransferUser=BX.proxy_context.getAttribute("data-userId")}if(e.maxUsers<=0)BX.hide(this.popupTransferDialogContactListSearch);else BX.show(this.popupTransferDialogContactListSearch);this.linesRedrawTransferDialogDest();return BX.PreventDefault(t)},this))};BX.Messenger.prototype.linesRedrawTransferDialogDest=function(){var e="";var t=0;if(this.linesTransferUser>0){t++;e+='<span class="bx-messenger-dest-block'+(this.users[this.linesTransferUser].extranet?" bx-messenger-dest-block-extranet":"")+'">'+'<span class="bx-messenger-dest-text">'+this.users[this.linesTransferUser].name+"</span>"+'<span class="bx-messenger-dest-del" data-userId="'+this.linesTransferUser+'"></span></span>'}this.popupTransferDialogDestElements.innerHTML=e;this.popupTransferDialogDestElements.parentNode.scrollTop=this.popupTransferDialogDestElements.parentNode.offsetHeight;if(BX.util.even(t))BX.addClass(this.popupTransferDialogDestElements.parentNode,"bx-messenger-popup-newchat-dest-even");else BX.removeClass(this.popupTransferDialogDestElements.parentNode,"bx-messenger-popup-newchat-dest-even");this.popupTransferDialogContactListSearch.focus()};BX.Messenger.prototype.linesSendTransfer=function(e){if(this.BXIM.messenger.blockJoinChat[e])return false;if(this.chat[e]&&this.chat[e].entity_type!="LINES")return false;if(this.linesTransferUser<=0)return false;if(this.popupTransferDialog)this.popupTransferDialog.close();this.BXIM.messenger.blockJoinChat[e]=true;BX.ajax({url:this.BXIM.pathToAjax+"?LINES_TRANSFER&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:{COMMAND:"transfer",CHAT_ID:e,TRANSFER_ID:this.linesTransferUser,IM_OPEN_LINES:"Y",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(){this.BXIM.messenger.blockJoinChat[e]=false},this),onfailure:BX.delegate(function(){this.BXIM.messenger.blockJoinChat[e]=false},this)})};BX.IM.Desktop=function(e,t){this.BXIM=e;this.clientVersion=false;this.markup=BX("placeholder-messanger");this.htmlWrapperHead=null;this.showNotifyId={};this.showMessageId={};this.lastSetIcon=null;this.topmostWindow=null;this.topmostWindowTimeout=null;this.topmostWindowCloseTimeout=null;this.minCallVideoWidth=320;this.minCallVideoHeight=180;this.minCallWidth=320;this.minCallHeight=35;this.minHistoryWidth=608;this.minHistoryDiskWidth=780;this.minHistoryHeight=593;this.minSettingsWidth=590;this.startSettingsHeight=BX.browser.IsMac()?326:335;this.minSettingsHeight=137;if(this.run()&&!this.ready()&&BX.desktop.getApiVersion()>0){this.BXIM.init=false;this.BXIM.tryConnect=false}else if(this.run()&&this.BXIM.init){BX.desktop.addTab({id:"config",title:BX.message("IM_SETTINGS"),order:150,target:false,events:{open:BX.delegate(function(e){this.BXIM.openSettings({active:BX.desktop.getCurrentTab()})},this)}});BX.desktop.addSeparator({order:500});if(this.ready()&&!this.BXIM.bitrix24net){BX.desktop.addTab({id:"im-lf",title:BX.message("IM_DESKTOP_GO_SITE").replace("#COUNTER#",""),order:550,target:false,events:{open:function(){BX.desktop.browse(BX.desktop.getCurrentUrl())}}})}if(this.BXIM.animationSupport&&/Microsoft Windows NT 5/i.test(navigator.userAgent))this.BXIM.animationSupport=false;if(this.ready())this.BXIM.changeFocus(BX.desktop.windowIsFocused());BX.bind(window,"keydown",BX.delegate(function(e){if(!(BX.desktop.getCurrentTab()=="im"||BX.desktop.getCurrentTab()=="notify"||BX.desktop.getCurrentTab()=="im-phone"))return false;if(e.keyCode==27){if(this.messenger.popupSmileMenu){this.messenger.popupSmileMenu.destroy()}else if(this.messenger.popupMessengerFileButton!=null&&BX.hasClass(this.messenger.popupMessengerFileButton,"bx-messenger-textarea-file-active")){this.messenger.closePopupFileMenu()}else if(this.messenger.popupPopupMenu){this.messenger.popupPopupMenu.destroy()}else if(this.messenger.popupChatDialog&&this.messenger.popupChatDialogContactListSearch.value.length>=0){this.messenger.popupChatDialogContactListSearch.value=""}else if(this.BXIM.extraOpen){BX.desktop.changeTab("im");this.messenger.extraClose(true)}else if(this.messenger.renameChatDialogInput&&this.messenger.renameChatDialogInput.value.length>0){this.messenger.renameChatDialogInput.value=this.messenger.chat[this.messenger.currentTab.toString().substr(4)].name;this.messenger.popupMessengerTextarea.focus()}else if(this.messenger.popupContactListSearchInput&&(this.messenger.popupContactListSearchInput.value.length>0||this.messenger.chatList)){BX.MessengerCommon.contactListSearch({keyCode:27});this.messenger.popupMessengerTextarea.focus()}else{if(BX.util.trim(this.messenger.popupMessengerEditTextarea.value).length>0){this.messenger.editMessageCancel()}else if(BX.util.trim(this.messenger.popupMessengerTextarea.value).length<=0&&!this.webrtc.callInit){this.messenger.textareaHistory[this.messenger.currentTab]="";this.messenger.popupMessengerTextarea.value="";BX.desktop.windowCommand("hide")}else if(e.shiftKey){this.messenger.textareaHistory[this.messenger.currentTab]="";this.messenger.popupMessengerTextarea.value=""}}}else if(e.altKey==true){if(e.keyCode==49||e.keyCode==50||e.keyCode==51||e.keyCode==52||e.keyCode==53||e.keyCode==54||e.keyCode==55||e.keyCode==56||e.keyCode==57){this.messenger.openMessenger(this.messenger.recentListIndex[parseInt(e.keyCode)-49]);BX.PreventDefault(e)}else if(e.keyCode==48){this.messenger.popupContactListSearchInput.focus();BX.PreventDefault(e)}}},this));BX.desktop.syncPause(false);BX.desktop.addCustomEvent("bxImClickNewMessage",BX.delegate(function(e){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");this.BXIM.openMessenger(e)},this));BX.desktop.addCustomEvent("bxImClickCloseMessage",BX.delegate(function(e){BX.MessengerCommon.readMessage(e)},this));BX.desktop.addCustomEvent("bxImClickCloseNotify",BX.delegate(function(e){this.BXIM.notify.viewNotify(e)},this));BX.desktop.addCustomEvent("bxImClickNotify",BX.delegate(function(){BX.desktop.windowCommand("show");BX.desktop.changeTab("notify")},this));BX.desktop.addCustomEvent("bxCallDecline",BX.delegate(function(){var e=this.webrtc.callVideo;this.webrtc.callSelfDisabled=true;this.webrtc.callCommand(this.webrtc.callChatId,"decline",{ACTIVE:this.webrtc.callActive?"Y":"N",INITIATOR:this.webrtc.initiator?"Y":"N"});this.BXIM.playSound("stop");if(e&&this.webrtc.callStreamSelf!=null)this.webrtc.callOverlayVideoClose();else this.webrtc.callOverlayClose()},this));BX.desktop.addCustomEvent("bxPhoneAnswer",BX.delegate(function(){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");this.BXIM.stopRepeatSound("ringtone");this.webrtc.phoneIncomingAnswer();this.closeTopmostWindow()},this));BX.desktop.addCustomEvent("bxPhoneSkip",BX.delegate(function(){this.webrtc.phoneCallFinish();this.webrtc.callAbort();this.webrtc.callOverlayClose()},this));BX.desktop.addCustomEvent("bxCallOpenDialog",BX.delegate(function(){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");if(this.BXIM.dialogOpen){if(this.webrtc.callOverlayUserId>0){this.messenger.openChatFlag=false;BX.MessengerCommon.openDialog(this.webrtc.callOverlayUserId,false,false)}else{this.messenger.openChatFlag=true;BX.MessengerCommon.openDialog("chat"+this.webrtc.callOverlayChatId,false,false)}}else{if(this.webrtc.callOverlayUserId>0){this.messenger.openChatFlag=false;this.messenger.currentTab=this.webrtc.callOverlayUserId}else{this.messenger.openChatFlag=true;this.messenger.currentTab="chat"+this.webrtc.callOverlayChatId}this.messenger.extraClose(true,false)}this.webrtc.callOverlayToggleSize(false)},this));BX.desktop.addCustomEvent("bxCallMuteMic",BX.delegate(function(){if(this.webrtc.phoneCurrentCall)this.webrtc.phoneToggleAudio();else this.webrtc.toggleAudio();var e=BX.findChildByClassName(BX("bx-messenger-call-overlay-button-mic"),"bx-messenger-call-overlay-button-mic");if(e)BX.toggleClass(e,"bx-messenger-call-overlay-button-mic-off")},this));BX.desktop.addCustomEvent("bxCallAnswer",BX.delegate(function(e,t,s,i){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");this.webrtc.callActive=true;BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_ANSWER&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"answer",CHAT_ID:e,CALL_TO_GROUP:i?"Y":"N",RECIPIENT_ID:this.callUserId,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(){this.webrtc.callDialog()},this)})},this));BX.desktop.addCustomEvent("bxCallJoin",BX.delegate(function(e,t,s,i){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");this.webrtc.callAbort();this.webrtc.callOverlayClose(false);this.webrtc.callInvite(i?"chat"+e:t,s)},this));BX.desktop.addCustomEvent("bxImClearHistory",BX.delegate(function(e){
this.messenger.history[e]=[];this.messenger.showMessage[e]=[];if(this.BXIM.init)BX.MessengerCommon.drawTab(e)},this));BX.desktop.addCustomEvent("bxSaveSettings",BX.delegate(function(e){this.BXIM.settings=e;if(this.BXIM.messenger!=null){BX.MessengerCommon.drawTab(this.messenger.currentTab,true);BX.MessengerCommon.userListRedraw(true);if(this.BXIM.messenger.popupMessengerTextareaSendType)this.BXIM.messenger.popupMessengerTextareaSendType.innerHTML=this.BXIM.settings.sendByEnter?"Enter":BX.browser.IsMac()?"⌘+Enter":"Ctrl+Enter"}if(this.BXIM.webrtc!=null){this.BXIM.webrtc.readDefaults()}},this));BX.desktop.addCustomEvent("bxSaveColor",BX.delegate(function(e){BX.MessengerCommon.setColor(e.color,e.chatId)},this));BX.desktop.addCustomEvent("bxImClickConfirmNotify",BX.delegate(function(e){delete this.BXIM.notify.notify[e];delete this.BXIM.notify.unreadNotify[e];delete this.BXIM.notify.flashNotify[e];this.BXIM.notify.updateNotifyCount(false);if(this.BXIM.openNotify)this.BXIM.notify.openNotify(true,true)},this));BX.desktop.addCustomEvent("BXUserAway",BX.delegate(this.onAwayAction,this));BX.desktop.addCustomEvent("BXTrayAction",BX.delegate(this.onTrayAction,this));BX.desktop.addCustomEvent("BXWakeAction",BX.delegate(this.onWakeAction,this));BX.desktop.addCustomEvent("BXForegroundChanged",BX.delegate(function(e){clearTimeout(this.BXIM.windowFocusTimeout);this.BXIM.windowFocusTimeout=setTimeout(BX.delegate(function(){this.BXIM.changeFocus(e);if(this.BXIM.isFocus()&&this.messenger&&this.messenger.unreadMessage[this.messenger.currentTab]&&this.messenger.unreadMessage[this.messenger.currentTab].length>0)BX.MessengerCommon.readMessage(this.messenger.currentTab);if(this.BXIM.isFocus("notify")&&this.notify){if(this.notify.unreadNotifyLoad)this.notify.loadNotify();else if(this.notify.notifyUpdateCount>0)this.notify.viewNotifyAll()}if(e){this.closeCallFloatDialog()}else{this.openCallFloatDialog()}},this),e?500:0)},this));BX.desktop.addCustomEvent("BXTopmostMoved",BX.delegate(function(e,t){e=parseInt(e);t=parseInt(t);if(e>=0&&t>=0){BXDesktopSystem.StoreSettings("global_topmost_x",""+e);BXDesktopSystem.StoreSettings("global_topmost_y",""+t)}},this));BX.bind(window,"blur",BX.delegate(function(){this.openCallFloatDialog()},this));BX.bind(window,"focus",BX.delegate(function(){this.closeCallFloatDialog()},this));BX.desktop.addCustomEvent("BXTrayMenu",BX.delegate(function(){var t=e.notify.getCounter("**");var s=e.notify.getCounter("im_notify");var i=e.notify.getCounter("im_message");BX.desktop.addTrayMenuItem({Id:"messenger",Order:100,Title:(BX.message("IM_DESKTOP_OPEN_MESSENGER")||"").replace("#COUNTER#",i>0?"("+i+")":""),Callback:function(){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");e.messenger.openMessenger(e.messenger.currentTab)},Default:true});BX.desktop.addTrayMenuItem({Id:"notify",Order:120,Title:(BX.message("IM_DESKTOP_OPEN_NOTIFY")||"").replace("#COUNTER#",s>0?"("+s+")":""),Callback:function(){BX.desktop.windowCommand("show");BX.desktop.changeTab("notify");e.notify.openNotify(false,true)}});BX.desktop.addTrayMenuItem({Id:"bdisk",Order:130,Title:BX.message("IM_DESKTOP_BDISK"),Callback:function(){if(BX.desktop.diskAttachStatus()){BX.desktop.diskOpenFolder()}else{BX.desktop.windowCommand("show");BX.desktop.changeTab("disk")}}});BX.desktop.addTrayMenuItem({Id:"site",Order:140,Title:(BX.message("IM_DESKTOP_GO_SITE")||"").replace("#COUNTER#",t>0?"("+t+")":""),Callback:function(){BX.desktop.browse(BX.desktop.getCurrentUrl())}});BX.desktop.addTrayMenuItem({Id:"separator1",IsSeparator:true,Order:150});BX.desktop.addTrayMenuItem({Id:"settings",Order:160,Title:BX.message("IM_DESKTOP_SETTINGS"),Callback:function(){e.openSettings()}});BX.desktop.addTrayMenuItem({Id:"separator2",IsSeparator:true,Order:1e3});BX.desktop.addTrayMenuItem({Id:"logout",Order:1010,Title:BX.message("IM_DESKTOP_LOGOUT"),Callback:function(){BX.desktop.logout(false,"tray_menu")}})},this));BX.desktop.addCustomEvent("BXProtocolUrl",BX.delegate(function(e,t){console.log("BXProtocolUrl",e,t?JSON.stringify(t):"");t=t?t:{};if(t.bitrix24net&&t.bitrix24net=="Y"&&!this.BXIM.bitrix24net)return false;BX.desktop.setActiveWindow();if(e=="messenger"){if(t.dialog){this.BXIM.openMessenger(t.dialog)}else if(t.chat){this.BXIM.openMessenger("chat"+t.chat)}else{this.BXIM.openMessenger()}BX.desktop.windowCommand("show")}else if(e=="chat"&&t.id){this.BXIM.openMessenger("chat"+t.id);BX.desktop.windowCommand("show")}else if(e=="chat"&&t.create){this.BXIM.openMessenger();this.BXIM.messenger.openChatCreateForm(t.create);BX.desktop.windowCommand("show")}else if(e=="notify"){this.BXIM.openNotify({force:true});BX.desktop.windowCommand("show")}else if(e=="history"&&t.user){if(t.dialog){this.BXIM.openHistory(t.dialog)}else if(t.chat){this.BXIM.openHistory("chat"+t.chat)}BX.desktop.windowCommand("show")}else if(e=="callto"){if(t.video){this.BXIM.callTo(t.video,true)}else if(t.audio){this.BXIM.callTo(t.audio,false)}else if(t.phone){if(t.params){var s={};t.params=t.params.split("!!");var i="";var a=true;for(var n=0;n<t.params.length;n++){if(a){i=t.params[n];a=false}else{a=true;s[i]=t.params[n]}}this.webrtc.phoneCall(unescape(t.phone),s)}else{this.BXIM.phoneTo(unescape(t.phone))}}BX.desktop.windowCommand("show")}},this));BX.addCustomEvent("onPullEvent-webdav",function(e,t){BX.desktop.diskReportStorageNotification(e,t)});BX.addCustomEvent("onPullEvent-main",BX.delegate(function(e,t){if(e=="user_counter"&&t[BX.message("SITE_ID")]){if(t[BX.message("SITE_ID")]["**"]){var s=parseInt(t[BX.message("SITE_ID")]["**"]);this.notify.updateNotifyCounters({"**":s})}}},this))}};BX.IM.Desktop.prototype.run=function(){return typeof BX.desktop!="undefined"};BX.IM.Desktop.prototype.ready=function(){return typeof BX.desktop!="undefined"&&BX.desktop.ready()};BX.IM.Desktop.prototype.getCurrentUrl=function(){if(!this.run())return false;return BX.desktop.getCurrentUrl()};BX.IM.Desktop.prototype.enableInVersion=function(e){if(!this.run())return false;return BX.desktop.enableInVersion(e)};BX.IM.Desktop.prototype.addCustomEvent=function(e,t){if(!this.run())return false;BX.desktop.addCustomEvent(e,t)};BX.IM.Desktop.prototype.onCustomEvent=function(e,t,s){if(!this.run())return false;BX.desktop.addCustomEvent(e,t,s)};BX.IM.Desktop.prototype.windowCommand=function(e,t){if(!this.run())return false;if(typeof t=="undefined")BX.desktop.windowCommand(e);else BX.desktop.windowCommand(t,e)};BX.IM.Desktop.prototype.browse=function(e){if(!this.run())return false;BX.desktop.browse(e)};BX.IM.Desktop.prototype.drawOnPlaceholder=function(e){if(this.markup==null||!BX.type.isDomNode(e))return false;this.markup.innerHTML="";this.markup.appendChild(e)};BX.IM.Desktop.prototype.openNewNotify=function(e,t,s){if(!this.ready())return;if(t=="")return false;if(this.showNotifyId[e])return false;this.showNotifyId[e]=true;var i={};i[e]=this.BXIM.notify.notify[e];BXDesktopSystem.ExecuteCommand("notification.show.html",this.getHtmlPage(t,s,{notify:i},"im-notify-popup"))};BX.IM.Desktop.prototype.openNewMessage=function(e,t,s){if(!this.ready())return;if(t=="")return false;if(this.showMessageId[e])return false;this.showMessageId[e]=true;BXDesktopSystem.ExecuteCommand("notification.show.html",this.getHtmlPage(t,s,true,"im-notify-popup"))};BX.IM.Desktop.prototype.adjustSize=function(){documentOffsetHeight=document.body.offsetHeight;if(this.run()&&!this.ready()){if(this.BXIM.context=="LINES"){if(window.innerHeight<BX.desktop.minHeight){return false}}else{documentOffsetHeight=BX.desktop.content.offsetHeight}var e=documentOffsetHeight-this.initHeight;this.initHeight=documentOffsetHeight}else if(!this.ready()||!this.BXIM.init||!this.BXIM.messenger||!this.BXIM.notify){return false}else{if(window.innerHeight<BX.desktop.minHeight)return false;var e=documentOffsetHeight-this.initHeight;this.initHeight=documentOffsetHeight}this.BXIM.messenger.popupMessengerBodySize=Math.max(this.BXIM.messenger.popupMessengerBodySize+e,this.BXIM.messenger.popupMessengerBodySizeMin-(this.BXIM.messenger.popupMessengerTextareaSize-30));if(this.BXIM.messenger.popupMessengerBody!=null){this.BXIM.messenger.popupMessengerBody.style.height=this.BXIM.messenger.popupMessengerBodySize+"px";this.BXIM.messenger.redrawChatHeader()}this.BXIM.messenger.popupContactListElementsSize=Math.max(this.BXIM.messenger.popupContactListElementsSize+e,this.BXIM.messenger.popupContactListElementsSizeMin);if(this.BXIM.messenger.popupContactListElements!=null)this.BXIM.messenger.popupContactListElements.style.height=this.BXIM.messenger.popupContactListElementsSize+"px";this.BXIM.messenger.popupMessengerFullHeight=documentOffsetHeight;if(this.BXIM.messenger.popupMessengerExtra!=null)this.BXIM.messenger.popupMessengerExtra.style.height=this.BXIM.messenger.popupMessengerFullHeight+"px";this.BXIM.notify.popupNotifySize=Math.max(this.BXIM.notify.popupNotifySize+e,this.BXIM.notify.popupNotifySizeMin);if(this.BXIM.notify.popupNotifyItem!=null)this.BXIM.notify.popupNotifyItem.style.height=this.BXIM.notify.popupNotifySize+"px";if(this.BXIM.webrtc.callOverlay){this.BXIM.webrtc.callOverlay.style.transition="none";this.BXIM.webrtc.callOverlay.style.width=(this.BXIM.messenger.popupMessengerExtra.style.display=="block"?this.BXIM.messenger.popupMessengerExtra.offsetWidth-1:this.BXIM.messenger.popupMessengerDialog.offsetWidth-1)+"px";this.BXIM.webrtc.callOverlay.style.height=this.BXIM.messenger.popupMessengerFullHeight-1+"px"}if(this.BXIM.messenger.chatCreateFormBody){BX.style(this.BXIM.messenger.chatCreateFormBody,"height",this.BXIM.messenger.popupMessengerBodySize+"px")}if(this.BXIM.messenger.popupCreateChatTextarea){BX.style(this.BXIM.messenger.popupCreateChatTextarea,"height",this.BXIM.messenger.popupMessengerTextareaSize+"px")}this.BXIM.messenger.closeMenuPopup();if(this.ready()){clearTimeout(this.BXIM.adjustSizeTimeout);this.BXIM.adjustSizeTimeout=setTimeout(BX.delegate(function(){this.BXIM.setLocalConfig("global_msz_v2",{wz:this.BXIM.messenger.popupMessengerFullWidth,ta2:this.BXIM.messenger.popupMessengerTextareaSize,b:this.BXIM.messenger.popupMessengerBodySize,cl:this.BXIM.messenger.popupContactListSize,hi:this.BXIM.messenger.popupHistoryItemsSize,fz:this.BXIM.messenger.popupMessengerFullHeight,ez:this.BXIM.messenger.popupContactListElementsSize,nz:this.BXIM.notify.popupNotifySize,hf:this.BXIM.messenger.popupHistoryFilterVisible,dw:window.innerWidth,dh:window.innerHeight,place:"desktop"});if(this.BXIM.webrtc.callOverlay)this.BXIM.webrtc.callOverlay.style.transition=""},this),500)}return true};BX.IM.Desktop.prototype.autoResize=function(e){if(!this.ready())return;BX.desktop.resize()};BX.IM.Desktop.prototype.openSettings=function(e,t,s){if(!this.ready())return false;s=s||{};if(s.minSettingsWidth)this.minSettingsWidth=s.minSettingsWidth;if(s.minSettingsHeight)this.minSettingsHeight=s.minSettingsHeight;BX.desktop.createWindow("settings",BX.delegate(function(s){s.SetProperty("clientSize",{Width:this.minSettingsWidth,Height:this.startSettingsHeight});s.SetProperty("minClientSize",{Width:this.minSettingsWidth,Height:this.minSettingsHeight});s.SetProperty("resizable",false);s.SetProperty("title",BX.message("IM_SETTINGS"));s.ExecuteCommand("html.load",this.getHtmlPage(e,t,{}))},this))};BX.IM.Desktop.prototype.openHistory=function(e,t,s){if(!this.ready())return false;BX.desktop.createWindow("history",BX.delegate(function(i){var a={chat:{},users:{},files:{}};if(e.toString().substr(0,4)=="chat"){var n=e.substr(4);a["chat"][n]=this.messenger.chat[n];a["files"][n]=this.disk.files[n];for(var r=0;r<this.messenger.userInChat[n].length;r++)a["users"][this.messenger.userInChat[n][r]]=this.messenger.users[this.messenger.userInChat[n][r]]}else{n=this.messenger.userChat[e]?this.messenger.userChat[e]:0;a["userChat"]={};a["userChat"][e]=n;a["users"][e]=this.messenger.users[e];a["users"][this.BXIM.userId]=this.messenger.users[this.BXIM.userId];a["files"][n]=this.disk.files[n]}i.SetProperty("clientSize",{Width:this.messenger.disk.enable?this.minHistoryDiskWidth:this.minHistoryWidth,Height:this.minHistoryHeight});i.SetProperty("minClientSize",{Width:this.messenger.disk.enable?this.minHistoryDiskWidth:this.minHistoryWidth,Height:this.minHistoryHeight});i.SetProperty("resizable",false);i.ExecuteCommand("html.load",this.getHtmlPage(t,s,a));i.SetProperty("title",BX.message("IM_M_HISTORY"))},this))};BX.IM.Desktop.prototype.openCallFloatDialog=function(){if(!this.BXIM.init||!this.ready()||!this.webrtc||!this.webrtc.callActive||this.topmostWindow||this.phoneTransferEnabled)return false;if(this.webrtc.callVideo&&!this.webrtc.callStreamMain)return false;if(!this.webrtc.callOverlayTitleBlock)return false;this.openTopmostWindow("callFloatDialog",'BXIM.webrtc.callFloatDialog("'+BX.util.jsencode(this.webrtc.callOverlayTitleBlock.innerHTML.replace(/<\/?[^>]+>/gi," "))+'", "'+(this.webrtc.callVideo?this.webrtc.callOverlayVideoMain.src:"")+'", '+(this.webrtc.audioMuted?1:0)+")",{},"im-desktop-call")};BX.IM.Desktop.prototype.closeCallFloatDialog=function(){if(!this.ready()||!this.topmostWindow)return false;if(this.webrtc.callActive){if(this.webrtc.callOverlayUserId>0&&this.webrtc.callOverlayUserId==this.messenger.currentTab){this.closeTopmostWindow()}else if(this.webrtc.callOverlayChatId>0&&this.webrtc.callOverlayChatId==this.messenger.currentTab.toString().substr(4)){this.closeTopmostWindow()}}else{this.closeTopmostWindow()}};BX.IM.Desktop.prototype.openTopmostWindow=function(e,t,s,i){if(!this.ready())return false;this.closeTopmostWindow();console.log("openTopmostWindow init",e,t);clearTimeout(this.topmostWindowTimeout);this.topmostWindowTimeout=setTimeout(BX.delegate(function(){if(this.topmostWindow)return false;console.log("openTopmostWindow show",e);this.topmostWindow=BXDesktopSystem.ExecuteCommand("topmost.show.html",this.getHtmlPage("",t,s,i))},this),500)};BX.IM.Desktop.prototype.closeTopmostWindow=function(){clearTimeout(this.topmostWindowTimeout);clearTimeout(this.topmostWindowCloseTimeout);if(!this.topmostWindow)return false;console.log("closeTopmostWindow init");if(this.topmostWindow&&this.topmostWindow.document)BX.desktop.windowCommand(this.topmostWindow,"hide");this.topmostWindowCloseTimeout=setTimeout(BX.delegate(function(){if(this.topmostWindow&&this.topmostWindow.document){console.log("closeTopmostWindow close");BX.desktop.windowCommand(this.topmostWindow,"close");this.topmostWindow=null}},this),300)};BX.IM.Desktop.prototype.getHtmlPage=function(e,t,s,i){if(!this.ready())return;e=e||"";t=t||"";i=i||"";var a=typeof s=="undefined"||typeof s!="object"?{}:s;s=typeof s!="undefined";if(this.htmlWrapperHead==null)this.htmlWrapperHead=document.head.outerHTML.replace(/BX\.PULL\.start\([^)]*\);/g,"");if(e!=""&&BX.type.isDomNode(e))e=e.outerHTML;if(t!=""&&BX.type.isDomNode(t))t=t.outerHTML;if(t!="")t='<script type="text/javascript">BX.ready(function(){'+t+"});</script>";var n="";if(s==true){n='<script type="text/javascript">'+"BX.ready(function() {"+"BXIM = new BX.IM(null, {"+"'init': false,"+"'colors' : "+(this.BXIM.colors?JSON.stringify(this.BXIM.colors):"false")+","+"'settings' : "+JSON.stringify(this.BXIM.settings)+","+"'settingsView' : "+JSON.stringify(this.BXIM.settingsView)+","+"'updateStateInterval': '"+this.BXIM.updateStateInterval+"',"+"'desktop': "+this.run()+","+"'ppStatus': false,"+"'ppServerStatus': false,"+"'xmppStatus': "+this.BXIM.xmppStatus+","+"'bitrixNetwork': "+this.BXIM.bitrixNetwork+","+"'bitrixNetwork2': "+this.BXIM.bitrixNetwork2+","+"'bitrixOpenLines': "+this.BXIM.bitrixOpenLines+","+"'bitrix24': "+this.BXIM.bitrix24+","+"'bitrixIntranet': "+this.BXIM.bitrixIntranet+","+"'bitrixXmpp': "+this.BXIM.bitrixXmpp+","+"'bitrixMobile': "+this.BXIM.bitrixMobile+","+"'files' : "+(a.files?JSON.stringify(a.files):"{}")+","+"'notify' : "+(a.notify?JSON.stringify(a.notify):"{}")+","+"'users' : "+(a.users?JSON.stringify(a.users):"{}")+","+"'chat' : "+(a.chat?JSON.stringify(a.chat):"{}")+","+"'userChat' : "+(a.userChat?JSON.stringify(a.userChat):"{}")+","+"'userInChat' : "+(a.userInChat?JSON.stringify(a.userInChat):"{}")+","+"'hrphoto' : "+(a.hrphoto?JSON.stringify(a.hrphoto):"{}")+","+"'phoneCrm' : "+(a.phoneCrm?JSON.stringify(a.phoneCrm):"{}")+","+"'generalChatId': "+this.BXIM.messenger.generalChatId+","+"'canSendMessageGeneralChat': "+this.BXIM.messenger.canSendMessageGeneralChat+","+"'userId': "+this.BXIM.userId+","+"'userEmail': '"+this.BXIM.userEmail+"',"+"'userColor': '"+this.BXIM.userColor+"',"+"'userGender': '"+this.BXIM.userGender+"',"+"'userExtranet': "+this.BXIM.userExtranet+","+"'disk': {'enable': "+(this.disk?this.disk.enable:false)+"},"+"'path' : "+JSON.stringify(this.BXIM.path)+"});"+"});"+"</script>"}return"<!DOCTYPE html><html>"+this.htmlWrapperHead+'<body class="im-desktop im-desktop-popup '+i+'"><div id="placeholder-messanger">'+e+"</div>"+n+t+"</body></html>"};BX.IM.Desktop.prototype.onAwayAction=function(e,t){BX.ajax({url:this.BXIM.pathToAjax+"?IDLE&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_IDLE:"Y",IM_AJAX_CALL:"Y",IDLE:e?"Y":"N",MANUAL:t?"Y":"N",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(e&&e.BITRIX_SESSID){BX.message({bitrix_sessid:e.BITRIX_SESSID})}if(e.ERROR=="AUTHORIZE_ERROR"&&this.desktop.ready()&&this.messenger.sendAjaxTry<3){this.messenger.sendAjaxTry++;BX.onCustomEvent(window,"onImError",[e.ERROR])}else if(e.ERROR=="SESSION_ERROR"&&this.messenger.sendAjaxTry<2){this.messenger.sendAjaxTry++;BX.onCustomEvent(window,"onImError",[e.ERROR,e.BITRIX_SESSID])}else{if(e.ERROR=="AUTHORIZE_ERROR"||e.ERROR=="SESSION_ERROR"){BX.onCustomEvent(window,"onImError",[e.ERROR])}}},this)})};BX.IM.Desktop.prototype.onWakeAction=function(){BX.desktop.setIconStatus("offline");BX.desktop.checkInternetConnection(function(){BX.desktop.windowReload()},BX.delegate(function(){BX.desktop.login()},this),10)};BX.IM.Desktop.prototype.onTrayAction=function(){BX.desktop.windowCommand("show");var e=this.BXIM.notify.getCounter("im_message");var t=this.BXIM.notify.getCounter("im_notify");if(e>0){if(this.BXIM.notifyOpen==true&&t>0){BX.desktop.changeTab("notify")}else{BX.desktop.changeTab("im");this.BXIM.messenger.openMessenger()}}else if(t>0){BX.desktop.changeTab("notify")}if(this.BXIM.messenger.popupMessengerTextarea){this.BXIM.messenger.popupMessengerTextarea.focus()}};BX.IM.Desktop.prototype.birthdayStatus=function(e){if(!this.ready())return false;if(typeof e!="boolean"){return this.BXIM.getLocalConfig("birthdayStatus",true)}else{this.BXIM.setLocalConfig("birthdayStatus",e);return e}};BX.IM.Desktop.prototype.changeTab=function(e){return false};BX.PopupWindowDesktop=function(){this.closeByEsc=true;this.setClosingByEsc=function(e){this.closeByEsc=e};this.close=function(){BX.desktop.windowCommand("close")};this.destroy=function(){BX.desktop.windowCommand("close")}};BX.IM.WebRTC=function(e,t){this.BXIM=e;this.screenSharing=new BX.IM.ScreenSharing(this,t);this.panel=t.panel;this.desktop=t.desktopClass;this.callToPhone=false;this.callOverlayFullScreen=false;this.callToMobile=false;this.callAspectCheckInterval;this.callAspectHorizontal=true;this.callInviteTimeout=null;this.callNotify=null;this.callAllowTimeout=null;this.callDialogAllow=null;this.callOverlay=null;this.callOverlayMinimize=null;this.callOverlayChatId=0;this.callOverlayUserId=0;this.callSelfDisabled=false;this.callOverlayPhotoSelf=null;this.callOverlayPhotoUsers={};this.callOverlayVideoUsers={};this.callOverlayVideoPhotoUsers={};this.callOverlayOptions={};this.callOverlayPhotoCompanion=null;this.callOverlayPhotoMini=null;this.callOverlayVideoMain=null;this.callOverlayVideoReserve=null;this.callOverlayVideoSelf=null;this.callOverlayProgressBlock=null;this.callOverlayStatusBlock=null;this.callOverlayButtonsBlock=null;this.callServerEnabled=t.callServerEnabled;this.phoneEnabled=t.phoneEnabled;this.phoneSipAvailable=t.phoneSipAvailable;this.phoneDeviceActive=t.phoneDeviceActive=="Y";this.phoneCanCallUserNumber=t.phoneCanCallUserNumber=="Y";this.phoneInitiateCallViaRestApp=t.phoneInitiateCallViaRestApp;this.phoneCallerID="";this.phoneLogin="";this.phoneServer="";this.phoneCheckBalance=false;this.phoneCallHistory={};this.phoneSDKinit=false;this.phoneMicAccess=false;this.phoneIncoming=false;this.phoneCallId="";this.phoneCallTime=0;this.phoneCallConfig={};this.phoneCallExternal=false;this.phoneCallDevice="WEBRTC";this.phonePortalCall=false;this.phoneNumber="";this.phoneNumberUser="";this.phoneNumberLast=this.BXIM.getLocalConfig("phone_last","");this.phoneParams={};this.phoneAPI=null;this.phoneDisconnectAfterCallFlag=true;this.phoneCurrentCall=null;this.phoneCrm=t.phoneCrm?t.phoneCrm:{};this.phoneMicMuted=false;this.phoneHolded=false;this.phoneRinging=0;this.phoneTransferEnabled=false;this.phoneTransferUser=0;this.phoneTransferType="user";this.phoneTransferPhone="";this.phoneConnectedInterval=null;this.phoneDeviceDelayTimeout=null;this.debug=false;this.popupTransferDialog=null;this.popupTransferDialogDestElements=null;this.popupTransferDialogContactListSearch=null;this.popupTransferDialogContactListElements=null;if(this.setTurnServer){this.setTurnServer({turnServer:t.turnServer||"",turnServerFirefox:t.turnServerFirefox||"",turnServerLogin:t.turnServerLogin||"",turnServerPassword:t.turnServerPassword||""})}this.readDefaults();this.defineButtons();var s=false;if(this.enabled){s=true;BX.addCustomEvent("onPullEvent-im",BX.delegate(function(t,s){if(t=="call"){this.log("Incoming",s.command,s.senderId,JSON.stringify(s));if(s.command=="join"){for(var i in s.users)this.messenger.users[i]=s.users[i];for(var i in s.hrphoto)this.messenger.hrphoto[i]=s.hrphoto[i];if(this.callInit||this.callActive){setTimeout(BX.delegate(function(){BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_BUSY&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"busy",CHAT_ID:s.chatId,RECIPIENT_ID:s.senderId,VIDEO:s.video?"Y":"N",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})},this),s.callToGroup?1e3:0)}else{if(this.desktop.ready()||!this.desktop.ready()&&!this.BXIM.desktopStatus){this.messenger.openMessenger("chat"+s.chatId);this.BXIM.repeatSound("ringtone",5e3);this.callNotifyWait(s.chatId,s.senderId,s.video,s.callToGroup,true)}if(this.desktop.ready()&&!this.BXIM.windowFocus){var a={users:{},chat:{},userInChat:{},hrphoto:{}};if(s.callToGroup){a["chat"][s.chatId]=this.messenger.chat[s.chatId];a["userInChat"][s.chatId]=this.messenger.userInChat[s.chatId]}for(var i=0;i<this.messenger.userInChat[s.chatId].length;i++){a["users"][this.messenger.userInChat[s.chatId][i]]=this.messenger.users[this.messenger.userInChat[s.chatId][i]];a["hrphoto"][this.messenger.userInChat[s.chatId][i]]=this.messenger.hrphoto[this.messenger.userInChat[s.chatId][i]]}this.desktop.openTopmostWindow("callNotifyWaitDesktop","BXIM.webrtc.callNotifyWaitDesktop("+s.chatId+",'"+s.senderId+"', "+(s.video?1:0)+", "+(s.callToGroup?1:0)+", true);",a,"im-desktop-call")}}}else if(s.command=="invite"||s.command=="invite_join"){for(var i in s.users)this.messenger.users[i]=s.users[i];for(var i in s.hrphoto)this.messenger.hrphoto[i]=s.hrphoto[i];for(var i in s.chat)this.messenger.chat[i]=s.chat[i];for(var i in s.userInChat)this.messenger.userInChat[i]=s.userInChat[i];if(this.callInit||this.callActive){if(s.command=="invite"){if(this.callChatId==s.chatId){this.callCommand(s.chatId,"busy_self");this.callOverlayClose(false)}else{setTimeout(BX.delegate(function(){BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_BUSY&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"busy",CHAT_ID:s.chatId,RECIPIENT_ID:s.senderId,VIDEO:s.video?"Y":"N",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})},this),s.callToGroup?1e3:0)}}else if(this.initiator&&this.callChatId==s.chatId){this.initiator=false;this.callDialog();BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_ANSWER&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"answer",CHAT_ID:this.callChatId,CALL_TO_GROUP:this.callToGroup?"Y":"N",RECIPIENT_ID:this.callUserId,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})}}else{if(this.desktop.ready()||!this.desktop.ready()&&!this.BXIM.desktopStatus||this.desktop.run()&&!this.desktop.ready()&&this.BXIM.desktopStatus){this.BXIM.repeatSound("ringtone",5e3);this.callCommand(s.chatId,"wait");if(this.desktop.run())BX.desktop.changeTab("im");this.callNotifyWait(s.chatId,s.senderId,s.video,s.callToGroup);if(s.isMobile){this.callToMobile=true;BX.addClass(this.callOverlay,"bx-messenger-call-overlay-mobile")}}if(this.desktop.ready()&&!this.BXIM.isFocus("all")){var a={users:{},chat:{},userInChat:{},hrphoto:{}};if(s.callToGroup){a["chat"][s.chatId]=this.messenger.chat[s.chatId];a["userInChat"][s.chatId]=this.messenger.userInChat[s.chatId]}for(var i=0;i<this.messenger.userInChat[s.chatId].length;i++){a["users"][this.messenger.userInChat[s.chatId][i]]=this.messenger.users[this.messenger.userInChat[s.chatId][i]];a["hrphoto"][this.messenger.userInChat[s.chatId][i]]=this.messenger.hrphoto[this.messenger.userInChat[s.chatId][i]]}this.desktop.openTopmostWindow("callNotifyWaitDesktop","BXIM.webrtc.callNotifyWaitDesktop("+s.chatId+",'"+s.senderId+"', "+(s.video?1:0)+", "+(s.callToGroup?1:0)+");",a,"im-desktop-call")}}}else if(this.callInit&&this.callChatId==s.lastChatId&&s.command=="invite_user"){for(var i in s.users)this.messenger.users[i]=s.users[i];for(var i in s.hrphoto)this.messenger.hrphoto[i]=s.hrphoto[i];this.callChatId=s.chatId;this.callGroupOverlayRedraw()}else if(!this.callActive&&this.callInit&&this.callChatId==s.chatId&&s.command=="wait"){if(!this.callToGroup){clearTimeout(this.callDialtoneTimeout);this.callDialtoneTimeout=setTimeout(BX.delegate(function(){this.BXIM.repeatSound("dialtone",5e3)},this),2e3)}this.callWait(s.senderId)}else if(this.initiator&&this.callChatId==s.chatId&&s.command=="answer"){this.callDialog();if(s.isMobile){this.callToMobile=true;BX.addClass(this.callOverlay,"bx-messenger-call-overlay-mobile")}}else if(s.command=="ready"){if(this.callActive&&this.callStreamSelf==null){clearTimeout(this.callAllowTimeout);this.callAllowTimeout=setTimeout(BX.delegate(function(){this.callOverlayProgress("offline");this.callCommand(this.callChatId,"errorAccess");this.callOverlayButtons(this.buttonsOverlayClose);this.callAbort(BX.message("IM_M_CALL_ST_NO_ACCESS_3"))},this),6e4)}this.log("Apponent "+s.senderId+" ready!");this.connected[s.senderId]=true}else if(this.callActive&&this.callChatId==s.chatId&&s.command=="errorAccess"&&(!s.callToGroup||s.closeConnect)){this.callOverlayProgress("offline");this.callOverlayStatus(BX.message("IM_M_CALL_ST_NO_ACCESS_2"));this.callOverlayButtons(this.buttonsOverlayClose);this.callAbort(BX.message("IM_M_CALL_ST_NO_ACCESS_2"))}else if(this.callActive&&this.callChatId==s.chatId&&s.command=="reconnect"){clearTimeout(this.pcConnectTimeout[s.senderId]);clearTimeout(this.initPeerConnectionTimeout[s.senderId]);if(this.pc[s.senderId])this.pc[s.senderId].close();delete this.pc[s.senderId];delete this.pcStart[s.senderId];if(this.callStreamMain==this.callStreamUsers[s.senderId])this.callStreamMain=null;this.callStreamUsers[s.senderId]=null;this.initPeerConnection(s.senderId)}else if(this.callActive&&this.callChatId==s.chatId&&s.command=="signaling"){this.signalingPeerData(s.senderId,s.peer)}else if(this.callInit&&this.callChatId==s.chatId&&s.command=="waitTimeout"&&(!s.callToGroup||s.closeConnect)){this.callAbort();this.callOverlayClose()}else if(this.callInit&&this.callChatId==s.chatId&&(s.command=="busy_self"||s.command=="callToPhone")){this.callAbort();this.callOverlayClose()}else if(this.callInit&&this.callChatId==s.chatId&&s.command=="busy"&&(!s.callToGroup||s.closeConnect)){this.callOverlayProgress("offline");this.callOverlayButtons([{text:BX.message("IM_M_CALL_BTN_RECALL"),className:"bx-messenger-call-overlay-button-recall",events:{click:BX.delegate(function(){this.callInvite(s.senderId,s.video)},this)}},{text:BX.message("IM_M_CALL_BTN_HISTORY"),title:BX.message("IM_M_CALL_BTN_HISTORY_2"),showInMinimize:true,className:"bx-messenger-call-overlay-button-history",events:{click:BX.delegate(function(){this.messenger.openHistory(this.messenger.currentTab)},this)}},{text:BX.message("IM_M_CALL_BTN_CLOSE"),className:"bx-messenger-call-overlay-button-close",events:{click:BX.delegate(function(){this.callOverlayClose()},this)}}]);this.callAbort(BX.message("IM_M_CALL_ST_BUSY"))}else if(this.callInit&&this.callChatId==s.chatId&&s.command=="decline"&&(!s.callToGroup||s.closeConnect)){if(this.callInitUserId!=this.BXIM.userId||this.callActive){var n=this.callVideo;this.callOverlayStatus(BX.message("IM_M_CALL_ST_DECLINE"));this.BXIM.playSound("stop");if(n&&this.callStreamSelf!=null)this.callOverlayVideoClose();else this.callOverlayClose()}else if(this.callInitUserId==this.BXIM.userId){this.callOverlayProgress("offline");this.callOverlayButtons(this.buttonsOverlayClose);this.callAbort(BX.message("IM_M_CALL_ST_DECLINE"))}else{this.callAbort()}}else if((s.command=="decline_self"&&this.callChatId==s.chatId||s.command=="answer_self"&&!this.callActive)&&!this.callSelfDisabled){this.BXIM.stopRepeatSound("ringtone");this.BXIM.stopRepeatSound("dialtone");this.callOverlayClose(true)}else if(this.callInit&&s.callToGroup&&this.callChatId==s.chatId&&(s.command=="errorAccess"||s.command=="waitTimeout"||s.command=="busy"||s.command=="decline")){var r=this.callOverlayVideoMain.getAttribute("data-userId");if(r==s.senderId){var o=false;for(var i in this.callStreamUsers){if(i==s.senderId)continue;this.callChangeMainVideo(i);o=true;break}if(!o){this.callStreamMain=null;this.callOverlayProgress("wait");this.callOverlayStatus(BX.message(this.callToGroup?"IM_M_CALL_ST_WAIT_ACCESS_3":"IM_M_CALL_ST_WAIT_ACCESS_2"));BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-call-active");BX.removeClass(e.webrtc.callOverlay,"bx-messenger-call-overlay-call-video");BX.removeClass(this.callOverlayVideoUsers[r].parentNode,"bx-messenger-call-video-block-hide")}}BX.addClass(this.callOverlayVideoUsers[s.senderId].parentNode,"bx-messenger-call-video-hide");this.connected[s.senderId]=false;this.callOverlayVideoUsers[s.senderId].src="";this.pc[s.senderId]=null;delete this.pc[s.senderId];delete this.pcStart[s.senderId];if(this.callStreamUsers[s.senderId]&&this.callStreamUsers[s.senderId].stop)this.callStreamUsers[s.senderId].stop();this.callStreamUsers[s.senderId]=null;delete this.callStreamUsers[s.senderId]}else{this.log('Command "'+s.command+'" skip (current chat: '+parseInt(this.callChatId)+"; command chat: "+parseInt(s.chatId))}}},this));if(this.callServerEnabled){var i=BX.create("link",{attrs:{href:"/bitrix/js/im/css/call.css",rel:"stylesheet",type:"text/css"}});document.head.insertBefore(i,document.head.firstChild);var i=BX.create("link",{attrs:{href:"/bitrix/css/main/font-awesome.css",rel:"stylesheet",type:"text/css"}});document.head.insertBefore(i,document.head.firstChild);var i=BX.create("script",{attrs:{src:"/bitrix/js/im/call.js",type:"text/javascript"}});document.head.insertBefore(i,document.head.firstChild);var i=BX.create("script",{attrs:{src:"/bitrix/js/im/webrtc/adapter.js",type:"text/javascript"}});document.head.insertBefore(i,document.head.firstChild);i=BX.create("script",{attrs:{src:"/bitrix/js/im/webrtc/janus.js",type:"text/javascript"}});document.head.insertBefore(i,document.head.firstChild)}}else{if(!this.BXIM.desktopStatus){this.initAudio(true);BX.addCustomEvent("onPullEvent-im",BX.delegate(function(e,t){if(t.command=="call"&&t.command=="invite"){for(var s in t.users)this.messenger.users[s]=t.users[s];for(var s in t.hrphoto)this.messenger.hrphoto[s]=t.hrphoto[s];this.callOverlayShow({toUserId:this.BXIM.userId,fromUserId:t.senderId,callToGroup:this.callToGroup,video:t.video,progress:"offline",minimize:false,status:this.desktop.ready()?BX.message("IM_M_CALL_ST_NO_WEBRTC_3"):BX.message("IM_M_CALL_ST_NO_WEBRTC_2"),buttons:[{text:BX.message("IM_M_CALL_BTN_DOWNLOAD"),className:"bx-messenger-call-overlay-button-download",events:{click:BX.delegate(function(){window.open(BX.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");
this.callOverlayClose()},this)},hide:this.BXIM.platformName==""},{text:BX.message("IM_M_CALL_BTN_CLOSE"),className:"bx-messenger-call-overlay-button-close",events:{click:BX.delegate(function(){this.callOverlayClose()},this)}}]});this.callOverlayDeleteEvents({closeNotify:false})}},this))}}if(this.phoneEnabled&&(this.phoneDeviceActive||this.enabled)){s=true;BX.MessengerCommon.pullPhoneEvent()}if(s){this.initAudio();if(BX.browser.SupportLocalStorage()){BX.addCustomEvent(window,"onLocalStorageSet",BX.delegate(this.storageSet,this))}BX.garbage(function(){if(this.callInit&&!this.callActive){if(this.initiator){this.callCommand(this.callChatId,"decline",{ACTIVE:this.callActive?"Y":"N",INITIATOR:this.initiator?"Y":"N"},false);this.callAbort()}else{var e={};for(var t in this.messenger.hrphoto)e[t]=this.messenger.users[t];BX.localStorage.set("mcr2",{users:e,hrphoto:this.messenger.hrphoto,chat:this.messenger.chat,userInChat:this.messenger.userInChat,callChatId:this.callChatId,callUserId:this.callUserId,callVideo:this.callVideo,callToGroup:this.callToGroup},5)}}if(this.callActive)this.callCommand(this.callChatId,"errorAccess",{},false);this.callOverlayClose()},this)}};if(BX.inheritWebrtc)BX.inheritWebrtc(BX.IM.WebRTC);BX.IM.WebRTC.prototype.ready=function(){return this.enabled};BX.IM.WebRTC.prototype.readDefaults=function(){if(!localStorage)return;this.defaultMicrophone=localStorage.getItem("bx-im-settings-default-microphone");this.defaultCamera=localStorage.getItem("bx-im-settings-default-camera");this.enableMicAutoParameters=localStorage.getItem("bx-im-settings-enable-mic-auto-parameters")!=="N"};BX.IM.WebRTC.prototype.defineButtons=function(){this.buttonsOverlayClose=[{text:BX.message("IM_M_CALL_BTN_CLOSE"),className:"bx-messenger-call-overlay-button-close",events:{click:BX.delegate(function(){this.callOverlayClose()},this)}}]};BX.IM.WebRTC.prototype.initAudio=function(e){if(e===true){this.panel.appendChild(this.BXIM.audio.error=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-error.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-error.mp3",type:"audio/mpeg"}})]}));return false}this.panel.appendChild(this.BXIM.audio.dialtone=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-dialtone.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-dialtone.mp3",type:"audio/mpeg"}})]}));this.panel.appendChild(this.BXIM.audio.ringtone=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-ringtone.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-ringtone.mp3",type:"audio/mpeg"}})]}));this.panel.appendChild(this.BXIM.audio.start=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-start.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-start.mp3",type:"audio/mpeg"}})]}));this.panel.appendChild(this.BXIM.audio.stop=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-stop.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-stop.mp3",type:"audio/mpeg"}})]}));this.panel.appendChild(this.BXIM.audio.error=BX.create("audio",{props:{className:"bx-messenger-audio"},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-error.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/video-error.mp3",type:"audio/mpeg"}})]}));if(typeof this.BXIM.audio.stop.play=="undefined"){this.BXIM.settings.enableSound=false}};BX.IM.WebRTC.prototype.startGetUserMedia=function(e,t){clearTimeout(this.callDialtoneTimeout);this.BXIM.stopRepeatSound("ringtone");this.BXIM.stopRepeatSound("dialtone");var s=true;clearTimeout(this.callInviteTimeout);clearTimeout(this.callDialogAllowTimeout);if(s){this.callDialogAllowTimeout=setTimeout(BX.delegate(function(){this.callDialogAllowShow()},this),1500)}this.parent.startGetUserMedia.apply(this,arguments)};BX.IM.WebRTC.prototype.onUserMediaSuccess=function(e){clearTimeout(this.callAllowTimeout);var t=this.parent.onUserMediaSuccess.apply(this,arguments);if(!t)return false;this.callOverlayProgress("online");this.callOverlayStatus(BX.message(this.callToGroup?"IM_M_CALL_ST_WAIT_ACCESS_3":"IM_M_CALL_ST_WAIT_ACCESS_2"));if(this.callDialogAllow)this.callDialogAllow.close();this.attachMediaStream(this.callOverlayVideoSelf,this.callStreamSelf);this.callOverlayVideoSelf.muted=true;if(this.callToGroup&&this.callVideo){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call-active");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call-video")}setTimeout(BX.delegate(function(){if(!this.callActive)return false;BX.addClass(this.callOverlay,"bx-messenger-call-overlay-ready")},this),500);this.callCommand(this.callChatId,"ready");if(this.desktop.ready()&&this.BXIM.init){BX.desktop.syncPause(true)}};BX.IM.WebRTC.prototype.onUserMediaError=function(e){clearTimeout(this.callAllowTimeout);var t=this.parent.onUserMediaError.apply(this,arguments);if(!t)return false;if(this.callDialogAllow)this.callDialogAllow.close();if(e&&e.name=="ConstraintNotSatisfiedError"){this.startGetUserMedia(this.lastUserMediaParams["video"],this.lastUserMediaParams["audio"])}else{this.callOverlayProgress("offline");this.callCommand(this.callChatId,"errorAccess");if(location.protocol.indexOf("https")===-1){this.callAbort(BX.message("IM_M_CALL_ST_NO_ACCESS_HTTPS"))}else{this.callAbort(BX.message("IM_M_CALL_ST_NO_ACCESS"))}this.callOverlayButtons(this.buttonsOverlayClose)}};BX.IM.WebRTC.prototype.setLocalAndSend=function(e,t){var s=this.parent.setLocalAndSend.apply(this,arguments);if(!s)return false;BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_SIGNALING&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"signaling",CHAT_ID:this.callChatId,RECIPIENT_ID:e,PEER:JSON.stringify(t),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});return true};BX.IM.WebRTC.prototype.onRemoteStreamAdded=function(e,t,s){if(s){this.attachMediaStream(this.callOverlayVideoMain,this.callStreamMain);if(this.desktop.ready())BX.desktop.onCustomEvent("bxCallChangeMainVideo",[this.callOverlayVideoMain.src]);if(!this.BXIM.windowFocus)this.desktop.openCallFloatDialog();this.callOverlayVideoMain.setAttribute("data-userId",e);this.callOverlayVideoMain.muted=false;this.callOverlayVideoMain.volume=1;BX("bx-messenger-call-overlay-button-plus").style.display="inline-block";this.callOverlayStatus(BX.message("IM_M_CALL_ST_ONLINE"));BX.addClass(this.callOverlay,"bx-messenger-call-overlay-online");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call-active");if(this.callVideo)BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call-video");clearInterval(this.callAspectCheckInterval);this.callAspectCheckInterval=setInterval(BX.delegate(function(){if(this.callOverlayVideoMain.offsetWidth<this.callOverlayVideoMain.offsetHeight){if(this.callAspectHorizontal){this.callAspectHorizontal=false;BX.addClass(this.callOverlay,"bx-messenger-call-overlay-aspect-vertical")}}else{if(!this.callAspectHorizontal){this.callAspectHorizontal=true;BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-aspect-vertical")}}},this),500)}if(this.callToGroup){if(!s){this.attachMediaStream(this.callOverlayVideoUsers[e],this.callStreamUsers[e]);BX.removeClass(this.callOverlayVideoUsers[e].parentNode,"bx-messenger-call-video-hide")}else{BX.addClass(this.callOverlayVideoUsers[e].parentNode,"bx-messenger-call-video-block-hide")}}if(this.initiator)this.callCommand(this.callChatId,"start",{CALL_TO_GROUP:this.callToGroup?"Y":"N",RECIPIENT_ID:e})};BX.IM.WebRTC.prototype.onRemoteStreamRemoved=function(e,t){clearInterval(this.callAspectCheckInterval);BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-aspect-vertical");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-online")};BX.IM.WebRTC.prototype.onIceCandidate=function(e,t){BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_SIGNALING&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"signaling",CHAT_ID:this.callChatId,RECIPIENT_ID:e,PEER:JSON.stringify(t),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})};BX.IM.WebRTC.prototype.peerConnectionError=function(e,t){if(this.callDialogAllow)this.callDialogAllow.close();this.callOverlayProgress("offline");this.callCommand(this.callChatId,"errorAccess");this.callAbort(BX.message("IM_M_CALL_ST_CON_ERROR"));this.callOverlayButtons(this.buttonsOverlayClose)};BX.IM.WebRTC.prototype.peerConnectionGetStats=function(){if(this.detectedBrowser!="chrome")return false;if(this.callUserId<=0||!this.pc[this.callUserId]||!this.pc[this.callUserId].getStats||this.callToGroup||this.callToPhone)return false;this.pc[this.callUserId].getStats(function(e){console.log(e)})};BX.IM.WebRTC.prototype.peerConnectionReconnect=function(e){var t=this.parent.peerConnectionReconnect.apply(this,arguments);if(!t)return false;BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_RECONNECT&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"reconnect",CHAT_ID:this.callChatId,RECIPIENT_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(){this.initPeerConnection(e,true)},this)});return true};BX.IM.WebRTC.prototype.callSupport=function(e,t){t=t?t:this.messenger;var s=true;if(typeof e!="undefined"){if(parseInt(e)>0){s=t.users[e]&&t.users[e].status!="guest"&&!t.users[e].bot&&!t.users[e].network}else{if(t.chat[e.toString().substr(4)]&&t.chat[e.toString().substr(4)].type=="open"){s=false}else if(!this.callServerEnabled){s=t.userInChat[e.toString().substr(4)]&&t.userInChat[e.toString().substr(4)].length<=4}}}return this.BXIM.ppServerStatus&&this.enabled&&s};BX.IM.WebRTC.prototype.callInvite=function(e,t,s){if(BX.localStorage.get("viInitedCall"))return false;if(this.desktop.run()&&BX.desktop.currentTab!="im"){BX.desktop.changeTab("im")}if(!this.callSupport()){if(!this.desktop.ready()){this.BXIM.openConfirm(BX.message("IM_CALL_NO_WEBRT"),[this.BXIM.platformName==""?null:new BX.PopupWindowButton({text:BX.message("IM_M_CALL_BTN_DOWNLOAD"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){window.open(BX.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");BX.proxy_context.popupWindow.close()},this)}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})])}return false}var i=false;if(parseInt(e)>0){if(this.messenger.users[e]&&this.messenger.users[e].status=="guest"){this.BXIM.openConfirm(BX.message("IM_CALL_USER_OFFLINE"));return false}else if(!this.messenger.users[e]){BX.MessengerCommon.getUserParam(e)}e=parseInt(e)}else{e=e.toString().substr(4);if(!this.messenger.userInChat[e]||this.messenger.userInChat[e].length<=1){return false}else if(!this.messenger.userInChat[e]||this.messenger.userInChat[e].length>4){this.BXIM.openConfirm(BX.message("IM_CALL_CHAT_LARGE"));return false}i=true}t=t==true;s=t===true&&s===true;if(!this.callActive&&!this.callInit&&e>0){this.initiator=true;this.callInitUserId=this.BXIM.userId;this.callInit=true;this.callActive=false;this.callUserId=i?0:e;this.callChatId=i?e:0;this.callToGroup=i;this.callGroupUsers=i?this.messenger.userInChat[e]:[];this.callVideo=t;this.callOverlayShow({toUserId:e,fromUserId:this.BXIM.userId,callToGroup:this.callToGroup,video:t,status:BX.message("IM_M_CALL_ST_CONNECT"),buttons:[{text:BX.message("IM_M_CALL_BTN_HANGUP"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){this.callSelfDisabled=true;this.callCommand(this.callChatId,"decline",{ACTIVE:this.callActive?"Y":"N",INITIATOR:this.initiator?"Y":"N"});this.callAbort();this.callOverlayClose()},this)}},{text:BX.message("IM_M_CALL_BTN_CHAT"),className:"bx-messenger-call-overlay-button-chat",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}]});this.BXIM.playSound("start");BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_INVITE&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"invite",CHAT_ID:e,CHAT:i?"Y":"N",VIDEO:t?"Y":"N",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(e.ERROR==""){this.callChatId=e.CHAT_ID;for(var t in e.USERS)this.messenger.users[t]=e.USERS[t];for(var t in e.HR_PHOTO)this.messenger.hrphoto[t]=e.HR_PHOTO[t];if(e.CALL_ENABLED&&this.callToGroup){for(var t in e.USERS_CONNECT){this.connected[t]=true}this.initiator=false;this.callInitUserId=0;this.callInit=true;this.callActive=false;this.callUserId=0;this.callChatId=e.CHAT_ID;this.callToGroup=e.CALL_TO_GROUP;this.callGroupUsers=this.messenger.userInChat[e.CHAT_ID];this.callVideo=e.CALL_VIDEO;this.callDialog();return false}this.callOverlayUpdatePhoto();var s=this.callToGroup?"chat"+this.callChatId:this.callUserId;var i=this.callToGroup;var a=this.callVideo;this.callInviteTimeout=setTimeout(BX.delegate(function(){this.callOverlayProgress("offline");this.callOverlayButtons([{text:BX.message("IM_M_CALL_BTN_RECALL"),className:"bx-messenger-call-overlay-button-recall",events:{click:BX.delegate(function(e){if(this.phoneCount(this.messenger.phones[s])>0){this.messenger.openPopupMenu(BX.proxy_context,"callPhoneMenu",true,{userId:s,video:a})}else{this.callInvite(s,a)}BX.PreventDefault(e)},this)},hide:i},{text:BX.message("IM_M_CALL_BTN_CLOSE"),className:"bx-messenger-call-overlay-button-close",events:{click:BX.delegate(function(){this.callOverlayClose()},this)}}]);this.callCommand(this.callChatId,"errorOffline");this.callAbort(BX.message(i?"IM_M_CALL_ST_NO_WEBRTC_1":"IM_M_CALL_ST_NO_WEBRTC"))},this),3e4)}else{this.callOverlayProgress("offline");this.callCommand(this.callChatId,"errorOffline");this.callOverlayButtons(this.buttonsOverlayClose);this.callAbort(e.ERROR)}},this),onfailure:BX.delegate(function(){this.callAbort(BX.message("IM_M_CALL_ERR"));this.callOverlayClose()},this)})}};BX.IM.WebRTC.prototype.callInviteExperimental=function(e,t){var s=false;if(parseInt(e)>0){if(this.messenger.users[e]&&this.messenger.users[e].status=="guest"){this.BXIM.openConfirm(BX.message("IM_CALL_USER_OFFLINE"));return false}else if(!this.messenger.users[e]){BX.MessengerCommon.getUserParam(e)}e=parseInt(e)}else{e=e.toString().substr(4);if(!this.messenger.userInChat[e]||this.messenger.userInChat[e].length<=1){return false}s=true}t=t==true;BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_EXPERIMENTAL&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"inviteExperimental",CHAT_ID:e,CHAT:s?"Y":"N",VIDEO:t?"Y":"N",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});return true};BX.IM.WebRTC.prototype.callWait=function(){if(!this.callSupport())return false;this.callOverlayStatus(BX.message(this.callToGroup?"IM_M_CALL_ST_WAIT_2":"IM_M_CALL_ST_WAIT"));clearTimeout(this.callInviteTimeout);this.callInviteTimeout=setTimeout(BX.delegate(function(){if(!this.initiator){this.callAbort();this.callOverlayClose();return false}this.callOverlayProgress("offline");var e=this.callToGroup?"chat"+this.callChatId:this.callUserId;var t=this.callVideo;var s=this.callToGroup;this.callOverlayButtons([{text:BX.message("IM_M_CALL_BTN_RECALL"),className:"bx-messenger-call-overlay-button-recall",events:{click:BX.delegate(function(s){if(this.phoneCount(this.messenger.phones[e])>0){this.messenger.openPopupMenu(BX.proxy_context,"callPhoneMenu",true,{userId:e,video:t})}else{this.callInvite(e,t)}BX.PreventDefault(s)},this)},hide:s},{text:BX.message("IM_M_CALL_BTN_CLOSE"),className:"bx-messenger-call-overlay-button-close",events:{click:BX.delegate(function(){this.callOverlayClose()},this)}}]);this.callCommand(this.callChatId,"waitTimeout");this.callAbort(BX.message(this.callToGroup?"IM_M_CALL_ST_NO_ANSWER_2":"IM_M_CALL_ST_NO_ANSWER"))},this),2e4)};BX.IM.WebRTC.prototype.callChangeMainVideo=function(e){var t=this.callOverlayVideoMain.getAttribute("data-userId");if(t==e||!this.callStreamUsers[e])return false;BX.addClass(this.callOverlayVideoMain,"bx-messenger-call-video-main-block-animation");clearTimeout(this.callChangeMainVideoTimeout);this.callChangeMainVideoTimeout=setTimeout(BX.delegate(function(){this.callOverlayVideoMain.setAttribute("data-userId",e);this.attachMediaStream(this.callOverlayVideoMain,this.callStreamUsers[e]);if(this.desktop.ready())BX.desktop.onCustomEvent("bxCallChangeMainVideo",[this.callOverlayVideoMain.src]);BX.addClass(this.callOverlayVideoUsers[e].parentNode,"bx-messenger-call-video-block-hide");BX.addClass(this.callOverlayVideoUsers[e].parentNode,"bx-messenger-call-video-hide");this.callOverlayVideoUsers[e].parentNode.setAttribute("title","");if(this.callStreamUsers[t]){this.attachMediaStream(this.callOverlayVideoUsers[t],this.callStreamUsers[t]);BX.removeClass(this.callOverlayVideoUsers[t].parentNode,"bx-messenger-call-video-hide")}this.callOverlayVideoUsers[t].parentNode.setAttribute("title",BX.message("IM_CALL_MAGNIFY"));BX.removeClass(this.callOverlayVideoUsers[t].parentNode,"bx-messenger-call-video-block-hide");BX.removeClass(this.callOverlayVideoMain,"bx-messenger-call-video-main-block-animation")},this),400)};BX.IM.WebRTC.prototype.callInviteUserToChat=function(e){if(this.callChatId<=0||this.messenger.popupChatDialogSendBlock)return false;var t="";if(e.length==0){if(this.messenger.popupChatDialog!=null)this.messenger.popupChatDialog.close();return false}if(t!=""){this.BXIM.openConfirm(t);return false}if(this.screenSharing.callInit){this.screenSharing.callDecline()}this.messenger.popupChatDialogSendBlock=true;if(this.messenger.popupChatDialog!=null)this.messenger.popupChatDialog.buttons[0].setClassName("popup-window-button-disable");BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_INVITE_USER&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:{IM_CALL:"Y",COMMAND:"invite_user",USERS:JSON.stringify(e),CHAT_ID:this.callChatId,RECIPIENT_ID:this.callUserId,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){this.messenger.popupChatDialogSendBlock=false;if(this.messenger.popupChatDialog!=null)this.messenger.popupChatDialog.buttons[0].setClassName("popup-window-button-accept");if(e.ERROR==""){this.messenger.popupChatDialogSendBlock=false;if(this.messenger.popupChatDialog!=null)this.messenger.popupChatDialog.close()}else{this.BXIM.openConfirm(e.ERROR)}},this)})};BX.IM.WebRTC.prototype.callCommand=function(e,t,s,i){if(!this.callSupport())return false;e=parseInt(e);i=i!=false;s=typeof s=="object"?s:{};if(e>0){BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_SHARED&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,async:i,data:{IM_CALL:"Y",COMMAND:t,CHAT_ID:e,RECIPIENT_ID:this.callUserId,PARAMS:JSON.stringify(s),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(){if(this.callDialogAllow)this.callDialogAllow.close()},this)})}};BX.IM.WebRTC.prototype.callDialog=function(){if(!this.callSupport()&&this.callOverlay==null)return false;clearTimeout(this.callInviteTimeout);clearTimeout(this.callDialogAllowTimeout);if(this.callDialogAllow)this.callDialogAllow.close();this.callActive=true;this.callOverlayProgress("wait");this.callOverlayStatus(BX.message("IM_M_CALL_ST_WAIT_ACCESS"));this.callOverlayButtons([{text:BX.message("IM_M_CALL_BTN_HANGUP"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){var e=this.callVideo;this.callSelfDisabled=true;this.callCommand(this.callChatId,"decline",{ACTIVE:this.callActive?"Y":"N",INITIATOR:this.initiator?"Y":"N"});this.BXIM.playSound("stop");if(e&&this.callStreamSelf!=null)this.callOverlayVideoClose();else this.callOverlayClose()},this)}},{title:BX.message("IM_M_CHAT_TITLE"),className:"bx-messenger-call-overlay-button-plus",events:{click:BX.delegate(function(e){if(this.messenger.userInChat[this.callChatId]&&this.messenger.userInChat[this.callChatId].length==4){this.BXIM.openConfirm(BX.message("IM_CALL_GROUP_MAX_USERS"));return false}this.messenger.openChatDialog({chatId:this.callChatId,type:"CALL_INVITE_USER",bind:BX.proxy_context,maxUsers:4});BX.PreventDefault(e)},this)},hide:true},{title:BX.message("IM_M_CALL_BTN_MIC_TITLE"),id:"bx-messenger-call-overlay-button-mic",className:"bx-messenger-call-overlay-button-mic "+(this.audioMuted?" bx-messenger-call-overlay-button-mic-off":""),events:{click:BX.delegate(function(){this.toggleAudio();var e=BX.findChildByClassName(BX.proxy_context,"bx-messenger-call-overlay-button-mic");if(e)BX.toggleClass(e,"bx-messenger-call-overlay-button-mic-off")},this)}},{title:BX.message("IM_M_CALL_BTN_SCREEN_TITLE"),id:"bx-messenger-call-overlay-button-screen",className:"bx-messenger-call-overlay-button-screen "+(this.screenSharing.connect?" bx-messenger-call-overlay-button-screen-off":""),events:{click:BX.delegate(function(){if(!this.desktop.enableInVersion(30)){this.BXIM.openConfirm({title:BX.message("IM_M_CALL_SCREEN"),message:BX.message("IM_M_CALL_SCREEN_ERROR")});return false}this.toggleScreenSharing()},this)}},{title:BX.message("IM_M_CALL_BTN_HISTORY_2"),className:"bx-messenger-call-overlay-button-history2",events:{click:BX.delegate(function(){this.messenger.openHistory(this.messenger.currentTab)},this)}},{title:BX.message("IM_M_CALL_BTN_CHAT_2"),className:"bx-messenger-call-overlay-button-chat2",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}]);if(this.messenger.popupMessenger==null){this.messenger.openMessenger(this.callUserId);this.callOverlayToggleSize(false)}BX.addClass(this.callOverlay,"bx-messenger-call-overlay-maxi");BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-mini");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-line");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call");if(!this.callToGroup&&this.callVideo||!this.callVideo){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call-"+(this.callVideo?"video":"audio"))}this.startGetUserMedia(this.callVideo)};BX.IM.WebRTC.prototype.toggleScreenSharing=function(){if(this.screenSharing.callInit&&this.screenSharing.initiator){this.screenSharing.callDecline()}else{this.screenSharing.callInvite()}return true};BX.IM.WebRTC.prototype.callOverlayShow=function(e){if(!e||!(e.toUserId||e.phoneNumber)||!(e.fromUserId||e.phoneNumber)||!e.buttons)return false;if(this.callOverlay!=null){this.callOverlayClose(false,true)}this.messenger.closeMenuPopup();e.video=e.video!=false;e.callToGroup=e.callToGroup==true;e.callToPhone=e.callToPhone==true;e.minimize=typeof e.minimize=="undefined"?this.messenger.popupMessenger==null:e.minimize==true;e.status=e.status?e.status:"";e.progress=e.progress?e.progress:"connect";this.callOldBeforeUnload=window.onbeforeunload;if(!e.prepare){window.onbeforeunload=function(){if(typeof BX.PULL!="undefined"&&typeof BX.PULL.tryConnectDelay=="function"){BX.PULL.tryConnectDelay()}return BX.message("IM_M_CALL_EFP")}}this.callOverlayMinimize=e.prepare?true:e.minimize;var t=null;if(this.BXIM.dialogOpen)t=this.messenger.popupMessengerBody;else if(this.BXIM.notifyOpen)t=this.messenger.popupNotifyItem;if(t){if(BX.MessengerCommon.isScrollMin(t)){setTimeout(BX.delegate(function(){BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call")},this),e.minimize?0:400)}else{BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call");t.scrollTop=t.scrollTop+50}}else{BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call")}if(!this.callOverlayMinimize)BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi");var s={width:!this.messenger.popupMessenger?"610px":(this.messenger.popupMessengerExtra.style.display=="block"?this.messenger.popupMessengerExtra.offsetWidth+1:this.messenger.popupMessengerDialog.offsetWidth+1)+"px",height:this.messenger.popupMessengerFullHeight+2+"px",marginLeft:this.messenger.popupContactListSize+"px"};if(this.messenger.popupMessenger==null){s["marginTop"]="-1px"}if(e.phoneNumber){var i=this.callPhoneOverlayShow(e)}else{var i=e.callToGroup?this.callGroupOverlayShow(e):this.callUserOverlayShow(e)}this.callOverlay=BX.create("div",{props:{className:"bx-messenger-call-overlay "+(e.callToGroup?" bx-messenger-call-overlay-group ":"")+(this.callOverlayMinimize?"bx-messenger-call-overlay-mini":"bx-messenger-call-overlay-maxi")},style:s,children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-lvl-1"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-lvl-2"},children:[BX.create("div",{props:{className:"bx-messenger-call-video-main"},children:[BX.create("div",{props:{className:"bx-messenger-call-video-main-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-call-video-main-watermark"},children:[BX.create("img",{props:{className:"bx-messenger-call-video-main-watermark-img"},attrs:{src:"/bitrix/js/im/images/watermark_"+(this.BXIM.language=="ru"?"ru":"en")+".png"}})]}),BX.create("div",{props:{className:"bx-messenger-call-video-main-cell"},children:[BX.create("div",{props:{className:"bx-messenger-call-video-main-bg"},children:[this.callOverlayVideoMain=BX.create("video",{attrs:{autoplay:true},props:{className:"bx-messenger-call-video-main-block"}}),this.callOverlayVideoReserve=BX.create("video",{attrs:{autoplay:true},props:{className:"bx-messenger-hide"}})]})]})]})]})]})]}),this.callOverlayBody=BX.create("div",{props:{className:"bx-messenger-call-overlay-body"},children:i})]});if(e.prepare){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-float");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-show")}else if(this.messenger.popupMessenger!=null){this.messenger.setClosingByEsc(false);BX.addClass(BX("bx-messenger-popup-messenger"),"bx-messenger-popup-messenger-dont-close");this.messenger.popupMessengerContent.insertBefore(this.callOverlay,this.messenger.popupMessengerContent.firstChild)}else if(this.callNotify!=null){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-float");this.callNotify.setContent(this.callOverlay)}else{this.callNotify=new BX.PopupWindow("bx-messenger-call-notify",null,{lightShadow:true,zIndex:200,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){BX.unbind(window,"scroll",this.popupCallNotifyEvent);this.callNotify=null},this)},content:this.callOverlay});this.callNotify.show();BX.addClass(this.callOverlay,"bx-messenger-call-overlay-float");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-show");BX.addClass(this.callNotify.popupContainer.children[0],"bx-messenger-popup-window-transparent");setTimeout(BX.delegate(function(){if(this.callNotify){this.callNotify.adjustPosition()}},this),500);BX.bind(window,"scroll",this.popupCallNotifyEvent=BX.proxy(function(){this.callNotify.adjustPosition()},this))}setTimeout(BX.delegate(function(){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-show")},this),100);this.callOverlayStatus(e.status);this.callOverlayButtons(e.buttons);this.callOverlayProgress(e.progress);return true};BX.IM.WebRTC.prototype.callGroupOverlayShow=function(e){this.callOverlayOptions=e;var t=e.fromUserId!=this.BXIM.userId;var s=e.fromUserId!=this.BXIM.userId?e.fromUserId:e.toUserId;var i=this.callOverlayTitle();this.callOverlayChatId=s;var a=[];var n=[];for(var r=0;r<this.messenger.userInChat[s].length;r++){var o=this.messenger.userInChat[s][r];var l=BX.MessengerCommon.getHrPhoto(o,this.messenger.users[o].color);a.push(BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-left"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-block"},children:[this.callOverlayPhotoUsers[o]=BX.create("img",{props:{className:"bx-messenger-call-overlay-photo-img"},attrs:{"data-userId":o,src:l.src,style:l.color?"background-color: "+l.color:""}})]})]}));if(o==this.BXIM.userId)continue;var l=BX.MessengerCommon.getHrPhoto(o,this.messenger.users[o].color);n.push(BX.create("div",{props:{className:"bx-messenger-call-video-mini bx-messenger-call-video-hide"},attrs:{"data-userId":o},events:{click:BX.delegate(function(){this.callChangeMainVideo(BX.proxy_context.getAttribute("data-userId"))},this)},children:[this.callOverlayVideoUsers[o]=BX.create("video",{attrs:{autoplay:true},props:{className:"bx-messenger-call-video-mini-block"}}),BX.create("div",{props:{className:"bx-messenger-call-video-mini-photo"},children:[this.callOverlayVideoPhotoUsers[o]=BX.create("img",{props:{className:"bx-messenger-call-video-mini-photo-img"},attrs:{src:l.src,style:l.color?"background-color: "+l.color:""}})]})]}))}var l=BX.MessengerCommon.getHrPhoto(this.BXIM.userId,this.messenger.users[this.BXIM.userId].color);return[BX.create("div",{props:{className:"bx-messenger-call-overlay-line-maxi"},attrs:{title:BX.message("IM_M_CALL_BTN_RETURN")},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-line-maxi-block"}})]}),BX.create("div",{props:{className:"bx-messenger-call-video-users"},children:n}),BX.create("div",{props:{className:"bx-messenger-call-overlay-title"},children:[this.callOverlayTitleBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-title-block"},html:i})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-photo"},children:a}),BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-progress-group"},children:[this.callOverlayProgressBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-progress"}})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-status"},children:[this.callOverlayStatusBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-status-block"}})]}),BX.create("div",{props:{className:"bx-messenger-call-video-mini"},children:[this.callOverlayVideoSelf=BX.create("video",{attrs:{autoplay:true},props:{className:"bx-messenger-call-video-mini-block"}}),BX.create("div",{props:{className:"bx-messenger-call-video-mini-photo"},children:[this.callOverlayPhotoMini=BX.create("img",{props:{className:"bx-messenger-call-video-mini-photo-img"},attrs:{src:l.src,style:l.color?"background-color: "+l.color:""}})]})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-buttons"},children:[this.callOverlayButtonsBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-buttons-block"}})]})]};BX.IM.WebRTC.prototype.callUserOverlayShow=function(e){this.callOverlayOptions=e;var t=e.toUserId==this.BXIM.userId;var s=t?e.fromUserId:e.toUserId;var i=this.callOverlayTitle();this.callOverlayUserId=s;var a=BX.MessengerCommon.getHrPhoto(s,this.messenger.users[s].color);var n=BX.MessengerCommon.getHrPhoto(this.BXIM.userId,this.messenger.users[this.BXIM.userId].color);return[BX.create("div",{props:{className:"bx-messenger-call-overlay-line-maxi"},attrs:{title:BX.message("IM_M_CALL_BTN_RETURN")},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-line-maxi-block"}})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-title"},children:[this.callOverlayTitleBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-title-block"},html:i})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-photo"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-left"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-block"
},children:[this.callOverlayPhotoCompanion=BX.create("img",{props:{className:"bx-messenger-call-overlay-photo-img"},attrs:{"data-userId":s,src:a.src,style:a.color?"background-color: "+a.color:""}})]})]}),this.callOverlayProgressBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-progress"+(t?"":" bx-messenger-call-overlay-photo-progress-incoming")}}),BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-right"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-block"},children:[this.callOverlayPhotoSelf=BX.create("img",{props:{className:"bx-messenger-call-overlay-photo-img"},attrs:{"data-userId":this.BXIM.userId,src:n.src,style:n.color?"background-color: "+n.color:""}})]})]})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-status"},children:[this.callOverlayStatusBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-status-block"}})]}),BX.create("div",{props:{className:"bx-messenger-call-video-mini"},children:[this.callOverlayVideoSelf=BX.create("video",{attrs:{autoplay:true},props:{className:"bx-messenger-call-video-mini-block"}}),BX.create("div",{props:{className:"bx-messenger-call-video-mini-photo"},children:[this.callOverlayPhotoMini=BX.create("img",{props:{className:"bx-messenger-call-video-mini-photo-img"},attrs:{src:n.src,style:n.color?"background-color: "+n.color:""}})]})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-buttons"},children:[this.callOverlayButtonsBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-buttons-block"}})]})]};BX.IM.WebRTC.prototype.callPhoneOverlayShow=function(e){this.callOverlayOptions=e;var t=e.toUserId==this.BXIM.userId;var s=t?e.fromUserId:e.toUserId;this.callToPhone=true;var i="";if(e.phoneNumber=="hidden"){i=BX.message("IM_PHONE_HIDDEN_NUMBER")}else{if(e.callTitle){i=e.callTitle.toString()}else{i=e.phoneNumber.toString()}if(i.substr(0,1)=="8"||i.substr(0,1)=="+"){}else if(!isNaN(parseInt(i))&&i.length>=10){i="+"+i}}if(this.phoneTransferEnabled){i=BX.message("IM_PHONE_CALL_TRANSFER").replace("#PHONE#",i)}else if(e.isCallback){i=BX.message("IM_PHONE_CALLBACK_TO").replace("#PHONE#",i)}else{i=BX.message(t?"IM_PHONE_CALL_VOICE_FROM":"IM_PHONE_CALL_VOICE_TO").replace("#PHONE#",i)}var a=!e.isCallback&&t&&e.companyPhoneNumber?'<span class="bx-messenger-call-overlay-title-company-phone">'+BX.message("IM_PHONE_CALL_TO_PHONE").replace("#PHONE#",e.companyPhoneNumber)+"</span>":"";this.callOverlayUserId=s;BX.MessengerCommon.getUserParam(this.messenger.currentTab);BX.MessengerCommon.getUserParam(this.BXIM.userId);this.messenger.openChatFlag=this.messenger.currentTab.toString().substr(0,4)=="chat";var n=BX.MessengerCommon.getHrPhoto("phone",this.messenger.openChatFlag?this.messenger.chat[this.messenger.currentTab.toString().substr(4)].color:this.messenger.users[this.messenger.currentTab].color);var r=BX.MessengerCommon.getHrPhoto(this.BXIM.userId,this.messenger.users[this.BXIM.userId].color);return[this.callOverlayMeterGrade=BX.create("div",{attrs:{title:BX.message("IM_PHONE_GRADE")+" "+BX.message("IM_PHONE_GRADE_4")},props:{className:"bx-messenger-call-overlay-meter bx-messenger-call-overlay-meter-grade-5"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-meter-grade"}}),this.callOverlayMeterPercent=BX.create("div",{props:{className:"bx-messenger-call-overlay-meter-percent"},html:100})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-line-maxi"},attrs:{title:BX.message("IM_M_CALL_BTN_RETURN")},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-line-maxi-block"}})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-title"},children:[this.callOverlayTitleBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-title-block"},html:i+a})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-photo"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-left"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-block"},children:[this.callOverlayPhotoCompanion=BX.create("img",{props:{className:"bx-messenger-call-overlay-photo-img"},attrs:{"data-userId":"phone",src:n.src,style:n.color?"background-color: "+n.color:""}})]})]}),this.callOverlayProgressBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-progress"+(t?"":" bx-messenger-call-overlay-photo-progress-incoming")}}),BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-right"},children:[BX.create("div",{props:{className:"bx-messenger-call-overlay-photo-block"},children:[this.callOverlayPhotoSelf=BX.create("img",{props:{className:"bx-messenger-call-overlay-photo-img"},attrs:{"data-userId":this.BXIM.userId,src:r.src,style:r.color?"background-color: "+r.color:""}})]})]})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-crm-block"},children:[this.callOverlayCrmBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-crm-block-wrap"}})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-status"},children:[this.callOverlayStatusBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-status-block"}})]}),BX.create("div",{props:{className:"bx-messenger-call-video-mini"},children:[this.callOverlayVideoSelf=BX.create("video",{attrs:{autoplay:true},props:{className:"bx-messenger-call-video-mini-block"}}),BX.create("div",{props:{className:"bx-messenger-call-video-mini-photo"},children:[this.callOverlayPhotoMini=BX.create("img",{props:{className:"bx-messenger-call-video-mini-photo-img"},attrs:{src:r.src,style:r.color?"background-color: "+r.color:""}})]})]}),BX.create("div",{props:{className:"bx-messenger-call-overlay-buttons"},children:[this.callOverlayButtonsBlock=BX.create("div",{props:{className:"bx-messenger-call-overlay-buttons-block"}})]})]};BX.IM.WebRTC.prototype.callPhoneOverlayMeter=function(e){if(!this.phoneCurrentCall||this.phoneCurrentCall.state()!="CONNECTED")return false;var t=5;if(100==e){t=5}else if(e>=99){t=4}else if(e>=97){t=3}else if(e>=95){t=2}else{t=1}var s=BX.message("IM_PHONE_GRADE_4");if(t==4)s=BX.message("IM_PHONE_GRADE_3");else if(t==3||t==2)s=BX.message("IM_PHONE_GRADE_2");else if(t==1)s=BX.message("IM_PHONE_GRADE_1");this.callOverlayMeterGrade.className="bx-messenger-call-overlay-meter bx-messenger-call-overlay-meter-grade-"+t;this.callOverlayMeterGrade.setAttribute("title",BX.message("IM_PHONE_GRADE")+" "+s);this.callOverlayMeterPercent.innerHTML=e;return t};BX.IM.WebRTC.prototype.callGroupOverlayRedraw=function(){this.callToGroup=true;this.callGroupUsers=this.messenger.userInChat[this.callChatId];this.callOverlayUserId=0;this.callOverlayChatId=this.callChatId;this.callOverlayBody.innerHTML="";this.callOverlayOptions["callToGroup"]=this.callToGroup;this.callOverlayOptions["fromUserId"]=this.callChatId;BX.addClass(this.callOverlay,"bx-messenger-call-overlay-group");BX.adjust(this.callOverlayBody,{children:this.callGroupOverlayShow(this.callOverlayOptions)});this.callOverlayStatus(this.callOverlayOptions.status);this.callOverlayButtons(this.callOverlayOptions.buttons);this.callOverlayProgress(this.callOverlayOptions.progress);BX("bx-messenger-call-overlay-button-plus").style.display="inline-block";this.attachMediaStream(this.callOverlayVideoSelf,this.callStreamSelf);this.callOverlayVideoSelf.muted=true;if(this.messenger.currentTab!="chat"+this.callChatId){this.messenger.openMessenger("chat"+this.callChatId);this.callOverlayToggleSize(false)}var e=this.callOverlayVideoMain.getAttribute("data-userId");for(var t in this.callStreamUsers){if(!this.callStreamUsers[t]&&e==t)continue;this.attachMediaStream(this.callOverlayVideoUsers[t],this.callStreamUsers[t]);BX.removeClass(this.callOverlayVideoUsers[t].parentNode,"bx-messenger-call-video-hide")}BX.addClass(this.callOverlayVideoUsers[e].parentNode,"bx-messenger-call-video-block-hide");BX.addClass(this.callOverlayVideoUsers[e].parentNode,"bx-messenger-call-video-hide");this.callOverlayVideoUsers[e].parentNode.setAttribute("title","");return true};BX.IM.WebRTC.prototype.callOverlayToggleSize=function(e){if(this.callOverlay==null)return false;if(!this.ready()){this.callOverlayClose(true);return false}var t=typeof e=="boolean"?!e:this.callOverlayMinimize;var s=false;if(this.messenger.popupMessenger!=null&&!this.BXIM.dialogOpen)s=true;else if(this.messenger.popupMessenger!=null&&this.callOverlayUserId>0&&this.callOverlayUserId!=this.messenger.currentTab)s=true;else if(this.messenger.popupMessenger!=null&&this.callOverlayChatId>0&&this.callOverlayChatId!=this.messenger.currentTab.toString().substr(4))s=true;else if(this.messenger.popupMessenger!=null&&this.callOverlayUserId==0&&this.callOverlayChatId==0&&this.phoneNumber)s=true;if(t&&this.callActive)BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call");else BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-call");BX.unbindAll(this.callOverlay);if(t){this.callOverlayMinimize=false;BX.addClass(this.callOverlay,"bx-messenger-call-overlay-maxi");BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-line");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-mini")}else{this.callOverlayMinimize=true;BX.addClass(this.callOverlay,"bx-messenger-call-overlay-mini");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-maxi");BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi");if(s){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-line");setTimeout(BX.delegate(function(){BX.bind(this.callOverlay,"click",BX.delegate(function(){if(this.BXIM.dialogOpen){if(this.callOverlayUserId>0){this.messenger.openChatFlag=false;BX.MessengerCommon.openDialog(this.callOverlayUserId,false,false)}else{this.messenger.openChatFlag=true;BX.MessengerCommon.openDialog("chat"+this.callOverlayChatId,false,false)}}else{if(this.callOverlayUserId>0){this.messenger.openChatFlag=false;this.messenger.currentTab=this.callOverlayUserId}else{this.messenger.openChatFlag=true;this.messenger.currentTab="chat"+this.callOverlayChatId}this.messenger.extraClose(true,false)}this.callOverlayToggleSize(false)},this))},this),200)}else{BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-line")}if(this.BXIM.isFocus())BX.MessengerCommon.readMessage(this.messenger.currentTab);if(this.BXIM.isFocus()&&this.notify.notifyUpdateCount>0)this.notify.viewNotifyAll()}if(this.callOverlayUserId>0&&this.callOverlayUserId==this.messenger.currentTab){this.desktop.closeTopmostWindow()}else if(this.callOverlayChatId>0&&this.callOverlayChatId==this.messenger.currentTab.toString().substr(4)){this.desktop.closeTopmostWindow()}else{this.desktop.openCallFloatDialog()}if(this.callDialogAllow!=null){if(this.callDialogAllow)this.callDialogAllow.close();setTimeout(BX.delegate(function(){this.callDialogAllowShow()},this),1500)}if(this.popupTransferDialog)this.popupTransferDialog.close()};BX.IM.WebRTC.prototype.callOverlayClose=function(e,t){if(this.callOverlay==null)return false;this.audioMuted=true;this.toggleAudio(false);t=t==true;if(!t&&this.callOverlayFullScreen){if(this.detectedBrowser=="firefox"){BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-fullscreen");BX.remove(this.messenger.popupMessengerContent);BX.hide(this.messenger.popupMessenger.popupContainer);setTimeout(BX.delegate(function(){this.messenger.popupMessenger.destroy();this.messenger.openMessenger(this.messenger.currentTab)},this),200)}}if(this.messenger.popupMessenger!=null){var s=null;if(this.BXIM.dialogOpen)s=this.messenger.popupMessengerBody;else if(this.BXIM.notifyOpen)s=this.messenger.popupNotifyItem;if(s){if(BX.MessengerCommon.isScrollMax(s)){BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-call")}else{BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-call");s.scrollTop=s.scrollTop-50}}else{BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-call")}BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi")}this.messenger.closeMenuPopup();e=e!=false;if(e)BX.addClass(this.callOverlay,"bx-messenger-call-overlay-hide");if(e){setTimeout(BX.delegate(function(){BX.remove(this.callOverlay);this.callOverlay=null;this.callOverlayButtonsBlock=null;this.callOverlayTitleBlock=null;this.callOverlayMeter=null;this.callOverlayStatusBlock=null;this.callOverlayProgressBlock=null;this.callOverlayMinimize=null;this.callOverlayChatId=0;this.callOverlayUserId=0;this.callOverlayPhotoSelf=null;this.callOverlayPhotoUsers={};this.callOverlayVideoUsers={};this.callOverlayVideoPhotoUsers={};this.callOverlayOptions={};this.callOverlayPhotoCompanion=null;this.callSelfDisabled=false;if(this.BXIM.isFocus())BX.MessengerCommon.readMessage(this.messenger.currentTab)},this),300)}else{BX.remove(this.callOverlay);this.callOverlay=null;this.callOverlayButtonsBlock=null;this.callOverlayStatusBlock=null;this.callOverlayProgressBlock=null;this.callOverlayMinimize=null;this.callOverlayChatId=0;this.callOverlayUserId=0;this.callOverlayPhotoSelf=null;this.callOverlayPhotoUsers={};this.callOverlayVideoUsers={};this.callOverlayVideoPhotoUsers={};this.callOverlayOptions={};this.callOverlayPhotoCompanion=null;this.callSelfDisabled=false;if(this.BXIM.isFocus())BX.MessengerCommon.readMessage(this.messenger.currentTab)}if(t){window.onbeforeunload=this.callOldBeforeUnload;this.BXIM.stopRepeatSound("ringtone");this.BXIM.stopRepeatSound("dialtone")}else{this.callOverlayDeleteEvents()}this.desktop.closeTopmostWindow()};BX.IM.WebRTC.prototype.callOverlayVideoClose=function(){this.audioMuted=true;this.toggleAudio(false);BX.style(this.callOverlayVideoMain,"height",this.callOverlayVideoMain.parentNode.offsetHeight+"px");BX.addClass(this.callOverlayVideoMain.parentNode,"bx-messenger-call-video-main-bg-start");setTimeout(BX.delegate(function(){this.callOverlayClose()},this),1700)};BX.IM.WebRTC.prototype.callAbort=function(e){this.callOverlayDeleteEvents();if(e)this.callOverlayStatus(e)};BX.IM.WebRTC.prototype.callOverlayDeleteEvents=function(e){e=e||{};this.desktop.closeTopmostWindow();window.onbeforeunload=this.callOldBeforeUnload;var t=e.closeNotify!==false;if(t&&this.callNotify)this.callNotify.destroy();var s=null;if(this.phoneCallId){s=this.phoneCallId}else if(this.callToGroup){s="chat"+this.callChatId}else{s="user"+this.callUserId}BX.onCustomEvent(window,"onImCallEnd",{CALL_ID:s});clearInterval(this.callAspectCheckInterval);if(this.desktop.ready()&&this.BXIM.init){BX.desktop.syncPause(false)}this.deleteEvents();this.callToMobile=false;this.callToPhone=false;BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-call-audio");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-call-video");if(this.messenger.popupMessenger){this.messenger.popupMessenger.setClosingByEsc(true);BX.removeClass(BX("bx-messenger-popup-messenger"),"bx-messenger-popup-messenger-dont-close");this.messenger.dialogStatusRedraw()}this.phoneCallFinish();clearTimeout(this.callDialtoneTimeout);this.BXIM.stopRepeatSound("ringtone");this.BXIM.stopRepeatSound("dialtone");clearTimeout(this.callInviteTimeout);clearTimeout(this.callDialogAllowTimeout);if(this.callDialogAllow)this.callDialogAllow.close()};BX.IM.WebRTC.prototype.callOverlayProgress=function(e){if(this.callOverlay==null)return false;if(e!=this.callOverlayOptions.progress){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-status-"+e);BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-status-"+this.callOverlayOptions.progress)}this.callOverlayOptions.progress=e;this.callOverlayProgressBlock.innerHTML="";if(e=="connect"){this.callOverlayProgressBlock.appendChild(BX.create("div",{props:{className:"bx-messenger-call-overlay-progress"},children:[BX.create("img",{props:{className:"bx-messenger-call-overlay-progress-status bx-messenger-call-overlay-progress-status-anim-1"}}),BX.create("img",{props:{className:"bx-messenger-call-overlay-progress-status bx-messenger-call-overlay-progress-status-anim-2"}})]}))}else if(e=="online"){this.callOverlayProgressBlock.appendChild(BX.create("div",{props:{className:"bx-messenger-call-overlay-progress bx-messenger-call-overlay-progress-online"},children:[BX.create("img",{props:{className:"bx-messenger-call-overlay-progress-status bx-messenger-call-overlay-progress-status-anim-3"}})]}))}else if(e=="wait"||e=="offline"||e=="error"){if(e=="offline"){BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-online");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-call");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-call-active");this.BXIM.playSound("error")}else if(e=="error"){e="offline"}this.callOverlayProgressBlock.appendChild(BX.create("div",{props:{className:"bx-messenger-call-overlay-progress bx-messenger-call-overlay-progress-"+e}}))}else{this.callOverlayOptions.progress="";BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-status-"+e);return false}};BX.IM.WebRTC.prototype.callOverlayStatus=function(e){if(this.callOverlay==null||typeof e=="undefined")return false;this.callOverlayOptions.status=e;this.callOverlayStatusBlock.innerHTML=e.toString()};BX.IM.WebRTC.prototype.callOverlayTitle=function(){var e="";var t=this.callInitUserId!=this.BXIM.userId;if(this.callToPhone){e=this.callOverlayTitleBlock.innerHTML}else if(this.callToGroup){e=this.messenger.chat[this.callChatId].name;if(e.length>85)e=e.substr(0,85)+"...";e=BX.message("IM_CALL_GROUP_"+(this.callVideo?"VIDEO":"VOICE")+(t?"_FROM":"_TO")).replace("#CHAT#",e)}else{e=BX.message("IM_M_CALL_"+(this.callVideo?"VIDEO":"VOICE")+(t?"_FROM":"_TO")).replace("#USER#",this.messenger.users[this.callUserId].name)}return e};BX.IM.WebRTC.prototype.setCallOverlayTitle=function(e){if(this.callOverlayTitleBlock){this.callOverlayTitleBlock.innerHTML=e}};BX.IM.WebRTC.prototype.callOverlayUpdatePhoto=function(){this.callOverlayTitleBlock.innerHTML=this.callOverlayTitle();for(var e in this.callOverlayPhotoUsers){if(e=="phone"){this.callOverlayPhotoUsers[e].src="/bitrix/js/im/images/hidef-phone-v3.png"}else if(this.messenger.hrphoto[e]){this.callOverlayPhotoUsers[e].src=this.messenger.hrphoto[e];if(this.messenger.hrphoto[e]!="/bitrix/js/im/images/hidef-avatar-v3.png"){this.callOverlayPhotoUsers[e].type=""}}else if(this.messenger.users[e].avatar==this.BXIM.pathToBlankImage){this.callOverlayPhotoUsers[e].src="/bitrix/js/im/images/hidef-avatar-v3.png"}else{this.callOverlayPhotoUsers[e].src=this.messenger.users[e].avatar;this.callOverlayPhotoUsers[e].type=""}}for(var e in this.callOverlayVideoPhotoUsers){if(e=="phone"){this.callOverlayVideoPhotoUsers[e].src="/bitrix/js/im/images/hidef-phone-v3.png"}else if(this.messenger.hrphoto[e]){this.callOverlayVideoPhotoUsers[e].src=this.messenger.hrphoto[e];if(this.messenger.hrphoto[e]!="/bitrix/js/im/images/hidef-avatar-v3.png"){this.callOverlayVideoPhotoUsers[e].type=""}}else if(this.messenger.users[e].avatar==this.BXIM.pathToBlankImage){this.callOverlayVideoPhotoUsers[e].src="/bitrix/js/im/images/hidef-avatar-v3.png"}else{this.callOverlayVideoPhotoUsers[e].src=this.messenger.users[e].avatar;this.callOverlayVideoPhotoUsers[e].type="background-color: "+colorId}}if(this.callOverlayPhotoCompanion){var t=this.callOverlayPhotoCompanion.getAttribute("data-userId");if(t=="phone"){this.callOverlayPhotoCompanion.src="/bitrix/js/im/images/hidef-phone-v3.png"}else if(this.messenger.hrphoto[t]){this.callOverlayPhotoCompanion.src=this.messenger.hrphoto[t];if(this.messenger.hrphoto[t]!="/bitrix/js/im/images/hidef-avatar-v3.png"){this.callOverlayPhotoCompanion.type=""}}else if(this.messenger.users[t]&&this.messenger.users[t].avatar==this.BXIM.pathToBlankImage){this.callOverlayPhotoCompanion.src="/bitrix/js/im/images/hidef-avatar-v3.png"}else if(this.messenger.users[t]){this.callOverlayPhotoCompanion.src=this.messenger.users[t].avatar;this.callOverlayPhotoCompanion.type=""}}if(this.callOverlayPhotoSelf){var s=BX.MessengerCommon.getHrPhoto(this.BXIM.userId,this.messenger.users[this.BXIM.userId].color);this.callOverlayPhotoSelf.src=s.src;this.callOverlayPhotoSelf.type=s.color?"background-color: "+s.color:"";this.callOverlayPhotoMini.src=this.callOverlayPhotoSelf.src}};BX.IM.WebRTC.prototype.callOverlayTimer=function(e){tate=typeof e=="undefined"?"start":e;if(e=="start"){this.phoneCallTimeInterval=setInterval(BX.delegate(function(){this.phoneCallTime++},this),1e3)}else if(e=="pause"){clearInterval(this.phoneCallTimeInterval)}else{clearInterval(this.phoneCallTimeInterval)}};BX.IM.WebRTC.prototype.callOverlayDrawCrm=function(){if(!this.callOverlayCrmBlock||!this.phoneCrm.FOUND)return false;this.callOverlayCrmBlock.innerHTML="";if(this.phoneCrm.FOUND=="Y"){BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-mini");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-maxi");BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-crm");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-crm-short");var e=this.phoneCrm.CONTACT&&this.phoneCrm.CONTACT.NAME?this.phoneCrm.CONTACT.NAME:"";if(this.phoneCrm.ACTIVITY_URL){e='<a href="'+this.phoneCrm.SHOW_URL+'" target="_blank" class="bx-messenger-call-crm-about-link">'+e+"</a>"}var t=BX.create("div",{props:{className:"bx-messenger-call-crm-about"},children:[BX.create("div",{props:{className:"bx-messenger-call-crm-about-block bx-messenger-call-crm-about-contact"},children:[BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-header"},html:BX.message("IM_CRM_ABOUT_CONTACT")}),BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-avatar"},html:this.phoneCrm.CONTACT&&this.phoneCrm.CONTACT.PHOTO?'<img src="'+this.phoneCrm.CONTACT.PHOTO+'" class="bx-messenger-call-crm-about-block-avatar-img">':""}),BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-line-1"},html:e}),BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-line-2"},html:this.phoneCrm.CONTACT&&this.phoneCrm.CONTACT.POST?this.phoneCrm.CONTACT.POST:""})]}),this.phoneCrm.COMPANY?BX.create("div",{props:{className:"bx-messenger-call-crm-about-block bx-messenger-call-crm-about-company"},children:[BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-header"},html:BX.message("IM_CRM_ABOUT_COMPANY")}),BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-line-1"},html:this.phoneCrm.COMPANY})]}):null]});var s=BX.create("div",{props:{className:"bx-messenger-call-crm-about"},children:[BX.create("div",{props:{className:"bx-messenger-call-crm-about-block bx-messenger-call-crm-about-contact"},children:this.phoneCrm.RESPONSIBILITY&&this.phoneCrm.RESPONSIBILITY.NAME?[BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-header"},html:BX.message("IM_CRM_RESPONSIBILITY")}),BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-avatar"},html:this.phoneCrm.RESPONSIBILITY.PHOTO?'<img src="'+this.phoneCrm.RESPONSIBILITY.PHOTO+'" class="bx-messenger-call-crm-about-block-avatar-img">':""}),BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-line-1"},html:this.phoneCrm.RESPONSIBILITY.NAME?this.phoneCrm.RESPONSIBILITY.NAME:""}),BX.create("div",{props:{className:"bx-messenger-call-crm-about-block-line-2"},html:this.phoneCrm.RESPONSIBILITY.POST?this.phoneCrm.RESPONSIBILITY.POST:""})]:[]})]});var i=null;if(this.phoneCrm.ACTIVITY_URL||this.phoneCrm.INVOICE_URL||this.phoneCrm.DEAL_URL){i=BX.create("div",{props:{className:"bx-messenger-call-crm-buttons"},children:[this.phoneCrm.ACTIVITY_URL?BX.create("a",{attrs:{target:"_blank",href:this.phoneCrm.ACTIVITY_URL},props:{className:"bx-messenger-call-crm-button"},html:BX.message("IM_CRM_BTN_ACTIVITY")}):null,this.phoneCrm.DEAL_URL?BX.create("a",{attrs:{target:"_blank",href:this.phoneCrm.DEAL_URL},props:{className:"bx-messenger-call-crm-button"},html:BX.message("IM_CRM_BTN_DEAL")}):null,this.phoneCrm.INVOICE_URL?BX.create("a",{attrs:{target:"_blank",href:this.phoneCrm.INVOICE_URL},props:{className:"bx-messenger-call-crm-button"},html:BX.message("IM_CRM_BTN_INVOICE")}):null,this.phoneCrm.CURRENT_CALL_URL?BX.create("a",{attrs:{target:"_blank",href:this.phoneCrm.CURRENT_CALL_URL},props:{className:"bx-messenger-call-crm-link"},html:"+ "+BX.message("IM_CRM_BTN_CURRENT_CALL")}):null]})}var a=null;if(this.phoneCrm.ACTIVITIES&&this.phoneCrm.ACTIVITIES.length>0){crmArActivities=[];for(var n=0;n<this.phoneCrm.ACTIVITIES.length;n++){crmArActivities.push(BX.create("div",{props:{className:"bx-messenger-call-crm-activities-item"},children:[BX.create("a",{attrs:{target:"_blank",href:this.phoneCrm.ACTIVITIES[n].URL},props:{className:"bx-messenger-call-crm-activities-name"},html:this.phoneCrm.ACTIVITIES[n].TITLE}),BX.create("div",{props:{className:"bx-messenger-call-crm-activities-status"},html:(this.phoneCrm.ACTIVITIES[n].OVERDUE=="Y"?'<span class="bx-messenger-call-crm-activities-dot"></span>':"")+this.phoneCrm.ACTIVITIES[n].DATE})]}))}a=BX.create("div",{props:{className:"bx-messenger-call-crm-activities"},children:[BX.create("div",{props:{className:"bx-messenger-call-crm-activities-header"},html:BX.message("IM_CRM_ACTIVITIES")}),BX.create("div",{props:{className:"bx-messenger-call-crm-activities-items"},children:crmArActivities})]})}var r=null;if(this.phoneCrm.DEALS&&this.phoneCrm.DEALS.length>0){crmArDeals=[];for(var n=0;n<this.phoneCrm.DEALS.length;n++){crmArDeals.push(BX.create("div",{props:{className:"bx-messenger-call-crm-deals-item"},children:[BX.create("a",{attrs:{target:"_blank",href:this.phoneCrm.DEALS[n].URL},props:{className:"bx-messenger-call-crm-deals-name"},html:this.phoneCrm.DEALS[n].TITLE}),BX.create("div",{props:{className:"bx-messenger-call-crm-deals-status"},html:this.phoneCrm.DEALS[n].STAGE})]}))}r=BX.create("div",{props:{className:"bx-messenger-call-crm-deals"},children:[BX.create("div",{props:{className:"bx-messenger-call-crm-deals-header"},html:BX.message("IM_CRM_DEALS")}),BX.create("div",{props:{className:"bx-messenger-call-crm-deals-items"},children:crmArDeals})]})}var o=[];if(a&&r){o=[BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),t,a,r,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),i]}else{if(a||r){o=[BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),t,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),s,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),a?a:r,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),i]}else if(!a&&!r&&i){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-crm-short");this.callOverlayCrmBlock.innerHTML="";o=[BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),t,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),s,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),i]}else{BX.addClass(this.callOverlay,"bx-messenger-call-overlay-crm-short");this.callOverlayCrmBlock.innerHTML="";o=[BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),t,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),s]}}}else if(this.phoneCrm.LEAD_URL||this.phoneCrm.CONTACT_URL){BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-mini");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-maxi");BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-crm");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-crm-short");o=[BX.create("div",{props:{className:"bx-messenger-call-crm-phone-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-phone-icon"},children:[BX.create("div",{props:{className:"bx-messenger-call-crm-phone-icon-block"}})]}),BX.create("div",{props:{className:"bx-messenger-call-crm-phone-space"}}),BX.create("div",{props:{className:"bx-messenger-call-crm-buttons bx-messenger-call-crm-buttons-center"},children:[this.phoneCrm.CONTACT_URL?BX.create("a",{attrs:{target:"_blank",href:this.phoneCrm.CONTACT_URL},props:{className:"bx-messenger-call-crm-button"},html:BX.message("IM_CRM_BTN_NEW_CONTACT")}):null,this.phoneCrm.LEAD_URL?BX.create("a",{attrs:{target:"_blank",href:this.phoneCrm.LEAD_URL},props:{className:"bx-messenger-call-crm-button"},html:BX.message("IM_CRM_BTN_NEW_LEAD")}):null]})]}BX.adjust(this.callOverlayCrmBlock,{children:o})};BX.IM.WebRTC.prototype.callOverlayButtons=function(e){if(this.callOverlay==null)return false;this.callOverlayOptions.buttons=e;BX.cleanNode(this.callOverlayButtonsBlock);for(var t=0;t<e.length;t++){if(e[t]==null)continue;var s={};s.title=e[t].title||"";s.text=e[t].text||"";s.subtext=e[t].subtext||"";s.className=e[t].className||"";s.id=e[t].id||s.className;s.events=e[t].events||{};s.style={};var i="";if(typeof e[t].showInMinimize=="boolean")i=" bx-messenger-call-overlay-button-show-"+(e[t].showInMinimize?"mini":"maxi");else if(typeof e[t].showInMaximize=="boolean")i=" bx-messenger-call-overlay-button-show-"+(e[t].showInMaximize?"maxi":"mini");else if(typeof e[t].disabled=="boolean"&&e[t].disabled)i=" bx-messenger-call-overlay-button-disabled";if(typeof e[t].hide=="boolean"&&e[t].hide)s.style.display="none";this.callOverlayButtonsBlock.appendChild(BX.create("div",{attrs:{id:s.id,title:s.title},style:s.style,props:{className:"bx-messenger-call-overlay-button"+(s.subtext?" bx-messenger-call-overlay-button-sub":"")+i},events:s.events,html:'<span class="'+s.className+'"></span><span class="bx-messenger-call-overlay-button-text">'+s.text+(s.subtext?'<div class="bx-messenger-call-overlay-button-text-sub">'+s.subtext+"</div>":"")+"</span>"}))}};BX.IM.WebRTC.prototype.callDialogAllowShow=function(e){if(this.desktop.ready())return false;if(this.phoneMicAccess)return false;e=e!=false;if(!this.phoneAPI){if(this.callStreamSelf!=null)return false;if(e&&!this.callActive)return false}if(this.callDialogAllow)this.callDialogAllow.close();this.callDialogAllow=new BX.PopupWindow("bx-messenger-call-access",this.popupMessengerDialog,{lightShadow:true,zIndex:200,offsetTop:this.popupMessengerDialog?this.callOverlayMinimize?-20:-this.popupMessengerDialog.offsetHeight/2-100:-20,offsetLeft:this.callOverlay?this.callOverlay.offsetWidth/2-170:0,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.callDialogAllow=null},this)},content:BX.create("div",{props:{className:"bx-messenger-call-dialog-allow"},children:[BX.create("div",{props:{className:"bx-messenger-call-dialog-allow-image-block"},children:[BX.create("div",{props:{className:"bx-messenger-call-dialog-allow-center"},children:[BX.create("div",{props:{className:"bx-messenger-call-dialog-allow-arrow"}})]}),BX.create("div",{props:{className:"bx-messenger-call-dialog-allow-center"},children:[BX.create("div",{props:{className:"bx-messenger-call-dialog-allow-button"},html:BX.message("IM_M_CALL_ALLOW_BTN")})]})]}),BX.create("div",{props:{className:"bx-messenger-call-dialog-allow-text"},html:BX.message("IM_M_CALL_ALLOW_TEXT")})]})});this.callDialogAllow.show()};BX.IM.WebRTC.prototype.callNotifyWait=function(e,t,s,i,a){if(!this.callSupport())return false;a=a==true;s=s==true;i=i==true;this.initiator=false;this.callInitUserId=t;this.callInit=true;this.callActive=false;this.callUserId=i?0:t;this.callChatId=e;this.callToGroup=i;this.callGroupUsers=this.messenger.userInChat[e];this.callVideo=s;this.callOverlayShow({toUserId:this.BXIM.userId,fromUserId:this.callToGroup?e:t,callToGroup:this.callToGroup,video:s,status:BX.message(this.callToGroup?"IM_M_CALL_ST_INVITE_2":"IM_M_CALL_ST_INVITE"),
buttons:[{text:BX.message("IM_M_CALL_BTN_ANSWER"),className:"bx-messenger-call-overlay-button-answer",events:{click:BX.delegate(function(){this.BXIM.stopRepeatSound("ringtone");if(a){var e=this.callToGroup;var t=this.callChatId;var s=this.callUserId;var i=this.callVideo;this.callAbort();this.callOverlayClose(false);this.callInvite(e?"chat"+t:s,i)}else{this.callDialog();BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_ANSWER&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_CALL:"Y",COMMAND:"answer",CHAT_ID:this.callChatId,CALL_TO_GROUP:this.callToGroup?"Y":"N",RECIPIENT_ID:this.callUserId,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});this.desktop.closeTopmostWindow()}},this)}},{text:BX.message("IM_M_CALL_BTN_HANGUP"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){this.BXIM.stopRepeatSound("ringtone");this.callSelfDisabled=true;this.callCommand(this.callChatId,"decline",{ACTIVE:this.callActive?"Y":"N",INITIATOR:this.initiator?"Y":"N"});this.callAbort();this.callOverlayClose()},this)}},{text:BX.message("IM_M_CALL_BTN_CHAT"),className:"bx-messenger-call-overlay-button-chat",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}]});if(!this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){var n={title:BX.message("IM_PHONE_DESC"),text:BX.util.htmlspecialcharsback(this.callOverlayTitle()),icon:this.callUserId?this.messenger.users[this.callUserId].avatar:"",tag:"im-call"};n.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};n.onclick=function(){window.focus();this.close()};this.BXIM.notifyManager.nativeNotify(n)}};BX.IM.WebRTC.prototype.callNotifyWaitDesktop=function(e,t,s,i,a){this.BXIM.ppServerStatus=true;if(!this.callSupport()||!this.desktop.ready())return false;a=a==true;s=s==true;i=i==true;this.initiator=false;this.callInitUserId=t;this.callInit=true;this.callActive=false;this.callUserId=i?0:t;this.callChatId=e;this.callToGroup=i;this.callGroupUsers=this.messenger.userInChat[e];this.callVideo=s;this.callOverlayShow({prepare:true,toUserId:this.BXIM.userId,fromUserId:this.callToGroup?e:t,callToGroup:this.callToGroup,video:s,status:BX.message(this.callToGroup?"IM_M_CALL_ST_INVITE_2":"IM_M_CALL_ST_INVITE"),buttons:[{text:BX.message("IM_M_CALL_BTN_ANSWER"),className:"bx-messenger-call-overlay-button-answer",events:{click:BX.delegate(function(){if(a)BX.desktop.onCustomEvent("main","bxCallJoin",[e,t,s,i]);else BX.desktop.onCustomEvent("main","bxCallAnswer",[e,t,s,i]);BX.desktop.windowCommand("close")},this)}},{text:BX.message("IM_M_CALL_BTN_HANGUP"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){BX.desktop.onCustomEvent("main","bxCallDecline",[]);BX.desktop.windowCommand("close")},this)}}]});this.desktop.drawOnPlaceholder(this.callOverlay);BX.desktop.setWindowPosition({X:STP_CENTER,Y:STP_VCENTER,Width:470,Height:120})};BX.IM.WebRTC.prototype.callFloatDialog=function(e,t,s){if(!this.desktop.ready())return false;this.audioMuted=s;var i=t?this.desktop.minCallVideoWidth:this.desktop.minCallWidth;var a=t?this.desktop.minCallVideoHeight:this.desktop.minCallHeight;var n={width:i+"px",height:a+"px"};this.callOverlay=BX.create("div",{props:{className:"bx-messenger-call-float"+(t?"":" bx-messenger-call-float-audio")},style:n,children:[this.callOverlayVideoMain=!t?null:BX.create("video",{attrs:{autoplay:true,src:t},props:{className:"bx-messenger-call-float-video"},events:{click:BX.delegate(function(){BX.desktop.onCustomEvent("main","bxCallOpenDialog",[])},this)}}),BX.create("div",{props:{className:"bx-messenger-call-float-buttons"},children:[BX.create("div",{props:{className:"bx-messenger-call-float-button bx-messenger-call-float-button-mic"+(this.audioMuted?" bx-messenger-call-float-button-mic-disabled":"")},events:{click:BX.delegate(function(e){this.audioMuted=!this.audioMuted;BX.desktop.onCustomEvent("main","bxCallMuteMic",[this.audioMuted]);BX.toggleClass(BX.proxy_context,"bx-messenger-call-float-button-mic-disabled");var t=BX.findChildByClassName(BX.proxy_context,"bx-messenger-call-float-button-text");t.innerHTML=BX.message("IM_M_CALL_BTN_MIC")+" "+BX.message("IM_M_CALL_BTN_MIC_"+(this.audioMuted?"OFF":"ON"));BX.PreventDefault(e)},this)},children:[BX.create("span",{props:{className:"bx-messenger-call-float-button-icon"}}),BX.create("span",{props:{className:"bx-messenger-call-float-button-text"},html:BX.message("IM_M_CALL_BTN_MIC")+" "+BX.message("IM_M_CALL_BTN_MIC_"+(this.audioMuted?"OFF":"ON"))})]}),BX.create("div",{props:{className:"bx-messenger-call-float-button bx-messenger-call-float-button-decline"},events:{click:BX.delegate(function(e){BX.desktop.onCustomEvent("main","bxCallDecline",[]);BX.desktop.windowCommand("close");BX.PreventDefault(e)},this)},children:[BX.create("span",{props:{className:"bx-messenger-call-float-button-icon"}}),BX.create("span",{props:{className:"bx-messenger-call-float-button-text"},html:BX.message("IM_M_CALL_BTN_HANGUP")})]})]})]});this.desktop.drawOnPlaceholder(this.callOverlay);BX.desktop.setWindowMinSize({Width:i,Height:a});BX.desktop.setWindowResizable(false);BX.desktop.setWindowClosable(false);BX.desktop.setWindowResizable(false);BX.desktop.setWindowTitle(BX.util.htmlspecialcharsback(BX.util.htmlspecialcharsback(e)));if(BXDesktopSystem.QuerySettings("global_topmost_x",null)){BX.desktop.setWindowPosition({X:parseInt(BXDesktopSystem.QuerySettings("global_topmost_x",STP_RIGHT)),Y:parseInt(BXDesktopSystem.QuerySettings("global_topmost_y",STP_TOP)),Width:i,Height:a,Mode:STP_FRONT});if(!BX.browser.IsMac())BX.desktop.setWindowPosition({X:parseInt(BXDesktopSystem.QuerySettings("global_topmost_x",STP_RIGHT)),Y:parseInt(BXDesktopSystem.QuerySettings("global_topmost_y",STP_TOP)),Width:i,Height:a,Mode:STP_FRONT})}else{BX.desktop.setWindowPosition({X:STP_RIGHT,Y:STP_TOP,Width:i,Height:a,Mode:STP_FRONT});if(!BX.browser.IsMac())BX.desktop.setWindowPosition({X:STP_RIGHT,Y:STP_TOP,Width:i,Height:a,Mode:STP_FRONT})}if(t){clearInterval(this.callAspectCheckInterval);this.callAspectCheckInterval=setInterval(BX.delegate(function(){if(this.callOverlayVideoMain.offsetWidth<this.callOverlayVideoMain.offsetHeight){if(this.callAspectHorizontal){this.callAspectHorizontal=false;BX.addClass(this.callOverlay,"bx-messenger-call-overlay-aspect-vertical");BX.desktop.setWindowSize({Width:this.desktop.minCallVideoHeight,Height:this.desktop.minCallVideoWidth})}}else{if(!this.callAspectHorizontal){this.callAspectHorizontal=true;BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-aspect-vertical");BX.desktop.setWindowSize({Width:this.desktop.minCallVideoWidth,Height:this.desktop.minCallVideoHeight})}}},this),500)}BX.desktop.addCustomEvent("bxCallChangeMainVideo",BX.delegate(function(e){this.callOverlayVideoMain.src=e},this))};BX.IM.WebRTC.prototype.storageSet=function(e){if(e.key=="vite"){if(e.value===true||!this.BXIM.webrtc.callSelfDisabled){this.phoneTransferEnabled=e.value}}else if(e.key=="viExternalCard"){if(e.value===false){this.hideExternalCall()}}};BX.IM.WebRTC.prototype.phoneSupport=function(){return this.phoneEnabled&&(this.phoneDeviceActive||this.ready())};BX.IM.WebRTC.prototype.phoneToggleAudio=function(){if(!this.phoneCurrentCall)return false;if(this.phoneMicMuted){this.phoneCurrentCall.unmuteMicrophone()}else{this.phoneCurrentCall.muteMicrophone()}this.phoneMicMuted=!this.phoneMicMuted};BX.IM.WebRTC.prototype.phoneDeviceCall=function(e){var t=true;if(typeof e=="boolean"){this.BXIM.setLocalConfig("viDeviceCallBlock",!e);BX.localStorage.set("viDeviceCallBlock",!e,86400)}else{var s=this.BXIM.getLocalConfig("viDeviceCallBlock");if(!s){s=BX.localStorage.get("viDeviceCallBlock")}t=this.phoneDeviceActive&&s!=true}return t};BX.IM.WebRTC.prototype.openKeyPad=function(e){this.phoneKeyPadPutPlusFlag=false;if(!this.phoneSupport()&&!(this.BXIM.desktopStatus&&this.BXIM.desktopVersion>=18)){if(!this.desktop.ready()){this.BXIM.openConfirm(BX.message("IM_CALL_NO_WEBRT"),[this.BXIM.platformName==""?null:new BX.PopupWindowButton({text:BX.message("IM_M_CALL_BTN_DOWNLOAD"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){window.open(BX.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");BX.proxy_context.popupWindow.close()},this)}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})])}return false}if(this.callInit&&!this.callActive||this.callActive&&!this.phoneCurrentCall){if(this.BXIM.design=="DESKTOP"){if(BX.desktop.lastTabTarget!="im"){BX.desktop.changeTab(this.BXIM.dialogOpen?"im":"notify")}else{BX.desktop.closeTab("im-phone")}}return false}if(this.callActive&&this.BXIM.design=="DESKTOP"&&BX.hasClass(this.callOverlay,"bx-messenger-call-overlay-line")){BX.desktop.closeTab("im-phone");return false}if(this.popupKeyPad!=null){this.popupKeyPad.close();return false}var t="top";var s=94;if(this.messenger.popupMessenger){if(!this.callActive){if(this.BXIM.design=="DESKTOP"){var i=BX("bx-desktop-tab-im-phone");var a=-110;var n=60}else{BX.addClass(this.messenger.popupContactListSearchCall,"bx-messenger-input-search-call-active");var i=this.messenger.popupContactListSearchCall;var a=-10;var n=-52}}else{var i=BX("bx-messenger-call-overlay-button-keypad");var a=7;var n=this.desktop.run()?-90:-65;if(this.desktop.run())BX.desktop.closeTab("im-phone")}}else{var i=this.notify.panelButtonCall;var a=this.notify.panelButtonCallOffsetTop?this.notify.panelButtonCallOffsetTop:5;var n=this.notify.panelButtonCallOffsetLeft?this.notify.panelButtonCallOffsetLeft:-75;var t=this.notify.panelButtonCallAnlgePosition?this.notify.panelButtonCallAnlgePosition:t;var s=this.notify.panelButtonCallAnlgeOffset?this.notify.panelButtonCallAnlgeOffset:s}this.messenger.setClosingByEsc(false);this.popupKeyPad=new BX.PopupWindow("bx-messenger-popup-keypad",i,{offsetTop:a,offsetLeft:n,darkMode:true,closeByEsc:true,bindOptions:!this.desktop.run()?{position:"top"}:{},angle:{position:this.BXIM.design=="DESKTOP"&&!this.callActive?"left":t,offset:this.BXIM.design=="DESKTOP"?this.callActive?120:76:s},autoHide:true,zIndex:200,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){if(this.BXIM.design=="DESKTOP"){if(BX.desktop.lastTabTarget!="im"){BX.desktop.changeTab(this.BXIM.dialogOpen?"im":"notify")}else{BX.desktop.closeTab("im-phone")}}this.popupKeyPad=null;this.messenger.setClosingByEsc(true);BX.removeClass(this.messenger.popupContactListSearchCall,"bx-messenger-input-search-call-active")},this)},content:BX.create("div",{props:{className:"bx-messenger-calc-wrap"+(this.desktop.run()?" bx-messenger-calc-wrap-desktop":"")},children:[BX.create("div",{props:{className:"bx-messenger-calc-body"},children:[this.popupKeyPadButtons=BX.create("div",{props:{className:"bx-messenger-calc-panel"},children:[this.popupKeyPadInputDelete=BX.create("span",{props:{className:"bx-messenger-calc-panel-delete"}}),this.popupKeyPadInput=BX.create("input",{attrs:{readonly:this.callActive?true:false,type:"text",value:"",placeholder:BX.message(this.callActive?"IM_PHONE_PUT_DIGIT":"IM_PHONE_PUT_NUMBER")},props:{className:"bx-messenger-calc-panel-input"}})]}),this.popupKeyPadButtons=BX.create("div",{props:{className:"bx-messenger-calc-btns-block"},children:[BX.create("span",{attrs:{"data-digit":1},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-1"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":2},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-2"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":3},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-3"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":4},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-4"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":5},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-5"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":6},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-6"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":7},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-7"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":8},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-8"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":9},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-9"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":"*"},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-10"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":"0"},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-0"},html:'<span class="bx-messenger-calc-btn-num"></span>'}),BX.create("span",{attrs:{"data-digit":"#"},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-11"},html:'<span class="bx-messenger-calc-btn-num"></span>'})]})]}),this.callActive?null:BX.create("div",{props:{className:"bx-messenger-call-btn-wrap"},children:[this.popupKeyPadCall=BX.create("span",{props:{className:"bx-messenger-call-btn"},children:[BX.create("span",{props:{className:"bx-messenger-call-btn-icon"}}),BX.create("span",{props:{className:"bx-messenger-call-btn-text"},html:BX.message("IM_PHONE_CALL")})]}),!this.phoneNumberLast?null:this.popupKeyPadRecall=BX.create("span",{props:{className:"bx-messenger-call-btn-2"},attrs:{title:BX.message("IM_M_CALL_BTN_RECALL_3")},children:[BX.create("span",{props:{className:"bx-messenger-call-btn-2-icon"}})]})]})]}),noAllPaddings:true});this.popupKeyPad.show();this.popupKeyPadInput.focus();BX.bind(this.popupKeyPad.popupContainer,"click",BX.PreventDefault);BX.bind(this.popupKeyPadInput,"keydown",BX.delegate(function(e){if(e.keyCode==13){this.BXIM.phoneTo(this.popupKeyPadInput.value)}else if(e.keyCode==37||e.keyCode==39||e.keyCode==8||e.keyCode==107||e.keyCode==46||e.keyCode==35||e.keyCode==36){}else if((e.keyCode==61||e.keyCode==187||e.keyCode==51||e.keyCode==56)&&e.shiftKey){}else if((e.keyCode==67||e.keyCode==86||e.keyCode==65||e.keyCode==88)&&(e.metaKey||e.ctrlKey)){}else if(e.keyCode>=48&&e.keyCode<=57&&!e.shiftKey){}else if(e.keyCode>=96&&e.keyCode<=105&&!e.shiftKey){}else{return BX.PreventDefault(e)}},this));var r=BX.delegate(function(){if(!this.callActive&&this.popupKeyPadInput.value.length>0){if(this.popupKeyPadInput.parentNode.className=="bx-messenger-calc-panel")BX.addClass(this.popupKeyPadInput.parentNode,"bx-messenger-calc-panel-active")}else{if(this.popupKeyPadInput.parentNode.className=="bx-messenger-calc-panel bx-messenger-calc-panel-active")BX.removeClass(this.popupKeyPadInput.parentNode,"bx-messenger-calc-panel-active")}this.popupKeyPadInput.focus()},this);BX.bind(this.popupKeyPadCall,"click",BX.delegate(function(e){this.BXIM.phoneTo(this.popupKeyPadInput.value)},this));BX.bind(this.popupKeyPadRecall,"click",BX.delegate(function(e){this.BXIM.phoneTo(this.phoneNumberLast)},this));BX.bind(this.popupKeyPadRecall,"mouseover",BX.delegate(function(e){this.popupKeyPadInput.setAttribute("placeholder",this.phoneNumberLast)},this));BX.bind(this.popupKeyPadRecall,"mouseout",BX.delegate(function(e){this.popupKeyPadInput.setAttribute("placeholder",BX.message("IM_PHONE_PUT_NUMBER"))},this));BX.bind(this.popupKeyPadInputDelete,"click",BX.delegate(function(e){if(this.callActive)return false;this.popupKeyPadInput.value=this.popupKeyPadInput.value.substr(0,this.popupKeyPadInput.value.length-1);r()},this));BX.bind(this.popupKeyPadInput,"keyup",r);BX.bindDelegate(this.popupKeyPadButtons,"mousedown",{className:"bx-messenger-calc-btn"},BX.delegate(function(){var e=BX.proxy_context.getAttribute("data-digit");if(e!=0)return false;this.phoneKeyPadPutPlus()},this));BX.bindDelegate(this.popupKeyPadButtons,"mouseup",{className:"bx-messenger-calc-btn"},BX.delegate(function(){var e=BX.proxy_context.getAttribute("data-digit");if(e==0){this.phoneKeyPadPutPlusEnd()}else{this.popupKeyPadInput.value=this.popupKeyPadInput.value+""+e}BX.MessengerCommon.phoneSendDTMF(e);r()},this));return e?BX.PreventDefault(e):true};BX.IM.WebRTC.prototype.phoneKeyPadPutPlus=function(){this.phoneKeyPadPutPlusTimeout=setTimeout(BX.delegate(function(){this.phoneKeyPadPutPlusFlag=true;this.popupKeyPadInput.value=this.popupKeyPadInput.value+"+"},this),500)};BX.IM.WebRTC.prototype.phoneKeyPadPutPlusEnd=function(){clearTimeout(this.phoneKeyPadPutPlusTimeout);if(!this.phoneKeyPadPutPlusFlag)this.popupKeyPadInput.value=this.popupKeyPadInput.value+"0";this.phoneKeyPadPutPlusFlag=false};BX.IM.WebRTC.prototype.phoneCount=function(e){var t=0;if(typeof e==="object"){if(e.PERSONAL_MOBILE)t++;else if(e.PERSONAL_PHONE)t++;else if(e.WORK_PHONE)t++}return t};BX.IM.WebRTC.prototype.phoneDisconnectAfterCall=function(e){if(this.desktop.ready()){e=false}this.phoneDisconnectAfterCallFlag=e===false?false:true;return true};BX.IM.WebRTC.prototype.phoneCallInvite=function(e,t){this.phoneLog(e,t);this.phoneNumberUser=BX.util.htmlspecialchars(e);e=BX.MessengerCommon.phoneCorrect(e);if(typeof t!="object")t={};if(this.desktop.run()&&BX.desktop.currentTab!="im"){BX.desktop.changeTab("im")}if(this.popupKeyPad)this.popupKeyPad.close();if(!this.messenger.popupMessenger)this.messenger.openMessenger(this.messenger.currentTab);if(!this.callActive&&!this.callInit){this.initiator=true;this.callInitUserId=this.BXIM.userId;this.callInit=true;this.callActive=false;this.callUserId=0;this.callChatId=0;this.callToGroup=0;this.callGroupUsers=[];this.phoneNumber=e;this.phoneParams=t;this.callOverlayShow({toUserId:0,phoneNumber:this.phoneNumber,callTitle:this.phoneNumberUser,fromUserId:this.BXIM.userId,callToGroup:false,callToPhone:true,video:false,status:BX.message("IM_M_CALL_ST_CONNECT"),buttons:[{text:BX.message("IM_M_CALL_BTN_HANGUP"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){this.phoneCallFinish();this.callAbort();this.callOverlayClose()},this)}},{text:BX.message("IM_M_CALL_BTN_CHAT"),className:"bx-messenger-call-overlay-button-chat",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}]})}};BX.IM.WebRTC.prototype.phoneCall=function(e,t){if(BX.localStorage.get("viInitedCall"))return false;if(e!=""){this.phoneNumberLast=e;this.BXIM.setLocalConfig("phone_last",e)}this.phoneLog(e,t);this.phoneNumberUser=BX.util.htmlspecialchars(e);numberOriginal=e;e=BX.MessengerCommon.phoneCorrect(e);if(typeof t!="object")t={};if(e.length<=0){this.BXIM.openConfirm({title:BX.message("IM_PHONE_WRONG_NUMBER"),message:BX.message("IM_PHONE_WRONG_NUMBER_DESC")});return false}if(this.desktop.run()&&BX.desktop.currentTab!="im"){BX.desktop.changeTab("im")}if(this.popupKeyPad)this.popupKeyPad.close();if(!this.phoneSupport()){if(!this.desktop.ready()){this.BXIM.openConfirm(BX.message("IM_CALL_NO_WEBRT"),[new BX.PopupWindowButton({text:BX.message("IM_M_CALL_BTN_DOWNLOAD"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){window.open(BX.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");BX.proxy_context.popupWindow.close()},this)}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})])}return false}if(!this.messenger.popupMessenger)this.messenger.openMessenger(this.messenger.currentTab);if(!this.callActive&&!this.callInit){this.initiator=true;this.callInitUserId=this.BXIM.userId;this.callInit=true;this.callActive=false;this.callUserId=0;this.callChatId=0;this.callToGroup=0;this.phoneCallExternal=this.phoneDeviceCall();this.callGroupUsers=[];this.phoneNumber=e;this.phoneParams=t;this.callOverlayShow({toUserId:0,phoneNumber:this.phoneNumber,callTitle:this.phoneNumberUser,fromUserId:this.BXIM.userId,callToGroup:false,callToPhone:true,video:false,status:BX.message("IM_M_CALL_ST_CONNECT"),buttons:[{title:BX.message(this.phoneDeviceCall()?"IM_M_CALL_BTN_DEVICE_TITLE":"IM_M_CALL_BTN_DEVICE_OFF_TITLE"),id:"bx-messenger-call-overlay-button-device",className:"bx-messenger-call-overlay-button-device"+(this.phoneDeviceCall()?"":" bx-messenger-call-overlay-button-device-off"),events:{click:BX.delegate(function(){var e=this.phoneNumber;this.phoneCallFinish();this.callAbort();this.phoneDeviceCall(!this.phoneDeviceCall());this.phoneCall(e)},this)},hide:this.phoneDeviceActive&&this.enabled?false:true},{text:BX.message("IM_M_CALL_BTN_HANGUP"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){this.phoneCallFinish();this.callAbort();this.callOverlayClose()},this)}},{text:BX.message("IM_M_CALL_BTN_CHAT"),className:"bx-messenger-call-overlay-button-chat",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}]});this.BXIM.playSound("start");if(this.phoneCallExternal){BX.MessengerCommon.phoneCommand("deviceStartCall",{NUMBER:numberOriginal.toString().replace(/[^0-9\*]/g,""),PARAMS:t})}else if(!this.phoneLogin||!this.phoneServer){BX.MessengerCommon.phoneAuthorize()}else{this.phoneApiInit()}}};BX.IM.WebRTC.prototype.phoneIncomingAnswer=function(){this.callSelfDisabled=true;BX.MessengerCommon.phoneCommand(this.phoneTransferEnabled?"answerTransfer":"answer",{CALL_ID:this.phoneCallId});if(this.popupKeyPad)this.popupKeyPad.close();this.callOverlayButtons([{text:BX.message("IM_M_CALL_BTN_HANGUP"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){this.phoneCallFinish();this.callAbort();this.callOverlayClose()},this)}},{text:BX.message("IM_M_CALL_BTN_CHAT"),className:"bx-messenger-call-overlay-button-chat",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}]);if(this.messenger.popupMessenger==null){this.messenger.openMessenger(this.callUserId);this.callOverlayToggleSize(false)}BX.addClass(this.callOverlay,"bx-messenger-call-overlay-maxi ");BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi ");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-mini");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-line");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call-audio");if(!this.phoneLogin||!this.phoneServer){BX.MessengerCommon.phoneAuthorize()}else{this.phoneApiInit()}};BX.IM.WebRTC.prototype.phoneApiInit=function(){if(!this.phoneSupport())return false;if(!this.phoneLogin||!this.phoneServer){this.phoneCallFinish();this.callOverlayProgress("offline");this.callAbort(BX.message("IM_PHONE_ERROR"));this.callOverlayButtons(this.buttonsOverlayClose);return false}if(this.phoneAPI){if(this.phoneSDKinit){if(this.phoneIncoming){BX.MessengerCommon.phoneCommand(this.phoneTransferEnabled?"readyTransfer":"ready",{CALL_ID:this.phoneCallId})}else if(this.callInitUserId==this.BXIM.userId){this.phoneOnSDKReady()}}else{this.phoneOnSDKReady()}return true}this.phoneAPI=VoxImplant.getInstance();this.phoneAPI.addEventListener(VoxImplant.Events.SDKReady,BX.delegate(this.phoneOnSDKReady,this));this.phoneAPI.addEventListener(VoxImplant.Events.ConnectionEstablished,BX.delegate(this.phoneOnConnectionEstablished,this));this.phoneAPI.addEventListener(VoxImplant.Events.ConnectionFailed,BX.delegate(this.phoneOnConnectionFailed,this));this.phoneAPI.addEventListener(VoxImplant.Events.ConnectionClosed,BX.delegate(this.phoneOnConnectionClosed,this));this.phoneAPI.addEventListener(VoxImplant.Events.IncomingCall,BX.delegate(this.phoneOnIncomingCall,this));this.phoneAPI.addEventListener(VoxImplant.Events.AuthResult,BX.delegate(this.phoneOnAuthResult,this));this.phoneAPI.addEventListener(VoxImplant.Events.MicAccessResult,BX.delegate(this.phoneOnMicResult,this));this.phoneAPI.addEventListener(VoxImplant.Events.SourcesInfoUpdated,BX.delegate(this.phoneOnInfoUpdated,this));this.phoneAPI.addEventListener(VoxImplant.Events.NetStatsReceived,BX.delegate(this.phoneOnNetStatsReceived,this));var e=this.BXIM.language.toUpperCase();if(e=="EN")e="US";var t={useRTCOnly:true,micRequired:true,videoSupport:false,progressTone:true,progressToneCountry:e};var s=[];if(this.enableMicAutoParameters===false){t.audioConstraints={optional:[{echoCancellation:false},{googEchoCancellation:false},{googEchoCancellation2:false},{googDAEchoCancellation:false},{googAutoGainControl:false},{googAutoGainControl2:false},{mozAutoGainControl:false},{googNoiseSuppression:false},{googNoiseSuppression2:false},{googHighpassFilter:false},{googTypingNoiseDetection:false},{googAudioMirroring:false}]}}this.phoneAPI.init(t);if(this.defaultMicrophone){this.phoneAPI.useAudioSource(this.defaultMicrophone)}this.phoneSDKinit=true;return true};BX.IM.WebRTC.prototype.phoneOnSDKReady=function(e){this.phoneLog("SDK ready");e=e||{};e.delay=e.delay||false;if(!e.delay&&this.phoneDeviceActive){if(!this.phoneIncoming&&!this.phoneDeviceCall()){if(this.desktop.ready()){BX.desktop.changeTab("im");BX.desktop.windowCommand("show");this.desktop.closeTopmostWindow()}this.callOverlayProgress("wait");this.callDialogAllowTimeout=setTimeout(BX.delegate(function(){this.phoneOnSDKReady({delay:true})},this),5e3);return false}}if(this.desktop.ready()&&this.BXIM.init){BX.desktop.syncPause(true)}if(!this.phoneAPI.connected()){this.phoneAPI.connect();clearTimeout(this.callDialogAllowTimeout);this.callDialogAllowTimeout=setTimeout(BX.delegate(function(){this.callDialogAllowShow()},this),1500);this.callOverlayProgress("wait");this.callOverlayStatus(BX.message("IM_M_CALL_ST_WAIT_ACCESS"))}else{this.phoneLog("Connection exists");this.callOverlayProgress("connect");this.callOverlayStatus(BX.message("IM_M_CALL_ST_CONNECT"));this.phoneOnAuthResult({result:true})}};BX.IM.WebRTC.prototype.phoneOnConnectionEstablished=function(e){BX.MessengerCommon.phoneOnConnectionEstablished(e);this.phoneAPI.requestOneTimeLoginKey(this.phoneLogin+"@"+this.phoneServer)};BX.IM.WebRTC.prototype.phoneOnConnectionFailed=function(e){BX.MessengerCommon.phoneOnConnectionFailed(e)};BX.IM.WebRTC.prototype.phoneOnConnectionClosed=function(e){BX.MessengerCommon.phoneOnConnectionClosed(e)};BX.IM.WebRTC.prototype.phoneOnIncomingCall=function(e){BX.MessengerCommon.phoneOnIncomingCall(e)};BX.IM.WebRTC.prototype.phoneOnAuthResult=function(e){BX.MessengerCommon.phoneOnAuthResult(e)};BX.IM.WebRTC.prototype.phoneOnMicResult=function(e){BX.MessengerCommon.phoneOnMicResult(e)};BX.IM.WebRTC.prototype.phoneOnInfoUpdated=function(e){this.phoneLog("Info updated",this.phoneAPI.audioSources(),this.phoneAPI.videoSources())};BX.IM.WebRTC.prototype.phoneOnCallConnected=function(e){if(this.desktop.ready()&&this.BXIM.init){BX.desktop.syncPause(true)}this.BXIM.stopRepeatSound("ringtone",5e3);BX.localStorage.set("viInitedCall",true,5);clearInterval(this.phoneConnectedInterval);this.phoneConnectedInterval=setInterval(function(){BX.localStorage.set("viInitedCall",true,5)},5e3);this.desktop.closeTopmostWindow();this.phoneLog("Call connected",e);this.callOverlayCallConnectedButtons=[{text:BX.message("IM_M_CALL_BTN_HANGUP"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){this.phoneCallFinish();this.callAbort();this.BXIM.playSound("stop");this.callOverlayClose()},this)}},{title:BX.message("IM_M_CALL_BTN_MIC_TITLE"),id:"bx-messenger-call-overlay-button-mic",className:"bx-messenger-call-overlay-button-mic "+(this.phoneMicMuted?" bx-messenger-call-overlay-button-mic-off":""),events:{click:BX.delegate(function(){this.phoneToggleAudio();var e=BX.findChildByClassName(BX.proxy_context,"bx-messenger-call-overlay-button-mic");if(e)BX.toggleClass(e,"bx-messenger-call-overlay-button-mic-off")},this)},hide:this.phoneCallDevice=="PHONE"},{title:BX.message("IM_M_CALL_BTN_HOLD_TITLE"),id:"bx-messenger-call-overlay-button-hold",className:"bx-messenger-call-overlay-button-hold "+(this.phoneHolded?" bx-messenger-call-overlay-button-hold-on":""),events:{click:BX.delegate(function(){BX.MessengerCommon.phoneToggleHold();var e=BX.findChildByClassName(BX.proxy_context,"bx-messenger-call-overlay-button-hold");if(e)BX.toggleClass(e,"bx-messenger-call-overlay-button-hold-on")},this)},hide:this.phonePortalCall},{title:BX.message("IM_M_CALL_BTN_TRANSFER"),id:"bx-messenger-call-overlay-button-transfer",className:"bx-messenger-call-overlay-button-transfer",events:{click:BX.delegate(function(e){this.openTransferDialog({bind:BX.proxy_context});BX.PreventDefault(e)},this)},hide:this.phonePortalCall},{title:BX.message("IM_PHONE_OPEN_KEYPAD"),className:"bx-messenger-call-overlay-button-keypad",events:{click:BX.delegate(function(e){this.openKeyPad(e)},this)},hide:this.phoneCallDevice=="PHONE"},{title:BX.message("IM_M_CALL_BTN_CHAT_2"),className:"bx-messenger-call-overlay-button-chat2",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}];this.callOverlayButtons(this.callOverlayCallConnectedButtons);BX.addClass(this.callOverlay,"bx-messenger-call-overlay-maxi");BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-call-maxi");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-mini");BX.removeClass(this.callOverlay,"bx-messenger-call-overlay-line");BX.addClass(this.callOverlay,"bx-messenger-call-overlay-call");this.callOverlayProgress("online");this.callOverlayStatus(BX.message("IM_M_CALL_ST_ONLINE"));this.callActive=true;if(!this.BXIM.windowFocus)this.desktop.openCallFloatDialog()};BX.IM.WebRTC.prototype.phoneOnCallDisconnected=function(e){BX.MessengerCommon.phoneOnCallDisconnected(e)};BX.IM.WebRTC.prototype.phoneOnCallFailed=function(e){BX.MessengerCommon.phoneOnCallFailed(e)};BX.IM.WebRTC.prototype.phoneOnProgressToneStart=function(e){BX.MessengerCommon.phoneOnProgressToneStart(e)};BX.IM.WebRTC.prototype.phoneOnProgressToneStop=function(e){BX.MessengerCommon.phoneOnProgressToneStop(e)};BX.IM.WebRTC.prototype.phoneOnNetStatsReceived=function(e){BX.MessengerCommon.phoneOnNetStatsReceived(e)};BX.IM.WebRTC.prototype.phoneCallFinish=function(){BX.MessengerCommon.phoneCallFinish()};BX.IM.WebRTC.prototype.phoneIncomingWait=function(e,t,s,i,a){a=!!a;this.phoneLog("incoming call",e,t,s,i);if(!this.phoneSupport()){if(!this.desktop.ready()){this.BXIM.openConfirm(BX.message("IM_CALL_NO_WEBRT"),[new BX.PopupWindowButton({text:BX.message("IM_M_CALL_BTN_DOWNLOAD"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){window.open(BX.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");BX.proxy_context.popupWindow.close()},this)}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})])}return false}this.phoneNumberUser=s;if(!this.phonePortalCall){
this.phoneNumberUser=BX.util.htmlspecialchars(this.phoneNumberUser);s=s.replace(/[^a-zA-Z0-9\.]/g,"")}if(!this.callActive&&!this.callInit){this.initiator=true;this.callInitUserId=0;this.callInit=true;this.callActive=false;this.callUserId=0;this.callChatId=0;this.callToGroup=0;this.callGroupUsers=[];this.phoneIncoming=true;this.phoneCallId=t;this.phoneNumber=s;this.phoneParams={};this.callOverlayShow({toUserId:this.BXIM.userId,phoneNumber:this.phoneNumber,companyPhoneNumber:i,callTitle:this.phoneNumberUser,fromUserId:0,callToGroup:false,callToPhone:true,video:false,isCallback:a,status:a?BX.message("IM_PHONE_INVITE_CALLBACK"):BX.message("IM_PHONE_INVITE"),buttons:[{text:BX.message("IM_PHONE_BTN_ANSWER"),className:"bx-messenger-call-overlay-button-answer",events:{click:BX.delegate(function(){this.BXIM.stopRepeatSound("ringtone");this.phoneIncomingAnswer();this.desktop.closeTopmostWindow()},this)}},{text:BX.message("IM_PHONE_BTN_BUSY"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){this.phoneCallFinish();this.callAbort();this.callOverlayClose()},this)}},{text:BX.message("IM_M_CALL_BTN_CHAT"),className:"bx-messenger-call-overlay-button-chat",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}]});this.callOverlayDrawCrm();if(this.callNotify)this.callNotify.adjustPosition();if(!this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){var n={title:BX.message("IM_PHONE_DESC"),text:BX.util.htmlspecialcharsback(this.callOverlayTitle()),icon:this.callUserId?this.messenger.users[this.callUserId].avatar:"",tag:"im-call"};n.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};n.onclick=function(){window.focus();this.close()};this.BXIM.notifyManager.nativeNotify(n)}}};BX.IM.WebRTC.prototype.phoneIncomingWaitDesktop=function(e,t,s,i,a){this.BXIM.ppServerStatus=true;if(!this.callSupport()||!this.desktop.ready())return false;if(!a){this.phoneNumberUser=BX.util.htmlspecialchars(this.phoneNumberUser);s=s.replace(/[^a-zA-Z0-9\.]/g,"")}if(!this.callActive&&!this.callInit){this.initiator=true;this.callInitUserId=0;this.callInit=true;this.callActive=false;this.callUserId=0;this.callChatId=0;this.callToGroup=0;this.callGroupUsers=[];this.phoneIncoming=true;this.phoneCallId=t;this.phoneNumber=s;this.phoneParams={};this.callOverlayShow({prepare:true,toUserId:this.BXIM.userId,phoneNumber:this.phoneNumber,companyPhoneNumber:i,callTitle:this.phoneNumberUser,fromUserId:0,callToGroup:false,callToPhone:true,video:false,status:BX.message("IM_PHONE_INVITE"),buttons:[{text:BX.message("IM_PHONE_BTN_ANSWER"),className:"bx-messenger-call-overlay-button-answer",events:{click:BX.delegate(function(){BX.desktop.onCustomEvent("main","bxPhoneAnswer",[e,t,s]);BX.desktop.windowCommand("close")},this)}},{text:BX.message("IM_PHONE_BTN_BUSY"),className:"bx-messenger-call-overlay-button-hangup",events:{click:BX.delegate(function(){BX.desktop.onCustomEvent("main","bxPhoneSkip",[]);BX.desktop.windowCommand("close")},this)}}]});this.callOverlayDrawCrm();this.desktop.drawOnPlaceholder(this.callOverlay);if(this.phoneCrm&&this.phoneCrm.FOUND)BX.desktop.setWindowPosition({X:STP_CENTER,Y:STP_VCENTER,Width:609,Height:453});else BX.desktop.setWindowPosition({X:STP_CENTER,Y:STP_VCENTER,Width:470,Height:120})}};BX.IM.WebRTC.prototype.openTransferDialog=function(e){if(!this.phoneCurrentCall&&this.phoneCallDevice=="WEBRTC")return false;if(this.phoneTransferEnabled)return false;if(this.popupTransferDialog!=null){this.popupTransferDialog.close();return false}var t=e.bind?e.bind:null;e.maxUsers=1;this.popupTransferDialog=new BX.PopupWindow("bx-messenger-popup-transfer",t,{lightShadow:true,offsetTop:5,offsetLeft:this.desktop.run()?5:-162,autoHide:true,buttons:[new BX.PopupWindowButton({text:BX.message("IM_M_CALL_BTN_TRANSFER"),className:"popup-window-button-accept",events:{click:BX.delegate(function(){if(this.phoneTransferUser<=0)return false;var e=false;if(this.BXIM.messenger.phones&&this.BXIM.messenger.phones[this.phoneTransferUser]){if(this.BXIM.messenger.phones[this.phoneTransferUser].PERSONAL_MOBILE||this.BXIM.messenger.phones[this.phoneTransferUser].PERSONAL_PHONE||this.BXIM.messenger.phones[this.phoneTransferUser].WORK_PHONE){e=true}}if(!e){this.sendInviteTransfer()}else{var t=null;if(BX.proxy_context&&BX.proxy_context.buttonNode)t=BX.proxy_context.buttonNode;else t=BX.proxy_context;this.messenger.openPopupMenu(t,"callTransferMenu",true,{userId:this.phoneTransferUser})}},this)}}),new BX.PopupWindowButton({text:BX.message("IM_M_CHAT_BTN_CANCEL"),events:{click:BX.delegate(function(){this.popupTransferDialog.close()},this)}})],closeByEsc:true,zIndex:200,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupTransferDialog=null;this.popupTransferDialogContactListElements=null},this)},content:BX.create("div",{props:{className:"bx-messenger-popup-newchat-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-popup-newchat-caption"},html:BX.message("IM_M_CALL_TRANSFER_TEXT")}),BX.create("div",{props:{className:"bx-messenger-popup-newchat-box bx-messenger-popup-newchat-dest bx-messenger-popup-newchat-dest-even"},children:[this.popupTransferDialogDestElements=BX.create("span",{props:{className:"bx-messenger-dest-items"}}),this.popupTransferDialogContactListSearch=BX.create("input",{props:{className:"bx-messenger-input"},attrs:{type:"text",placeholder:BX.message(this.BXIM.bitrixIntranet?"IM_M_SEARCH_PLACEHOLDER_CP":"IM_M_SEARCH_PLACEHOLDER"),value:""}})]}),this.popupTransferDialogContactListElements=BX.create("div",{props:{className:"bx-messenger-popup-newchat-box bx-messenger-popup-newchat-cl bx-messenger-recent-wrap"},children:[]})]})});BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.popupTransferDialogContactListElements,this.popupTransferDialogContactListSearch.value,{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOfflineWithPhones:true});this.popupTransferDialog.setAngle({offset:this.desktop.run()?32:198});this.popupTransferDialog.show();this.popupTransferDialogContactListSearch.focus();BX.addClass(this.popupTransferDialog.popupContainer,"bx-messenger-mark");BX.bind(this.popupTransferDialog.popupContainer,"click",BX.PreventDefault);BX.bind(this.popupTransferDialogContactListSearch,"keyup",BX.delegate(function(t){if(t.keyCode==16||t.keyCode==17||t.keyCode==18||t.keyCode==20||t.keyCode==244||t.keyCode==224||t.keyCode==91)return false;if(t.keyCode==27&&this.popupTransferDialogContactListSearch.value!="")BX.MessengerCommon.preventDefault(t);if(t.keyCode==27){this.popupTransferDialogContactListSearch.value=""}if(t.keyCode==8){var s=null;var i=BX.util.objectSort(this.popupChatDialogUsers,"date","asc");for(var a=0;a<i.length;a++){s=i[a].id}if(s){delete this.popupChatDialogUsers[s];this.redrawChatDialogDest()}return true}if(t.keyCode==13){this.popupTransferDialogContactListSearch.value="";var n=BX.findChildByClassName(this.popupTransferDialogContactListElements,"bx-messenger-cl-item");if(n){if(this.popupTransferDialogContactListSearch.value!=""){this.popupTransferDialogContactListSearch.value=""}if(this.phoneTransferUser>0){e.maxUsers=e.maxUsers+1;if(e.maxUsers>0)BX.show(this.popupTransferDialogContactListSearch);this.phoneTransferUser=0}else{if(e.maxUsers>0){e.maxUsers=e.maxUsers-1;if(e.maxUsers<=0)BX.hide(this.popupTransferDialogContactListSearch);this.phoneTransferUser=n.getAttribute("data-userId")}}this.redrawTransferDialogDest()}}BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.popupTransferDialogContactListElements,this.popupTransferDialogContactListSearch.value,{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOfflineWithPhones:true,timeout:100})},this));BX.bindDelegate(this.popupTransferDialogDestElements,"click",{className:"bx-messenger-dest-del"},BX.delegate(function(){this.phoneTransferUser=0;e.maxUsers=e.maxUsers+1;if(e.maxUsers>0)BX.show(this.popupTransferDialogContactListSearch);this.redrawTransferDialogDest()},this));BX.bindDelegate(this.popupTransferDialogContactListElements,"click",{className:"bx-messenger-cl-item"},BX.delegate(function(t){if(this.popupTransferDialogContactListSearch.value!=""){this.popupTransferDialogContactListSearch.value="";BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.popupTransferDialogContactListElements,"",{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOfflineWithPhones:true})}if(this.phoneTransferUser>0){e.maxUsers=e.maxUsers+1;this.phoneTransferUser=0}else{if(e.maxUsers<=0)return false;e.maxUsers=e.maxUsers-1;this.phoneTransferUser=BX.proxy_context.getAttribute("data-userId")}if(e.maxUsers<=0)BX.hide(this.popupTransferDialogContactListSearch);else BX.show(this.popupTransferDialogContactListSearch);this.redrawTransferDialogDest();return BX.PreventDefault(t)},this))};BX.IM.WebRTC.prototype.redrawTransferDialogDest=function(){var e="";var t=0;if(this.phoneTransferUser>0){t++;e+='<span class="bx-messenger-dest-block'+(this.messenger.users[this.phoneTransferUser].extranet?" bx-messenger-dest-block-extranet":"")+'">'+'<span class="bx-messenger-dest-text">'+this.messenger.users[this.phoneTransferUser].name+"</span>"+'<span class="bx-messenger-dest-del" data-userId="'+this.phoneTransferUser+'"></span></span>'}this.popupTransferDialogDestElements.innerHTML=e;this.popupTransferDialogDestElements.parentNode.scrollTop=this.popupTransferDialogDestElements.parentNode.offsetHeight;if(BX.util.even(t))BX.addClass(this.popupTransferDialogDestElements.parentNode,"bx-messenger-popup-newchat-dest-even");else BX.removeClass(this.popupTransferDialogDestElements.parentNode,"bx-messenger-popup-newchat-dest-even");this.popupTransferDialogContactListSearch.focus()};BX.IM.WebRTC.prototype.sendInviteTransfer=function(){if(!this.phoneCurrentCall&&this.phoneCallDevice=="WEBRTC")return false;if(this.phoneTransferUser<=0)return false;if(this.popupTransferDialog)this.popupTransferDialog.close();this.phoneTransferEnabled=true;BX.localStorage.set("vite",true,1);this.callOverlayStatus(BX.message("IM_M_CALL_ST_TRANSFER"));this.callOverlayButtons([{text:BX.message("IM_M_CALL_BTN_RETURN"),className:"bx-messenger-call-overlay-button-transfer-on",events:{click:BX.delegate(this.cancelInviteTransfer,this)}},{text:BX.message("IM_M_CALL_BTN_CHAT"),className:"bx-messenger-call-overlay-button-chat",showInMaximize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}},{title:BX.message("IM_M_CALL_BTN_MAXI"),className:"bx-messenger-call-overlay-button-maxi",showInMinimize:true,events:{click:BX.delegate(this.callOverlayToggleSize,this)}}]);if(this.phoneCallDevice=="WEBRTC"){this.phoneCurrentCall.sendMessage(JSON.stringify({COMMAND:"hold"}))}else{BX.MessengerCommon.phoneCommand("hold",{CALL_ID:this.phoneCallId})}BX.MessengerCommon.phoneCommand("inviteTransfer",{CALL_ID:this.phoneCallId,USER_ID:this.phoneTransferUser,TRANSFER_TYPE:this.phoneTransferType,TRANSFER_PHONE:this.phoneTransferPhone})};BX.IM.WebRTC.prototype.cancelInviteTransfer=function(){if(!this.phoneCurrentCall&&this.phoneCallDevice=="WEBRTC")return false;this.phoneTransferUser=0;this.callOverlayStatus(BX.message("IM_M_CALL_ST_ONLINE"));this.callOverlayButtons(this.callOverlayCallConnectedButtons);if(this.phoneCallDevice=="WEBRTC"){this.phoneCurrentCall.sendMessage(JSON.stringify({COMMAND:"unhold"}))}else{BX.MessengerCommon.phoneCommand("unhold",{CALL_ID:this.phoneCallId})}if(this.phoneTransferEnabled)BX.MessengerCommon.phoneCommand("cancelTransfer",{CALL_ID:this.phoneCallId});this.phoneTransferEnabled=false;BX.localStorage.set("vite",false,1)};BX.IM.WebRTC.prototype.errorInviteTransfer=function(){if(!this.phoneTransferEnabled)return false;this.callOverlayStatus(BX.message("IM_M_CALL_ST_TRANSFER_1"));this.BXIM.playSound("error",true);this.phoneTransferUser=0;this.phoneTransferEnabled=false;BX.localStorage.set("vite",false,1)};BX.IM.WebRTC.prototype.successInviteTransfer=function(){if(!this.phoneTransferEnabled)return false;this.phoneTransferUser=0;this.phoneTransferEnabled=false;BX.localStorage.set("vite",false,1);if(this.phoneCallDevice=="PHONE"){this.callInit=false;this.phoneCallFinish();this.callOverlayDeleteEvents();this.callOverlayClose();this.BXIM.playSound("stop")}};BX.IM.WebRTC.prototype.showExternalCall=function(e){setTimeout(function(){BX.localStorage.set("viExternalCard",true,5)},100);clearInterval(this.phoneConnectedInterval);this.phoneConnectedInterval=setInterval(function(){BX.localStorage.set("viExternalCard",true,5)},5e3);this.phoneCallId=e.callId;this.callActive=true;this.phoneCallExternal=true;this.callOverlayShow({phoneNumber:e.phoneNumber,fromUserId:e.fromUserId,toUserId:e.toUserId,progress:"online",status:"",minimize:false,buttons:[{text:BX.message("IM_M_CALL_BTN_CLOSE"),className:"bx-messenger-call-overlay-button-close",events:{click:BX.delegate(function(){this.hideExternalCall()},this)}}]});if(e.crm){this.BXIM.webrtc.phoneCrm=e.crm;this.BXIM.webrtc.callOverlayDrawCrm()}};BX.IM.WebRTC.prototype.hideExternalCall=function(e){e=BX.type.isBoolean(e)?e:true;this.callOverlayClose(false);clearInterval(this.BXIM.webrtc.phoneConnectedInterval);if(e){setTimeout(function(){BX.localStorage.set("viExternalCard",false)},100)}this.phoneCallId="";this.callActive=false;this.phoneCallExternal=false};BX.IM.WebRTC.prototype.phoneLog=function(){if(this.desktop.ready()){var e="";for(var t=0;t<arguments.length;t++){e=e+" | "+(typeof arguments[t]=="object"?JSON.stringify(arguments[t]):arguments[t])}BX.desktop.log("phone."+this.BXIM.userEmail+".log",e.substr(3))}if(this.debug){if(console)console.log("Phone Log",JSON.stringify(arguments))}};BX.IM.WebRTC.prototype.startCallExperimental=function(e){var t=[];if(this.BXIM.messenger.openChatFlag){t=this.BXIM.messenger.userInChat[this.BXIM.messenger.currentTab.substr(4)]}else{t.push(this.BXIM.messenger.currentTab)}var s={};t.forEach(function(e){s[e]=this.BXIM.messenger.users[e]});this.callView=new CallView({roomId:e,userId:this.BXIM.userId,userDetails:s,server:"https://testphone.bitrix.info:8089/janus",apiSecret:"eaff35df4cf027ffb36300d9b9604d8f"})};BX.IM.ScreenSharing=function(e,t){t=t||{};this.webrtc=e;this.BXIM=this.webrtc.BXIM;this.debug=true;this.sdpConstraints={mandatory:{OfferToReceiveAudio:false,OfferToReceiveVideo:true}};this.oneway=true;this.sourceSelf=null;this.sourceApponent=null;this.callWindowBeforeUnload=null;BX.addCustomEvent("onImCallEnd",BX.delegate(function(e,t){this.callDecline(false)},this));BX.addCustomEvent("onPullEvent-im",BX.delegate(function(e,t){if(e=="screenSharing"){if(t.command=="inactive"){this.callDecline(false)}else if(!this.webrtc.callActive||this.webrtc.callUserId!=t.senderId){this.callCommand("inactive")}else{this.log("Incoming",t.command,t.senderId,JSON.stringify(t));if(t.command=="invite"){if(this.callInit){this.deleteEvents()}this.initiator=false;this.callVideo=true;this.callInit=true;this.callUserId=t.senderId;this.callInitUserId=t.senderId;this.callAnswer()}else if(t.command=="answer"&&this.initiator){this.startScreenSharing()}else if(t.command=="decline"){this.callDecline()}else if(t.command=="ready"){this.log("Apponent "+t.senderId+" ready!");this.connected[t.senderId]=true}else if(t.command=="reconnect"){clearTimeout(this.pcConnectTimeout[t.senderId]);clearTimeout(this.initPeerConnectionTimeout[t.senderId]);if(this.pc[t.senderId])this.pc[t.senderId].close();delete this.pc[t.senderId];delete this.pcStart[t.senderId];if(this.callStreamMain==this.callStreamUsers[t.senderId])this.callStreamMain=null;this.callStreamUsers[t.senderId]=null;this.initPeerConnection(t.senderId)}else if(t.command=="signaling"&&this.callActive){this.signalingPeerData(t.senderId,t.peer)}else{this.log('Command "'+t.command+'" skip')}}}},this));BX.garbage(function(){if(this.callInit){this.callCommand("decline",true)}},this)};if(BX.inheritWebrtc)BX.inheritWebrtc(BX.IM.ScreenSharing);BX.IM.ScreenSharing.prototype.startScreenSharing=function(){var e={mandatory:{chromeMediaSource:"screen",googLeakyBucket:true,maxWidth:window.screen.width,maxHeight:window.screen.height,maxFrameRate:5}};this.startGetUserMedia(e,false)};BX.IM.ScreenSharing.prototype.onUserMediaSuccess=function(e){var t=this.parent.onUserMediaSuccess.apply(this,arguments);if(!t)return false;if(this.initiator){BX.addClass(this.webrtc.callOverlay,"bx-messenger-call-overlay-screen-sharing-self");this.attachMediaStream(this.webrtc.callOverlayVideoSelf,this.callStreamSelf)}this.callCommand("ready");return true};BX.IM.ScreenSharing.prototype.onUserMediaError=function(e){var t=this.parent.onUserMediaError.apply(this,arguments);if(!t)return false;this.callDecline();return true};BX.IM.ScreenSharing.prototype.setLocalAndSend=function(e,t){var s=this.parent.setLocalAndSend.apply(this,arguments);if(!s)return false;BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_SIGNALING",method:"POST",dataType:"json",timeout:30,data:{IM_SHARING:"Y",COMMAND:"signaling",USER_ID:e,PEER:JSON.stringify(t),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});return true};BX.IM.ScreenSharing.prototype.onRemoteStreamAdded=function(e,t,s){if(!s)return false;BX.addClass(this.webrtc.callOverlay,"bx-messenger-call-overlay-screen-sharing");this.attachMediaStream(this.webrtc.callOverlayVideoReserve,this.webrtc.callStreamMain);this.webrtc.callOverlayVideoReserve.play();this.attachMediaStream(this.webrtc.callOverlayVideoMain,this.callStreamMain);this.webrtc.callOverlayVideoMain.play();return true};BX.IM.ScreenSharing.prototype.onRemoteStreamRemoved=function(e,t){};BX.IM.ScreenSharing.prototype.onIceCandidate=function(e,t){BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_SIGNALING",method:"POST",dataType:"json",timeout:30,data:{IM_SHARING:"Y",COMMAND:"signaling",USER_ID:e,PEER:JSON.stringify(t),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})};BX.IM.ScreenSharing.prototype.peerConnectionError=function(e,t){this.callDecline()};BX.IM.ScreenSharing.prototype.peerConnectionReconnect=function(e){var t=this.parent.peerConnectionReconnect.apply(this,arguments);if(!t)return false;BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_RECONNECT",method:"POST",dataType:"json",timeout:30,data:{IM_SHARING:"Y",COMMAND:"reconnect",USER_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(){this.initPeerConnection(e,true)},this)});return true};BX.IM.ScreenSharing.prototype.deleteEvents=function(){BX.removeClass(this.webrtc.callOverlay,"bx-messenger-call-overlay-screen-sharing-self");BX.removeClass(this.webrtc.callOverlay,"bx-messenger-call-overlay-screen-sharing");this.webrtc.callOverlayVideoReserve.src="";this.attachMediaStream(this.webrtc.callOverlayVideoSelf,this.webrtc.callStreamSelf);this.attachMediaStream(this.webrtc.callOverlayVideoMain,this.webrtc.callStreamMain);this.webrtc.callOverlayVideoMain.play();this.webrtc.callOverlayVideoSelf.play();this.parent.deleteEvents.apply(this,arguments);var e=BX.findChildByClassName(BX("bx-messenger-call-overlay-button-screen"),"bx-messenger-call-overlay-button-screen");if(e)BX.removeClass(e,"bx-messenger-call-overlay-button-screen-off");return true};BX.IM.ScreenSharing.prototype.callInvite=function(){if(this.callInit){this.deleteEvents()}this.initiator=true;this.callVideo=true;this.callInit=true;this.callActive=true;this.callUserId=this.webrtc.callUserId;this.callInitUserId=BXIM.userId;this.callCommand("invite");var e=BX.findChildByClassName(BX("bx-messenger-call-overlay-button-screen"),"bx-messenger-call-overlay-button-screen");if(e)BX.addClass(e,"bx-messenger-call-overlay-button-screen-off")};BX.IM.ScreenSharing.prototype.callAnswer=function(){this.callActive=true;this.startGetUserMedia();this.callCommand("answer")};BX.IM.ScreenSharing.prototype.callDecline=function(e){if(!this.callInit)return false;e=e===false?false:true;if(e){this.callCommand("decline")}this.deleteEvents()};BX.IM.ScreenSharing.prototype.callCommand=function(e,t){if(!this.signalingReady())return false;BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_COMMAND",method:"POST",dataType:"json",timeout:30,async:t!=false,data:{IM_SHARING:"Y",COMMAND:e,USER_ID:this.callUserId,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})};BX.IM.DiskManager=function(e,t){this.BXIM=e;this.notify=t.notifyClass;this.desktop=t.desktopClass;this.enable=t.enable;this.lightVersion=e.ieVersion==8||e.ieVersion==9;this.formBlocked={};this.formAgents={};this.files=t.files;this.filesProgress={};this.filesMessage={};this.filesRegister={};this.fileTmpId=1;this.timeout={};BX.garbage(function(){var e={};var t=0;for(var s in this.filesMessage){e[s]=this.filesMessage[s];if(this.messenger.message[e[s]]){t=this.messenger.message[e[s]].chatId}}if(t>0){BX.ajax({url:this.BXIM.pathToFileAjax+"?FILE_TERMINATE&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,timeout:30,async:false,data:{IM_FILE_UNREGISTER:"Y",CHAT_ID:t,FILES:JSON.stringify(this.filesProgress),MESSAGES:JSON.stringify(e),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})}},this)};BX.IM.DiskManager.prototype.drawHistoryFiles=function(e,t,s){if(!this.enable)return[];if(typeof this.files[e]=="undefined")return[];var i=[];if(typeof t!="object"){t=parseInt(t);if(typeof this.files[e][t]=="undefined")return[];i.push(t)}else{i=t}s=s||{};var a=this.desktop.ready()?"desktop":"default";var n=true;var r=[];for(var o=0;o<i.length;o++){var l=this.files[e][i[o]];if(!l)continue;if(!(l.status=="done"||l.status=="error"))continue;var p=BX.MessengerCommon.formatDate(l.date,[["tommorow","tommorow"],["today","today"],["yesterday","yesterday"],["",BX.date.convertBitrixFormat(BX.message("FORMAT_DATE"))]]);var h=BX.create("span",{props:{className:"bx-messenger-file-user"},children:[BX.create("span",{props:{className:"bx-messenger-file-author"},html:this.messenger.users[l.authorId]?this.messenger.users[l.authorId].name:l.authorName}),BX.create("span",{props:{className:"bx-messenger-file-date"},html:p})]});var c=null;if(l.type=="image"&&(l.preview||l.urlPreview[a])){if(l.urlPreview[a]){var u=BX.create("img",{attrs:{src:l.urlPreview[a]},props:{className:"bx-messenger-file-image-text"}})}else if(l.preview&&typeof l.preview!="string"){var u=l.preview}else{var u=BX.create("img",{attrs:{src:l.preview},props:{className:"bx-messenger-file-image-text"}})}if(n&&l.urlShow[a]){c=BX.create("div",{props:{className:"bx-messenger-file-preview"},children:[BX.create("span",{props:{className:"bx-messenger-file-image"},children:[BX.create("a",{attrs:{href:l.urlShow[a],target:"_blank"},props:{className:"bx-messenger-file-image-src"},children:[u]})]}),BX.create("br")]})}else{c=BX.create("div",{props:{className:"bx-messenger-file-preview"},children:[BX.create("span",{props:{className:"bx-messenger-file-image"},children:[BX.create("span",{props:{className:"bx-messenger-file-image-src"},children:[u]})]}),BX.create("br")]})}}var d=l.name;if(d.length>23){d=d.substr(0,10)+"..."+d.substr(d.length-10,d.length)}var m=BX.create("span",{attrs:{title:l.name},props:{className:"bx-messenger-file-title"},html:d});if(n&&(l.urlShow[a]||l.urlDownload[a])){m=BX.create("a",{props:{className:"bx-messenger-file-title-href"},attrs:{href:l.urlShow[a]?l.urlShow[a]:l.urlDownload[a],target:"_blank"},children:[m]})}m=BX.create("div",{props:{className:"bx-messenger-file-attrs"},children:[m,BX.create("span",{props:{className:"bx-messenger-file-size"},html:BX.UploaderUtils.getFormattedSize(l.size)}),BX.create("span",{attrs:{title:BX.message("IM_F_MENU")},props:{className:"bx-messenger-file-menu"}})]});var g=null;if(l.status=="error"){g=BX.create("span",{props:{className:"bx-messenger-file-status-error"},html:l.errorText?l.errorText:BX.message("IM_F_ERROR")})}if(i.length==1&&s.showInner=="Y"){r=[h,m,c,g]}else{r.push(BX.create("div",{attrs:{id:"im-file-history-panel-"+l.id,"data-chatId":l.chatId,"data-fileId":l.id},props:{className:"bx-messenger-file"},children:[h,m,c,g]}))}if(i.length==1&&s.getElement=="Y"){r=r[0]}}return r};BX.IM.DiskManager.prototype.chatDialogInit=function(){if(!this.messenger.popupMessengerFileFormInput||!BX.Uploader)return false;this.formAgents["imDialog"]=BX.Uploader.getInstance({id:"imDialog",allowUpload:"A",uploadMethod:"deferred",showImage:true,filesInputMultiple:true,input:this.messenger.popupMessengerFileFormInput,dropZone:this.messenger.popupMessengerBodyDialog,fields:{preview:{params:{width:212,height:119}}}});BX.addCustomEvent(this.formAgents["imDialog"],"onAttachFiles",BX.delegate(function(e,t,s){if(this.messenger.popupMessengerFileFormInput.getAttribute("disabled"))return false;var i=s.form.CHAT_ID.value;if(this.messenger.chat[i]&&this.messenger.chat[i].type=="open"&&!BX.MessengerCommon.userInChat(i)){while(e.length>0){e.pop()}}else if(this.messenger.chat[i]&&i==this.messenger.generalChatId&&!this.messenger.canSendMessageGeneralChat){while(e.length>0){e.pop()}}},this));BX.addCustomEvent(this.formAgents["imDialog"].dropZone,"dragEnter",BX.delegate(function(){if(this.messenger.currentTab.toString().substr(0,4)=="chat"&&this.messenger.chat[this.BXIM.messenger.currentTab.substr(4)].type=="open"){if(!BX.MessengerCommon.userInChat(this.messenger.currentTab.substr(4)))return false}if(this.messenger.currentTab.toString().substr(0,4)=="chat"&&this.messenger.currentTab.toString().substr(4)==this.messenger.generalChatId&&!this.messenger.canSendMessageGeneralChat){return false}if(parseInt(this.messenger.popupMessengerFileFormChatId.value)<=0||this.messenger.popupMessengerFileFormInput.getAttribute("disabled"))return false;BX.style(this.messenger.popupMessengerFileDropZone,"display","block");BX.style(this.messenger.popupMessengerFileDropZone,"width",this.messenger.popupMessengerBodyDialog.offsetWidth-2+"px");BX.style(this.messenger.popupMessengerFileDropZone,"height",this.messenger.popupMessengerBodyDialog.offsetHeight-2+"px");clearTimeout(this.messenger.popupMessengerFileDropZoneTimeout);this.messenger.popupMessengerFileDropZoneTimeout=setTimeout(BX.delegate(function(){BX.addClass(this.messenger.popupMessengerFileDropZone,"bx-messenger-file-dropzone-active")},this),10)},this));BX.addCustomEvent(this.formAgents["imDialog"].dropZone,"dragLeave",BX.delegate(function(){if(this.messenger.currentTab.toString().substr(0,4)=="chat"&&this.messenger.chat[this.messenger.currentTab.substr(4)].type=="open"){if(!BX.MessengerCommon.userInChat(this.messenger.currentTab.substr(4)))return false}BX.removeClass(this.messenger.popupMessengerFileDropZone,"bx-messenger-file-dropzone-active");clearTimeout(this.messenger.popupMessengerFileDropZoneTimeout);this.messenger.popupMessengerFileDropZoneTimeout=setTimeout(BX.delegate(function(){BX.style(this.messenger.popupMessengerFileDropZone,"display","none");BX.style(this.messenger.popupMessengerFileDropZone,"width",0);BX.style(this.messenger.popupMessengerFileDropZone,"height",0)},this),300)},this));BX.addCustomEvent(this.formAgents["imDialog"],"onError",BX.delegate(BX.MessengerCommon.diskChatDialogUploadError,BX.MessengerCommon));BX.addCustomEvent(this.formAgents["imDialog"],"onFileinputIsReinited",BX.delegate(function(e){if(!e&&!this.formAgents["imDialog"].fileInput)return false;this.messenger.popupMessengerFileFormInput=e?e:this.formAgents["imDialog"].fileInput;if(parseInt(this.messenger.popupMessengerFileFormChatId.value)<=0){this.messenger.popupMessengerFileFormInput.setAttribute("disabled",true)}},this));BX.addCustomEvent(this.formAgents["imDialog"],"onFileIsInited",BX.delegate(function(e,t,s){BX.MessengerCommon.diskChatDialogFileInited(e,t,s);BX.addCustomEvent(t,"onUploadStart",BX.delegate(BX.MessengerCommon.diskChatDialogFileStart,BX.MessengerCommon));BX.addCustomEvent(t,"onUploadProgress",BX.delegate(BX.MessengerCommon.diskChatDialogFileProgress,BX.MessengerCommon));BX.addCustomEvent(t,"onUploadDone",BX.delegate(BX.MessengerCommon.diskChatDialogFileDone,BX.MessengerCommon));BX.addCustomEvent(t,"onUploadError",BX.delegate(BX.MessengerCommon.diskChatDialogFileError,BX.MessengerCommon))},this));if(BX.DiskFileDialog){if(!this.flagFileDialogInited){BX.addCustomEvent(BX.DiskFileDialog,"inited",BX.proxy(this.initEventFileDialog,this))}BX.addCustomEvent(BX.DiskFileDialog,"loadItems",BX.delegate(function(e,t){if(t!="im-file-dialog")return false;BX.DiskFileDialog.target[t]=e.replace("/bitrix/tools/disk/uf.php",this.BXIM.pathToFileAjax)},this))}};BX.IM.DiskManager.prototype.saveToDisk=function(e,t,s){if(!this.files[e]||!this.files[e][t])return false;if(this.files[e][t].saveToDiskBlock)return false;s=s||{};this.files[e][t].saveToDiskBlock=true;var i=s.boxId?s.boxId:"im-file";var a=BX(i+"-"+t);var n=BX.findChildByClassName(a,"bx-messenger-file-download-disk");if(n){BX.addClass(n,"bx-messenger-file-download-block");n.innerHTML=BX.message("IM_SAVING")}else if(i=="im-file-history-panel"){n=BX.findChildByClassName(a,"bx-messenger-file-date");if(n){BX.addClass(n.parentNode.parentNode,"bx-messenger-file-download-block");n.setAttribute("data-date",n.innerHTML);n.innerHTML=BX.message("IM_SAVING")}}BX.ajax({url:this.BXIM.pathToFileAjax+"?FILE_SAVE_TO_DISK&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,timeout:30,data:{IM_FILE_SAVE_TO_DISK:"Y",CHAT_ID:e,FILE_ID:t,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(s){this.files[e][t].saveToDiskBlock=false;var a=BX(i+"-"+t);var n=BX.findChildByClassName(a,"bx-messenger-file-download-disk");if(n){BX.removeClass(n,"bx-messenger-file-download-block");n.innerHTML=BX.message("IM_F_DOWNLOAD_DISK")}else if(i=="im-file-history-panel"){n=BX.findChildByClassName(a,"bx-messenger-file-date");if(n){BX.removeClass(n.parentNode.parentNode,"bx-messenger-file-download-block");n.innerHTML=n.getAttribute("data-date")}n=BX.findChildByClassName(a,"bx-messenger-file-title")}if(n&&s.ERROR==""){this.messenger.tooltip(n,BX.message("IM_F_SAVE_OK"))}else{this.messenger.tooltip(n,BX.message("IM_F_SAVE_ERR"))}},this),onfailure:BX.delegate(function(){this.files[e][t].saveToDiskBlock=false;var s=BX(i+"-"+t);var a=BX.findChildByClassName(s,"bx-messenger-file-download-disk");if(a){BX.removeClass(a,"bx-messenger-file-download-block");a.innerHTML=BX.message("IM_F_DOWNLOAD_DISK");this.messenger.tooltip(a,BX.message("IM_F_SAVE_ERR"))}else if(i=="im-file-history-panel"){a=BX.findChildByClassName(s,"bx-messenger-file-date");if(a){BX.removeClass(a.parentNode.parentNode,"bx-messenger-file-download-block");a.innerHTML=a.getAttribute("data-date")}}},this)})};BX.IM.DiskManager.prototype.deleteFile=function(e,t,s){if(!this.files[e]||!this.files[e][t])return false;if(this.files[e][t].saveToDiskBlock)return false;s=s||{};this.files[e][t].saveToDiskBlock=true;var i=s.boxId?s.boxId:"im-file";var a=BX(i+"-"+t);var n=BX.findChildByClassName(a,"bx-messenger-file-download-disk");if(n){BX.addClass(n,"bx-messenger-file-download-block");n.innerHTML=BX.message("IM_DELETING")}else if(i=="im-file-history-panel"){n=BX.findChildByClassName(a,"bx-messenger-file-date");if(n){BX.addClass(n.parentNode.parentNode,"bx-messenger-file-download-block");n.setAttribute("data-date",n.innerHTML);n.innerHTML=BX.message("IM_DELETING")}}BX.ajax({url:this.BXIM.pathToFileAjax+"?FILE_DELETE&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,timeout:30,data:{IM_FILE_DELETE:"Y",CHAT_ID:e,FILE_ID:t,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(s){delete this.files[e][t];var a=BX.MessengerCommon.getRecipientByChatId(e);if(BX("im-file-history-"+t)){this.messenger.drawHistory(a)}if(BX("im-file-"+t)){BX.MessengerCommon.drawTab(a,true)}var n=BX(i+"-"+t);BX.style(n,"transform","scale(0, 0)");BX.style(n,"height",n.offsetHeight+"px");setTimeout(function(){BX.style(n,"height","0px")},500);setTimeout(function(){BX.remove(n)},700);this.messenger.loadHistoryFiles(e,true)},this),onfailure:BX.delegate(function(){this.files[e][t].saveToDiskBlock=false;var s=BX(i+"-"+t);var a=BX.findChildByClassName(s,"bx-messenger-file-download-disk");
if(a){BX.removeClass(a,"bx-messenger-file-download-block");a.innerHTML=BX.message("IM_F_DOWNLOAD_DISK");this.messenger.tooltip(a,BX.message("IM_F_SAVE_ERR"))}else if(i=="im-file-history-panel"){a=BX.findChildByClassName(s,"bx-messenger-file-date");if(a){BX.removeClass(a.parentNode.parentNode,"bx-messenger-file-download-block");a.innerHTML=a.getAttribute("data-date")}}},this)})};BX.IM.DiskManager.prototype.openFileDialog=function(){this.messenger.setClosingByEsc(false);BX.ajax({url:this.BXIM.pathToFileAjax+"?action=selectFile&dialogName=im-file-dialog",method:"GET",skipAuthCheck:true,timeout:30,onsuccess:BX.delegate(function(e){if(typeof e=="object"&&e.error){this.messenger.setClosingByEsc(true)}},this),onfailure:BX.delegate(function(){this.messenger.setClosingByEsc(true)},this)})};BX.IM.DiskManager.prototype.initEventFileDialog=function(e){if(e!="im-file-dialog"||!BX.DiskFileDialog)return false;this.flagFileDialogInited=true;BX.DiskFileDialog.obCallback[e]={saveButton:BX.delegate(function(e,t,s){this.uploadFromDisk(e,t,s)},this),popupShow:BX.delegate(function(){BX.bind(BX.DiskFileDialog.popupWindow.popupContainer,"click",BX.MessengerCommon.preventDefault);this.messenger.setClosingByEsc(false)},this),popupDestroy:BX.delegate(function(){this.messenger.setClosingByEsc(true)},this)};BX.DiskFileDialog.openDialog(e)};BX.IM.DiskManager.prototype.uploadFromDisk=function(e,t,s,i){i=i||"";var a=this.messenger.popupMessengerFileFormChatId.value;if(!this.files[a])this.files[a]={};var n=[];for(var r in s){var o=r.replace("n","");this.files[a]["disk"+o]={id:"disk"+o,tempId:"disk"+o,chatId:a,date:s[r].modifyDateInt,type:"file",preview:"",name:s[r].name,size:s[r].sizeInt,status:"upload",progress:-1,authorId:this.BXIM.userId,authorName:this.messenger.users[this.BXIM.userId].name,urlPreview:"",urlShow:"",urlDownload:""};n.push("disk"+o)}var l=0;if(this.messenger.chat[a]){l="chat"+a}else{for(var p in this.messenger.userChat){if(this.messenger.userChat[p]==a){l=p;break}}}if(!l)return false;var h="tempFile"+this.fileTmpId;this.messenger.message[h]={id:h,chatId:a,senderId:this.BXIM.userId,recipientId:l,date:BX.MessengerCommon.getNowDate(),text:i,params:{FILE_ID:n}};if(!this.messenger.showMessage[l])this.messenger.showMessage[l]=[];this.messenger.showMessage[l].push(h);BX.MessengerCommon.drawMessage(l,this.messenger.message[h]);BX.MessengerCommon.drawProgessMessage(h);this.messenger.sendMessageFlag++;this.messenger.popupMessengerFileFormInput.setAttribute("disabled",true);BX.ajax({url:this.BXIM.pathToFileAjax+"?FILE_UPLOAD_FROM_DISK&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,timeout:30,data:{IM_FILE_UPLOAD_FROM_DISK:"Y",CHAT_ID:a,RECIPIENT_ID:l,MESSAGE:i,MESSAGE_TMP_ID:h,FILES:JSON.stringify(n),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(e.ERROR!=""){this.messenger.sendMessageFlag--;delete this.messenger.message[h];BX.MessengerCommon.drawTab(l);return false}this.messenger.sendMessageFlag--;var t=[];var s={};for(var i in e.FILES){var a=e.FILES[i];if(parseInt(a.id)>0){this.files[e.CHAT_ID][a.id]=a;delete this.files[e.CHAT_ID][i];if(BX("im-file-"+i)){BX("im-file-"+i).setAttribute("data-fileId",a.id);BX("im-file-"+i).id="im-file-"+a.id;BX.MessengerCommon.diskRedrawFile(e.CHAT_ID,a.id)}t.push(a.id)}else{this.files[e.CHAT_ID][i]["status"]="error";BX.MessengerCommon.diskRedrawFile(e.CHAT_ID,i)}}this.messenger.message[e.MESSAGE_ID]=BX.clone(this.messenger.message[e.MESSAGE_TMP_ID]);this.messenger.message[e.MESSAGE_ID]["id"]=e.MESSAGE_ID;this.messenger.message[e.MESSAGE_ID]["params"]["FILE_ID"]=t;if(this.messenger.popupMessengerLastMessage==e.MESSAGE_TMP_ID)this.messenger.popupMessengerLastMessage=e.MESSAGE_ID;delete this.messenger.message[e.MESSAGE_TMP_ID];var n=BX.util.array_search(""+e.MESSAGE_TMP_ID+"",this.messenger.showMessage[e.RECIPIENT_ID]);if(this.messenger.showMessage[e.RECIPIENT_ID][n])this.messenger.showMessage[e.RECIPIENT_ID][n]=""+e.MESSAGE_ID+"";if(BX("im-message-"+e.MESSAGE_TMP_ID)){BX("im-message-"+e.MESSAGE_TMP_ID).id="im-message-"+e.MESSAGE_ID;var r=BX.findChild(this.messenger.popupMessengerBodyWrap,{attribute:{"data-messageid":""+e.MESSAGE_TMP_ID}},true);if(r){r.setAttribute("data-messageid",""+e.MESSAGE_ID+"");if(r.getAttribute("data-blockmessageid")==""+e.MESSAGE_TMP_ID)r.setAttribute("data-blockmessageid",""+e.MESSAGE_ID+"")}else{var o=BX.findChild(this.messenger.popupMessengerBodyWrap,{attribute:{"data-blockmessageid":""+e.MESSAGE_TMP_ID}},true);if(o){o.setAttribute("data-blockmessageid",""+e.MESSAGE_ID+"")}}var p=BX.findChildByClassName(r,"bx-messenger-content-item-date");if(p)p.innerHTML=" "+BX.MessengerCommon.formatDate(this.messenger.message[e.MESSAGE_ID].date,BX.MessengerCommon.getDateFormatType("MESSAGE"))}BX.MessengerCommon.clearProgessMessage(e.MESSAGE_ID);if(this.messenger.history[e.RECIPIENT_ID])this.messenger.history[e.RECIPIENT_ID].push(e.MESSAGE_ID);else this.messenger.history[e.RECIPIENT_ID]=[e.MESSAGE_ID];if(BX.MessengerCommon.enableScroll(this.messenger.popupMessengerBody,200)){if(this.BXIM.animationSupport){if(this.messenger.popupMessengerBodyAnimation!=null)this.messenger.popupMessengerBodyAnimation.stop();(this.messenger.popupMessengerBodyAnimation=new BX.easing({duration:800,start:{scroll:this.messenger.popupMessengerBody.scrollTop},finish:{scroll:this.messenger.popupMessengerBody.scrollHeight-this.messenger.popupMessengerBody.offsetHeight},transition:BX.easing.makeEaseInOut(BX.easing.transitions.quart),step:BX.delegate(function(e){this.messenger.popupMessengerBody.scrollTop=e.scroll},this)})).animate()}else{this.messenger.popupMessengerBody.scrollTop=this.messenger.popupMessengerBody.scrollHeight-this.messenger.popupMessengerBody.offsetHeight}}this.messenger.popupMessengerFileFormInput.removeAttribute("disabled")},this),onfailure:BX.delegate(function(){this.messenger.sendMessageFlag--;delete this.messenger.message[h];BX.MessengerCommon.drawTab(l)},this)});this.fileTmpId++};BX.IM.DiskManager.prototype.chatAvatarInit=function(){if(!BX.Uploader)return false;if(this.messenger.popupMessengerPanelAvatarUpload2){this.formAgents["popupMessengerPanelAvatarUpload2"]=BX.Uploader.getInstance({id:"popupMessengerPanelAvatarUpload2",allowUpload:"I",uploadMethod:"immediate",showImage:false,input:this.messenger.popupMessengerPanelAvatarUpload2,dropZone:this.messenger.popupMessengerPanelAvatarUpload2.parentNode});BX.addCustomEvent(this.formAgents["popupMessengerPanelAvatarUpload2"],"onFileinputIsReinited",BX.delegate(function(e){if(!e&&!this.formAgents["popupMessengerPanelAvatarUpload2"].fileInput)return false;this.messenger.popupMessengerPanelAvatarUpload2=e?e:this.formAgents["popupMessengerPanelAvatarUpload2"].fileInput},this));BX.addCustomEvent(this.formAgents["popupMessengerPanelAvatarUpload2"],"onFileIsInited",BX.delegate(function(e,t,s){this.chatAvatarAttached(s);BX.addCustomEvent(t,"onUploadDone",BX.delegate(this.chatAvatarDone,this));BX.addCustomEvent(t,"onUploadError",BX.delegate(this.chatAvatarError,this))},this))}if(this.messenger.popupMessengerPanelAvatarUpload3){this.formAgents["popupMessengerPanelAvatarUpload3"]=BX.Uploader.getInstance({id:"popupMessengerPanelAvatarUpload3",allowUpload:"I",uploadMethod:"immediate",showImage:false,input:this.messenger.popupMessengerPanelAvatarUpload3,dropZone:this.messenger.popupMessengerPanelAvatarUpload3.parentNode});BX.addCustomEvent(this.formAgents["popupMessengerPanelAvatarUpload3"],"onFileinputIsReinited",BX.delegate(function(e){if(!e&&!this.formAgents["popupMessengerPanelAvatarUpload3"].fileInput)return false;this.messenger.popupMessengerPanelAvatarUpload3=e?e:this.formAgents["popupMessengerPanelAvatarUpload3"].fileInput},this));BX.addCustomEvent(this.formAgents["popupMessengerPanelAvatarUpload3"],"onFileIsInited",BX.delegate(function(e,t,s){this.chatAvatarAttached(s);BX.addCustomEvent(t,"onUploadDone",BX.delegate(this.chatAvatarDone,this));BX.addCustomEvent(t,"onUploadError",BX.delegate(this.chatAvatarError,this))},this))}};BX.IM.DiskManager.prototype.avatarFormIsBlocked=function(e,t,s){result=this.formBlocked[t+"_"+e]?true:false;element=this.messenger[t];if(this.messenger.currentTab=="chat"+e){if(element){if(result){element.title="";element.disabled=true}else{element.title=BX.message("IM_M_AVATAR_UPLOAD");element.removeAttribute("disabled")}}if(s){if(result){BX.addClass(s.firstChild,"bx-messenger-panel-avatar-progress-on")}else{BX.removeClass(s.firstChild,"bx-messenger-panel-avatar-progress-on")}BX.removeClass(s,"bx-messenger-panel-avatar-upload-error")}}return result};BX.IM.DiskManager.prototype.chatAvatarAttached=function(e){if(!e.form.CHAT_ID)return false;this.formBlocked[e.id+"_"+e.form.CHAT_ID.value]=true;this.avatarFormIsBlocked(e.form.CHAT_ID.value,e.id,e.form)};BX.IM.DiskManager.prototype.chatAvatarDone=function(e,t,s,i){this.formBlocked[s.id+"_"+t.file.chatId]=false;this.avatarFormIsBlocked(t.file.chatId,s.id,s.form);this.messenger.updateChatAvatar(t.file.chatId,t.file.chatAvatar)};BX.IM.DiskManager.prototype.chatAvatarError=function(e,t,s,i){var a=s.streams.packages.getItem(i).data;this.formBlocked[s.id+"_"+a.CHAT_ID]=false;this.avatarFormIsBlocked(a.CHAT_ID,s.id,s.form);BX.addClass(s.form,"bx-messenger-panel-avatar-upload-error");s.fileInput.title=t.error};BX.IM.NotifyManager=function(e){this.stack=[];this.stackTimeout=null;this.stackPopup={};this.stackPopupTimeout={};this.stackPopupTimeout2={};this.stackPopupId=0;this.stackOverflow=false;this.blockNativeNotify=false;this.blockNativeNotifyTimeout=null;this.notifyShow=0;this.notifyHideTime=5e3;this.notifyHeightCurrent=10;this.notifyHeightMax=0;this.notifyGarbageTimeout=null;this.notifyAutoHide=true;this.notifyAutoHideTimeout=null;if(BX.browser.SupportLocalStorage()){BX.addCustomEvent(window,"onLocalStorageSet",BX.proxy(this.storageSet,this))}this.BXIM=e};BX.IM.NotifyManager.prototype.storageSet=function(e){if(e.key=="mnnb"){this.blockNativeNotify=true;clearTimeout(this.blockNativeNotifyTimeout);this.blockNativeNotifyTimeout=setTimeout(BX.delegate(function(){this.blockNativeNotify=false},this),1e3)}};BX.IM.NotifyManager.prototype.add=function(e){if(typeof e!="object"||!e.html)return false;if(BX.type.isDomNode(e.html))e.html=e.html.outerHTML;this.stack.push(e);if(!this.stackOverflow)this.setShowTimer(300)};BX.IM.NotifyManager.prototype.remove=function(e){delete this.stack[e]};BX.IM.NotifyManager.prototype.draw=function(){this.show()};BX.IM.NotifyManager.prototype.show=function(){this.notifyHeightMax=document.body.offsetHeight;var e=BX.GetWindowScrollPos();for(var t=0;t<this.stack.length;t++){if(typeof this.stack[t]=="undefined")continue;var s=new BX.PopupWindow("bx-im-notify-flash-"+this.stackPopupId,{top:"-1000px",left:0},{lightShadow:true,zIndex:200,events:{onPopupClose:BX.delegate(function(){BX.proxy_context.popupContainer.style.opacity=0;this.notifyShow--;this.notifyHeightCurrent-=BX.proxy_context.popupContainer.offsetHeight+10;this.stackOverflow=false;setTimeout(BX.delegate(function(){this.destroy()},BX.proxy_context),1500)},this),onPopupDestroy:BX.delegate(function(){BX.unbindAll(BX.findChildByClassName(BX.proxy_context.popupContainer,"bx-notifier-item-delete"));BX.unbindAll(BX.proxy_context.popupContainer);delete this.stackPopup[BX.proxy_context.uniquePopupId];delete this.stackPopupTimeout[BX.proxy_context.uniquePopupId];delete this.stackPopupTimeout2[BX.proxy_context.uniquePopupId]},this)},bindOnResize:false,content:BX.create("div",{props:{className:"bx-notifyManager-item"},html:this.stack[t].html})});s.notifyParams=this.stack[t];s.notifyParams.id=t;s.show();BX.onCustomEvent(window,"onNotifyManagerShow",[this.stack[t]]);s.popupContainer.style.left=document.body.offsetWidth-s.popupContainer.offsetWidth-10+"px";s.popupContainer.style.opacity=0;if(this.notifyHeightMax<this.notifyHeightCurrent+s.popupContainer.offsetHeight+10){if(this.notifyShow>0){s.destroy();this.stackOverflow=true;break}}BX.addClass(s.popupContainer,"bx-notifyManager-animation");s.popupContainer.style.opacity=1;s.popupContainer.style.top=e.scrollTop+this.notifyHeightCurrent+"px";this.notifyHeightCurrent=this.notifyHeightCurrent+s.popupContainer.offsetHeight+10;this.stackPopupId++;this.notifyShow++;this.remove(t);this.stackPopupTimeout[s.uniquePopupId]=null;BX.bind(s.popupContainer,"mouseover",BX.delegate(function(){this.clearAutoHide()},this));BX.bind(s.popupContainer,"mouseout",BX.delegate(function(){this.setAutoHide(this.notifyHideTime/2)},this));BX.bind(s.popupContainer,"contextmenu",BX.delegate(function(e){if(this.stackPopup[BX.proxy_context.id].notifyParams.tag)this.closeByTag(this.stackPopup[BX.proxy_context.id].notifyParams.tag);else this.stackPopup[BX.proxy_context.id].close();return BX.PreventDefault(e)},this));var i=BX.findChildren(s.popupContainer,{tagName:"a"},true);for(var a=0;a<i.length;a++){if(i[a].href!="#")i[a].target="_blank"}BX.bind(BX.findChildByClassName(s.popupContainer,"bx-notifier-item-delete"),"click",BX.delegate(function(e){var t=BX.proxy_context.parentNode.parentNode.parentNode.parentNode.id.replace("popup-window-content-","");if(this.stackPopup[t].notifyParams.close)this.stackPopup[t].notifyParams.close(this.stackPopup[t]);this.stackPopup[t].close();if(this.notifyAutoHide==false){this.clearAutoHide();this.setAutoHide(this.notifyHideTime/2)}return BX.PreventDefault(e)},this));BX.bindDelegate(s.popupContainer,"click",{className:"bx-notifier-item-button-confirm"},BX.delegate(function(e){var t=BX.proxy_context.getAttribute("data-id");this.BXIM.notify.confirmRequest({notifyId:t,notifyValue:BX.proxy_context.getAttribute("data-value"),notifyURL:BX.proxy_context.getAttribute("data-url"),notifyTag:this.BXIM.notify.notify[t]&&this.BXIM.notify.notify[t].tag?this.BXIM.notify.notify[t].tag:null,groupDelete:BX.proxy_context.getAttribute("data-group")!=null},true);for(var s in this.stackPopup){if(this.stackPopup[s].notifyParams.notifyId==t)this.stackPopup[s].close()}if(this.notifyAutoHide==false){this.clearAutoHide();this.setAutoHide(this.notifyHideTime/2)}return BX.PreventDefault(e)},this));if(s.notifyParams.click){s.popupContainer.style.cursor="pointer";BX.bind(s.popupContainer,"click",BX.delegate(function(e){this.notifyParams.click(this);if(this.notifyParams.notifyId!="network")return BX.PreventDefault(e)},s))}this.stackPopup[s.uniquePopupId]=s}if(this.stack.length>0){this.clearAutoHide(true);this.setAutoHide(this.notifyHideTime)}this.garbage()};BX.IM.NotifyManager.prototype.closeByTag=function(e){for(var t=0;t<this.stack.length;t++){if(typeof this.stack[t]!="undefined"&&this.stack[t].tag==e){delete this.stack[t]}}for(var t in this.stackPopup){if(this.stackPopup[t].notifyParams.tag==e)this.stackPopup[t].close()}};BX.IM.NotifyManager.prototype.setShowTimer=function(e){clearTimeout(this.stackTimeout);this.stackTimeout=setTimeout(BX.delegate(this.draw,this),e)};BX.IM.NotifyManager.prototype.setAutoHide=function(e){this.notifyAutoHide=true;clearTimeout(this.notifyAutoHideTimeout);this.notifyAutoHideTimeout=setTimeout(BX.delegate(function(){for(var t in this.stackPopupTimeout){this.stackPopupTimeout[t]=setTimeout(BX.delegate(function(){this.close()},this.stackPopup[t]),e-1e3);this.stackPopupTimeout2[t]=setTimeout(BX.delegate(function(){this.setShowTimer(300)},this),e-700)}},this),1e3)};BX.IM.NotifyManager.prototype.clearAutoHide=function(e){clearTimeout(this.notifyGarbageTimeout);this.notifyAutoHide=false;e=e==true;if(e){clearTimeout(this.stackTimeout);for(var t in this.stackPopupTimeout){clearTimeout(this.stackPopupTimeout[t]);clearTimeout(this.stackPopupTimeout2[t])}}else{clearTimeout(this.notifyAutoHideTimeout);this.notifyAutoHideTimeout=setTimeout(BX.delegate(function(){clearTimeout(this.stackTimeout);for(var e in this.stackPopupTimeout){clearTimeout(this.stackPopupTimeout[e]);clearTimeout(this.stackPopupTimeout2[e])}},this),300)}};BX.IM.NotifyManager.prototype.garbage=function(){clearTimeout(this.notifyGarbageTimeout);this.notifyGarbageTimeout=setTimeout(BX.delegate(function(){var e=[];for(var t=0;t<this.stack.length;t++){if(typeof this.stack[t]!="undefined")e.push(this.stack[t])}this.stack=e},this),1e4)};BX.IM.NotifyManager.prototype.nativeNotify=function(e,t){if(!e.title||e.title.length<=0)return false;if(this.blockNativeNotify)return false;if(!t){setTimeout(BX.delegate(function(){if(this.blockNativeNotify)return false;this.nativeNotify(e,true)},this),Math.floor(Math.random()*151)+50);return true}BX.localStorage.set("mnnb",true,1);var s=new Notification(e.title,{tag:e.tag?e.tag:"",body:e.text?e.text:"",icon:e.icon?e.icon:""});if(typeof e.onshow=="function")s.onshow=e.onshow;if(typeof e.onclick=="function")s.onclick=e.onclick;if(typeof e.onclose=="function")s.onclose=e.onclose;if(typeof e.onerror=="function")s.onerror=e.onerror;return true};BX.IM.NotifyManager.prototype.nativeNotifyShow=function(){this.show()};BX.IM.NotifyManager.prototype.nativeNotifyGranted=function(){return window.Notification&&window.Notification.permission&&window.Notification.permission.toLowerCase()=="granted"};BX.IM.NotifyManager.prototype.nativeNotifyAccessForm=function(){if(!this.BXIM.xmppStatus&&!this.BXIM.desktopStatus&&this.BXIM.settings.nativeNotify&&window.Notification&&window.Notification.permission&&window.Notification.permission.toLowerCase()=="default"){clearTimeout(this.popupMessengerDesktopTimeout);var e=BX.delegate(function(){Notification.requestPermission();BXIM.messenger.hideTopLine()},this);var t=BX.delegate(function(){this.BXIM.settings.nativeNotify=false;this.BXIM.saveSettings({nativeNotify:this.BXIM.settings.nativeNotify});BXIM.messenger.hideTopLine()},this);BXIM.messenger.showTopLine(BX.message("IM_WN_MAC")+"<br />"+BX.message("IM_WN_TEXT"),[{title:BX.message("IM_WN_ACCEPT"),callback:e},{title:BX.message("IM_DESKTOP_INSTALL_N"),callback:t}])}else{return false}return true};BX.IM.LevelMeter=function(e){this.element=e;this.maximumLevel=1;this.mediaStream=null;this.audioContext=null;this.mediaStreamNode=null;this.scriptNode=null;this.instant=0;this.slow=0;this.clip=0;this.supported=window.AudioContext||window.webkitAudioContext;this.animationInterval=null;this.mask=BX.create("div",{attrs:{className:"bx-messenger-settings-level-meter-mask"}});this.filler=BX.create("div",{attrs:{className:"bx-messenger-settings-level-meter-filler"}});this.element.appendChild(this.mask);this.mask.appendChild(this.filler)};BX.IM.LevelMeter.prototype.render=function(){var e=Math.floor(this.slow*100);this.filler.style.width=e+"%"};BX.IM.LevelMeter.prototype.attachMediaStream=function(e){var t=this;if(!(e instanceof MediaStream))return;this.stop();this.audioContext=new(window.AudioContext||window.webkitAudioContext);this.scriptNode=this.audioContext.createScriptProcessor(2048,1,1);this.scriptNode.connect(this.audioContext.destination);this.mediaStream=e;this.mediaStreamNode=this.audioContext.createMediaStreamSource(this.mediaStream);this.mediaStreamNode.connect(this.scriptNode);this.scriptNode.onaudioprocess=function(e){var s=e.inputBuffer.getChannelData(0);var i;var a=0;var n=0;for(i=0;i<s.length;++i){a+=s[i]*s[i];if(Math.abs(s[i])>.99){n+=1}}t.instant=Math.sqrt(a/s.length);t.slow=.75*t.slow+.25*t.instant;t.clip=n/s.length};this.animationInterval=setInterval(this.render.bind(this),200)};BX.IM.LevelMeter.prototype.getVolume=function(){return{instant:this.instant,slow:this.slow}};BX.IM.LevelMeter.prototype.stop=function(){if(this.scriptNode)this.scriptNode.disconnect();if(this.mediaStreamNode)this.mediaStreamNode.disconnect();if(this.audioContext)this.audioContext.close();if(this.animationInterval)clearInterval(this.animationInterval);this.scriptNode=null;this.mediaStreamNode=null;this.mediaStream=null;this.audioContext=null;this.animationInterval=null}})();(function(){if(BX.desktopUtils)return;BX.desktopUtils=function(){this.runningCheckTimeout={};this.checkUrl="http://127.0.0.1:20141/"};BX.desktopUtils.prototype.runningCheck=function(e,t,s){if(typeof e=="undefined"){return false}if(typeof t=="undefined"){t=function(){}}s=typeof s=="undefined"||!s?false:true;var i=+new Date;if(typeof BXIM=="undefined"||BXIM.desktop.ready()||!BXIM.desktopStatus||BXIM.desktopVersion<18){t(false,i);return false}else if(BXIM.desktopVersion<35){if(s){t(false,i)}else{e(true,i)}return true}var a=BX.create("img",{attrs:{src:this.checkUrl+"icon.png?"+i,"data-id":i},props:{className:"bx-messenger-out-of-view"},events:{error:function(){var e=this.getAttribute("data-id");t(false,e);clearTimeout(BX.desktopUtils.runningCheckTimeout[e]);BX.remove(this)},load:function(){var t=this.getAttribute("data-id");e(true,t);clearTimeout(BX.desktopUtils.runningCheckTimeout[t]);BX.remove(this)}}});document.body.appendChild(a);this.runningCheckTimeout[i]=setTimeout(function(){t(false,i);clearTimeout(BX.desktopUtils.runningCheckTimeout[i]);BX.remove(this)},500);return true};BX.desktopUtils.prototype.goToBx=function(e){if(typeof BXIM!="undefined"&&BXIM.desktopVersion>=36&&!e.match(/^bx:\/\/v(\d)\//)){e=e.replace("bx://","bx://v"+BXIM.desktopProtocolVersion+"/"+location.hostname+"/")}if(typeof BX.PULL!="undefined"&&typeof BX.PULL.setPrivateVar!="undefined"){BX.PULL.setPrivateVar("_pullTryAfterBxLink",true)}location.href=e};BX.desktopUtils.prototype.isChangedLocationToBx=function(){if(typeof BX.PULL!="undefined"&&typeof BX.PULL.setPrivateVar!="undefined")return BX.PULL.returnPrivateVar("_pullTryAfterBxLink");return false};BX.desktopUtils=new BX.desktopUtils})();
//# sourceMappingURL=im.map.js