uawdijnntqw1x1x1
IP : 3.137.208.89
Hostname : axolotl
Kernel : Linux axolotl 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) x86_64
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
OS : Linux
PATH:
/
var
/
www
/
axolotl
/
data
/
www
/
.
/
b24.axolotl.ru
/
public_html
/
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",setPortalCallQueueName:"phoneCallViewSetPortalCallQueueName",setPortalCallData:"phoneCallViewSetPortalCallData",setConfig:"phoneCallViewSetConfig",setCallState:"phoneCallViewSetCallState",reloadCrmCard:"phoneCallViewReloadCrmCard",setCallId:"phoneCallViewSetCallId",setLineNumber:"phoneCallViewSetLineNumber",setPhoneNumber:"phoneCallViewSetPhoneNumber",setCompanyPhoneNumber:"phoneCallViewSetCompanyPhoneNumber",setTransfer:"phoneCallViewSetTransfer",closeWindow:"phoneCallViewCloseWindow",onHold:"phoneCallViewOnHold",onUnHold:"phoneCallViewOnUnHold",onMute:"phoneCallViewOnMute",onUnMute:"phoneCallViewOnUnMute",onMakeCall:"phoneCallViewOnMakeCall",onCallListMakeCall:"phoneCallViewOnCallListMakeCall",onAnswer:"phoneCallViewOnAnswer",onSkip:"phoneCallViewOnSkip",onHangup:"phoneCallViewOnHangup",onClose:"phoneCallViewOnClose",onStartTransfer:"phoneCallViewOnStartTransfer",onCompleteTransfer:"phoneCallViewOnCompleteTransfer",onCancelTransfer:"phoneCallViewOnCancelTransfer",onBeforeUnload:"phoneCallViewOnBeforeUnload",onSwitchDevice:"phoneCallViewOnSwitchDevice",onQualityGraded:"phoneCallViewOnQualityGraded",onDialpadButtonClicked:"phoneCallViewOnDialpadButtonClicked",onCommentShown:"phoneCallViewOnCommentShown",onSaveComment:"phoneCallViewOnSaveComment",onSetAutoClose:"phoneCallViewOnSetAutoClose"};var l={restApps:[],callInterceptAllowed:false};var a="/bitrix/js/im/images/blank.gif";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=BX.prop.getString(i,"crmEntityType","");this.crmEntityId=BX.prop.getInteger(i,"crmEntityId",0);this.crmActivityId=BX.prop.getInteger(i,"crmActivityId",0);this.crmActivityEditUrl=BX.prop.getString(i,"crmActivityEditUrl","");this.crmData=BX.prop.getObject(i,"crmData",{});this.crmBindings=BX.prop.getArray(i,"crmBindings",[]);this.externalRequests={};this.portalCallData=i.portalCallData;this.portalCallUserId=i.portalCallUserId;this.portalCallQueueName=i.portalCallQueueName;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.transfer=i.transfer===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,completeTransfer:BX.type.isFunction(i.events.completeTransfer)?i.events.completeTransfer: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._onTransferCompleteButtonClickHandler=this._onTransferCompleteButtonClick.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 h({BXIM:this.BXIM,parentPhoneCallView:this,closable:this.callListId>0?true:this.closable});this.currentLayout=this.callListId>0?t.crm:t.simple;C.desktop.isCurrentPage=true;this.init();this.createTitle().then(this.setTitle.bind(this));if(i.hasOwnProperty("uiState")){this.setUiState(i["uiState"])}C.CallCard=this;if(C.isDesktop()){C.removeDesktopEventHandlers()}C.onInitialize(this.getPlacementOptions());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();window.removeEventListener("beforeunload",this._unloadHandler);BX.removeCustomEvent(window,"onLocalStorageSet",this._externalEventHandler);BX.removeCustomEvent("onPullEvent-crm",this._onPullEventCrmHandler);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();return this};BX.PhoneCallView.prototype.createPopup=function(){var e=this;return new BX.PopupWindow(e.getId(),null,{targetContainer:document.body,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]&&this.portalCallData.hrphoto[this.portalCallUserId]!=a){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"},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=new BX.Promise;var t="";BX.PhoneNumberParser.getInstance().parse(this.phoneNumber).then(function(i){if(this.phoneNumber=="unknown"){e.resolve(BX.message("IM_PHONE_CALL_VIEW_NUMBER_UNKNOWN"));return}if(this.phoneNumber=="hidden"){t=BX.message("IM_PHONE_HIDDEN_NUMBER")}else{t=this.phoneNumber.toString();if(i.isValid()){t=i.format();if(i.isInternational()&&t.charAt(0)!="+"){t="+"+t}}else{t=this.phoneNumber.toString()}}if(this.isCallback()){t=BX.message("IM_PHONE_CALLBACK_TO").replace("#PHONE#",t)}else if(this.isPortalCall()){switch(this.direction){case BX.PhoneCallView.Direction.incoming:if(this.portalCallUserId){t=BX.message("IM_M_CALL_VOICE_FROM").replace("#USER#",this.portalCallData.users[this.portalCallUserId].name)}break;case BX.PhoneCallView.Direction.outgoing:if(this.portalCallUserId){t=BX.message("IM_M_CALL_VOICE_TO").replace("#USER#",this.portalCallData.users[this.portalCallUserId].name)}else{t=BX.message("IM_M_CALL_VOICE_TO").replace("#USER#",this.portalCallQueueName)+" ("+this.phoneNumber+")"}break}}else{t=BX.message(this.direction===BX.PhoneCallView.Direction.incoming?"IM_PHONE_CALL_VOICE_FROM":"IM_PHONE_CALL_VOICE_TO").replace("#PHONE#",t);if(this.direction===BX.PhoneCallView.Direction.incoming&&this.companyPhoneNumber){t=t+", "+BX.message("IM_PHONE_CALL_TO_PHONE").replace("#PHONE#",this.companyPhoneNumber)}if(this.isTransfer()){t=t+" "+BX.message("IM_PHONE_CALL_TRANSFERED")}}e.resolve(t)}.bind(this));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]&&this.portalCallData.hrphoto[this.portalCallUserId]!=a){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.setPhoneNumber=function(e){this.phoneNumber=e;this.setOnSlave(o.setPhoneNumber,[e])};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.setLineNumber,[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={};this.renderButtons();if(e===BX.PhoneCallView.CallState.connected&&this.isAutoFoldAllowed()){this.fold()}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.transfer};BX.PhoneCallView.prototype.setTransfer=function(e){e=e==true;if(this.transfer==e){return}this.transfer=e;this.setOnSlave(o.setTransfer,[e]);this.setUiState(this._uiState)};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||"";this.crmBindings=BX.type.isArray(e.bindings)?e.bindings:[];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){BX.onCustomEvent(window,"CallCard::EntityChanged",[{CRM_ENTITY_TYPE:e,CRM_ENTITY_ID:i,PHONE_NUMBER:this.phoneNumber}]);C.onEntityChanged({CRM_ENTITY_TYPE:e,CRM_ENTITY_ID:i,PHONE_NUMBER:this.phoneNumber});BX.ajax.runAction("voximplant.callview.getCrmCard",{data:{entityType:e,entityId:i}}).then(function(e){if(this.currentLayout==t.simple){this.currentLayout=t.crm;this.crm=true;var i=this.createLayoutCrm();this.elements.main.parentNode.replaceChild(i,this.elements.main);this.elements.main=i;this.setUiState(this._uiState);this.setStatusText(this.statusText)}if(this.elements.crmCard){BX.html(this.elements.crmCard,e.data.html);setTimeout(function(){if(this.isDesktop()){this.resizeWindow(this.getInitialWidth(),this.getInitialHeight())}this.adjust();this.bindCrmCardEvents()}.bind(this),100)}this.renderCrmButtons()}.bind(this)).catch((function(e){console.error("Could not load crm card: ",e.errors[0])}))};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();this.createTitle().then(function(e){this.setTitle(e)}.bind(this))}};BX.PhoneCallView.prototype.setPortalCallQueueName=function(e){this.portalCallQueueName=e;this.setOnSlave(o.setPortalCallQueueName,[e]);this.createTitle().then(function(e){this.setTitle(e)}.bind(this))};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.hasSipPhone){t.buttons.push("sipPhone")}if(this.callListId>0){t.buttons.push("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=this.isTransfer()?[]:["hold"];if(!this.deviceCall){t.buttons.push("mute","qualityMeter")}t.buttons.push("fold");if(!this.callListId&&!this.isTransfer()){t.buttons.push("transfer")}if(this.deviceCall){t.buttons.push("close")}else{t.buttons.push("dialpad","hangup")}t.layout=BX.PhoneCallView.ButtonLayouts.spaced;break;case BX.PhoneCallView.UiState.transferring:t.buttons=["transferComplete","transferCancel"];break;case BX.PhoneCallView.UiState.transferFailed:t.buttons=["transferCancel"];break;case BX.PhoneCallView.UiState.transferConnected:t.buttons=["hangup"];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={left:null,right:null};this.elements.buttons={};if(this.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced){n.left=BX.create("div",{props:{className:"im-phone-call-buttons-container-left"}});n.right=BX.create("div",{props:{className:"im-phone-call-buttons-container-right"}});t.appendChild(n.left);t.appendChild(n.right)}this.buttons.forEach((function(o){var l;switch(o){case"hold":l=e._renderSimpleButton("","im-phone-call-btn-hold",e._onHoldButtonClickHandler);if(e.isHeld())BX.addClass(l,"active");if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)n.left.appendChild(l);else t.appendChild(l);break;case"mute":l=e._renderSimpleButton("","im-phone-call-btn-mute",e._onMuteButtonClickHandler);if(e.isMuted())BX.addClass(l,"active");if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)n.left.appendChild(l);else t.appendChild(l);break;case"transfer":l=e._renderSimpleButton("","im-phone-call-btn-transfer",e._onTransferButtonClickHandler);if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)n.left.appendChild(l);else t.appendChild(l);break;case"transferComplete":l=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_TRANSFER"),"im-phone-call-btn im-phone-call-btn-blue im-phone-call-btn-arrow",e._onTransferCompleteButtonClickHandler);t.appendChild(l);break;case"transferCancel":l=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_RETURN"),"im-phone-call-btn im-phone-call-btn-red",e._onTransferCancelButtonClickHandler);t.appendChild(l);break;case"dialpad":l=e._renderSimpleButton("","im-phone-call-btn-dialpad",e._onDialpadButtonClickHandler);if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)n.left.appendChild(l);else t.appendChild(l);break;case"call":l=e._renderSimpleButton(BX.message("IM_PHONE_CALL"),"im-phone-call-btn im-phone-call-btn-green",e._onMakeCallButtonClickHandler);t.appendChild(l);break;case"answer":l=e._renderSimpleButton(BX.message("IM_PHONE_BTN_ANSWER"),"im-phone-call-btn im-phone-call-btn-green",e._onAnswerButtonClickHandler);t.appendChild(l);break;case"skip":l=e._renderSimpleButton(BX.message("IM_PHONE_BTN_BUSY"),"im-phone-call-btn im-phone-call-btn-red",e._onSkipButtonClickHandler);t.appendChild(l);break;case"hangup":l=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)n.right.appendChild(l);else t.appendChild(l);break;case"close":l=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)n.right.appendChild(l);else t.appendChild(l);break;case"topClose":if(!e.isDesktop()){l=BX.create("div",{props:{className:"im-phone-call-top-close-btn"},events:{click:e._onCloseButtonClickHandler}});s.appendChild(l)}break;case"notifyAdmin":l=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(){C.isUsed?C.onNotifyAdminButtonClick():e.callbacks.notifyAdmin()}));t.appendChild(l);break;case"sipPhone":l=e._renderSimpleButton("",e.deviceCall?"im-phone-call-btn-phone active":"im-phone-call-btn-phone",e._onSwitchDeviceButtonClickHandler);if(e.buttonLayout==BX.PhoneCallView.ButtonLayouts.spaced)n.left.appendChild(l);else t.appendChild(l);break;case"qualityMeter":l=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(l);break;case"settings":break;case"next":l=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(l);break;case"redial":l=e._renderSimpleButton(BX.message("IM_M_CALL_BTN_RECALL"),"im-phone-call-btn im-phone-call-btn-green",e._onMakeCallButtonClickHandler);t.appendChild(l);break;case"fold":if(!e.isDesktop()&&e.canBeFolded()){l=BX.create("div",{props:{className:"im-phone-btn-arrow"},text:BX.message("IM_PHONE_CALL_VIEW_FOLD"),events:{click:e._onFoldButtonClickHandler}});i.appendChild(l)}break;default:throw"Unknown button "+o}if(l){e.elements.buttons[o]=l}}));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=e.id;var i=e.node;if(this.restAppLayoutLoaded){BX.rest.AppLayout.getPlacement("CALL_CARD").load(t,this.getPlacementOptions());return}if(this.restAppLayoutLoading){return}this.restAppLayoutLoading=true;BX.ajax.runAction("voximplant.callView.loadRestApp",{data:{appId:t,placementOptions:this.getPlacementOptions()}}).then(function(e){if(!this.popup&&!this.isDesktop()){return}BX.html(i,e.data.html);this.restAppLayoutLoaded=true;this.restAppLayoutLoading=false;this.restAppInterface=BX.rest.AppLayout.initializePlacement("CALL_CARD");this.initializeAppInterface(this.restAppInterface)}.bind(this))};BX.PhoneCallView.prototype.unloadRestApps=function(){if(!BX.rest||!BX.rest.AppLayout){return false}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,CRM_BINDINGS:this.crmBindings,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()}C.onHoldButtonClick(this.isHeld())};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()}C.onMuteButtonClick(this.isMuted())};BX.PhoneCallView.prototype._onTransferButtonClick=function(e){this.selectTransferTarget(function(e){C.onTransferButtonClick(e);if(this.isDesktop()&&this.slave){BX.desktop.onCustomEvent(o.onStartTransfer,[e])}else{this.callbacks.transfer(e)}}.bind(this))};BX.PhoneCallView.prototype._onTransferCompleteButtonClick=function(e){C.onCompleteTransferButtonClick();if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onCompleteTransfer,[]);else this.callbacks.completeTransfer()};BX.PhoneCallView.prototype._onTransferCancelButtonClick=function(e){C.onCancelTransferButtonClick();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);C.onDialpadButtonClick(i)},onClose:function(e){t.keypad.destroy();t.keypad=null}});t.keypad.show()};BX.PhoneCallView.prototype._onHangupButtonClick=function(e){C.onHangupButtonClick();if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onHangup,[]);else this.callbacks.hangup()};BX.PhoneCallView.prototype._onCloseButtonClick=function(e){C.onCloseButtonClick();if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onClose,[]);else this.close()};BX.PhoneCallView.prototype._onMakeCallButtonClick=function(e){C.onMakeCallButtonClick();var t={};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(){this.keypad.destroy();this.keypad=null}.bind(this),onDial:function(e){this.keypad.close();this.phoneNumber=e.phoneNumber;this.createTitle().then(function(e){this.setTitle(e)}.bind(this));t={phoneNumber:e.phoneNumber,crmEntityType:this.crmEntityType,crmEntityId:this.crmEntityId,callListId:this.callListId};if(this.isDesktop()&&this.slave){BX.desktop.onCustomEvent(o.onCallListMakeCall,[t])}else{this.callbacks.callListMakeCall(t)}}.bind(this)});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){this.closeNumberSelectMenu();this.phoneNumber=e.phoneNumber;this.createTitle().then(function(e){this.setTitle(e)}.bind(this));t={phoneNumber:e.phoneNumber,crmEntityType:this.crmEntityType,crmEntityId:this.crmEntityId,callListId:this.callListId};if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onCallListMakeCall,[t]);else this.callbacks.callListMakeCall(t)}.bind(this)})}}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;C.onNextButtonClick();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.isDesktop()&&this.slave){BX.desktop.onCustomEvent(o.onCommentShown,[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.value=this.comment;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();C.onAddCommentButtonClick(this.comment)}};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);t=BX.util.add_url_param(t,{redirect:"y"});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){C.onAnswerButtonClick();if(this.isDesktop()&&this.slave)BX.desktop.onCustomEvent(o.onAnswer,[]);else this.callbacks.answer()};BX.PhoneCallView.prototype._onSkipButtonClick=function(e){C.onSkipButtonClick();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){C.onQualityMeterClick(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;this.comment="";if(BX.type.isArray(e.bindings)){this.crmBindings=e.bindings.map((function(e){return{ENTITY_TYPE:e.type,ENTITY_ID:e.id}}))}else{this.crmBindings=[]}if(e.phones.length>0)this.phoneNumber=e.phones[0].VALUE;else this.phoneNumber="unknown";this.createTitle().then(this.setTitle.bind(this));this.loadCrmCard(e.type,e.id);if(this.currentTabName==="webform"){this.formManager.unload();this.formManager.load({id:this.webformId,secCode:this.webformSecCode,lang:BX.message("LANGUAGE_ID")})}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.isTimerStarted=function(){return!!this.timerInterval};BX.PhoneCallView.prototype.startTimer=function(){if(this.isTimerStarted()){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.isTimerStarted()){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,{targetContainer:document.body,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.setPortalCallQueueName,this.setPortalCallQueueName.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.setPhoneNumber,this.setPhoneNumber.bind(this));BX.desktop.addCustomEvent(o.setTransfer,this.setTransfer.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.onCompleteTransfer,(function(){e.callbacks.completeTransfer()}));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.onCommentShown,(function(t){e.commentShown=t}));BX.desktop.addCustomEvent(o.onSaveComment,(function(t){e.comment=t;e.saveComment()}));BX.desktop.addCustomEvent(o.onSetAutoClose,(function(t){e.autoClose=t}))};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,[])}C.CallCard=null;this.enableDocumentScroll();this.callbacks.close();BX.onCustomEvent(window,"CallCard::AfterClose",[])};BX.PhoneCallView.prototype.disableAutoClose=function(){this.allowAutoClose=false;if(this.isDesktop()&&this.slave){BX.desktop.onCustomEvent(o.onSetAutoClose,[this.allowAutoClose])}this.renderButtons()};BX.PhoneCallView.prototype.enableAutoClose=function(){this.allowAutoClose=true;if(this.isDesktop()&&this.slave){BX.desktop.onCustomEvent(o.onSetAutoClose,[this.allowAutoClose])}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.isCallListMode=function(){return this.callListId>0};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.prototype.selectTransferTarget=function(e){e=BX.type.isFunction(e)?e:BX.DoNothing;BX.loadExt("ui.entity-selector").then(function(){var t=C.isUsed?this.getDialogConfigForBackgroundApp(e):this.getDefaultDialogConfig(e);var i=new BX.UI.EntitySelector.Dialog(t);i.show()}.bind(this))};BX.PhoneCallView.prototype.getDialogConfigForBackgroundApp=function(e){return{targetNode:this.elements.buttons.transfer,multiple:false,cacheable:false,hideOnSelect:false,enableSearch:true,entities:[{id:"user",options:{inviteEmployeeLink:false,selectFields:["personalPhone","personalMobile","workPhone"]}},{id:"department"}],events:{"Item:onSelect":function(t){t.target.deselectAll();var i=t.data.item;if(i.getEntityId()==="user"){var s=i.getCustomData();if(s.get("personalPhone")||s.get("personalMobile")||s.get("workPhone")){this.showTransferToUserMenu({userId:i.getId(),customData:Object.fromEntries(s),onSelect:function(i){t.target.hide();e({phoneNumber:this.phoneNumber,target:i.target})}})}else{t.target.hide();e({phoneNumber:this.phoneNumber,target:i.getId()})}}}.bind(this)}}};BX.PhoneCallView.prototype.getDefaultDialogConfig=function(e){return{targetNode:this.elements.buttons.transfer,multiple:false,cacheable:false,hideOnSelect:false,enableSearch:true,entities:[{id:"user",options:{inviteEmployeeLink:false,selectFields:["personalPhone","personalMobile","workPhone"]}},{id:"department"},{id:"voximplant_group"}],events:{"Item:onSelect":function(t){t.target.deselectAll();var i=t.data.item;if(i.getEntityId()==="user"){var s=i.getCustomData();if(s.get("personalPhone")||s.get("personalMobile")||s.get("workPhone")){this.showTransferToUserMenu({userId:i.getId(),customData:Object.fromEntries(s),onSelect:function(i){t.target.hide();e({type:i.type,target:i.target})}})}else{t.target.hide();e({type:"user",target:i.getId()})}}else if(i.getEntityId()==="voximplant_group"){t.target.hide();e({type:"queue",target:i.getId()})}}.bind(this)}}};BX.PhoneCallView.prototype.showTransferToUserMenu=function(e){var t=BX.prop.getInteger(e,"userId",0);var i=BX.prop.getObject(e,"customData",{});var s=BX.prop.getFunction(e,"onSelect",BX.DoNothing);var n;var o=function(e){var t=e.currentTarget.dataset["type"];var i=e.currentTarget.dataset["target"];s({type:t,target:i});n.close()};var l=[{icon:"bx-messenger-menu-call-voice",text:BX.message("IM_PHONE_INNER_CALL"),dataset:{type:"user",target:t},onclick:o},{separator:true}];if(i["personalMobile"]){l.push({type:"call",text:BX.message("IM_PHONE_PERSONAL_MOBILE"),phone:BX.util.htmlspecialchars(i["personalMobile"]),dataset:{type:"pstn",target:i["personalMobile"]},onclick:o})}if(i["personalPhone"]){l.push({type:"call",text:BX.message("IM_PHONE_PERSONAL_PHONE"),phone:BX.util.htmlspecialchars(i["personalPhone"]),dataset:{type:"pstn",target:i["personalPhone"]},onclick:o})}if(i["workPhone"]){l.push({type:"call",text:BX.message("IM_PHONE_WORK_PHONE"),phone:BX.util.htmlspecialchars(i["workPhone"]),dataset:{type:"pstn",target:i["workPhone"]},onclick:o})}var a=BX.create("div",{props:{className:"bx-messenger-popup-menu"},children:[BX.create("div",{props:{className:"bx-messenger-popup-menu-items"},children:BX.MessengerChat.MenuPrepareList(l)})]});n=new BX.PopupWindow("bx-messenger-phone-transfer-menu",null,{targetContainer:document.body,darkMode:this.BXIM.settings.enableDarkTheme,lightShadow:true,autoHide:true,closeByEsc:true,cacheable:false,overlay:{backgroundColor:"#FFFFFF",opacity:0},content:a});n.show()};BX.PhoneCallView.initializeBackgroundAppPlacement=function(e){C.initializePlacement(e)};BX.PhoneCallView.Direction={incoming:"incoming",outgoing:"outgoing",callback:"callback"};BX.PhoneCallView.UiState={incoming:1,transferIncoming:2,outgoing:3,connectingIncoming:4,connectingOutgoing:5,connected:6,transferring:7,transferFailed:8,transferConnected:9,idle:10,error:11,moneyError:12,sipPhoneError:13,redial:14,externalCard:15};BX.PhoneCallView.CallState={idle:"idle",connecting:"connecting",connected:"connected"};var r={iframe:39};var h=function(e){this.BXIM=e.BXIM;this.parentPhoneCallView=e.parentPhoneCallView;this.closable=e.closable;this.title=e.title||"";this.window=null};h.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))};h.prototype.setClosable=function(e){this.closable=e==true;if(this.window){this.window.SetProperty("closable",this.closable)}};h.prototype.setTitle=function(e){this.title=e;if(this.window)this.window.SetProperty("title",e)};h.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+","+"'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>"};h.prototype.addCustomEvent=function(e,t){if(!BX.MessengerCommon.isDesktop())return false;BX.desktop.addCustomEvent(e,t)};h.prototype.onCustomEvent=function(e,t,i){if(!BX.MessengerCommon.isDesktop())return false;BX.desktop.onCustomEvent(e,t,i)};h.prototype.resize=function(e,t){BXDesktopWindow.SetProperty("clientSize",{Width:e,Height:t})};h.prototype.setResizable=function(e){e=e==true;BXDesktopWindow.SetProperty("resizable",e)};h.prototype.setMinSize=function(e,t){BXDesktopWindow.SetProperty("minClientSize",{Width:e,Height:t})};h.prototype.setWindowPosition=function(e){BXDesktopWindow.SetProperty("position",e)};h.prototype.center=function(){BXDesktopWindow.ExecuteCommand("center")};h.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]};h.prototype.isFeatureSupported=function(e){if(!r.hasOwnProperty(e))return false;return this.getVersion()>=r[e]};var c=function(t){this.node=t.node;this.id=t.id;this.entityType="";this.statuses=new Map;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(){const i=t.statuses.get(t.currentStatusId);if(i&&i.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){e.ITEMS=[];t.statuses.set(e.STATUS_ID,e)}));i.ITEMS.forEach((function(e){let i=t.statuses.get(e.STATUS_ID);if(i){i.ITEMS.push(e)}}))}t.entityType=i.ENTITY_TYPE;let s=t.statuses.get(t.currentStatusId);if(s&&s.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.get(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.get(this.currentStatusId).ITEMS[this.currentItemIndex]._node;BX.addClass(i,"im-phone-call-list-customer-block-active");var s=this.statuses.get(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,bindings:[{type:this.entityType,id:s.ELEMENT_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.get(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.get(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.get(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=[];for(let[t,i]of this.statuses){if(!i||i.ITEMS.length===0)continue;i._node=this.renderStatusBlock(i);e.push(i._node)}return e};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.get(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.get(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.get(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(let[t,i]of this.statuses){o={id:"setStatus_"+t,text:i.NAME,onclick:this.actionMenuItemClickHandler(e.ELEMENT_ID,t).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(let[e,t]of this.statuses){t.ITEMS=[]}e.forEach((function(e){t.statuses.get(e.STATUS_ID).ITEMS.push(e)}));if(this.statuses.get(this.currentStatusId).ITEMS.length===0){this.currentStatusId=this.getNonEmptyStatusId();this.currentItemIndex=0}else{if(this.currentItemIndex>=this.statuses.get(this.currentStatusId).ITEMS.length)this.currentItemIndex=0}this.selectItem(this.currentStatusId,this.currentItemIndex)};c.prototype.getNonEmptyStatusId=function(){var e=false;for(let[t,i]of this.statuses){if(i.ITEMS.length>0){e=t;break}}return e};c.prototype.getCurrentElement=function(){return this.statuses.get(this.currentStatusId).ITEMS[this.currentItemIndex]};c.prototype.getStatusTitle=function(e){var t=this.statuses.get(e).ITEMS.length;return BX.util.htmlspecialchars(this.statuses.get(e).NAME)+" ("+t.toString()+")"};var d=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(d==null)d=new BX.FoldedCallView;return d};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 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={targetContainer:document.body,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(e.popup){e.popup.destroy()}}}};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.key==="+"||e.key==="#"||e.key==="*"){}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){f(this.elements.input,e.key);e.preventDefault();this.callbacks.onButtonClick({key:e.key})}else if(e.keyCode>=96&&e.keyCode<=105&&!e.shiftKey){f(this.elements.input,e.key);e.preventDefault();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(){if(!l.callInterceptAllowed){this.close();if("UI"in BX&&"InfoHelper"in BX.UI){BX.UI.InfoHelper.show("limit_contact_center_telephony_intercept")}return}BX.MessengerCommon.phoneCommand("interceptCall",{},true,function(e){if(!e.FOUND||e.FOUND=="Y"){this.close()}else{if(e.ERROR){this.interceptErrorPopup=new BX.PopupWindow("intercept-call-error",this.elements.interceptButton,{targetContainer:document.body,content:BX.util.htmlspecialchars(e.ERROR),autoHide:true,closeByEsc:true,bindOptions:{position:"bottom"},angle:{offset:40},zIndex:this.zIndex+100,events:{onPopupClose:function(e){this.interceptErrorPopup.destroy()}.bind(this),onPopupDestroy:function(e){this.interceptErrorPopup=null}.bind(this)}});this.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){i.plusEntered=false;this.plusKeyTimeout=setTimeout((function(){if(!i.elements.input.value.startsWith("+")){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){f(this.elements.input,"0")}this.plusEntered=false}else{f(this.elements.input,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},maxHeight:600,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)};const C={CallCard:null,isUsed:false,UndefinedCallCard:{result:"error",errorCode:"Call card is undefined"},initializePlacement:function(){var e=BX.rest.AppLayout.initializePlacement("PAGE_BACKGROUND_WORKER");this.initializeInterface(e)},initializeInterface:function(e){if(this.isDesktop()){this.initializeDesktopInterfaceMethods(e);this.bindDesktopEvents();this.addDesktopEventHandlers()}else{this.initializeBrowserInterfaceMethods(e)}this.initializeInterfaceEvents(e)},initializeBrowserInterfaceMethods:function(e){e.prototype.CallCardSetMute=(e,t)=>this.setMute(e,t);e.prototype.CallCardSetHold=(e,t)=>this.setHold(e,t);e.prototype.CallCardSetUiState=(e,t)=>this.setUiState(e,t);e.prototype.CallCardGetListUiStates=(e,t)=>this.getListUiStates(e,t);e.prototype.CallCardSetCardTitle=(e,t)=>this.setCardTitle(e,t);e.prototype.CallCardSetStatusText=(e,t)=>this.setStatusText(e,t);e.prototype.CallCardClose=(e,t)=>this.close(e,t);e.prototype.CallCardStartTimer=(e,t)=>this.startTimer(e,t);e.prototype.CallCardStopTimer=(e,t)=>this.stopTimer(e,t)},initializeDesktopInterfaceMethods:function(e){e.prototype.CallCardSetMute=(e,t)=>this.desktop.setMute(e,t);e.prototype.CallCardSetHold=(e,t)=>this.desktop.setHold(e,t);e.prototype.CallCardSetUiState=(e,t)=>this.desktop.setUiState(e,t);e.prototype.CallCardGetListUiStates=(e,t)=>this.desktop.getListUiStates(e,t);e.prototype.CallCardSetCardTitle=(e,t)=>this.desktop.setCardTitle(e,t);e.prototype.CallCardSetStatusText=(e,t)=>this.desktop.setStatusText(e,t);e.prototype.CallCardClose=(e,t)=>this.desktop.close(e,t);e.prototype.CallCardStartTimer=(e,t)=>this.desktop.startTimer(e,t);e.prototype.CallCardStopTimer=(e,t)=>this.desktop.stopTimer(e,t)},initializeInterfaceEvents:function(e){e.prototype.events.push("BackgroundCallCard::initialized");e.prototype.events.push("BackgroundCallCard::addCommentButtonClick");e.prototype.events.push("BackgroundCallCard::muteButtonClick");e.prototype.events.push("BackgroundCallCard::holdButtonClick");e.prototype.events.push("BackgroundCallCard::closeButtonClick");e.prototype.events.push("BackgroundCallCard::transferButtonClick");e.prototype.events.push("BackgroundCallCard::cancelTransferButtonClick");e.prototype.events.push("BackgroundCallCard::completeTransferButtonClick");e.prototype.events.push("BackgroundCallCard::hangupButtonClick");e.prototype.events.push("BackgroundCallCard::nextButtonClick");e.prototype.events.push("BackgroundCallCard::skipButtonClick");e.prototype.events.push("BackgroundCallCard::answerButtonClick");e.prototype.events.push("BackgroundCallCard::entityChanged");e.prototype.events.push("BackgroundCallCard::qualityMeterClick");e.prototype.events.push("BackgroundCallCard::dialpadButtonClick");e.prototype.events.push("BackgroundCallCard::makeCallButtonClick");e.prototype.events.push("BackgroundCallCard::notifyAdminButtonClick")},bindDesktopEvents:function(){if(!this.desktop.isCorporatePortalPage()){return}for(const e of this.events){this.desktop.addCustomEvent("DesktopCallCard"+(e[0].toUpperCase()+e.slice(1)),(function(t,i){BX.onCustomEvent(window,"BackgroundCallCard::"+e,[t,i])}))}this.desktop.addCustomEvent("DesktopCallCardInitialized",(function(e,t){if(!C.CallCard){C.CallCard=true}BX.onCustomEvent(window,"BackgroundCallCard::initialized",[e,t])}));this.desktop.addCustomEvent("DesktopCallCardCloseButtonClick",(function(e,t){C.CallCard=false;BX.onCustomEvent(window,"BackgroundCallCard::closeButtonClick",[e,t])}))},addDesktopEventHandlers:function(){this.desktop.addCustomEvent("DesktopCallCardSetUiState",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;const i=this.desktop.getCallCardWindow();i.BX.PhoneCallView.BackgroundWorker.setUiState(e,t)}));this.desktop.addCustomEvent("DesktopCallCardSetMute",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;const i=this.desktop.getCallCardWindow();i.BX.PhoneCallView.BackgroundWorker.setMute(e,t)}));this.desktop.addCustomEvent("DesktopCallCardSetHold",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;const i=this.desktop.getCallCardWindow();i.BX.PhoneCallView.BackgroundWorker.setHold(e,t)}));this.desktop.addCustomEvent("DesktopCallCardGetListUiState",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;this.getListUiStates(e,t)}));this.desktop.addCustomEvent("DesktopCallCardSetCardTitle",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;const i=this.desktop.getCallCardWindow();i.BX.PhoneCallView.BackgroundWorker.setCardTitle(e,t)}));this.desktop.addCustomEvent("DesktopCallCardSetStatusText",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;const i=this.desktop.getCallCardWindow();i.BX.PhoneCallView.BackgroundWorker.setStatusText(e,t)}));this.desktop.addCustomEvent("DesktopCallCardClose",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;const i=this.desktop.getCallCardWindow();this.close(e,t)}));this.desktop.addCustomEvent("DesktopCallCardStartTimer",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;const i=this.desktop.getCallCardWindow();i.BX.PhoneCallView.BackgroundWorker.startTimer(e,t)}));this.desktop.addCustomEvent("DesktopCallCardStopTimer",((e,t)=>{if(this.isDesktop()&&this.desktop.isCorporatePortalPage()){return}this.isUsed=true;t=typeof t==="function"?t:BX.DoNothing;const i=this.desktop.getCallCardWindow();i.BX.PhoneCallView.BackgroundWorker.stopTimer(e,t)}))},events:["addCommentButtonClick","muteButtonClick","holdButtonClick","transferButtonClick","cancelTransferButtonClick","completeTransferButtonClick","hangupButtonClick","nextButtonClick","skipButtonClick","answerButtonClick","entityChanged","qualityMeterClick","dialpadButtonClick","makeCallButtonClick","notifyAdminButtonClick"],desktop:{eventHandlers:[],setUiState:function(e,t){if(!C.CallCard){t(C.UndefinedCallCard);return}if(!e.hasOwnProperty("uiState")||!BX.PhoneCallView.UiState[e.uiState]){t([{result:"error",errorCode:"Invalid ui state"}]);return}BXDesktopSystem.BroadcastEvent("DesktopCallCardSetUiState",[e,BX.DoNothing]);t([])},setMute:function(e,t){if(!C.CallCard){t(C.UndefinedCallCard);return}if(!e.hasOwnProperty("muted")){t({result:"error",errorCode:"missing field muted"});return}BXDesktopSystem.BroadcastEvent("DesktopCallCardSetMute",[e,BX.DoNothing]);t([])},setHold:function(e,t){if(!C.CallCard){t(C.UndefinedCallCard);return}if(!e.hasOwnProperty("held")){t([{result:"error",errorCode:"missing field held"}])}BXDesktopSystem.BroadcastEvent("DesktopCallCardSetHold",[e,BX.DoNothing]);t([])},getListUiStates:function(e,t){C.getListUiStates(e,t)},setCardTitle:function(e,t){if(!C.CallCard){t(C.UndefinedCallCard);return}if(!e.hasOwnProperty("title")){t([{result:"error",errorCode:"missing field title"}]);return}BXDesktopSystem.BroadcastEvent("DesktopCallCardSetCardTitle",[e,BX.DoNothing]);t([])},setStatusText:function(e,t){if(!C.CallCard){t(C.UndefinedCallCard);return}if(!e.hasOwnProperty("statusText")){t([{result:"error",errorCode:"missing field statusText"}]);return}BXDesktopSystem.BroadcastEvent("DesktopCallCardSetStatusText",[e,BX.DoNothing]);t([])},close:function(e,t){if(!C.CallCard){t(C.UndefinedCallCard);return}C.CallCard=false;BXDesktopSystem.BroadcastEvent("DesktopCallCardClose",[e,BX.DoNothing]);t([])},startTimer:function(e,t){if(!C.CallCard){t(C.UndefinedCallCard);return}BXDesktopSystem.BroadcastEvent("DesktopCallCardStartTimer",[e,BX.DoNothing]);t([])},stopTimer:function(e,t){if(!C.CallCard){t(C.UndefinedCallCard);return}BXDesktopSystem.BroadcastEvent("DesktopCallCardStopTimer",[e,BX.DoNothing]);t([])},addCustomEvent:function(e,t){const i=function(e){const i=[];for(const t in e.detail){i.push(e.detail[t])}t.apply(window,i)};if(!this.eventHandlers[e]){this.eventHandlers[e]=[]}this.eventHandlers[e].push(i);window.addEventListener(e,i);return true},removeCustomEvents:function(e){if(!this.eventHandlers[e]){return false}this.eventHandlers[e].forEach((function(t){window.removeEventListener(e,t)}));this.eventHandlers[e]=[]},isCallCardPage:function(){return BXDesktopWindow.GetWindowId()!==BXDesktopSystem.GetMainWindow().GetWindowId()},isCorporatePortalPage:function(){return!BX.MessengerCommon.isDesktop()},getCallCardWindow:function(){return BXWindows.find((e=>e.name==="callWindow"))}},removeDesktopEventHandlers:function(){for(const e of this.events){this.desktop.removeCustomEvents("DesktopCallCard"+(e[0].toUpperCase()+e.slice(1)))}this.desktop.removeCustomEvents("DesktopCallCardInitialized");this.desktop.removeCustomEvents("DesktopCallCardCloseButtonClick")},onInitialize:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardInitialized",[e]);return}BX.onCustomEvent(window,"BackgroundCallCard::initialized",[e])},onAddCommentButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardAddCommentButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::addCommentButtonClick",[e])},onMuteButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardMuteButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::muteButtonClick",[e])},onHoldButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardHoldButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::holdButtonClick",[e])},onCloseButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardCloseButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::closeButtonClick",[e])},onTransferButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardTransferButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::transferButtonClick",[e])},onCancelTransferButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardCancelTransferButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::cancelTransferButtonClick",[e])},onCompleteTransferButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardCompleteTransferButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::completeTransferButtonClick",[e])},onHangupButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardHangupButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::hangupButtonClick",[e])},onNextButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardNextButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::nextButtonClick",[e])},onSkipButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardSkipButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::skipButtonClick",[e])},onAnswerButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardAnswerButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::answerButtonClick",[e])},onEntityChanged:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardEntityChanged",[e])}BX.onCustomEvent(window,"BackgroundCallCard::entityChanged",[e])},onQualityMeterClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardQualityMeterClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::qualityMeterClick",[e])},onDialpadButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardDialpadButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::dialpadButtonClick",[e])},onMakeCallButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardMakeCallButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::makeCallButtonClick",[e])},onNotifyAdminButtonClick:function(e){if(this.isDesktop()&&this.desktop.isCallCardPage()){BXDesktopSystem.BroadcastEvent("DesktopCallCardNotifyAdminButtonClick",[e])}BX.onCustomEvent(window,"BackgroundCallCard::notifyAdminButtonClick",[e])},setMute:function(e,t){if(!this.CallCard){t(this.UndefinedCallCard);return}if(this.CallCard.isMuted()===!!e.muted){t([]);return}if(e.muted){this.CallCard.setMuted(e.muted);BX.addClass(this.CallCard.elements.buttons.mute,"active");if(this.CallCard.isDesktop()&&this.CallCard.slave){BX.desktop.onCustomEvent(o.onMute,[])}else{this.CallCard.callbacks.mute()}}else{this.CallCard.setMuted(e.muted);BX.removeClass(this.CallCard.elements.buttons.mute,"active");if(this.CallCard.isDesktop()&&this.CallCard.slave){BX.desktop.onCustomEvent(o.onUnMute,[])}else{this.CallCard.callbacks.unmute()}}t([])},setHold:function(e,t){if(!this.CallCard){t([this.UndefinedCallCard]);return}if(this.CallCard.isHeld()===!!e.held){t([]);return}if(e.held){this.CallCard.setHeld(e.held);BX.addClass(this.CallCard.elements.buttons.hold,"active");if(this.CallCard.isDesktop()&&this.CallCard.slave){BX.desktop.onCustomEvent(o.onHold,[])}else{this.CallCard.callbacks.hold()}}else{this.CallCard.setHeld(e.held);BX.removeClass(this.CallCard.elements.buttons.hold,"active");if(this.CallCard.isDesktop()&&this.CallCard.slave){BX.desktop.onCustomEvent(o.onUnHold,[])}else{this.CallCard.callbacks.unhold()}}t([])},setUiState:function(e,t){if(!this.CallCard){t([this.UndefinedCallCard]);return}if(e&&e.uiState&&BX.PhoneCallView.UiState[e.uiState]){this.CallCard.setUiState(BX.PhoneCallView.UiState[e.uiState])}else{t([{result:"error",errorCode:"Invalid ui state"}]);return}if(e.uiState==="connected"){if(e.disableAutoStartTimer){this.CallCard.stopTimer();this.hideTimer()}else{this.showTimer()}}if(e.uiState!=="connected"&&!this.CallCard.isTimerStarted()){this.hideTimer()}t([])},getListUiStates:function(e,t){t(Object.keys(BX.PhoneCallView.UiState).filter((function(e){switch(e){case"sipPhoneError":return false;case"idle":return false;case"externalCard":return false;default:return true}})))},startTimer:function(e,t){if(!this.CallCard){t([this.UndefinedCallCard]);return}this.showTimer();this.CallCard.startTimer()},stopTimer:function(e,t){if(!this.CallCard){t([this.UndefinedCallCard]);return}this.CallCard.stopTimer()},close:function(e,t){if(!this.CallCard){t([this.UndefinedCallCard]);return}this.CallCard.close();t([]);this.CallCard=false},setCardTitle:function(e,t){if(!this.CallCard){t([this.UndefinedCallCard]);return}this.CallCard.setTitle(e.title);t([])},setStatusText:function(e,t){if(!this.CallCard){t([this.UndefinedCallCard]);return}this.CallCard.setStatusText(e.statusText);t([])},showTimer:function(){if(!BX.PhoneCallView.BackgroundWorker.CallCard.elements.timer.visible){BX.PhoneCallView.BackgroundWorker.CallCard.sections.timer.visible=true;BX.PhoneCallView.BackgroundWorker.CallCard.elements.timer.style.display="";if(BX.PhoneCallView.BackgroundWorker.CallCard.isFolded()){BX.PhoneCallView.BackgroundWorker.CallCard.unfoldedElements.timer.style.display=""}}},hideTimer:function(){if(this.CallCard.sections.timer){this.CallCard.sections.timer.visible=false}if(this.CallCard.elements.timer){this.CallCard.elements.timer.style.display="none"}this.CallCard.initialTimestamp=0},isDesktop:function(){return typeof BXDesktopSystem!=="undefined"}};BX.PhoneCallView.BackgroundWorker=C;function f(e,t){if(e.selectionStart||e.selectionStart=="0"){var i=e.selectionStart;var s=e.selectionEnd;e.value=e.value.substring(0,i)+t+e.value.substring(s,e.value.length);e.selectionStart=i+t.length;e.selectionEnd=i+t.length}else{e.value+=t}}})(); //# sourceMappingURL=phone_call_view.map.js
/var/www/axolotl/data/www/./b24.axolotl.ru/public_html/bitrix/js/im/phone_call_view.min.js