Your IP : 3.135.220.30


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/im/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/im/phone_call_view.min.js

(function(){var e=function(){};var t={simple:"simple",crm:"crm"};var i={simple:{width:550,height:492},crm:{width:550,height:650}};var s={height:"im-phone-call-view-height",width:"im-phone-call-view-width"};var n=15e3;var o={setTitle:"phoneCallViewSetTitle",setStatus:"phoneCallViewSetStatus",setUiState:"phoneCallViewSetUiState",setDeviceCall:"phoneCallViewSetDeviceCall",setCrmEntity:"phoneCallViewSetCrmEntity",setPortalCall:"phoneCallViewSetPortalCall",setPortalCallUserId:"phoneCallViewSetPortalCallUserId",setPortalCallData:"phoneCallViewSetPortalCallData",setConfig:"phoneCallViewSetConfig",setCallState:"phoneCallViewSetCallState",reloadCrmCard:"phoneCallViewReloadCrmCard",setCallId:"phoneCallViewSetCallId",setLineNumber:"phoneCallViewSetLineNumber",setCompanyPhoneNumber:"phoneCallViewSetCompanyPhoneNumber",closeWindow:"phoneCallViewCloseWindow",onHold:"phoneCallViewOnHold",onUnHold:"phoneCallViewOnUnHold",onMute:"phoneCallViewOnMute",onUnMute:"phoneCallViewOnUnMute",onMakeCall:"phoneCallViewOnMakeCall",onCallListMakeCall:"phoneCallViewOnCallListMakeCall",onAnswer:"phoneCallViewOnAnswer",onSkip:"phoneCallViewOnSkip",onHangup:"phoneCallViewOnHangup",onClose:"phoneCallViewOnClose",onStartTransfer:"phoneCallViewOnStartTransfer",onCancelTransfer:"phoneCallViewOnCancelTransfer",onBeforeUnload:"phoneCallViewOnBeforeUnload",onSwitchDevice:"phoneCallViewOnSwitchDevice",onQualityGraded:"phoneCallViewOnQualityGraded",onDialpadButtonClicked:"phoneCallViewOnDialpadButtonClicked",onSaveComment:"phoneCallViewOnSaveComment"};var l={restApps:[],callInterceptAllowed:false};BX.PhoneCallView=function(i){this.id="im-phone-call-view";this.BXIM=i.BXIM||window.BXIM;if(!BX.type.isPlainObject(i))i={};this.keypad=null;this.phoneNumber=i.phoneNumber||"hidden";this.lineNumber=i.lineNumber||"";this.companyPhoneNumber=i.companyPhoneNumber||"";this.direction=i.direction||BX.PhoneCallView.Direction.incoming;this.fromUserId=i.fromUserId;this.toUserId=i.toUserId;this.config=i.config||{};this.callId=i.callId||"";this.callState=BX.PhoneCallView.CallState.idle;this.crmEntityType=i.crmEntityType||"";this.crmEntityId=i.crmEntityId||0;this.crmActivityId=i.crmActivityId||0;this.crmActivityEditUrl=i.crmActivityEditUrl||"";this.crmData=BX.type.isPlainObject(i.crmData)?i.crmData:{};this.externalRequests={};this.portalCallUserId=i.portalCallUserId;this.portalCallData=i.portalCallData;this.hasSipPhone=i.hasSipPhone===true;this.deviceCall=i.deviceCall===true;this.portalCall=i.portalCall===true;this.crm=i.crm===true;this.held=false;this.muted=false;this.recording=i.recording===true;this.makeCall=i.makeCall===true;this.closable=false;this.allowAutoClose=true;this.folded=i.folded===true;this.autoFold=i.autoFold===true;this.title="";this._uiState=i.uiState||BX.PhoneCallView.UiState.idle;this.statusText=i.statusText||"";this.progress="";this.quality=0;this.qualityPopup=null;this.qualityGrade=0;this.comment="";this.commentShown=false;this.initialTimestamp=i.initialTimestamp||0;this.timerInterval=null;this.elements=this.getInitialElements();this.sections=this.getInitialSections();var s=this.getUiStateButtons(this._uiState);this.buttonLayout=s.layout;this.buttons=s.buttons;if(!BX.type.isPlainObject(i.events))i.events={};this.callbacks={hold:BX.type.isFunction(i.events.hold)?i.events.hold:e,unhold:BX.type.isFunction(i.events.unhold)?i.events.unhold:e,mute:BX.type.isFunction(i.events.mute)?i.events.mute:e,unmute:BX.type.isFunction(i.events.unmute)?i.events.unmute:e,makeCall:BX.type.isFunction(i.events.makeCall)?i.events.makeCall:e,callListMakeCall:BX.type.isFunction(i.events.callListMakeCall)?i.events.callListMakeCall:e,answer:BX.type.isFunction(i.events.answer)?i.events.answer:e,skip:BX.type.isFunction(i.events.skip)?i.events.skip:e,hangup:BX.type.isFunction(i.events.hangup)?i.events.hangup:e,close:BX.type.isFunction(i.events.close)?i.events.close:e,transfer:BX.type.isFunction(i.events.transfer)?i.events.transfer:e,cancelTransfer:BX.type.isFunction(i.events.cancelTransfer)?i.events.cancelTransfer:e,switchDevice:BX.type.isFunction(i.events.switchDevice)?i.events.switchDevice:e,qualityGraded:BX.type.isFunction(i.events.qualityGraded)?i.events.qualityGraded:e,dialpadButtonClicked:BX.type.isFunction(i.events.dialpadButtonClicked)?i.events.dialpadButtonClicked:e};this.popup=null;this._onBeforeUnloadHandler=this._onBeforeUnload.bind(this);this._onDblClickHandler=this._onDblClick.bind(this);this._onHoldButtonClickHandler=this._onHoldButtonClick.bind(this);this._onMuteButtonClickHandler=this._onMuteButtonClick.bind(this);this._onTransferButtonClickHandler=this._onTransferButtonClick.bind(this);this._onTransferCancelButtonClickHandler=this._onTransferCancelButtonClick.bind(this);this._onDialpadButtonClickHandler=this._onDialpadButtonClick.bind(this);this._onHangupButtonClickHandler=this._onHangupButtonClick.bind(this);this._onCloseButtonClickHandler=this._onCloseButtonClick.bind(this);this._onMakeCallButtonClickHandler=this._onMakeCallButtonClick.bind(this);this._onNextButtonClickHandler=this._onNextButtonClick.bind(this);this._onRedialButtonClickHandler=this._onRedialButtonClick.bind(this);this._onFoldButtonClickHandler=this._onFoldButtonClick.bind(this);this._onAnswerButtonClickHandler=this._onAnswerButtonClick.bind(this);this._onSkipButtonClickHandler=this._onSkipButtonClick.bind(this);this._onSwitchDeviceButtonClickHandler=this._onSwitchDeviceButtonClick.bind(this);this._onQualityMeterClickHandler=this._onQualityMeterClick.bind(this);this._onPullEventCrmHandler=this._onPullEventCrm.bind(this);this._externalEventHandler=this._onExternalEvent.bind(this);this._unloadHandler=this._onWindowUnload.bind(this);this.hiddenTabs=[];this.currentTabName="";this.moreTabsMenu=null;this.callListId=i.callListId||0;this.callListStatusId=i.callListStatusId||null;this.callListItemIndex=i.callListItemIndex||null;this.callListView=null;this.currentEntity=null;this.callingEntity=null;this.numberSelectMenu=null;this.webformId=i.webformId||0;this.webformSecCode=i.webformSecCode||"";this.webformLoaded=false;this.formManager=null;this.restAppLayoutLoaded=false;this.restAppLayoutLoading=false;this.restAppInterface=null;this.callWindow=null;this.slave=i.slave===true;this.skipOnResize=i.skipOnResize===true;this.desktop=new r({BXIM:this.BXIM,parentPhoneCallView:this,closable:this.callListId>0?true:this.closable});this.currentLayout=this.callListId>0?t.crm:t.simple;this.init();this.setTitle(this.createTitle());if(i.hasOwnProperty("uiState")){this.setUiState(i["uiState"])}window.test=this};BX.PhoneCallView.ButtonLayouts={centered:"centered",spaced:"spaced"};BX.PhoneCallView.create=function(e){return new BX.PhoneCallView(e)};BX.PhoneCallView.prototype.getInitialElements=function(){return{main:null,title:null,sections:{status:null,timer:null,crmButtons:null},avatar:null,progress:null,timer:null,status:null,commentEditorContainer:null,commentEditor:null,qualityMeter:null,crmCard:null,crmButtonsContainer:null,crmButtons:{},buttonsContainer:null,topLevelButtonsContainer:null,topButtonsContainer:null,buttons:{},sidebarContainer:null,tabsContainer:null,tabsBodyContainer:null,tabs:{callList:null,webform:null,app:null},tabsBody:{callList:null,webform:null,app:null},moreTabs:null}};BX.PhoneCallView.prototype.getInitialSections=function(){return{status:{visible:false},timer:{visible:false},crmButtons:{visible:false},commentEditor:{visible:false}}};BX.PhoneCallView.prototype.init=function(){var e=this;if(BX.MessengerCommon.isDesktop()&&!this.slave){this.desktop.openCallWindow("",null,{width:this.getInitialWidth(),height:this.getInitialHeight(),resizable:this.currentLayout==t.crm,minWidth:this.elements.sidebarContainer?950:550,minHeight:650});this.bindMasterDesktopEvents();window.addEventListener("beforeunload",this._unloadHandler);return}this.elements.main=this.createLayout();this.updateView();if(this.isDesktop()){document.body.appendChild(this.elements.main);this.bindSlaveDesktopEvents()}else if(this.isFolded()){document.body.appendChild(this.elements.main)}else{this.popup=this.createPopup();BX.addCustomEvent(window,"onLocalStorageSet",this._externalEventHandler)}if(this.callListId>0){if(this.callListView){this.callListView.reinit({node:this.elements.tabsBody.callList})}else{this.callListView=new c({node:this.elements.tabsBody.callList,id:this.callListId,statusId:this.callListStatusId,itemIndex:this.callListItemIndex,makeCall:this.makeCall,BXIM:this.BXIM,onSelectedItem:this.onCallListSelectedItem.bind(this)});this.callListView.init(function(){if(e.makeCall){e._onMakeCallButtonClick()}});this.setUiState(BX.PhoneCallView.UiState.outgoing)}}else if(this.crm&&!this.isFolded()){this.loadCrmCard(this.crmEntityType,this.crmEntityId)}BX.addCustomEvent("onPullEvent-crm",this._onPullEventCrmHandler);if(!this.isDesktop()){window.addEventListener("beforeunload",this._onBeforeUnloadHandler)}};BX.PhoneCallView.prototype.reinit=function(){this.elements=this.getInitialElements();this.init()};BX.PhoneCallView.setDefaults=function(e){for(paramName in e){if(e.hasOwnProperty(paramName)&&l.hasOwnProperty(paramName)){l[paramName]=e[paramName]}}};BX.PhoneCallView.prototype.show=function(){if(!this.popup)return;if(!this.isDesktop()&&!this.isFolded())this.disableDocumentScroll();this.popup.show()};BX.PhoneCallView.prototype.createPopup=function(){var e=this;return new BX.PopupWindow(e.getId(),null,{content:this.elements.main,closeIcon:false,noAllPaddings:true,zIndex:n,offsetLeft:0,offsetTop:0,closeByEsc:false,draggable:{restrict:false},overlay:{backgroundColor:"black",opacity:30},events:{onPopupClose:function(){if(e.isFolded()){}else{e.callbacks.close()}},onPopupDestroy:function(){e.popup=null}}})};BX.PhoneCallView.prototype.createLayout=function(){if(this.isFolded())return this.createLayoutFolded();else if(this.currentLayout==t.crm)return this.createLayoutCrm();else return this.createLayoutSimple()};BX.PhoneCallView.prototype.createLayoutCrm=function(){var e=BX.create("div",{props:{className:"im-phone-call-top-level"},events:{dblclick:this._onDblClickHandler},children:[this.elements.topLevelButtonsContainer=BX.create("div"),BX.create("div",{props:{className:"im-phone-call-wrapper"+(this.hasSideBar()?"":" im-phone-call-wrapper-without-sidebar")},children:[BX.create("div",{props:{className:"im-phone-call-container"+(this.hasSideBar()?"":" im-phone-call-container-without-sidebar")},children:[BX.create("div",{props:{className:"im-phone-call-header-container"},children:[BX.create("div",{props:{className:"im-phone-call-header"},children:[this.elements.title=BX.create("div",{props:{className:"im-phone-call-title-text"},html:this.renderTitle()})]})]}),this.elements.crmCard=BX.create("div",{props:{className:"im-phone-call-crm-card"}}),this.elements.sections.status=BX.create("div",{props:{className:"im-phone-call-section"},style:this.sections.status.visible?{}:{display:"none"},children:[BX.create("div",{props:{className:"im-phone-call-status-description"},children:[this.elements.status=BX.create("div",{props:{className:"im-phone-call-status-description-item"},text:this.statusText})]})]}),this.elements.sections.timer=BX.create("div",{props:{className:"im-phone-call-section"},style:this.sections.timer.visible?{}:{display:"none"},children:[BX.create("div",{props:{className:"im-phone-call-status-timer"},children:[BX.create("div",{props:{className:"im-phone-call-status-timer-item"},children:[this.elements.timer=BX.create("span")]})]})]}),this.elements.commentEditorContainer=BX.create("div",{props:{className:"im-phone-call-section"},style:this.commentShown?{}:{display:"none"},children:[BX.create("div",{props:{className:"im-phone-call-comments"},children:[this.elements.commentEditor=BX.create("textarea",{props:{className:"im-phone-call-comments-textarea",value:this.comment,placeholder:BX.message("IM_PHONE_CALL_COMMENT_PLACEHOLDER")},events:{bxchange:this._onCommentChanged.bind(this)}})]})]}),this.elements.sections.crmButtons=BX.create("div",{props:{className:"im-phone-call-section"},style:this.sections.crmButtons.visible?{}:{display:"none"},children:[this.elements.crmButtonsContainer=BX.create("div",{props:{className:"im-phone-call-crm-buttons"}})]}),this.elements.buttonsContainer=BX.create("div",{props:{className:"im-phone-call-buttons-container"}}),this.elements.topButtonsContainer=BX.create("div",{props:{className:"im-phone-call-buttons-container-top"}})]})]})]});if(this.hasSideBar()){this.createSidebarLayout();if(this.elements.sidebarContainer){e.appendChild(this.elements.sidebarContainer)}setTimeout(function(){this.checkMoreButton()}.bind(this),0)}if(this.isDesktop()){e.style.position="fixed";e.style.top=0;e.style.bottom=0;e.style.left=0;e.style.right=0}else{e.style.width=this.getInitialWidth()+"px";e.style.height=this.getInitialHeight()+"px"}return e};BX.PhoneCallView.prototype.hasSideBar=function(){if(this.isDesktop()&&!this.desktop.isFeatureSupported("iframe"))return this.callListId>0;else return this.callListId>0||this.webformId>0||l.restApps.length>0};BX.PhoneCallView.prototype.getInitialWidth=function(){var e=window.localStorage?parseInt(window.localStorage.getItem(s.width)):0;if(this.currentLayout==t.simple){return i.simple.width}else if(this.hasSideBar()){if(e>0){return e}else{return Math.min(Math.floor(screen.width*.8),1200)}}else{return i.crm.width}};BX.PhoneCallView.prototype.getInitialHeight=function(){var e=window.localStorage?parseInt(window.localStorage.getItem(s.height)):0;if(this.currentLayout==t.simple){return i.simple.height}else if(e>0){return e}else{return i.crm.height}};BX.PhoneCallView.prototype.saveInitialSize=function(e,i){if(!window.localStorage)return false;if(this.currentLayout==t.crm){window.localStorage.setItem(s.height,i.toString());if(this.hasSideBar()){window.localStorage.setItem(s.width,e)}}};BX.PhoneCallView.prototype.showSections=function(e){var t=this;if(!BX.type.isArray(e))return;e.forEach(function(e){if(t.elements.sections[e])t.elements.sections[e].style.removeProperty("display");if(t.sections[e])t.sections[e].visible=true})};BX.PhoneCallView.prototype.hideSections=function(e){var t=this;if(!BX.type.isArray(e))return;e.forEach(function(e){if(t.elements.sections[e])t.elements.sections[e].style.display="none";if(t.sections[e])t.sections[e].visible=false})};BX.PhoneCallView.prototype.showOnlySections=function(e){var t=this;if(!BX.type.isArray(e))return;var i={};e.forEach(function(e){i[e]=true});for(var s in this.elements.sections){if(!this.elements.sections.hasOwnProperty(s)||!BX.type.isDomNode(this.elements.sections[s]))continue;if(i[s]){this.elements.sections[s].style.removeProperty("display");if(this.sections.hasOwnProperty(s))this.sections[s].visible=true}else{this.elements.sections[s].style.display="none";if(this.sections.hasOwnProperty(s))this.sections[s].visible=false}}};BX.PhoneCallView.prototype.createSidebarLayout=function(){var e=this;var t=[];var i=[];if(this.callListId>0){this.elements.tabs.callList=BX.create("span",{props:{className:"im-phone-sidebar-tab"},dataset:{tabId:"callList",tabBodyId:"callList"},text:BX.message("IM_PHONE_CALL_VIEW_CALL_LIST_TITLE"),events:{click:this._onTabHeaderClick.bind(this)}});t.push(this.elements.tabs.callList);this.elements.tabsBody.callList=BX.create("div");i.push(this.elements.tabsBody.callList)}if(this.webformId>0&&this.isWebformSupported()){this.elements.tabs.webform=BX.create("span",{props:{className:"im-phone-sidebar-tab"},dataset:{tabId:"webform",tabBodyId:"webform"},text:BX.message("IM_PHONE_CALL_VIEW_WEBFORM_TITLE"),events:{click:this._onTabHeaderClick.bind(this)}});t.push(this.elements.tabs.webform);this.elements.tabsBody.webform=BX.create("div",{props:{className:"im-phone-call-form-container"}});i.push(this.elements.tabsBody.webform);this.formManager=new m({node:this.elements.tabsBody.webform,onFormSend:this._onFormSend.bind(this)})}if(l.restApps.length>0&&this.isRestAppsSupported()){l.restApps.forEach(function(i){var s=i.id;var n="restApp"+s;e.elements.tabs[n]=BX.create("span",{props:{className:"im-phone-sidebar-tab"},dataset:{tabId:n,tabBodyId:"app",restAppId:s},text:BX.util.htmlspecialchars(i.name),events:{click:e._onTabHeaderClick.bind(e)}});t.push(e.elements.tabs[n])});e.elements.tabsBody.app=BX.create("div",{props:{className:"im-phone-call-app-container"}});i.push(e.elements.tabsBody.app)}this.elements.sidebarContainer=BX.create("div",{props:{className:"im-phone-sidebar-wrap"},children:[BX.create("div",{props:{className:"im-phone-sidebar-tabs-container"},children:[this.elements.tabsContainer=BX.create("div",{props:{className:"im-phone-sidebar-tabs-left"},children:t}),BX.create("div",{props:{className:"im-phone-sidebar-tabs-right"},children:[this.elements.moreTabs=BX.create("span",{props:{className:"im-phone-sidebar-tab im-phone-sidebar-tab-more"},style:{display:"none"},dataset:{},text:BX.message("IM_PHONE_CALL_VIEW_MORE"),events:{click:this._onTabMoreClick.bind(this)}})]})]}),this.elements.tabsBodyContainer=BX.create("div",{props:{className:"im-phone-sidebar-tabs-body-container"},children:i})]});if(this.callListId>0)this.setActiveTab({tabId:"callList",tabBodyId:"callList"});else if(this.webformId>0&&this.isWebformSupported())this.setActiveTab({tabId:"webform",tabBodyId:"webform"});else if(l.restApps.length>0&&this.isRestAppsSupported())this.setActiveTab({tabId:"restApp"+l.restApps[0].id,tabBodyId:"app",restAppId:l.restApps[0].id})};BX.PhoneCallView.prototype.createLayoutSimple=function(){var e="";if(this.isPortalCall()&&this.portalCallData.hrphoto&&this.portalCallData.hrphoto[this.portalCallUserId]){e=this.portalCallData.hrphoto[this.portalCallUserId]}var t=BX.create("div",{props:{className:"im-phone-call-wrapper"},children:[BX.create("div",{props:{className:"im-phone-call-container"},children:[BX.create("div",{props:{className:"im-phone-calling-section"},children:[this.elements.title=BX.create("div",{props:{className:"im-phone-calling-text"}})]}),BX.create("div",{props:{className:"im-phone-call-section im-phone-calling-progress-section"},children:[BX.create("div",{props:{className:"im-phone-calling-progress-container"},children:[BX.create("div",{props:{className:"im-phone-calling-progress-container-block-l"},children:[BX.create("div",{props:{className:"im-phone-calling-progress-phone"}})]}),this.elements.progress=BX.create("div",{props:{className:"im-phone-calling-progress-container-block-c"}}),BX.create("div",{props:{className:"im-phone-calling-progress-container-block-r"},children:[this.elements.avatar=BX.create("div",{props:{className:"im-phone-calling-progress-customer"},style:e==""?{}:{"background-image":"url("+e+")"}})]})]})]}),BX.create("div",{props:{className:"im-phone-call-section"},children:[this.elements.status=BX.create("div",{props:{className:"im-phone-calling-process-status"}})]}),this.elements.buttonsContainer=BX.create("div",{props:{className:"im-phone-call-buttons-container"}}),this.elements.topButtonsContainer=BX.create("div",{props:{className:"im-phone-call-buttons-container-top"}})]})]});t.style.width=this.getInitialWidth()+"px";t.style.height=this.getInitialHeight()+"px";return t};BX.PhoneCallView.prototype.createLayoutFolded=function(){var e=this;return BX.create("div",{props:{className:"im-phone-call-panel-mini"},style:{zIndex:n},children:[this.elements.sections.timer=this.elements.timer=BX.create("div",{props:{className:"im-phone-call-panel-mini-time"},style:this.sections.timer.visible?{}:{display:"none"}}),this.elements.buttonsContainer=BX.create("div",{props:{className:"im-phone-call-panel-mini-buttons"}}),BX.create("div",{props:{className:"im-phone-call-panel-mini-expand"},events:{click:function(){e.unfold()}}})]})};BX.PhoneCallView.prototype.setActiveTab=function(e){var t=e.tabId;var i=e.tabBodyId;var s=e.restAppId||"";e.hidden=e.hidden===true;for(tab in this.elements.tabs){if(this.elements.tabs.hasOwnProperty(tab)&&BX.type.isDomNode(this.elements.tabs[tab])){if(tab==t)BX.addClass(this.elements.tabs[tab],"im-phone-sidebar-tab-active");else BX.removeClass(this.elements.tabs[tab],"im-phone-sidebar-tab-active")}}if(e.hidden)BX.addClass(this.elements.moreTabs,"im-phone-sidebar-tab-active");else BX.removeClass(this.elements.moreTabs,"im-phone-sidebar-tab-active");for(tab in this.elements.tabsBody){if(this.elements.tabsBody.hasOwnProperty(tab)&&BX.type.isDomNode(this.elements.tabsBody[tab])){if(tab==i)this.elements.tabsBody[tab].style.removeProperty("display");else this.elements.tabsBody[tab].style.display="none"}}this.currentTabName=t;if(t==="webform"&&!this.webformLoaded){this.loadForm({id:this.webformId,secCode:this.webformSecCode})}if(s!==""){this.loadRestApp({id:s,callId:this.BXIM.webrtc.phoneCallId,node:this.elements.tabsBody.app})}};BX.PhoneCallView.prototype.isCurrentTabHidden=function(){var e=false;for(var t=0;t<this.hiddenTabs.length;t++){if(this.hiddenTabs[t].dataset.tabId==this.currentTabName){e=true;break}}return e};BX.PhoneCallView.prototype.checkMoreButton=function(){if(!this.elements.tabsContainer)return;var e=this.elements.tabsContainer.children;var t;this.hiddenTabs=[];for(var i=0;i<e.length;i++){t=e.item(i);if(t.offsetTop>7){this.hiddenTabs.push(t)}}if(this.hiddenTabs.length>0)this.elements.moreTabs.style.removeProperty("display");else this.elements.moreTabs.style.display="none";if(this.isCurrentTabHidden())BX.addClass(this.elements.moreTabs,"im-phone-sidebar-tab-active");else BX.removeClass(this.elements.moreTabs,"im-phone-sidebar-tab-active")};BX.PhoneCallView.prototype._onTabHeaderClick=function(e){if(this.moreTabsMenu)this.moreTabsMenu.close();this.setActiveTab({tabId:e.target.dataset.tabId,tabBodyId:e.target.dataset.tabBodyId,restAppId:e.target.dataset.restAppId||"",hidden:false})};BX.PhoneCallView.prototype._onTabMoreClick=function(e){var t=this;if(this.hiddenTabs.length===0)return;if(this.moreTabsMenu){this.moreTabsMenu.close();return}var i=[];this.hiddenTabs.forEach(function(e){i.push({id:"selectTab_"+e.dataset.tabId,text:e.innerText,onclick:function(){t.moreTabsMenu.close();t.setActiveTab({tabId:e.dataset.tabId,tabBodyId:e.dataset.tabBodyId,restAppId:e.dataset.restAppId||"",hidden:true})}})});this.moreTabsMenu=BX.PopupMenu.create("phoneCallViewMoreTabs",this.elements.moreTabs,i,{autoHide:true,offsetTop:0,offsetLeft:0,angle:{position:"top"},parentPopup:this.popup,zIndex:n+100,events:{onPopupClose:function(){t.moreTabsMenu.popupWindow.destroy();BX.PopupMenu.destroy("phoneCallViewMoreTabs")},onPopupDestroy:function(){t.moreTabsMenu=null}}});this.moreTabsMenu.popupWindow.show()};BX.PhoneCallView.prototype.getId=function(){return this.id};BX.PhoneCallView.prototype.createTitle=function(){var e="";if(this.phoneNumber=="unknown"){return BX.message("IM_PHONE_CALL_VIEW_NUMBER_UNKNOWN")}if(this.phoneNumber=="hidden"){e=BX.message("IM_PHONE_HIDDEN_NUMBER")}else{e=this.phoneNumber.toString();if(e.substr(0,1)=="8"||e.substr(0,1)=="+"){}else if(!isNaN(parseInt(e))&&e.length>=10){e="+"+e}}if(this.isTransfer()){e=BX.message("IM_PHONE_CALL_TRANSFER").replace("#PHONE#",e)}else if(this.isCallback()){e=BX.message("IM_PHONE_CALLBACK_TO").replace("#PHONE#",e)}else if(this.isPortalCall()){switch(this.direction){case BX.PhoneCallView.Direction.incoming:e=BX.message("IM_M_CALL_VOICE_FROM").replace("#USER#",this.portalCallData.users[this.portalCallUserId].name);break;case BX.PhoneCallView.Direction.outgoing:e=BX.message("IM_M_CALL_VOICE_TO").replace("#USER#",this.portalCallData.users[this.portalCallUserId].name);break}}else{e=BX.message(this.direction===BX.PhoneCallView.Direction.incoming?"IM_PHONE_CALL_VOICE_FROM":"IM_PHONE_CALL_VOICE_TO").replace("#PHONE#",e);if(this.direction===BX.PhoneCallView.Direction.incoming&&this.companyPhoneNumber){e=e+", "+BX.message("IM_PHONE_CALL_TO_PHONE").replace("#PHONE#",this.companyPhoneNumber)}}return e};BX.PhoneCallView.prototype.renderTitle=function(){return BX.util.htmlspecialchars(this.title)};BX.PhoneCallView.prototype.renderAvatar=function(){var e="";if(this.isPortalCall()&&this.elements.avatar&&this.portalCallData.hrphoto&&this.portalCallData.hrphoto[this.portalCallUserId]){e=this.portalCallData.hrphoto[this.portalCallUserId];BX.adjust(this.elements.avatar,{style:e==""?{}:{"background-image":"url("+e+")"}})}};BX.PhoneCallView.prototype._getCrmEditUrl=function(e,t){if(!BX.type.isNotEmptyString(e))return"";t=parseInt(t)||0;return"/crm/"+e.toLowerCase()+"/edit/"+t.toString()+"/"};BX.PhoneCallView.prototype._generateExternalContext=function(){return this._getRandomString(16)};BX.PhoneCallView.prototype._getRandomString=function(e){charSet="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var t="";for(var i=0;i<e;i++){var s=Math.floor(Math.random()*charSet.length);t+=charSet.substring(s,s+1)}return t};BX.PhoneCallView.prototype.setTitle=function(e){this.title=e;if(this.isDesktop()){if(this.slave){BXDesktopWindow.SetProperty("title",e)}else{BX.desktop.onCustomEvent(o.setTitle,[e])}}if(this.elements.title){this.elements.title.innerHTML=this.renderTitle()}};BX.PhoneCallView.prototype.getTitle=function(){return this.title};BX.PhoneCallView.prototype.setQuality=function(e){this.quality=e;if(this.elements.qualityMeter)this.elements.qualityMeter.style.width=this.getQualityMeterWidth()};BX.PhoneCallView.prototype.getQualityMeterWidth=function(){if(this.quality>0&&this.quality<=5)return this.quality*20+"%";else return"0"};BX.PhoneCallView.prototype.setProgress=function(e){this.progress=e;if(!this.elements.progress)return;BX.cleanNode(this.elements.progress);this.elements.progress.appendChild(this.renderProgress())};BX.PhoneCallView.prototype.setStatusText=function(e){if(this.isDesktop()&&!this.slave){BX.desktop.onCustomEvent(o.setStatus,[e]);return}this.statusText=e;if(this.elements.status)this.elements.status.innerText=this.statusText};BX.PhoneCallView.prototype.setConfig=function(e){if(!BX.type.isPlainObject(e))return;this.config=e;if(!this.isDesktop()||this.slave){this.renderCrmButtons()}this.setOnSlave(o.setConfig,[e])};BX.PhoneCallView.prototype.setCallId=function(e){this.callId=e;this.setOnSlave(o.setCallId,[e])};BX.PhoneCallView.prototype.setLineNumber=function(e){this.lineNumber=e;this.setOnSlave(o.setCallId,[e])};BX.PhoneCallView.prototype.setCompanyPhoneNumber=function(e){this.companyPhoneNumber=e;this.setOnSlave(o.setCompanyPhoneNumber,[e])};BX.PhoneCallView.prototype.setButtons=function(e,t){if(!BX.PhoneCallView.ButtonLayouts[t])t=BX.PhoneCallView.ButtonLayouts.centered;this.buttonLayout=t;this.buttons=e;this.renderButtons()};BX.PhoneCallView.prototype.setUiState=function(e){this._uiState=e;var t=this.getUiStateButtons(e);this.buttons=t.buttons;this.buttonLayout=t.layout;switch(e){case BX.PhoneCallView.UiState.incoming:this.setClosable(false);this.showOnlySections(["status"]);this.renderCrmButtons();this.stopTimer();break;case BX.PhoneCallView.UiState.transferIncoming:this.setClosable(false);this.showOnlySections(["status"]);this.renderCrmButtons();this.stopTimer();break;case BX.PhoneCallView.UiState.outgoing:this.setClosable(true);this.showOnlySections(["status"]);this.renderCrmButtons();this.stopTimer();this.hideCallIcon();break;case BX.PhoneCallView.UiState.connectingIncoming:this.setClosable(false);this.showOnlySections(["status"]);this.renderCrmButtons();this.stopTimer();break;case BX.PhoneCallView.UiState.connectingOutgoing:this.setClosable(false);this.showOnlySections(["status"]);this.renderCrmButtons();this.showCallIcon();this.stopTimer();break;case BX.PhoneCallView.UiState.connected:if(this.deviceCall)this.setClosable(true);else this.setClosable(false);this.showSections(["status","timer"]);this.renderCrmButtons();this.showCallIcon();this.startTimer();break;case BX.PhoneCallView.UiState.transferring:this.setClosable(false);this.showSections(["status","timer"]);this.renderCrmButtons();break;case BX.PhoneCallView.UiState.idle:this.setClosable(true);this.stopTimer();this.hideCallIcon();this.showOnlySections(["status"]);this.renderCrmButtons();break;case BX.PhoneCallView.UiState.error:this.setClosable(true);this.stopTimer();this.hideCallIcon();break;case BX.PhoneCallView.UiState.moneyError:this.setClosable(true);this.stopTimer();this.hideCallIcon();break;case BX.PhoneCallView.UiState.sipPhoneError:this.setClosable(true);this.stopTimer();this.hideCallIcon();break;case BX.PhoneCallView.UiState.redial:this.setClosable(true);this.stopTimer();this.hideCallIcon();break}if(this.isDesktop()&&!this.slave){BX.desktop.onCustomEvent(o.setUiState,[e]);return}this.renderButtons()};BX.PhoneCallView.prototype.setCallState=function(e,t){if(this.callState===e)return;this.callState=e;if(!BX.type.isPlainObject(t))t={};if(e===BX.PhoneCallView.CallState.connected&&this.isAutoFoldAllowed()){this.fold()}else{this.renderButtons()}BX.onCustomEvent(window,"CallCard::CallStateChanged",[e,t]);this.setOnSlave(o.setCallState,[e,t])};BX.PhoneCallView.prototype.isAutoFoldAllowed=function(){return this.autoFold===true&&!this.isDesktop()&&!this.isFolded()&&l.restApps.length==0};BX.PhoneCallView.prototype.isHeld=function(){return this.held};BX.PhoneCallView.prototype.setHeld=function(e){this.held=e};BX.PhoneCallView.prototype.setRecording=function(e){this.recording=e};BX.PhoneCallView.prototype.isRecording=function(){return this.recording};BX.PhoneCallView.prototype.isMuted=function(){return this.muted};BX.PhoneCallView.prototype.setMuted=function(e){this.muted=e};BX.PhoneCallView.prototype.isTransfer=function(){return this.direction===BX.PhoneCallView.Direction.incomingTransfer};BX.PhoneCallView.prototype.isCallback=function(){return this.direction===BX.PhoneCallView.Direction.callback};BX.PhoneCallView.prototype.isPortalCall=function(){return this.portalCall};BX.PhoneCallView.prototype.setCallback=function(t,i){if(!this.callbacks.hasOwnProperty(t))return false;this.callbacks[t]=BX.type.isFunction(i)?i:e};BX.PhoneCallView.prototype.setDeviceCall=function(e){this.deviceCall=e;if(this.elements.buttons.sipPhone){if(e)BX.addClass(this.elements.buttons.sipPhone,"active");else BX.removeClass(this.elements.buttons.sipPhone,"active")}if(this.isDesktop()&&!this.slave){BX.desktop.onCustomEvent(o.setDeviceCall,[e])}};BX.PhoneCallView.prototype.setCrmEntity=function(e){this.crmEntityType=e.type;this.crmEntityId=e.id;this.crmActivityId=e.activityId||"";this.crmActivityEditUrl=e.activityEditUrl||"";if(this.isDesktop()&&!this.slave){BX.desktop.onCustomEvent(o.setCrmEntity,[e])}};BX.PhoneCallView.prototype.setCrmData=function(e){if(!BX.type.isPlainObject(e))return;this.crm=true;this.crmData=e};BX.PhoneCallView.prototype.loadCrmCard=function(e,i,s,n){var o=3;s=parseInt(s)||0;n=n===true;if(!n){BX.onCustomEvent(window,"CallCard::EntityChanged",[{CRM_ENTITY_TYPE:e,CRM_ENTITY_ID:i,PHONE_NUMBER:this.phoneNumber}])}var l=this;var a={sessid:BX.bitrix_sessid(),COMMAND:"getCrmCard",IM_PHONE:"Y",IM_AJAX_CALL:"Y",PARAMS:{ENTITY_TYPE:e,ENTITY_ID:i}};BX.ajax({url:this.BXIM.pathToCallAjax+"?CALL_CRM_CARD&V="+this.BXIM.revision,method:"POST",datatype:"html",data:a,onsuccess:function(n){var a;try{if(n[0]==="{"){a=JSON.parse(n)}else{a={}}}catch(e){a={}}if(a.ERROR==="SESSION_ERROR"&&a.BITRIX_SESSID&&s<=o){BX.message({bitrix_sessid:a.BITRIX_SESSID});setTimeout(function(){this.loadCrmCard(e,i,s+1,true)}.bind(this),50);return}else if(a.ERROR=="AUTHORIZE_ERROR"&&this.isDesktop()&&s<=o){setTimeout(function(){this.loadCrmCard(e,i,s+1,true)}.bind(this),5e3);BX.onCustomEvent(window,"onImError",[a.ERROR]);return}if(l.currentLayout==t.simple){l.currentLayout=t.crm;l.crm=true;var r=l.createLayoutCrm();l.elements.main.parentNode.replaceChild(r,l.elements.main);l.elements.main=r;l.setUiState(l._uiState);l.setStatusText(l.statusText)}if(l.elements.crmCard){l.elements.crmCard.innerHTML=n;setTimeout(function(){if(l.isDesktop()){l.resizeWindow(l.getInitialWidth(),l.getInitialHeight())}l.adjust();l.bindCrmCardEvents()},100)}l.renderCrmButtons()}})};BX.PhoneCallView.prototype.reloadCrmCard=function(){if(this.isDesktop()&&!this.slave){BX.desktop.onCustomEvent(o.reloadCrmCard,[])}else{this.loadCrmCard(this.crmEntityType,this.crmEntityId)}};BX.PhoneCallView.prototype.bindCrmCardEvents=function(){var e=this;if(!this.elements.crmCard)return;if(!BX.Crm||!BX.Crm.Page)return;var t=this.elements.crmCard.querySelectorAll("a[data-use-slider=Y]");for(var i=0;i<t.length;i++){BX.bind(t[i],"click",function(t){if(BX.Crm.Page.isSliderEnabled(t.currentTarget.href)){if(!e.isFolded()){e.fold()}}})}};BX.PhoneCallView.prototype.setPortalCallUserId=function(e){this.portalCallUserId=e;this.setOnSlave(o.setPortalCallUserId,[e]);if(this.portalCallData&&this.portalCallData.users[this.portalCallUserId]){this.renderAvatar();if(!this.slave){this.setTitle(BX.message("IM_M_CALL_VOICE_TO").replace("#USER#",this.portalCallData.users[this.portalCallUserId].name))}}};BX.PhoneCallView.prototype.setPortalCall=function(e){this.portalCall=e==true;this.setOnSlave(o.setPortalCall,[e])};BX.PhoneCallView.prototype.setPortalCallData=function(e){this.portalCallData=e;this.setOnSlave(o.setPortalCallData,[e])};BX.PhoneCallView.prototype.setOnSlave=function(e,t){if(this.isDesktop()&&!this.slave){BX.desktop.onCustomEvent(e,t)}};BX.PhoneCallView.prototype.updateView=function(){if(this.elements.title)this.elements.title.innerHTML=this.renderTitle();if(this.elements.progress){BX.cleanNode(this.elements.progress);this.elements.progress.appendChild(this.renderProgress())}if(this.elements.status)this.elements.status.innerText=this.statusText;this.renderButtons();this.renderTimer()};BX.PhoneCallView.prototype.renderProgress=function(){var e;var t=this.progress;if(t=="connect"){e=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(t=="online"){e=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(t=="wait"||t=="offline"||t=="error"){if(t=="offline"){this.BXIM.playSound("error")}else if(t=="error"){t="offline"}e=BX.create("div",{props:{className:"bx-messenger-call-overlay-progress bx-messenger-call-overlay-progress-"+t}})}else{e=BX.create("div",{props:{className:"bx-messenger-call-overlay-progress bx-messenger-call-overlay-progress-"+t}})}return e};BX.PhoneCallView.prototype.getUiStateButtons=function(e){var t={buttons:[],layout:BX.PhoneCallView.ButtonLayouts.centered};switch(e){case BX.PhoneCallView.UiState.incoming:t.buttons=["answer","skip"];break;case BX.PhoneCallView.UiState.transferIncoming:t.buttons=["answer","skip"];break;case BX.PhoneCallView.UiState.outgoing:t.buttons=["call"];if(this.callListId>0){t.buttons.push("next");t.buttons.push("fold");if(!this.isDesktop())t.buttons.push("topClose")}break;case BX.PhoneCallView.UiState.connectingIncoming:t.buttons=["hangup"];break;case BX.PhoneCallView.UiState.connectingOutgoing:if(this.hasSipPhone){t.buttons.push("sipPhone")}t.buttons.push("hangup");break;case BX.PhoneCallView.UiState.error:if(this.callListId>0){t.buttons=["redial","next","topClose"]}else{t.buttons.push("close")}break;case BX.PhoneCallView.UiState.moneyError:t.buttons=["notifyAdmin","close"];break;case BX.PhoneCallView.UiState.sipPhoneError:t.buttons=["sipPhone","close"];break;case BX.PhoneCallView.UiState.connected:t.buttons=["hold","mute","qualityMeter","fold"];if(!this.callListId)t.buttons.push("transfer");if(this.deviceCall){t.buttons.push("close")}else{t.buttons.push("dialpad");t.buttons.push("hangup")}t.layout=BX.PhoneCallView.ButtonLayouts.spaced;break;case BX.PhoneCallView.UiState.transferring:t.buttons=["transferCancel"];break;case BX.PhoneCallView.UiState.idle:if(this.hasSipPhone)t.buttons=["close"];else if(this.direction==BX.PhoneCallView.Direction.incoming)t.buttons=["close"];else if(this.direction==BX.PhoneCallView.Direction.outgoing){t.buttons=["redial"];if(this.callListId>0){t.buttons.push("next");t.buttons.push("fold")}else{t.buttons.push("close")}}if(this.callListId>0&&!this.isDesktop()){t.buttons.push("topClose")}break;case BX.PhoneCallView.UiState.redial:t.buttons=["redial"];break;case BX.PhoneCallView.UiState.externalCard:t.buttons=["close"];t.buttons.push("fold");break}return t};BX.PhoneCallView.prototype.renderButtons=function(){if(this.isFolded()){this.renderButtonsFolded()}else{this.renderButtonsDefault()}};BX.PhoneCallView.prototype.renderButtonsDefault=function(){var e=this;var t=document.createDocumentFragment();var i=document.createDocumentFragment();var s=document.createDocumentFragment();var n;var o={left:null,right:null};this.elements.buttons={};if(this.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced){o.left=BX.create("div",{props:{className:"im-phone-call-buttons-container-left"}});o.right=BX.create("div",{props:{className:"im-phone-call-buttons-container-right"}});t.appendChild(o.left);t.appendChild(o.right)}this.buttons.forEach(function(l){switch(l){case"hold":n=e._renderSimpleButton("","im-phone-call-btn-hold",e._onHoldButtonClickHandler);if(e.isHeld())BX.addClass(n,"active");if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)o.left.appendChild(n);else t.appendChild(n);break;case"mute":n=e._renderSimpleButton("","im-phone-call-btn-mute",e._onMuteButtonClickHandler);if(e.isMuted())BX.addClass(n,"active");if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)o.left.appendChild(n);else t.appendChild(n);break;case"transfer":n=e._renderSimpleButton("","im-phone-call-btn-transfer",e._onTransferButtonClickHandler);if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)o.left.appendChild(n);else t.appendChild(n);break;case"transferCancel":n=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_RETURN"),"im-phone-call-btn im-phone-call-btn-blue im-phone-call-btn-arrow",e._onTransferCancelButtonClickHandler);t.appendChild(n);break;case"dialpad":n=e._renderSimpleButton("","im-phone-call-btn-dialpad",e._onDialpadButtonClickHandler);if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)o.left.appendChild(n);else t.appendChild(n);break;case"call":n=e._renderSimpleButton(BX.message("IM_PHONE_CALL"),"im-phone-call-btn im-phone-call-btn-green",e._onMakeCallButtonClickHandler);t.appendChild(n);break;case"answer":n=e._renderSimpleButton(BX.message("IM_PHONE_BTN_ANSWER"),"im-phone-call-btn im-phone-call-btn-green",e._onAnswerButtonClickHandler);t.appendChild(n);break;case"skip":n=e._renderSimpleButton(BX.message("IM_PHONE_BTN_BUSY"),"im-phone-call-btn im-phone-call-btn-red",e._onSkipButtonClickHandler);t.appendChild(n);break;case"hangup":n=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_HANGUP"),"im-phone-call-btn im-phone-call-btn-red  im-phone-call-btn-tube",e._onHangupButtonClickHandler);if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)o.right.appendChild(n);else t.appendChild(n);break;case"close":n=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_CLOSE"),"im-phone-call-btn im-phone-call-btn-red",e._onCloseButtonClickHandler);if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)o.right.appendChild(n);else t.appendChild(n);break;case"topClose":if(!e.isDesktop()){n=BX.create("div",{props:{className:"im-phone-call-top-close-btn"},events:{click:e._onCloseButtonClickHandler}});s.appendChild(n)}break;case"notifyAdmin":n=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_NOTIFY_ADMIN"),"im-phone-call-btn im-phone-call-btn-blue im-phone-call-btn-arrow",function(){e.callbacks.notifyAdmin()});t.appendChild(n);break;case"sipPhone":n=e._renderSimpleButton("",e.deviceCall?"im-phone-call-btn-phone active":"im-phone-call-btn-phone",e._onSwitchDeviceButtonClickHandler);if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)o.left.appendChild(n);else t.appendChild(n);break;case"qualityMeter":n=BX.create("span",{props:{className:"im-phone-call-btn-signal"},events:{click:e._onQualityMeterClickHandler},children:[BX.create("span",{props:{className:"im-phone-call-btn-signal-icon-container"},children:[BX.create("span",{props:{className:"im-phone-call-btn-signal-background"}}),e.elements.qualityMeter=BX.create("span",{props:{className:"im-phone-call-btn-signal-active"},style:{width:e.getQualityMeterWidth()}})]})]});t.appendChild(n);break;case"settings":break;case"next":n=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_NEXT"),"im-phone-call-btn im-phone-call-btn-gray im-phone-call-btn-arrow",e._onNextButtonClickHandler);t.appendChild(n);break;case"redial":n=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_RECALL"),"im-phone-call-btn im-phone-call-btn-green",e._onMakeCallButtonClickHandler);t.appendChild(n);break;case"fold":if(!e.isDesktop()&&e.canBeFolded()){n=BX.create("div",{props:{className:"im-phone-btn-arrow"},text:BX.message("IM_PHONE_CALL_VIEW_FOLD"),events:{click:e._onFoldButtonClickHandler}});i.appendChild(n)}break;default:throw"Unknown button "+l}if(n){e.elements.buttons[l]=n}});if(this.elements.buttonsContainer){BX.cleanNode(this.elements.buttonsContainer);this.elements.buttonsContainer.appendChild(t)}if(this.elements.topButtonsContainer){BX.cleanNode(this.elements.topButtonsContainer);this.elements.topButtonsContainer.appendChild(i)}if(this.elements.topLevelButtonsContainer){BX.cleanNode(this.elements.topLevelButtonsContainer);this.elements.topLevelButtonsContainer.appendChild(s)}};BX.PhoneCallView.prototype.renderButtonsFolded=function(){var e=this;var t=document.createDocumentFragment();this.elements.buttons={};this.buttons.forEach(function(i){switch(i){case"hangup":buttonNode=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_HANGUP"),"im-phone-call-panel-mini-cancel",e._onHangupButtonClickHandler);t.appendChild(buttonNode);break;case"close":buttonNode=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_CLOSE"),"im-phone-call-panel-mini-cancel",e._onCloseButtonClickHandler);t.appendChild(buttonNode);break}});if(this.elements.buttonsContainer){BX.cleanNode(this.elements.buttonsContainer);this.elements.buttonsContainer.appendChild(t)}};BX.PhoneCallView.prototype.renderCrmButtons=function(){var e=this;var t;var i=document.createDocumentFragment();this.elements.crmButtons={};if(!this.elements.crmButtonsContainer)return;t=["addComment"];if(this.crmEntityType=="CONTACT"){t.push("addDeal");t.push("addInvoice")}else if(this.crmEntityType=="COMPANY"){t.push("addDeal");t.push("addInvoice")}else if(!this.crmEntityType&&this.config.CRM_CREATE=="none"){t.push("addLead");t.push("addContact")}if(t.length>0){t.forEach(function(t){var s;switch(t){case"addComment":s=BX.create("div",{props:{className:"im-phone-call-crm-button im-phone-call-crm-button-comment"+(e.commentShown?" im-phone-call-crm-button-active":"")},children:[e.elements.crmButtons.addCommentLabel=BX.create("div",{props:{className:"im-phone-call-crm-button-item"},text:e.commentShown?BX.message("IM_PHONE_CALL_VIEW_SAVE"):BX.message("IM_PHONE_ACTION_CRM_COMMENT")})],events:{click:e._onAddCommentButtonClick.bind(e)}});break;case"addDeal":s=BX.create("div",{props:{className:"im-phone-call-crm-button"},children:[BX.create("div",{props:{className:"im-phone-call-crm-button-item"},text:BX.message("IM_PHONE_ACTION_CRM_DEAL")})],events:{click:e._onAddDealButtonClick.bind(e)}});break;case"addInvoice":s=BX.create("div",{props:{className:"im-phone-call-crm-button"},children:[BX.create("div",{props:{className:"im-phone-call-crm-button-item"},text:BX.message("IM_PHONE_ACTION_CRM_INVOICE")})],events:{click:e._onAddInvoiceButtonClick.bind(e)}});break;case"addLead":s=BX.create("div",{props:{className:"im-phone-call-crm-button"},children:[BX.create("div",{props:{className:"im-phone-call-crm-button-item"},text:BX.message("IM_CRM_BTN_NEW_LEAD")})],events:{click:e._onAddLeadButtonClick.bind(e)}});break;case"addContact":s=BX.create("div",{props:{className:"im-phone-call-crm-button"},children:[BX.create("div",{props:{className:"im-phone-call-crm-button-item"},text:BX.message("IM_CRM_BTN_NEW_CONTACT")})],events:{click:e._onAddContactButtonClick.bind(e)}});break}if(s){i.appendChild(s);e.elements.crmButtons[t]=s}});BX.cleanNode(this.elements.crmButtonsContainer);this.elements.crmButtonsContainer.appendChild(i);this.showSections(["crmButtons"])}else{BX.cleanNode(this.elements.crmButtonsContainer);this.hideSections(["crmButtons"])}};BX.PhoneCallView.prototype._renderSimpleButton=function(e,t,i){var s={};if(e!="")s.text=e;if(t!="")s.props={className:t};if(BX.type.isFunction(i))s.events={click:i};return BX.create("span",s)};BX.PhoneCallView.prototype.loadForm=function(e){if(!this.formManager)return;this.formManager.load({id:e.id,secCode:e.secCode})};BX.PhoneCallView.prototype.unloadForm=function(){if(!this.formManager)return;this.formManager.unload();BX.cleanNode(this.elements.tabsBody.webform)};BX.PhoneCallView.prototype._onFormSend=function(e){if(!this.callListView)return;var t=this.callListView.getCurrentElement();this.callListView.setWebformResult(t.ELEMENT_ID,e.resultId)};BX.PhoneCallView.prototype.loadRestApp=function(e){var t=this;var i=e.id;var s=e.callId;var n=e.node;if(this.restAppLayoutLoaded){BX.rest.AppLayout.getPlacement("CALL_CARD").load(i,this.getPlacementOptions());return}if(this.restAppLayoutLoading){return}this.restAppLayoutLoading=true;var o={sessid:BX.bitrix_sessid(),REST_APP_ID:i,PLACEMENT_OPTIONS:this.getPlacementOptions()};BX.ajax({url:"/bitrix/tools/voximplant/rest_app.php",method:"POST",dataType:"html",data:o,onsuccess:function(e){n.innerHTML=e;t.restAppLayoutLoaded=true;t.restAppLayoutLoading=false;t.restAppInterface=BX.rest.AppLayout.initializePlacement("CALL_CARD");t.initializeAppInterface(t.restAppInterface)}})};BX.PhoneCallView.prototype.unloadRestApps=function(){var e=BX.rest.AppLayout.getPlacement("CALL_CARD");if(this.restAppLayoutLoaded&&e){e.destroy();this.restAppLayoutLoaded=false}};BX.PhoneCallView.prototype.initializeAppInterface=function(e){e.prototype.events.push("CallCard::EntityChanged");e.prototype.events.push("CallCard::BeforeClose");e.prototype.events.push("CallCard::CallStateChanged");e.prototype.getStatus=function(e,t){t(this.getPlacementOptions())}.bind(this);e.prototype.disableAutoClose=function(e,t){this.disableAutoClose();t([])}.bind(this);e.prototype.enableAutoClose=function(e,t){this.enableAutoClose();t([])}.bind(this)};BX.PhoneCallView.prototype.getPlacementOptions=function(){return{CALL_ID:this.callId,PHONE_NUMBER:this.phoneNumber==="unknown"?undefined:this.phoneNumber,LINE_NUMBER:this.lineNumber,LINE_NAME:this.companyPhoneNumber,CRM_ENTITY_TYPE:this.crmEntityType,CRM_ENTITY_ID:this.crmEntityId,CRM_ACTIVITY_ID:this.crmActivityId===0?undefined:this.crmActivityId,CALL_DIRECTION:this.direction,CALL_STATE:this.callState,CALL_LIST_MODE:this.callListId>0}};BX.PhoneCallView.prototype.isUnloadAllowed=function(){return this.folded&&(this.deviceCall||this._uiState===BX.PhoneCallView.UiState.idle||this._uiState===BX.PhoneCallView.UiState.error||this._uiState===BX.PhoneCallView.UiState.externalCard)};BX.PhoneCallView.prototype._onBeforeUnload=function(e){if(!this.isUnloadAllowed()){e.returnValue=BX.message("IM_PHONE_CALL_VIEW_DONT_LEAVE");return BX.message("IM_PHONE_CALL_VIEW_DONT_LEAVE")}};BX.PhoneCallView.prototype._onDblClick=function(e){BX.PreventDefault(e);if(!this.isFolded()&&this.canBeFolded())this.fold()};BX.PhoneCallView.prototype._onHoldButtonClick=function(e){if(this.isHeld()){this.held=false;BX.removeClass(this.elements.buttons.hold,"active");if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onUnHold,[]);else this.callbacks.unhold()}else{this.held=true;BX.addClass(this.elements.buttons.hold,"active");if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onHold,[]);else this.callbacks.hold()}};BX.PhoneCallView.prototype._onMuteButtonClick=function(e){if(this.isMuted()){this.muted=false;BX.removeClass(this.elements.buttons.mute,"active");if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onUnMute,[]);else this.callbacks.unmute()}else{this.muted=true;BX.addClass(this.elements.buttons.mute,"active");if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onMute,[]);else this.callbacks.mute()}};BX.PhoneCallView.prototype._onTransferButtonClick=function(e){var t=this;this.transferPopup=d.create({bindElement:this.elements.buttons.transfer,BXIM:this.BXIM,onSelect:function(e){if(t.isDesktop()&&t.slave)BX.desktop.onCustomEvent(o.onStartTransfer,[e]);else t.callbacks.transfer(e)},onDestroy:function(){t.transferPopup=null}});this.transferPopup.show()};BX.PhoneCallView.prototype._onTransferCancelButtonClick=function(e){if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onCancelTransfer,[]);else this.callbacks.cancelTransfer()};BX.PhoneCallView.prototype._onDialpadButtonClick=function(e){var t=this;this.keypad=new u({bindElement:this.elements.buttons.dialpad,hideDial:true,onButtonClick:function(e){var i=e.key;if(t.isDesktop()&&t.slave)BX.desktop.onCustomEvent(o.onDialpadButtonClicked,[i]);else t.callbacks.dialpadButtonClicked(i)},onClose:function(e){t.keypad.destroy();t.keypad=null}});t.keypad.show()};BX.PhoneCallView.prototype._onHangupButtonClick=function(e){if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onHangup,[]);else this.callbacks.hangup()};BX.PhoneCallView.prototype._onCloseButtonClick=function(e){if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onClose,[]);else this.close()};BX.PhoneCallView.prototype._onMakeCallButtonClick=function(e){var t={};var i=this;if(this.callListId>0){this.callingEntity=this.currentEntity;if(this.currentEntity.phones.length==0){this.keypad=new u({bindElement:this.elements.buttons.call?this.elements.buttons.call:null,onClose:function(){i.keypad.destroy();i.keypad=null},onDial:function(e){i.keypad.close();i.phoneNumber=e.phoneNumber;i.setTitle(i.createTitle());t={phoneNumber:e.phoneNumber,crmEntityType:i.crmEntityType,crmEntityId:i.crmEntityId,callListId:i.callListId};if(i.isDesktop()&&i.slave)BX.desktop.onCustomEvent(o.onCallListMakeCall,[t]);else i.callbacks.callListMakeCall(t)}});this.keypad.show()}else if(this.currentEntity.phones.length==1){t.phoneNumber=this.currentEntity.phones[0].VALUE;t.crmEntityType=this.crmEntityType;t.crmEntityId=this.crmEntityId;t.callListId=this.callListId;if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onCallListMakeCall,[t]);else this.callbacks.callListMakeCall(t)}else{this.showNumberSelectMenu({bindElement:this.elements.buttons.call?this.elements.buttons.call:null,phoneNumbers:this.currentEntity.phones,onSelect:function(e){i.closeNumberSelectMenu();i.phoneNumber=e.phoneNumber;i.setTitle(i.createTitle());t={phoneNumber:e.phoneNumber,crmEntityType:i.crmEntityType,crmEntityId:i.crmEntityId,callListId:i.callListId};if(i.isDesktop()&&i.slave)BX.desktop.onCustomEvent(o.onCallListMakeCall,[t]);else i.callbacks.callListMakeCall(t)}})}}else{if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onMakeCall,[this.phoneNumber]);else this.callbacks.makeCall(this.phoneNumber)}};BX.PhoneCallView.prototype._onNextButtonClick=function(e){if(!this.callListView)return;this.setUiState(BX.PhoneCallView.UiState.outgoing);this.callListView.moveToNextItem();this.setStatusText("")};BX.PhoneCallView.prototype._onRedialButtonClick=function(e){};BX.PhoneCallView.prototype._onCommentChanged=function(e){this.comment=this.elements.commentEditor.value};BX.PhoneCallView.prototype._onAddCommentButtonClick=function(e){this.commentShown=!this.commentShown;if(this.commentShown){if(this.elements.crmButtons.addComment){BX.addClass(this.elements.crmButtons.addComment,"im-phone-call-crm-button-active");this.elements.crmButtons.addCommentLabel.innerText=BX.message("IM_PHONE_CALL_VIEW_SAVE")}if(this.elements.commentEditor)this.elements.commentEditor.focus();if(this.elements.commentEditorContainer)this.elements.commentEditorContainer.style.removeProperty("display")}else{if(this.elements.crmButtons.addComment){BX.removeClass(this.elements.crmButtons.addComment,"im-phone-call-crm-button-active");this.elements.crmButtons.addCommentLabel.innerText=BX.message("IM_PHONE_ACTION_CRM_COMMENT")}if(this.elements.commentEditorContainer)this.elements.commentEditorContainer.style.display="none";if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onSaveComment,[this.comment]);else this.saveComment()}};BX.PhoneCallView.prototype._onAddDealButtonClick=function(e){var t=this._getCrmEditUrl("DEAL",0);var i=this._generateExternalContext();if(this.crmEntityType==="CONTACT")t=BX.util.add_url_param(t,{contact_id:this.crmEntityId});else if(this.crmEntityType==="COMPANY")t=BX.util.add_url_param(t,{company_id:this.crmEntityId});t=BX.util.add_url_param(t,{external_context:i});if(this.callListId>0){t=BX.util.add_url_param(t,{call_list_id:this.callListId});t=BX.util.add_url_param(t,{call_list_element:this.currentEntity.id})}this.externalRequests[i]={type:"add",context:i,window:window.open(t)}};BX.PhoneCallView.prototype._onAddInvoiceButtonClick=function(e){var t=this._getCrmEditUrl("INVOICE",0);var i=this._generateExternalContext();if(this.crmEntityType==="CONTACT")t=BX.util.add_url_param(t,{contact:this.crmEntityId});else if(this.crmEntityType==="COMPANY")t=BX.util.add_url_param(t,{company:this.crmEntityId});t=BX.util.add_url_param(t,{external_context:i});if(this.callListId>0){t=BX.util.add_url_param(t,{call_list_id:this.callListId});t=BX.util.add_url_param(t,{call_list_element:this.currentEntity.id})}this.externalRequests[i]={type:"add",context:i,window:window.open(t)}};BX.PhoneCallView.prototype._onAddLeadButtonClick=function(e){var t=this._getCrmEditUrl("LEAD",0);t=BX.util.add_url_param(t,{phone:this.phoneNumber,origin_id:"VI_"+this.callId});window.open(t)};BX.PhoneCallView.prototype._onAddContactButtonClick=function(e){var t=this._getCrmEditUrl("CONTACT",0);t=BX.util.add_url_param(t,{phone:this.phoneNumber,origin_id:"VI_"+this.callId});window.open(t)};BX.PhoneCallView.prototype._onFoldButtonClick=function(e){this.fold()};BX.PhoneCallView.prototype._onAnswerButtonClick=function(e){if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onAnswer,[]);else this.callbacks.answer()};BX.PhoneCallView.prototype._onSkipButtonClick=function(e){if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onSkip,[]);else this.callbacks.skip()};BX.PhoneCallView.prototype._onSwitchDeviceButtonClick=function(e){if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onSwitchDevice,[{phoneNumber:this.phoneNumber}]);else this.callbacks.switchDevice({phoneNumber:this.phoneNumber})};BX.PhoneCallView.prototype._onQualityMeterClick=function(e){var t=this;this.showQualityPopup({onSelect:function(e){t.qualityGrade=e;t.closeQualityPopup();if(t.isDesktop()&&t.slave)BX.desktop.onCustomEvent(o.onQualityGraded,[e]);else t.callbacks.qualityGraded(e)}})};BX.PhoneCallView.prototype._onExternalEvent=function(e){e=BX.type.isPlainObject(e)?e:{};e.key=e.key||"";var t=e.value||{};t.entityTypeName=t.entityTypeName||"";t.context=t.context||"";t.isCanceled=BX.type.isBoolean(t.isCanceled)?t.isCanceled:false;if(t.isCanceled)return;if(e.key==="onCrmEntityCreate"&&this.externalRequests[t.context]){if(this.externalRequests[t.context]){if(this.externalRequests[t.context]["type"]=="create"){this.crmEntityType=t.entityTypeName;this.crmEntityId=t.entityInfo.id;this.loadCrmCard(this.crmEntityType,this.crmEntityId)}else if(this.externalRequests[t.context]["type"]=="add"){this.loadCrmCard(this.crmEntityType,this.crmEntityId)}if(this.externalRequests[t.context]["window"])this.externalRequests[t.context]["window"].close();delete this.externalRequests[t.context]}}};BX.PhoneCallView.prototype._onPullEventCrm=function(e,t){if(e==="external_event"){if(t.NAME==="onCrmEntityCreate"&&t.IS_CANCELED==false){var i=t.PARAMS;if(this.externalRequests[i.context]){var s=i.entityTypeName;var n=i.entityInfo.id;if(this.callListView){var o=this.callListView.getCurrentElement()}}}}};BX.PhoneCallView.prototype.onCallListSelectedItem=function(e){this.currentEntity=e;this.crmEntityType=e.type;this.crmEntityId=e.id;if(e.phones.length>0)this.phoneNumber=e.phones[0].VALUE;else this.phoneNumber="unknown";this.setTitle(this.createTitle());this.loadCrmCard(e.type,e.id);if(this.currentTabName==="webform"){this.formManager.unload();this.formManager.load({id:this.webformId,secCode:this.webformSecCode})}if(this._uiState===BX.PhoneCallView.UiState.redial)this.setUiState(BX.PhoneCallView.UiState.outgoing);this.updateView()};BX.PhoneCallView.prototype._onWindowUnload=function(){this.close()};BX.PhoneCallView.prototype.showCallIcon=function(){if(!this.callListView)return;if(!this.callingEntity)return;this.callListView.setCallingElement(this.callingEntity.statusId,this.callingEntity.index)};BX.PhoneCallView.prototype.hideCallIcon=function(){if(!this.callListView)return;this.callListView.resetCallingElement()};BX.PhoneCallView.prototype.startTimer=function(){if(this.timerInterval)return;if(this.initialTimestamp===0){this.initialTimestamp=(new Date).getTime()}this.timerInterval=setInterval(this.renderTimer.bind(this),1e3);this.renderTimer()};BX.PhoneCallView.prototype.renderTimer=function(){if(!this.elements.timer)return;var e=(new Date).getTime();var t=e-this.initialTimestamp;var i=Math.floor(t/1e3);var s=Math.floor(i/60).toString();if(s.length<2)s="0"+s;var n=(i%60).toString();if(n.length<2)n="0"+n;var o=this.isRecording()?BX.message("IM_PHONE_TIMER_WITH_RECORD"):BX.message("IM_PHONE_TIMER_WITHOUT_RECORD");if(this.isFolded()){this.elements.timer.innerText=s+":"+n}else{this.elements.timer.innerText=o.replace("#MIN#",s).replace("#SEC#",n)}};BX.PhoneCallView.prototype.stopTimer=function(){if(!this.timerInterval)return;clearInterval(this.timerInterval);this.timerInterval=null};BX.PhoneCallView.prototype.showQualityPopup=function(e){if(!BX.type.isPlainObject(e))e={};if(!BX.type.isFunction(e.onSelect))e.onSelect=BX.DoNothing;var t=this;var i={1:null,2:null,3:null,4:null,5:null};var s=function(i){return BX.create("div",{props:{className:"im-phone-popup-rating-stars-item "+(t.qualityGrade==i?"im-phone-popup-rating-stars-item-active":"")},dataset:{grade:i},events:{click:function(t){BX.PreventDefault(t);var i=t.currentTarget.dataset.grade;e.onSelect(i)}}})};this.qualityPopup=new BX.PopupWindow("PhoneCallViewQualityGrade",this.elements.qualityMeter,{darkMode:true,closeByEsc:true,autoHide:true,zIndex:n+200,noAllPaddings:true,overlay:{backgroundColor:"white",opacity:0},bindOptions:{position:"top"},angle:{position:"bottom",offset:30},content:BX.create("div",{props:{className:"im-phone-popup-rating"},children:[BX.create("div",{props:{className:"im-phone-popup-rating-title"},text:BX.message("IM_PHONE_CALL_VIEW_RATE_QUALITY")}),BX.create("div",{props:{className:"im-phone-popup-rating-stars"},children:[i["1"]=s(1),i["2"]=s(2),i["3"]=s(3),i["4"]=s(4),i["5"]=s(5)],events:{mouseover:function(){if(i[t.qualityGrade])BX.removeClass(i[t.qualityGrade],"im-phone-popup-rating-stars-item-active")},mouseout:function(){if(i[t.qualityGrade])BX.addClass(i[t.qualityGrade],"im-phone-popup-rating-stars-item-active")}}})]}),events:{onPopupClose:function(){this.destroy()},onPopupDestroy:function(){t.qualityPopup=null}}});this.qualityPopup.show()};BX.PhoneCallView.prototype.closeQualityPopup=function(){if(this.qualityPopup)this.qualityPopup.close()};BX.PhoneCallView.prototype.saveComment=function(){BX.MessengerCommon.phoneCommand("saveComment",{CALL_ID:this.callId,COMMENT:this.comment})};BX.PhoneCallView.prototype.showNumberSelectMenu=function(e){var t=this;var i=[];if(!BX.type.isPlainObject(e))e={};if(!BX.type.isArray(e.phoneNumbers))return;e.onSelect=BX.type.isFunction(e.onSelect)?e.onSelect:BX.DoNothing;e.phoneNumbers.forEach(function(t){i.push({id:"number-select-"+BX.util.getRandomString(10),text:t.VALUE,onclick:function(){e.onSelect({phoneNumber:t.VALUE})}})});this.numberSelectMenu=BX.PopupMenu.create("im-phone-call-view-number-select",e.bindElement,i,{autoHide:true,offsetTop:0,offsetLeft:40,angle:{position:"top"},zIndex:n+200,closeByEsc:true,overlay:{backgroundColor:"white",opacity:0},events:{onPopupClose:function(){t.numberSelectMenu.popupWindow.destroy();BX.PopupMenu.destroy("im-phone-call-view-number-select")},onPopupDestroy:function(){t.numberSelectMenu=null}}});this.numberSelectMenu.popupWindow.show()};BX.PhoneCallView.prototype.closeNumberSelectMenu=function(){if(this.numberSelectMenu)this.numberSelectMenu.popupWindow.close()};BX.PhoneCallView.prototype.fold=function(){if(!this.canBeFolded())return false;if(this.callListId>0&&this.callState===BX.PhoneCallView.CallState.idle){this.foldCallView()}else{this.foldCall()}};BX.PhoneCallView.prototype.unfold=function(){if(!this.isDesktop()&&this.isFolded()){BX.cleanNode(this.elements.main,true);this.folded=false;this.elements=this.unfoldedElements;this.show()}};BX.PhoneCallView.prototype.foldCall=function(){if(this.isDesktop()||!this.popup)return;var e=this;var t=this.popup.popupContainer;var i=this.popup.overlay.element;BX.addClass(t,"im-phone-call-view-folding");BX.addClass(i,"popup-window-overlay-im-phone-call-view-folding");setTimeout(function(){e.folded=true;e.popup.close();e.unfoldedElements=e.elements;BX.removeClass(t,"im-phone-call-view-folding");BX.removeClass(i,"popup-window-overlay-im-phone-call-view-folding");e.reinit();e.enableDocumentScroll()},300)};BX.PhoneCallView.prototype.foldCallView=function(){var e=this;var t=BX.FoldedCallView.getInstance();var i=this.popup.popupContainer;var s=this.popup.overlay.element;BX.addClass(i,"im-phone-call-view-folding");BX.addClass(s,"popup-window-overlay-im-phone-call-view-folding");setTimeout(function(){e.close();t.fold({callListId:e.callListId,webformId:e.webformId,webformSecCode:e.webformSecCode,currentItemIndex:e.callListView.currentItemIndex,currentItemStatusId:e.callListView.currentStatusId,statusList:e.callListView.statuses,entityType:e.callListView.entityType},true)},300)};BX.PhoneCallView.prototype.bindSlaveDesktopEvents=function(){var e=this;BX.desktop.addCustomEvent(o.setTitle,this.setTitle.bind(this));BX.desktop.addCustomEvent(o.setStatus,this.setStatusText.bind(this));BX.desktop.addCustomEvent(o.setUiState,this.setUiState.bind(this));BX.desktop.addCustomEvent(o.setDeviceCall,this.setDeviceCall.bind(this));BX.desktop.addCustomEvent(o.setCrmEntity,this.setCrmEntity.bind(this));BX.desktop.addCustomEvent(o.reloadCrmCard,this.reloadCrmCard.bind(this));BX.desktop.addCustomEvent(o.setPortalCall,this.setPortalCall.bind(this));BX.desktop.addCustomEvent(o.setPortalCallUserId,this.setPortalCallUserId.bind(this));BX.desktop.addCustomEvent(o.setPortalCallData,this.setPortalCallData.bind(this));BX.desktop.addCustomEvent(o.setConfig,this.setConfig.bind(this));BX.desktop.addCustomEvent(o.setCallId,this.setCallId.bind(this));BX.desktop.addCustomEvent(o.setLineNumber,this.setLineNumber.bind(this));BX.desktop.addCustomEvent(o.setCompanyPhoneNumber,this.setCompanyPhoneNumber.bind(this));BX.desktop.addCustomEvent(o.setCallState,this.setCallState.bind(this));BX.desktop.addCustomEvent(o.closeWindow,function(){window.close()});BX.bind(window,"beforeunload",function(){BX.unbindAll(window,"beforeunload");BX.desktop.onCustomEvent(o.onBeforeUnload,[])});BX.bind(window,"resize",BX.debounce(function(t){if(e.skipOnResize){e.skipOnResize=false;return}e.saveInitialSize(window.innerWidth,window.innerHeight)},100,this));BX.addCustomEvent("SidePanel.Slider:onOpen",function(e){if(!e.getSlider().isSelfContained()){e.denyAction();window.open(e.slider.url)}})};BX.PhoneCallView.prototype.bindMasterDesktopEvents=function(){var e=this;BX.desktop.addCustomEvent(o.onHold,function(){e.callbacks.hold()});BX.desktop.addCustomEvent(o.onUnHold,function(){e.callbacks.unhold()});BX.desktop.addCustomEvent(o.onMute,function(){e.callbacks.mute()});BX.desktop.addCustomEvent(o.onUnMute,function(){e.callbacks.unmute()});BX.desktop.addCustomEvent(o.onMakeCall,function(t){e.callbacks.makeCall(t)});BX.desktop.addCustomEvent(o.onCallListMakeCall,function(t){e.callbacks.callListMakeCall(t)});BX.desktop.addCustomEvent(o.onAnswer,function(){e.callbacks.answer()});BX.desktop.addCustomEvent(o.onSkip,function(){e.callbacks.skip()});BX.desktop.addCustomEvent(o.onHangup,function(){e.callbacks.hangup()});BX.desktop.addCustomEvent(o.onClose,function(){e.close()});BX.desktop.addCustomEvent(o.onStartTransfer,function(t){e.callbacks.transfer(t)});BX.desktop.addCustomEvent(o.onCancelTransfer,function(){e.callbacks.cancelTransfer()});BX.desktop.addCustomEvent(o.onSwitchDevice,function(t){e.callbacks.switchDevice(t)});BX.desktop.addCustomEvent(o.onBeforeUnload,function(){e.desktop.window=null;e.callbacks.hangup();e.callbacks.close()});BX.desktop.addCustomEvent(o.onQualityGraded,function(t){e.callbacks.qualityGraded(t)});BX.desktop.addCustomEvent(o.onDialpadButtonClicked,function(t){e.callbacks.dialpadButtonClicked(t)});BX.desktop.addCustomEvent(o.onSaveComment,function(t){e.comment=t;e.saveComment()})};BX.PhoneCallView.prototype.unbindDesktopEvents=function(){for(eventId in o){if(o.hasOwnProperty(eventId)){BX.desktop.removeCustomEvents(o[eventId])}}};BX.PhoneCallView.prototype.isDesktop=function(){return BX.MessengerCommon.isDesktop()};BX.PhoneCallView.prototype.isFolded=function(){return this.folded};BX.PhoneCallView.prototype.canBeFolded=function(){return this.allowAutoClose&&(this.callState===BX.PhoneCallView.CallState.connected||this.callState===BX.PhoneCallView.CallState.idle&&this.callListId>0)};BX.PhoneCallView.prototype.getFoldedHeight=function(){if(!this.folded)return 0;if(!this.elements.main)return 0;return this.elements.main.clientHeight+(this.elements.sections.status?this.elements.sections.status.clientHeight:0)};BX.PhoneCallView.prototype.isWebformSupported=function(){return!this.isDesktop()||this.desktop.isFeatureSupported("iframe")};BX.PhoneCallView.prototype.isRestAppsSupported=function(){return!this.isDesktop()||this.desktop.isFeatureSupported("iframe")};BX.PhoneCallView.prototype.setClosable=function(e){e=e==true;this.closable=e;if(this.isDesktop()){}else if(this.popup){this.popup.setClosingByEsc(e)}};BX.PhoneCallView.prototype.isClosable=function(){return this.closable};BX.PhoneCallView.prototype.adjust=function(){if(this.popup){this.popup.adjustPosition()}if(this.isDesktop()&&this.slave){if(this.currentLayout==t.simple){this.desktop.setResizable(false)}else{this.desktop.setResizable(true);this.desktop.setMinSize(this.elements.sidebarContainer?900:550,650)}this.desktop.center()}};BX.PhoneCallView.prototype.resizeWindow=function(e,t){if(!this.isDesktop()||!this.slave)return false;this.skipOnResize=true;this.desktop.resize(e,t)};BX.PhoneCallView.prototype.close=function(){BX.onCustomEvent(window,"CallCard::BeforeClose",[]);if(this.isFolded()&&this.elements.main){BX.addClass(this.elements.main,"im-phone-call-panel-mini-closing");setTimeout(function(){BX.cleanNode(this.elements.main,true);this.elements=this.getInitialElements()}.bind(this),300)}if(this.popup)this.popup.close();if(this.desktop.window){BX.desktop.onCustomEvent(o.closeWindow,[])}this.enableDocumentScroll();this.callbacks.close();BX.onCustomEvent(window,"CallCard::AfterClose",[])};BX.PhoneCallView.prototype.disableAutoClose=function(){this.allowAutoClose=false;this.renderButtons()};BX.PhoneCallView.prototype.enableAutoClose=function(){this.allowAutoClose=true;this.renderButtons()};BX.PhoneCallView.prototype.autoClose=function(){if(this.allowAutoClose&&!this.commentShown){this.close()}else{BX.onCustomEvent(window,"CallCard::BeforeClose",[])}};BX.PhoneCallView.prototype.disableDocumentScroll=function(){var e=window.innerWidth-document.documentElement.clientWidth;document.body.style.setProperty("padding-right",e+"px");document.body.classList.add("im-phone-call-disable-scroll");var t=BX("bx-im-bar");if(t){t.style.setProperty("right",e+"px")}};BX.PhoneCallView.prototype.enableDocumentScroll=function(){document.body.classList.remove("im-phone-call-disable-scroll");document.body.style.removeProperty("padding-right");var e=BX("bx-im-bar");if(e){e.style.removeProperty("right")}};BX.PhoneCallView.prototype.dispose=function(){window.removeEventListener("beforeunload",this._onBeforeUnloadHandler);BX.removeCustomEvent("onPullEvent-crm",this._onPullEventCrmHandler);this.unloadRestApps();this.unloadForm();if(this.isFolded()&&this.elements.main){BX.addClass(this.elements.main,"im-phone-call-panel-mini-closing");setTimeout(function(){BX.cleanNode(this.elements.main,true)}.bind(this),300)}if(this.popup){this.popup.destroy();this.popup=null}if(this.qualityPopup)this.qualityPopup.close();if(this.transferPopup)this.transferPopup.close();if(this.keypad)this.keypad.close();if(this.numberSelectMenu)this.closeNumberSelectMenu();if(this.isDesktop()){this.unbindDesktopEvents();if(this.desktop.window){BX.desktop.onCustomEvent(o.closeWindow,[]);this.desktop.window=null}if(!this.slave){window.removeEventListener("beforeunload",this._unloadHandler)}}else{window.removeEventListener("beforeunload",this._onBeforeUnloadHandler)}};BX.PhoneCallView.prototype.canBeUnloaded=function(){return this.allowAutoClose&&this.isFolded()};BX.PhoneCallView.prototype.getState=function(){return{callId:this.callId,folded:this.folded,uiState:this._uiState,phoneNumber:this.phoneNumber,companyPhoneNumber:this.companyPhoneNumber,direction:this.direction,fromUserId:this.fromUserId,toUserId:this.toUserId,statusText:this.statusText,crm:this.crm,hasSipPhone:this.hasSipPhone,deviceCall:this.deviceCall,transfer:this.transfer,callback:this.callback,crmEntityType:this.crmEntityType,crmEntityId:this.crmEntityId,crmActivityId:this.crmActivityId,crmActivityEditUrl:this.crmActivityEditUrl,callListId:this.callListId,callListStatusId:this.callListStatusId,callListItemIndex:this.callListItemIndex,config:this.config?this.config:"{}",portalCall:this.portalCall?"true":"false",portalCallData:this.portalCallData?this.portalCallData:"{}",portalCallUserId:this.portalCallUserId,webformId:this.webformId,webformSecCode:this.webformSecCode,initialTimestamp:this.initialTimestamp,crmData:this.crmData}};BX.PhoneCallView.Direction={incoming:"incoming",outgoing:"outgoing",incomingTransfer:"incomingTransfer",callback:"callback"};BX.PhoneCallView.UiState={incoming:1,transferIncoming:2,outgoing:3,connectingIncoming:4,connectingOutgoing:5,connected:6,transferring:7,idle:8,error:9,moneyError:10,sipPhoneError:11,redial:12,externalCard:13};BX.PhoneCallView.CallState={idle:"idle",connecting:"connecting",connected:"connected"};var a={iframe:39};var r=function(e){this.BXIM=e.BXIM;this.parentPhoneCallView=e.parentPhoneCallView;this.closable=e.closable;this.title=e.title||"";this.window=null};r.prototype.openCallWindow=function(e,t,i){if(!BX.MessengerCommon.isDesktop())return false;i=i||{};if(i.minSettingsWidth)this.minSettingsWidth=i.minSettingsWidth;if(i.minSettingsHeight)this.minSettingsHeight=i.minSettingsHeight;i.resizable=i.resizable==true;BX.desktop.createWindow("callWindow",BX.delegate(function(s){s.SetProperty("clientSize",{Width:i.width,Height:i.height});s.SetProperty("resizable",i.resizable);if(i.resizable&&i.hasOwnProperty("minWidth")&&i.hasOwnProperty("minHeight")){s.SetProperty("minClientSize",{Width:i.minWidth,Height:i.minHeight})}s.SetProperty("title",this.title);s.SetProperty("closable",true);s.ExecuteCommand("html.load",this.getHtmlPage(e,t,{}));this.window=s},this))};r.prototype.setClosable=function(e){this.closable=e==true;if(this.window){this.window.SetProperty("closable",this.closable)}};r.prototype.setTitle=function(e){this.title=e;if(this.window)this.window.SetProperty("title",e)};r.prototype.getHtmlPage=function(e,t,i,s){if(!BX.MessengerCommon.isDesktop())return;e=e||"";t=t||"";s=s||"";var n=typeof i=="undefined"||typeof i!="object"?{}:i;i=typeof i!="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 o="";if(i==true){o='<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' : "+(n.files?JSON.stringify(n.files):"{}")+","+"'notify' : "+(n.notify?JSON.stringify(n.notify):"{}")+","+"'users' : "+(n.users?JSON.stringify(n.users):"{}")+","+"'chat' : "+(n.chat?JSON.stringify(n.chat):"{}")+","+"'userChat' : "+(n.userChat?JSON.stringify(n.userChat):"{}")+","+"'userInChat' : "+(n.userInChat?JSON.stringify(n.userInChat):"{}")+","+"'hrphoto' : "+(n.hrphoto?JSON.stringify(n.hrphoto):"{}")+","+"'phoneCrm' : "+(n.phoneCrm?JSON.stringify(n.phoneCrm):"{}")+","+"'generalChatId': "+this.BXIM.messenger.generalChatId+","+"'canSendMessageGeneralChat': "+this.BXIM.messenger.canSendMessageGeneralChat+","+"'userId': "+this.BXIM.userId+","+"'userEmail': '"+this.BXIM.userEmail+"',"+"'userColor': '"+this.BXIM.userColor+"',"+"'userGender': '"+this.BXIM.userGender+"',"+"'userExtranet': "+this.BXIM.userExtranet+","+"'disk': {'enable': "+(this.disk?this.disk.enable:false)+"},"+"'path' : "+JSON.stringify(this.BXIM.path)+"});"+"BXIM.messenger.contactListLoad = false;"+"BX.PhoneCallView.setDefaults("+JSON.stringify(l)+");"+"PCW = new BX.PhoneCallView({"+"'slave': true, "+"'skipOnResize': true, "+"'callId': '"+this.parentPhoneCallView.callId+"',"+"'uiState': "+this.parentPhoneCallView._uiState+","+"'phoneNumber': '"+this.parentPhoneCallView.phoneNumber+"',"+"'companyPhoneNumber': '"+this.parentPhoneCallView.companyPhoneNumber+"',"+"'direction': '"+this.parentPhoneCallView.direction+"',"+"'fromUserId': '"+this.parentPhoneCallView.fromUserId+"',"+"'toUserId': '"+this.parentPhoneCallView.toUserId+"',"+"'crm': "+this.parentPhoneCallView.crm+","+"'hasSipPhone': "+this.parentPhoneCallView.hasSipPhone+","+"'deviceCall': "+this.parentPhoneCallView.deviceCall+","+"'transfer': "+this.parentPhoneCallView.transfer+","+"'callback': "+this.parentPhoneCallView.callback+","+"'crmEntityType': '"+this.parentPhoneCallView.crmEntityType+"',"+"'crmEntityId': '"+this.parentPhoneCallView.crmEntityId+"',"+"'crmActivityId': '"+this.parentPhoneCallView.crmActivityId+"',"+"'crmActivityEditUrl': '"+this.parentPhoneCallView.crmActivityEditUrl+"',"+"'callListId': "+this.parentPhoneCallView.callListId+","+"'callListStatusId': '"+this.parentPhoneCallView.callListStatusId+"',"+"'callListItemIndex': "+this.parentPhoneCallView.callListItemIndex+","+"'config': "+(this.parentPhoneCallView.config?JSON.stringify(this.parentPhoneCallView.config):"{}")+","+"'portalCall': "+(this.parentPhoneCallView.portalCall?"true":"false")+","+"'portalCallData': "+(this.parentPhoneCallView.portalCallData?JSON.stringify(this.parentPhoneCallView.portalCallData):"{}")+","+"'portalCallUserId': "+this.parentPhoneCallView.portalCallUserId+","+"'webformId': "+this.parentPhoneCallView.webformId+","+"'webformSecCode': '"+this.parentPhoneCallView.webformSecCode+"'"+"});"+"});"+"<\/script>"}return"<!DOCTYPE html><html>"+this.htmlWrapperHead+'<body class="im-desktop im-desktop-popup '+s+'"><div id="placeholder-messanger">'+e+"</div>"+o+t+"</body></html>"};r.prototype.addCustomEvent=function(e,t){if(!BX.MessengerCommon.isDesktop())return false;BX.desktop.addCustomEvent(e,t)};r.prototype.onCustomEvent=function(e,t,i){if(!BX.MessengerCommon.isDesktop())return false;BX.desktop.onCustomEvent(e,t,i)};r.prototype.resize=function(e,t){BXDesktopWindow.SetProperty("clientSize",{Width:e,Height:t})};r.prototype.setResizable=function(e){e=e==true;BXDesktopWindow.SetProperty("resizable",e)};r.prototype.setMinSize=function(e,t){BXDesktopWindow.SetProperty("minClientSize",{Width:e,Height:t})};r.prototype.setWindowPosition=function(e){BXDesktopWindow.SetProperty("position",e)};r.prototype.center=function(){BXDesktopWindow.ExecuteCommand("center")};r.prototype.getVersion=function(e){if(typeof BXDesktopSystem=="undefined")return 0;if(!this.clientVersion)this.clientVersion=BXDesktopSystem.GetProperty("versionParts");return e?this.clientVersion.join("."):this.clientVersion[3]};r.prototype.isFeatureSupported=function(e){if(!a.hasOwnProperty(e))return false;return this.getVersion()>=a[e]};var c=function(t){this.node=t.node;this.id=t.id;this.entityType="";this.statuses={};this.elements={};this.currentStatusId=t.callListStatusId||"IN_WORK";this.currentItemIndex=t.itemIndex||0;this.callingStatusId=null;this.callingItemIndex=null;this.selectionLocked=false;this.itemActionMenu=null;this.callbacks={onError:BX.type.isFunction(t.onError)?t.onError:e,onSelectedItem:BX.type.isFunction(t.onSelectedItem)?t.onSelectedItem:e};this.showLimit=10;this.showDelta=10};c.getAjaxUrl=function(){return BX.MessengerCommon.isDesktop()?"/desktop_app/call_list.ajax.php":"/bitrix/components/bitrix/crm.activity.call_list/ajax.php"};c.prototype.init=function(e){if(!BX.type.isFunction(e))e=BX.DoNothing;var t=this;this.load(function(){if(t.statuses[t.currentStatusId].ITEMS.length>0){t.render();t.selectItem(t.currentStatusId,t.currentItemIndex);e()}else{BX.debug("empty call list. don't know what to do")}})};c.prototype.reinit=function(e){if(BX.type.isDomNode(e.node))this.node=e.node;this.render();this.selectItem(this.currentStatusId,this.currentItemIndex);if(this.callingStatusId!==null&&this.callingItemIndex!==null)this.setCallingElement(this.callingStatusId,this.callingItemIndex)};c.prototype.load=function(e){var t=this;var i={sessid:BX.bitrix_sessid(),ajax_action:"GET_CALL_LIST",callListId:this.id};BX.ajax({url:c.getAjaxUrl(),method:"POST",dataType:"json",data:i,onsuccess:function(i){if(!i.ERROR){if(BX.type.isArray(i.STATUSES)){i.STATUSES.forEach(function(e){t.statuses[e.STATUS_ID]=e;t.statuses[e.STATUS_ID].ITEMS=[]});i.ITEMS.forEach(function(e){t.statuses[e.STATUS_ID].ITEMS.push(e)})}t.entityType=i.ENTITY_TYPE;if(t.statuses[t.currentStatusId].ITEMS.length==0){t.currentStatusId=t.getNonEmptyStatusId();t.currentItemIndex=0}e()}else{console.log(i)}}})};c.prototype.selectItem=function(e,t){var i=this.statuses[this.currentStatusId].ITEMS[this.currentItemIndex]._node;BX.removeClass(i,"im-phone-call-list-customer-block-active");if(this.itemActionMenu)this.itemActionMenu.close();this.currentStatusId=e;this.currentItemIndex=t;i=this.statuses[this.currentStatusId].ITEMS[this.currentItemIndex]._node;BX.addClass(i,"im-phone-call-list-customer-block-active");var s=this.statuses[e].ITEMS[t];if((this.entityType=="DEAL"||this.entityType=="QUOTE"||this.entityType=="INVOICE")&&s.ASSOCIATED_ENTITY){this.callbacks.onSelectedItem({type:s.ASSOCIATED_ENTITY.TYPE,id:s.ASSOCIATED_ENTITY.ID,phones:s.ASSOCIATED_ENTITY.PHONES,statusId:e,index:t})}else{this.callbacks.onSelectedItem({type:this.entityType,id:s.ELEMENT_ID,phones:s.PHONES,statusId:e,index:t})}};c.prototype.moveToNextItem=function(){var e=this.currentItemIndex+1;if(e>=this.statuses[this.currentStatusId].ITEMS.length)e=0;this.selectItem(this.currentStatusId,e)};c.prototype.setCallingElement=function(e,t){this.callingStatusId=e;this.callingItemIndex=t;currentNode=this.statuses[this.callingStatusId].ITEMS[this.callingItemIndex]._node;BX.addClass(currentNode,"im-phone-call-list-customer-block-calling");this.selectionLocked=true};c.prototype.resetCallingElement=function(){if(this.callingStatusId===null||this.callingItemIndex===null)return;currentNode=this.statuses[this.callingStatusId].ITEMS[this.callingItemIndex]._node;BX.removeClass(currentNode,"im-phone-call-list-customer-block-calling");this.callingStatusId=null;this.callingItemIndex=null;this.selectionLocked=false};c.prototype.render=function(){BX.cleanNode(this.node);var e=BX.create("div",{props:{className:"im-phone-call-list-container"},children:this.renderStatusBlocks()});this.node.appendChild(e)};c.prototype.renderStatusBlocks=function(){var e=this;var t=[];var i;var s;for(i in this.statuses){var n=this.statuses[i];if(n.ITEMS.length==0)continue;n._node=this.renderStatusBlock(n);t.push(n._node)}return t};c.prototype.renderStatusBlock=function(e){var t;var i;var s;var n=e.STATUS_ID;if(!e.hasOwnProperty("_folded"))e._folded=false;className="im-phone-call-list-block";if(e.CLASS!="")className=className+" "+e.CLASS;return BX.create("div",{props:{className:className},children:[BX.create("div",{props:{className:"im-phone-call-list-block-title"+(e._folded?"":" active")},children:[BX.create("span",{text:this.getStatusTitle(n)}),BX.create("div",{props:{className:"im-phone-call-list-block-title-arrow"}})],events:{click:function(n){clearTimeout(t);e._folded=!e._folded;if(e._folded){BX.removeClass(n.target,"active");i.style.height=s.clientHeight.toString()+"px";t=setTimeout(function(){i.style.height=0},50)}else{BX.addClass(n.target,"active");i.style.height=0;t=setTimeout(function(){i.style.height=s.clientHeight+"px"},50)}BX.PreventDefault(n)}}}),i=BX.create("div",{props:{className:"im-phone-call-list-items-block"},children:[s=BX.create("div",{props:{className:"im-phone-call-list-items-measuring"},children:this.renderCallListItems(n)})],events:{transitionend:function(){if(!e._folded){i.style.removeProperty("height")}}}})]})};c.prototype.renderCallListItems=function(e){var t=[];var i=this.statuses[e];if(i._shownCount>0){if(i._shownCount>i.ITEMS.length)i._shownCount=i.ITEMS.length}else{i._shownCount=Math.min(this.showLimit,i.ITEMS.length)}for(var s=0;s<i._shownCount;s++){t.push(this.renderCallListItem(i.ITEMS[s],e,s))}if(i.ITEMS.length>i._shownCount){i._showMoreNode=BX.create("div",{props:{className:"im-phone-call-list-show-more-wrap"},children:[BX.create("span",{props:{className:"im-phone-call-list-show-more-button"},dataset:{statusId:e},text:BX.message("IM_PHONE_CALL_LIST_MORE").replace("#COUNT#",i.ITEMS.length-i._shownCount),events:{click:this.onShowMoreClick.bind(this)}})]});t.push(i._showMoreNode)}else{i._showMoreNode=null}return t};c.prototype.renderCallListItem=function(e,t,i){var s=this.statuses[t].NAME;var n=this;var o="";if(BX.type.isArray(e.PHONES)){e.PHONES.forEach(function(e,t){if(t!=0){o+="; "}o+=BX.util.htmlspecialchars(e.VALUE)})}e._node=BX.create("div",{props:{className:this.currentStatusId==t&&this.currentItemIndex==i?"im-phone-call-list-customer-block im-phone-call-list-customer-block-active":"im-phone-call-list-customer-block"},children:[BX.create("div",{props:{className:"im-phone-call-list-customer-block-action"},children:[BX.create("span",{text:s})],events:{click:function(t){if(n.itemActionMenu)n.itemActionMenu.popupWindow.close();else n.showItemMenu(e,t.target);BX.PreventDefault(t)}}}),BX.create("div",{props:{className:"im-phone-call-list-item-customer-name"+(e.ASSOCIATED_ENTITY?" im-phone-call-list-connection-line":"")},children:[BX.create("a",{attrs:{href:e.EDIT_URL,target:"_blank"},props:{className:"im-phone-call-list-item-customer-link"},text:e.NAME,events:{click:function(t){window.open(e.EDIT_URL);BX.PreventDefault(t)}}})]}),e.POST?BX.create("div",{props:{className:"im-phone-call-list-item-customer-info"},text:e.POST}):null,e.COMPANY_TITLE?BX.create("div",{props:{className:"im-phone-call-list-item-customer-info"},text:e.COMPANY_TITLE}):null,o?BX.create("div",{props:{className:"im-phone-call-list-item-customer-info"},text:o}):null,e.ASSOCIATED_ENTITY?this.renderAssociatedEntity(e.ASSOCIATED_ENTITY):null],events:{click:function(){if(!n.selectionLocked&&(n.currentStatusId!=e.STATUS_ID||n.currentItemIndex!=i)){n.selectItem(e.STATUS_ID,i)}}}});return e._node};c.prototype.renderAssociatedEntity=function(e){var t="";if(BX.type.isArray(e.PHONES)){e.PHONES.forEach(function(e,i){if(i!=0){t+="; "}t+=BX.util.htmlspecialchars(e.VALUE)})}return BX.create("div",{props:{className:"im-phone-call-list-item-customer-entity im-phone-call-list-connection-line-item"},children:[BX.create("a",{attrs:{href:e.EDIT_URL,target:"_blank"},props:{className:"im-phone-call-list-item-customer-link"},text:e.NAME,events:{click:function(t){window.open(e.EDIT_URL);BX.PreventDefault(t)}}}),BX.create("div",{props:{className:"im-phone-call-list-item-customer-info"},text:e.POST}),BX.create("div",{props:{className:"im-phone-call-list-item-customer-info"},text:e.COMPANY_TITLE}),t?BX.create("div",{props:{className:"im-phone-call-list-item-customer-info"},text:t}):null]})};c.prototype.onShowMoreClick=function(e){var t=e.target.dataset.statusId;var i=this.statuses[t];i._shownCount+=this.showDelta;if(i._shownCount>i.ITEMS.length)i._shownCount=i.ITEMS.length;var s=this.renderStatusBlock(i);i._node.parentNode.replaceChild(s,i._node);i._node=s};c.prototype.showItemMenu=function(e,t){var i=this;var s=[];var o;for(statusId in this.statuses){o={id:"setStatus_"+statusId,text:this.statuses[statusId].NAME,onclick:this.actionMenuItemClickHandler(e.ELEMENT_ID,statusId).bind(this)};s.push(o)}s.push({id:"callListItemActionMenu_delimiter",delimiter:true});s.push({id:"defer15min",text:BX.message("IM_PHONE_CALL_VIEW_CALL_LIST_DEFER_15_MIN"),onclick:function(){i.itemActionMenu.popupWindow.close();i.setElementRank(e.ELEMENT_ID,e.RANK+35)}});s.push({id:"defer1hour",text:BX.message("IM_PHONE_CALL_VIEW_CALL_LIST_DEFER_HOUR"),onclick:function(){i.itemActionMenu.popupWindow.close();i.setElementRank(e.ELEMENT_ID,e.RANK+185)}});s.push({id:"moveToEnd",text:BX.message("IM_PHONE_CALL_VIEW_CALL_LIST_TO_END"),onclick:function(){i.itemActionMenu.popupWindow.close();i.setElementRank(e.ELEMENT_ID,e.RANK+5100)}});this.itemActionMenu=BX.PopupMenu.create("callListItemActionMenu",t,s,{autoHide:true,offsetTop:0,offsetLeft:0,angle:{position:"top"},zIndex:n+200,events:{onPopupClose:function(){i.itemActionMenu.popupWindow.destroy();BX.PopupMenu.destroy("callListItemActionMenu")},onPopupDestroy:function(){i.itemActionMenu=null}}});this.itemActionMenu.popupWindow.show()};c.prototype.actionMenuItemClickHandler=function(e,t){var i=this;return function(){i.itemActionMenu.popupWindow.close();i.setElementStatus(e,t)}};c.prototype.setElementRank=function(e,t){var i=this;this.executeItemAction({action:"SET_ELEMENT_RANK",parameters:{callListId:this.id,elementId:e,rank:t},successCallback:function(e){if(e.ITEMS){i.repopulateItems(e.ITEMS);i.render()}}})};c.prototype.setElementStatus=function(e,t){var i=this;this.executeItemAction({action:"SET_ELEMENT_STATUS",parameters:{callListId:this.id,elementId:e,statusId:t},successCallback:function(e){i.repopulateItems(e.ITEMS);i.render()}})};c.prototype.setWebformResult=function(e,t){this.executeItemAction({action:"SET_WEBFORM_RESULT",parameters:{callListId:this.id,elementId:e,webformResultId:t}})};c.prototype.executeItemAction=function(e){var t=this;if(!BX.type.isPlainObject(e))e={};if(!BX.type.isFunction(e.successCallback))e.successCallback=BX.DoNothing;var i={sessid:BX.bitrix_sessid(),ajax_action:e.action,parameters:e.parameters};BX.ajax({url:c.getAjaxUrl(),method:"POST",dataType:"json",data:i,onsuccess:function(t){e.successCallback(t)}})};c.prototype.repopulateItems=function(e){var t=this;for(statusId in this.statuses){this.statuses[statusId].ITEMS=[]}e.forEach(function(e){t.statuses[e.STATUS_ID].ITEMS.push(e)});if(this.statuses[this.currentStatusId].ITEMS.length==0){this.currentStatusId=this.getNonEmptyStatusId();this.currentItemIndex=0}else{if(this.currentItemIndex>=this.statuses[this.currentStatusId].ITEMS.length)this.currentItemIndex=0}this.selectItem(this.currentStatusId,this.currentItemIndex)};c.prototype.getNonEmptyStatusId=function(){var e=false;for(statusId in this.statuses){if(this.statuses[statusId].ITEMS.length>0){e=statusId;break}}return e};c.prototype.getCurrentElement=function(){return this.statuses[this.currentStatusId].ITEMS[this.currentItemIndex]};c.prototype.getStatusTitle=function(e){var t=this.statuses[e].ITEMS.length;return BX.util.htmlspecialchars(this.statuses[e].NAME)+" ("+t.toString()+")"};var h=null;var p={};BX.FoldedCallView=function(e){this.currentItem={};this.callListParams={id:0,webformId:0,webformSecCode:"",itemIndex:0,itemStatusId:"",statusList:{},entityType:""};this.node=null;this.elements={avatar:null,callButton:null,nextButton:null,unfoldButton:null};this._lsKey="bx-im-folded-call-view-data";this._lsTtl=86400;this.init()};BX.FoldedCallView.getInstance=function(){if(h==null)h=new BX.FoldedCallView;return h};BX.FoldedCallView.prototype.init=function(){this.load();if(this.callListParams.id>0){this.currentItem=this.callListParams.statusList[this.callListParams.itemStatusId].ITEMS[this.callListParams.itemIndex];this.render()}};BX.FoldedCallView.prototype.load=function(){var e=BX.localStorage.get(this._lsKey);if(BX.type.isPlainObject(e)){this.callListParams=e}};BX.FoldedCallView.prototype.destroy=function(){if(this.node){BX.cleanNode(this.node,true);this.node=null}BX.localStorage.remove(this._lsKey)};BX.FoldedCallView.prototype.store=function(){BX.localStorage.set(this._lsKey,this.callListParams,this._lsTtl)};BX.FoldedCallView.prototype.fold=function(e,t){t=t==true;this.callListParams.id=e.callListId;this.callListParams.webformId=e.webformId;this.callListParams.webformSecCode=e.webformSecCode;this.callListParams.itemIndex=e.currentItemIndex;this.callListParams.itemStatusId=e.currentItemStatusId;this.callListParams.statusList=e.statusList;this.callListParams.entityType=e.entityType;this.currentItem=this.callListParams.statusList[this.callListParams.itemStatusId].ITEMS[this.callListParams.itemIndex];this.store();this.render(t)};BX.FoldedCallView.prototype.unfold=function(e){var t=this;BX.addClass(this.node,"im-phone-folded-call-view-unfold");this.node.addEventListener("animationend",function(){if(t.node){BX.cleanNode(t.node,true);t.node=null}BX.localStorage.remove(t._lsKey);if(!window.BXIM||t.callListParams.id==0)return false;var i={};if(t.callListParams.webformId>0&&t.callListParams.webformSecCode!=""){i.webformId=t.callListParams.webformId;i.webformSecCode=t.callListParams.webformSecCode}i.callListStatusId=t.callListParams.itemStatusId;i.callListItemIndex=t.callListParams.itemIndex;i.makeCall=e;window.BXIM.startCallList(t.callListParams.id,i)})};BX.FoldedCallView.prototype.moveToNext=function(){this.callListParams.itemIndex++;if(this.callListParams.itemIndex>=this.callListParams.statusList[this.callListParams.itemStatusId].ITEMS.length)this.callListParams.itemIndex=0;this.currentItem=this.callListParams.statusList[this.callListParams.itemStatusId].ITEMS[this.callListParams.itemIndex];this.store();this.render()};BX.FoldedCallView.prototype.render=function(e){var t=this;e=e==true;if(this.node==null){this.node=BX.create("div",{props:{id:"im-phone-folded-call-view",className:"im-phone-call-wrapper im-phone-call-wrapper-fixed im-phone-call-panel"},events:{dblclick:this._onViewDblClick.bind(this)}});document.body.appendChild(this.node)}else{BX.cleanNode(this.node)}this.node.appendChild(BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-left"},style:e?{bottom:"-90px"}:{},children:[BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-user"},children:[BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-user-image"},children:[this.elements.avatar=BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-user-image-item"}})]}),BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-user-info"},children:this.renderUserInfo()})]})]}));this.node.appendChild(BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-right"},children:[BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-btn-container"},children:[this.elements.callButton=BX.create("span",{props:{className:"im-phone-call-btn im-phone-call-btn-green"},text:BX.message("IM_PHONE_CALL_VIEW_FOLDED_BUTTON_CALL"),events:{click:this._onDialButtonClick.bind(this)}}),this.elements.nextButton=BX.create("span",{props:{className:"im-phone-call-btn im-phone-call-btn-gray im-phone-call-btn-arrow"},text:BX.message("IM_PHONE_CALL_VIEW_FOLDED_BUTTON_NEXT"),events:{click:this._onNextButtonClick.bind(this)}})]})]}));this.node.appendChild(BX.create("div",{props:{className:"im-phone-btn-block"},children:[this.elements.unfoldButton=BX.create("div",{props:{className:"im-phone-btn-arrow"},children:[BX.create("div",{props:{className:"im-phone-btn-arrow-inner"},text:BX.message("IM_PHONE_CALL_VIEW_UNFOLD")})],events:{click:this._onUnfoldButtonClick.bind(this)}})]}));if(p[this.currentItem.ELEMENT_ID]){this.elements.avatar.style.backgroundImage="url('"+BX.util.htmlspecialchars(p[this.currentItem.ELEMENT_ID])+"')"}else{this.loadAvatar(this.callListParams.entityType,this.currentItem.ELEMENT_ID)}if(e){BX.addClass(this.node,"im-phone-folded-call-view-fold");this.node.addEventListener("animationend",function(){BX.removeClass(t.node,"im-phone-folded-call-view-fold")})}};BX.FoldedCallView.prototype.renderUserInfo=function(){var e=[];e.push(BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-user-name"},text:this.currentItem.NAME}));if(this.currentItem.POST)e.push(BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-user-item"},text:this.currentItem.POST}));if(this.currentItem.COMPANY_TITLE)e.push(BX.create("div",{props:{className:"im-phone-call-wrapper-fixed-user-item"},text:this.currentItem.COMPANY_TITLE}));return e};BX.FoldedCallView.prototype.loadAvatar=function(e,t){var i=this;BX.ajax({url:c.getAjaxUrl(),method:"POST",dataType:"json",data:{sessid:BX.bitrix_sessid(),ajax_action:"GET_AVATAR",entityType:e,entityId:t},onsuccess:function(e){if(!e.avatar)return;p[t]=e.avatar;if(i.currentItem.ELEMENT_ID==t&&i.elements.avatar){i.elements.avatar.style.backgroundImage="url('"+BX.util.htmlspecialchars(e.avatar)+"')"}}})};BX.FoldedCallView.prototype._onViewDblClick=function(e){BX.PreventDefault(e);this.unfold(false)};BX.FoldedCallView.prototype._onDialButtonClick=function(e){BX.PreventDefault(e);this.unfold(true)};BX.FoldedCallView.prototype._onNextButtonClick=function(e){BX.PreventDefault(e);this.moveToNext()};BX.FoldedCallView.prototype._onUnfoldButtonClick=function(e){BX.PreventDefault(e);this.unfold(false)};var d=function(e){this.bindElement=BX.type.isDomNode(e.bindElement)?e.bindElement:null;this.callbacks={onSelect:BX.type.isFunction(e.onSelect)?e.onSelect:BX.DoNothing,onDestroy:BX.type.isFunction(e.onDestroy)?e.onDestroy:BX.DoNothing};this.popup=null;this.selectedUserId=0;this.BXIM=e.BXIM;this.elements={destinationContainer:null,input:null}};d.create=function(e){return new d(e)};d.prototype.show=function(){if(!this.popup){this.popup=this.createPopup();this.popup.setAngle({offset:BX.MessengerCommon.isPage()?32:198});this.bindEvents()}this.popup.show();this.elements.input.focus()};d.prototype.close=function(){if(this.popup)this.popup.close()};d.prototype.createPopup=function(){var e=this;return new BX.PopupWindow("bx-messenger-popup-transfer",this.bindElement,{zIndex:n+200,lightShadow:true,offsetTop:5,offsetLeft:BX.MessengerCommon.isPage()?5:-162,autoHide:true,closeByEsc:true,content:this.render(),buttons:[new BX.PopupWindowButton({text:BX.message("IM_M_CALL_BTN_TRANSFER"),className:"popup-window-button-accept",events:{click:function(t){var i=false;if(e.selectedUserId==0)return false;if(e.BXIM.messenger.phones&&e.BXIM.messenger.phones[e.selectedUserId]){if(e.BXIM.messenger.phones[e.selectedUserId].PERSONAL_MOBILE||e.BXIM.messenger.phones[e.selectedUserId].PERSONAL_PHONE||e.BXIM.messenger.phones[e.selectedUserId].WORK_PHONE){i=true}}if(!i){e.popup.close();e.callbacks.onSelect({type:"user",userId:e.selectedUserId})}else{e.BXIM.messenger.openPopupMenu(t.target,"callTransferMenu",true,{userId:e.selectedUserId,zIndex:n+210,onSelect:function(t){e.popup.close();e.callbacks.onSelect(t)}})}}}}),new BX.PopupWindowButton({text:BX.message("IM_M_CHAT_BTN_CANCEL"),events:{click:function(){e.popup.close()}}})],events:{onPopupClose:function(){this.destroy()},onPopupDestroy:function(){e.popup=null;e.elements.contactList=null;e.callbacks.onDestroy()}}})};d.prototype.render=function(){return BX.create("div",{props:{className:"bx-messenger-popup-newchat-wrap"},children:[BX.create("div",{props:{className:"bx-messenger-popup-newchat-caption"},html:BX.message("IM_M_CALL_TRANSFER_TEXT")}),BX.create("div",{props:{className:"bx-messenger-popup-newchat-box bx-messenger-popup-newchat-dest bx-messenger-popup-newchat-dest-even"},children:[this.elements.destinationContainer=BX.create("span",{props:{className:"bx-messenger-dest-items"}}),this.elements.input=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.elements.contactList=BX.create("div",{props:{className:"bx-messenger-popup-newchat-box bx-messenger-popup-newchat-cl bx-messenger-recent-wrap"},children:[]})]})};d.prototype.bindEvents=function(e){var t=this;var i=1;BX.MessengerCommon.contactListSearchClear();if(!this.BXIM.messenger.contactListLoad){this.elements.contactList.appendChild(BX.create("div",{props:{className:"bx-messenger-cl-item-load"},html:BX.message("IM_CL_LOAD")}));BX.MessengerCommon.contactListGetFromServer(function(){BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",t.elements.contactList,t.elements.input.value,{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOnlyIntranet:true,viewOfflineWithPhones:true})})}else{BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.elements.contactList,this.elements.input.value,{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOnlyIntranet:true,viewOfflineWithPhones:true})}BX.bindDelegate(this.elements.contactList,"click",{className:"bx-messenger-chatlist-more"},BX.delegate(this.BXIM.messenger.toggleChatListGroup,this.BXIM.messenger));BX.addClass(this.popup.popupContainer,"bx-messenger-mark");BX.bind(this.popup.popupContainer,"click",BX.PreventDefault);BX.bind(this.elements.input,"keyup",BX.delegate(function(e){if(e.keyCode==16||e.keyCode==17||e.keyCode==18||e.keyCode==20||e.keyCode==244||e.keyCode==224||e.keyCode==91)return false;if(e.keyCode==27&&this.elements.input.value!="")BX.MessengerCommon.preventDefault(e);if(e.keyCode==27){this.elements.input.value=""}if(e.keyCode==8){var t=null;var s=BX.util.objectSort(this.popupChatDialogUsers,"date","asc");for(var n=0;n<s.length;n++){t=s[n].id}if(t){delete this.popupChatDialogUsers[t];this.redrawChatDialogDest()}}if(e.keyCode==13){this.elements.input.value="";var o=BX.findChildByClassName(this.elements.contactList,"bx-messenger-cl-item");if(o){if(this.elements.input.value!=""){this.elements.input.value=""}if(this.selectedUserId>0){i=i+1;if(i>0)BX.show(this.elements.input);this.selectedUserId=0}else{if(i>0){i=i-1;if(i<=0)BX.hide(this.elements.input);this.selectedUserId=o.getAttribute("data-userId")}}this.redrawTransferDialogDest()}}BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.elements.contactList,this.elements.input.value,{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOnlyIntranet:true,viewOfflineWithPhones:true,timeout:100})},this));BX.bindDelegate(this.elements.destinationContainer,"click",{className:"bx-messenger-dest-del"},BX.delegate(function(){this.selectedUserId=0;i=i+1;if(i>0)BX.show(this.elements.input);this.redrawTransferDialogDest()},this));BX.bindDelegate(this.elements.contactList,"click",{className:"bx-messenger-cl-item"},BX.delegate(function(e){if(this.elements.input.value!=""){this.elements.input.value="";BX.MessengerCommon.contactListPrepareSearch("popupTransferDialogContactListElements",this.elements.contactList,"",{viewChat:false,viewOpenChat:false,viewOffline:false,viewBot:false,viewOnlyIntranet:true,viewOfflineWithPhones:true})}if(this.selectedUserId){i=i+1;this.selectedUserId=0}else{if(i<=0)return false;i=i-1;this.selectedUserId=BX.proxy_context.getAttribute("data-userId")}if(i<=0)BX.hide(this.elements.input);else BX.show(this.elements.input);this.redrawTransferDialogDest();return BX.PreventDefault(e)},this))};d.prototype.redrawTransferDialogDest=function(){var e="";var t=0;var i=this.selectedUserId.toString().substr(0,5)=="queue";var s=i?this.selectedUserId.toString().substr(5):0;if(i){var n=this.selectedUserId;for(var o=0;o<this.queue.length;o++){if(this.queue[o].ID==s){n=this.queue[o].NAME;break}}t++;e+='<span class="bx-messenger-dest-block bx-messenger-dest-block-extranet">'+'<span class="bx-messenger-dest-text">'+n+"</span>"+'<span class="bx-messenger-dest-del" data-userId="'+this.selectedUserId+'"></span></span>'}else if(this.selectedUserId>0){t++;e+='<span class="bx-messenger-dest-block'+(this.BXIM.messenger.users[this.selectedUserId].extranet?" bx-messenger-dest-block-extranet":"")+'">'+'<span class="bx-messenger-dest-text">'+this.BXIM.messenger.users[this.selectedUserId].name+"</span>"+'<span class="bx-messenger-dest-del" data-userId="'+this.selectedUserId+'"></span></span>'}this.elements.destinationContainer.innerHTML=e;this.elements.destinationContainer.parentNode.scrollTop=this.elements.destinationContainer.parentNode.offsetHeight;if(BX.util.even(t))BX.addClass(this.elements.destinationContainer.parentNode,"bx-messenger-popup-newchat-dest-even");else BX.removeClass(this.elements.destinationContainer.parentNode,"bx-messenger-popup-newchat-dest-even");this.elements.input.focus()};d.prototype.destroy=function(){this.BXIM.messenger.closeMenuPopup()};var u=function(e){if(!BX.type.isPlainObject(e))e={};this.bindElement=e.bindElement||null;this.offsetTop=e.offsetTop||0;this.offsetLeft=e.offsetLeft||0;this.anglePosition=e.anglePosition||"";this.angleOffset=e.angleOffset||0;this.history=e.history||[];this.selectedLineId=e.defaultLineId;this.lines=e.lines||{};this.availableLines=e.availableLines||[];this.zIndex=n+200;this.hideDial=e.hideDial===true;this.plusEntered=false;this.callbacks={onButtonClick:BX.type.isFunction(e.onButtonClick)?e.onButtonClick:BX.DoNothing,onDial:BX.type.isFunction(e.onDial)?e.onDial:BX.DoNothing,onClose:BX.type.isFunction(e.onClose)?e.onClose:BX.DoNothing};this.elements={inputContainer:null,input:null,lineSelector:null,lineName:null,interceptButton:null,historyButton:null};this.plusKeyTimeout=null;this.lineSelectMenu=null;this.historySelectMenu=null;this.interceptErrorPopup=null;this.popup=this.createPopup()};u.prototype.createPopup=function(){var e=this;var t={darkMode:true,closeByEsc:true,autoHide:true,zIndex:this.zIndex,content:this.render(),noAllPaddings:true,offsetTop:this.offsetTop,offsetLeft:this.offsetLeft,overlay:{backgroundColor:"white",opacity:0},events:{onPopupClose:function(){e.callbacks.onClose()}}};if(this.anglePosition!==""){t.angle={position:this.anglePosition,offset:this.angleOffset}}return new BX.PopupWindow("phone-call-view-popup-keypad",this.bindElement,t)};u.prototype.canSelectLine=function(){return this.availableLines.length>1};u.prototype.setSelectedLineId=function(e){this.selectedLineId=e;if(this.elements.lineName){this.elements.lineName.innerText=this.getLineName(e)}};u.prototype.getLineName=function(e){return this.lines.hasOwnProperty(e)?this.lines[e].SHORT_NAME:""};u.prototype.render=function(){var e=this;var t=function(t){var i;if(t=="*")i="10";else if(t=="#")i="11";else i=t;return BX.create("span",{dataset:{digit:t},props:{className:"bx-messenger-calc-btn bx-messenger-calc-btn-"+i},children:[BX.create("span",{props:{className:"bx-messenger-calc-btn-num"}})],events:{mousedown:e._onKeyButtonMouseDown.bind(e),mouseup:e._onKeyButtonMouseUp.bind(e)}})};return BX.create("div",{props:{className:"bx-messenger-calc-wrap"+(BX.MessengerCommon.isPage()?" bx-messenger-calc-wrap-desktop":"")},events:{click:this._onBodyClick.bind(this)},children:[BX.create("div",{props:{className:"bx-messenger-calc-body"},children:[this.elements.inputContainer=BX.create("div",{props:{className:"bx-messenger-calc-panel"},children:[BX.create("span",{props:{className:"bx-messenger-calc-panel-delete"},events:{click:this._onDeleteButtonClick.bind(this)}}),this.elements.input=BX.create("input",{attrs:{readonly:this.hideDial,type:"text",value:"",placeholder:BX.message(this.hideDial?"IM_PHONE_PUT_DIGIT":"IM_PHONE_PUT_NUMBER")},props:{className:"bx-messenger-calc-panel-input"},events:{keydown:this._onInputKeydown.bind(this),keyup:function(){e._onAfterNumberChanged()}}})]}),BX.create("div",{props:{className:"bx-messenger-calc-btns-block"},children:["1","2","3","4","5","6","7","8","9","*","0","#"].map(t)})]}),this.hideDial?null:BX.create("div",{props:{className:"bx-messenger-call-btn-wrap"},children:[this.elements.lineSelector=!this.canSelectLine()?null:BX.create("div",{props:{className:"im-phone-select-line"},children:[this.elements.lineName=BX.create("span",{props:{className:"im-phone-select-line-name"},text:this.getLineName(this.selectedLineId)}),BX.create("span",{props:{className:"im-phone-select-line-select"}})],events:{click:this._onLineSelectClick.bind(this)}}),BX.create("span",{props:{className:"bx-messenger-call-btn-separate"},children:[BX.create("span",{props:{className:"bx-messenger-call-btn"},children:[BX.create("span",{props:{className:"bx-messenger-call-btn-text"},html:BX.message("IM_PHONE_CALL")})],events:{click:this._onDialButtonClick.bind(this)}}),this.elements.historyButton=BX.create("span",{props:{className:"bx-messenger-call-btn-arrow"},events:{click:this._onShowHistoryButtonClick.bind(this)}})]}),this.elements.interceptButton=BX.create("span",{props:{className:"im-phone-intercept-button"+(l.callInterceptAllowed?"":" im-phone-intercept-button-locked")},text:BX.message("IM_PHONE_CALL_VIEW_INTERCEPT"),events:{click:this._onInterceptButtonClick.bind(this)}})]})]})};u.prototype._onBodyClick=function(e){if(this.interceptErrorPopup)this.interceptErrorPopup.close()};u.prototype._onInputKeydown=function(e){if(e.keyCode==13){this.callbacks.onDial({phoneNumber:this.elements.input.value,lineId:this.selectedLineId})}else if(e.keyCode==37||e.keyCode==39||e.keyCode==8||e.keyCode==107||e.keyCode==46||e.keyCode==35||e.keyCode==36){}else if((e.keyCode==61||e.keyCode==187||e.keyCode==51||e.keyCode==56)&&e.shiftKey){}else if((e.keyCode==67||e.keyCode==86||e.keyCode==65||e.keyCode==88)&&(e.metaKey||e.ctrlKey)){}else if(e.keyCode>=48&&e.keyCode<=57&&!e.shiftKey){this.callbacks.onButtonClick({key:e.key})}else if(e.keyCode>=96&&e.keyCode<=105&&!e.shiftKey){this.callbacks.onButtonClick({key:e.key})}else{return BX.PreventDefault(e)}};u.prototype._onAfterNumberChanged=function(){if(this.elements.input.value.length>0)BX.addClass(this.elements.inputContainer,"bx-messenger-calc-panel-active");else BX.removeClass(this.elements.inputContainer,"bx-messenger-calc-panel-active");this.elements.input.focus()};u.prototype._onDeleteButtonClick=function(){this.elements.input.value=this.elements.input.value.substr(0,this.elements.input.value.length-1);this._onAfterNumberChanged()};u.prototype._onDialButtonClick=function(){this.callbacks.onDial({phoneNumber:this.elements.input.value,lineId:this.selectedLineId})};u.prototype._onInterceptButtonClick=function(){var e=this;if(!l.callInterceptAllowed){this.close();if(BX.Voximplant&&BX.Voximplant.showLicensePopup){BX.Voximplant.showLicensePopup("call-intercept")}return}BX.MessengerCommon.phoneCommand("interceptCall",{},true,function(t){if(!t.FOUND||t.FOUND=="Y"){e.close()}else{if(t.ERROR){e.interceptErrorPopup=new BX.PopupWindow("intercept-call-error",this.elements.interceptButton,{content:BX.util.htmlspecialchars(t.ERROR),autoHide:true,closeByEsc:true,bindOptions:{position:"bottom"},angle:{offset:40},zIndex:this.zIndex+100,onPopupClose:function(t){e.interceptErrorPopup.destroy()},onPopupDestroy:function(t){e.interceptErrorPopup=null}});e.interceptErrorPopup.show()}}}.bind(this))};u.prototype._onKeyButtonMouseDown=function(e){BX.PreventDefault(e);var t=e.currentTarget.dataset.digit.toString();var i=this;if(t==0){this.plusKeyTimeout=setTimeout(function(){i.plusEntered=true;i.elements.input.value=i.elements.input.value+"+"},500)}};u.prototype._onKeyButtonMouseUp=function(e){BX.PreventDefault(e);var t=e.currentTarget.dataset.digit.toString();if(t==0){clearTimeout(this.plusKeyTimeout);if(!this.plusEntered)this.elements.input.value=this.elements.input.value+"0";this.plusEntered=false}else{this.elements.input.value=this.elements.input.value+t}this._onAfterNumberChanged();this.callbacks.onButtonClick({key:t})};u.prototype._onShowHistoryButtonClick=function(){var e=this;var t=[];if(!BX.type.isArray(this.history)||this.history.length===0)return;this.history.forEach(function(i,s){t.push({id:"history_"+s,text:BX.util.htmlspecialchars(i),onclick:function(){e.historySelectMenu.close();e.callbacks.onDial({phoneNumber:i,lineId:e.selectedLineId})}})});this.historySelectMenu=BX.PopupMenu.create("phoneCallViewDialHistory",this.elements.historyButton,t,{autoHide:true,offsetTop:0,offsetLeft:0,zIndex:n+300,bindOptions:{position:"top"},angle:{offset:33},closeByEsc:true,overlay:{backgroundColor:"white",opacity:0},events:{onPopupClose:function(){e.historySelectMenu.popupWindow.destroy();BX.PopupMenu.destroy("phoneCallViewDialHistory")},onPopupDestroy:function(){e.historySelectMenu=null}}});this.historySelectMenu.popupWindow.show()};u.prototype._onLineSelectClick=function(e){var t=this;var i=[];this.availableLines.forEach(function(e){i.push({id:"selectLine_"+e,text:BX.util.htmlspecialchars(t.getLineName(e)),onclick:function(){t.lineSelectMenu.close();t.setSelectedLineId(e)}})});this.lineSelectMenu=BX.PopupMenu.create("phoneCallViewSelectLine",this.elements.lineSelector,i,{autoHide:true,zIndex:this.zIndex+100,closeByEsc:true,bindOptions:{position:"top"},offsetLeft:35,angle:{offset:33},overlay:{backgroundColor:"white",opacity:0},events:{onPopupClose:function(){t.lineSelectMenu.popupWindow.destroy();BX.PopupMenu.destroy("phoneCallViewSelectLine")},onPopupDestroy:function(){t.lineSelectMenu=null}}});this.lineSelectMenu.popupWindow.show()};u.prototype.show=function(){if(this.popup){this.popup.show();this.elements.input.focus()}};u.prototype.close=function(){if(this.lineSelectMenu)this.lineSelectMenu.destroy();if(this.historySelectMenu)this.historySelectMenu.destroy();if(this.interceptErrorPopup)this.interceptErrorPopup.close();if(this.popup)this.popup.close()};u.prototype.destroy=function(){if(this.lineSelectMenu)this.lineSelectMenu.destroy();if(this.historySelectMenu)this.historySelectMenu.destroy();if(this.interceptErrorPopup)this.interceptErrorPopup.destroy();if(this.popup)this.popup.destroy();this.popup=null};BX.PhoneKeypad=u;var m=function(e){this.node=e.node;this.currentForm=null;this.callbacks={onFormLoad:BX.type.isFunction(e.onFormLoad)?e.onFormLoad:BX.DoNothing,onFormUnLoad:BX.type.isFunction(e.onFormUnLoad)?e.onFormUnLoad:BX.DoNothing,onFormSend:BX.type.isFunction(e.onFormSend)?e.onFormSend:BX.DoNothing}};m.prototype.load=function(e){var t=this.getFormData(e);window.Bitrix24FormLoader.load(t);this.currentForm=t};m.prototype.unload=function(){if(this.currentForm){window.Bitrix24FormLoader.unload(this.currentForm);this.currentForm=null}};m.prototype.getFormData=function(e){return{id:e.id,sec:e.secCode,type:"inline",lang:"ru",ref:window.location.href,node:this.node,handlers:{load:this._onFormLoad.bind(this),unload:this._onFormUnLoad.bind(this),send:this.onFormSend.bind(this)},options:{borders:false,logo:false}}};m.prototype._onFormLoad=function(e){this.callbacks.onFormLoad(e)};m.prototype._onFormUnLoad=function(e){this.callbacks.onFormUnLoad(e)};m.prototype.onFormSend=function(e){this.callbacks.onFormSend(e)}})();