Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/im/ |
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/im/im.min.js |
(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=119;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.colorsHex=t.colorsHex;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.micTestMediaStream=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.linesCount=t.linesCount||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=="POPUP-FULLSCREEN"&&BX.browser.IsMobile()){this.design="POPUP"}if(this.context=="DESKTOP"||this.context=="FULLSCREEN"||this.context=="PAGE"||this.context=="DIALOG"||this.context=="LINES"||this.context=="POPUP-FULLSCREEN"){if(this.context=="DESKTOP"){BX.desktop.init({context:this.context,design:this.design,bxim:this})}if(BX.MessengerCommon.isPage()){BX.MessengerWindow.init({context:this.context,design:this.design,bxim:this})}}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,phoneCanPerformCalls:t.webrtc&&t.webrtc.phoneCanPerformCalls=="Y"||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||{},phoneLines:t.webrtc&&t.webrtc.phoneLines||{},phoneDefaultLineId:t.webrtc&&t.webrtc.phoneDefaultLineId||"",phoneAvailableLines:t.webrtc&&t.webrtc.availableLines||[],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")});BX.PhoneCallView.setDefaults({restApps:t.webrtc&&t.webrtc.phoneCallCardRestApps||[],callInterceptAllowed:t.webrtc&&t.webrtc.phoneCanInterceptCall||false});this.desktop.webrtc=this.webrtc;if(this.init){if(BX.MessengerCommon.isDesktop()){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=new Date(t.notify[s].date);if(parseInt(s)>this.lastRecordId)this.lastRecordId=parseInt(s)}for(var s in t.message){t.message[s].date=new Date(t.message[s].date);if(parseInt(s)>this.lastRecordId)this.lastRecordId=parseInt(s)}for(var s in t.recent){t.recent[s].date=new Date(t.recent[s].date)}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,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,enableExternal:t.disk&&t.disk.external});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||{},userChatOptions:t.userChatOptions||{},userInGroup:t.userInGroup||{},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,tooltipShowed:t.tooltipShowed||{},bot:t.bot||{},command:t.command||[],textareaIcon:t.textareaIcon||[],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(BX.MessengerCommon.isDesktop()&&!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(BX.MessengerCommon.isDesktop())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(!BX.MessengerCommon.isPage()&&(this.messenger==null||this.messenger.popupMessenger==null))return false;if(e=="dialog"){if(BX.MessengerCommon.isPage()&&BX.MessengerWindow.getCurrentTab()!="im"&&BX.MessengerWindow.getCurrentTab()!="im-phone"&&BX.MessengerWindow.getCurrentTab()!="im-ol")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(BX.MessengerCommon.isPage()&&BX.MessengerWindow.getCurrentTab()!="notify"&&BX.MessengerWindow.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={start:true,dialtone:true,ringtone: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(e){this.audio.current=null}};BX.IM.prototype.repeatSound=function(e,t){t=parseInt(t)||1e3;t=t>=1e3?t:1e3;if(this.audio.timeout[e])clearTimeout(this.audio.timeout[e]);if(BX.MessengerCommon.isDesktop()||!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.linesCount>0)s+=parseInt(this.linesCount);if(BX.MessengerCommon.isPage()){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+this.linesCount>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+this.linesCount>0)a=BX.message("IM_DESKTOP_UNREAD_MESSAGES");else if(this.notify!=null&&this.notify.getCounter("**")>0)a=BX.message("IM_DESKTOP_UNREAD_LF");if(BX.MessengerCommon.isDesktop()){BX.desktop.setIconTooltip(a);BX.desktop.setIconBadge(i,this.messageCount+this.linesCount>0)}}if(BX.MessengerCommon.isPage()&&this.notify){var n=this.notify.getCounter("**");BX.MessengerWindow.setTabBadge("im-lf",n)}BX.onCustomEvent(window,"onImUpdateSumCounters",[s,"SUM"]);if(this.settings.status!="dnd"&&!this.desktopStatus&&s>0){if(!BX.MessengerCommon.isDesktop()&&document.title!="("+s+") "+this.windowTitle)document.title="("+s+") "+this.windowTitle;if(this.notify.panelButtonMessage){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(!BX.MessengerCommon.isDesktop()&&document.title!=this.windowTitle)document.title=this.windowTitle;if(this.notify.panelButtonMessage){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;if(!this.settings.openDesktopFromPanel){BX.defer(function(){if(BX.MessengerCommon.isPage()){if(BX.MessengerWindow.currentTab!="notify"){BX.MessengerWindow.changeTab("im",true)}this.notify.openNotify(false,true);setTimeout(function(){BX.MessengerWindow.changeTab("notify",true)},100)}else{this.notify.openNotify(false,true)}},this)();return false}BX.desktopUtils.runningCheck(function(){BX.desktopUtils.goToBx("bx://notify")},BX.defer(function(){if(BX.MessengerCommon.isPage()){if(BX.MessengerWindow.currentTab!="notify"){BX.MessengerWindow.changeTab("im",true)}this.notify.openNotify(false,true);setTimeout(function(){BX.MessengerWindow.changeTab("notify",true)},100)}else{this.notify.openNotify(false,true)}},this))};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.sendMessage=function(e,t){if(!t&&!e)return false;if(!t){t=e;e=this.messenger.currentTab}var s=this.messenger.popupMessengerTextarea.value;this.messenger.popupMessengerTextarea.value=t;this.messenger.sendMessage(e);setTimeout(BX.delegate(function(){this.messenger.popupMessengerTextarea.value=s;this.messenger.textareaCheckText()},this),10);return true};BX.IM.prototype.putMessage=function(e){BX.addClass(this.messenger.popupMessengerTextarea.parentNode,"bx-messenger-textarea-focus");this.messenger.popupMessengerTextarea.focus();this.messenger.insertTextareaText(this.messenger.popupMessengerTextarea,e+" ",false);this.messenger.textareaHistory[this.messenger.currentTab]=e+" ";return true};BX.IM.prototype.phoneTo=function(e,t){t=t?t:{};var s=t["LINE_ID"]?t["LINE_ID"]:this.webrtc.phoneDefaultLineId;if(typeof t!="object"){try{t=JSON.parse(t)}catch(e){t={}}}if(this.webrtc.isRestLine(s)){BX.MessengerCommon.phoneStartCallViaRestApp(e,s,t);return true}if(!BX.MessengerCommon.isDesktop()&&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();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.startCallList=function(e,t){t=t?t:{};e=parseInt(e);if(e==0)return;if(!this.desktop.ready()&&this.desktopStatus&&this.desktopVersion>=18){BX.desktopUtils.runningCheck(function(){BX.desktopUtils.goToBx("bx://calllist/id/"+e+/params/+BX.desktopUtils.encodeParams(t))},BX.delegate(function(){this.webrtc.startCallList(e,t)},this))}else{this.webrtc.startCallList(e,t)}return true};BX.IM.prototype.checkCallSupport=function(){return this.webrtc.callSupport()};BX.IM.prototype.addPopupMenuModifier=function(e){this.messenger.popupPopupMenuModifyFunction.push(e);return true};BX.IM.prototype.openMessengerSlider=function(e,t){t=t||{};t.SLIDER="Y";BX.defer(function(){if(e&&e.toString().substr(0,4)=="imol"){this.messenger.linesOpenMessenger(e.toString().substr(5),t)}else{this.messenger.openMessengerSlider(e,t)}},this)()};BX.IM.prototype.openMessenger=function(e,t,s){e=e===false?false:e;s=s?true:false;if(!this.settings.openDesktopFromPanel||s){BX.defer(function(){if(e&&e.toString().substr(0,4)=="imol"){this.messenger.linesOpenMessenger(e.toString().substr(5))}else{this.messenger.openMessenger(e);if(t){BX.MessengerWindow.changeTab(t,true)}}},this)();return false}BX.desktopUtils.runningCheck(function(){BX.desktopUtils.goToBx(e===false?"bx://messenger":"bx://messenger/dialog/"+encodeURIComponent(e)+"/tab/"+t)},BX.defer(function(){if(e&&e.toString().substr(0,4)=="imol"){this.messenger.linesOpenMessenger(e.toString().substr(5))}else{this.messenger.openMessenger(e);if(t){BX.MessengerWindow.changeTab(t,true)}}},this));return false};BX.IM.prototype.closeMessenger=function(){this.messenger.popupMessenger.close()};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"){setTimeout(BX.delegate(function(){this.messenger.linesOpenHistory(e.toString().substr(5))},this),300)}else{setTimeout(BX.delegate(function(){this.messenger.openHistory(e)},this),10)}};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){if(typeof e=="number"&&this.revision<e){if(BX.MessengerCommon.isDesktop()||this.context=="PAGE"){console.log("NOTICE: Window reload, because REVISION UP ("+this.revision+" -> "+e+")");BX.MessengerWindow.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(!BX.MessengerCommon.isPage())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})}}var i=BX.MessengerCommon.isPage()&&this.bitrixOpenLines?true:false;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)},{type:"space"},i?{title:BX.message("IM_M_VIEW_OL_LIST"),type:"checkbox",name:"linesTabEnable",checked:this.settings.linesTabEnable,saveCallback:BX.delegate(function(e){this.messenger.toggleLinesTab(e.checked);return e.checked},this)}:null,i?{title:BX.message("IM_M_VIEW_OL_NEW"),type:"checkbox",name:"linesNewGroupEnable",checked:this.settings.linesNewGroupEnable,saveCallback:BX.delegate(function(e){this.messenger.toggleLinesNewGroup(e.checked);return e.checked},this)}:null,i?{type:"space"}:null,{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_RICH_LINK_ON"),type:"checkbox",name:"enableRichLink",checked:this.settings.enableRichLink},{title:BX.message("IM_M_ENABLE_SOUND"),type:"checkbox",name:"enableSound",checked:this.settings.enableSound},BX.MessengerCommon.isDesktop()?{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_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.desktopVersion?{title:BX.message("IM_M_OPEN_DESKTOP_FROM_PANEL"),type:"checkbox",name:"openDesktopFromPanel",checked:this.settings.openDesktopFromPanel}:null,BX.MessengerCommon.isDesktop()?{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",{children:[BX.create("div",{props:{className:"bx-messenger-content-item-progress"}}),BX.create("span",{props:{className:"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_SPEAKER"),type:"select",name:"defaultSpeaker",items:{},saveCallback:function(e){if(!localStorage)return e.value;localStorage.setItem("bx-im-settings-default-speaker",e.value)}},{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(BX.MessengerCommon.isDesktop()){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(!BX.MessengerCommon.isPage()&&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(BX.MessengerCommon.isDesktop())this.desktop.autoResize()},this));if(this.settings.notifyScheme=="simple")this.GetSimpleNotifySettings();else this.GetNotifySettings();if(!BX.MessengerCommon.isDesktop())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 o={};if(this.settingsView[n].click)o={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:o}));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 r=[];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)r.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:r}));i=false}t.push(BX.create("div",{props:{className:"bx-messenger-settings-contents"},children:s}));if(BX.MessengerCommon.isDesktop()){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 o=0;o<t.rows[a].length;o++){if(typeof t.rows[a][o]!="object"||t.rows[a][o]===null)continue;var r={};var l={};if(t.rows[a][o].type=="separator"){r={colspan:t.headers.length};l={className:"bx-messenger-settings-table-sep"}}else if(t.rows[a][o].type=="error"){r={colspan:t.headers.length};l={className:"bx-messenger-settings-table-error"}}if(typeof this.settingsDisabled[t.rows[a][o].name]!="undefined"){t.rows[a][o].disabled=this.settingsDisabled[t.rows[a][o].name]}n.push(BX.create("td",{attrs:r,props:l,children:this.prepareSettingsItem(t.rows[a][o])}))}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);var i=null;if(s.tooltip){i=BX.create("span",{props:{className:"bx-messenger-settings-tooltip"},attrs:{"data-tooltip":s.tooltip},html:"i",events:{click:BX.delegate(function(e){this.messenger.tooltip(BX.proxy_context,BX.proxy_context.getAttribute("data-tooltip"),{angle:false,width:300});BX.PreventDefault(e)},this)}})}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 a={click:s.callback};t.push(BX.create("span",{props:{className:"bx-messenger-settings-link"},attrs:s.attrs,html:s.title,events:a}))}if(s.type=="checkbox"){if(s.callback)var a={change:s.callback};if(typeof s.checked=="undefined")s.checked=this.settings[s.name]!=false;var n={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)n["data-save"]=1;var o=BX.create("input",{attrs:n,events:a});t.push(BX.create("div",{style:{whiteSpace:"nowrap"},children:[o,i]}));if(s.saveCallback)this.settingsSaveCallback[s.name]=s.saveCallback}else if(s.type=="select"){if(s.callback)var a={change:s.callback};var r=[];for(var l=0;l<s.items.length;l++){r.push(BX.create("option",{attrs:{value:s.items[l].value,selected:s.value==s.items[l].value?"true":false},html:s.items[l].title}))}var n={name:s.name};if(s.name)n["data-save"]=1;var o=BX.create("select",{attrs:n,events:a,children:r});t.push(BX.create("div",{style:{whiteSpace:"nowrap"},children:[o,i]}));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 p=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:p}}),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:p}}),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]"),speakerSelect:document.querySelector("[name=defaultSpeaker]"),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(BX.MessengerCommon.isDesktop()){BX.desktop.resize()}})}if(!this.webrtc.enabled){console.log("webrtc is not supported");return}var s={audio:false,video:false};var i={audioInput:false,videoInput:false,audioOutput:false};var a={audioInput:false,videoInput:false,audioOutput:false};navigator.mediaDevices.enumerateDevices().then(function(t){t.forEach(function(t){if(t.kind=="audioinput"){i.audioInput=true;if(e.webrtc.defaultMicrophone===t.deviceId){a.audioInput=true}}else if(t.kind=="videoinput"){i.videoInput=true;if(e.webrtc.defaultCamera===t.deviceId){a.videoInput=true}}else if(t.kind=="audiooutput"){i.audioOutput=true;if(e.webrtc.defaultSpeaker===t.deviceId){a.audioOutput=true}}});if(!a.audioInput){window.localStorage.removeItem("bx-im-settings-default-microphone");e.webrtc.defaultMicrophone=""}if(!a.videoInput){window.localStorage.removeItem("bx-im-settings-default-camera");e.webrtc.defaultCamera=""}if(!a.audioOutput){window.localStorage.removeItem("bx-im-settings-default-speaker");e.webrtc.defaultSpeaker=""}if(i.audioInput){if(e.webrtc.defaultMicrophone)s.audio={deviceId:{exact:e.webrtc.defaultMicrophone}};else s.audio=true}if(i.videoInput){if(e.webrtc.defaultCamera)s.video={deviceId:{exact:e.webrtc.defaultCamera}};else s.video=true}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(BX.MessengerCommon.isDesktop()){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,o){if(s&&t.micSelect.options.length==0&&t.camSelect.options.length==0){s.forEach(function(s){var n;var o=false;var r=false;var l=false;var p=s.label==""?BX.message("IM_SETTINGS_HARDWARE_DEFAULT_MICROPHONE"):s.label;if(s.kind=="audioinput"){o=true;n=BX.create("option",{text:p,attrs:{value:s.deviceId}});if(s.label===a||s.deviceId===e.webrtc.defaultMicrophone){n.selected=true}t.micSelect.options.add(n)}else if(s.kind=="videoinput"){l=true;n=BX.create("option",{text:p,attrs:{value:s.deviceId}});if(s.label===i||s.deviceId===e.webrtc.defaultCamera){n.selected=true}t.camSelect.options.add(n)}else if(s.kind=="audiooutput"){r=true;n=BX.create("option",{text:p,attrs:{value:s.deviceId}});if(s.deviceId===e.webrtc.defaultSpeaker){n.selected=true}t.speakerSelect.options.add(n)}});n()}else{o()}})}).catch(function(e){console.log("could not access user hardware. constraints were: ",s);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(BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isDesktop())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(BX.MessengerCommon.isDesktop())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(BX.MessengerCommon.isDesktop())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(BX.MessengerCommon.isDesktop())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(BX.MessengerCommon.isDesktop())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;var i=t===false;if(typeof t=="undefined"||typeof t=="object"&&t.length<=0||t===false){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:15e3,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);if(i===true){setTimeout(BX.delegate(function(){this.close()},this.popupConfirm),2e3)}};BX.IM.prototype.setBackground=function(e){var t=null;var s=null;if(BX.MessengerCommon.isPage()){s=BX.MessengerWindow.contentBox}else{s=this.messenger.popupMessengerContent}var i=false;if(typeof e=="undefined"){e=this.settings.backgroundImage}else{if(e=="on"){e=true}else if(e=="off"){e=false}else if(this.colorsHex[e.toString().toUpperCase()]){e=this.colorsHex[e.toString().toUpperCase()]}else{var a={};for(var n in this.colors){a[this.colors[n].toUpperCase()]=n}if(a[e.toString().toUpperCase()]){var n=a[e.toString().toUpperCase()];if(this.colorsHex[n]){e=this.colorsHex[n]}}}i=this.settings.backgroundImage!=e}if(e===false){BX.removeClass(s,"bx-messenger-image");BX.removeClass(s,"bx-messenger-image-link");BX.style(s,"background-image","");BX.style(s,"background-color","")}else if(e===true){BX.addClass(s,"bx-messenger-image");BX.removeClass(s,"bx-messenger-image-link");BX.style(s,"background-image","");BX.style(s,"background-color","")}else if(e.toString().length>0){BX.addClass(s,"bx-messenger-image");if(e.toString().substr(0,1)=="#"){BX.style(s,"background-color",e);BX.style(s,"background-image","")}else if(e.toString().substr(0,4)=="http"){BX.addClass(s,"bx-messenger-image-link");BX.style(s,"background-image","url("+e+")");BX.style(s,"background-color","")}else{return false}}else{return false}if(i){this.saveSettings({backgroundImage:e})}};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(BX.MessengerCommon.isDesktop()){return BX.desktop.getLocalConfig(e,t)}t=typeof t=="undefined"?null:t;if(!BX.browser.SupportLocalStorage()){return t}if(BX.MessengerCommon.isPage()&&!BX.MessengerCommon.isDesktop())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(e){s=t}}return s};BX.IM.prototype.setLocalConfig=function(e,t,s){if(BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isPage()&&!BX.MessengerCommon.isDesktop())e="full-"+e;BX.localStorage.set(e,t,s);return true};BX.IM.prototype.removeLocalConfig=function(e){if(BX.MessengerCommon.isDesktop()){return BX.desktop.removeLocalConfig(e)}if(!BX.browser.SupportLocalStorage())return false;if(BX.MessengerCommon.isPage()&&!BX.MessengerCommon.isDesktop())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=="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.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;for(var s in this.notify){this.notify[s].date=new Date(this.notify[s].date)}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 i in this.notify)this.initNotifyCount--}if(t.domNode){this.panel=t.domNode;this.panelEnabled=true;BX.bind(this.panel,"click",BX.PreventDefault)}else{this.panel=BX.create("span",{props:{className:"bx-messenger-hide"}});this.panelEnabled=false}if(this.panelEnabled){if(BX.browser.IsDoctype())BX.addClass(this.panel,"bx-notifier-panel-doc");else BX.addClass(document.body,"bx-no-doctype");this.panelButtonCall=BX.findChildByClassName(this.panel,"bx-notifier-call");if(!this.webrtc.phoneEnabled||!this.webrtc.phoneCanPerformCalls){BX.style(this.panelButtonCall,"display","none")}this.panelButtonNetwork=BX.findChildByClassName(this.panel,"bx-notifier-network");if(this.panelButtonNetwork){this.panelButtonNetworkCount=BX.findChildByClassName(this.panelButtonNetwork,"bx-notifier-indicator-count");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");if(this.panelButtonNotify){this.panelButtonNotifyCount=BX.findChildByClassName(this.panelButtonNotify,"bx-notifier-indicator-count");if(this.panelButtonNotifyCount)this.panelButtonNotifyCount.innerHTML=""}this.panelButtonMessage=BX.findChildByClassName(this.panel,"bx-notifier-message");if(this.panelButtonMessage){this.panelButtonMessageCount=BX.findChildByClassName(this.panelButtonMessage,"bx-notifier-indicator-count");if(this.panelButtonMessageCount)this.panelButtonMessageCount.innerHTML=""}this.panelButtonMail=BX.findChildByClassName(this.panel,"bx-notifier-mail");if(this.panelButtonMail){this.panelButtonMailCount=BX.findChildByClassName(this.panelButtonMail,"bx-notifier-indicator-count");if(this.panelButtonMailCount){this.panelButtonMail.href=this.BXIM.path.mail;this.panelButtonMail.setAttribute("target","_blank");if(this.panelButtonMailCount!=null)this.panelButtonMailCount.innerHTML=""}}this.panelDragLabel=BX.findChildByClassName(this.panel,"bx-notifier-drag");if(this.panelDragLabel){BX.bind(this.panelDragLabel,"mousedown",BX.delegate(this._startDrag,this));BX.bind(this.panelDragLabel,"dobleclick",BX.delegate(this._stopDrag,this))}}if(BX.browser.IsAndroid()||BX.browser.IsIOS())BX.addClass(document.body,"bx-im-mobile");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(BX.MessengerCommon.isPage()){BX.MessengerWindow.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 a=BX.localStorage.get("npp");this.BXIM.settings.panelPositionHorizontal=!!a?a.h:this.BXIM.settings.panelPositionHorizontal;this.BXIM.settings.panelPositionVertical=!!a?a.v:this.BXIM.settings.panelPositionVertical;var n=BX.localStorage.get("mfn");if(n){for(var i in this.flashNotify)if(this.flashNotify[i]!=n[i]&&n[i]==false)this.flashNotify[i]=false}BX.garbage(function(){BX.localStorage.set("mfn",this.flashNotify,15)},this)}if(this.panelButtonNotify){BX.bind(this.panelButtonNotify,"click",BX.proxy(function(){this.toggleNotify()},this.BXIM))}if(this.webrtc.phoneEnabled&&this.webrtc.phoneCanPerformCalls){if(this.panelButtonCall){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))}if(this.panelDragLabel){BX.bind(this.panelDragLabel,"mousedown",BX.proxy(this._startDrag,this));BX.bind(this.panelDragLabel,"dobleclick",BX.proxy(this._stopDrag,this))}this.updateNotifyMailCount();if(!BX.MessengerCommon.isPage()){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);var s="";if(this.mailCount>99)s="99+";else if(this.mailCount>0)s=this.mailCount;if(this.panelButtonMail){if(this.mailCount>0)BX.removeClass(this.panelButtonMail,"bx-notifier-hide");else BX.addClass(this.panelButtonMail,"bx-notifier-hide");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){this.panelButtonNotifyCount.innerHTML=n;this.adjustPosition({resize:true,timeout:500})}if(this.messengerNotifyButtonCount)this.messengerNotifyButtonCount.innerHTML=parseInt(n)>0?'<span class="bx-messenger-cl-count-digit">'+n+"</span>":"";if(BX.MessengerCommon.isPage()){BX.MessengerWindow.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.viewNotifyMarkupUpdate=function(){if(this.BXIM.notifyOpen){var e=BX.findChildrenByClassName(this.popupNotifyItem,"bx-notifier-item-new",false);if(e!=null){for(var t=0;t<e.length;t++){if(e[t].getAttribute("data-notifyType")==1){continue}if(!this.unreadNotify[e[t].getAttribute("data-notifyId")]){BX.removeClass(e[t],"bx-notifier-item-new")}}}for(var t in this.unreadNotify){var s=BX.findChildByClassName(this.popupNotifyItem,"bx-notifier-item-"+t,false);if(s!=null){BX.addClass(s,"bx-notifier-item-new")}}}};BX.Notify.prototype.viewNotifyAll=function(e){e=e!==false;if(this.BXIM.settings.notifyAutoRead){var t=null;for(var s in this.unreadNotify){if(this.notify[s]&&this.notify[s].type!=1){delete this.unreadNotify[s];if(t===null||t>s){t=s}}delete this.flashNotify[s]}if(!t){return false}if(e){BX.ajax({url:this.BXIM.pathToAjax+"?NOTIFY_READ&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:{IM_NOTIFY_READ:"Y",ID:t,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})}setTimeout(this.viewNotifyMarkupUpdate,500);this.updateNotifyCount(false)}else{for(var s in this.unreadNotify){delete this.flashNotify[s]}}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=this.notify[e].date.getTime();var i=this.notify[t].date.getTime();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 o=BX.clone(this.notify[i[a]]);if(o&&o.userId&&o.userName)n[o.userId]=o.userName;o.text=o.text.replace(/\[CHAT=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,s,i){return i});o=this.createNotify(o,true);if(o!==false){t.push(o);o=this.notify[i[a]];s.push({title:o.userName?BX.util.htmlspecialcharsback(o.userName):BX.message("IM_NOTIFY_WINDOW_NEW_TITLE"),text:BX.util.htmlspecialcharsback(o.text).split("<br />").join("\n").replace(/<\/?[^>]+>/gi,""),icon:o.userAvatar?o.userAvatar:"",tag:"im-notify-"+o.tag})}}if(t.length>5){var r="";for(var a in n)r+=", <i>"+n[a]+"</i>";var o={id:0,type:4,date:new Date,tag:"",originalTag:"",title:BX.message("IM_NM_NOTIFY_1").replace("#COUNT#",t.length),text:r.length>0?BX.message("IM_NM_NOTIFY_2").replace("#USERS#",r.substr(2)):BX.message("IM_NM_NOTIFY_3")};o=this.createNotify(o,true);BX.style(o,"cursor","pointer");t=[o];s=[{id:"",title:BX.message("IM_NM_NOTIFY_1").replace("#COUNT#",t.length),text:r.length>0?BX.message("IM_NM_NOTIFY_2").replace("#USERS#",BX.util.htmlspecialcharsback(r.substr(2))).replace(/<\/?[^>]+>/gi,""):BX.message("IM_NM_NOTIFY_3")}]}if(t.length==0)return false;if(BX.MessengerCommon.isDesktop())BX.desktop.flashIcon(false);this.closePopup();if(this.BXIM.context=="LINES"||this.BXIM.context=="DIALOG"){return false}if(this.BXIM.settings.status=="dnd"||!BX.MessengerCommon.isDesktop()&&this.BXIM.desktopStatus)return false;if(e&&!this.BXIM.xmppStatus)this.BXIM.playSound("reminder");if(e&&BX.MessengerCommon.isDesktop()){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 o=s[a];o.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};o.onclick=function(){window.focus();top.BXIM.openNotify();this.close()};this.BXIM.notifyManager.nativeNotify(o)}}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")].originalTag:"",notifyId:t[a].getAttribute("data-notifyId"),notifyType:t[a].getAttribute("data-notifyType"),click:t[a].id>0?null:BX.delegate(function(e){this.BXIM.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].originalTag:"";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&&BX.MessengerCommon.isDesktop())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&&BX.MessengerCommon.isDesktop())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&&BX.MessengerCommon.isDesktop())BX.desktop.windowCommand("close")},this),onfailure:BX.delegate(function(){if(t&&BX.MessengerCommon.isDesktop())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||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 o=[];var r=[];for(var n in s){r.push(parseInt(n))}r.sort(function(e,t){if(!s[e]||!s[t]){return 0}var i=s[e].date.getTime();var a=s[t].date.getTime();var n=typeof s[e].confirmMessages=="undefined"?parseInt(s[e].type):2;var o=typeof s[t].confirmMessages=="undefined"?parseInt(s[t].type):2;if(n==1&&o!=1){return-1}else if(o==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<r.length;n++){var l=s[r[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)o.push(l)}if(o.length==0){if(this.messenger.popupMessengerConnectionStatusState!="online"){o.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")}));o.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){o.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){o.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")}));o.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){o.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")}));o.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 o}else if(!t){o.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 o};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(!BX.MessengerCommon.isPage()){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);clearTimeout(this.popupMessengerTopLineTimeout);this.popupMessengerTopLineTimeout=setTimeout(BX.delegate(function(){this.BXIM.notifyManager.nativeNotifyAccessForm()},this),1e4);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")=="openlines"){this.messenger.linesOpenHistory(BX.proxy_context.getAttribute("data-sessionId"))}else if(BX.proxy_context.getAttribute("data-entity")=="network"){this.messenger.openMessenger("network"+BX.proxy_context.getAttribute("data-networkId"))}else if(BX.proxy_context.getAttribute("data-entity")=="date"){this.messenger.openPopupMenu(BX.proxy_context,"shareMenu")}},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(BX.MessengerCommon.isDesktop()){BX.bindDelegate(this.popupNotifyItem,"contextmenu",{className:"bx-notifier-item-content"},BX.delegate(function(e){if(!BX.proxy_context)return;BX.proxy_context.parentNode.setAttribute("id","bx-notifier-item-delete-"+BX.proxy_context.parentNode.getAttribute("data-notifyId"));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||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 o={};if(a)o={IM_NOTIFY_GROUP_REMOVE:"Y",NOTIFY_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()};else o={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:o,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(!BX.MessengerCommon.isPage()){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=new Date(t.NOTIFY[i].date);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=new Date(e.NOTIFY[i].date);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(BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isDesktop())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 o=this.panel.offsetHeight;if(s>a.scrollWidth-n)s=a.scrollWidth-n;if(i>a.scrollHeight-o)i=a.scrollHeight-o;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(/\[like\]/gi,'<span class="bx-smile bx-im-smile-like" title="'+BX.message("IM_MESSAGE_LIKE")+'"></span>');e.text=e.text.replace(/\[dislike\]/gi,'<span class="bx-smile bx-im-smile-dislike" title="'+BX.message("IM_MESSAGE_DISLIKE")+'"></span>');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=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,s,i){var a="";s=parseInt(s);if(s>0){if(t){a='<span class="bx-messenger-ajax" data-entity="openlines" data-sessionId="'+s+'">'+i+"</span>"}else{a='<span class="bx-messenger-ajax" data-entity="chat" data-chatId="'+s+'">'+i+"</span>"}}else{a=i}return a});e.text=e.text.replace(/\[RATING\=([1-5]{1})\]/gi,BX.delegate(function(e,t){return BX.MessengerCommon.linesVoteHeadNodes(0,t,false).outerHTML},this));if(BX.MessengerCommon.isDesktop()||this.BXIM.context=="FULLSCREEN"||this.BXIM.context=="PAGE"){e.text=e.text.replace(/<a(.*?)>(.*?)<\/a>/gi,BX.delegate(function(e,t,s){return"<a"+t.replace('target="_self"','target="_blank"')+' 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 o=false;if(typeof e.confirmMessages!="undefined"){o=true;for(var r=0;r<e.confirmMessages.length;r++){n.push(BX.create("div",{props:{className:"bx-notifier-item-confirm-message"},html:e.confirmMessages[r]}))}}else{for(var r=0;r<e.buttons.length;r++){var l=e.buttons[r].TYPE=="accept"?"accept":e.buttons[r].TYPE=="cancel"?"cancel":"default";var p={"data-id":e.id,"data-value":e.buttons[r].VALUE};if(e.grouped)p["data-group"]="Y";if(e.buttons[r].URL)p["data-url"]=e.buttons[r].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[r].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:""}})]}),!o?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&&BX.MessengerCommon.isDesktop())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&&BX.MessengerCommon.isDesktop())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.realSearchAvailable=!this.BXIM.userExtranet||!this.BXIM.bitrixIntranet&&!this.BXIM.bitrix24net;this.realSearch=!this.BXIM.options.contactListLoad;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.sendFrameTokenCollection={};this.sendFrameTokenTimeout=500;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.textareaIcon=t.textareaIcon;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;for(var s in this.users){this.users[s].absent=this.users[s].absent?new Date(this.users[s].absent):false;this.users[s].idle=this.users[s].idle?new Date(this.users[s].idle):false;this.users[s].last_activity_date=new Date(this.users[s].last_activity_date);this.users[s].mobile_last_date=new Date(this.users[s].mobile_last_date)}this.businessUsers=t.businessUsers;this.openlines=t.openlines;this.groups=t.groups;this.userInGroup=t.userInGroup;this.currentTab=0;this.generalChatId=t.generalChatId;this.canSendMessageGeneralChat=t.canSendMessageGeneralChat;this.redrawTab={};this.loadLastMessageTimeout={};this.loadLastMessageClassTimeout={};this.showMessage=t.showMessage;this.unreadMessage=t.unreadMessage;this.flashMessage=t.flashMessage;this.tooltipShowed=t.tooltipShowed||{};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;for(var i in this.chat){this.chat[i].date_create=new Date(this.chat[i].date_create)}this.userChat=t.userChat;this.userInChat=t.userInChat;this.userChatBlockStatus=t.userChatBlockStatus;this.userChatOptions=t.userChatOptions;this.blockJoinChat={};this.hrphoto=t.hrphoto;this.chatPublicWatch=0;this.chatPublicWatchAdd=false;this.popupIframeBind=true;this.popupIframeMenu=null;this.popupMessengerLiveChatDelayedFormMid=0;this.popupMessengerLiveChatActionTimeout=null;this.popupMessengerLiveChatDelayedForm=null;this.popupMessengerLiveChatFormStage=null;this.phones={};this.errorMessage={};this.message=t.message;for(var a in this.message){this.message[a].date=new Date(this.message[a].date)}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.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.popupMessengerSendingTimeout={};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.popupMessengerPanelBotIcons=false;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.popupPopupMenuModifyFunction=[];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.openBotFlag=false;this.openCallFlag=false;this.contactListLoad=!this.BXIM.options.contactListLoad;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.linesSilentMode={};this.linesLiveChatVote=false;this.enableGroupChat=this.BXIM.ppStatus?true:false;if(this.BXIM.init){if(BX.MessengerCommon.isPage()){BX.MessengerWindow.setUserInfo(BX.MessengerCommon.getUserParam());BX.MessengerWindow.addTab({id:"im",title:BX.message("IM_DESKTOP_OPEN_MESSENGER").replace("#COUNTER#",""),order:100,events:{open:BX.delegate(function(){if(BX.MessengerCommon.isPage()&&this.BXIM.context=="POPUP-FULLSCREEN"&&!this.popupMessenger){return false}if(!this.BXIM.dialogOpen){this.openMessenger(this.currentTab)}},this)}});if(this.webrtc.phoneSupport()&&this.webrtc.phoneCanPerformCalls){BX.MessengerWindow.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)}})}if(this.BXIM.settings.linesTabEnable&&BX.MessengerCommon.isLinesOperator()){BX.MessengerWindow.addTab({id:"im-ol",title:BX.message("IM_CTL_CHAT_OL"),order:105,target:"im",events:{open:BX.delegate(function(){if(BX.MessengerCommon.isPage()&&this.BXIM.context=="POPUP-FULLSCREEN"&&!this.popupMessenger){return false}if(!this.BXIM.dialogOpen){this.openMessenger(this.currentTab)}BX.MessengerCommon.userListRedraw()},this),close:BX.delegate(function(){BX.MessengerCommon.userListRedraw()},this)}})}}BX.addCustomEvent("onPullError",BX.delegate(function(e,t){if(e=="AUTHORIZE_ERROR"){if(BX.MessengerCommon.isDesktop()){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(){if(this.BXIM.messenger.chatList){BX.MessengerCommon.contactListSearchClear()}this.closeMenuPopup()},this));BX.addCustomEvent("OnMessengerWindowShowPopup",BX.delegate(function(e){this.openMessenger(e)},this));BX.addCustomEvent("OnMessengerWindowClosePopup",BX.delegate(function(){this.closeMessenger()},this));BX.addCustomEvent("onImError",BX.delegate(function(e,t){if(e=="AUTHORIZE_ERROR"||e=="SEND_ERROR"&&t=="AUTHORIZE_ERROR"){if(BX.MessengerCommon.isDesktop()){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 n in this.unreadMessage){if(typeof this.flashMessage[n]=="undefined")this.flashMessage[n]={};for(var o=this.unreadMessage[n].length-1;o>=0;o--){BX.localStorage.set("mum",{userId:n,message:this.message[this.unreadMessage[n][o]]},5)}}BX.localStorage.set("muum",this.unreadMessage,5);if(this.notify.panelButtonMessage){BX.bind(this.notify.panelButtonMessage,"click",BX.delegate(function(e){this.BXIM.openMessenger(true)},this))}var r=this.BXIM.getLocalConfig("mcesh",null);if(r!==null){this.BXIM.options.chatExtendShowHistory=r}var l=this.BXIM.getLocalConfig("global_msz_v2",false);if(!l&&BX.MessengerCommon.isPage()){this.desktop.initHeight=BX.MessengerWindow.initHeight;if(BX.MessengerCommon.isDesktop()){if(!BX.browser.IsMac()&&!this.desktop.enableInVersion(37)){BXDesktopWindow.SetProperty("clientSize",{Width:window.innerWidth,Height:window.innerHeight})}this.tmpTextareaResize=BX.delegate(function(){var e=this.BXIM.getLocalConfig("global_tas",this.popupMessengerTextareaSize);this.setTextareaSize(e);BX.unbind(window,"resize",this.tmpTextareaResize)},this);BX.bind(window,"resize",this.tmpTextareaResize)}else{BX.addCustomEvent("onImInit",BX.delegate(function(){var e=this.BXIM.getLocalConfig("global_tas",this.BXIM.context=="POPUP-FULLSCREEN"?60:this.popupMessengerTextareaSize);this.setTextareaSize(e)},this))}}else if(l&&(!BX.MessengerCommon.isPage()||BX.MessengerCommon.isDesktop())){this.popupMessengerFullWidth=parseInt(l.wz);this.popupMessengerTextareaSize=parseInt(l.ta2);this.popupMessengerBodySize=parseInt(l.b)>0?parseInt(l.b):this.popupMessengerBodySize;this.popupHistoryItemsSize=parseInt(l.hi);this.popupMessengerFullHeight=parseInt(l.fz);this.popupContactListElementsSize=parseInt(l.ez);this.notify.popupNotifySize=parseInt(l.nz);this.popupHistoryFilterVisible=l.hf;if(BX.MessengerCommon.isDesktop()){BX.desktop.setWindowSize({Width:parseInt(l.dw),Height:parseInt(l.dh)});this.desktop.initHeight=parseInt(l.dh)}}else{if(BX.MessengerCommon.isDesktop()){BX.desktop.setWindowSize({Width:BX.MessengerWindow.initWidth,Height:BX.MessengerWindow.initHeight});this.desktop.initHeight=BX.MessengerWindow.initHeight}else if(BX.MessengerCommon.isPage()){this.desktop.initHeight=BX.MessengerWindow.initHeight}BX.addCustomEvent("onImInit",BX.delegate(function(){var e=this.BXIM.getLocalConfig("global_tas",this.BXIM.context=="POPUP-FULLSCREEN"?60:this.popupMessengerTextareaSize);this.setTextareaSize(e)},this))}if(BX.MessengerCommon.isPage()){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 p=BX.localStorage.get("mcr2");if(p){for(var n in p.users)this.users[n]=p.users[n];for(var n in p.hrphoto)this.hrphoto[n]=p.hrphoto[n];for(var n in p.chat)this.chat[n]=p.chat[n];for(var n in p.userInChat)this.userInChat[n]=p.userInChat[n];this.callInit=true;setTimeout(BX.delegate(function(){this.webrtc.callNotifyWait(p.callChatId,p.callUserId,p.callVideo,p.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.currentTab=this.currentTab?this.currentTab:0;this.messageTmpIndex=BX.localStorage.get("mti")||0;var h=BX.localStorage.get("mfm");if(h){for(var n in this.flashMessage)for(var c in this.flashMessage[n])if(h[n]&&this.flashMessage[n][c]!=h[n][c]&&h[n][c]==false)this.flashMessage[n][c]=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(BX.MessengerCommon.isDesktop()&&(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 u=this.BXIM.getLocalConfig("mtah",false);if(u){this.textareaHistory=u;this.BXIM.removeLocalConfig("mtah")}var m=this.BXIM.getLocalConfig("mtam",false);if(m){this.textareaHistory=m;this.BXIM.removeLocalConfig("mtam")}var d=this.BXIM.getLocalConfig("mct",false);if(d){this.currentTab=d;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(BX.MessengerCommon.isDesktop()&&(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 n=0;var g=BX.date.format("d-m");for(var s in this.users){if(this.users[s].birthday==g&&s!=this.BXIM.userId){this.message[s+"birthday"]={id:s+"birthday",senderId:0,recipientId:s,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[s].name+"</strong>")};if(!this.showMessage[s])this.showMessage[s]=[];this.showMessage[s].push(s+"birthday");this.showMessage[s].sort(BX.delegate(function(e,t){if(!this.message[e]||!this.message[t]){return 0}var s=this.message[e].date.getTime();var i=this.message[t].date.getTime();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 f=this.showMessage[s][this.showMessage[s].length-1];BX.MessengerCommon.recentListAdd({userId:s,userIsChat:false,id:this.message[f].id,date:this.message[f].date,recipientId:this.message[f].recipientId,senderId:this.message[f].senderId,text:f==s+"birthday"?BX.message("IM_M_BIRTHDAY_MESSAGE_SHORT").replace("#USER_NAME#",this.users[s].name):this.message[f].text,params:{}},true);this.recent.sort(BX.delegate(function(e,t){if(!this.message[e.id]||!this.message[t.id]){return 0}var s=this.message[e.id].date.getTime();var i=this.message[t.id].date.getTime();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 B=this.BXIM.getLocalConfig("birthdayPopup"+(new Date).getFullYear(),{});if(this.desktop.birthdayStatus()&&!B[s]){this.message[s+"birthdayPopup"]={id:s+"birthdayPopup",senderId:0,recipientId:s,date:BX.MessengerCommon.getNowDate(true),text:BX.message("IM_M_BIRTHDAY_MESSAGE_SHORT").replace("#USER_NAME#",this.users[s].name)};if(BX.MessengerCommon.isDesktop()){if(!this.unreadMessage[s])this.unreadMessage[s]=[];this.unreadMessage[s].push(s+"birthdayPopup");if(!this.flashMessage[s])this.flashMessage[s]={};this.flashMessage[s][s+"birthdayPopup"]=true}B[s]=true;this.BXIM.removeLocalConfig("birthdayPopup"+((new Date).getFullYear()-1));this.BXIM.setLocalConfig("birthdayPopup"+(new Date).getFullYear(),B)}}n++}this.updateState();if(t.openMessenger!==false)this.openMessenger(t.openMessenger);else if(this.openMessengerFlag)this.openMessenger(this.currentTab);if(t.openHistory!==false){this.BXIM.openHistory(t.openHistory)}if(t.openNotify!==false)this.BXIM.openNotify();if(this.BXIM.settings.status!="dnd")this.newMessage();this.updateMessageCount();setInterval(BX.delegate(function(){BX.MessengerCommon.checkProgessMessage();this.expireFrameToken()},this),1e3);BX.bind(window,"message",BX.delegate(function(e){if(e&&e.origin==this.openFrameDialogFrameSourceDomain){this.openFrameDialogPostMessage(e.data)}},this))}else{if(t.openMessenger!==false)this.BXIM.openMessenger(t.openMessenger);if(t.openHistory!==false)this.BXIM.openHistory(t.openHistory)}};BX.Messenger.prototype.openMessengerSlider=function(e,t){t=t||{};requestParams={};requestParams.IFRAME="Y";requestParams.IM_DIALOG=e;requestParams.IM_RECENT=t.RECENT=="N"?"N":"Y";requestParams.IM_MENU=t.MENU=="N"?"N":"Y";var s={cacheable:false,allowChangeHistory:false,requestMethod:"post",requestParams:requestParams};if(t.RECENT=="N"||t.MENU=="N"){s.width=800+(t.RECENT=="N"?0:50)+(t.MENU=="N"?0:20)}BX.SidePanel.Instance.open("/desktop_app/",s)};BX.Messenger.prototype.openMessenger=function(e,t){if(BX.MessengerCommon.isPage()&&this.BXIM.context=="POPUP-FULLSCREEN"&&!BX.MessengerWindow.isPopupShow()){BX.MessengerWindow.showPopup(e);return false}if(this.BXIM.errorMessage!=""){this.BXIM.openConfirm(this.BXIM.errorMessage,[new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:BX.delegate(function(e){BX.proxy_context.popupWindow.close();if(BX.MessengerWindow){BX.MessengerWindow.closePopup()}BX.PreventDefault(e)},this)}})]);return false}if(this.BXIM.popupSettings!=null&&!BX.MessengerCommon.isDesktop())this.BXIM.popupSettings.close();if(this.popupMessenger!=null&&this.dialogOpen&&this.currentTab==e&&e!=0)return false;if(e!==false&&BX.MessengerCommon.isPage()&&BX.MessengerWindow.currentTab!="im"&&BX.MessengerWindow.currentTab!="im-ol"){BX.MessengerWindow.changeTab("im",false,true)}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.openBotFlag=false;this.openLinesFlag=false;this.openCallFlag=false;if(typeof e=="boolean"){e=0}else if(e==0){for(var s in this.unreadMessage){e=s;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.getChatId()]&&this.chat[this.getChatId()].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"||e.toString().substr(0,2)=="sg"){BX.MessengerCommon.getUserParam(e);this.openChatFlag=true;if(e.toString().substr(0,4)=="chat"){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.openChatFlag&&this.users[e]&&this.users[e].bot){this.openBotFlag=true}}if(this.popupMessenger!=null){BX.MessengerCommon.openDialog(e,this.BXIM.dialogOpen?false:true);if(!(BX.browser.IsAndroid()||BX.browser.IsIOS()||window!=window.top)){if(this.popupMessengerTextarea)this.popupMessengerTextarea.focus()}return false}var i={};if(!BX.browser.IsMobile()&&BX.MessengerCommon.isPage()){var a=BX.MessengerWindow.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}else{i={width:this.popupMessengerFullWidth+"px"}}if(BX.MessengerWindow&&BX.MessengerWindow.contentMenu){if(this.BXIM.options.showMenu){BX.removeClass(BX.MessengerWindow.contentBox,"bx-desktop-appearance-hide-menu")}else{BX.addClass(BX.MessengerWindow.contentBox,"bx-desktop-appearance-hide-menu")}}var n=BX.MessengerCommon.getUserStatus(this.users[this.BXIM.userId]);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"):"")+(BX.MessengerCommon.isPage()?" bx-messenger-box-desktop":"")+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")+(this.BXIM.options.showRecent?"":" bx-messenger-hide-recent")},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()||!this.webrtc.phoneCanPerformCalls?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(this.users[this.BXIM.userId])},html:'<span class="bx-messenger-cl-panel-status"></span><span class="bx-messenger-cl-panel-status-text">'+BX.message("IM_STATUS_"+(n=="birthday"?"online":n).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"+(this.BXIM.isAdmin?" bx-messenger-user-admin":"")},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])},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.users[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.popupMessengerPanelLastDate=BX.create("span",{props:{className:"bx-messenger-panel-title-position"},html:""})]}),this.popupMessengerPanelStatus=BX.create("span",{props:{className:"bx-messenger-panel-desc"},html:BX.MessengerCommon.getUserPosition(this.users[this.currentTab],false,true)})]}),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.getChatId()}}),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"}})]}),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,this.chat[this.getChatId()].entity_type=="LINES"?"openLinesMenu":"pathMenu");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.popupOpenLinesSpam=BX.create("span",{attrs:{title:BX.message("IM_M_OL_FORCE_CLOSE")?BX.message("IM_M_OL_FORCE_CLOSE").replace("<br>",""):BX.message("IM_M_OL_SPAM")},props:{className:"bx-messenger-panel-button bx-messenger-panel-spam"},events:{click:BX.delegate(function(e){this.linesMarkAsSpam();BX.PreventDefault(e)},this)}}),this.popupOpenLinesClose=BX.create("span",{attrs:{title:BX.message("IM_M_OL_CLOSE")},props:{className:"bx-messenger-panel-button bx-messenger-panel-close"},events:{click:BX.delegate(function(e){this.linesCloseDialog();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.popupMessengerPanelButtonExtend=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.getChatId(),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.getChatId()]?this.chat[this.getChatId()].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.getChatId()}}),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("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,"callContextMenu");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.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.getChatId()]?this.chat[this.getChatId()].name:BX.message("IM_CL_LOAD")}),this.popupMessengerPanelCallDescription=BX.create("span",{props:{className:"bx-messenger-panel-desc"},text:this.chat[this.getChatId()]&&this.chat[this.getChatId()].entity_data_1&&this.chat[this.getChatId()].entity_data_1.toString().charAt(0)==="Y"?this.chat[this.getChatId()].call_number: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){var t=this.popupMessengerEditMessageId;BX.MessengerCommon.editMessageAjax(this.popupMessengerEditMessageId,this.popupMessengerEditTextarea.value);if(this.message[t].quick_saved){BX.MessengerCommon.linesSaveToQuickAnswers(t,true)}},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.popupMessengerBodyPanel=BX.create("div",{props:{className:"bx-messenger-body-panel"},style:{height:this.popupMessengerBodySize+"px"},children:[BX.create("div",{props:{className:"bx-messenger-body-panel-title"},children:[this.popupMessengerBodyPanelTitleName=BX.create("div",{props:{className:"bx-messenger-body-panel-title-name"}}),this.popupMessengerBodyPanelTitleDesc=BX.create("div",{props:{className:"bx-messenger-body-panel-title-desc"}}),BX.create("div",{props:{className:"bx-messenger-body-panel-title-close"},events:{click:BX.delegate(function(){this.closeMessengerPanel()},this)}})]}),this.popupMessengerBodyPanelWrap=BX.create("div",{props:{className:"bx-messenger-body-panel-wrap"}})]}),this.popupMessengerBody=BX.create("div",{props:{className:"bx-messenger-body"},style:{height:this.popupMessengerBodySize+"px"},children:[BX.create("div",{props:{className:"bx-messenger-body-bg"},children:[this.popupMessengerBodyWrap=BX.create("div",{props:{className:"bx-messenger-body-wrap"}})]})]}),this.popupMessengerBodyLiveChatForm=BX.create("div",{props:{className:"bx-messenger-livechat-form"}}),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")}),this.popupMessengerTextareaOpenLinesTransfer=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.browser.IsMobile()?BX.create("span"):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(){if(this.popupMessengerTextareaPlace&&this.popupMessengerTextareaPlace.className.indexOf("bx-messenger-textarea-with-text")==-1){return false}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.popupMessengerTextareaIcons=BX.create("div",{props:{className:"bx-messenger-textarea-icons"},children:[this.popupMessengerFileButton=this.disk.getFileMenuIcon(),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.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.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_FORMS_MENU")},props:{className:"bx-messenger-textarea-forms"},events:{click:BX.delegate(function(e){this.openFormsMenu();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.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.popupMessengerTextareaIconBox=BX.create("div",{props:{className:"bx-messenger-textarea-icon-box"}})]}),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"}}),BX.MessengerCommon.isPage()&&!BX.MessengerCommon.isDesktop()?null:BX.create("span",{props:{className:"bx-messenger-resize"},events:BX.MessengerCommon.isPage()?{}:{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(BX.MessengerCommon.isPage()){this.popupMessenger=new BX.PopupWindowDesktop(this.BXIM);BX.MessengerWindow.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(){this.closeMessenger()},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.BXIM.setBackground();this.popupMessengerTopLine=BX.create("div",{props:{className:"bx-messenger-box-topline"}});this.popupMessengerContent.insertBefore(this.popupMessengerTopLine,this.popupMessengerContent.firstChild);clearTimeout(this.popupMessengerTopLineTimeout);this.popupMessengerTopLineTimeout=setTimeout(BX.delegate(function(){this.BXIM.notifyManager.nativeNotifyAccessForm()},this),1e4);if(!BX.MessengerCommon.isDesktop()&&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}],false)},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)}}this.textareaIconPrepare();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){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,"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(BX.MessengerCommon.isDesktop()){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.getChatId();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]||!this.users[this.userInChat[t][i]].active)continue;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.users[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(this.toggleChatListGroup,this));BX.bindDelegate(this.popupContactListElements,"click",{className:"bx-messenger-chatlist-search-button"},BX.delegate(function(){this.BXIM.messenger.chatListSearchAction(BX.proxy_context.parentNode)},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.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(BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isDesktop()){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-attach-block-spoiler"},BX.delegate(function(e){var t=BX.findChildByClassName(BX.proxy_context,"bx-messenger-attach-block-value");if(BX.hasClass(BX.proxy_context,"bx-messenger-attach-block-spoiler-show")){height=t.getAttribute("data-min-height");BX.removeClass(BX.proxy_context,"bx-messenger-attach-block-spoiler-show")}else{BX.addClass(BX.proxy_context,"bx-messenger-attach-block-spoiler-show");height=t.getAttribute("data-max-height")}t.style.maxHeight=height+"px"},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.parentNode.parentNode.getAttribute("data-blockmessageid");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){BX.localStorage.set("implc",true,1);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.users[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:5,offsetLeft:12,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.getChatId();if(this.openChatFlag&&!BX.MessengerCommon.userInChat(t)){return false}if(BX.localStorage.get("implc",true,1)){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;if(this.BXIM.messenger.popupMessengerDialog&&BX.hasClass(this.BXIM.messenger.popupMessengerDialog,"bx-messenger-chat-load-last-message")){return false}var e=this.currentTab.substr(4);BX.MessengerCommon.joinToChat(e);return true},this));BX.bind(this.popupMessengerTextareaGeneralJoin,"click",BX.delegate(function(){if(this.BXIM.messenger.popupMessengerDialog&&BX.hasClass(this.BXIM.messenger.popupMessengerDialog,"bx-messenger-chat-load-last-message")){return false}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;if(this.BXIM.messenger.popupMessengerDialog&&BX.hasClass(this.BXIM.messenger.popupMessengerDialog,"bx-messenger-chat-load-last-message")){return false}var e=this.currentTab.substr(4);if(!BX.MessengerCommon.userInChat(e)){var t=BX.MessengerCommon.linesGetSession(this.chat[e]);if(parseInt(t.id)<=0){BX.MessengerCommon.linesStartSession(e)}else if(parseInt(this.chat[e].owner)==0){BX.MessengerCommon.linesAnswer(e)}else{BX.MessengerCommon.linesJoinSession(e)}}else{BX.MessengerCommon.linesAnswer(e)}return true},this));BX.bind(this.popupMessengerTextareaOpenLinesSkip,"click",BX.delegate(function(){if(this.currentTab.substr(0,4)!="chat")return false;if(this.BXIM.messenger.popupMessengerDialog&&BX.hasClass(this.BXIM.messenger.popupMessengerDialog,"bx-messenger-chat-load-last-message")){return false}var e=this.currentTab.substr(4);if(!BX.MessengerCommon.userInChat(e))BX.MessengerCommon.dialogCloseCurrent(true);else 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")=="openlines"){this.linesOpenHistory(BX.proxy_context.getAttribute("data-sessionId"))}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")=="date"){this.openPopupMenu(BX.proxy_context,"shareMenu")}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.BXIM.sendMessage(this.currentTab,BX.proxy_context.nextSibling.innerHTML)}else if(BX.proxy_context.getAttribute("data-entity")=="put"){this.BXIM.putMessage(BX.proxy_context.nextSibling.innerHTML)}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(e){if(this.openLinesFlag){this.tooltip(BX.proxy_context,BX.message("IM_TIP_OL_SYSTEM"),{offsetLeft:48})}BX.PreventDefault(e)},this));BX.bind(this.popupMessengerBody,"scroll",BX.delegate(function(e){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)}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()}if(this.popupTooltip!=null){this.popupTooltip.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",{props:{className:"bx-messenger-box-hello-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-box-hello"},html:BX.message("IM_M_EMPTY")})]}))}else{BX.MessengerCommon.openDialog(e)}};BX.Messenger.prototype.closeMessenger=function(){if(!this.popupMessenger||this.webrtc.callInit)return false;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;BX.remove(this.popupMessengerContent);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();return true};BX.Messenger.prototype.openMessengerPanel=function(){if(!this.popupMessengerBodyPanel)return false;this.popupMessengerPanelOpen=true;this.popupMessengerBody.style.width="calc(100% - 400px)";this.popupMessengerTextareaPlace.style.width="calc(100% - 400px)";this.popupMessengerBodyPanel.style.height=this.popupMessengerBodyDialog.offsetHeight+"px";this.popupMessengerBodyPanel.style.right="0";return true};BX.Messenger.prototype.closeMessengerPanel=function(){if(!this.popupMessengerBodyPanel)return false;this.popupMessengerPanelOpen=false;this.popupMessengerBody.style.removeProperty("width");this.popupMessengerTextareaPlace.style.removeProperty("width");this.popupMessengerBodyPanel.style.removeProperty("right");return true};BX.Messenger.prototype.enterFullScreen=function(){if(this.messengerFullscreenStatus){if(document.cancelFullScreen)document.cancelFullScreen();else if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen()}else{if(BX.browser.IsChrome()||BX.browser.IsSafari()){this.popupMessengerContent.webkitRequestFullScreen(this.popupMessengerContent.ALLOW_KEYBOARD_INPUT);BX.bind(window,"webkitfullscreenchange",this.messengerFullscreenBind=BX.proxy(this.eventFullScreen,this))}else if(BX.browser.IsFirefox()){this.popupMessengerContent.mozRequestFullScreen(this.popupMessengerContent.ALLOW_KEYBOARD_INPUT);BX.bind(window,"mozfullscreenchange",this.messengerFullscreenBind=BX.proxy(this.eventFullScreen,this))}}};BX.Messenger.prototype.eventFullScreen=function(e){if(this.messengerFullscreenStatus){if(BX.browser.IsChrome()||BX.browser.IsSafari())BX.unbind(window,"webkitfullscreenchange",this.messengerFullscreenBind);else if(BX.browser.IsFirefox())BX.unbind(window,"mozfullscreenchange",this.messengerFullscreenBind);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.messengerFullscreenStatus=false;this.resizeMainWindow();this.popupMessenger.adjustPosition()}else{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};BX.Messenger.prototype.tooltip=function(e,t,s){if(this.tooltipIsOpen())this.popupTooltip.close();s=s||{};s.offsetLeft=s.offsetLeft||0;s.offsetTop=s.offsetTop||BX.MessengerCommon.isDesktop()?0:-10;s.width=s.width||0;s.angle=typeof s.angle=="undefined"?true:s.angle;s.showOnce=typeof s.showOnce=="undefined"?false:s.showOnce;s.bindOptions=typeof s.bindOptions=="undefined"?{position:"top"}:s.bindOptions;if(s.showOnce){if(this.tooltipShowed[s.showOnce]){return true}else{BX.userOptions.save("im","tooltipShowed",s.showOnce,1);this.tooltipShowed[s.showOnce]=1}}var i=null;if(typeof t=="object"){i=BX.create("div",{props:{className:"bx-messenger-tooltip",style:"padding-right: 5px;"+(s.width>0?"width: "+s.width+"px;":"")},children:[t]})}else{i=BX.create("div",{props:{className:"bx-messenger-tooltip",style:"padding-right: 5px;"+(s.width>0?"width: "+s.width+"px;":"")},html:t})}this.popupTooltip=new BX.PopupWindow("bx-messenger-tooltip",e,{lightShadow:true,autoHide:true,darkMode:true,offsetLeft:s.offsetLeft,offsetTop:s.offsetTop,closeIcon:{},bindOptions:s.bindOptions,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupTooltip=null},this)},zIndex:2e3,content:i});if(s.angle){this.popupTooltip.setAngle({offset:23,position:s.bindOptions.position=="top"?"bottom":"top"})}this.popupTooltip.show();return true};BX.Messenger.prototype.tooltipIsOpen=function(){return this.popupTooltip!=null};BX.Messenger.prototype.tooltipClose=function(){if(this.tooltipIsOpen())this.popupTooltip.close()};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";clearInterval(this.popupMessengerPanelLastDateInterval);if(this.openChatFlag){this.textareaIconToggle();this.redrawChatHeader(e)}else if(this.users[this.currentTab]){BX.style(this.popupOpenLinesSpam,"display","");if(this.popupMessengerFileFormChatId){this.popupMessengerFileFormChatId.value=this.userChat[this.currentTab]?this.userChat[this.currentTab]:0;if(!this.disk.enableExternal&&(this.users[this.currentTab].bot||this.users[this.currentTab].network)){this.popupMessengerFileFormInput.setAttribute("disabled",true)}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.users[this.currentTab]);this.popupMessengerPanelAvatar.parentNode.title=BX.MessengerCommon.getUserStatus(this.users[this.currentTab],false).title;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>)"}var t=BX.delegate(function(){if(!this.popupMessengerPanelLastDate||this.currentTab&&this.currentTab.toString().substr(0,4)=="chat")return false;var e=BX.MessengerCommon.getUserLastDate(this.users[this.currentTab]);this.popupMessengerPanelLastDate.innerHTML=e?". "+e:"";return true},this);t();this.popupMessengerPanelLastDateInterval=setInterval(t,6e4);this.popupMessengerPanelStatus.innerHTML=BX.MessengerCommon.getUserPosition(this.users[this.currentTab],false);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");this.popupMessengerPanelBotIcons=true}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;this.textareaIconToggle();s.push("bx-messenger-chat-guest");s.push("bx-messenger-chat-open");s.push("bx-messenger-chat-chat");s.push("bx-messenger-chat-call");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]};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.getChatId()];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()&&this.webrtc.phoneCanPerformCalls?"bx-messenger-panel-call-enabled":"bx-messenger-panel-call-disabled";return"bx-messenger-panel-call-phone "+e};BX.Messenger.prototype.chatListSearchAction=function(e){this.realSearch=true;this.popupContactListElementsWrap.appendChild(BX.create("div",{props:{className:"bx-messenger-cl-item-search"},html:BX.message("IM_M_CL_SEARCH")}));BX.remove(e);BX.MessengerCommon.contactListRealSearch(this.contactListSearchText)};BX.Messenger.prototype.toggleChatListGroup=function(){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");if(this.popupContactListElements){var e=BX.pos(BX.proxy_context,true);this.popupContactListElements.scrollTop=e.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")}};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",{props:{className:"bx-messenger-textarea-icons"},children:[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",bind:e.currentTarget});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(BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isDesktop()){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.getChatId=function(){return this.currentTab.toString().substr(4)};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.getChatId();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)}}if(this.popupMessengerFileFormChatId){this.popupMessengerFileFormChatId.value=t;if(this.chat[t]&&!this.disk.enableExternal&&this.chat[t].type=="lines"&&this.chat[t].entity_id.substr(0,8)!="livechat"){this.popupMessengerFileFormInput.setAttribute("disabled",true)}else{if(parseInt(this.popupMessengerFileFormChatId.value)>0){this.popupMessengerFileFormInput.removeAttribute("disabled")}else{this.popupMessengerFileFormInput.setAttribute("disabled",true)}}}this.renameChatDialogFlag=false;BX.style(this.popupOpenLinesSpam,"display","");BX.style(this.popupOpenLinesClose,"display","none");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;if(this.popupMessengerPanelCallDescription)this.popupMessengerPanelCallDescription.innerText=this.chat[t]&&this.chat[t].entity_data_1&&this.chat[t].entity_data_1.toString().charAt(0)==="Y"?this.chat[t].call_number:BX.message("IM_PHONE_DESC");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-lines");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.addClass(this.popupMessengerDialog,"bx-messenger-chat-call");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 o=BX.MessengerCommon.livechatGetSession(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 o=BX.MessengerCommon.linesGetSession(this.chat[t]);BX.addClass(this.popupMessengerPanelAvatarForm2,"bx-messenger-panel-avatar-lines");BX.addClass(this.popupMessengerPanelAvatarForm2,"bx-messenger-panel-avatar-"+BX.MessengerCommon.linesGetSource(this.chat[t]));i.push("bx-messenger-chat-lines");s.push("bx-messenger-chat-chat");s.push("bx-messenger-chat-livechat");if(!BX.MessengerCommon.userInChat(t)){n=true;BX.style(this.popupOpenLinesTransfer,"display","none");BX.style(this.popupMessengerTextareaOpenLinesTransfer,"display",o.id?"inline-block":"none");this.popupMessengerTextareaOpenLinesAnswer.innerHTML=o.id?BX.message("IM_OL_INVITE_JOIN_2"):BX.message("IM_OL_INVITE_JOIN");this.popupMessengerTextareaOpenLinesSkip.innerHTML=BX.message("IM_OL_INVITE_CLOSE");this.popupMessengerTextareaOpenLinesText.innerHTML=o.id?BX.message("IM_OL_INVITE_TEXT_JOIN"):BX.message("IM_OL_INVITE_TEXT_OPEN")}else if(this.chat[t].owner==0){n=true;BX.style(this.popupOpenLinesTransfer,"display","none");BX.style(this.popupOpenLinesClose,"display","none");BX.style(this.popupMessengerTextareaOpenLinesTransfer,"display",o.id?"inline-block":"none");this.popupMessengerTextareaOpenLinesAnswer.innerHTML=o.id?BX.message("IM_OL_INVITE_ANSWER"):BX.message("IM_OL_INVITE_JOIN");this.popupMessengerTextareaOpenLinesSkip.innerHTML=o.id?BX.message("IM_OL_INVITE_SKIP"):BX.message("IM_OL_INVITE_CLOSE");this.popupMessengerTextareaOpenLinesText.innerHTML=o.id?BX.message("IM_OL_INVITE_TEXT"):BX.message("IM_OL_INVITE_TEXT_OPEN")}else{if(this.chat[t].owner==this.BXIM.userId){BX.style(this.popupOpenLinesTransfer,"display","block");BX.style(this.popupOpenLinesClose,"display","block")}else{BX.style(this.popupOpenLinesTransfer,"display","none");BX.style(this.popupOpenLinesClose,"display","none")}}if(o.id&&parseInt(this.chat[t].owner)>0){BX.style(this.popupOpenLinesSpam,"display","")}else{BX.style(this.popupOpenLinesSpam,"display","block")}if(this.linesSilentMode[t]){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(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" onclick="BXIM.closeMessenger()" 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(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")}}s.push("bx-messenger-chat-call");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");if(this.chat[t].entity_type!=""&&BX.MessengerCommon.getEntityTypePath(t)){this.popupMessengerPanelChat.className="bx-messenger-panel bx-messenger-context-chat bx-messenger-panel-with-menu"}else{this.popupMessengerPanelChat.className="bx-messenger-panel bx-messenger-context-chat"}if(this.chat[t].entity_type!=""&&BX.MessengerCommon.checkRestriction(t,"EXTEND")){BX.style(this.popupMessengerPanelButtonExtend,"display","none")}else{BX.style(this.popupMessengerPanelButtonExtend,"display","block")}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 r=false;this.popupMessengerPanelUsers.innerHTML="";if(this.userInChat[t]){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(o.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||!c.active){continue}if(this.chat[t].entity_type=="LINES"&&this.chat[t].owner==0&&c.id!=this.BXIM.userId&&!(c.bot||c.connector)){continue}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)+(this.chat[t].owner==c.id?" bx-notifier-popup-avatar-owner":"")+(c.extranet&&!c.connector?" 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" title="'+c.name+'"></span>'+"</span>"+'<span class="bx-notifier-popup-user-name'+(c.extranet&&!c.connector?" bx-messenger-panel-chat-user-name-extranet":"")+(c.connector?" bx-messenger-panel-chat-user-name-lines":"")+(c.bot?" bx-messenger-panel-chat-user-name-bot":"")+'">'+c.name+"</span>"+"</span>";r=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&&c.active){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)+(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" title="'+c.name+'"></span>'+"</span>"+"</span>";r=true}}if(r&&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(!r){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.getChatId();if(this.renameChatDialogFlag||!BX.MessengerCommon.userInChat(e)||BX.MessengerCommon.checkRestriction(e,"RENAME"))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&&!BX.MessengerCommon.isDesktop()){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}BX.MessengerCommon.contactListSearchClear();this.closePopupFileMenu();if(this.popupPopupMenu!=null)this.popupPopupMenu.destroy();if(this.popupSmileMenu!=null){this.popupSmileMenu.destroy()}if(this.commandPopup!=null){this.commandPopup.destroy()}if(this.popupIframeMenu!=null&&this.popupIframeBind){this.popupIframeMenu.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:BX.MessengerCommon.isPage()?39:210};var a=BX.MessengerCommon.isPage()?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=BX.MessengerCommon.isPage()?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 o=e.bind?e.bind:null;var r=e.type!="CHAT_EXTEND"||this.chat[e.chatId].entity_type=="LINES";this.popupChatDialog=new BX.PopupWindow("bx-messenger-popup-newchat",o,{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.getChatId(),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")})}),r?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}});BX.bindDelegate(this.popupChatDialogContactListElements,"click",{className:"bx-messenger-chatlist-more"},BX.delegate(this.toggleChatListGroup,this));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!=""){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()}}else{var a=BX.findChildByClassName(this.popupChatDialogContactListElements,"bx-messenger-chatlist-search-button");if(a){this.popupChatDialogContactListElements.appendChild(BX.create("div",{props:{className:"bx-messenger-cl-item-search"},html:BX.message("IM_M_CL_SEARCH")}));BX.remove(a);this.BXIM.messenger.realSearch=true;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));return true}}if(this.BXIM.messenger.realSearch){this.BXIM.messenger.realSearchFound=true}}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-chatlist-search-button"},BX.delegate(function(){this.popupChatDialogContactListElements.appendChild(BX.create("div",{props:{className:"bx-messenger-cl-item-search"},html:BX.message("IM_M_CL_SEARCH")}));BX.remove(BX.proxy_context.parentNode);this.BXIM.messenger.realSearch=true;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))},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=o.value.substr(0,o.selectionEnd);s=s.substr(s.lastIndexOf(e.delimiter),o.selectionEnd-s.lastIndexOf(e.delimiter));o.value=o.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.toString();var n=s.substr(0,9)=="structure";var o=false;var r="";if(n){var l=s.substr(9);r=this.groups[l].name.split(" / ")[0]}else{r=this.users[s].name;o=this.users[s].extranet}t++;e+='<span class="bx-messenger-dest-block'+(o?" bx-messenger-dest-block-extranet":"")+(n?" bx-messenger-dest-block-structure":"")+'">'+'<span class="bx-messenger-dest-text">'+r+"</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 p=BX.MessengerCommon.countObject(this.popupChatDialogUsers);if(p>=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(p){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,9)=="structure"){e.users[s]=parseInt(e.users[s].toString().substr(9));if(e.users[s]<0)continue;e.users[s]="structure"+e.users[s]}else if(e.users[s].toString().substr(0,7)=="network"){}else{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&&this.popupChatDialogShowHistory.checked?"Y":"N",USERS:JSON.stringify(e.users),IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()};this.BXIM.options.chatExtendShowHistory=this.popupChatDialogShowHistory&&this.popupChatDialogShowHistory.checked;BXIM.setLocalConfig("mcesh",this.BXIM.options.chatExtendShowHistory)}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 o=13;var r=[];var l={};var p={offset:4};this.popupPopupMenuStyle="";if(i.offsetTop)n=i.offsetTop;if(i.offsetLeft)o=i.offsetLeft;if(i.anglePosition)p.position=i.anglePosition;if(t=="createChat"){l={position:"bottom"};if(i.openDesktop){r=[{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){r=[{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{r=[{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=="pathMenu"){var h=this.getChatId();var c=BX.MessengerCommon.getEntityTypePath(h);n=5;o=14;r=[{icon:"bx-messenger-menu-crm",text:c["TITLE"],href:c["PATH"],target:"_blank",onclick:BX.delegate(function(){this.closeMenuPopup()},this)},{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=="openLinesMenu"){var h=this.getChatId();var u=this.chat[h].owner==this.BXIM.userId;var m=BX.MessengerCommon.linesGetSession(this.chat[h]);n=5;o=14;r=[u?{icon:"bx-messenger-menu-pause",text:BX.message(m.pin=="Y"?"IM_M_OL_PAUSE_OFF":"IM_M_OL_PAUSE_ON"),onclick:BX.delegate(function(){this.linesTogglePinMode();this.closeMenuPopup()},this)}:null,u&&m.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,m.crmLink?{icon:"bx-messenger-menu-crm",text:BX.message("IM_M_OL_GOTO_CRM"),href:m.crmLink,target:"_blank",onclick:BX.delegate(function(){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)},m.id?{separator:true}:null,!u&&m.id?{icon:"bx-messenger-menu-intercept",text:BX.message("IM_M_OL_INTERCEPT"),onclick:BX.delegate(function(){this.linesInterceptSession();this.closeMenuPopup()},this)}:null,u&&m.id?{icon:"bx-messenger-menu-spam",text:BX.message("IM_M_OL_FORCE_CLOSE"),onclick:BX.delegate(function(){this.linesMarkAsSpam();this.closeMenuPopup()},this)}:null]}else if(t=="textareaAppsMenu"){r=[];for(var d=0;d<this.textareaIcon.length;d++){if(!this.textareaIcon[d]||this.BXIM.userExtranet&&!this.textareaIcon[d]["extranet"]||this.textareaIcon[d].hidden){continue}if(this.desktop.ready()&&!this.desktop.enableInVersion(39)&&this.textareaIcon[d]["iframe"]){if(BXDesktopSystem.GetProperty("versionParts").join(".")!="5.0.32.38"){continue}}if(!this.textareaIcon[d]["title"]&&!this.textareaIcon[d]["url"]){continue}if(this.textareaIcon[d]["url"]){continue}var g=this.textareaIcon[d]["description"]?this.textareaIcon[d]["description"]:this.textareaIcon[d]["title"];r.push({text:BX.util.htmlspecialchars(this.textareaIcon[d]["title"]),onclick:BX.delegate(function(e){this.textareaIconClick();return BX.PreventDefault(e)},this),attrs:{title:g,"data-context":this.textareaIcon[d]["context"],"data-code":this.textareaIcon[d]["code"],"data-id":this.textareaIcon[d]["id"]}})}n=5;o=14}else if(t=="status"){o=9;l={position:"top"};r=[{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 f=e.getAttribute("data-id");r=[{text:BX.message("IM_MENU_DELETE"),onclick:BX.delegate(function(t){this.removeRecentSmile(f);BX.remove(e);this.popupPopupMenu.close();return BX.PreventDefault(t)},this)}]}else if(t=="notifyDelete"){var B=e.getAttribute("data-notifyId");var X=this.notify.notify[B].settingName;var M=typeof this.BXIM.settingsNotifyBlocked[X]=="undefined"?BX.message("IM_NOTIFY_DELETE_2"):BX.message("IM_NOTIFY_DELETE_3");if(typeof i.applyToDom!="undefined"){e=i.applyToDom}r=[this.notify.unreadNotify[B]?{text:BX.message("IM_MENU_READ"),onclick:BX.delegate(function(){this.notify.viewNotify(B,true);this.closeMenuPopup()},this)}:null,!this.notify.unreadNotify[B]?{text:BX.message("IM_MENU_UNREAD"),onclick:BX.delegate(function(){this.notify.viewNotify(B,false);this.closeMenuPopup()},this)}:null,{text:BX.message("IM_NOTIFY_DELETE_1"),onclick:BX.delegate(function(){this.notify.deleteNotify(B);this.closeMenuPopup()},this)},{text:M,onclick:BX.delegate(function(){this.notify.blockNotifyType(X);this.closeMenuPopup()},this)}]}else if(t=="callMenu"){n=2;o=20;r=[{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){r.push({separator:true});r.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)});r.push({icon:"bx-messenger-menu-call-video",text:BX.message("IM_CALL_MIC_TEST_BUTTON"),onclick:BX.delegate(function(){this.BXIM.webrtc.startMicTest();this.closeMenuPopup()},this)})}if(this.BXIM.webrtc.phoneCanCallUserNumber&&!this.openChatFlag&&this.phones[this.currentTab]){r.push({separator:true});if(this.phones[this.currentTab].PERSONAL_MOBILE){r.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){r.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){r.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){r.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;o=25;r=[{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)}];r.push({separator:true});if(this.phones[i.userId]&&this.BXIM.webrtc.phoneCanCallUserNumber){r.push({separator:true});if(this.phones[i.userId].PERSONAL_MOBILE){r.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){r.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){r.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;o=25;i.onSelect=BX.type.isFunction(i.onSelect)?i.onSelect:BX.DoNothing;r=[{icon:"bx-messenger-menu-call-voice",text:BX.message("IM_PHONE_INNER_CALL"),onclick:BX.delegate(function(){this.closeMenuPopup();i.onSelect({type:"user",userId:i.userId})},this)}];if(this.phones[i.userId]){r.push({separator:true});if(this.phones[i.userId].PERSONAL_MOBILE){r.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();i.onSelect({type:"phone",userId:i.userId,phone:this.phones[i.userId].PERSONAL_MOBILE})},this)})}if(this.phones[i.userId].PERSONAL_PHONE){r.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();i.onSelect({type:"phone",userId:i.userId,phone:this.phones[i.userId].PERSONAL_PHONE})},this)})}if(this.phones[i.userId].WORK_PHONE){r.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();i.onSelect({type:"phone",userId:i.userId,phone:this.phones[i.userId].WORK_PHONE})},this)})}}}else if(t=="callContextMenu"){var I=BX.MessengerCommon.phoneGetCallFields(this.getChatId());r=[{icon:"bx-messenger-menu-history-2",text:BX.message("IM_M_HISTORY"),onclick:BX.delegate(function(){this.openHistory(this.currentTab);this.closeMenuPopup()},this)},I.crm?{icon:"bx-messenger-menu-crm",text:BX.message("IM_M_OL_GOTO_CRM"),href:I.crmShowUrl,target:"_blank",onclick:BX.delegate(function(){this.closeMenuPopup()},this)}:null]}else if(t=="chatUser"){var C=e.getAttribute("data-userId");var h=this.getChatId();var u=this.chat[h].owner==this.BXIM.userId;if(this.users[this.BXIM.userId].connector){return false}if(C==this.BXIM.userId){var b=BX.MessengerCommon.checkRestriction(h,"LEAVE")||this.chat[h].type=="lines"&&(this.chat[h].owner==0||this.chat[h].owner==this.BXIM.userId);r=[{icon:"bx-messenger-menu-profile",text:BX.message("IM_M_OPEN_PROFILE"),href:this.BXIM.path.profile,onclick:BX.delegate(function(){this.closeMenuPopup()},this)},b?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[C].connector){var m=BX.MessengerCommon.linesGetSession(this.chat[h]);r=[{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[C].name)+" ",false);BX.MessengerCommon.addMentionList(this.currentTab,BX.util.htmlspecialcharsback(this.users[C].name),C);this.popupMessengerTextarea.focus();this.closeMenuPopup()},this)},u&&m.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,m.crmLink?{icon:"bx-messenger-menu-crm",text:BX.message("IM_M_OL_GOTO_CRM"),href:m.crmLink,target:"_blank",onclick:BX.delegate(function(){this.closeMenuPopup()},this)}:null]}else{var y=!BX.MessengerCommon.checkRestriction(h,"LEAVE")&&this.chat[h].owner==this.BXIM.userId;var x=true;if(h!=this.generalChatId){x=BX.MessengerCommon.userInChat(h)}else if(!this.canSendMessageGeneralChat||this.BXIM.settings.generalNotify){x=false}if(y&&this.chat[h].type=="open"){y=this.users[C].extranet?true:false}r=[!x?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[C].name)+" ",false);BX.MessengerCommon.addMentionList(this.currentTab,BX.util.htmlspecialcharsback(this.users[C].name),C);this.popupMessengerTextarea.focus();this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-write",text:BX.message("IM_M_WRITE_MESSAGE"),onclick:BX.delegate(function(){this.openMessenger(C);this.closeMenuPopup()},this)},!this.webrtc.callSupport(C,this)||this.webrtc.callInit?null:{icon:"bx-messenger-menu-video",text:BX.message("IM_M_CALL_VIDEO"),onclick:BX.delegate(function(){this.BXIM.callTo(C,true);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-history",text:BX.message("IM_M_OPEN_HISTORY"),onclick:BX.delegate(function(){this.openHistory(C);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-profile",text:BX.message("IM_M_OPEN_PROFILE"),href:this.users[C].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,C);this.closeMenuPopup()},this)}:{}]}}else if(t=="contactList"){n=2;o=25;var C=e.getAttribute("data-userId");var v=e.getAttribute("data-userIsChat")===true||e.getAttribute("data-userIsChat")=="true";var T=e.getAttribute("data-isPinned")===true||e.getAttribute("data-isPinned")=="true";if(this.recentList||v){var S=this.chat[C.toString().substr(4)]&&this.chat[C.toString().substr(4)].type=="lines";var _=BX.message("IM_M_CHAT_MUTE_OFF");var N=false;if(v){N=true}else if(this.users[C].extranet){N=true}if(N&&this.muteButtonStatus(C)){_=BX.message("IM_M_CHAT_MUTE_ON")}var E=BX.message(!T?"IM_M_OL_PIN_ON":"IM_M_OL_PIN_OFF");hideItem=!BX.MessengerCommon.userInChat(C.toString().substr(4));r=[S?null:{icon:"bx-messenger-menu-write",text:BX.message("IM_M_WRITE_MESSAGE"),onclick:BX.delegate(function(){this.openMessenger(C);this.closeMenuPopup()},this)},S?null:{icon:"bx-messenger-menu-pin",text:E,onclick:BX.delegate(function(){BX.MessengerCommon.pinDialog(C,!T);this.closeMenuPopup()},this)},!S&&!hideItem&&N?{icon:"bx-messenger-menu-chat-mute",text:_,onclick:BX.delegate(function(){BX.MessengerCommon.muteMessageChat(C);this.closeMenuPopup()},this)}:{},S||(!this.webrtc.callSupport(C,this)||this.webrtc.callInit)||v&&(this.chat[C.toString().substr(4)].type=="call"||this.chat[C.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(C,true);this.closeMenuPopup()},this)},hideItem&&!v?null:{icon:"bx-messenger-menu-history",text:BX.message("IM_M_OPEN_HISTORY"),onclick:BX.delegate(function(){this.openHistory(C);this.closeMenuPopup()},this)},!v?{icon:"bx-messenger-menu-profile",text:BX.message("IM_M_OPEN_PROFILE"),href:this.users[C].profile,onclick:BX.delegate(function(){this.closeMenuPopup()},this)}:{},!hideItem&&v&&this.chat[C.toString().substr(4)].type!="call"&&!BX.MessengerCommon.checkRestriction(C.toString().substr(4),"RENAME")?{icon:"bx-messenger-menu-chat-rename",text:BX.message("IM_M_CHAT_RENAME"),onclick:BX.delegate(function(){if(this.currentTab!=C){this.openMessenger(C)}else{this.renameChatDialog()}this.closeMenuPopup()},this)}:{},S||v&&!this.recentList?null:{icon:"bx-messenger-menu-hide-"+(v?"chat":"dialog"),text:BX.message("IM_M_HIDE_"+(v?this.chat[C.toString().substr(4)].type=="call"?"CALL":"CHAT":"DIALOG")),onclick:BX.delegate(function(){BX.MessengerCommon.recentListHide(C);this.closeMenuPopup()},this)},!hideItem&&v&&this.chat[C.toString().substr(4)].type!="call"&&this.chat[C.toString().substr(4)].type!="lines"&&!BX.MessengerCommon.checkRestriction(C.toString().substr(4),"LEAVE")?{icon:"bx-messenger-menu-chat-exit",text:BX.message("IM_M_CHAT_EXIT"),onclick:BX.delegate(function(){BX.MessengerCommon.leaveFromChat(C.toString().substr(4));this.closeMenuPopup()},this)}:{}]}else{r=[{icon:"bx-messenger-menu-write",text:BX.message("IM_M_WRITE_MESSAGE"),onclick:BX.delegate(function(){this.openMessenger(C);this.closeMenuPopup()},this)},!v&&(!this.webrtc.callSupport(C,this)||this.webrtc.callInit)?null:{icon:"bx-messenger-menu-video",text:BX.message("IM_M_CALL_VIDEO"),onclick:BX.delegate(function(){this.BXIM.callTo(C,true);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-history",text:BX.message("IM_M_OPEN_HISTORY"),onclick:BX.delegate(function(){this.openHistory(C);this.closeMenuPopup()},this)},{icon:"bx-messenger-menu-profile",text:BX.message("IM_M_OPEN_PROFILE"),href:this.users[C].profile,onclick:BX.delegate(function(){this.closeMenuPopup()},this)}]}}else if(t=="dialogContext"||t=="dialogMenu"){var w=[];if(t=="dialogMenu"){this.popupPopupMenuStyle="bx-messenger-content-item-menu-hover";p={offset:12};if(e.parentNode.parentNode){w=[BX("im-message-"+e.parentNode.parentNode.getAttribute("data-blockmessageid"))]}}else{var A=false;if(e.target.className.indexOf("bx-messenger-file")>=0||e.target.className.indexOf("bx-bxu-proper-canvas")>=0){var k=BX.findParent(e.target,{className:"bx-messenger-file-box"});if(k&&k.previousSibling){A=true;w=[k.previousSibling]}}if(!A){if(BX.hasClass(e.target,"bx-messenger-message")){w=[e.target]}else if(e.target.className.indexOf("bx-messenger-content-quote")>=0){w=BX.findParent(e.target,{className:"bx-messenger-message"});w=[w]}else{w=BX.findChildrenByClassName(e.target,"bx-messenger-message")}if(w.length<=0){w=BX.findParent(e.target,{className:"bx-messenger-message"});if(!w){if(e.target.className.substr(0,19)=="bx-messenger-attach"){var D=BX.findParent(e.target,{className:"bx-messenger-attach-box"});w=D.previousSibling}}w=[w]}}}if(w.length<=0||!w[w.length-1])return false;var L=BX.message("IM_M_SYSTEM_USER");var O=w[w.length-1].id.replace("im-message-","");if(this.message[O].senderId&&this.users[this.message[O].senderId])L=this.users[this.message[O].senderId].name;if(O.substr(0,4)=="temp")return false;var P=this.message[O].date;var R=t=="dialogContext"?BX.desktop.clipboardSelected():{text:"",selectionStart:0,selectionEnd:0};var H=false;var U="";var C=this.message[O].senderId;var F=this.message[O].params&&this.message[O].params.DATE_TS&&this.message[O].params.DATE_TS.length>0;if(this.openChatFlag&&this.message[O].senderId!=this.BXIM.userId&&this.users[this.message[O].senderId]){U=this.users[this.message[O].senderId].name}var W=null;var V="";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")V=e.target.href;else if(e.target.parentNode.tagName=="A")V=e.target.parentNode.href;else if(e.target.parentNode.parentNode.tagName=="A")V=e.target.parentNode.parentNode.href;if(V.indexOf("/desktop_app/")<0)H=true}else if(t=="dialogContext"&&e.target.tagName=="IMG"&&e.target.classList.contains("bx-icon")){W=e.target.src}var G=this.message[O].params&&this.message[O].params.FILE_ID&&this.message[O].params.FILE_ID.length>0&&BX.clipboard.isCopySupported();var Y=false;if(t=="dialogContext"&&BX.desktop){Y=true}var j=false;var z=false;if(BX.MessengerCommon.checkEditMessage(O,"edit")){j=true}if(BX.MessengerCommon.checkEditMessage(O,"delete")){z=true}if(this.openChatFlag&&this.message[O].chatId&&!BX.MessengerCommon.userInChat(this.message[O].chatId)){return false}var K=false;if(this.openChatFlag&&this.message[O].chatId&&this.generalChatId==this.message[O].chatId){if(this.BXIM.isAdmin&&!this.message[O].isNowDeleted){z=true}if(!this.canSendMessageGeneralChat){K=true}}var J=R.text.length>0||this.users[this.BXIM.userId].extranet;var q=J||!this.chat[this.message[O].chatId]||this.chat[this.message[O].chatId].entity_type!="LINES";var Z={text:BX.message("IM_MENU_TO_OL_QA"),onclick:BX.delegate(function(){BX.MessengerCommon.linesSaveToQuickAnswers(O);this.closeMenuPopup()},this)};if(this.message[O].quick_saved){Z.text=BX.message("IM_MENU_TO_OL_QA_ADDED");Z.onclick=null}r=[U.length<=0||K?null:{text:BX.message("IM_MENU_ANSWER"),onclick:BX.delegate(function(e){this.insertTextareaText(this.popupMessengerTextarea," "+BX.util.htmlspecialcharsback(U)+" ",false);BX.MessengerCommon.addMentionList(this.currentTab,BX.util.htmlspecialcharsback(U),C);setTimeout(BX.delegate(function(){this.popupMessengerTextarea.focus()},this),200);this.closeMenuPopup()},this)},U.length<=0||K?null:{separator:true},H?{text:BX.message("IM_MENU_COPY3"),onclick:BX.delegate(function(){BX.clipboard.copy(V);this.closeMenuPopup()},this)}:null,G?{text:BX.message("IM_MENU_COPY_FILE"),onclick:BX.delegate(function(){var e="";for(var t=0;t<this.message[O].params.FILE_ID.length;t++){e=e+"[DISK="+this.message[O].params.FILE_ID[t]+"]"}BX.clipboard.copy(e);this.closeMenuPopup()},this)}:null,W?{text:BX.message("IM_SETTINGS_SAVE"),onclick:BX.delegate(function(){this.addRecentSmile(this.message[O].text,W);this.closeMenuPopup()},this)}:null,W||G||H&&this.message[O].text?{separator:true}:null,C==this.BXIM.userId||R.text.length>0?null:{text:BX.message("IM_MENU_UNREAD"),onclick:BX.delegate(function(){BX.MessengerCommon.unreadMessage(O);this.closeMenuPopup()},this)},C==this.BXIM.userId?null:{separator:true},R.text.length<=0||K?null:{text:BX.message("IM_MENU_QUOTE"),onclick:BX.delegate(function(){var e=BX.IM.getSelectionText();this.insertQuoteText(L,P,e);this.closeMenuPopup()},this)},K||R.text.length>0||!this.message[O].text&&(!this.message[O].params||this.message[O].params.FILE_ID.length<=0)?null:{text:BX.message("IM_MENU_QUOTE2"),onclick:BX.delegate(function(){var e=[];for(var t=0;t<w.length;t++){var s=w[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(L,P,e.join("\n"))}this.closeMenuPopup()},this)},!Y||R.text.length<=0?null:{text:BX.message("IM_MENU_COPY"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy();this.closeMenuPopup()},this)},!Y||!this.message[O].text||R.text.length>0?null:{text:BX.message("IM_MENU_COPY2"),onclick:BX.delegate(function(){var e=[];for(var t=0;t<w.length;t++){var s=w[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(L,P,e.join("\n"),false)},this))}this.closeMenuPopup()},this)},J?null:{separator:true},J?null:{text:BX.message("IM_MENU_TO_TASK"),onclick:BX.delegate(function(){this.shareMessage(O,"TASK");this.closeMenuPopup()},this)},J||!F?null:{text:BX.message("IM_MENU_TO_CALEND"),onclick:BX.delegate(function(){this.shareMessage(O,"CALEND");this.closeMenuPopup()},this)},J?null:{text:BX.message("IM_MENU_TO_CHAT"),onclick:BX.delegate(function(){this.shareMessage(O,"CHAT");this.closeMenuPopup()},this)},J?null:{text:BX.message("IM_MENU_TO_POST"),onclick:BX.delegate(function(){this.shareMessage(O,"POST");this.closeMenuPopup()},this)},q?null:{separator:true},q?null:{text:BX.message("IM_MENU_TO_OL_START"),onclick:BX.delegate(function(){BX.MessengerCommon.linesStartSessionByMessage(O);this.closeMenuPopup()},this)},q?null:Z,!(!j||this.message[O].senderId!=this.BXIM.userId)||z?{separator:true}:null,!j||this.message[O].senderId!=this.BXIM.userId?null:{text:BX.message("IM_MENU_EDIT"),onclick:BX.delegate(function(){this.editMessage(O);this.closeMenuPopup()},this)},!z?null:{text:BX.message("IM_M_HISTORY_DELETE"),onclick:BX.delegate(function(){this.deleteMessage(O,false);this.closeMenuPopup()},this)}];if(this.message[O].params&&this.message[O].params.MENU){var Q=true;for(var d=0;d<this.message[O].params.MENU.length;d++){var $=this.message[O].params.MENU[d];if($.CONTEXT&&(BX.MessengerCommon.isMobile()&&$.CONTEXT=="DESKTOP"||!BX.MessengerCommon.isMobile()&&$.CONTEXT=="MOBILE")){continue}if(Q){r.push({separator:true});Q=false}var ee=$.DISABLED=="Y";r.push({text:$.TEXT,disabled:ee,icon:"bx-messenger-menu-important",dataParams:$,href:$.LINK?$.LINK:"",onclick:ee?null:BX.delegate(function(){var e=JSON.parse(BX.proxy_context.getAttribute("data-params"));if(e.FUNCTION){var t=e.FUNCTION.toString().replace("#MESSAGE_ID#",O).replace("#DIALOG_ID#",dialogId).replace("#USER_ID#",this.BXIM.userId);t()}else if(e.APP_ID){e.APP_PARAMS=e.APP_PARAMS?e.APP_PARAMS:"";this.textareaIconDialogClick(parseInt(e.APP_ID),O,BX.util.htmlspecialchars(e.APP_PARAMS))}this.closeMenuPopup()},this)})}}}else if(t=="shareMenu"){var O=e.getAttribute("data-messageId");var te=e.getAttribute("data-ts");var J=this.users[this.BXIM.userId].extranet;r=[J?null:{text:BX.message("IM_MENU_TO_TASK"),onclick:BX.delegate(function(){this.shareMessage(O,"TASK",te);this.closeMenuPopup()},this)},J?null:{text:BX.message("IM_MENU_TO_CALEND"),onclick:BX.delegate(function(){this.shareMessage(O,"CALEND",te);this.closeMenuPopup()},this)},J?null:{text:BX.message("IM_MENU_TO_CHAT"),onclick:BX.delegate(function(){this.shareMessage(O,"CHAT",te);this.closeMenuPopup()},this)}]}else if(t=="history"){var w=[];if(e.target.className=="bx-messenger-history-item"){w=[e.target]}else if(e.target.className.indexOf("bx-messenger-content-quote")>=0){w=BX.findParent(e.target,{className:"bx-messenger-history-item"});w=[w]}else{w=BX.findChildrenByClassName(e.target,"bx-messenger-history-item")}if(w.length<=0){w=BX.findParent(e.target,{className:"bx-messenger-history-item"});w=[w]}if(w.length<=0||!w[w.length-1])return false;var L=BX.message("IM_M_SYSTEM_USER");var O=w[w.length-1].getAttribute("data-messageId");if(this.message[O].senderId&&this.users[this.message[O].senderId])L=this.users[this.message[O].senderId].name;var P=this.message[O].date;if(BX.desktop){var R=BX.desktop.clipboardSelected();var H=false;var V="";if(e.target.tagName=="IMG"&&e.target.parentNode.tagName=="A"||e.target.tagName=="A"){if(e.target.tagName=="A")V=e.target.href;else V=e.target.parentNode.href;if(V.indexOf("/desktop_app/")<0||V.indexOf("/desktop_app/show.file.php")>=0)H=true}var se=this.BXIM.messenger.historySearch?true:false;r=[se?{text:BX.message("IM_HISTORY_RELATED"),onclick:BX.delegate(function(){this.showContext(O);this.closeMenuPopup()},this)}:null,se?{separator:true}:null,H?{text:BX.message("IM_MENU_COPY3"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy(BX.delegate(function(){return V},this));this.closeMenuPopup()},this)}:null,H?{separator:true}:null,R.text.length<=0?null:{text:BX.message("IM_MENU_QUOTE"),onclick:BX.delegate(function(){var e=BX.IM.getSelectionText();this.insertQuoteText(L,P,e);this.closeMenuPopup()},this)},{text:BX.message("IM_MENU_QUOTE2"),onclick:BX.delegate(function(){var e=[];for(var t=0;t<w.length;t++){var s=w[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(L,P,e.join("\n"))}this.closeMenuPopup()},this)},{separator:true},R.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<w.length;t++){var s=w[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(L,P,e.join("\n"),false)},this))}this.closeMenuPopup()},this)}]}else{var ie=this.popupMessengerTextarea||opener;var se=this.BXIM.messenger.historySearch?true:false;r=[se?{text:BX.message("IM_HISTORY_RELATED"),onclick:BX.delegate(function(){this.showContext(O);this.closeMenuPopup()},this)}:null,ie?{separator:true}:null,ie?{text:BX.message("IM_MENU_QUOTE2"),onclick:BX.delegate(function(){var e=[];for(var t=0;t<w.length;t++){var s=w[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(L,P,e.join("\n"))}this.closeMenuPopup()},this)}:null,!se&&!ie?{text:BX.message("IM_P_CLOSE"),onclick:BX.delegate(function(){this.closeMenuPopup()},this)}:null]}}else if(t=="historyFileMenu"){n=4;o=8;this.popupPopupMenuStyle="bx-messenger-file-active";var ae=i.fileId;var h=i.chatId;var ne=true;if(!this.disk.files[h][ae])return false;var oe=this.disk.files[h][ae].authorId!=this.BXIM.userId;r=[ne?{text:BX.message("IM_F_DOWNLOAD"),href:this.disk.files[h][ae].urlDownload,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,ae,{boxId:"im-file-history-panel"});this.closeMenuPopup()},this)},this.chat[h]&&this.chat[h].type=="open"&&oe?null:{text:BX.message("IM_F_DELETE"),onclick:BX.delegate(function(){this.BXIM.openConfirm(oe?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,ae,{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 R=BX.desktop.clipboardSelected();var H=false;if(e.target.tagName=="A"&&(e.target.href.indexOf("/desktop_app/")<0||V.indexOf("/desktop_app/show.file.php")>=0)){H=true;var V=e.target.href}else if(e.target.parentNode.tagName=="A"&&(e.target.parentNode.href.indexOf("/desktop_app/")<0||V.indexOf("/desktop_app/show.file.php")>=0)){H=true;var V=e.target.parentNode.href}if(!H&&R.text.length<=0){var B=e.target.getAttribute("data-notifyId");if(!B){B=e.target.parentNode.parentNode.getAttribute("data-notifyId");if(!B){B=e.target.parentNode.getAttribute("data-notifyId")}}if(B){e.target.setAttribute("data-notifyId",B);this.openPopupMenu(e.target,"notifyDelete",false,{applyToDom:e})}return false}r=[H?{text:BX.message("IM_MENU_COPY3"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy(BX.delegate(function(){return V},this));this.closeMenuPopup()},this)}:null,H?{separator:true}:null,R.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;r=[{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}r=[];var R=BX.desktop.clipboardSelected(e.target,i.spell);if(!R.text){i.spell=false}if(i.spell){if(i.spellReady){for(var d=0;d<i.suggest.length;d++){dataParams={suggest:i.suggest[d],selectionStart:R.selectionStart,selectionEnd:R.selectionEnd};r.push({text:i.suggest[d],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(d==5)break}if(r.length<=0){r.push({text:BX.message("IM_MENU_SUGGEST_EMPTY"),bold:true,slim:true})}r.push({separator:true})}else{BXDesktopSystem.SpellCheckWord(R.text,BX.delegate(function(t,s){this.openPopupMenu(e,"copypaste",false,{spell:!t,spellReady:true,suggest:s})},this))}}if(!i.spell||i.spellReady){if(R.text.length){r.push({text:BX.message("IM_MENU_CUT"),onclick:BX.delegate(function(){BX.desktop.clipboardCut();this.closeMenuPopup()},this)}),r.push({text:BX.message("IM_MENU_COPY"),onclick:BX.delegate(function(){BX.desktop.clipboardCopy();this.closeMenuPopup()},this)}),r.push({text:BX.message("IM_MENU_DELETE"),onclick:BX.delegate(function(){BX.desktop.clipboardDelete();this.closeMenuPopup()},this)})}else{r.push({text:BX.message("IM_MENU_PASTE"),onclick:BX.delegate(function(){BX.desktop.clipboardPaste();this.closeMenuPopup()},this)})}l={position:"top"}}}else{r=[]}if(r.length<=0){return false}var re=true;for(var d=0;d<r.length;d++){if(r[d]){re=false}}if(re){r=[{text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),onclick:BX.delegate(function(){this.closeMenuPopup()},this)}]}else{var le=false;for(var d=0;d<r.length;d++){if(r[d]){if(r[d].separator){r[d]=null}else{break}}}}r=this.modifierPopupMenu(t,r);this.popupPopupMenuDateCreate=+new Date;this.popupPopupMenu=new BX.PopupWindow("bx-messenger-popup-"+t,e,{lightShadow:true,offsetTop:n,offsetLeft:o,autoHide:true,closeByEsc:true,zIndex:i.zIndex?i.zIndex:3001,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 if(this.popupPopupMenuStyle=="bx-messenger-content-item-menu-hover")BX.removeClass(this.popupPopupMenu.bindElement.parentNode,this.popupPopupMenuStyle);else BX.removeClass(this.popupPopupMenu.bindElement,this.popupPopupMenuStyle)}if(this.popupPopupMenuDateCreate+500<+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 if(this.popupPopupMenuStyle=="bx-messenger-content-item-menu-hover")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(r)})]})});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 if(this.popupPopupMenuStyle=="bx-messenger-content-item-menu-hover")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.modifierPopupMenu=function(e,t){var s=null;for(var i=0;i<this.popupPopupMenuModifyFunction.length;i++){s=this.popupPopupMenuModifyFunction[i](e,t);if(s){t=s}}return t};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=0;var n=10;var o={position:"top"};var r={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:r,children:[BX.create("div",{props:{className:"bx-messenger-external-data-load"},html:BX.message("IM_CL_LOAD")})]});if(t=="user"){r={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"){r={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"){r={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 m in this.BXIM.messenger.readedList[this.BXIM.messenger.currentTab]){if(m==this.BXIM.userId)continue;if(!u||u>this.BXIM.messenger.readedList[this.BXIM.messenger.currentTab][m].date){c=m;u=this.BXIM.messenger.readedList[this.BXIM.messenger.currentTab][m].date}h.push({userId:m,date:this.BXIM.messenger.readedList[this.BXIM.messenger.currentTab][m].date})}var d='<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+'"':"";d+='<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(this.users[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>"}d+="</span>";p=BX.create("div",{props:{className:"bx-messenger-popup-menu"},html:d})}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:o,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){e.CHAT[t].date_create=new Date(e.CHAT[t].date_create);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){e.USERS[t].last_activity_date=new Date(e.USERS[t].last_activity_date);e.USERS[t].mobile_last_date=new Date(e.USERS[t].mobile_last_date);e.USERS[t].idle=e.USERS[t].idle?new Date(e.USERS[t].idle):false;e.USERS[t].absent=e.USERS[t].absent?new Date(e.USERS[t].absent):false;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)}}}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}var s=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(this.users[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(this.users[t["USER_ID"]],false).title},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(this.users[t["USER_ID"]])})]}),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_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 i=BX.message("IM_CL_CHAT_2");if(this.chat[t["CHAT_ID"]].type=="call"){i=BX.message("IM_CL_PHONE")}else if(this.chat[t["CHAT_ID"]].type=="lines"){i=BX.message("IM_CL_LINES")}else if(this.chat[t["CHAT_ID"]].type=="livechat"){i=BX.message("IM_CL_LINES")}else if(this.chat[t["CHAT_ID"]].type=="open"){i=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:i})]}),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 a=false;if(t["CALL_RECORD_HTML"]){var a={HTML:BX.message("CALL_RECORD_ERROR"),SCRIPT:[]};if(!BX.MessengerCommon.isDesktop())a=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_FORMATTED"]?t["PHONE_NUMBER_FORMATTED"]:(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"]})]}),a?BX.create("div",{props:{className:"bx-messenger-record-box"},children:[BX.create("span",{props:{className:"bx-messenger-record-player"},html:a.HTML})]}):null]})]});if(a){for(var n=0;n<a.SCRIPT.length;n++){BX.evalGlobal(a.SCRIPT[n].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(!BX.MessengerCommon.isPage())this.setClosingByEsc(false);this.popupHistoryPanel=null;var n=this.redrawHistoryPanel(e,t);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&&BX.MessengerCommon.isDesktop()){this.desktop.openHistory(e,this.popupHistoryElements,"BXIM.openHistory('"+e+"');");return false}else if(BX.MessengerCommon.isDesktop()){this.popupHistory=new BX.PopupWindowDesktop;this.desktop.drawOnPlaceholder(this.popupHistoryElements);BX.bind(window,"keydown",BX.proxy(function(e){if(e.keyCode==27){if(this.popupHistorySearchInput.value==""){this.popupHistory.destroy()}else{this.popupHistorySearchInput.value="";this.popupHistorySearchInput.focus()}}},this))}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(BX.MessengerCommon.isDesktop()){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")=="openlines"){this.linesOpenHistory(BX.proxy_context.getAttribute("data-sessionId"))}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")=="date"){this.openPopupMenu(BX.proxy_context,"shareMenu")}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.popupHistoryElements,"click",{className:"bx-messenger-history-item-menu"},BX.delegate(function(e){this.openPopupMenu(e,"history",false);return BX.PreventDefault(e)},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=new Date(e.FILES[i].date);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.showContext=function(e){BX.ajax({url:this.BXIM.pathToAjax+"?LOAD_CONTEXT_MESSAGE&V="+this.BXIM.revision,method:"POST",dataType:"json",skipAuthCheck:true,timeout:30,data:{IM_LOAD_CONTEXT_MESSAGE:"Y",MESSAGE_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(t){if(t&&t.BITRIX_SESSID){BX.message({bitrix_sessid:t.BITRIX_SESSID})}if(t.ERROR==""){var s=t.DIALOG_ID;this.showMessage[s]=[];this.sendAjaxTry=0;for(var i in t.MESSAGE){t.MESSAGE[i].date=new Date(t.MESSAGE[i].date);this.message[i]=t.MESSAGE[i]}for(var i in t.FILES){if(!this.disk.files[t.CHAT_ID])this.disk.files[t.CHAT_ID]={};if(this.disk.files[t.CHAT_ID][i])continue;t.FILES[i].date=new Date(t.FILES[i].date);this.disk.files[t.CHAT_ID][i]=t.FILES[i]}for(var i in t.USERS){t.USERS[i].last_activity_date=new Date(t.USERS[i].last_activity_date);t.USERS[i].mobile_last_date=new Date(t.USERS[i].mobile_last_date);t.USERS[i].idle=t.USERS[i].idle?new Date(t.USERS[i].idle):false;t.USERS[i].absent=t.USERS[i].absent?new Date(t.USERS[i].absent):false;this.users[i]=t.USERS[i]}for(var i in t.USER_IN_GROUP){if(typeof this.userInGroup[i]=="undefined"){this.userInGroup[i]=t.USER_IN_GROUP[i]}else{for(var a=0;a<t.USER_IN_GROUP[i].users.length;a++)this.userInGroup[i].users.push(t.USER_IN_GROUP[i].users[a]);this.userInGroup[i].users=BX.util.array_unique(this.userInGroup[i].users)}}for(var i in t.PHONES){this.phones[i]={};for(var a in t.PHONES[i]){this.phones[i][a]=BX.util.htmlspecialcharsback(t.PHONES[i][a])}}var n=this.historySearch;this.historySearch="";this.drawHistory(t.DIALOG_ID,t.USERS_MESSAGE,false);this.historySearch=n;if(BX("im-message-history-"+e)){var o=BX("im-message-history-"+e).parentNode.offsetTop;this.popupHistoryItems.scrollTop=o-this.popupHistoryItems.offsetHeight/2+BX("im-message-history-"+e).parentNode.offsetHeight/2;BX.addClass(BX("im-message-history-"+e).parentNode,"bx-messenger-history-item-context");BX.addClass(this.popupHistoryBodyWrap,"bx-messenger-history-items-wrap-show-context")}}else{if(t.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<2){this.sendAjaxTry++;setTimeout(BX.delegate(function(){this.showContext(e)},this),1e3);BX.onCustomEvent(window,"onImError",[t.ERROR,t.BITRIX_SESSID])}else if(t.ERROR=="AUTHORIZE_ERROR"){this.sendAjaxTry++;if(BX.MessengerCommon.isDesktop()){setTimeout(BX.delegate(function(){this.showContext(e)},this),1e4)}BX.onCustomEvent(window,"onImError",[t.ERROR])}}},this),onfailure:BX.delegate(function(){this.sendAjaxTry=0},this)})};BX.Messenger.prototype.jumpToMessage=function(e){};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(BX.MessengerCommon.isDesktop())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=e.text;var n=BX.MessengerCommon.diskDrawFiles(e.chatId,e.params.FILE_ID,{status:["done","error"],boxId:"im-file-history"});if(n.length>0){n=BX.create("div",{props:{className:"bx-messenger-file-box"+(e.text!=""?" bx-messenger-file-box-with-message":"")},children:n})}else{n=null}var o=null;var r=[];if(e.params.ATTACH){for(var l=0;l<e.params.ATTACH.length;l++){r[l]=e.params.ATTACH[l]}var p=/\[ATTACH=([0-9]{1,})\]/gm;var h=[];while((h=p.exec(a))!==null){for(var l=0;l<r.length;l++){if(e.params.ATTACH[l].ID==h[1]){o=BX.create("div",{props:{className:"bx-messenger-attach-box"},children:BX.MessengerCommon.drawAttach(e.id,e.chatId,[r[l]])});a=a.replace("[ATTACH="+h[1]+"]",o.innerHTML);delete r[l]}}}}if(e.params.LINK_ACTIVE&&e.params.LINK_ACTIVE.length>0&&e.params.LINK_ACTIVE.indexOf(this.BXIM.userId.toString())<0){a=a.replace(/<a.*?href="([^"]*)".*?>(.*?)<\/a>/gi,"$2")}var c="";if(e.params.CLASS){c=e.params.CLASS}o=BX.MessengerCommon.drawAttach(e.id,e.chatId,r);if(o.length>0){o=BX.create("div",{props:{className:"bx-messenger-attach-box"},children:o})}else{o=null}var u=this.BXIM.messenger.users[e.senderId];if(e.params&&u&&u.id>0&&(e.params.AVATAR||e.params.NAME||e.params.USER_ID)){u=BX.clone(u);if(e.params.AVATAR){u.avatar=e.params.AVATAR}if(e.params.NAME){u.name=e.params.NAME;u.first_name=e.params.NAME.split(" ")[0]}e=BX.clone(e);if(parseInt(e.params.USER_ID)){e.senderId="network"+e.params.USER_ID}}var m=BX.MessengerCommon.linesVoteDraw(e.id);if(m){a=m;e.system="Y"}else{c=c.replace("bx-messenger-content-item-vote","");var d=BX.MessengerCommon.linesVoteResultDraw(e.id,a);if(d){a=d}}var g=null;if(typeof a=="string"){g=BX.create("span",{props:{className:"bx-messenger-history-item-text"+(i?" bx-messenger-message-deleted":" ")+(i||s?" bx-messenger-message-edited":"")},attrs:{id:"im-message-history-"+e.id},html:BX.MessengerCommon.prepareText(a,false,true,true,!this.BXIM.messenger.openChatFlag||e.senderId==this.BXIM.userId?false:this.BXIM.messenger.users[this.BXIM.userId].name)})}else{g=BX.create("span",{props:{className:"bx-messenger-history-item-text"+(i?" bx-messenger-message-deleted":" ")+(i||s?" bx-messenger-message-edited":"")},attrs:{id:"im-message-history-"+e.id},children:[a]})}if(n==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 f="";var B="";if(e.senderId>0&&u){f=u.avatar;B=u.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")+" "+c},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(f)?" bx-messenger-content-item-avatar-img-default":"")},attrs:{src:e.senderId>0?f:this.BXIM.pathToBlankImage,style:e.senderId>0&&BX.MessengerCommon.isBlankAvatar(f)&&B?"background-color: "+B:""}})]}),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",{props:{className:"bx-messenger-history-item-menu"}}),g,n,o,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,i){if(this.popupHistory==null)return false;i=typeof i=="undefined"?true:i;s=typeof s=="undefined"?true:s;var a=false;var n=0;if(e.toString().substr(0,4)=="chat"){a=true;n=e.toString().substr(4)}var o=[];var r=false;BX.removeClass(this.popupHistoryBodyWrap,"bx-messenger-history-items-wrap-show-context");this.popupHistoryBodyWrap.innerHTML="";var l=this.historySearch.length>0;var t=!t?this.history:t;if(t[e]&&(!a&&this.users[e]||a&&this.chat[n])){var p=BX.util.array_unique(t[e]);var h={};if(i){p.sort(BX.delegate(function(e,t){e=parseInt(e);t=parseInt(t);if(!this.message[e]||!this.message[t]){return 0}var s=this.message[e].date.getTime();var i=this.message[t].date.getTime();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 c=0;c<p.length;c++){if(l&&this.message[t[e][c]].text.toLowerCase().indexOf((this.historySearch+"").toLowerCase())<0)continue;var u=BX.MessengerCommon.formatDate(this.message[t[e][c]].date,BX.MessengerCommon.getDateFormatType("MESSAGE_TITLE"));if(!BX("bx-im-history-"+u)&&!h[u]){h[u]=true;o.push(BX.create("div",{props:{className:"bx-messenger-content-group bx-messenger-content-group-history"},children:[BX.create("div",{attrs:{id:"bx-im-history-"+u},props:{className:"bx-messenger-content-group-title"+(this.BXIM.language=="ru"?" bx-messenger-lowercase":"")},html:u})]}))}var m=this.drawMessageHistory(this.message[t[e][c]]);if(m)o.push(m)}if(o.length<=0){if(!this.historySearchBegin){r=true;o=[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;o=[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(o.length>0){BX.adjust(this.popupHistoryBodyWrap,{children:o});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:a?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(i){if(i&&i.BITRIX_SESSID){BX.message({bitrix_sessid:i.BITRIX_SESSID})}if(i.ERROR==""){if(!a){if(!this.userChat[e]){this.userChat[e]=i.CHAT_ID}}for(var n in i.FILES){if(!this.disk.files[i.CHAT_ID])this.disk.files[i.CHAT_ID]={};if(this.disk.files[i.CHAT_ID][n])continue;i.FILES[n].date=new Date(i.FILES[n].date);this.disk.files[i.CHAT_ID][n]=i.FILES[n]}this.showMessage[e]=[];this.sendAjaxTry=0;for(var n in i.MESSAGE){i.MESSAGE[n].date=new Date(i.MESSAGE[n].date);this.message[n]=i.MESSAGE[n];if(this.BXIM.settings.loadLastMessage)this.showMessage[e].push(n)}for(var n in i.USERS_MESSAGE){if(this.history[n])this.history[n]=BX.util.array_merge(this.history[n],i.USERS_MESSAGE[n]);else this.history[n]=i.USERS_MESSAGE[n]}if(!a&&this.users[e]&&!this.users[e].fake||a&&this.chat[i.CHAT_ID]&&!this.chat[i.CHAT_ID].fake){BX.cleanNode(this.popupHistoryBodyWrap);if(!i.USERS_MESSAGE[e]||i.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<i.USERS_MESSAGE[e].length;n++){var o=BX.MessengerCommon.formatDate(this.message[i.USERS_MESSAGE[e][n]].date,BX.MessengerCommon.getDateFormatType("MESSAGE_TITLE"));var r=typeof BX.translit!="undefined"?BX.translit(o):o;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:o})]}))}var l=this.drawMessageHistory(this.message[i.USERS_MESSAGE[e][n]]);if(l)this.popupHistoryBodyWrap.appendChild(l)}}if(this.BXIM.settings.loadLastMessage&&this.currentTab==e)BX.MessengerCommon.drawTab(this.currentTab,true)}else{if(a&&this.chat[i.USER_ID.substr(4)].fake)this.chat[i.USER_ID.toString().substr(4)].name=BX.message("IM_M_USER_NO_ACCESS");if(!a){BX.MessengerCommon.getUserParam(e,true);this.users[e].name=BX.message("IM_M_USER_NO_ACCESS")}for(var n in i.USERS){i.USERS[n].last_activity_date=new Date(i.USERS[n].last_activity_date);i.USERS[n].mobile_last_date=new Date(i.USERS[n].mobile_last_date);i.USERS[n].idle=i.USERS[n].idle?new Date(i.USERS[n].idle):false;i.USERS[n].absent=i.USERS[n].absent?new Date(i.USERS[n].absent):false;this.users[n]=i.USERS[n]}for(var n in i.USER_IN_GROUP){if(typeof this.userInGroup[n]=="undefined"){this.userInGroup[n]=i.USER_IN_GROUP[n]}else{for(var p=0;p<i.USER_IN_GROUP[n].users.length;p++)this.userInGroup[n].users.push(i.USER_IN_GROUP[n].users[p]);this.userInGroup[n].users=BX.util.array_unique(this.userInGroup[n].users)}}for(var n in i.CHAT){i.CHAT[n].date_create=new Date(i.CHAT[n].date_create);this.chat[n]=i.CHAT[n]}for(var n in i.USER_IN_CHAT){this.userInChat[n]=i.USER_IN_CHAT[n]}for(var n in i.USER_BLOCK_CHAT){this.userChatBlockStatus[n]=i.USER_BLOCK_CHAT[n]}if(!a)BX.MessengerCommon.userListRedraw();this.dialogStatusRedraw();this.drawHistory(e,false,false)}if(this.historyChatId==0){this.historyChatId=i.CHAT_ID;this.drawHistoryFiles(this.historyChatId)}this.redrawHistoryPanel(e,a?i.USER_ID.substr(4):0)}else{if(i.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<2){this.sendAjaxTry++;setTimeout(BX.delegate(function(){this.drawHistory(e,t,s)},this),1e3);BX.onCustomEvent(window,"onImError",[i.ERROR,i.BITRIX_SESSID])}else if(i.ERROR=="AUTHORIZE_ERROR"){this.sendAjaxTry++;if(BX.MessengerCommon.isDesktop()){setTimeout(BX.delegate(function(){this.drawHistory(e,t,s)},this),1e4)}BX.onCustomEvent(window,"onImError",[i.ERROR])}}},this),onfailure:BX.delegate(function(){this.sendAjaxTry=0},this)})}};BX.Messenger.prototype.redrawHistoryPanel=function(e,t,s){var i=e.toString().substr(0,4)=="chat"?true:false;var a=null;s=s||{};BX.MessengerCommon.getUserParam(e);if(i){a=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":"")}})]}),s.drawLinesVote=="Y"?BX.create("a",{attrs:{"data-rating":s.sessionVoteHead,title:BX.message("IM_M_HISTORY_LINES_VOTE")+(s.sessionVoteHead>0?" ("+s.sessionVoteHead+"/5)":"")},props:{className:"bx-messenger-panel-history-vote"},events:{click:BX.delegate(function(){this.linesVoteHeadDialog(BX.proxy_context,s.sessionId);return BX.PreventDefault()},this)}}):null,s.drawLinesJoin=="Y"?BX.create("a",{attrs:{title:BX.message("IM_M_HISTORY_LINES_JOIN")},props:{className:"bx-messenger-panel-history-join"},events:{click:BX.delegate(function(){this.popupHistory.close();this.linesOpenMessenger(this.chat[t].entity_id)},this)}}):null,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{a=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(this.users[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(this.users[e],false).title},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&&this.bot[e]?'<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(this.users[e])})]})}if(this.popupHistoryPanel){this.popupHistoryPanel.innerHTML="";BX.adjust(this.popupHistoryPanel,{children:[a]})}else{return[a]}};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 o=BX.util.objectSort(t,"date","desc");for(var r=0;r<o.length;r++){if(i&&o[r].name.toLowerCase().indexOf((this.historyFilesSearch+"").toLowerCase())<0)continue;var l=this.disk.drawHistoryFiles(e,o[r].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=new Date(i.FILES[a].date);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(BX.MessengerCommon.isDesktop()){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=new Date(e.MESSAGE[i].date);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=new Date(e.FILES[i].date);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=new Date(e.MESSAGE[i].date);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=new Date(e.FILES[i].date);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=new Date(e.FILES[i].date);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(BX.MessengerCommon.isDesktop()){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:BX.MessengerCommon.isDesktop()?"Y":"N",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(t)BX.localStorage.set("mus",true,5);if(BX.MessengerCommon.isDesktop()){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))for(var n in e.ONLINE){if(this.users[n]){this.users[n].status=e.ONLINE[n].status;this.users[n].color=e.ONLINE[n].color;this.users[n].idle=e.ONLINE[n].idle?new Date(e.ONLINE[n].idle):false;this.users[n].last_activity_date=new Date(e.ONLINE[n].last_activity_date);this.users[n].mobile_last_date=new Date(e.ONLINE[n].mobile_last_date)}}this.BXIM.messenger.command=e.COMMAND?e.COMMAND:[];this.BXIM.messenger.textareaIcon=e.TEXTAREA_ICON?e.TEXTAREA_ICON:[];this.BXIM.messenger.textareaIconPrepare();if(typeof e.FILES!="undefined"){for(var o in e.FILES){if(!this.disk.files[o])this.disk.files[o]={};for(var n in e.FILES[o]){e.FILES[o][n].date=new Date(e.FILES[o][n].date);this.disk.files[o][n]=e.FILES[o][n]}}}if(typeof e.MESSAGE!="undefined")for(var n in e.MESSAGE)e.MESSAGE[n].date=new Date(e.MESSAGE[n].date);BX.MessengerCommon.updateStateVar(e,t);if(typeof e.USERS_MESSAGE!="undefined")a=true;this.dialogStatusRedraw();BX.MessengerCommon.userListRedraw();if(typeof e.NOTIFY!="undefined"){for(var n in e.NOTIFY){e.NOTIFY[n].date=new Date(e.NOTIFY[n].date);this.notify.notify[n]=e.NOTIFY[n];this.BXIM.lastRecordId=parseInt(n)>this.BXIM.lastRecordId?parseInt(n):this.BXIM.lastRecordId}for(var n in e.FLASH_NOTIFY)if(typeof this.notify.flashNotify[n]=="undefined")this.notify.flashNotify[n]=e.FLASH_NOTIFY[n];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(BX.MessengerCommon.isDesktop()){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&&!BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isDesktop()){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(e){}},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(BX.MessengerCommon.isDesktop()){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&&!BX.MessengerCommon.isDesktop()){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){if(!this.popupMessengerExtra)return false;this.setClosingByEsc(false);if(!this.BXIM.extraBind){BX.bind(window,"keydown",this.BXIM.extraBind=BX.proxy(function(e){if(e.keyCode==27&&this.popupMessenger){this.popupMessenger.destroy()}},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){if(!this.popupMessengerExtra)return true;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",{props:{className:"bx-messenger-box-hello-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-box-hello"},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(" ","\t");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(BX.MessengerCommon.isDesktop())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(BX.MessengerCommon.isDesktop()&&!this.webrtc.debug){BX.MessengerWindow.windowReload()}return false}else if(this.popupMessengerTextarea.value=="/windowReload"){this.textareaHistory[this.currentTab]="";this.popupMessengerTextarea.value="";this.textareaCheckText();location.reload();if(BX.MessengerCommon.isDesktop())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.getChatId()}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("/background")==0){var s=BX.util.trim(this.popupMessengerTextarea.value).split(" ")[1];if(!s){s=this.BXIM.settings.backgroundImage?false:true}this.BXIM.setBackground(s);this.popupMessengerTextarea.value="";this.textareaCheckText();return false}else if(this.popupMessengerTextarea.value.indexOf("/color")==0){var s=this.popupMessengerTextarea.value.split(" ")[1];if(s&&this.openChatFlag){BX.MessengerCommon.setColor(s,this.getChatId())}this.popupMessengerTextarea.value="";this.textareaCheckText();return false}else if(this.popupMessengerTextarea.value.indexOf("/rename")==0){var i=this.popupMessengerTextarea.value.substr(8);if(i&&this.openChatFlag){BX.MessengerCommon.renameChat(this.getChatId(),i)}this.popupMessengerTextarea.value="";this.textareaCheckText();return false}if(BX.MessengerCommon.isDesktop()){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.MessengerWindow.initWidth,Height:BX.MessengerWindow.initHeight});this.BXIM.setLocalConfig("global_msz_v2",false);BX.desktop.apiReady=false;location.reload();if(BX.MessengerCommon.isDesktop())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 a=this.messageTmpIndex;this.message["temp"+a]={id:"temp"+a,chatId:t,senderId:this.BXIM.userId,recipientId:e,date:new Date,text:BX.MessengerCommon.prepareText(this.popupMessengerTextarea.value,true)};if(!this.showMessage[e])this.showMessage[e]=[];this.showMessage[e].push("temp"+a);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 n=BX.findChildByClassName(this.popupMessengerBodyWrap,"bx-messenger-content-load");if(n)BX.remove(n);var o=BX.findChildByClassName(this.popupMessengerBodyWrap,"bx-messenger-content-empty");if(o)BX.remove(o);if(e.toString().substr(0,4)=="chat"&&this.linesSilentMode&&this.linesSilentMode[e.toString().substr(4)]){if(!this.message["temp"+a].params){this.message["temp"+a].params={}}this.message["temp"+a].params.CLASS="bx-messenger-content-item-system"}BX.MessengerCommon.drawMessage(e,this.message["temp"+a]);BX.MessengerCommon.sendMessageAjax(a,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&&t.parentNode.parentNode&&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.parentNode&&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(){this.closeMenuPopup();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();this.textareaCommandListUpdate("")};BX.Messenger.prototype.textareaCommandListUpdate=function(e){if(this.currentTab==this.BXIM.userId){return false}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 o=a.value.substr(a.selectionStart);var r=a.value.substr(0,n);a.value=r+t+""+o;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 o=e.value.substr(0,e.selectionStart).lastIndexOf("/");var r=e.value.substr(e.selectionStart);var l=e.value.substr(0,o+1);e.value=l+r;e.selectionStart=o+1;e.selectionEnd=e.selectionStart;this.textareaCommandListUpdate(false);return BX.PreventDefault(t)}else if(t.keyCode==9){this.textareaCommandSelect("down");command="/"+this.commandSelect;var o=e.value.substr(0,e.selectionStart).lastIndexOf("/");var r=e.value.substr(e.selectionStart);var l=e.value.substr(0,o);e.value=l+command+""+r;e.selectionStart=o+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 o=e.value.substr(0,e.selectionStart).lastIndexOf("/");var r=e.value.substr(e.selectionStart);var l=e.value.substr(0,o);e.value=l+command+r;e.selectionStart=o+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||!BX.MessengerCommon.isDesktop()&&BX.browser.IsChrome()&&t.keyCode==69){var o=e.selectionStart;var m=e.selectionEnd;resultText=e.value.substring(o,m);if(t.keyCode==84||!BX.MessengerCommon.isDesktop()&&BX.browser.IsChrome()&&t.keyCode==69){if(o==m){o=0;m=e.value.length;resultText=e.value}e.value=e.value.substring(0,o)+BX.correctText(resultText,{replace_way:"AUTO",mixed:true})+e.value.substring(m,e.value.length);e.selectionStart=o;e.selectionEnd=m}else{if(o==m){return BX.PreventDefault(t)}resultTagStart=e.value.substring(o,o+3);resultTagEnd=e.value.substring(m-4,m);if(resultTagStart.toLowerCase()=="["+u[t.keyCode]+"]"&&resultTagEnd.toLowerCase()=="[/"+u[t.keyCode]+"]"){e.value=e.value.substring(0,o)+e.value.substring(o+3,m-4)+e.value.substring(m,e.value.length);e.selectionStart=o;e.selectionEnd=m-7}else{e.value=e.value.substring(0,o)+"["+u[t.keyCode]+"]"+resultText+"[/"+u[t.keyCode]+"]"+e.value.substring(m,e.value.length);e.selectionStart=o;e.selectionEnd=m+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,"\t");return BX.PreventDefault(t)}if(t.keyCode==27&&!BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isDesktop()&&BX.browser.IsMac()&&!this.desktop.enableInVersion(36))return false;var s=e.match(/\[icon\=([^\]]*)\]/gi);var i=false;if(s&&s.length){var a=[];var n=this.BXIM.getLocalConfig("smiles-recent",[])||[];for(var o=0;o<n.length;o++){a.push(n[o].IMAGE)}for(var o=0;o<s.length;o++){var r=s[o];var l=r.match(/icon\=(\S+[^\s.,> )\];\'\"!?])/i);if(l&&l[1]){l=l[1];if(a&&a.indexOf(l)>-1||l.match(/^(\d+)$/)){continue}}else{continue}if(t&&t.indexOf(l)<0){continue}i=true;var p={IMAGE:l,HEIGHT:20,WIDTH:20,NAME:""};var h=r.match(/size\=(\d+)/i);if(h&&h[1]){p["WIDTH"]=h[1];p["HEIGHT"]=h[1]}else{var c=r.match(/width\=(\d+)/i);if(c&&c[1]){p["WIDTH"]=c[1]}var u=r.match(/height\=(\d+)/i);if(u&&u[1]){p["HEIGHT"]=u[1]}if(p["WIDTH"]&&!p["HEIGHT"]){p["HEIGHT"]=p["WIDTH"]}else if(p["HEIGHT"]&&!p["WIDTH"]){p["WIDTH"]=p["HEIGHT"]}else{p["WIDTH"]=20;p["HEIGHT"]=20}}var m=r.match(/title\=(.*[^\s\]])/i);if(m&&m[1]){m=m[1];if(m.indexOf("width=")>-1){m=m.substr(0,m.indexOf("width="))}if(m.indexOf("height=")>-1){m=m.substr(0,m.indexOf("height="))}if(m.indexOf("size=")>-1){m=m.substr(0,m.indexOf("size="))}if(m){m=BX.util.trim(m);p["NAME"]=m}}n.push(p);this.injectRecentSmile(p)}if(i){this.BXIM.setLocalConfig("smiles-recent",n,26e5)}}return s?s.length:0};BX.Messenger.prototype.removeRecentSmile=function(e){if(BX.MessengerCommon.isDesktop()&&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(BX.MessengerCommon.isDesktop()&&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";e.bind=e.bind||this.popupMessengerSmileButton;this.closePopupFileMenu();if(this.popupPopupMenu!=null)this.popupPopupMenu.destroy();if(this.popupChatDialog!=null){this.popupChatDialog.destroy()}if(this.popupSmileMenu!=null){this.popupSmileMenu.destroy()}if(this.commandPopup!=null){this.commandPopup.destroy()}if(this.popupIframeMenu!=null&&this.popupIframeBind){this.popupIframeMenu.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 o=[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 r="";for(var l=0;l<this.smileSet.length;l++){if(typeof t[this.smileSet[l]["ID"]]=="undefined")continue;s=this.smileSet[l]["ID"];r=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]}));o.push(BX.create("span",{attrs:{"data-set-id":s,title:BX.util.htmlspecialcharsback(r)},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",e.bind,{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:o})]})});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.textareaIconToggle=function(){if(!this.popupMessengerPanelBotIcons){return true}var e=BX.findChildrenByClassName(this.popupMessengerTextareaIconBox,"bx-messenger-textarea-icon-bot",true);if(!e){this.popupMessengerPanelBotIcons=false;return false}for(var t=0;t<e.length;t++){BX.removeClass(e[t],"bx-messenger-textarea-icon-bot-show")}this.popupMessengerPanelBotIcons=false;if(this.openBotFlag){var e=BX.findChildrenByClassName(this.popupMessengerTextareaIconBox,"bx-messenger-textarea-icon-bot-"+this.currentTab,true);if(e){for(var t=0;t<e.length;t++){BX.addClass(e[t],"bx-messenger-textarea-icon-bot-show")}this.popupMessengerPanelBotIcons=true}}return true};BX.Messenger.prototype.textareaIconCheckContext=function(e){var t=e.substr(-6)=="-admin";if(t&&!this.BXIM.isAdmin){return false}if(t){e=e.substr(0,e.length-6)}if(e=="chat"){if(!this.openChatFlag){return false}}else if(e=="bot"){if(!this.openBotFlag){return false}}else if(e=="lines"){if(!this.openLinesFlag){return false}}else if(e=="call"){if(!this.openCallFlag){return false}}else if(e=="user"){if(this.openCallFlag||this.openChatFlag||this.openLinesFlag){return false}}return true};BX.Messenger.prototype.textareaIconPrepare=function(){if(!this.popupMessengerTextareaIconBox)return false;this.popupMessengerTextareaIconBox.innerHTML="";if(!this.textareaIcon.length){return false}var e=null;var t=[];var s=[];for(var i=0;i<this.textareaIcon.length;i++){if(!this.textareaIcon[i]||this.textareaIcon[i].hidden){continue}if(this.desktop.ready()&&!this.desktop.enableInVersion(39)&&this.textareaIcon[i]["iframe"]){if(BXDesktopSystem.GetProperty("versionParts").join(".")!="5.0.32.38"){continue}}var a=this.textareaIcon[i]["description"]?this.textareaIcon[i]["description"]:this.textareaIcon[i]["title"];if(!this.textareaIcon[i]["title"]&&!this.textareaIcon[i]["url"]){continue}var n="bx-messenger-textarea-icon-marketplace-"+this.textareaIcon[i]["id"]+" bx-messenger-textarea-icon-context-"+this.textareaIcon[i]["context"]+(this.textareaIcon[i]["context"]=="bot"||this.textareaIcon[i]["context"]=="bot-admin"?" bx-messenger-textarea-icon-bot bx-messenger-textarea-icon-bot-"+this.textareaIcon[i]["botId"]:"");if(!this.textareaIcon[i]["url"]){t.push(this.textareaIcon[i]);s.push(n);continue}e=BX.create("div",{props:{className:"bx-messenger-textarea-icon-marketplace "+n},attrs:{title:a,style:"background-image: url('"+this.textareaIcon[i]["url"]+"')","data-context":this.textareaIcon[i]["context"],"data-code":this.textareaIcon[i]["code"],"data-id":this.textareaIcon[i]["id"]},events:{click:BX.delegate(this.textareaIconClick,this)}});this.popupMessengerTextareaIconBox.appendChild(e)}if(t.length){this.popupMessengerTextareaIconApps=BX.create("div",{props:{className:"bx-messenger-textarea-icon-marketplace bx-messenger-textarea-icon-marketplace-default "+s.join(" ")},attrs:{title:BX.message("IM_APPS_LIST")},events:{click:BX.delegate(function(e){this.openPopupMenu(BX.proxy_context,"textareaAppsMenu")},this)}});this.popupMessengerTextareaIconBox.appendChild(this.popupMessengerTextareaIconApps)}return true};BX.Messenger.prototype.textareaIconDialogClick=function(id,messageId,params){params=params||{};var icon=null;for(var i=0;i<this.textareaIcon.length;i++){if(!this.textareaIcon[i]||this.textareaIcon[i].id!=id){continue}icon=this.textareaIcon[i];break}if(!icon&&!params.___ajaxSkip){BX.ajax({url:this.BXIM.pathToAjax+"?GET_TEXTAREA_ICONS&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:{IM_GET_TEXTAREA_ICONS:"Y",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){this.textareaIcon=e.TEXTAREA_ICON?e.TEXTAREA_ICON:[];this.textareaIconPrepare();params.___ajaxSkip=true;this.textareaIconDialogClick(id,messageId,params)},this)});return false}delete params.___ajaxSkip;if(this.textareaIconCheckContext(icon.context)){if(icon.iframe){var dialogContext="user";var dialogEntityId="";var dialogEntityData1="";if(this.currentTab.toString().substr(0,4)=="chat"){dialogContext=this.chat[this.currentTab.substr(4)].entity_type.toLowerCase();dialogEntityId=this.chat[this.currentTab.substr(4)].entity_id;dialogEntityData1=this.chat[this.currentTab.substr(4)].entity_data_1}this.openFrameDialog({bind:null,title:icon.title,copyright:icon.copyright,iframe:{src:icon.iframe,width:icon.iframeWidth,height:icon.iframeHeight,popup:true},params:{BOT_ID:icon.botId,BOT_CODE:icon.botCode,APP_ID:icon.id,APP_CODE:icon.code,DOMAIN:location.origin,DOMAIN_HASH:icon.domainHash,USER_ID:this.BXIM.userId,USER_HASH:icon.userHash,DIALOG_ID:this.currentTab,DIALOG_CONTEXT:dialogContext,DIALOG_ENTITY_ID:dialogEntityId,DIALOG_ENTITY_DATA_1:dialogEntityData1,LANG:BX.message.LANGUAGE_ID,IS_CHROME:BX.browser.IsChrome()?"Y":"N",CONTEXT:"button",MESSAGE_ID:messageId,BUTTON_PARAMS:params}})}else if(icon.js){var button=BX.proxy_context;eval(icon.js)}}};BX.Messenger.prototype.textareaIconClick=function(event){if(this.popupPopupMenu!=null){this.popupPopupMenu.destroy()}var icon=null;for(var i=0;i<this.textareaIcon.length;i++){if(!this.textareaIcon[i]||this.textareaIcon[i].id!=BX.proxy_context.getAttribute("data-id")||this.textareaIcon[i].hidden){continue}icon=this.textareaIcon[i];break}if(!icon){return false}if(this.textareaIconCheckContext(icon.context)){if(icon.iframe){var dialogContext="user";var dialogEntityId="";var dialogEntityData1="";if(this.currentTab.toString().substr(0,4)=="chat"){dialogContext=this.chat[this.currentTab.substr(4)].entity_type.toLowerCase();dialogEntityId=this.chat[this.currentTab.substr(4)].entity_id;dialogEntityData1=this.chat[this.currentTab.substr(4)].entity_data_1}this.openFrameDialog({bind:event?BX.proxy_context:this.popupMessengerTextareaIconApps,title:icon.title,copyright:icon.copyright,iframe:{src:icon.iframe,width:icon.iframeWidth,height:icon.iframeHeight,popup:icon.iframePopup},params:{BOT_ID:icon.botId,BOT_CODE:icon.botCode,APP_ID:icon.id,APP_CODE:icon.code,DOMAIN:location.origin,DOMAIN_HASH:icon.domainHash,USER_ID:this.BXIM.userId,USER_HASH:icon.userHash,DIALOG_ID:this.currentTab,DIALOG_CONTEXT:dialogContext,DIALOG_ENTITY_ID:dialogEntityId,DIALOG_ENTITY_DATA_1:dialogEntityData1,LANG:BX.message.LANGUAGE_ID,IS_CHROME:BX.browser.IsChrome()?"Y":"N",CONTEXT:"textarea"}})}else if(icon.js){var button=BX.proxy_context;eval(icon.js)}}return event?BX.PreventDefault(event):true};BX.Messenger.prototype.openFrameDialog=function(e){e=e||{};if(e.iframe&&e.iframe.popup){e.bind=null}else{e.bind=e.bind||null}this.closePopupFileMenu();if(this.popupPopupMenu!=null){this.popupPopupMenu.destroy()}if(this.popupChatDialog!=null){this.popupChatDialog.destroy()}if(this.popupSmileMenu!=null){this.popupSmileMenu.destroy()}if(this.commandPopup!=null){this.commandPopup.destroy()}if(this.popupIframeMenu!=null){this.popupIframeMenu.destroy()}this.openFrameDialogBid=e.params.BOT_ID;this.openFrameDialogDid=this.currentTab;if(this.sendFrameTokenCollection[this.openFrameDialogBid]){if(this.sendFrameTokenCollection[this.openFrameDialogBid]+this.sendFrameTokenTimeout*1e3<+new Date){this.sendFrameToken(this.openFrameDialogBid,this.openFrameDialogDid)}}else{this.sendFrameToken(this.openFrameDialogBid,this.openFrameDialogDid)}var t="";for(var s in e.params){t=t+s+"="+encodeURIComponent(e.params[s])+"&"}t=e.iframe.src+t;e.iframe.height=parseInt(e.iframe.height);if(e.iframe.height>this.popupMessengerBody.offsetHeight){e.iframe.height=this.popupMessengerBody.offsetHeight}this.popupIframeBind=!!e.bind;this.popupIframeMenu=new BX.PopupWindow("bx-messenger-iframe",e.bind,{lightShadow:false,offsetTop:0,offsetLeft:-38,autoHide:this.popupIframeBind,closeByEsc:true,bindOptions:{position:"top"},closeIcon:e.bind?null:{right:"13px"},draggable:e.bind?null:{restrict:true},zIndex:200,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.openFrameDialogBid=null;this.openFrameDialogDid=null;this.popupIframeMenu=null;this.popupIframeBind=true;this.openFrameDialogFrame=null;this.openFrameDialogFrameSourceDomain=null},this)},content:BX.create("div",{props:{className:"bx-messenger-iframe-title-box"},children:[this.openFrameDialogTitle=BX.create("div",{props:{className:"bx-messenger-command-popup-header"},children:[BX.create("span",{props:{className:"bx-messenger-command-popup-title"},text:e.title}),BX.create("span",{props:{className:"bx-messenger-command-popup-help"},children:[BX.create("span",{props:{className:"bx-messenger-command-popup-help-item"},text:e.copyright})]})]}),this.openFrameDialogFrame=BX.create("iframe",{attrs:{frameborder:0,src:t,style:"min-width: "+parseInt(e.iframe.width)+"px; min-height: "+parseInt(e.iframe.height)+"px; max-height: 100%; max-width: 100%;",sandbox:"allow-same-origin allow-forms allow-scripts allow-popups"},props:{className:"bx-messenger-iframe-element"+(BX.browser.IsMac()?"":" bx-messenger-custom-scroll")}})]})});if(e.bind){this.popupIframeMenu.setAngle({offset:74})}else{this.openFrameDialogTitle.style.cursor="move";BX.bind(this.openFrameDialogTitle,"mousedown",BX.proxy(this.popupIframeMenu.onTitleMouseDown,this.popupIframeMenu))}this.popupIframeMenu.show();BX.bind(this.openFrameDialogFrame,"load",BX.delegate(this.openFrameDialogLoad,this));if(t.indexOf("http")===0){var i=document.createElement("a");i.href=t;this.openFrameDialogFrameSourceDomain=i.protocol+"//"+i.hostname+(i.port&&i.port!="80"&&i.port!="443"?":"+i.port:"")}else{this.openFrameDialogFrameSourceDomain=location.protocol+"//"+location.hostname+(location.port&&location.port!="80"&&location.port!="443"?":"+location.port:"")}BX.onCustomEvent("onImOpenFrameDialog",[]);return false};BX.Messenger.prototype.openFrameDialogLoad=function(e){var t=0;if(typeof window.postMessage==="function"&&!t){this.openFrameDialogFrameUid=Math.random().toString().substr(2);this.openFrameDialogFrame.contentWindow.postMessage(JSON.stringify({action:"init",domain:location.origin,uniqueLoadId:this.openFrameDialogFrameUid}),this.openFrameDialogFrameSourceDomain)}};BX.Messenger.prototype.openFrameDialogPostMessage=function(e){var t={};try{t=JSON.parse(e)}catch(e){}if(!t.action)return;if(this.openFrameDialogFrameUid!=t.uniqueLoadId)return;if(t.action=="send"){this.BXIM.sendMessage(t.message)}else if(t.action=="put"){this.BXIM.putMessage(t.message);this.BXIM.messenger.textareaCheckText()}else if(t.action=="call"){this.BXIM.phoneTo(t.number)}else if(t.action=="support"){this.BXIM.openMessenger("networkLines"+t.code,null,true)}else if(t.action=="close"){if(this.popupIframeMenu!=null){this.popupIframeMenu.destroy()}}return true};BX.Messenger.prototype.expireFrameToken=function(){if(!this.openFrameDialogBid){return false}for(var e in this.sendFrameTokenCollection){if(this.sendFrameTokenCollection[e]+this.sendFrameTokenTimeout*1e3<+new Date){delete this.sendFrameTokenCollection[e];if(this.openFrameDialogBid){this.sendFrameToken(this.openFrameDialogBid,this.openFrameDialogDid)}}}return true};BX.Messenger.prototype.sendFrameToken=function(e,t){this.sendFrameTokenCollection[e]=+new Date;BX.ajax({url:this.BXIM.pathToAjax+"?SEND_FRAME_TOKEN&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:60,data:{IM_OPEN_REST_TOKEN:"Y",BOT_ID:e,DIALOG_ID:t,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}})};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");BX.addClass(this.popupMessengerConnectionStatus,"bx-messenger-connection-status-hide")},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,"edit"))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=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,BX.delegate(function(e,t,s,i){BX.MessengerCommon.addMentionList(this.currentTab,i,"chat"+parseInt(s));return i},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&&!BX.MessengerCommon.checkEditMessage(e,"delete"))return false;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.shareMessage=function(e,t,s){BX.MessengerCommon.shareMessageAjax(e,t,s)};BX.Messenger.prototype.toggleLinesTab=function(e){if(typeof e=="undefined"){e=this.BXIM.settings.linesTabEnable}else{this.BXIM.settings.linesTabEnable=e}if(e){if(BX.MessengerWindow.existsTab("im-ol")){BX.MessengerWindow.showTab("im-ol")}else if(BX.MessengerCommon.isLinesOperator()){BX.MessengerWindow.addTab({id:"im-ol",title:BX.message("IM_CTL_CHAT_OL"),order:105,target:"im",events:{open:BX.delegate(function(){if(BX.MessengerCommon.isPage()&&this.BXIM.context=="POPUP-FULLSCREEN"&&!this.popupMessenger){return false}if(!this.BXIM.dialogOpen){this.openMessenger(this.currentTab)}BX.MessengerCommon.userListRedraw()},this),close:BX.delegate(function(){BX.MessengerCommon.userListRedraw()},this)}})}}else{BX.MessengerWindow.hideTab("im-ol")}if(BX.MessengerWindow.currentTab=="im-ol"){BX.MessengerWindow.changeTab("im",true)}BX.MessengerCommon.userListRedraw();this.updateMessageCount();return true};BX.Messenger.prototype.toggleLinesNewGroup=function(e){if(typeof e=="undefined"){e=this.BXIM.settings.linesNewGroupEnable}else{this.BXIM.settings.linesNewGroupEnable=e}BX.MessengerCommon.userListRedraw();return e};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 o=0;o<n.length;o++){var r=n[o].id.replace("im-message-","");if(this.message[r]){if(s){if(this.users[this.message[r].senderId]){i=this.users[this.message[r].senderId].name;a=this.message[r].date}s=false}var l=this.message[r].text.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,BX.delegate(function(e,t,s){return s},this));l=l.replace(/\[CHAT=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,BX.delegate(function(e,t,s,i){return i},this));l=l.replace(/\[RATING\=([1-5]{1})\]/gi,BX.delegate(function(e,t){return"["+BX.message("IM_F_RATING")+"] "},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 t==1e4?"":"["+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=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,BX.delegate(function(e,t,s,i){return i},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 t==1e4?"":"["+BX.message("IM_F_ATTACH")+"] "},this));s=s.replace(/\[RATING\=([1-5]{1})\]/gi,BX.delegate(function(e,t){return"["+BX.message("IM_F_RATING")+"] "},this));s=s.replace(/ /gi," ");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()||BX.MessengerCommon.isDesktop()){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.popupMessengerBodyPanel.style.height=this.popupMessengerBodyDialog.offsetHeight+"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_tas",this.popupMessengerTextareaSize);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.setTextareaSize=function(e){e=Math.max(Math.min(e,143),30);if(this.popupMessengerTextareaSize==e)return true;var t=e-this.popupMessengerTextareaSize;this.popupMessengerBodySize=this.popupMessengerBodySize+t*-1;if(this.popupMessengerBody){this.popupMessengerBody.style.height=this.popupMessengerBodySize+"px";this.popupMessengerBodyPanel.style.height=this.popupMessengerBodyDialog.offsetHeight+"px"}this.popupMessengerTextareaSize=e;if(this.popupMessengerTextarea){this.popupMessengerTextarea.style.height=e+"px"}return true};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.popupMessengerBodyPanel!=null)this.xx.style.height=this.popupMessengerBodyDialog.offsetHeight+"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 o in this.flashMessage){var r=false;var l=false;if(this.BXIM.isFocus()&&this.popupMessenger!=null&&o==this.currentTab){r=true;n++}else if(o.toString().substr(0,4)=="chat"||this.users[o]&&this.users[o].extranet){if(this.muteButtonStatus(o)){l=true}}if(r||l){for(var p in this.flashMessage[o]){if(this.flashMessage[o][p]!==false){this.flashMessage[o][p]=false;i++}}continue}var h={};for(var p in this.flashMessage[o]){if(this.flashMessage[o][p]===false||h[o]){this.flashMessage[o][p]=false;continue}h[o]=true;var c=this.message[p].recipientId.toString().substr(0,4)=="chat";var u=this.message[p].recipientId;var m=!c&&this.message[p].senderId==0?o:this.message[p].senderId;if(c&&!this.chat[u.substr(4)]||!c&&!this.users[m]){continue}var d=c&&this.chat[u.substr(4)].type=="call";var g=c&&this.chat[u.substr(4)].type=="lines";var f=this.message[p].system=="Y";var B=BX.MessengerCommon.purifyText(this.message[p].text,this.message[p].params);if(o!=this.BXIM.userId){a[o]=c?this.chat[u.substr(4)].name:this.users[m].name}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 M=u.substr(4);var I=BX.MessengerCommon.isBlankAvatar(this.chat[M].avatar)?"background-color: "+this.chat[M].color:"";var C=3;if(d){C=4}else if(g){C=7}else if(this.generalChatId==M){C=6}else if(this.chat[u.substr(4)].type=="open"){C=5}}else{var I=BX.MessengerCommon.isBlankAvatar(this.users[m].avatar)?"background-color: "+this.users[m].color:""}var b=BX.create("div",{attrs:{"data-userId":c?u:m,"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[m].avatar)?c?" bx-notifier-item-avatar-img-default-"+C:" bx-notifier-item-avatar-img-default":"")},attrs:{src:c?this.chat[u.substr(4)].avatar:this.users[m].avatar,style:I}})]}),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[m].name}),BX.create("span",{props:{className:"bx-notifier-item-text"},html:(c&&m>0?"<i>"+this.users[m].name+"</i>: ":"")+BX.MessengerCommon.prepareText(B,false,true)})]})]});if(!this.BXIM.xmppStatus||this.BXIM.xmppStatus&&c){t.push(b);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=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,s,i){return i});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:m,title:BX.util.htmlspecialcharsback(c?this.chat[u.substr(4)].name:this.users[m].name),text:(c&&m>0?this.users[m].name+": ":"")+B,icon:c?this.chat[u.substr(4)].avatar:this.users[m].avatar,tag:"im-messenger-"+(c?u:m)})}this.flashMessage[o][p]=false}}if(this.BXIM.context=="LINES"||this.BXIM.context=="DIALOG"){return false}if(!BX.MessengerCommon.isDesktop()&&this.BXIM.desktopStatus)return false;if(t.length>5){var y="";for(var o in a)y+=", <i>"+a[o]+"</i>";var x={id:0,type:4,date:new Date,title:BX.message("IM_NM_MESSAGE_1").replace("#COUNT#",t.length),text:BX.message("IM_NM_MESSAGE_2").replace("#USERS#",y.substr(2))};t=[];t.push(this.notify.createNotify(x,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(y.substr(2))).replace(/<\/?[^>]+>/gi,"")})}else if(t.length==0){if(n>0&&BX.MessengerCommon.isDesktop())BX.desktop.flashIcon();if(e&&n>0&&this.BXIM.settings.status!="dnd"){this.BXIM.playSound("newMessage2")}return false}if(BX.MessengerCommon.isDesktop())BX.desktop.flashIcon();if(BX.MessengerCommon.isDesktop()){for(var o=0;o<t.length;o++){var v=t[o].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(v,t[o],T)}}else if(e&&!this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){for(var o=0;o<s.length;o++){var x=s[o];x.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};x.onclick=function(){window.focus();top.BXIM.openMessenger(x.id);this.close()};this.BXIM.notifyManager.nativeNotify(x)}}else{if(this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){BX.localStorage.set("mnnb",true,1)}for(var o=0;o<t.length;o++){this.BXIM.notifyManager.add({html:t[o],tag:"im-message-"+t[o].getAttribute("data-userId"),userId:t[o].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(BX.MessengerCommon.isDesktop())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 o=!t&&e.senderId==0?i:e.senderId;var r=e.text_mobile?e.text_mobile:e.text;if(!e.id)e.id="custom-"+ +new Date;if(e.date)e.date=new Date;r=r.replace(/------------------------------------------------------(.*?)------------------------------------------------------/gim,"["+BX.message("IM_M_QUOTE_BLOCK")+"]");if(r.length>150){r=r.substr(0,150);var l=r.lastIndexOf(" ");if(l<140)r=r.substr(0,l)+"...";else r=r.substr(0,140)+"..."}if(r==""&&e.params["FILE_ID"].length>0){r="["+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[o].avatar)?"background-color: "+this.users[o].color:""}var u=BX.create("div",{attrs:{"data-userId":t?s:o,"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[o].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[o].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[o].name}),BX.create("span",{props:{className:"bx-notifier-item-text"},html:(t&&o>0?"<i>"+this.users[o].name+"</i>: ":"")+BX.MessengerCommon.prepareText(r,false,true)})]})]});if(!this.BXIM.xmppStatus||this.BXIM.xmppStatus&&t){r=BX.util.htmlspecialcharsback(r);r=r.split("<br />").join("\n");r=r.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,function(e,t,s){return s});r=r.replace(/\[CHAT=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,s,i){return i});r=r.replace(/\[PCH=([0-9]{1,})\](.*?)\[\/PCH\]/gi,function(e,t,s){return s});r=r.replace(/\[SEND(?:=(.+?))?\](.+?)?\[\/SEND\]/gi,function(e,t,s){return s?s:t});r=r.replace(/\[PUT(?:=(.+?))?\](.+?)?\[\/PUT\]/gi,function(e,t,s){return s?s:t});r=r.replace(/\[CALL(?:=(.+?))?\](.+?)?\[\/CALL\]/gi,function(e,t,s){return s?s:t});r=r.replace(/\[ATTACH=([0-9]{1,})\]/gi,function(e,t,s){return""});notifyTextObject={id:t?s:o,title:BX.util.htmlspecialcharsback(t?this.chat[s.substr(4)].name:this.users[o].name),text:(t&&o>0?this.users[o].name+": ":"")+r,icon:t?this.chat[s.substr(4)].avatar:this.users[o].avatar,tag:"im-messenger-"+(t?s:o)}}else{return false}if(!(!BX.MessengerCommon.isDesktop()&&BX.MessengerCommon.isPage())&&!BX.MessengerCommon.isDesktop()&&this.BXIM.desktopStatus)return false;if(BX.MessengerCommon.isDesktop()){var m='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,m)}else if(!this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){var d=notifyTextObject;d.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};d.onclick=function(){window.focus();top.BXIM.openMessenger(d.id);this.close()};this.BXIM.notifyManager.nativeNotify(d)}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;var i=0;for(var a in this.unreadMessage){if(!this.unreadMessage[a])continue;if(a.toString().substr(0,4)=="chat"){s=a.toString().substr(4);if(this.chat[s]&&this.chat[s].entity_type=="LINES"&&this.BXIM.settings.linesTabEnable&&BX.MessengerCommon.isLinesOperator()){i=i+this.unreadMessage[a].length}else if(!this.userChatBlockStatus[s]||!this.userChatBlockStatus[s][this.BXIM.userId]){t=t+this.unreadMessage[a].length}}else{t=t+this.unreadMessage[a].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;if(this.BXIM.linesCount!=i)BX.onCustomEvent(window,"onImUpdateCounterMessage",[i,"LINES"]);this.BXIM.linesCount=i;var n="";if(this.messageCount>99)n="99+";else if(this.messageCount>0)n=this.messageCount;if(this.notify.panelButtonMessageCount){this.notify.panelButtonMessageCount.innerHTML=n;this.notify.adjustPosition({resize:true,timeout:500})}if(BX.MessengerCommon.isPage()){BX.MessengerWindow.setTabBadge("im",t);BX.MessengerWindow.setTabBadge("im-ol",i)}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");e=e=="birthday"?"online":e;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(BX.MessengerCommon.isDesktop())BX.desktop.setIconStatus(e)};BX.Messenger.prototype.resizeMainWindow=function(){if(BX.MessengerCommon.isPage())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,s){if(typeof e!="string")return false;if(typeof s!="function"){s=BX.delegate(function(){this.hideTopLine()},this)}var i=[];i.push(BX.create("span",{props:{className:"bx-messenger-box-topline-close"},events:{click:s}}));if(typeof t=="object"){var a=[];for(var n=0;n<t.length;n++){a.push(BX.create("span",{props:{className:"bx-messenger-box-topline-button"},html:t[n].title,events:{click:t[n].callback}}))}i.push(BX.create("span",{props:{className:"bx-messenger-box-topline-buttons"},children:a}))}i.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:i});BX.addClass(this.popupMessengerTopLine,"bx-messenger-box-topline-show");return true};BX.Messenger.prototype.hideTopLine=function(e){BX.removeClass(this.popupMessengerTopLine,"bx-messenger-box-topline-show");if(e!==false);{BX.localStorage.set("mhtl",true,1)}};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();if(this.popupIframeMenu!=null&&this.popupIframeBind)this.popupIframeMenu.destroy();if(window.obCrm&&window.obCrm.olCrmSelector&&window.obCrm.olCrmSelector.popup)window.obCrm.olCrmSelector.popup.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:"_blank","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 n=i.attrs?i.attrs:{};n["title"]=i.title?i.title:"";n["href"]=i.href?i.href:"";n["target"]=i.target?i.target:"_blank";n["data-params"]=i.dataParams?JSON.stringify(i.dataParams):"";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":"")+(i.disabled?" bx-messenger-popup-menu-item-disabled":"")+(BX.type.isNotEmptyString(i.className)?" "+i.className:"")},attrs:n,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=="mhtl"){this.hideTopLine(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=="mrm"){BX.MessengerCommon.readMessage(e.value,false,false)}else if(e.key=="mcl"){BX.MessengerCommon.leaveFromChat(e.value,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;e.value.date=new Date(e.value.date);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"){e.value.message.date=new Date(e.value.message.date);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.linesVoteHeadDialog=function(e,t,s){s=s||false;var i=e.getAttribute("data-rating")||0;var a=BX.MessengerCommon.linesVoteHeadNodes(t,i,true,s?null:e);if(s)return a;this.tooltip(e,a,{offsetTop:10,offsetLeft:12,bindOptions:{position:"bottom"}});return true};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();if(!e)return false;var s=this.BXIM.disk.enable;s=false;this.popupHistoryPanel=null;var i=this.redrawHistoryPanel("chat"+e,e,{drawLinesJoin:t.CAN_JOIN,drawLinesVote:t.CAN_VOTE_HEAD,sessionVoteHead:t.SESSION_VOTE_HEAD,sessionId:t.SESSION_ID});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);if(t.HISTORY["chat"+e]){t.HISTORY["chat"+e].sort(BX.delegate(function(e,t){e=parseInt(e);t=parseInt(t);if(e>t){return 1}else if(e<t){return-1}else{return 0}},this))}this.drawHistory("chat"+e,t.HISTORY,false,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")=="openlines"){this.linesOpenHistory(BX.proxy_context.getAttribute("data-sessionId"))}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")=="date"){this.openPopupMenu(BX.proxy_context,"shareMenu")}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.linesLivechatFormShow=function(e,t,s){return false};BX.Messenger.prototype.linesLivechatFormHide=function(){return this.linesLivechatFormShow()};BX.Messenger.prototype.linesOpenMessenger=function(e,t){t=t||{};BX.MessengerCommon.linesOpenSession(e,t)};BX.Messenger.prototype.linesCreateLead=function(){var e=this.getChatId();var t=BX.MessengerCommon.linesGetSession(this.chat[e]);if(t.crm=="N"){BX.MessengerCommon.linesCreateLead(e)}};BX.Messenger.prototype.linesCloseDialog=function(){var e=this.getChatId();BX.MessengerCommon.linesCloseDialog(e)};BX.Messenger.prototype.linesMarkAsSpam=function(){var e=this.getChatId();BX.MessengerCommon.linesMarkAsSpam(e)};BX.Messenger.prototype.linesInterceptSession=function(){var e=this.getChatId();BX.MessengerCommon.linesInterceptSession(e)};BX.Messenger.prototype.linesTogglePinMode=function(){var e=this.getChatId();var t;var s=BX.MessengerCommon.linesGetSession(this.chat[e]);if(s.pin=="Y"){t="N"}else{t="Y"}BX.MessengerCommon.linesActivatePinMode(e,t)};BX.Messenger.prototype.linesToggleSilentMode=function(){var e=this.getChatId();var t;if(this.linesSilentMode[e]){BX.removeClass(this.popupMessengerHiddenModeButton,"bx-messenger-textarea-hidden-active");t="N"}else{BX.addClass(this.popupMessengerHiddenModeButton,"bx-messenger-textarea-hidden-active");t="Y"}this.linesSilentMode[e]=t=="Y";this.tooltip(this.popupMessengerHiddenModeButton,BX.message(t=="Y"?"IM_OL_CHAT_STEALTH_ON":"IM_OL_CHAT_STEALTH_OFF"),{offsetLeft:15,showOnce:t=="Y"?"OL_STEALTH_ON":"OL_STEALTH_OFF"})};BX.Messenger.prototype.linesOpenTransferDialog=function(e){if(this.BXIM.messenger.popupMessengerDialog&&BX.hasClass(this.BXIM.messenger.popupMessengerDialog,"bx-messenger-chat-load-last-message")){return false}if(this.popupTransferDialog!=null){this.popupTransferDialog.close();return false}if(this.popupChatDialog!=null){this.popupChatDialog.close();return false}BX.MessengerCommon.contactListSearchClear();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:BX.MessengerCommon.isPage()?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.getChatId();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,viewTransferOlQueue:true,viewOnlyIntranet:true,viewOfflineWithPhones:false});BX.bindDelegate(this.popupTransferDialogContactListElements,"click",{className:"bx-messenger-chatlist-more"},BX.delegate(this.toggleChatListGroup,this));this.popupTransferDialog.setAngle({offset:BX.MessengerCommon.isPage()?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,viewTransferOlQueue:true,viewOnlyIntranet:true,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,viewTransferOlQueue:true,viewOnlyIntranet:true,viewOfflineWithPhones:false})}if(this.linesTransferUser){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;var s=this.linesTransferUser.toString().substr(0,5)=="queue";var i=s?this.linesTransferUser.toString().substr(5):0;if(s){var a=this.linesTransferUser;for(var n=0;n<this.openlines.queue.length;n++){if(this.openlines.queue[n].id==i){a=this.openlines.queue[n].name;break}}t++;e+='<span class="bx-messenger-dest-block bx-messenger-dest-block-queue">'+'<span class="bx-messenger-dest-text">'+a+"</span>"+'<span class="bx-messenger-dest-del" data-userId="'+this.linesTransferUser+'"></span></span>'}else 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;if(!BX.MessengerCommon.userInChat(e))BX.MessengerCommon.dialogCloseCurrent(true);else BX.MessengerCommon.dialogCloseCurrent(false);if(this.linesTransferUser.toString().substr(0,5)=="queue"){var t=this.linesTransferUser.substr(5);for(var s=0;s<this.BXIM.messenger.openlines.queue.length;s++){if(this.BXIM.messenger.openlines.queue[s].id==t){this.BXIM.messenger.openlines.queue[s].transfer_count=parseInt(this.BXIM.messenger.openlines.queue[s].transfer_count)+1}}}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.initDate=new Date;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=620;this.startSettingsHeight=BX.browser.IsMac()?448:357;this.minSettingsHeight=137;if(this.BXIM.init&&BX.MessengerCommon.isPage()){BX.MessengerWindow.addTab({id:"config",title:BX.message("IM_SETTINGS"),order:150,target:false,events:{open:BX.delegate(function(e){this.BXIM.openSettings({active:BX.MessengerWindow.getCurrentTab()})},this)}});BX.MessengerWindow.addSeparator({order:500});if(!this.BXIM.bitrix24net){BX.MessengerWindow.addTab({id:"im-lf",title:BX.message("IM_DESKTOP_GO_SITE").replace("#COUNTER#",""),order:550,target:false,events:{open:BX.delegate(function(){BX.MessengerWindow.browse(BX.MessengerWindow.getCurrentUrl()+this.BXIM.path.lf)},this)}})}if(this.BXIM.animationSupport&&/Microsoft Windows NT 5/i.test(navigator.userAgent))this.BXIM.animationSupport=false;if(BX.MessengerCommon.isDesktop())this.BXIM.changeFocus(BX.desktop.windowIsFocused());if(this.BXIM.context=="DESKTOP"||this.BXIM.context=="POPUP-FULLSCREEN"){BX.bind(window,"keydown",BX.delegate(function(e){if(!BX.MessengerWindow.isPopupShow())return false;if(!(BX.MessengerWindow.getCurrentTab()=="im"||BX.MessengerWindow.getCurrentTab()=="notify"||BX.MessengerWindow.getCurrentTab()=="im-phone"||BX.MessengerWindow.getCurrentTab()=="im-ol"))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){}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="";if(BX.MessengerCommon.isDesktop()){BX.desktop.windowCommand("hide")}else if(this.messenger.popupMessenger){this.messenger.popupMessenger.destroy()}}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))}if(BX.MessengerCommon.isDesktop()){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){var t=BX.MessengerWindow.currentTab=="im-ol"||BX.MessengerWindow.currentTab=="im";BX.MessengerCommon.drawTab(this.messenger.currentTab,true,0,t);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(BX.MessengerCommon.isPage()&&this.BXIM.bitrixOpenLines){this.messenger.toggleLinesTab();this.messenger.toggleLinesNewGroup()}}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;for(var s in t){t[s]=decodeURIComponent(t[s])}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()}if(t.tab){BX.MessengerWindow.changeTab(t.tab,true)}BX.desktop.setActiveWindow();BX.desktop.windowCommand("show")}else if(e=="chat"&&t.id){this.BXIM.openMessenger("chat"+t.id);BX.desktop.setActiveWindow();BX.desktop.windowCommand("show")}else if(e=="chat"&&t.create){this.BXIM.openMessenger();this.BXIM.messenger.openChatCreateForm(t.create);BX.desktop.setActiveWindow();BX.desktop.windowCommand("show")}else if(e=="notify"){this.BXIM.openNotify({force:true});BX.desktop.setActiveWindow();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.setActiveWindow();BX.desktop.windowCommand("show")}else if(e=="callto"){if(t.video){this.BXIM.callTo(t.video,true);BX.desktop.setActiveWindow();BX.desktop.windowCommand("show")}else if(t.audio){this.BXIM.callTo(t.audio,false);BX.desktop.setActiveWindow();BX.desktop.windowCommand("show")}else if(t.phone){if(t.params){this.webrtc.phoneCall(unescape(t.phone),BX.desktopUtils.decodeParams(t.params))}else{this.BXIM.phoneTo(unescape(t.phone))}}}else if(e=="calllist"){if(!t.id)return;this.BXIM.startCallList(t.id,BX.desktopUtils.decodeParams(t.params))}},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")]&&t[BX.message("SITE_ID")].hasOwnProperty("**")){var s=parseInt(t[BX.message("SITE_ID")]["**"]);this.notify.updateNotifyCounters({"**":s})}},this))}};BX.IM.Desktop.prototype.run=function(){return BX.MessengerCommon.isPage()};BX.IM.Desktop.prototype.ready=function(){return BX.MessengerCommon.isDesktop()};BX.IM.Desktop.prototype.getCurrentUrl=function(){if(!BX.MessengerCommon.isDesktop())return false;return BX.desktop.getCurrentUrl()};BX.IM.Desktop.prototype.enableInVersion=function(e){if(!BX.MessengerCommon.isDesktop())return false;return BX.desktop.enableInVersion(e)};BX.IM.Desktop.prototype.addCustomEvent=function(e,t){if(!BX.MessengerCommon.isDesktop())return false;BX.desktop.addCustomEvent(e,t)};BX.IM.Desktop.prototype.onCustomEvent=function(e,t,s){if(!BX.MessengerCommon.isDesktop())return false;BX.desktop.onCustomEvent(e,t,s)};BX.IM.Desktop.prototype.windowCommand=function(e,t){if(!BX.MessengerCommon.isDesktop())return false;if(typeof t=="undefined")BX.desktop.windowCommand(e);else BX.desktop.windowCommand(t,e)};BX.IM.Desktop.prototype.browse=function(e){if(!BX.MessengerCommon.isDesktop())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(!BX.MessengerCommon.isDesktop())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(!BX.MessengerCommon.isDesktop())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(BX.MessengerCommon.isPage()&&!BX.MessengerCommon.isDesktop()){if(this.BXIM.context=="POPUP-FULLSCREEN"&&BX.hasClass(BX.MessengerWindow.popup,"bx-im-fullscreen-closed")){return false}if(this.BXIM.context=="LINES"){if(window.innerHeight<BX.MessengerWindow.minHeight){return false}}else if(BX.MessengerWindow.content){documentOffsetHeight=BX.MessengerWindow.content.offsetHeight}var e=documentOffsetHeight-this.initHeight;this.initHeight=documentOffsetHeight}else if(!BX.MessengerCommon.isDesktop()||!this.BXIM.init||!this.BXIM.messenger||!this.BXIM.notify){return false}else{if(window.innerHeight<BX.MessengerWindow.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.popupMessengerBodyPanel.style.height=this.BXIM.messenger.popupMessengerBodyDialog.offsetHeight+"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(BX.MessengerCommon.isDesktop()){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(!BX.MessengerCommon.isDesktop())return;BX.desktop.resize()};BX.IM.Desktop.prototype.openSettings=function(e,t,s){if(!BX.MessengerCommon.isDesktop())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(!BX.MessengerCommon.isDesktop())return false;BX.desktop.createWindow("history",BX.delegate(function(i){var a={chat:{},users:{},files:{}};var n=this.messenger.disk.enable;if(e.toString().substr(0,4)=="chat"){var o=e.substr(4);a["chat"][o]=this.messenger.chat[o];a["files"][o]=this.disk.files[o];for(var r=0;r<this.messenger.userInChat[o].length;r++)a["users"][this.messenger.userInChat[o][r]]=this.messenger.users[this.messenger.userInChat[o][r]]}else{o=this.messenger.userChat[e]?this.messenger.userChat[e]:0;a["userChat"]={};a["userChat"][e]=o;a["users"][e]=this.messenger.users[e];a["users"][this.BXIM.userId]=this.messenger.users[this.BXIM.userId];a["files"][o]=this.disk.files[o]}i.SetProperty("clientSize",{Width:n?this.minHistoryDiskWidth:this.minHistoryWidth,Height:this.minHistoryHeight});i.SetProperty("minClientSize",{Width:n?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||!BX.MessengerCommon.isDesktop()||!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(!BX.MessengerCommon.isDesktop()||!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(!BX.MessengerCommon.isDesktop())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(!BX.MessengerCommon.isDesktop())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': "+BX.MessengerCommon.isPage()+","+"'desktopVersion': "+this.BXIM.desktopVersion+","+"'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)+", 'external': "+(this.disk?this.disk.external: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"&&BX.MessengerCommon.isDesktop()&&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.MessengerCommon.checkInternetConnection(function(){var e=BXIM.desktop.initDate;var t=new Date;if(e.getDate()+""+e.getMonth()+""+e.getFullYear()==t.getDate()+""+t.getMonth()+""+t.getFullYear()){BX.PULL.setPrivateVar("_pullTimeConfig",0);BX.PULL.expireConfig();BX.PULL.init()}else{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(!BX.MessengerCommon.isDesktop())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(){if(BX.MessengerCommon.isDesktop()){BX.desktop.windowCommand("close")}else if(BX.MessengerCommon.isPage()){BX.MessengerWindow.closePopup()}};this.destroy=function(){if(BX.MessengerCommon.isDesktop()){BX.desktop.windowCommand("close")}else if(BX.MessengerCommon.isPage()){BX.MessengerWindow.closePopup()}}};BX.IM.WebRTC=function(e,t){if(this.parent){this.parent.constructor.apply(this,arguments)}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=null;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.phoneCanPerformCalls=t.phoneCanPerformCalls;this.phoneSipAvailable=t.phoneSipAvailable;this.phoneDeviceActive=t.phoneDeviceActive=="Y";this.phoneCanCallUserNumber=t.phoneCanCallUserNumber=="Y";this.phoneCallerID="";this.phoneLogin="";this.phoneServer="";this.phoneCheckBalance=false;this.phoneCallHistory={};this.phoneHistory=this.BXIM.getLocalConfig("phone-history")||[];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.phoneFullNumber="";this.phoneNumberUser="";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.phoneLines=t.phoneLines||{};this.phoneDefaultLineId=t.phoneDefaultLineId||false;this.phoneAvailableLines=t.phoneAvailableLines||[];this.phoneCallView=false;this.foldedPhoneCallView=BX.FoldedCallView.getInstance();this.callListId=0;this.lastCallListCallParams=null;this.debug=false;this.phoneKeypad=null;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();this.restoreFoldedCallView();if(BX.type.isFunction(this.logDevices)){this.logDevices()}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){s.users[i].last_activity_date=new Date(s.users[i].last_activity_date);s.users[i].mobile_last_date=new Date(s.users[i].mobile_last_date);s.users[i].idle=s.users[i].idle?new Date(s.users[i].idle):false;s.users[i].absent=s.users[i].absent?new Date(s.users[i].absent):false;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(BX.MessengerCommon.isDesktop()||!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(BX.MessengerCommon.isDesktop()&&!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){s.users[i].last_activity_date=new Date(s.users[i].last_activity_date);s.users[i].mobile_last_date=new Date(s.users[i].mobile_last_date);s.users[i].idle=s.users[i].idle?new Date(s.users[i].idle):false;s.users[i].absent=s.users[i].absent?new Date(s.users[i].absent):false;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){s.chat[i].date_create=new Date(s.chat[i].date_create);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(BX.MessengerCommon.isDesktop()||!this.BXIM.desktopStatus){this.BXIM.repeatSound("ringtone",5e3);this.callCommand(s.chatId,"wait");if(BX.MessengerCommon.isPage()){BX.MessengerWindow.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(BX.MessengerCommon.isDesktop()&&!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){s.users[i].last_activity_date=new Date(s.users[i].last_activity_date);s.users[i].mobile_last_date=new Date(s.users[i].mobile_last_date);s.users[i].idle=s.users[i].idle?new Date(s.users[i].idle):false;s.users[i].absent=s.users[i].absent?new Date(s.users[i].absent):false;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("Opponent "+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 o=this.callOverlayVideoMain.getAttribute("data-userId");if(o==s.senderId){var r=false;for(var i in this.callStreamUsers){if(i==s.senderId)continue;this.callChangeMainVideo(i);r=true;break}if(!r){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[o].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/main/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){t.users[s].last_activity_date=new Date(t.users[s].last_activity_date);t.users[s].mobile_last_date=new Date(t.users[s].mobile_last_date);t.users[s].idle=t.users[s].idle?new Date(t.users[s].idle):false;t.users[s].absent=t.users[s].absent?new Date(t.users[s].absent):false;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:BX.MessengerCommon.isDesktop()?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))}}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){if(this.phoneCallView&&(this.phoneCallExternal||this.phoneCallDevice==="PHONE")){if(this.phoneCallView.canBeUnloaded()){BX.localStorage.set("bxim-folded-call-card",{phoneCallId:this.phoneCallId,phoneCrm:this.phoneCrm,phoneCallDevice:this.phoneCallDevice,phoneCallExternal:this.phoneCallExternal,callView:this.phoneCallView.getState()},15)}}else{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.restoreFoldedCallView=function(){var e=this;var t=BX.localStorage.get("bxim-folded-call-card");if(!BX.type.isPlainObject(t))return;this.callActive=true;this.phoneCallId=t.phoneCallId;this.phoneCrm=t.phoneCrm;this.phoneCallDevice=t.phoneCallDevice;this.phoneCallExternal=t.phoneCallExternal;var s=t.callView;s.BXIM=this.BXIM;this.phoneCallView=new BX.PhoneCallView(t.callView);if(this.phoneCallExternal){this.phoneCallView.setUiState(BX.PhoneCallView.UiState.externalCard);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connected);this.bindPhoneViewCallbacksExternalCall(this.phoneCallView)}else{this.bindPhoneViewCallbacks(this.phoneCallView)}if(this.phoneCallExternal){BX.localStorage.set("viExternalCard",true,5);this.phoneConnectedInterval=setInterval(function(){if(e.phoneCallExternal){BX.localStorage.set("viExternalCard",true,5)}},5e3)}setTimeout(function(){BX.MessengerCommon.phoneCommand("getCall",{CALL_ID:e.phoneCallId},true,function(t){if(!t.FOUND||t.FOUND!=="Y"){e.phoneCallId="";e.callActive=false;e.phoneCallExternal=false;e.callSelfDisabled=false;clearInterval(e.BXIM.webrtc.phoneConnectedInterval);BX.localStorage.set("viExternalCard",false);if(e.phoneCallView){e.phoneCallView.dispose();e.phoneCallView=null}}})}.bind(this),0)};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.defaultSpeaker=localStorage.getItem("bx-im-settings-default-speaker");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(BX.MessengerCommon.isDesktop()&&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(this.useFallbackConstraints===false){this.useFallbackConstraints=true;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(BX.MessengerCommon.isDesktop())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{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(BX.MessengerCommon.isPage()&&BX.MessengerWindow.currentTab!="im"){BX.MessengerWindow.changeTab("im")}if(!this.callSupport()){if(!BX.MessengerCommon.isDesktop()){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){e.USERS[t].last_activity_date=new Date(e.USERS[t].last_activity_date);e.USERS[t].mobile_last_date=new Date(e.USERS[t].mobile_last_date);e.USERS[t].idle=e.USERS[t].idle?new Date(e.USERS[t].idle):false;e.USERS[t].absent=e.USERS[t].absent?new Date(e.USERS[t].absent):false;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(BX.MessengerCommon.isDesktop())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 o=0;o<this.messenger.userInChat[s].length;o++){var r=this.messenger.userInChat[s][o];var l=BX.MessengerCommon.getHrPhoto(r,this.messenger.users[r].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[r]=BX.create("img",{props:{className:"bx-messenger-call-overlay-photo-img"},attrs:{"data-userId":r,src:l.src,style:l.color?"background-color: "+l.color:""}})]})]}));if(r==this.BXIM.userId)continue;var l=BX.MessengerCommon.getHrPhoto(r,this.messenger.users[r].color);n.push(BX.create("div",{props:{className:"bx-messenger-call-video-mini bx-messenger-call-video-hide"},attrs:{"data-userId":r},events:{click:BX.delegate(function(){this.callChangeMainVideo(BX.proxy_context.getAttribute("data-userId"))},this)},children:[this.callOverlayVideoUsers[r]=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[r]=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 o=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:o.src,style:o.color?"background-color: "+o.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:o.src,style:o.color?"background-color: "+o.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;this.phoneCallView.setQuality(t);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.overlayEnterFullScreen=function(){if(this.callOverlayFullScreen){BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-fullscreen");if(document.cancelFullScreen)document.cancelFullScreen();else if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen()}else{BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-fullscreen");if(this.detectedBrowser=="chrome"){BX.bind(window,"webkitfullscreenchange",this.callOverlayFullScreenBind=BX.proxy(this.overlayEventFullScreen,this));this.messenger.popupMessengerContent.webkitRequestFullScreen(this.messenger.popupMessengerContent.ALLOW_KEYBOARD_INPUT)}else if(this.detectedBrowser=="firefox"){BX.bind(window,"mozfullscreenchange",this.callOverlayFullScreenBind=BX.proxy(this.overlayEventFullScreen,this));this.messenger.popupMessengerContent.mozRequestFullScreen(this.messenger.popupMessengerContent.ALLOW_KEYBOARD_INPUT)}}};BX.IM.WebRTC.prototype.overlayEventFullScreen=function(){if(this.callOverlayFullScreen){if(this.detectedBrowser=="chrome")BX.unbind(window,"webkitfullscreenchange",this.callOverlayFullScreenBind);else if(this.detectedBrowser=="firefox")BX.unbind(window,"mozfullscreenchange",this.callOverlayFullScreenBind);BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-fullscreen");if(BX.browser.IsChrome()){BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-fullscreen-chrome-hack");setTimeout(BX.delegate(function(){BX.removeClass(this.messenger.popupMessengerContent,"bx-messenger-fullscreen-chrome-hack")},this),100)}this.callOverlayFullScreen=false;this.messenger.resizeMainWindow()}else{BX.addClass(this.messenger.popupMessengerContent,"bx-messenger-fullscreen");this.callOverlayFullScreen=true;this.messenger.resizeMainWindow()}this.messenger.popupMessengerBody.scrollTop=this.messenger.popupMessengerBody.scrollHeight-this.messenger.popupMessengerBody.offsetHeight};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)}else{this.overlayEnterFullScreen()}}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.phoneCallView)this.phoneCallView.setStatusText(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(BX.MessengerCommon.isDesktop()&&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.phoneCallView)this.phoneCallView.setProgress(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(!BX.type.isNotEmptyString(e)||!this.phoneCallView)return false;this.phoneCallView.setStatusText(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.phoneCallView){this.phoneCallView.setTitle(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 o=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})]}))}o=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 r=[];if(a&&o){r=[BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),t,a,o,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),i]}else{if(a||o){r=[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:o,BX.create("div",{props:{className:"bx-messenger-call-crm-space"}}),i]}else if(!a&&!o&&i){BX.addClass(this.callOverlay,"bx-messenger-call-overlay-crm-short");this.callOverlayCrmBlock.innerHTML="";r=[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="";r=[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");r=[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:r})};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(BX.MessengerCommon.isDesktop())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(!BX.MessengerCommon.isDesktop())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.phoneMute=function(){if(!this.phoneCurrentCall)return false;this.phoneMicMuted=true;this.phoneCurrentCall.muteMicrophone()};BX.IM.WebRTC.prototype.phoneUnmute=function(){if(!this.phoneCurrentCall)return false;this.phoneMicMuted=false;this.phoneCurrentCall.unmuteMicrophone()};BX.IM.WebRTC.prototype.phoneToggleAudio=function(){if(!this.phoneCurrentCall)return false;if(this.phoneMicMuted){this.phoneCurrentCall.unmuteMicrophone();this.phoneCallView.setMuted(false)}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);if(this.phoneCallView)this.phoneCallView.setDeviceCall(e)}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){var t;var s;var i;var a=this.BXIM.design=="DESKTOP"&&!this.callActive?"left":"top";var n=this.BXIM.design=="DESKTOP"?this.callActive?120:76:94;if(!this.phoneSupport()&&!(this.BXIM.desktopStatus&&this.BXIM.desktopVersion>=18)){if(!BX.MessengerCommon.isDesktop()){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.phoneCurrentCall||BX.localStorage.get("viInitedCall")||BX.localStorage.get("viExternalCard")){return false}if(this.phoneKeypad!==null){this.phoneKeypad.close();return false}if(this.messenger.popupMessenger){if(!this.callActive){if(this.BXIM.design=="DESKTOP"){t=BX("bx-desktop-tab-im-phone");s=-110;i=60}else{BX.addClass(this.messenger.popupContactListSearchCall,"bx-messenger-input-search-call-active");t=this.messenger.popupContactListSearchCall;s=-10;i=-52}}else{t=BX("bx-messenger-call-overlay-button-keypad");s=7;i=BX.MessengerCommon.isPage()?-90:-65;if(BX.MessengerCommon.isPage()){BX.MessengerWindow.closeTab("im-phone")}}}else{t=this.notify.panelButtonCall;s=this.notify.panelButtonCallOffsetTop?this.notify.panelButtonCallOffsetTop:5;i=this.notify.panelButtonCallOffsetLeft?this.notify.panelButtonCallOffsetLeft:-75;a=this.notify.panelButtonCallAnlgePosition?this.notify.panelButtonCallAnlgePosition:a;n=this.notify.panelButtonCallAnlgeOffset?this.notify.panelButtonCallAnlgeOffset:n}this.messenger.setClosingByEsc(false);this.phoneKeypad=new BX.PhoneKeypad({bindElement:t,offsetTop:s,offsetLeft:i,anglePosition:a,angleOffset:n,defaultLineId:this.phoneDefaultLineId,lines:this.phoneLines,availableLines:this.phoneAvailableLines,history:this.phoneGetHistory(),onDial:function(e){var t={};this.phoneKeypad.close();if(e.lineId){t["LINE_ID"]=e.lineId}this.phoneCall(e.phoneNumber,t)}.bind(this),onClose:function(){this.phoneKeypad=null;if(this.messenger.popupMessenger&&this.BXIM.design=="DESKTOP"&&BX.MessengerCommon.isPage()){if(BX.MessengerWindow.lastTabTarget!="im"){BX.MessengerWindow.changeTab(this.BXIM.dialogOpen?"im":"notify")}else{BX.MessengerWindow.closeTab("im-phone")}}this.messenger.setClosingByEsc(true);BX.removeClass(this.messenger.popupContactListSearchCall,"bx-messenger-input-search-call-active")}.bind(this)});this.phoneKeypad.show()};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(BX.MessengerCommon.isDesktop()){e=false}this.phoneDisconnectAfterCallFlag=e===false?false:true;return true};BX.IM.WebRTC.prototype.phoneDisplayExternal=function(e){var t=e.phoneNumber;this.phoneLog(t,e);this.phoneNumberUser=BX.util.htmlspecialchars(t);t=BX.MessengerCommon.phoneCorrect(t);if(typeof e!="object")e={};if(this.callActive||this.callInit)return;if(this.phoneCallView)return;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=t;this.phoneCallView=new BX.PhoneCallView({BXIM:this.BXIM,callId:e.callId,config:e.config,direction:BX.PhoneCallView.Direction.outgoing,phoneNumber:this.phoneNumber,statusText:BX.message("IM_M_CALL_ST_CONNECT"),hasSipPhone:true,deviceCall:true,portalCall:e.portalCall,portalCallUserId:e.portalCallUserId,portalCallData:e.portalCallData,crm:e.showCrmCard,crmEntityType:e.crmEntityType,crmEntityId:e.crmEntityId,crmData:this.phoneCrm});this.bindPhoneViewCallbacks(this.phoneCallView);this.phoneCallView.setUiState(BX.PhoneCallView.UiState.idle);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connected);this.phoneCallView.show()};BX.IM.WebRTC.prototype.isRestLine=function(e){if(this.phoneLines.hasOwnProperty(e))return this.phoneLines[e].TYPE==="REST";else return false};BX.IM.WebRTC.prototype.setPhoneNumber=function(e){var t=/(\d+)([;#]*)([\d,]*)/.exec(e);this.phoneFullNumber=e;if(t){this.phoneNumber=t[1]}};BX.IM.WebRTC.prototype.phoneCall=function(e,t){if(BX.localStorage.get("viInitedCall"))return false;if(this.phoneCallView)return false;if(this.callActive||this.callInit)return false;if(this.popupKeyPad)this.popupKeyPad.close();if(e!=""){this.phoneAddToHistory(e)}var s=BX.type.isPlainObject(t)&&t["LINE_ID"]?t["LINE_ID"]:this.phoneDefaultLineId;if(this.isRestLine(s)){BX.MessengerCommon.phoneStartCallViaRestApp(e,s,t);return true}this.phoneLog(e,t);this.phoneNumberUser=BX.util.htmlspecialchars(e);numberOriginal=e;if(typeof t!="object")t={};var i=BX.MessengerCommon.phoneCorrect(e);if(i[0]==="+"){i=i.substr(1)}if(i.length<=0){this.BXIM.openConfirm({title:BX.message("IM_PHONE_WRONG_NUMBER"),message:BX.message("IM_PHONE_WRONG_NUMBER_DESC")});return false}this.setPhoneNumber(i);if(!this.phoneSupport()){if(!BX.MessengerCommon.isDesktop()){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.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.phoneParams=t;this.phoneCallView=new BX.PhoneCallView({phoneNumber:this.phoneFullNumber,callTitle:this.phoneNumberUser,fromUserId:this.BXIM.userId,direction:BX.PhoneCallView.Direction.outgoing,uiState:BX.PhoneCallView.UiState.connectingOutgoing,status:BX.message("IM_M_CALL_ST_CONNECT"),hasSipPhone:this.phoneDeviceActive,deviceCall:this.phoneCallExternal,BXIM:this.BXIM,crmData:this.phoneCrm,autoFold:t["AUTO_FOLD"]===true});this.bindPhoneViewCallbacks(this.phoneCallView);this.phoneCallView.show();this.BXIM.playSound("start");if(this.phoneCallExternal){this.phoneCallDevice="PHONE";this.phoneCallView.setProgress("wait");this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_PHONE_NOTICE"));BX.MessengerCommon.phoneCommand("deviceStartCall",{NUMBER:numberOriginal.toString().replace(/[^0-9\*#,;]/g,""),PARAMS:t},true,function(e){this.phoneCallId=e.CALL_ID;this.phoneCallExternal=e.EXTERNAL==true;this.phoneCallConfig=e.CONFIG;this.phoneCallView.setProgress("wait");this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_WAIT_PHONE"));this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingOutgoing);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connecting);if(BX.MessengerCommon.isDesktop()){BX.desktop.changeTab("im");BX.desktop.windowCommand("show");this.BXIM.desktop.closeTopmostWindow()}}.bind(this))}else{this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_CALL_INIT"));if(!this.phoneLogin||!this.phoneServer)BX.MessengerCommon.phoneAuthorize();else this.phoneApiInit()}};BX.IM.WebRTC.prototype.phoneAddToHistory=function(e){var t=this.phoneHistory;var s=t.indexOf(e);if(s===0){}else if(s>0){t.splice(s,s);this.phoneHistory=[e].concat(t)}else{this.phoneHistory=[e].concat(t.slice(0,4))}this.BXIM.setLocalConfig("phone-history",this.phoneHistory)};BX.IM.WebRTC.prototype.phoneGetHistory=function(){return this.phoneHistory};BX.IM.WebRTC.prototype.startCallList=function(e,t){e=parseInt(e);if(e==0||this.callActive||this.callInit||this.phoneCallView||this.isCallListMode())return false;this.callListId=e;this.phoneCallView=new BX.PhoneCallView({crm:true,callListId:e,callListStatusId:t.callListStatusId,callListItemIndex:t.callListItemIndex,direction:BX.PhoneCallView.Direction.outgoing,makeCall:t.makeCall===true,uiState:BX.PhoneCallView.UiState.outgoing,BXIM:this.BXIM,webformId:t.webformId||0,webformSecCode:t.webformSecCode||"",hasSipPhone:this.phoneDeviceActive,deviceCall:this.phoneDeviceCall(),crmData:this.phoneCrm});this.bindPhoneViewCallbacks(this.phoneCallView);this.phoneCallView.show();return true};BX.IM.WebRTC.prototype.isCallListMode=function(){return this.callListId>0};BX.IM.WebRTC.prototype.callListMakeCall=function(e){if(this.isRestLine(this.phoneDefaultLineId)){BX.MessengerCommon.phoneStartCallViaRestApp(e.phoneNumber,this.phoneDefaultLineId,{ENTITY_TYPE:"CRM_"+e.crmEntityType,ENTITY_ID:e.crmEntityId,CALL_LIST_ID:e.callListId});return true}if(BX.localStorage.get("viInitedCall"))return false;if(this.callActive||this.callInit)return false;if(!this.phoneCallView)return false;this.lastCallListCallParams=e;if(typeof params!="object")params={};if(!this.phoneSupport()){this.phoneCallView.setStatusText(BX.message("IM_CALL_NO_WEBRT"));this.phoneCallView.setUiState(BX.PhoneCallView.UiState.error);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.idle);return false}var t=e.phoneNumber;var s=t;var i=BX.MessengerCommon.phoneCorrect(t);if(i[0]==="+")i=i.substr(1);if(i.length<=0){this.phoneCallView.setStatusText(BX.message("IM_PHONE_WRONG_NUMBER_DESC"));return false}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.setPhoneNumber(i);this.phoneParams={ENTITY_TYPE:"CRM_"+e.crmEntityType,ENTITY_ID:e.crmEntityId,CALL_LIST_ID:e.callListId};this.BXIM.playSound("start");if(this.phoneCallExternal){this.phoneCallDevice="PHONE";this.phoneCallView.setProgress("wait");this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_PHONE_NOTICE"));this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingOutgoing);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connecting);BX.MessengerCommon.phoneCommand("deviceStartCall",{NUMBER:s.toString().replace(/[^0-9\*#,;]/g,""),PARAMS:this.phoneParams},true,function(e){this.phoneCallId=e.CALL_ID;this.phoneCallExternal=params.EXTERNAL==true;this.phoneCallConfig=params.CONFIG;this.phoneCallView.setProgress("wait");this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_WAIT_PHONE"));this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingOutgoing);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connecting);if(BX.MessengerCommon.isDesktop()){BX.desktop.changeTab("im");BX.desktop.windowCommand("show");this.BXIM.desktop.closeTopmostWindow()}}.bind(this))}else{this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_CALL_INIT"));this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingOutgoing);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connecting);if(!this.phoneLogin||!this.phoneServer)BX.MessengerCommon.phoneAuthorize();else this.phoneApiInit()}};BX.IM.WebRTC.prototype.phoneIncomingAnswer=function(){this.BXIM.stopRepeatSound("ringtone");this.callSelfDisabled=true;BX.MessengerCommon.phoneCommand(this.phoneTransferEnabled?"answerTransfer":"answer",{CALL_ID:this.phoneCallId});if(this.popupKeyPad)this.popupKeyPad.close();this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingIncoming);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connecting);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.phoneCallView.setUiState(BX.PhoneCallView.UiState.error);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.idle);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:false};if(this.debug){t.showDebugInfo=true;t.showWarnings=true;t.prettyPrint=true}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)}if(BX.MessengerCommon.isDesktop()&&BX.type.isFunction(this.phoneAPI.setLoggerCallback)){this.phoneAPI.enableSilentLogging();this.phoneAPI.setLoggerCallback(function(e){this.phoneLog(e.label+": "+e.message)}.bind(this))}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(BX.MessengerCommon.isPage()){BX.MessengerWindow.changeTab("im")}if(BX.MessengerCommon.isDesktop()){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(BX.MessengerCommon.isDesktop()&&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.phoneCallView.setProgress("wait");this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_WAIT_ACCESS"));this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connecting);if(this.phoneIncoming)this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingIncoming);else this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingOutgoing)}else{this.phoneLog("Connection exists");this.phoneCallView.setProgress("connect");this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_CONNECT"));this.phoneOnAuthResult({result:true});this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connecting);if(this.phoneIncoming)this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingIncoming);else this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connectingOutgoing)}};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(BX.MessengerCommon.isDesktop()&&this.BXIM.init){BX.desktop.syncPause(true)}this.BXIM.stopRepeatSound("ringtone",5e3);BX.localStorage.set("viInitedCall",true,7);clearInterval(this.phoneConnectedInterval);this.phoneConnectedInterval=setInterval(function(){BX.localStorage.set("viInitedCall",true,7)},5e3);this.desktop.closeTopmostWindow();this.phoneLog("Call connected",e);this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connected);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connected);this.phoneCallView.setProgress("online");this.phoneCallView.setStatusText(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.bindPhoneViewCallbacks=function(e){if(!e instanceof BX.PhoneCallView)return false;e.setCallback("mute",function(){this.phoneMute()}.bind(this));e.setCallback("unmute",function(){this.phoneUnmute()}.bind(this));e.setCallback("hold",function(){BX.MessengerCommon.phoneHold()}.bind(this));e.setCallback("unhold",function(){BX.MessengerCommon.phoneUnhold()}.bind(this));e.setCallback("answer",this.phoneIncomingAnswer.bind(this));e.setCallback("skip",function(){this.phoneCallFinish();this.callAbort();this.phoneCallView.close()}.bind(this));e.setCallback("hangup",function(){this.phoneCallFinish();this.callAbort();this.BXIM.playSound("stop");this.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_FINISHED"));this.phoneCallView.setCallState(BX.PhoneCallView.CallState.idle);if(this.isCallListMode()){this.phoneCallView.setUiState(BX.PhoneCallView.UiState.outgoing);if(this.phoneCallView.isFolded()){this.phoneCallView.unfold()}}else{this.phoneCallView.close()}}.bind(this));e.setCallback("transfer",function(e){if(e.type=="user"){this.phoneTransferType="user";this.phoneTransferUser=e.userId;this.sendInviteTransfer()}else if(e.type=="phone"){this.phoneTransferType="phone";this.phoneTransferUser=e.userId;this.phoneTransferPhone=e.phone;this.sendInviteTransfer()}}.bind(this));e.setCallback("cancelTransfer",this.cancelInviteTransfer.bind(this));e.setCallback("callListMakeCall",this.callListMakeCall.bind(this));e.setCallback("close",function(){this.callListId=0;if(this.phoneCallView){this.phoneCallView.dispose();this.phoneCallView=null}if(this.phoneCallDevice=="PHONE"){this.phoneCallId="";this.callActive=false;this.callInit=false;this.phoneCallExternal=false;this.callSelfDisabled=false;clearInterval(this.BXIM.webrtc.phoneConnectedInterval);BX.localStorage.set("viExternalCard",false)}}.bind(this));e.setCallback("switchDevice",function(e){var t=e.phoneNumber;var s=this.lastCallListCallParams;this.phoneCallFinish();this.callAbort();this.phoneDeviceCall(!this.phoneDeviceCall());this.phoneCallView.setDeviceCall(this.phoneDeviceCall());if(this.isCallListMode()){this.callListMakeCall(s)}else{this.phoneCallView.close();this.phoneCall(t)}}.bind(this));e.setCallback("qualityGraded",function(e){var t={COMMAND:"gradeQuality",grade:e};if(this.phoneCurrentCall)this.phoneCurrentCall.sendMessage(JSON.stringify(t))}.bind(this));e.setCallback("dialpadButtonClicked",function(e){BX.MessengerCommon.phoneSendDTMF(e)}.bind(this))};BX.IM.WebRTC.prototype.phoneIncomingWait=function(e){e.isCallback=!!e.isCallback;this.phoneLog("incoming call",JSON.stringify(e));if(!this.phoneSupport()){if(!BX.MessengerCommon.isDesktop()){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=BX.util.htmlspecialchars(e.callerId);e.callerId=e.callerId.replace(/[^a-zA-Z0-9\.]/g,"");if(this.callActive||this.callInit)return false;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=e.callId;this.phoneNumber=e.callerId;this.phoneParams={};var t;if(this.phoneTransferEnabled)t=BX.PhoneCallView.Direction.incomingTransfer;else if(e.isCallback)t=BX.PhoneCallView.Direction.callback;else t=BX.PhoneCallView.Direction.incoming;this.phoneCallView=new BX.PhoneCallView({BXIM:this.BXIM,userId:this.BXIM.userId,phoneNumber:this.phoneNumber,lineNumber:e.lineNumber,companyPhoneNumber:e.companyPhoneNumber,callTitle:this.phoneNumberUser,direction:t,statusText:e.isCallback?BX.message("IM_PHONE_INVITE_CALLBACK"):BX.message("IM_PHONE_INVITE"),crm:e.showCrmCard,crmEntityType:e.crmEntityType,crmEntityId:e.crmEntityId,crmActivityId:e.crmActivityId,crmActivityEditUrl:e.crmActivityEditUrl,callId:this.phoneCallId,crmData:this.phoneCrm});this.bindPhoneViewCallbacks(this.phoneCallView);this.phoneCallView.setUiState(BX.PhoneCallView.UiState.incoming);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connecting);if(e.config){this.phoneCallView.setConfig(e.config)}this.phoneCallView.show();if(e.portalCall){this.phoneCallView.setPortalCall(true);this.phoneCallView.setPortalCallData(e.portalCallData);this.phoneCallView.setPortalCallUserId(e.portalCallUserId)}if(!this.BXIM.windowFocus&&this.BXIM.notifyManager.nativeNotifyGranted()){var s={title:BX.message("IM_PHONE_DESC"),text:BX.util.htmlspecialcharsback(this.phoneCallView.getTitle()),icon:this.callUserId?this.messenger.users[this.callUserId].avatar:"",tag:"im-call"};s.onshow=function(){var e=this;setTimeout(function(){e.close()},5e3)};s.onclick=function(){window.focus();this.close()};this.BXIM.notifyManager.nativeNotify(s)}};BX.IM.WebRTC.prototype.phoneIncomingWaitDesktop=function(e,t,s,i,a){this.BXIM.ppServerStatus=true;if(!this.callSupport()||!BX.MessengerCommon.isDesktop())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.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.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_TRANSFER"));this.phoneCallView.setUiState(BX.PhoneCallView.UiState.transferring);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.phoneCallView.setStatusText(BX.message("IM_M_CALL_ST_ONLINE"));this.phoneCallView.setUiState(BX.PhoneCallView.UiState.connected);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.phoneCallView.setStatusText(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.BXIM.playSound("stop");this.phoneCallView.autoClose()}};BX.IM.WebRTC.prototype.startMicTest=function(){var e,t,s,i,a,n;var o;var r={audio:{deviceId:{ideal:this.defaultMicrophone}},video:{deviceId:{ideal:this.defaultCamera}}};var l;var p="waiting";var h=this;var c=[];var u=BX.create("div",{props:{className:"bx-messenger-mic-test"},children:[BX.create("div",{props:{className:"bx-messenger-mic-test-videos"},children:[BX.create("div",{props:{className:"bx-messenger-mic-test-video-wrap"},children:[a=BX.create("video",{props:{className:"bx-messenger-mic-test-video-self"}})]}),BX.create("div",{props:{className:"bx-messenger-mic-test-video-wrap"},children:[n=BX.create("video",{props:{className:"bx-messenger-mic-test-video-self"},events:{ended:function(){p="idle";t.innerText=BX.message("IM_CALL_MIC_TEST_PLAY_START");e.disabled=false}}})]})]}),BX.create("div",{props:{className:"bx-messenger-mic-test-buttons"},children:[e=BX.create("button",{text:BX.message("IM_CALL_MIC_TEST_RECORD_START"),events:{click:function(){if(p=="idle"){o=new MediaRecorder(h.micTestVideoStream,{mimeType:"video/webm; codecs=vp9"});o.start();o.ondataavailable=function(e){c.push(e.data)};o.onstop=function(){l=new Blob(c,{type:"video/webm"});n.src=URL.createObjectURL(l);p="idle";t.disabled=false;e.innerText=BX.message("IM_CALL_MIC_TEST_RECORD_START")};n.src=null;e.innerText=BX.message("IM_CALL_MIC_TEST_RECORD_STOP");t.disabled=true;p="recording"}else if(p=="recording"){o.stop()}else if(p=="playing"){}}}}),t=BX.create("button",{text:BX.message("IM_CALL_MIC_TEST_PLAY_START"),events:{click:function(){if(p=="idle"){n.play();p="playing";t.innerText=BX.message("IM_CALL_MIC_TEST_PLAY_STOP");e.disabled=true}else if(p=="playing"){n.pause();p="idle";t.innerText=BX.message("IM_CALL_MIC_TEST_PLAY_START");e.disabled=false}}}}),s=BX.create("button",{text:BX.message("IM_CALL_MIC_TEST_CLOSE"),events:{click:function(){BX.webrtc.stopMediaStream(h.micTestVideoStream);h.micTestVideoStream=null;BX.remove(u)}}})]}),i=BX.create("div",{props:{className:"bx-messenger-mic-test-button-exit"}})]});this.messenger.popupMessengerContent.insertBefore(u,this.messenger.popupMessengerContent.firstChild);a.volume=0;e.disabled=true;t.disabled=true;navigator.mediaDevices.getUserMedia(r).then(function(t){h.micTestVideoStream=t;a.src=URL.createObjectURL(h.micTestVideoStream);a.play();p="idle";e.disabled=false})};BX.IM.WebRTC.prototype.showExternalCall=function(e){var t=this;var s;if(this.phoneCallView)return;setTimeout(function(){BX.localStorage.set("viExternalCard",true,5)},100);clearInterval(this.phoneConnectedInterval);this.phoneConnectedInterval=setInterval(function(){if(t.phoneCallExternal){BX.localStorage.set("viExternalCard",true,5)}},5e3);this.phoneCallId=e.callId;this.callActive=true;this.phoneCallExternal=true;if(e.isCallback)s=BX.PhoneCallView.Direction.callback;else if(e.fromUserId>0)s=BX.PhoneCallView.Direction.outgoing;else s=BX.PhoneCallView.Direction.incoming;this.phoneCallView=new BX.PhoneCallView({BXIM:this.BXIM,callId:e.callId,direction:s,phoneNumber:e.phoneNumber,lineNumber:e.lineNumber,companyPhoneNumber:e.companyPhoneNumber,fromUserId:e.fromUserId,toUserId:e.toUserId,crm:e.showCrmCard,crmEntityType:e.crmEntityType,crmEntityId:e.crmEntityId,crmActivityId:e.crmActivityId,crmActivityEditUrl:e.crmActivityEditUrl,crmData:this.phoneCrm});this.bindPhoneViewCallbacksExternalCall(this.phoneCallView);this.phoneCallView.setUiState(BX.PhoneCallView.UiState.externalCard);this.phoneCallView.setCallState(BX.PhoneCallView.CallState.connected);this.phoneCallView.setConfig(e.config);this.phoneCallView.show();if(e.portalCall){this.phoneCallView.setPortalCall(true);this.phoneCallView.setPortalCallData(e.portalCallData);this.phoneCallView.setPortalCallUserId(e.portalCallUserId)}};BX.IM.WebRTC.prototype.bindPhoneViewCallbacksExternalCall=function(e){e.setCallback("close",function(){if(this.phoneCallView){this.phoneCallView.dispose();this.phoneCallView=null}this.phoneCallId="";this.callActive=false;this.phoneCallExternal=false;this.callSelfDisabled=false;clearInterval(this.BXIM.webrtc.phoneConnectedInterval);BX.localStorage.set("viExternalCard",false)}.bind(this))};BX.IM.WebRTC.prototype.hideExternalCall=function(e){if(this.phoneCallView){this.phoneCallView.autoClose()}};BX.IM.WebRTC.prototype.phoneLog=function(){if(BX.MessengerCommon.isDesktop()){var e="";for(var t=0;t<arguments.length;t++){if(BX.type.isPlainObject(arguments[t])){try{e=e+" | "+JSON.stringify(arguments[t])}catch(t){e=e+" | (circular structure)"}}else{e=e+" | "+arguments[t]}}BX.desktop.log("phone."+this.BXIM.userEmail+".log",e.substr(3))}if(this.debug){if(console){try{console.log("Phone Log",JSON.stringify(arguments))}catch(e){console.log("Phone Log",arguments[0])}}}};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){if(this.parent){this.parent.constructor.apply(this,arguments)}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.sourceOpponent=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("Opponent "+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;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.enableExternal=t.enableExternal;this.lightVersion=e.ieVersion==8||e.ieVersion==9;this.formBlocked={};this.formAgents={};this.files=t.files;for(var s in this.files){this.files[s].date=new Date(this.files[s].date)}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.getFileMenuIcon=function(){if(!this.enable)return null;return BX.create("div",{attrs:{title:BX.message("IM_F_UPLOAD_MENU")},props:{className:"bx-messenger-textarea-file"+(this.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.messenger.popupMessengerFileForm=BX.create("form",{attrs:{action:this.BXIM.pathToFileAjax,style:this.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.messenger.popupMessengerFileFormChatId=BX.create("input",{attrs:{type:"hidden",name:"CHAT_ID",value:0}}),this.messenger.popupMessengerFileFormRegChatId=BX.create("input",{attrs:{type:"hidden",name:"REG_CHAT_ID",value:0}}),this.messenger.popupMessengerFileFormRegMessageId=BX.create("input",{attrs:{type:"hidden",name:"REG_MESSAGE_ID",value:0}}),this.messenger.popupMessengerFileFormRegParams=BX.create("input",{attrs:{type:"hidden",name:"REG_PARAMS",value:""}}),this.messenger.popupMessengerFileFormRegMessageHidden=BX.create("input",{attrs:{type:"hidden",name:"REG_MESSAGE_HIDDEN",value:"N"}}),BX.create("input",{attrs:{type:"hidden",name:"IM_AJAX_CALL",value:"Y"}}),this.messenger.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.lightVersion?null:BX.create("div",{props:{className:"bx-messenger-popup-menu-item"},html:BX.browser.IsMobile()?BX.message("IM_F_UPLOAD_MENU_1_M"):BX.message("IM_F_UPLOAD_MENU_1")}),this.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.openFileDialog()},this)}}),BX.create("div",{props:{className:"bx-messenger-textarea-file-popup-arrow"}})]})],events:{click:BX.delegate(function(e){if(this.messenger.popupMessengerConnectionStatusState!="online")return false;if(BX.hasClass(this.messenger.popupMessengerFileButton,"bx-messenger-textarea-file-active")){setTimeout(BX.delegate(function(){this.messenger.closePopupFileMenu()},this),100)}else{if(parseInt(this.messenger.popupMessengerFileFormChatId.value)<=0){return false}if(this.messenger.popupMessengerFileFormInput.getAttribute("disabled")){var t=false;if(this.messenger.currentTab.toString().substr(0,4)=="chat"){var s=this.messenger.currentTab.toString().substr(4);if(this.messenger.chat[s]&&!this.enableExternal&&this.messenger.chat[s].type=="lines"&&this.messenger.chat[s].entity_id.substr(0,8)!="livechat"){t=true}}else if(this.messenger.users[this.messenger.currentTab].bot||this.messenger.users[this.messenger.currentTab].network){t=true}if(t){if(this.BXIM.isAdmin){var i=BX.create("div",{children:[BX.create("span",{html:BX.message("IM_D_SEND_PUBLIC_ADMIN")+" "}),BX.create("span",{props:{className:"bx-messenger-ajax"},html:BX.message("IM_D_SEND_PUBLIC_ADMIN_ON"),events:{click:BX.delegate(function(){this.messenger.closeMenuPopup();BX.ajax({url:this.BXIM.pathToAjax+"?IM_DISK_ACTIVATE_PUBLIC_LINK&V="+this.BXIM.revision,method:"POST",dataType:"json",timeout:30,data:{IM_DISK_ACTIVATE_PUBLIC_LINK:"Y",STATUS:"Y",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){this.tooltip(this.messenger.popupMessengerFileButton,BX.message("IM_D_SEND_PUBLIC_ADMIN_READY"),{offsetLeft:10});this.enableExternal=true;this.messenger.popupMessengerFileFormInput.removeAttribute("disabled")},this)})},this)}})]});this.messenger.tooltip(BX.proxy_context,i,{offsetLeft:10,width:400})}else{this.messenger.tooltip(BX.proxy_context,BX.message("IM_D_SEND_PUBLIC_USER"),{offsetLeft:10,width:400})}return BX.PreventDefault(e)}else{return BX.PreventDefault(e)}}this.messenger.closeMenuPopup();this.messenger.popupPopupMenuDateCreate=+new Date;BX.addClass(this.messenger.popupMessengerFileButton,"bx-messenger-textarea-file-active");if(BX.MessengerCommon.isPage()){BX.addClass(this.messenger.popupMessengerFileButton,"bx-messenger-textarea-file-desktop")}this.messenger.setClosingByEsc(false)}},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=true;var n=[];for(var o=0;o<i.length;o++){var r=this.files[e][i[o]];if(!r)continue;if(!(r.status=="done"||r.status=="error"))continue;var l=BX.MessengerCommon.formatDate(r.date,[["tommorow","tommorow"],["today","today"],["yesterday","yesterday"],["",BX.date.convertBitrixFormat(BX.message("FORMAT_DATE"))]]);var p=BX.create("span",{props:{className:"bx-messenger-file-user"},children:[BX.create("span",{props:{className:"bx-messenger-file-author"},html:this.messenger.users[r.authorId]?this.messenger.users[r.authorId].name:r.authorName}),BX.create("span",{props:{className:"bx-messenger-file-date"},html:l})]});var h=null;if(r.type=="image"&&(r.preview||r.urlPreview)){if(r.urlPreview){var c=BX.create("img",{attrs:{src:r.urlPreview},props:{className:"bx-messenger-file-image-text"}})}else if(r.preview&&typeof r.preview!="string"){var c=r.preview}else{var c=BX.create("img",{attrs:{src:r.preview},props:{className:"bx-messenger-file-image-text"}})}if(a&&r.urlShow){h=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:r.urlShow,target:"_blank"},props:{className:"bx-messenger-file-image-src"},children:[c]})]}),BX.create("br")]})}else{h=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:[c]})]}),BX.create("br")]})}}var u=r.name;if(u.length>23){u=u.substr(0,10)+"..."+u.substr(u.length-10,u.length)}var m=BX.create("span",{attrs:{title:r.name},props:{className:"bx-messenger-file-title"},html:u});if(a&&(r.urlShow||r.urlDownload)){m=BX.create("a",{props:{className:"bx-messenger-file-title-href"},attrs:{href:r.urlShow?r.urlShow:r.urlDownload,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(r.size)}),BX.create("span",{attrs:{title:BX.message("IM_F_MENU")},props:{className:"bx-messenger-file-menu"}})]});var d=null;if(r.status=="error"){d=BX.create("span",{props:{className:"bx-messenger-file-status-error"},html:r.errorText?r.errorText:BX.message("IM_F_ERROR")})}if(i.length==1&&s.showInner=="Y"){n=[p,m,h,d]}else{n.push(BX.create("div",{attrs:{id:"im-file-history-panel-"+r.id,"data-chatId":r.chatId,"data-fileId":r.id},props:{className:"bx-messenger-file"},children:[p,m,h,d]}))}if(i.length==1&&s.getElement=="Y"){n=n[0]}}return n};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:"500",height:"500"}}}});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(e){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;var t=false;if(e&&e["dataTransfer"]&&e["dataTransfer"]["types"]){for(var s in e["dataTransfer"]["types"]){if(e["dataTransfer"]["types"][s]==="Files"){t=true;break}}}if(t===false)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 o in s){var r=o.replace("n","");this.files[a]["disk"+r]={id:"disk"+r,tempId:"disk"+r,chatId:a,date:new Date(s[o].modifyDateInt*1e3),type:"file",preview:"",name:s[o].name,size:s[o].sizeInt,status:"upload",progress:-1,authorId:this.BXIM.userId,authorName:this.messenger.users[this.BXIM.userId].name,urlPreview:"",urlShow:"",urlDownload:""};n.push("disk"+r)}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="N";if(l.toString().substr(0,4)=="chat"&&this.BXIM.messenger.linesSilentMode&&this.BXIM.messenger.linesSilentMode[a]){h="Y"}var c="tempFile"+this.fileTmpId;this.messenger.message[c]={id:c,chatId:a,senderId:this.BXIM.userId,recipientId:l,date:new Date,text:i,params:{FILE_ID:n,CLASS:h=="Y"?"bx-messenger-content-item-system":""}};if(!this.messenger.showMessage[l])this.messenger.showMessage[l]=[];this.messenger.showMessage[l].push(c);BX.MessengerCommon.drawMessage(l,this.messenger.message[c]);BX.MessengerCommon.drawProgessMessage(c);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:c,OL_SILENT: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[c];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){a.date=new Date(a.date);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 o=BX.findChild(this.messenger.popupMessengerBodyWrap,{attribute:{"data-messageid":""+e.MESSAGE_TMP_ID}},true);if(o){o.setAttribute("data-messageid",""+e.MESSAGE_ID+"");if(o.getAttribute("data-blockmessageid")==""+e.MESSAGE_TMP_ID)o.setAttribute("data-blockmessageid",""+e.MESSAGE_ID+"")}else{var r=BX.findChild(this.messenger.popupMessengerBodyWrap,{attribute:{"data-blockmessageid":""+e.MESSAGE_TMP_ID}},true);if(r){r.setAttribute("data-blockmessageid",""+e.MESSAGE_ID+"")}}var p=BX.findChildByClassName(o,"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[c];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){var i=this.formBlocked[t+"_"+e]||BX.MessengerCommon.checkRestriction(e,"AVATAR")?true:false;if(this.messenger.currentTab!="chat"+e)return i;var a=this.formAgents[t]&&this.formAgents[t].fileInput?this.formAgents[t].fileInput:null;if(a){if(i){a.title="";a.disabled=true;a.style.cursor="default"}else{a.title=BX.message("IM_M_AVATAR_UPLOAD");a.removeAttribute("disabled");a.style.cursor=""}}if(s){if(i){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 i};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:3400,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(){clearTimeout(this.BXIM.messenger.popupMessengerTopLineTimeout);if(!this.BXIM.messenger.popupMessengerTopLine)return false;var e=BX.localStorage.get("imNativeNotify");if(!this.BXIM.xmppStatus&&!this.BXIM.desktopStatus&&e!==false&&window.Notification&&window.Notification.permission&&window.Notification.permission.toLowerCase()=="default"){clearTimeout(this.popupMessengerDesktopTimeout);var t=BX.delegate(function(){Notification.requestPermission();this.BXIM.messenger.hideTopLine()},this);var s=BX.delegate(function(){BX.localStorage.set("imNativeNotify",false,3e6);this.BXIM.saveSettings({nativeNotify:this.BXIM.settings.nativeNotify});this.BXIM.messenger.hideTopLine()},this);this.BXIM.messenger.showTopLine(BX.message("IM_WN_MAC")+"<br />"+BX.message("IM_WN_TEXT"),[{title:BX.message("IM_WN_ACCEPT"),callback:t},{title:BX.message("IM_DESKTOP_INSTALL_N"),callback:s}],BX.delegate(function(){BX.localStorage.set("imNativeNotify",false,86400);this.BXIM.messenger.hideTopLine()},this))}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"||BX.MessengerCommon.isDesktop()||!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.prototype.encodeParams=function(e){if(!BX.type.isPlainObject(e))return"";var t="";var s=true;for(var i in e){t=t+(s?"":"!!")+i+"!!"+e[i];s=false}return t};BX.desktopUtils.prototype.decodeParams=function(e){var t={};if(!BX.type.isNotEmptyString(e))return t;var s=e.split("!!");for(var i=0;i<s.length;i=i+2){t[s[i]]=s[i+1]}return t};BX.desktopUtils=new BX.desktopUtils})();