403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/call/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/call/controller.min.js
(function(){BX.namespace("BX.Call");if(BX.Call.Controller){return}const e={onViewStateChanged:"onViewStateChanged"};const t={Opened:"Opened",Closed:"Closed",Folded:"Folded"};const i={Resume:"resume",Blank:"blank"};const l=961;const s=328;const o="CallController::documentCreated";const n="im:call-document:16102021:web";const a=5*60*1e3;const r="im:mask:06122022:desktop";const c=5*60*1e3;const h="docx";const d="xlsx";const u="pptx";class C{constructor(e){const i=BX.prop.getBoolean(e,"init",true);this.messenger=e.messenger;this.inited=false;this.container=null;this.docEditor=null;this.docEditorIframe=null;this.maxEditorWidth=s;this.docCreatedForCurrentCall=false;this.folded=false;this.currentCall=null;this.childCall=null;this.callView=null;this.callNotification=null;this.invitePopup=null;this.videoStrategy=null;this.isHttps=window.location.protocol==="https:";this.callWithLegacyMobile=false;this.featureScreenSharing=BX.Call.Controller.FeatureState.Enabled;this.featureRecord=BX.Call.Controller.FeatureState.Enabled;this.callRecordState=BX.Call.View.RecordState.Stopped;this.callRecordType=BX.Call.View.RecordType.None;this.autoCloseCallView=true;this.talkingUsers={};this._callViewState=t.Closed;this._onCallUserInvitedHandler=this._onCallUserInvited.bind(this);this._onCallDestroyHandler=this._onCallDestroy.bind(this);this._onCallUserStateChangedHandler=this._onCallUserStateChanged.bind(this);this._onCallUserMicrophoneStateHandler=this._onCallUserMicrophoneState.bind(this);this._onCallUserCameraStateHandler=this._onCallUserCameraState.bind(this);this._onCallUserVideoPausedHandler=this._onCallUserVideoPaused.bind(this);this._onCallLocalMediaReceivedHandler=this._onCallLocalMediaReceived.bind(this);this._onCallLocalMediaStoppedHandler=this._onCallLocalMediaStopped.bind(this);this._onCallLocalCameraFlipHandler=this._onCallLocalCameraFlip.bind(this);this._onCallLocalCameraFlipInDesktopHandler=this._onCallLocalCameraFlipInDesktop.bind(this);this._onCallRemoteMediaReceivedHandler=this._onCallRemoteMediaReceived.bind(this);this._onCallRemoteMediaStoppedHandler=this._onCallRemoteMediaStopped.bind(this);this._onCallUserVoiceStartedHandler=this._onCallUserVoiceStarted.bind(this);this._onCallUserVoiceStoppedHandler=this._onCallUserVoiceStopped.bind(this);this._onCallUserScreenStateHandler=this._onCallUserScreenState.bind(this);this._onCallUserRecordStateHandler=this._onCallUserRecordState.bind(this);this.onCallUserFloorRequestHandler=this._onCallUserFloorRequest.bind(this);this._onCallFailureHandler=this._onCallFailure.bind(this);this._onNetworkProblemHandler=this._onNetworkProblem.bind(this);this._onMicrophoneLevelHandler=this._onMicrophoneLevel.bind(this);this._onReconnectingHandler=this._onReconnecting.bind(this);this._onReconnectedHandler=this._onReconnected.bind(this);this._onCustomMessageHandler=this._onCustomMessage.bind(this);this._onJoinRoomOfferHandler=this._onJoinRoomOffer.bind(this);this._onJoinRoomHandler=this._onJoinRoom.bind(this);this._onLeaveRoomHandler=this._onLeaveRoom.bind(this);this._onTransferRoomSpeakerHandler=this._onTransferRoomSpeaker.bind(this);this._onCallLeaveHandler=this._onCallLeave.bind(this);this._onCallJoinHandler=this._onCallJoin.bind(this);this._onBeforeUnloadHandler=this._onBeforeUnload.bind(this);this._onImTabChangeHandler=this._onImTabChange.bind(this);this._onUpdateChatCounterHandler=this._onUpdateChatCounter.bind(this);this._onChildCallFirstMediaHandler=this._onChildCallFirstMedia.bind(this);this._onWindowFocusHandler=this._onWindowFocus.bind(this);this._onWindowBlurHandler=this._onWindowBlur.bind(this);if(BX.desktop&&false){this.floatingWindow=new BX.Call.FloatingVideo({onMainAreaClick:this._onFloatingVideoMainAreaClick.bind(this),onButtonClick:this._onFloatingVideoButtonClick.bind(this)});this.floatingWindowUser=0}this.showFloatingWindowTimeout=0;this.hideIncomingCallTimeout=0;if(BX.desktop){const e=!!BX.MessengerTheme.isDark();this.floatingScreenShareWindow=new BX.Call.FloatingScreenShare({darkMode:e,onBackToCallClick:this._onFloatingScreenShareBackToCallClick.bind(this),onStopSharingClick:this._onFloatingScreenShareStopClick.bind(this),onChangeScreenClick:this._onFloatingScreenShareChangeScreenClick.bind(this)})}this.showFloatingScreenShareWindowTimeout=0;this.mutePopup=null;this.allowMutePopup=true;this.webScreenSharePopup=null;this.feedbackPopup=null;this.eventEmitter=new BX.Event.EventEmitter(this,"BX.Call.Controller");this.resizeObserver=new BX.ResizeObserver(this._onResize.bind(this));if(i){this.init()}}get userId(){return Number(BX.message("USER_ID"))}get callViewState(){return this._callViewState}set callViewState(t){if(this.callViewState==t){return}this._callViewState=t;this.eventEmitter.emit(e.onViewStateChanged,{callViewState:t})}init(){BX.addCustomEvent(window,"CallEvents::incomingCall",this.onIncomingCall.bind(this));BX.Call.Hardware.subscribe(BX.Call.Hardware.Events.deviceChanged,this._onDeviceChange.bind(this));BX.Call.Hardware.subscribe(BX.Call.Hardware.Events.onChangeMirroringVideo,this._onCallLocalCameraFlipHandler);if(BX.desktop&&this.floatingWindow){window.addEventListener("blur",this._onWindowBlurHandler);window.addEventListener("focus",this._onWindowFocusHandler);BX.desktop.addCustomEvent("BXForegroundChanged",(e=>{if(e){this._onWindowFocus()}else{this._onWindowBlur()}}))}if(BX.desktop&&this.floatingScreenShareWindow){BX.desktop.addCustomEvent("BXScreenMediaSharing",((e,t,i,l,s,o,n)=>{this.floatingScreenShareWindow.close();this.floatingScreenShareWindow.setSharingData({title:t,x:i,y:l,width:s,height:o,app:n}).then((()=>{this.floatingScreenShareWindow.show()})).catch((e=>{console.error("setSharingData error",e)}))}));window.addEventListener("blur",this._onWindowBlurHandler);window.addEventListener("focus",this._onWindowFocusHandler);BX.desktop.addCustomEvent("BXForegroundChanged",(e=>{if(e){this._onWindowFocus()}else{this._onWindowBlur()}}))}if(BX.desktop){BX.desktop.addCustomEvent(BX.Call.Hardware.Events.onChangeMirroringVideo,this._onCallLocalCameraFlipInDesktopHandler)}if(window["VoxImplant"]){VoxImplant.getInstance().addEventListener(VoxImplant.Events.MicAccessResult,this.voxMicAccessResult.bind(this))}window.addEventListener("beforeunload",this._onBeforeUnloadHandler);BX.addCustomEvent("OnDesktopTabChange",this._onImTabChangeHandler);BX.addCustomEvent(window,"onImUpdateCounterMessage",this._onUpdateChatCounter.bind(this));BX.garbage(this.destroy,this);this.inited=true}subscribe(e,t){return this.eventEmitter.subscribe(e,t)}unsubscribe(e,t){return this.eventEmitter.unsubscribe(e,t)}voxMicAccessResult(e){if(e.stream&&e.stream.getAudioTracks().length>0&&this.callView){this.callView.microphoneId=e.stream.getAudioTracks()[0].getSettings().deviceId}}getCallUsers(e){const t=Object.keys(this.currentCall.getUsers());if(e){t.push(this.currentCall.userId)}return t}getActiveCallUsers(){const e=this.currentCall.getUsers();let t=[];for(let i in e){if(e.hasOwnProperty(i)){if(e[i]===BX.Call.UserState.Connected||e[i]===BX.Call.UserState.Connecting||e[i]===BX.Call.UserState.Calling){t.push(i)}}}return t}updateFloatingWindowContent(){if(!this.floatingWindow||!this.currentCall){return}this.floatingWindow.setTitle(this.currentCall.associatedEntity.name);BX.Call.Util.getUserAvatars(this.currentCall.id,this.getActiveCallUsers()).then((e=>{this.floatingWindow.setAvatars(e)}))}onIncomingCall(e){console.warn("incoming.call",e);const t=e.call;const i=this.currentCall&&(this.callView||this.callNotification);this.callWithLegacyMobile=e.isLegacyMobile===true;if(!i){if(this.callView){return}this.checkDesktop().then((()=>{BX.Call.Hardware.init();if(this.currentCall||t.state==BX.Call.State.Finished){return}this.currentCall=t;this.bindCallEvents();this.updateFloatingWindowContent();if(this.currentCall.associatedEntity.type==="chat"&&this.currentCall.associatedEntity.advanced["chatType"]==="videoconf"){this.isConferencePageOpened(this.currentCall.associatedEntity.id).then((e=>{if(e){this.removeCallEvents();this.currentCall=null}else{this.showIncomingConference()}}))}else{let t=e.video===true;this.showIncomingCall({video:t});BX.Call.Hardware.init().then((()=>{if(!BX.Call.Hardware.hasCamera()){if(t){this.showNotification(BX.message("IM_CALL_ERROR_NO_CAMERA"))}if(this.callNotification){this.callNotification.setHasCamera(false)}}}))}}),(e=>{if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall=null}console.error(e);this.log(e);if(!this.isHttps){this.showNotification(BX.message("IM_CALL_INCOMING_ERROR_HTTPS_REQUIRED"))}else{this.showNotification(BX.message("IM_CALL_INCOMING_UNSUPPORTED_BROWSER"))}}))}else{if(t.id==this.currentCall.id){}else if(t.parentId==this.currentCall.id){if(!this.childCall){this.childCall=t;this.childCall.users.forEach((e=>this.callView.addUser(e,BX.Call.UserState.Calling)));this.updateCallViewUsers(t.id,this.childCall.users);this.answerChildCall()}}else{t.decline(486);return false}}}bindCallEvents(){this.currentCall.addEventListener(BX.Call.Event.onUserInvited,this._onCallUserInvitedHandler);this.currentCall.addEventListener(BX.Call.Event.onDestroy,this._onCallDestroyHandler);this.currentCall.addEventListener(BX.Call.Event.onUserStateChanged,this._onCallUserStateChangedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserMicrophoneState,this._onCallUserMicrophoneStateHandler);this.currentCall.addEventListener(BX.Call.Event.onUserCameraState,this._onCallUserCameraStateHandler);this.currentCall.addEventListener(BX.Call.Event.onUserVideoPaused,this._onCallUserVideoPausedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserScreenState,this._onCallUserScreenStateHandler);this.currentCall.addEventListener(BX.Call.Event.onUserRecordState,this._onCallUserRecordStateHandler);this.currentCall.addEventListener(BX.Call.Event.onUserFloorRequest,this.onCallUserFloorRequestHandler);this.currentCall.addEventListener(BX.Call.Event.onLocalMediaReceived,this._onCallLocalMediaReceivedHandler);this.currentCall.addEventListener(BX.Call.Event.onLocalMediaStopped,this._onCallLocalMediaStoppedHandler);this.currentCall.addEventListener(BX.Call.Event.onRemoteMediaReceived,this._onCallRemoteMediaReceivedHandler);this.currentCall.addEventListener(BX.Call.Event.onRemoteMediaStopped,this._onCallRemoteMediaStoppedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserVoiceStarted,this._onCallUserVoiceStartedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserVoiceStopped,this._onCallUserVoiceStoppedHandler);this.currentCall.addEventListener(BX.Call.Event.onCallFailure,this._onCallFailureHandler);this.currentCall.addEventListener(BX.Call.Event.onNetworkProblem,this._onNetworkProblemHandler);this.currentCall.addEventListener(BX.Call.Event.onMicrophoneLevel,this._onMicrophoneLevelHandler);this.currentCall.addEventListener(BX.Call.Event.onReconnecting,this._onReconnectingHandler);this.currentCall.addEventListener(BX.Call.Event.onReconnected,this._onReconnectedHandler);this.currentCall.addEventListener(BX.Call.Event.onCustomMessage,this._onCustomMessageHandler);this.currentCall.addEventListener(BX.Call.Event.onJoinRoomOffer,this._onJoinRoomOfferHandler);this.currentCall.addEventListener(BX.Call.Event.onJoinRoom,this._onJoinRoomHandler);this.currentCall.addEventListener(BX.Call.Event.onLeaveRoom,this._onLeaveRoomHandler);this.currentCall.addEventListener(BX.Call.Event.onTransferRoomSpeaker,this._onTransferRoomSpeakerHandler);this.currentCall.addEventListener(BX.Call.Event.onJoin,this._onCallJoinHandler);this.currentCall.addEventListener(BX.Call.Event.onLeave,this._onCallLeaveHandler)}removeCallEvents(){this.currentCall.removeEventListener(BX.Call.Event.onUserInvited,this._onCallUserInvitedHandler);this.currentCall.removeEventListener(BX.Call.Event.onDestroy,this._onCallDestroyHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserStateChanged,this._onCallUserStateChangedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserMicrophoneState,this._onCallUserMicrophoneStateHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserCameraState,this._onCallUserCameraStateHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserVideoPaused,this._onCallUserVideoPausedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserScreenState,this._onCallUserScreenStateHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserRecordState,this._onCallUserRecordStateHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserFloorRequest,this.onCallUserFloorRequestHandler);this.currentCall.removeEventListener(BX.Call.Event.onLocalMediaReceived,this._onCallLocalMediaReceivedHandler);this.currentCall.removeEventListener(BX.Call.Event.onLocalMediaStopped,this._onCallLocalMediaStoppedHandler);this.currentCall.removeEventListener(BX.Call.Event.onRemoteMediaReceived,this._onCallRemoteMediaReceivedHandler);this.currentCall.removeEventListener(BX.Call.Event.onRemoteMediaStopped,this._onCallRemoteMediaStoppedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserVoiceStarted,this._onCallUserVoiceStartedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserVoiceStopped,this._onCallUserVoiceStoppedHandler);this.currentCall.removeEventListener(BX.Call.Event.onCallFailure,this._onCallFailureHandler);this.currentCall.removeEventListener(BX.Call.Event.onNetworkProblem,this._onNetworkProblemHandler);this.currentCall.removeEventListener(BX.Call.Event.onMicrophoneLevel,this._onMicrophoneLevelHandler);this.currentCall.removeEventListener(BX.Call.Event.onReconnecting,this._onReconnectingHandler);this.currentCall.removeEventListener(BX.Call.Event.onReconnected,this._onReconnectedHandler);this.currentCall.removeEventListener(BX.Call.Event.onCustomMessage,this._onCustomMessageHandler);this.currentCall.removeEventListener(BX.Call.Event.onJoin,this._onCallJoinHandler);this.currentCall.removeEventListener(BX.Call.Event.onLeave,this._onCallLeaveHandler)}bindCallViewEvents(){this.callView.setCallback(BX.Call.View.Event.onShow,this._onCallViewShow.bind(this));this.callView.setCallback(BX.Call.View.Event.onClose,this._onCallViewClose.bind(this));this.callView.setCallback(BX.Call.View.Event.onDestroy,this._onCallViewDestroy.bind(this));this.callView.setCallback(BX.Call.View.Event.onButtonClick,this._onCallViewButtonClick.bind(this));this.callView.setCallback(BX.Call.View.Event.onBodyClick,this._onCallViewBodyClick.bind(this));this.callView.setCallback(BX.Call.View.Event.onReplaceCamera,this._onCallViewReplaceCamera.bind(this));this.callView.setCallback(BX.Call.View.Event.onReplaceMicrophone,this._onCallViewReplaceMicrophone.bind(this));this.callView.setCallback(BX.Call.View.Event.onSetCentralUser,this._onCallViewSetCentralUser.bind(this));this.callView.setCallback(BX.Call.View.Event.onChangeHdVideo,this._onCallViewChangeHdVideo.bind(this));this.callView.setCallback(BX.Call.View.Event.onChangeMicAutoParams,this._onCallViewChangeMicAutoParams.bind(this));this.callView.setCallback(BX.Call.View.Event.onChangeFaceImprove,this._onCallViewChangeFaceImprove.bind(this));this.callView.setCallback(BX.Call.View.Event.onReplaceSpeaker,this._onCallViewReplaceSpeaker.bind(this))}updateCallViewUsers(e,t){BX.Call.Util.getUsers(e,t).then((e=>{if(this.callView){this.callView.updateUserData(e)}}))}createVideoStrategy(){if(this.videoStrategy){this.videoStrategy.destroy()}const e=window.BXIM.settings.callAcceptIncomingVideo||BX.Call.VideoStrategy.Type.AllowAll;this.videoStrategy=new BX.Call.VideoStrategy({call:this.currentCall,callView:this.callView,strategyType:e})}removeVideoStrategy(){if(this.videoStrategy){this.videoStrategy.destroy()}this.videoStrategy=null}setFeatureScreenSharing(e){this.featureScreenSharing=e}setFeatureRecord(e){this.featureRecord=e}setVideoStrategyType(e){if(this.videoStrategy){this.videoStrategy.setType(e)}}isMessengerOpen(){return!!this.messenger.popupMessenger}createContainer(){this.container=BX.create("div",{props:{className:"bx-messenger-call-overlay"}});if(BX.MessengerWindow){BX.MessengerWindow.content.insertBefore(this.container,BX.MessengerWindow.content.firstChild)}else{this.messenger.popupMessengerContent.insertBefore(this.container,this.messenger.popupMessengerContent.firstChild)}this.messenger.popupMessengerContent.classList.add("bx-messenger-call")}removeContainer(){if(this.container){BX.remove(this.container);this.container=null;this.messenger.popupMessengerContent.classList.remove("bx-messenger-call")}}answerChildCall(){this.removeCallEvents();this.removeVideoStrategy();this.childCall.addEventListener(BX.Call.Event.onRemoteMediaReceived,this._onChildCallFirstMediaHandler);this.childCall.addEventListener(BX.Call.Event.onLocalMediaReceived,this._onCallLocalMediaReceivedHandler);this.childCall.answer({useVideo:this.currentCall.isVideoEnabled()})}_onChildCallFirstMedia(e){this.log("Finishing one-to-one call, switching to group call");let t=BX.Call.View.RecordType.None;if(this.isRecording()){t=this.callRecordType;BXDesktopSystem.CallRecordStop();this.callRecordState=BX.Call.View.RecordState.Stopped;this.callRecordType=BX.Call.View.RecordType.None;this.callView.setRecordState(this.callView.getDefaultRecordState());this.callView.setButtonActive("record",false)}this.callView.showButton("floorRequest");if(this.callView){if("track"in e){this.callView.setUserMedia(e.userId,e.kind,e.track)}if("mediaRenderer"in e&&e.mediaRenderer.kind==="audio"){this.callView.setUserMedia(e.userId,"audio",e.mediaRenderer.stream.getAudioTracks()[0])}if("mediaRenderer"in e&&(e.mediaRenderer.kind==="video"||e.mediaRenderer.kind==="sharing")){this.callView.setVideoRenderer(e.userId,e.mediaRenderer)}}this.childCall.removeEventListener(BX.Call.Event.onRemoteMediaReceived,this._onChildCallFirstMediaHandler);this.removeCallEvents();const i=this.currentCall;i.hangup();this.currentCall=this.childCall;this.childCall=null;if(this.currentCall.associatedEntity&&this.currentCall.associatedEntity.id){this.messenger.openMessenger(this.currentCall.associatedEntity.id)}if(i.muted){this.currentCall.setMuted(true)}this.bindCallEvents();this.createVideoStrategy();if(t!==BX.Call.View.RecordType.None){this._startRecordCall(t)}}checkDesktop(){return new Promise((function(e){BX.desktopUtils.runningCheck((function(){}),(function(){e()}))}))}isMutedPopupAllowed(){if(!this.allowMutePopup||!this.currentCall){return false}const e=this.currentCall.currentRoom&&this.currentCall.currentRoom();if(e&&e.speaker!=this.userId){return false}return true}isConferencePageOpened(e){return new Promise(((t,i)=>{let l=BX.Messenger.Lib.LocalStorage.get(BX.CallEngine.getSiteId(),BX.CallEngine.getCurrentUserId(),BX.CallEngine.getConferencePageTag(e),"N");return t(l==="Y")}))}showIncomingCall(e){if(!BX.type.isPlainObject(e)){e={}}e.video=e.video==true;if(this.feedbackPopup){this.feedbackPopup.close()}const t=this.callWithLegacyMobile?e.video===true:true;this.callNotification=new BX.Call.Notification({callerName:this.currentCall.associatedEntity.name,callerAvatar:this.currentCall.associatedEntity.avatar,callerType:this.currentCall.associatedEntity.advanced.chatType,callerColor:this.currentCall.associatedEntity.avatarColor,video:e.video,hasCamera:t,onClose:this._onCallNotificationClose.bind(this),onDestroy:this._onCallNotificationDestroy.bind(this),onButtonClick:this._onCallNotificationButtonClick.bind(this)});this.callNotification.show();this.scheduleCancelNotification();window.BXIM.repeatSound("ringtone",3500,true)}showIncomingConference(){this.callNotification=new BX.Call.NotificationConference({callerName:this.currentCall.associatedEntity.name,callerAvatar:this.currentCall.associatedEntity.avatar,callerColor:this.currentCall.associatedEntity.avatarColor,onClose:this._onCallNotificationClose.bind(this),onDestroy:this._onCallNotificationDestroy.bind(this),onButtonClick:this._onCallConferenceNotificationButtonClick.bind(this)});this.callNotification.show();this.scheduleCancelNotification();window.BXIM.repeatSound("ringtone",3500,true)}scheduleCancelNotification(){clearTimeout(this.hideIncomingCallTimeout);this.hideIncomingCallTimeout=setTimeout((()=>{if(this.callNotification){this.callNotification.close()}if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall=null}}),30*1e3)}showNotification(e,t){if(!t){t=[]}BX.UI.Notification.Center.notify({content:BX.util.htmlspecialchars(e),position:"top-right",autoHideDelay:5e3,closeButton:true,actions:t})}showNetworkProblemNotification(e){BX.UI.Notification.Center.notify({content:BX.util.htmlspecialchars(e),position:"top-right",autoHideDelay:5e3,closeButton:true,actions:[{title:BX.message("IM_M_CALL_HELP"),events:{click:(e,t,i)=>{top.BX.Helper.show("redirect=detail&code=12723718");t.close()}}}]})}showUnsupportedNotification(){if(BX.desktop&&BX.desktop.apiReady){window.BXIM.openConfirm(BX.message("IM_CALL_DESKTOP_TOO_OLD"),[new BX.PopupWindowButton({text:BX.message("IM_M_CALL_BTN_UPDATE"),className:"popup-window-button-accept",events:{click:function(){window.open(BX.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");this.popupWindow.close()}}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})])}else{window.BXIM.openConfirm(BX.message("IM_CALL_WEBRTC_USE_CHROME_OR_DESKTOP"),[new BX.PopupWindowButton({text:BX.message("IM_CALL_DETAILS"),className:"popup-window-button-accept",events:{click:function(){this.popupWindow.close();top.BX.Helper.show("redirect=detail&code=11387752")}}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})])}}isUserAgentSupported(){if(BX.desktop&&BX.desktop.apiReady){return BX.desktop.enableInVersion(48)}if("VoxImplant"in window){return VoxImplant.getInstance().isRTCsupported()}return BX.Call.Util.isWebRTCSupported()}startCall(e,t){if(!this.isUserAgentSupported()){this.showUnsupportedNotification();return}if(this.callView||this.currentCall){return}if(this.feedbackPopup){this.feedbackPopup.close()}let i=BX.Call.Provider.Plain;if(BX.Call.Util.isCallServerAllowed()&&e.toString().substr(0,4)==="chat"){i=BX.Call.Provider.Voximplant}const l=+new Date;this._openMessenger(e).then((()=>BX.Call.Hardware.init())).then((()=>{this.createContainer();let l=[];if(i===BX.Call.Provider.Plain){l.push("floorRequest")}if(!BX.Call.Util.shouldShowDocumentButton()){l.push("document")}this.callView=new BX.Call.View({container:this.container,showChatButtons:true,userLimit:BX.Call.Util.getUserLimit(),language:window.BXIM.language,layout:e.toString().startsWith("chat")?BX.Call.View.Layout.Grid:BX.Call.View.Layout.Centered,microphoneId:BX.Call.Hardware.defaultMicrophone,showShareButton:this.featureScreenSharing!==BX.Call.Controller.FeatureState.Disabled,showRecordButton:this.featureRecord!==BX.Call.Controller.FeatureState.Disabled,hiddenButtons:l,blockedButtons:["record"]});this.bindCallViewEvents();if(t&&!BX.Call.Hardware.hasCamera()){this.showNotification(BX.message("IM_CALL_ERROR_NO_CAMERA"));t=false}return BX.Call.Engine.getInstance().createCall({entityType:"chat",entityId:e,provider:i,videoEnabled:!!t,enableMicAutoParameters:BX.Call.Hardware.enableMicAutoParameters,joinExisting:true})})).then((e=>{const i=+new Date;this.currentCall=e.call;this.log("Call creation time: "+(i-l)/1e3+" seconds");this.currentCall.useHdVideo(BX.Call.Hardware.preferHdQuality);if(BX.Call.Hardware.defaultMicrophone){this.currentCall.setMicrophoneId(BX.Call.Hardware.defaultMicrophone)}if(BX.Call.Hardware.defaultCamera){this.currentCall.setCameraId(BX.Call.Hardware.defaultCamera)}if(this.currentCall.associatedEntity&&this.currentCall.associatedEntity.id){if(this.messenger.currentTab!=this.currentCall.associatedEntity.id){this.messenger.openMessenger(this.currentCall.associatedEntity.id)}}this.autoCloseCallView=true;this.bindCallEvents();this.createVideoStrategy();this.callView.appendUsers(this.currentCall.getUsers());this.callView.show();this.updateCallViewUsers(this.currentCall.id,this.getCallUsers(true));this.showDocumentPromo();this.showMaskPromo();if(e.isNew){this.log("Inviting users");this.currentCall.inviteUsers();window.BXIM.repeatSound("dialtone",5e3,true)}else{this.log("Joining existing call");this.currentCall.answer({useVideo:t})}})).catch((e=>{console.error(e);let t;if(typeof e=="string"){t=e}else if(typeof e=="object"&&e.code){t=e.code=="access_denied"?"ACCESS_DENIED":e.code}else{t="UNKNOWN_ERROR"}this._onCallFailure({code:t,message:e.message||""})}))}joinCall(e,t,i){const l=BX.prop.getBoolean(i,"joinAsViewer",false);if(!this.isUserAgentSupported()){this.showUnsupportedNotification();return}if(this.callView||this.currentCall){return}let s;this.log("Joining call "+e);BX.CallEngine.getCallWithId(e).then((e=>{this.currentCall=e.call;s=this.currentCall.associatedEntity.id.toString().startsWith("chat");return this._openMessenger()})).then((()=>BX.Call.Hardware.init())).then((()=>{this.createContainer();let e=[];if(this.currentCall instanceof BX.Call.PlainCall){e.push("floorRequest")}if(!BX.Call.Util.shouldShowDocumentButton()){e.push("document")}this.callView=new BX.Call.View({container:this.container,showChatButtons:true,userLimit:BX.Call.Util.getUserLimit(),language:window.BXIM.language,layout:s?BX.Call.View.Layout.Grid:BX.Call.View.Layout.Centered,showRecordButton:this.featureRecord!==BX.Call.Controller.FeatureState.Disabled,microphoneId:BX.Call.Hardware.defaultMicrophone,hiddenButtons:e,blockedButtons:["record"]});this.autoCloseCallView=true;this.bindCallViewEvents();this.callView.appendUsers(this.currentCall.getUsers());this.updateCallViewUsers(this.currentCall.id,this.getCallUsers(true));this.callView.show();this.showDocumentPromo();this.currentCall.useHdVideo(BX.Call.Hardware.preferHdQuality);if(BX.Call.Hardware.defaultMicrophone){this.currentCall.setMicrophoneId(BX.Call.Hardware.defaultMicrophone)}if(BX.Call.Hardware.defaultCamera){this.currentCall.setCameraId(BX.Call.Hardware.defaultCamera)}this.bindCallEvents();this.createVideoStrategy();if(t&&!BX.Call.Hardware.hasCamera()){this.showNotification(BX.message("IM_CALL_ERROR_NO_CAMERA"));t=false}if(this.getCallUsers(true).length>this.getMaxActiveMicrophonesCount()){this.currentCall.setMuted(true);this.callView.setMuted(true);this.showAutoMicMuteNotification()}this.currentCall.answer({useVideo:!!t,joinAsViewer:l})}))}leaveCurrentCall(){if(this.callView){this.callView.releaseLocalMedia()}if(this.currentCall){this.currentCall.hangup()}if(this.callView){this.callView.close()}}hasActiveCall(){return this.currentCall!=null&&this.currentCall.isAnyoneParticipating()||this.callView!=null}hasVisibleCall(){return!!(this.callView&&this.callView.visible&&this.callView.size==BX.Call.View.Size.Full)}canRecord(){return BX.desktop&&BX.desktop.getApiVersion()>=54}isRecording(){return this.canRecord()&&this.callRecordState!=BX.Call.View.RecordState.Stopped}useDevicesInCurrentCall(e){if(!this.currentCall||!this.currentCall.ready){return}for(let t=0;t<e.length;t++){const i=e[t];switch(i.kind){case"audioinput":this.currentCall.setMicrophoneId(i.deviceId);break;case"videoinput":this.currentCall.setCameraId(i.deviceId);break;case"audiooutput":if(this.callView){this.callView.setSpeakerId(i.deviceId)}break}}}removeDevicesFromCurrentCall(e){if(!this.currentCall||!this.currentCall.ready){return}for(let t=0;t<e.length;t++){const i=e[t];switch(i.kind){case"audioinput":if(this.currentCall.microphoneId==i.deviceId){const e=Object.keys(BX.Call.Hardware.microphoneList);this.currentCall.setMicrophoneId(e.length>0?e[0]:"")}break;case"videoinput":if(this.currentCall.cameraId==i.deviceId){const e=Object.keys(BX.Call.Hardware.cameraList);this.currentCall.setCameraId(e.length>0?e[0]:"")}break;case"audiooutput":if(this.callView&&this.callView.speakerId==i.deviceId){const e=Object.keys(BX.Call.Hardware.audioOutputList);this.callView.setSpeakerId(e.length>0?e[0]:"")}break}}}showChat(){if(BX.desktop&&this.floatingWindow){this.detached=true;this.callView.hide();this.floatingWindow.setTitle(this.currentCall.associatedEntity.name);BX.Call.Util.getUserAvatars(this.currentCall.id,this.getActiveCallUsers()).then((e=>{this.floatingWindow.setAvatars(e);this.floatingWindow.show()}));this.container.style.width=0}else{this.fold(BX.util.htmlspecialcharsback(this.currentCall.associatedEntity.name))}}fold(e){if(this.folded||BX.desktop&&this.floatingWindow){return}if(!e&&this.currentCall){e=BX.util.htmlspecialcharsback(this.currentCall.associatedEntity.name)}this.folded=true;this.resizeObserver.unobserve(this.container);this.container.classList.add("bx-messenger-call-overlay-folded");this.callView.setTitle(e);this.callView.setSize(BX.Call.View.Size.Folded);this.callViewState=t.Folded;if(this.sidebar){this.sidebar.toggleHidden(true)}this.closePromo();BX.onCustomEvent(this,"CallController::onFold",{})}setCallEditorMaxWidth(e){if(e!=this.maxEditorWidth){this.maxEditorWidth=e;this._onResize()}}findCallEditorWidth(){const e=this.container.clientWidth;const t=e<this.maxEditorWidth+BX.Call.View.MIN_WIDTH?e-BX.Call.View.MIN_WIDTH:this.maxEditorWidth;const i=e-t;return{callWidth:i,editorWidth:t}}showDocumentsMenu(){const e=this.callView.buttons.document.elements.root.offsetWidth;const t=BX.Call.Util.getResumesArticleCode();const l=BX.Call.Util.getDocumentsArticleCode();let s=[{text:BX.message("IM_M_CALL_MENU_CREATE_RESUME"),onclick:(e,l)=>{this.documentsMenu.close();this.maybeShowDocumentEditor({type:i.Resume},t)}},{text:BX.message("IM_M_CALL_MENU_CREATE_FILE"),items:[{text:BX.message("IM_M_CALL_MENU_CREATE_FILE_DOC"),onclick:(e,t)=>{this.documentsMenu.close();this.maybeShowDocumentEditor({type:i.Blank,typeFile:h},l)}},{text:BX.message("IM_M_CALL_MENU_CREATE_FILE_XLS"),onclick:(e,t)=>{this.documentsMenu.close();this.maybeShowDocumentEditor({type:i.Blank,typeFile:d},l)}},{text:BX.message("IM_M_CALL_MENU_CREATE_FILE_PPT"),onclick:(e,t)=>{this.documentsMenu.close();this.maybeShowDocumentEditor({type:i.Blank,typeFile:u},l)}}]}];if(!t){s.push({text:BX.message("IM_M_CALL_MENU_OPEN_LAST_RESUME"),cacheable:true,items:[{id:"loading",text:BX.message("IM_M_CALL_MENU_LOADING_RESUME_LIST")}],events:{onSubMenuShow:e=>this.buildPreviousResumesSubmenu(e.target)}})}this.documentsMenu=new BX.PopupMenuWindow({angle:false,bindElement:this.callView.buttons.document.elements.root,targetContainer:this.container,offsetTop:-15,bindOptions:{position:"top"},cacheable:false,subMenuOptions:{maxWidth:450},events:{onShow:t=>{const i=t.getTarget();i.getPopupContainer().style.display="block";const l=e/2-i.getPopupContainer().offsetWidth/2;i.setOffset({offsetLeft:l+40});i.setAngle({offset:i.getPopupContainer().offsetWidth/2-17})},onDestroy:()=>this.documentsMenu=null},items:s});this.documentsMenu.show()}buildPreviousResumesSubmenu(e){BX.ajax.runAction("disk.api.integration.messengerCall.listResumesInChatByCall",{data:{callId:this.currentCall.id}}).then((t=>{const i=t.data.resumes;if(i.length>0){i.forEach((t=>{e.getSubMenu().addMenuItem({id:t.id,text:t.object.createDate+": "+t.object.name,onclick:(e,i)=>{this.documentsMenu.close();this.viewDocumentByLink(t.links.view)}})}))}else{e.getSubMenu().addMenuItem({id:"nothing",text:BX.message("IM_M_CALL_MENU_NO_RESUME"),disabled:true})}e.getSubMenu().removeMenuItem("loading");e.adjustSubMenu()}))}maybeShowDocumentEditor(e,t){if(t){if(t){BX.UI.InfoHelper.show(t);return}}this.showDocumentEditor(e)}showDocumentEditor(e){e=e||{};let t=true;if(this.sidebar){if(e.force){this.sidebar.close(false);this.sidebar.destroy();this.sidebar=null;t=false}else{return}}if(this.callView){this.callView.setButtonActive("document",true)}clearTimeout(this.showPromoPopupTimeout);this._createAndOpenSidebarWithIframe("about:blank",t);BX.loadExt("disk.onlyoffice-im-integration").then((()=>{const t=new BX.Disk.OnlyOfficeImIntegration.CreateDocument({dialog:{id:this.currentCall.associatedEntity.id},call:{id:this.currentCall.id},delegate:{setMaxWidth:this.setCallEditorMaxWidth.bind(this),onDocumentCreated:this._onDocumentCreated.bind(this)}});let l;if(e.type===i.Resume){l=t.getIframeUrlForTemplates()}else if(e.type===i.Blank){l=t.getIframeUrlForCreate({typeFile:e.typeFile})}else{l=t.getIframeUrl({viewerItem:e.viewerItem})}l.then((e=>{this.docEditorIframe.src=e})).catch((e=>{console.error(e);this.closeDocumentEditor();alert(BX.message("IM_F_ERROR"))}));this.docEditor=t})).catch((e=>{console.error(e);this.closeDocumentEditor();alert(BX.message("IM_F_ERROR"))}));this.resizeObserver.observe(this.container)}closeDocumentEditor(){return new Promise((e=>{if(this.docEditor&&this.docEditorIframe){this.docEditor.onCloseIframe(this.docEditorIframe)}if(this.container){this.resizeObserver.unobserve(this.container)}if(this.callView){this.callView.setButtonActive("document",false);this.callView.removeMaxWidth()}if(!this.sidebar){return e()}const t=this.sidebar;this.sidebar=null;t.close().then((()=>{this.docEditor=null;this.docEditorIframe=null;t.destroy();this.maxEditorWidth=this.docCreatedForCurrentCall?l:s;if(!this.callView){this.removeContainer();e()}}))}))}viewDocumentByLink(e){if(this.sidebar){return}if(this.callView){this.callView.setButtonActive("document",true)}this.maxEditorWidth=l;this._createAndOpenSidebarWithIframe(e)}_createAndOpenSidebarWithIframe(e,t){t=t!=false;const i=this.findCallEditorWidth();const l=i.callWidth;const s=i.editorWidth;this.callView.setMaxWidth(l);this.sidebar=new BX.Call.Sidebar({container:this.container,width:s,events:{onCloseClicked:this.onSideBarCloseClicked.bind(this)}});this.sidebar.open(t);const o=new BX.Loader({target:this.sidebar.elements.contentContainer});o.show();const n=BX.create("iframe",{attrs:{src:e,frameborder:"0"},style:{display:"none",border:"0",margin:"0",width:"100%",height:"100%"}});n.addEventListener("load",(function(){o.destroy();n.style.display="block"}),{once:true});n.addEventListener("error",(e=>{console.error(e);this.closeDocumentEditor();alert(BX.message("IM_F_ERROR"))}));this.sidebar.elements.contentContainer.appendChild(n);this.docEditorIframe=n}_onDocumentCreated(){this.docCreatedForCurrentCall=true;if(this.currentCall){this.currentCall.sendCustomMessage(o,true)}}onSideBarCloseClicked(){this.closeDocumentEditor()}_ensureDocumentEditorClosed(){return new Promise(((e,t)=>{if(!this.sidebar){return e()}const i=this;window.BXIM.openConfirm(BX.message("IM_CALL_CLOSE_DOCUMENT_EDITOR_TO_ANSWER"),[new BX.PopupWindowButton({text:BX.message("IM_CALL_CLOSE_DOCUMENT_EDITOR_YES"),className:"popup-window-button-accept",events:{click:function(){this.popupWindow.close();i.closeDocumentEditor().then((function(){e()}))}}}),new BX.PopupWindowButton({text:BX.message("IM_CALL_CLOSE_DOCUMENT_EDITOR_NO"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close();t()}}})],true,{maxWidth:600})}))}onDocumentPromoActionClicked(){this.closePromo();const e=BX.Call.Util.getResumesArticleCode();if(e){BX.UI.InfoHelper.show(e);return}this.showDocumentEditor({type:i.Resume})}onDocumentPromoClosed(){this.documentPromoPopup=null}unfold(){if(this.detached){this.container.style.removeProperty("width");this.callView.show();this.detached=false;if(this.floatingWindow){this.floatingWindow.hide()}}if(this.folded){this.folded=false;this.container.classList.remove("bx-messenger-call-overlay-folded");this.callView.setSize(BX.Call.View.Size.Full);this.callViewState=t.Opened;if(this.sidebar){this.sidebar.toggleHidden(false);this.resizeObserver.observe(this.container)}}BX.onCustomEvent(this,"CallController::onUnfold",{})}isFullScreen(){if("webkitFullscreenElement"in document){return!!document.webkitFullscreenElement}else if("fullscreenElement"in document){return!!document.fullscreenElement}return false}toggleFullScreen(){if(this.isFullScreen()){this.exitFullScreen()}else{this.enterFullScreen()}}enterFullScreen(){if(BX.MessengerSlider&&BX.MessengerSlider.isFocus()&&BX.getClass("BX.SidePanel.Instance.enterFullScreen")){BX.SidePanel.Instance.enterFullScreen()}else{if(BX.browser.IsChrome()||BX.browser.IsSafari()){document.body.webkitRequestFullScreen()}else if(BX.browser.IsFirefox()){document.body.requestFullscreen()}}}exitFullScreen(){if(BX.MessengerSlider&&BX.MessengerSlider.isFocus()&&BX.getClass("BX.SidePanel.Instance.exitFullScreen")){BX.SidePanel.Instance.exitFullScreen()}else{if(document.cancelFullScreen){document.cancelFullScreen()}else if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else if(document.webkitCancelFullScreen){document.webkitCancelFullScreen()}else if(document.exitFullscreen){document.exitFullscreen()}}}showDocumentPromo(){if(!this.callView||!this.currentCall||!BX.Call.Util.shouldShowDocumentButton()){return false}if(!BX.MessengerPromo||!BX.MessengerPromo.needToShow(n)){return false}const e=this.callView.buttons.document.elements.root;const t=e.querySelector(".bx-messenger-videocall-panel-icon");if(!t){return false}this.documentPromoPopup=new BX.Call.PromoPopup({bindElement:t,promoCode:n,events:{onActionClick:this.onDocumentPromoActionClicked.bind(this),onClose:this.onDocumentPromoClosed.bind(this)}});this.showPromoPopupTimeout=setTimeout((()=>{if(this.folded){return false}this.documentPromoPopup.show()}),a)}showMaskPromo(){if(!this.callView||!this.currentCall||!BX.Call.Hardware.BackgroundDialog.isMaskAvailable()){return false}if(!BX.MessengerPromo||!BX.MessengerPromo.needToShow(r)){return false}this.maskPromoPopup=new BX.Call.PromoPopup3D({promoCode:r,events:{onClose:()=>{this.maskPromoPopup=null}}});this.showPromoPopup3dTimeout=setTimeout(function(){if(this.folded){return false}this.maskPromoPopup.show()}.bind(this),c)}closePromo(){if(this.documentPromoPopup){this.documentPromoPopup.close()}if(this.maskPromoPopup){this.maskPromoPopup.close()}clearTimeout(this.showPromoPopupTimeout);clearTimeout(this.showPromoPopup3dTimeout)}_openMessenger(e){return new Promise(((t,i)=>{this.messenger.openMessenger(e).then((()=>t())).catch((e=>i(e)))}))}_startRecordCall(e){this.callView.setButtonActive("record",true);this.callRecordType=e;this.currentCall.sendRecordState({action:BX.Call.View.RecordState.Started,date:new Date});this.callRecordState=BX.Call.View.RecordState.Started}_onCallNotificationClose(e){clearTimeout(this.hideIncomingCallTimeout);window.BXIM.stopRepeatSound("ringtone");if(this.callNotification){this.callNotification.destroy()}}_onCallNotificationDestroy(e){this.callNotification=null}_onCallNotificationButtonClick(e){clearTimeout(this.hideIncomingCallTimeout);this.callNotification.close();switch(e.button){case"answer":this._onAnswerButtonClick(e.video);break;case"decline":if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall.decline();this.currentCall=null}break}}_onAnswerButtonClick(e){if(BX.desktop){BX.desktop.windowCommand("show")}if(!this.isUserAgentSupported()){this.log("Error: unsupported user agent");this.removeVideoStrategy();this.removeCallEvents();this.currentCall.decline();this.currentCall=null;this.showUnsupportedNotification();return}if(this.callView){this.callView.destroy()}const t=this.currentCall.associatedEntity&&this.currentCall.associatedEntity.id?this.currentCall.associatedEntity.id:false;let i=t.toString().startsWith("chat");this._ensureDocumentEditorClosed().then((()=>this._openMessenger(t))).then((()=>BX.Call.Hardware.init())).then((()=>{this.createContainer();let t=[];if(this.currentCall instanceof BX.Call.PlainCall){t.push("floorRequest")}if(!BX.Call.Util.shouldShowDocumentButton()){t.push("document")}this.callView=new BX.Call.View({container:this.container,users:this.currentCall.users,userStates:this.currentCall.getUsers(),showChatButtons:true,showRecordButton:this.featureRecord!==BX.Call.Controller.FeatureState.Disabled,userLimit:BX.Call.Util.getUserLimit(),layout:i?BX.Call.View.Layout.Grid:BX.Call.View.Layout.Centered,microphoneId:BX.Call.Hardware.defaultMicrophone,blockedButtons:["record"],hiddenButtons:t});this.autoCloseCallView=true;if(this.callWithLegacyMobile){this.callView.blockAddUser()}this.bindCallViewEvents();this.updateCallViewUsers(this.currentCall.id,this.getCallUsers(true));this.callView.show();this.showDocumentPromo();this.showMaskPromo();this.currentCall.useHdVideo(BX.Call.Hardware.preferHdQuality);if(BX.Call.Hardware.defaultMicrophone){this.currentCall.setMicrophoneId(BX.Call.Hardware.defaultMicrophone)}if(BX.Call.Hardware.defaultCamera){this.currentCall.setCameraId(BX.Call.Hardware.defaultCamera)}if(this.getCallUsers(true).length>this.getMaxActiveMicrophonesCount()){this.currentCall.setMuted(true);this.callView.setMuted(true);this.showAutoMicMuteNotification()}this.currentCall.answer({useVideo:e&&BX.Call.Hardware.hasCamera(),enableMicAutoParameters:BX.Call.Hardware.enableMicAutoParameters});this.createVideoStrategy()}))}_onCallConferenceNotificationButtonClick(e){clearTimeout(this.hideIncomingCallTimeout);this.callNotification.close();switch(e.button){case"answerConference":if(this.currentCall&&"id"in this.currentCall.associatedEntity){let e=this.currentCall.associatedEntity.id.toString();if(e.startsWith("chat")){e=e.substr(4)}if(window.BXIM.messenger.chat.hasOwnProperty(e)){window.BXIM.openVideoconf(window.BXIM.messenger.chat[e].public.code)}}break;case"skipConference":if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall.decline();this.currentCall=null}break}}_onCallViewShow(e){this.callView.setButtonCounter("chat",BXIM.messenger.messageCount);this.callViewState=t.Opened}_onCallViewClose(e){this.callView.destroy();this.callViewState=t.Closed;if(this.floatingWindow){this.floatingWindow.close()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.documentsMenu){this.documentsMenu.close()}if(BX.desktop){BX.desktop.closeWindow("callBackground")}this.closePromo();this._closeReconnectionBaloon()}_onCallViewDestroy(e){this.callView=null;this.folded=false;this.autoCloseCallView=true;if(this.sidebar){BX.adjust(this.container,{style:{backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(5px)"}})}else{this.removeContainer();this.maxEditorWidth=s}}_onCallViewBodyClick(e){if(this.folded){this.unfold()}}_onCallViewButtonClick(e){const t=e.buttonName;const i={hangup:this._onCallViewHangupButtonClick.bind(this),close:this._onCallViewCloseButtonClick.bind(this),inviteUser:this._onCallViewInviteUserButtonClick.bind(this),toggleMute:this._onCallViewToggleMuteButtonClick.bind(this),toggleScreenSharing:this._onCallViewToggleScreenSharingButtonClick.bind(this),record:this._onCallViewRecordButtonClick.bind(this),toggleVideo:this._onCallViewToggleVideoButtonClick.bind(this),toggleSpeaker:this._onCallViewToggleSpeakerButtonClick.bind(this),showChat:this._onCallViewShowChatButtonClick.bind(this),floorRequest:this._onCallViewFloorRequestButtonClick.bind(this),showHistory:this._onCallViewShowHistoryButtonClick.bind(this),fullscreen:this._onCallViewFullScreenButtonClick.bind(this),document:this._onCallViewDocumentButtonClick.bind(this),microphoneSideIcon:this._onCallViewMicrophoneSideIconClick.bind(this)};if(BX.type.isFunction(i[t])){i[t].call(this,e)}}_onCallViewHangupButtonClick(e){this.leaveCurrentCall()}_onCallViewCloseButtonClick(e){if(this.callView){this.callView.close()}}_onCallViewShowChatButtonClick(e){this.messenger.openMessenger(this.currentCall.associatedEntity.id);this.showChat()}_onCallViewFloorRequestButtonClick(e){const t=this.callView.getUserFloorRequestState(BX.CallEngine.getCurrentUserId());const i=this.callView.getUserTalking(BX.CallEngine.getCurrentUserId());this.callView.setUserFloorRequestState(BX.CallEngine.getCurrentUserId(),!t);if(this.currentCall){this.currentCall.requestFloor(!t)}clearTimeout(this.callViewFloorRequestTimeout);if(i&&!t){this.callViewFloorRequestTimeout=setTimeout((()=>{if(this.currentCall){this.currentCall.requestFloor(false)}}),1500)}}_getDisconnectedUsers(){const e=[];const t=this.currentCall.getUsers();for(let i in t){if(t[i]!==BX.Call.UserState.Connected&&BX.Call.Util.userData[i]){e.push(BX.Call.Util.userData[i])}}return e}_closeReconnectionBaloon(){if(this.reconnectionBaloon){this.reconnectionBaloon.close();this.reconnectionBaloon=null}}_onCallViewInviteUserButtonClick(e){if(this.invitePopup){this.invitePopup.close();return}const t=this.currentCall.getUsers();const i=this._getDisconnectedUsers();this.invitePopup=new BX.Call.InvitePopup({viewElement:this.callView.container,bindElement:e.node,zIndex:BX.MessengerCommon.getDefaultZIndex()+200,idleUsers:i,allowNewUsers:Object.keys(t).length<BX.Call.Util.getUserLimit()-1,onDestroy:this._onInvitePopupDestroy.bind(this),onSelect:this._onInvitePopupSelect.bind(this)});this.callView.setHotKeyTemporaryBlock(true);this.invitePopup.show()}_onCallViewToggleMuteButtonClick(e){const t=this.currentCall.currentRoom&&this.currentCall.currentRoom();if(t&&t.speaker!=this.userId&&!e.muted){this.currentCall.requestRoomSpeaker();return}this.currentCall.setMuted(e.muted);this.callView.setMuted(e.muted);if(this.floatingWindow){this.floatingWindow.setAudioMuted(e.muted)}if(this.mutePopup){this.mutePopup.close()}if(!e.muted){this.allowMutePopup=true}if(this.isRecording()){BXDesktopSystem.CallRecordMute(e.muted)}}_onCallViewRecordButtonClick(e){if(e.recordState===BX.Call.View.RecordState.Started){if(this.featureRecord===BX.Call.Controller.FeatureState.Limited){BX.MessengerLimit.showHelpSlider("call_record");return}if(this.featureRecord===BX.Call.Controller.FeatureState.Disabled){return}if(this.canRecord()){const t=BX.prop.getBoolean(e,"forceRecord",BX.Call.View.RecordType.None);if(t!==BX.Call.View.RecordType.None){this._startRecordCall(t)}else if(BX.desktop&&BX.desktop.enableInVersion(55)){if(!this.callRecordMenu){this.callRecordMenu=new BX.PopupMenuWindow({bindElement:e.node,targetContainer:this.callView.container,items:[{text:BX.message("IM_M_CALL_MENU_RECORD_VIDEO"),onclick:(e,t)=>{this._startRecordCall(BX.Call.View.RecordType.Video);t.getMenuWindow().close()}},{text:BX.message("IM_M_CALL_MENU_RECORD_AUDIO"),onclick:(e,t)=>{this._startRecordCall(BX.Call.View.RecordType.Audio);t.getMenuWindow().close()}}],autoHide:true,angle:{position:"top",offset:80},offsetTop:0,offsetLeft:-25,events:{onPopupClose:()=>this.callRecordMenu.destroy(),onPopupDestroy:()=>this.callRecordMenu=null}})}this.callRecordMenu.toggle();return}this.callView.setButtonActive("record",true)}else{if(window.BX.Helper){window.BX.Helper.show("redirect=detail&code=12398134")}return}}else if(e.recordState===BX.Call.View.RecordState.Paused){if(this.canRecord()){BXDesktopSystem.CallRecordPause(true)}}else if(e.recordState===BX.Call.View.RecordState.Resumed){if(this.canRecord()){BXDesktopSystem.CallRecordPause(false)}}else if(e.recordState===BX.Call.View.RecordState.Stopped){this.callView.setButtonActive("record",false)}this.currentCall.sendRecordState({action:e.recordState,date:new Date});this.callRecordState=e.recordState}_onCallViewToggleScreenSharingButtonClick(e){if(this.featureScreenSharing===BX.Call.Controller.FeatureState.Limited){BX.MessengerLimit.showHelpSlider("call_screen_sharing");return}if(this.featureScreenSharing===BX.Call.Controller.FeatureState.Disabled){return}if(this.currentCall.isScreenSharingStarted()){if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.documentPromoPopup){this.documentPromoPopup.close()}this.currentCall.stopScreenSharing();if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}}else{this.currentCall.startScreenSharing();BX.CallEngine.getRestClient().callMethod("im.call.onShareScreen",{callId:this.currentCall.id})}}_onCallViewToggleVideoButtonClick(e){if(!BX.Call.Hardware.initialized){return}if(e.video&&Object.values(BX.Call.Hardware.cameraList).length===0){return}if(!e.video){this.callView.releaseLocalMedia()}this.currentCall.setVideoEnabled(e.video)}_onCallViewToggleSpeakerButtonClick(e){const t=this.currentCall.currentRoom&&this.currentCall.currentRoom();if(t&&t.speaker!=this.userId){alert("only room speaker can turn on sound");return}this.callView.muteSpeaker(!e.speakerMuted);if(e.fromHotKey){BX.UI.Notification.Center.notify({content:BX.message(this.callView.speakerMuted?"IM_M_CALL_MUTE_SPEAKERS_OFF":"IM_M_CALL_MUTE_SPEAKERS_ON"),position:"top-right",autoHideDelay:3e3,closeButton:true})}}_onCallViewMicrophoneSideIconClick(e){const t=this.currentCall.currentRoom&&this.currentCall.currentRoom();if(t){this.toggleRoomMenu(this.callView.buttons.microphone.elements.icon)}else{this.toggleRoomListMenu(this.callView.buttons.microphone.elements.icon)}}_onCallViewShowHistoryButtonClick(e){this.messenger.openHistory(this.currentCall.associatedEntity.id)}_onCallViewFullScreenButtonClick(e){if(this.folded){this.unfold()}this.toggleFullScreen()}_onCallViewDocumentButtonClick(e){this.sidebar?this.closeDocumentEditor():this.showDocumentsMenu()}_onCallViewReplaceCamera(e){if(this.currentCall){this.currentCall.setCameraId(e.deviceId)}BX.Call.Hardware.defaultCamera=e.deviceId}_onCallViewReplaceMicrophone(e){if(this.currentCall){this.currentCall.setMicrophoneId(e.deviceId)}if(this.currentCall instanceof BX.Call.VoximplantCall){this.callView.setMicrophoneId(e.deviceId)}BX.Call.Hardware.defaultMicrophone=e.deviceId}_onCallViewReplaceSpeaker(e){BX.Call.Hardware.defaultSpeaker=e.deviceId}_onCallViewChangeHdVideo(e){BX.Call.Hardware.preferHdQuality=e.allowHdVideo}_onCallViewChangeMicAutoParams(e){BX.Call.Hardware.enableMicAutoParameters=e.allowMicAutoParams}_onCallViewChangeFaceImprove(e){if(typeof BX.desktop==="undefined"){return}BX.desktop.cameraSmoothingStatus(e.faceImproveEnabled)}_onCallViewSetCentralUser(e){if(e.stream&&this.floatingWindow){this.floatingWindowUser=e.userId}}_onCallUserInvited(e){if(this.callView){this.updateCallViewUsers(this.currentCall.id,[e.userId]);this.callView.addUser(e.userId)}}_onCallDestroy(e){if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall=null}this.callWithLegacyMobile=false;if(this.callNotification){this.callNotification.close()}if(this.invitePopup){this.invitePopup.close()}if(this.isRecording()){BXDesktopSystem.CallRecordStop()}this.callRecordState=BX.Call.View.RecordState.Stopped;this.callRecordType=BX.Call.View.RecordType.None;if(this.callRecordMenu){this.callRecordMenu.close()}if(this.callView&&this.autoCloseCallView){this.callView.close()}if(this.floatingWindow){this.floatingWindow.close()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.mutePopup){this.mutePopup.close()}if(BX.desktop){BX.desktop.closeWindow("callBackground")}this.closePromo();this.allowMutePopup=true;this.docCreatedForCurrentCall=false;this._closeReconnectionBaloon();window.BXIM.messenger.dialogStatusRedraw();window.BXIM.stopRepeatSound("dialtone");window.BXIM.stopRepeatSound("ringtone")}_onCallUserStateChanged(e){setTimeout(this.updateFloatingWindowContent.bind(this),100);if(this.callView){this.callView.setUserState(e.userId,e.state);if(e.isLegacyMobile){this.callView.blockAddUser();this.callView.blockSwitchCamera();this.callView.blockScreenSharing();this.callView.disableMediaSelection();this.callView.updateButtons()}}if(e.state==BX.Call.UserState.Connecting||e.state==BX.Call.UserState.Connected){window.BXIM.stopRepeatSound("dialtone")}if(e.state==BX.Call.UserState.Connected){if(!e.isLegacyMobile){this.callView.unblockButtons(["camera","floorRequest","screen"])}if(this.callRecordState===BX.Call.View.RecordState.Stopped){this.callView.unblockButtons(["record"])}}else if(e.state==BX.Call.UserState.Idle&&e.previousState==BX.Call.UserState.Connected){}else if(e.state==BX.Call.UserState.Failed){if(e.networkProblem){this.showNetworkProblemNotification(BX.message("IM_M_CALL_TURN_UNAVAILABLE"))}else{BX.Call.Util.getUser(this.currentCall.id,e.userId).then((e=>{this.showNotification(BX.Call.Util.getCustomMessage("IM_M_CALL_USER_FAILED",{gender:e.gender,name:e.name}))}))}}else if(e.state==BX.Call.UserState.Declined){BX.Call.Util.getUser(this.currentCall.id,e.userId).then((e=>{this.showNotification(BX.Call.Util.getCustomMessage("IM_M_CALL_USER_DECLINED",{gender:e.gender,name:e.name}))}))}else if(e.state==BX.Call.UserState.Busy){BX.Call.Util.getUser(this.currentCall.id,e.userId).then((e=>{this.showNotification(BX.Call.Util.getCustomMessage("IM_M_CALL_USER_BUSY",{gender:e.gender,name:e.name}))}))}}_onCallUserMicrophoneState(e){if(!this.callView){return}this.callView.setUserMicrophoneState(e.userId,e.microphoneState)}_onCallUserCameraState(e){if(!this.callView){return}this.callView.setUserCameraState(e.userId,e.cameraState)}_onCallUserVideoPaused(e){if(!this.callView){return}this.callView.setUserVideoPaused(e.userId,e.videoPaused)}_onCallLocalMediaReceived(e){this.log("Received local media stream "+e.tag);if(this.callView){const t=e.tag=="main"?BX.Call.Hardware.enableMirroring:false;this.callView.setLocalStream(e.stream);this.callView.flipLocalVideo(t);this.callView.setButtonActive("screen",e.tag=="screen");if(e.tag=="screen"){if(!BX.desktop){this.showWebScreenSharePopup()}this.callView.blockSwitchCamera();this.callView.updateButtons()}else{if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}if(!this.currentCall.callFromMobile){this.callView.unblockSwitchCamera();this.callView.updateButtons()}}}if(this.currentCall&&this.currentCall.videoEnabled&&e.stream.getVideoTracks().length===0){this.showNotification(BX.message("IM_CALL_CAMERA_ERROR_FALLBACK_TO_MIC"));this.currentCall.setVideoEnabled(false)}}_onCallLocalCameraFlip(e){this._onCallLocalCameraFlipInDesktop(e.data.enableMirroring)}_onCallLocalCameraFlipInDesktop(e){if(this.callView){this.callView.flipLocalVideo(e)}}_onCallLocalMediaStopped(e){}_onCallRemoteMediaReceived(e){if(this.callView){if("track"in e){this.callView.setUserMedia(e.userId,e.kind,e.track)}if("mediaRenderer"in e&&e.mediaRenderer.kind==="audio"){this.callView.setUserMedia(e.userId,"audio",e.mediaRenderer.stream.getAudioTracks()[0])}if("mediaRenderer"in e&&(e.mediaRenderer.kind==="video"||e.mediaRenderer.kind==="sharing")){this.callView.setVideoRenderer(e.userId,e.mediaRenderer)}}}_onCallRemoteMediaStopped(e){if(this.callView){if("mediaRenderer"in e){if(e.kind==="video"||e.kind==="sharing"){this.callView.setVideoRenderer(e.userId,null)}}else{this.callView.setUserMedia(e.userId,e.kind,null)}}}_onCallUserVoiceStarted(e){if(e.local){if(this.currentCall.muted&&this.isMutedPopupAllowed()){this.showMicMutedNotification()}return}this.talkingUsers[e.userId]=true;if(this.callView){this.callView.setUserTalking(e.userId,true);this.callView.setUserFloorRequestState(e.userId,false)}if(this.floatingWindow){this.floatingWindow.setTalking(Object.keys(this.talkingUsers).map((function(e){return Number(e)})))}}_onCallUserVoiceStopped(e){if(e.local){return}if(this.talkingUsers[e.userId]){delete this.talkingUsers[e.userId]}if(this.callView){this.callView.setUserTalking(e.userId,false)}if(this.floatingWindow){this.floatingWindow.setTalking(Object.keys(this.talkingUsers).map((function(e){return Number(e)})))}}_onCallUserScreenState(e){if(this.callView){this.callView.setUserScreenState(e.userId,e.screenState)}if(e.userId==BX.CallEngine.getCurrentUserId()){this.callView.setButtonActive("screen",e.screenState);if(e.screenState){if(!BX.desktop){this.showWebScreenSharePopup()}this.callView.blockSwitchCamera()}else{if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}if(!this.currentCall.callFromMobile){this.callView.unblockSwitchCamera();this.callView.updateButtons()}}this.callView.updateButtons()}}_onCallUserRecordState(e){this.callRecordState=e.recordState.state;this.callView.setRecordState(e.recordState);if(!this.canRecord()||e.userId!=BX.message["USER_ID"]){return true}if(e.recordState.state===BX.Call.View.RecordState.Started&&e.recordState.userId==BX.message["USER_ID"]){const e=BX.Call.View.RecordSource.Chat;const t=this.currentCall.associatedEntity.id;const i=this.currentCall.associatedEntity.name;const l=this.currentCall.id;const s=BX.date.format(window.BXIM.webrtc.formatRecordDate||"d.m.Y");let o=BX.message("IM_CALL_RECORD_NAME");if(o){o=o.replace("#CHAT_TITLE#",i).replace("#CALL_ID#",l).replace("#DATE#",s)}else{o="call_record_"+this.currentCall.id}BX.CallEngine.getRestClient().callMethod("im.call.onStartRecord",{callId:this.currentCall.id});BXDesktopSystem.CallRecordStart({windowId:e,fileName:o,callId:l,callDate:s,dialogId:t,dialogName:i,video:this.callRecordType!==BX.Call.View.RecordType.Audio,muted:this.currentCall.isMuted(),cropTop:72,cropBottom:73,shareMethod:"im.disk.record.share"})}else if(e.recordState.state===BX.Call.View.RecordState.Stopped){BXDesktopSystem.CallRecordStop()}return true}_onCallUserFloorRequest(e){if(this.callView){this.callView.setUserFloorRequestState(e.userId,e.requestActive)}}_onCallFailure(e){const t=e.code||e.name||e.error;console.error("Call failure: ",e);let i;if(e.name=="VoxConnectionError"||e.name=="AuthResult"){BX.Call.Util.reportConnectionResult(e.call.id,false)}if(e.name=="AuthResult"||t=="AUTHORIZE_ERROR"){i=BX.message("IM_CALL_ERROR_AUTHORIZATION")}else if(e.name=="Failed"&&t==403){i=BX.message("IM_CALL_ERROR_HARDWARE_ACCESS_DENIED")}else if(t=="ERROR_UNEXPECTED_ANSWER"){i=BX.message("IM_CALL_ERROR_UNEXPECTED_ANSWER")}else if(t=="BLANK_ANSWER_WITH_ERROR_CODE"){i=BX.message("IM_CALL_ERROR_BLANK_ANSWER")}else if(t=="BLANK_ANSWER"){i=BX.message("IM_CALL_ERROR_BLANK_ANSWER")}else if(t=="ACCESS_DENIED"){i=BX.message("IM_CALL_ERROR_ACCESS_DENIED")}else if(t=="NO_WEBRTC"){i=this.isHttps?BX.message("IM_CALL_NO_WEBRT"):BX.message("IM_CALL_ERROR_HTTPS_REQUIRED")}else if(t=="UNKNOWN_ERROR"){i=BX.message("IM_CALL_ERROR_UNKNOWN")}else if(t=="NETWORK_ERROR"){i=BX.message("IM_CALL_ERROR_NETWORK")}else if(t=="NotAllowedError"){i=BX.message("IM_CALL_ERROR_HARDWARE_ACCESS_DENIED")}else{i=BX.message("IM_CALL_ERROR_UNKNOWN_WITH_CODE").replace("#ERROR_CODE#",t)}if(this.callView){this.callView.showFatalError({text:i})}else{this.showNotification(i)}window.BXIM.stopRepeatSound("dialtone");this.autoCloseCallView=false;if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall.destroy();this.currentCall=null}}_onNetworkProblem(e){this.showNetworkProblemNotification(BX.message("IM_M_CALL_TURN_UNAVAILABLE"))}_onMicrophoneLevel(e){if(this.callView){this.callView.setMicrophoneLevel(e.level)}}_onReconnecting(){return false;if(this.reconnectionBaloon){return}this.reconnectionBaloon=BX.UI.Notification.Center.notify({content:BX.util.htmlspecialchars(BX.message("IM_CALL_RECONNECTING")),autoHide:false,position:"top-right",closeButton:false})}_onReconnected(){return false;this._closeReconnectionBaloon()}_onCustomMessage(e){if(e.message===o){this.docCreatedForCurrentCall=true;this.maxEditorWidth=l}}_onJoinRoomOffer(e){console.log("_onJoinRoomOffer",e);if(!e.initiator&&!this.currentCall.currentRoom()){this.currentCall.joinRoom(e.roomId);this.showRoomJoinedPopup(true,e.speaker==this.userId,e.users)}}_onJoinRoom(e){console.log("_onJoinRoom",e);if(e.speaker==this.userId){this.callView.setRoomState(BX.Call.View.RoomState.Speaker)}else{this.currentCall.setMuted(true);this.callView.setMuted(true);this.callView.muteSpeaker(true);this.callView.setRoomState(BX.Call.View.RoomState.NonSpeaker)}}_onLeaveRoom(e){this.callView.setRoomState(BX.Call.View.RoomState.Speaker);this.callView.muteSpeaker(false)}_onTransferRoomSpeaker(e){console.log("_onTransferRoomSpeaker",e);if(e.speaker==this.userId){this.currentCall.setMuted(false);this.callView.setMuted(false);this.callView.setRoomState(BX.Call.View.RoomState.Speaker);if(e.initiator==this.userId){this.callView.muteSpeaker(false);this.showMicTakenFromPopup(e.previousSpeaker)}}else{this.currentCall.setMuted(true);this.callView.setMuted(true);this.callView.muteSpeaker(true);this.callView.setRoomState(BX.Call.View.RoomState.NonSpeaker);this.showMicTakenByPopup(e.speaker)}}_onCallJoin(e){if(e.local){if(this.currentCall&&this.currentCall instanceof BX.Call.VoximplantCall){BX.Call.Util.reportConnectionResult(this.currentCall.id,true)}return}if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall=null}if(this.callView){this.callView.close()}if(this.callNotification){this.callNotification.close()}if(this.invitePopup){this.invitePopup.close()}if(this.floatingWindow){this.floatingWindow.close()}if(this.mutePopup){this.mutePopup.close()}window.BXIM.stopRepeatSound("dialtone")}_onCallLeave(e){console.log("_onCallLeave",e);if(!e.local&&this.currentCall&&this.currentCall.ready){this.log(new Error("received remote leave with active call!"));return}if(this.isRecording()){BXDesktopSystem.CallRecordStop()}this.callRecordState=BX.Call.View.RecordState.Stopped;this.callRecordType=BX.Call.View.RecordType.None;this.docCreatedForCurrentCall=false;let t=false;let i;let l;if(this.currentCall&&this.currentCall.associatedEntity){this.removeVideoStrategy();this.removeCallEvents();l=this.currentCall.associatedEntity.id;t=this.currentCall.wasConnected;i={id:this.currentCall.id,provider:this.currentCall.provider,userCount:this.currentCall.users.length,browser:BX.Call.Util.getBrowserForStatistics(),isMobile:BX.browser.IsMobile(),isConference:false};this.currentCall=null}if(this.callView){this.callView.close()}if(this.invitePopup){this.invitePopup.close()}if(this.floatingWindow){this.floatingWindow.close()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.callNotification){this.callNotification.close()}if(this.mutePopup){this.mutePopup.close()}this.allowMutePopup=true;if(BX.desktop){BX.desktop.closeWindow("callBackground")}this.closePromo();this._closeReconnectionBaloon();window.BXIM.messenger.dialogStatusRedraw();window.BXIM.stopRepeatSound("dialtone");window.BXIM.stopRepeatSound("ringtone");if(t){this.lastCallDetails=i;if(BXIM.messenger.currentTab){BX.MessengerCommon.drawMessage(l,{id:"call"+i.id,chatId:BXIM.messenger.getChatId(),senderId:0,recipientId:BXIM.messenger.currentTab,date:new Date,text:'<span class="bx-messenger-ajax" onclick="BXIM.callController.showFeedbackPopup();">'+BX.message("IM_CALL_RATE_CALL")+"</span>",params:{}})}}}_onInvitePopupDestroy(e){this.callView.setHotKeyTemporaryBlock(false);this.invitePopup=null}_onInvitePopupSelect(e){this.invitePopup.close();if(!this.currentCall){return}const t=e.user.id;if(BX.Call.Util.isCallServerAllowed()&&this.currentCall instanceof BX.Call.PlainCall){this.removeVideoStrategy();this.removeCallEvents();BX.Call.Engine.getInstance().createChildCall(this.currentCall.id,BX.Call.Provider.Voximplant,[t]).then((e=>{this.childCall=e.call;this.childCall.addEventListener(BX.Call.Event.onRemoteMediaReceived,this._onChildCallFirstMediaHandler);this.childCall.addEventListener(BX.Call.Event.onLocalMediaReceived,this._onCallLocalMediaReceivedHandler);this.childCall.useHdVideo(BX.Call.Hardware.preferHdQuality);if(this.currentCall.microphoneId){this.childCall.setMicrophoneId(this.currentCall.microphoneId)}if(this.currentCall.cameraId){this.childCall.setCameraId(this.currentCall.cameraId)}this.childCall.inviteUsers({users:this.childCall.users})}));this.callView.addUser(t,BX.Call.UserState.Calling);if(BXIM.messenger.users[t]){let e={};e[t]=BXIM.messenger.users[t];this.callView.updateUserData(e)}}else{const e=this.currentCall.getUsers();if(Object.keys(e).length<BX.Call.Util.getUserLimit()-1||e.hasOwnProperty(t)){this.currentCall.inviteUsers({users:[t]})}}}_onWindowFocus(){if(!this.detached){clearTimeout(this.showFloatingWindowTimeout);clearTimeout(this.showFloatingScreenShareWindowTimeout);if(this.floatingWindow){this.floatingWindow.hide()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.hide()}}}_onWindowBlur(e){clearTimeout(this.showFloatingWindowTimeout);clearTimeout(this.showFloatingScreenShareWindowTimeout);if(this.currentCall&&this.floatingWindow&&this.callView){this.showFloatingWindowTimeout=setTimeout((()=>{if(this.currentCall&&this.floatingWindow&&this.callView){this.floatingWindow.setTitle(this.currentCall.associatedEntity.name);BX.Call.Util.getUserAvatars(this.currentCall.id,this.getActiveCallUsers()).then((e=>{this.floatingWindow.setAvatars(e);this.floatingWindow.show()}))}}),300)}if(this.currentCall&&this.floatingScreenShareWindow&&this.callView&&this.currentCall.isScreenSharingStarted()){this.showFloatingScreenShareWindowTimeout=setTimeout((()=>{if(this.currentCall&&this.floatingScreenShareWindow&&this.callView&&this.currentCall.isScreenSharingStarted()){this.floatingScreenShareWindow.show()}}),300)}}_onBeforeUnload(e){if(this.floatingWindow){this.floatingWindow.close()}if(this.callNotification){this.callNotification.close()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.hasActiveCall()){e.preventDefault();e.returnValue=""}}_onImTabChange(e){if(e==="notify"&&this.currentCall&&this.callView){this.fold(BX.util.htmlspecialcharsback(this.currentCall.associatedEntity.name))}}_onUpdateChatCounter(e){if(!this.currentCall||!this.currentCall.associatedEntity||!this.currentCall.associatedEntity.id||!this.callView){return}this.callView.setButtonCounter("chat",e)}_onDeviceChange(e){if(!this.currentCall||!this.currentCall.ready){return}const t=e.data.added;const i=e.data.removed;if(t.length>0){this.log("New devices: ",t);BX.UI.Notification.Center.notify({content:BX.message("IM_CALL_DEVICES_FOUND")+"<br><ul>"+t.map((function(e){return"<li>"+e.label}))+"</ul>",position:"top-right",autoHideDelay:1e4,closeButton:true,actions:[{title:BX.message("IM_CALL_DEVICES_CLOSE"),events:{click:(e,t,i)=>t.close()}}]});setTimeout((()=>this.useDevicesInCurrentCall(t)),500)}if(i.length>0){this.log("Removed devices: ",i);BX.UI.Notification.Center.notify({content:BX.message("IM_CALL_DEVICES_DETACHED")+"<br><ul>"+i.map((function(e){return"<li>"+e.label}))+"</ul>",position:"top-right",autoHideDelay:1e4,closeButton:true,actions:[{title:BX.message("IM_CALL_DEVICES_CLOSE"),events:{click:function(e,t,i){t.close()}}}]});setTimeout((()=>this.removeDevicesFromCurrentCall(i)),500)}}_onFloatingVideoMainAreaClick(e){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");if(!this.currentCall){return}if(this.currentCall.associatedEntity&&this.currentCall.associatedEntity.id){this.messenger.openMessenger(this.currentCall.associatedEntity.id)}else if(!this.isMessengerOpen()){this.messenger.openMessenger()}if(this.detached){this.container.style.removeProperty("width");this.callView.show();this.detached=false}}_onFloatingVideoButtonClick(e){switch(e.buttonName){case"toggleMute":this._onCallViewToggleMuteButtonClick(e);break;case"hangup":this._onCallViewHangupButtonClick();break}}_onFloatingScreenShareBackToCallClick(){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.hide()}}_onFloatingScreenShareStopClick(){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");this.currentCall.stopScreenSharing();if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}}_onFloatingScreenShareChangeScreenClick(){if(this.currentCall){this.currentCall.startScreenSharing(true)}}_onResize(){if(this.sidebar&&this.callView){const e=this.findCallEditorWidth();const t=e.callWidth;const i=e.editorWidth;this.callView.setMaxWidth(t);this.sidebar.setWidth(i)}}destroy(){if(this.floatingWindow){this.floatingWindow.destroy();this.floatingWindow=null}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.destroy();this.floatingScreenShareWindow=null}if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}BX.Call.Hardware.unsubscribe(BX.Call.Hardware.Events.onChangeMirroringVideo,this._onCallLocalCameraFlipHandler)}log(){if(this.currentCall){let e=[this.currentCall.id];BX.CallEngine.log.apply(BX.CallEngine,e.concat(Array.prototype.slice.call(arguments)))}else{BX.CallEngine.log.apply(BX.CallEngine,arguments)}}test(e,t,i){e=typeof e=="undefined"?[473,464]:e;t=typeof t=="undefined"?{width:320,height:180}:t;i=typeof i=="undefined"?false:i;this._openMessenger().then((()=>t||i?BX.Call.Hardware.init():null)).then((()=>{this.createContainer();let e=["floorRequest"];if(!BX.Call.Util.shouldShowDocumentButton()){e.push("document")}this.callView=new BX.Call.View({container:this.container,showChatButtons:true,userLimit:48,language:window.BXIM.language,layout:BX.Call.View.Layout.Grid,hiddenButtons:e});this.lastUserId=1;this.callView.setCallback("onButtonClick",(e=>this._onTestCallViewButtonClick(e)));this.callView.setCallback(BX.Call.View.Event.onUserClick,(e=>{if(!e.stream){this.callView.setUserState(e.userId,BX.Call.UserState.Connected);this.callView.setUserMedia(e.userId,"video",this.stream2.getVideoTracks()[0])}}));this.callView.setUiState(BX.Call.View.UiState.Connected);this.callView.setCallback(BX.Call.View.Event.onBodyClick,this._onCallViewBodyClick.bind(this));this.callView.setCallback("onShow",this._onCallViewShow.bind(this));this.callView.setCallback("onClose",this._onCallViewClose.bind(this));this.callView.setCallback("onReplaceMicrophone",(function(e){console.log("onReplaceMicrophone",e)}));this.callView.setCallback("onReplaceCamera",(function(e){console.log("onReplaceCamera",e)}));this.callView.setCallback("onReplaceSpeaker",(function(e){console.log("onReplaceSpeaker",e)}));this.callView.show();if(i||t){return navigator.mediaDevices.getUserMedia({audio:i,video:t})}else{return new MediaStream}})).then((l=>{this.stream=l;this.callView.setLocalStream(this.stream);e.forEach((e=>this.callView.addUser(e,BX.Call.UserState.Connected)));if(i!==false){this.vad=new BX.SimpleVAD({mediaStream:this.stream});setInterval((()=>this.callView.setMicrophoneLevel(this.vad.currentVolume)),100)}if(t){return navigator.mediaDevices.getUserMedia({audio:false,video:{width:320,height:180}})}else{return new MediaStream}})).then((t=>{this.stream2=t;this.callView.setUserMedia(e[0],"video",this.stream2.getVideoTracks()[0]);BX.rest.callMethod("im.user.list.get",{ID:e.concat(BXIM.userId),AVATAR_HR:"Y"}).then((e=>this.callView.updateUserData(e.data())))}))}_onTestCallViewButtonClick(e){console.log(e.buttonName);switch(e.buttonName){case"hangup":case"close":this.callView.close();break;case"inviteUser":this.lastUserId++;BX.rest.callMethod("im.user.list.get",{ID:[this.lastUserId],AVATAR_HR:"Y"}).then((e=>this.callView.updateUserData(e.data())));this.callView.addUser(this.lastUserId,BX.Call.UserState.Connecting);break;case"fullscreen":this.toggleFullScreen();break;case"record":this._onCallViewRecordButtonClick(e);break;case"floorRequest":this._onCallViewFloorRequestButtonClick(e);break;case"showChat":this.fold('asd "asd"');break;case"toggleScreenSharing":this.callView.setUserMedia(464,"screen",this.stream2.getVideoTracks()[0]);break;case"returnToCall":break;case"document":this._onCallViewDocumentButtonClick();break}}testIncoming(e){this.callNotification=new BX.Call.Notification({callerName:"this.currentCall.associatedEntity.name",callerAvatar:"this.currentCall.associatedEntity.avatar",callerType:"this.currentCall.associatedEntity.advanced.chatType",callerColor:"",video:true,hasCamera:!!e,onClose:this._onCallNotificationClose.bind(this),onDestroy:this._onCallNotificationDestroy.bind(this),onButtonClick:()=>this.callNotification.close()});this.callNotification.show()}getMaxActiveMicrophonesCount(){return 4}showMicMutedNotification(){if(this.mutePopup||!this.callView){return}this.mutePopup=new BX.Call.CallHint({callFolded:this.folded,bindElement:this.folded?null:this.callView.buttons.microphone.elements.icon,targetContainer:this.folded?this.messenger.popupMessengerContent:this.callView.container,icon:"mic-off",buttons:[this.createUnmuteButton()],onClose:()=>{this.allowMutePopup=false;this.mutePopup.destroy();this.mutePopup=null}});this.mutePopup.show()}showAutoMicMuteNotification(){if(this.mutePopup||!this.callView){return}this.mutePopup=new BX.Call.CallHint({callFolded:this.folded,bindElement:this.folded?null:this.callView.buttons.microphone.elements.icon,targetContainer:this.folded?this.messenger.popupMessengerContent:this.callView.container,title:BX.Text.encode(BX.message("IM_CALL_MIC_AUTO_MUTED")),icon:"mic-off",buttons:[this.createUnmuteButton()],onClose:()=>{this.mutePopup.destroy();this.mutePopup=null}});this.mutePopup.show()}createUnmuteButton(){return new BX.UI.Button({baseClass:"ui-btn ui-btn-icon-mic",text:BX.message("IM_CALL_UNMUTE_MIC"),size:BX.UI.Button.Size.EXTRA_SMALL,color:BX.UI.Button.Color.LIGHT_BORDER,noCaps:true,round:true,events:{click:()=>{this._onCallViewToggleMuteButtonClick({muted:false});this.mutePopup.destroy();this.mutePopup=null}}})}toggleRoomMenu(e){if(this.roomMenu){this.roomMenu.destroy();return}const t=this.currentCall.currentRoom().speaker;const i=this.callView.userRegistry.get(t);this.roomMenu=new BX.PopupMenuWindow({targetContainer:this.container,bindElement:e,items:[{text:BX.message("IM_CALL_SOUND_PLAYS_VIA"),disabled:true},{html:`<div class="bx-messenger-videocall-room-menu-avatar" style="--avatar: url('${BX.Text.encode(i.avatar)}')"></div>${BX.Text.encode(i.name)}`},{delimiter:true},{text:BX.message("IM_CALL_LEAVE_ROOM"),onclick:(e,t)=>{this.currentCall.leaveCurrentRoom();this.roomMenu.close()}},{delimiter:true},{text:BX.message("IM_CALL_HELP"),onclick:(e,t)=>{this.showRoomHelp();this.roomMenu.close()}}],events:{onDestroy:()=>this.roomMenu=null}});this.roomMenu.show()}toggleRoomListMenu(e){if(this.roomListMenu){this.roomListMenu.destroy();return}this.currentCall.listRooms().then((t=>{this.roomListMenu=new BX.PopupMenuWindow({targetContainer:this.container,bindElement:e,items:this.prepareRoomListMenuItems(t),events:{onDestroy:()=>this.roomListMenu=null}});this.roomListMenu.show()}))}prepareRoomListMenuItems(e){let t=[{text:BX.message("IM_CALL_JOIN_ROOM"),disabled:true},{delimiter:true}];t=t.concat(...e.map((e=>({text:this.getRoomDescription(e),onclick:(t,i)=>{if(this.currentCall&&this.currentCall.joinRoom){this.currentCall.joinRoom(e.id)}this.roomListMenu.destroy()}}))));t.push({delimiter:true});t.push({text:BX.message("IM_CALL_HELP"),onclick:(e,t)=>{this.showRoomHelp();this.roomMenu.close()}});return t}showRoomHelp(){BX.loadExt("ui.dialogs.messagebox").then((()=>{BX.UI.Dialogs.MessageBox.alert(BX.message("IM_CALL_HELP_TEXT"),BX.message("IM_CALL_HELP"))}))}getRoomDescription(e){const t=e.userList.map((e=>{const t=this.callView.userRegistry.get(e);return t.name}));let i=BX.message("IM_CALL_ROOM_DESCRIPTION");i=i.replace("#ROOM_ID#",e.id);i=i.replace("#PARTICIPANTS_LIST#",t.join(", "));return i}showRoomJoinedPopup(e,t,i){if(this.roomJoinedPopup||!this.callView){return}let l;if(!e){l=BX.message("IM_CALL_ROOM_JOINED_MANUALLY")+"<p>"+BX.message("IM_CALL_ROOM_JOINED_P2")+"</p>"}else{const e=i.filter((e=>e!=this.userId)).map((e=>{const t=this.callView.userRegistry.get(e);return t.name}));const s=e.join(", ");if(t){l=BX.Text.encode(BX.message("IM_CALL_ROOM_JOINED_AUTO_SPEAKER").replace("#PARTICIPANTS_LIST#",s))}else{l=BX.Text.encode(BX.message("IM_CALL_ROOM_JOINED_AUTO").replace("#PARTICIPANTS_LIST#",s));l+="<p>"+BX.Text.encode(BX.message("IM_CALL_ROOM_JOINED_P2"))+"</p>"}}this.roomJoinedPopup=new BX.Call.CallHint({callFolded:this.folded,bindElement:this.folded?null:this.callView.buttons.microphone.elements.icon,targetContainer:this.folded?this.messenger.popupMessengerContent:this.callView.container,title:l,buttonsLayout:"bottom",autoCloseDelay:0,buttons:[new BX.UI.Button({baseClass:"ui-btn",text:BX.message("IM_CALL_ROOM_JOINED_UNDERSTOOD"),size:BX.UI.Button.Size.EXTRA_SMALL,color:BX.UI.Button.Color.LIGHT_BORDER,noCaps:true,round:true,events:{click:()=>{this.roomJoinedPopup.destroy();this.roomJoinedPopup=null}}}),new BX.UI.Button({text:BX.message("IM_CALL_ROOM_WRONG_ROOM"),size:BX.UI.Button.Size.EXTRA_SMALL,color:BX.UI.Button.Color.LINK,noCaps:true,round:true,events:{click:()=>{this.roomJoinedPopup.destroy();this.roomJoinedPopup=null;this.currentCall.leaveCurrentRoom()}}})],onClose:()=>{this.roomJoinedPopup.destroy();this.roomJoinedPopup=null}});this.roomJoinedPopup.show()}showMicTakenFromPopup(e){if(this.micTakenFromPopup||!this.callView){return}const t=this.callView.userRegistry.get(e);const i=BX.message("IM_CALL_ROOM_MIC_TAKEN_FROM").replace("#USER_NAME#",t.name);this.micTakenFromPopup=new BX.Call.CallHint({callFolded:this.folded,bindElement:this.folded?null:this.callView.buttons.microphone.elements.icon,targetContainer:this.folded?this.messenger.popupMessengerContent:this.callView.container,title:BX.Text.encode(i),buttonsLayout:"right",autoCloseDelay:5e3,buttons:[],onClose:()=>{this.micTakenFromPopup.destroy();this.micTakenFromPopup=null}});this.micTakenFromPopup.show()}showMicTakenByPopup(e){if(this.micTakenByPopup||!this.callView){return}const t=this.callView.userRegistry.get(e);this.micTakenByPopup=new BX.Call.CallHint({callFolded:this.folded,bindElement:this.folded?null:this.callView.buttons.microphone.elements.icon,targetContainer:this.folded?this.messenger.popupMessengerContent:this.callView.container,title:BX.Text.encode(BX.message("IM_CALL_ROOM_MIC_TAKEN_BY").replace("#USER_NAME#",t.name)),buttonsLayout:"right",autoCloseDelay:5e3,buttons:[],onClose:()=>{this.micTakenByPopup.destroy();this.micTakenByPopup=null}});this.micTakenByPopup.show()}showWebScreenSharePopup(){if(this.webScreenSharePopup){this.webScreenSharePopup.show();return}this.webScreenSharePopup=new BX.Call.WebScreenSharePopup({bindElement:this.callView.buttons.screen.elements.root,targetContainer:this.callView.container,onClose:()=>{this.webScreenSharePopup.destroy();this.webScreenSharePopup=null},onStopSharingClick:()=>{this._onCallViewToggleScreenSharingButtonClick();this.webScreenSharePopup.destroy();this.webScreenSharePopup=null}});this.webScreenSharePopup.show()}showFeedbackPopup(e){if(!e){if(this.lastCallDetails){e=this.lastCallDetails}else{console.error("Could not show feedback without call")}}BX.loadExt("ui.feedback.form").then((()=>{BX.UI.Feedback.Form.open({id:"call_feedback_"+Math.random(),forms:[{zones:["ru"],id:406,sec:"9lhjhn",lang:"ru"}],presets:{call_id:e.id||0,call_amount:e.userCount||0}})}))}showFeedbackPopup_(e){if(this.feedbackPopup){return}if(!e){e=this.lastCallDetails}const t=!!BX.MessengerTheme.isDark();if(!BX.type.isPlainObject(e)){return}BX.loadExt("im.component.call-feedback").then((()=>{let i;this.feedbackPopup=new BX.PopupWindow({id:"im-call-feedback",content:"",titleBar:BX.message("IM_CALL_QUALITY_FEEDBACK"),closeIcon:true,noAllPaddings:true,cacheable:false,background:t?"#3A414B":null,darkMode:t,closeByEsc:true,autoHide:true,events:{onPopupClose:()=>{this.feedbackPopup.destroy()},onPopupDestroy:()=>{if(i){i.$destroy()}this.feedbackPopup=null}}});const l="<bx-im-component-call-feedback "+'@feedbackSent="onFeedbackSent" '+':darkMode="darkMode" '+':callDetails="callDetails" />';i=BX.Vue.createApp({template:l,data:function(){return{darkMode:t,callDetails:e}},methods:{onFeedbackSent:()=>{setTimeout((()=>{if(this.feedbackPopup){this.feedbackPopup.close()}}),1500)}}});i.mount("#"+this.feedbackPopup.getContentContainer().id);this.feedbackPopup.show()}))}}BX.Call.Controller=C;BX.Call.Controller.FeatureState={Enabled:"enabled",Disabled:"disabled",Limited:"limited"};BX.Call.Controller.Events=e;BX.Call.Controller.ViewState=t;BX.Call.Controller.DocumentType=i})();
//# sourceMappingURL=controller.map.js

Youez - 2016 - github.com/yon3zu
LinuXploit