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/application/conference/dist/ |
Upload File : |
this.BX=this.BX||{};this.BX.Messenger=this.BX.Messenger||{};(function(e,t,i,a,l,r,n,s,o,c,u,d,h,C,f,g,m,p,v,S,w,y,k,B,I,V,U,b){"use strict";var E=Object.freeze({guest:"guest"});var X=function(){function e(t){babelHelpers.classCallCheck(this,e);this.queryAuthRestore=false;this.setAuthId(E.guest);this.restClient=new U.RestClient({endpoint:t.endpoint,queryParams:this.queryParams,cors:true})}babelHelpers.createClass(e,[{key:"setAuthId",value:function e(t){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";if(babelHelpers.typeof(this.queryParams)!=="object"){this.queryParams={}}if(t==E.guest||typeof t==="string"&&t.match(/^[a-f0-9]{32}$/)){this.queryParams.call_auth_id=t}else{console.error("%CallRestClient.setAuthId: auth is not correct (%c".concat(t,"%c)"),"color: black;","font-weight: bold; color: red","color: black");return false}if(t==E.guest&&typeof i==="string"&&i.match(/^[a-f0-9]{32}$/)){this.queryParams.call_custom_auth_id=i}return true}},{key:"setChatId",value:function e(t){if(babelHelpers.typeof(this.queryParams)!=="object"){this.queryParams={}}this.queryParams.call_chat_id=t}},{key:"setConfId",value:function e(t){if(babelHelpers.typeof(this.queryParams)!=="object"){this.queryParams={}}this.queryParams.videoconf_id=t}},{key:"setPassword",value:function e(t){if(babelHelpers.typeof(this.queryParams)!=="object"){this.queryParams={}}this.queryParams.videoconf_password=t}},{key:"callMethod",value:function e(t,i,a,l){var r=this;var n=arguments.length>4&&arguments[4]!==undefined?arguments[4]:null;if(!n){n=b.Utils.getLogTrackingParams({name:t})}var s=new BX.Promise;this.restClient.callMethod(t,i,null,l,n).then(function(e){r.queryAuthRestore=false;s.fulfill(e)}).catch(function(e){var a=e.error();if(a.ex.error=="LIVECHAT_AUTH_WIDGET_USER"){r.setAuthId(a.ex.hash);if(t===RestMethod.widgetUserRegister){console.warn("BX.LiveChatRestClient: ".concat(a.ex.error_description," (").concat(a.ex.error,")"));r.queryAuthRestore=false;s.reject(e);return false}if(!r.queryAuthRestore){console.warn("BX.LiveChatRestClient: your auth-token has expired, send query with a new token");r.queryAuthRestore=true;r.restClient.callMethod(t,i,null,l,n).then(function(e){r.queryAuthRestore=false;s.fulfill(e)}).catch(function(e){r.queryAuthRestore=false;s.reject(e)});return false}}r.queryAuthRestore=false;s.reject(e)});return s}},{key:"callBatch",value:function e(t,i,a,l,r){var n=this;var s=function e(s){for(var o in t){if(!t.hasOwnProperty(o)){continue}var c=s[o].error();if(c&&c.ex.error=="LIVECHAT_AUTH_WIDGET_USER"){n.setAuthId(c.ex.hash);if(o===RestMethod.widgetUserRegister){console.warn("BX.LiveChatRestClient: ".concat(c.ex.error_description," (").concat(c.ex.error,")"));n.queryAuthRestore=false;i(s);return false}if(!n.queryAuthRestore){console.warn("BX.LiveChatRestClient: your auth-token has expired, send query with a new token");n.queryAuthRestore=true;n.restClient.callBatch(t,i,a,l,r);return false}}}n.queryAuthRestore=false;i(s);return true};return this.restClient.callBatch(t,s,a,l,r)}}]);return e}();var R=function(){function e(){var t=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,e);this.inited=false;this.dialogInited=false;this.initPromise=new BX.Promise;this.params=i;this.params.userId=this.params.userId?parseInt(this.params.userId):0;this.params.siteId=this.params.siteId||"";this.params.chatId=this.params.chatId?parseInt(this.params.chatId):0;this.params.dialogId=this.params.chatId?"chat"+this.params.chatId.toString():"0";this.params.passwordRequired=!!this.params.passwordRequired;this.messagesQueue=[];this.template=null;this.rootNode=this.params.node||document.createElement("div");this.event=new v.VueVendorV2;this.callContainer=null;this.callView=null;this.preCall=null;this.currentCall=null;this.videoStrategy=null;this.featureConfig={};(i.featureConfig||[]).forEach(function(e){t.featureConfig[e.id]=e});this.localVideoStream=null;this.conferencePageTagInterval=null;this.onCallUserInvitedHandler=this.onCallUserInvited.bind(this);this.onCallUserStateChangedHandler=this.onCallUserStateChanged.bind(this);this.onCallUserMicrophoneStateHandler=this.onCallUserMicrophoneState.bind(this);this.onCallLocalMediaReceivedHandler=BX.debounce(this.onCallLocalMediaReceived.bind(this),1e3);this.onCallUserStreamReceivedHandler=this.onCallUserStreamReceived.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._onCallJoinHandler=this.onCallJoin.bind(this);this.onCallLeaveHandler=this.onCallLeave.bind(this);this.onCallDestroyHandler=this.onCallDestroy.bind(this);this.onPreCallDestroyHandler=this.onPreCallDestroy.bind(this);this.onPreCallUserStateChangedHandler=this.onPreCallUserStateChanged.bind(this);this.waitingForCallStatus=false;this.waitingForCallStatusTimeout=null;this.callEventReceived=false;this.callRecordState=BX.Call.View.RecordState.Stopped;this.desktop=null;this.floatingScreenShareWindow=null;this.initDesktopEvents().then(function(){return t.initRestClient()}).then(function(){return t.subscribePreCallChanges()}).then(function(){return t.initPullClient()}).then(function(){return t.initCore()}).then(function(){return t.setModelData()}).then(function(){return t.initComponent()}).then(function(){return t.initCallInterface()}).then(function(){return t.initUserComplete()}).catch(function(){})}babelHelpers.createClass(e,[{key:"initDesktopEvents",value:function e(){var t=this;if(!b.Utils.platform.isBitrixDesktop()){return new Promise(function(e,t){return e()})}this.desktop=new h.Desktop;this.floatingScreenShareWindow=new BX.Call.FloatingScreenShare({desktop:this.desktop,onBackToCallClick:this.onFloatingScreenShareBackToCallClick.bind(this),onStopSharingClick:this.onFloatingScreenShareStopClick.bind(this)});if(this.floatingScreenShareWindow){this.desktop.addCustomEvent("BXScreenMediaSharing",function(e,i,a,l,r,n,s){t.floatingScreenShareWindow.setSharingData({title:i,x:a,y:l,width:r,height:n,app:s}).then(function(){t.floatingScreenShareWindow.show()}).catch(function(e){c.Logger.log("setSharingData error",e)})});window.addEventListener("focus",function(){t.onWindowFocus()});window.addEventListener("blur",function(){t.onWindowBlur()})}return new Promise(function(e,t){return e()})}},{key:"initRestClient",value:function e(){this.restClient=new X({endpoint:this.getHost()+"/rest"});this.restClient.setConfId(this.params.conferenceId);return new Promise(function(e,t){return e()})}},{key:"initPullClient",value:function e(){if(!this.params.isIntranetOrExtranet){this.pullClient=new I.PullClient({serverEnabled:true,userId:this.params.userId,siteId:this.params.siteId,restClient:this.restClient,skipStorageInit:true,configTimestamp:0,skipCheckRevision:true,getPublicListMethod:"im.call.channel.public.list"});return new Promise(function(e,t){return e()})}else{this.pullClient=BX.PULL;return this.pullClient.start().then(function(){return new Promise(function(e,t){return e()})})}}},{key:"initPullHandlers",value:function e(){this.pullClient.subscribe(new V.ImCallPullHandler({store:this.controller.getStore(),application:this,controller:this.controller}));return new Promise(function(e,t){return e()})}},{key:"initCore",value:function e(){var t=this;this.controller=new n.Controller({host:this.getHost(),siteId:this.params.siteId,userId:this.params.userId,languageId:this.params.language,pull:{client:this.pullClient},rest:{client:this.restClient},vuexBuilder:{database:!b.Utils.browser.isIe(),databaseName:"imol/call",databaseType:S.VuexBuilder.DatabaseType.localStorage,models:[r.CallApplicationModel.create()]}});return new Promise(function(e,i){t.controller.ready().then(function(){return e()})})}},{key:"initComponent",value:function e(){var t=this;if(this.getStartupErrorCode()){this.setError(this.getStartupErrorCode())}return this.controller.createVue(this,{el:this.rootNode,data:function e(){return{chatId:t.getChatId(),dialogId:t.getDialogId()}},template:'<bx-im-component-call :dialogId="dialogId"/>'}).then(function(e){t.template=e;return new Promise(function(e,t){return e()})})}},{key:"setModelData",value:function e(){this.controller.getStore().commit("application/set",{dialog:{chatId:this.getChatId(),dialogId:this.getDialogId()}});if(this.params.passwordRequired){this.controller.getStore().commit("callApplication/common",{passChecked:false})}if(this.params.conferenceTitle){this.controller.getStore().commit("callApplication/setConferenceTitle",{conferenceTitle:this.params.conferenceTitle})}if(this.params.alias){this.controller.getStore().commit("callApplication/setAlias",{alias:this.params.alias})}return new Promise(function(e,t){return e()})}},{key:"initCallInterface",value:function t(){this.callContainer=document.getElementById("bx-im-component-call-container");this.callView=new BX.Call.View({container:this.callContainer,showChatButtons:true,showShareButton:this.getFeatureState("screenSharing")!==e.FeatureState.Disabled,showRecordButton:this.getFeatureState("record")!==e.FeatureState.Disabled,userLimit:BX.Call.Util.getUserLimit(),isIntranetOrExtranet:!!this.params.isIntranetOrExtranet,language:this.params.language,layout:b.Utils.device.isMobile()?BX.Call.View.Layout.Mobile:BX.Call.View.Layout.Centered,uiState:BX.Call.View.UiState.Preparing,blockedButtons:["camera","microphone","chat","floorRequest","screen","record"],localUserState:BX.Call.UserState.Idle,hiddenButtons:this.params.isIntranetOrExtranet?[]:["record"]});this.callView.subscribe(BX.Call.View.Event.onButtonClick,this.onCallButtonClick.bind(this));this.callView.subscribe(BX.Call.View.Event.onReplaceCamera,this.onCallReplaceCamera.bind(this));this.callView.subscribe(BX.Call.View.Event.onReplaceMicrophone,this.onCallReplaceMicrophone.bind(this));this.callView.subscribe(BX.Call.View.Event.onReplaceSpeaker,this.onCallReplaceSpeaker.bind(this));this.callView.subscribe(BX.Call.View.Event.onChangeHdVideo,this.onCallViewChangeHdVideo.bind(this));this.callView.subscribe(BX.Call.View.Event.onChangeMicAutoParams,this.onCallViewChangeMicAutoParams.bind(this));this.callView.subscribe(BX.Call.View.Event.onUserNameMouseOver,this.onCallViewUserNameMouseOver.bind(this));this.callView.subscribe(BX.Call.View.Event.onUserNameMouseOut,this.onCallViewUserNameMouseOut.bind(this));this.callView.subscribe(BX.Call.View.Event.onUserNameClick,this.onCallViewUserNameClick.bind(this));this.callView.subscribe(BX.Call.View.Event.onUserChangeNameClick,this.onCallViewUserChangeNameClick.bind(this));this.callView.blockAddUser();this.callView.blockHistoryButton();if(!b.Utils.device.isMobile()){this.callView.show()}return new Promise(function(e,t){return e()})}},{key:"initUser",value:function e(){var t=this;return new Promise(function(e,i){if(t.getStartupErrorCode()||!t.controller.getStore().state.callApplication.common.passChecked){return i()}if(t.params.userId>0){t.controller.setUserId(t.params.userId);if(t.params.isIntranetOrExtranet){t.switchToSessAuth();t.controller.getStore().commit("callApplication/user",{id:t.params.userId})}else{var a=t.getUserHashCookie();if(a){t.restClient.setAuthId(a);t.restClient.setChatId(t.getChatId());t.controller.getStore().commit("callApplication/user",{id:t.params.userId,hash:a});t.pullClient.start()}}t.controller.getStore().commit("callApplication/common",{inited:true});return e()}else{t.restClient.setAuthId("guest");t.restClient.setChatId(t.getChatId());if(typeof BX.SidePanel!=="undefined"){BX.SidePanel.Instance.disableAnchorBinding()}return t.restClient.callMethod("im.call.user.register",{alias:t.params.alias,user_hash:t.getUserHashCookie()||""}).then(function(i){BX.message["USER_ID"]=i.data().id;t.controller.getStore().commit("callApplication/user",{id:i.data().id,hash:i.data().hash});t.controller.setUserId(i.data().id);t.callView.setLocalUserId(i.data().id);if(i.data().created){t.params.userCount++}t.controller.getStore().commit("callApplication/common",{inited:true});t.restClient.setAuthId(i.data().hash);t.pullClient.start();return e()})}})}},{key:"initUserComplete",value:function e(){var t=this;return this.initUser().then(function(){return t.startPageTagInterval()}).then(function(){return t.tryJoinExistingCall()}).then(function(){return t.initCall()}).then(function(){return t.initPullHandlers()}).then(function(){return t.subscribeToStoreChanges()}).then(function(){return t.initComplete()}).catch(function(){})}},{key:"startPageTagInterval",value:function e(){var t=this;return new Promise(function(e){clearInterval(t.conferencePageTagInterval);t.conferencePageTagInterval=setInterval(function(){o.LocalStorage.set(t.params.siteId,t.params.userId,BX.CallEngine.getConferencePageTag(t.params.dialogId),"Y",2)},1e3);e()})}},{key:"tryJoinExistingCall",value:function e(){var t=this;this.restClient.callMethod("im.call.tryJoinCall",{entityType:"chat",entityId:this.params.dialogId,provider:BX.Call.Provider.Voximplant,type:BX.Call.Type.Permanent}).then(function(e){c.Logger.warn("tryJoinCall",e.data());if(e.data().success){t.waitingForCallStatus=true;t.waitingForCallStatusTimeout=setTimeout(function(){t.waitingForCallStatus=false;if(!t.callEventReceived){t.setConferenceStatus(false)}t.callEventReceived=false},5e3)}else{t.setConferenceStatus(false)}})}},{key:"subscribePreCallChanges",value:function e(){BX.addCustomEvent(window,"CallEvents::callCreated",this.onCallCreated.bind(this))}},{key:"onCallCreated",value:function e(t){var i=this;c.Logger.warn("we got event onCallCreated",t);if(this.preCall||this.currentCall){return}var a=t.call;if(a.associatedEntity.type==="chat"&&a.associatedEntity.id===this.params.dialogId){this.preCall=t.call;this.updatePreCallCounter();this.preCall.addEventListener(BX.Call.Event.onUserStateChanged,this.onPreCallUserStateChangedHandler);this.preCall.addEventListener(BX.Call.Event.onDestroy,this.onPreCallDestroyHandler);if(this.waitingForCallStatus){this.callEventReceived=true}this.setConferenceStatus(true);this.setConferenceStartDate(t.call.startDate)}var l=this.controller.getStore().state.callApplication.common.userReadyToJoin;if(l){var r=this.controller.getStore().state.callApplication.common.joinWithVideo;setTimeout(function(){BX.Call.Hardware.init().then(function(){i.startCall(r)})},1e3)}}},{key:"releasePreCall",value:function e(){if(this.preCall){this.preCall.removeEventListener(BX.Call.Event.onUserStateChanged,this.onPreCallUserStateChangedHandler);this.preCall.removeEventListener(BX.Call.Event.onDestroy,this.onPreCallDestroyHandler);this.preCall=null}}},{key:"onPreCallDestroy",value:function e(t){if(this.waitingForCallStatusTimeout){clearTimeout(this.waitingForCallStatusTimeout)}this.setConferenceStatus(false);this.releasePreCall()}},{key:"onPreCallUserStateChanged",value:function e(t){this.updatePreCallCounter()}},{key:"updatePreCallCounter",value:function e(){if(this.preCall){this.controller.getStore().commit("callApplication/common",{userInCallCount:this.preCall.getParticipatingUsers().length})}else{this.controller.getStore().commit("callApplication/common",{userInCallCount:0})}}},{key:"initCall",value:function e(){BX.CallEngine.setRestClient(this.restClient);BX.CallEngine.setPullClient(this.pullClient);BX.CallEngine.setCurrentUserId(this.controller.getUserId());this.callView.unblockButtons(["chat"])}},{key:"createVideoStrategy",value:function e(){if(this.videoStrategy){this.videoStrategy.destroy()}var t=b.Utils.device.isMobile()?BX.Call.VideoStrategy.Type.OnlySpeaker:BX.Call.VideoStrategy.Type.AllowAll;this.videoStrategy=new BX.Call.VideoStrategy({call:this.currentCall,callView:this.callView,strategyType:t})}},{key:"removeVideoStrategy",value:function e(){if(this.videoStrategy){this.videoStrategy.destroy()}this.videoStrategy=null}},{key:"subscribeToStoreChanges",value:function e(){var t=this;this.controller.getStore().subscribe(function(e,i){var a=e.payload,l=e.type;if(l==="users/update"&&a.fields.name){if(t.callView){t.callView.updateUserData(babelHelpers.defineProperty({},a.id,{name:a.fields.name}))}}else if(l==="dialogues/update"&&typeof a.fields.counter==="number"){if(t.callView){t.callView.setButtonCounter("chat",a.fields.counter)}}else if(l==="dialogues/update"&&a.fields.name){document.title=a.fields.name}})}},{key:"initComplete",value:function e(){this.controller.getStore().commit("callApplication/common",{userCount:this.params.userCount});if(this.controller.getStore().state.callApplication.common.inited){y.EventEmitter.emit(C.EventType.conference.initCompleted);this.inited=true;this.initPromise.resolve(this)}}},{key:"ready",value:function e(){if(this.inited){var t=new BX.Promise;t.resolve(this);return t}return this.initPromise}},{key:"restart",value:function e(){console.trace("restart");return;if(this.currentCall){this.removeCallEvents();this.currentCall=null}if(this.callView){this.callView.releaseLocalMedia();this.callView.close();this.callView.destroy();this.callView=null}this.initCallInterface();this.initCall();this.controller.getStore().commit("callApplication/returnToPreparation")}},{key:"initHardware",value:function e(){var t=this;return new Promise(function(e,i){BX.Call.Hardware.init().then(function(){if(Object.values(BX.Call.Hardware.microphoneList).length===0){t.setError(C.CallApplicationErrorCode.missingMicrophone)}t.callView.unblockButtons(["camera","microphone"]);t.callView.enableMediaSelection();e()}).catch(function(e){if(e==="NO_WEBRTC"&&t.isHttps()){t.setError(C.CallApplicationErrorCode.unsupportedBrowser)}else if(e==="NO_WEBRTC"&&!t.isHttps()){t.setError(C.CallApplicationErrorCode.unsafeConnection)}i(e)})})}},{key:"startCall",value:function e(t){var i=this;var a=BX.Call.Provider.Voximplant;if(b.Utils.device.isMobile()){this.callView.show()}else{this.callView.setLayout(BX.Call.View.Layout.Grid)}this.callView.setUiState(BX.Call.View.UiState.Calling);this.callView.setLocalUserState(BX.Call.UserState.Connected);if(this.localVideoStream){if(t){this.callView.setLocalStream(this.localVideoStream,true)}else{this.stopLocalVideoStream()}}if(!t){this.callView.setCameraState(false)}this.controller.getStore().commit("callApplication/startCall");BX.Call.Engine.getInstance().createCall({type:BX.Call.Type.Permanent,entityType:"chat",entityId:this.getDialogId(),provider:a,videoEnabled:t,enableMicAutoParameters:BX.Call.Hardware.enableMicAutoParameters,joinExisting:true}).then(function(e){c.Logger.warn("call created",e);i.currentCall=e.call;i.currentCall.useHdVideo(true);if(BX.Call.Hardware.defaultMicrophone){i.currentCall.setMicrophoneId(BX.Call.Hardware.defaultMicrophone)}if(BX.Call.Hardware.defaultCamera){i.currentCall.setCameraId(BX.Call.Hardware.defaultCamera)}if(!b.Utils.device.isMobile()){i.callView.setLayout(BX.Call.View.Layout.Grid)}i.callView.appendUsers(i.currentCall.getUsers());BX.Call.Util.getUsers(i.currentCall.id,i.getCallUsers(true)).then(function(e){i.callView.updateUserData(e)});i.releasePreCall();i.bindCallEvents();if(i.callView.isMuted){i.currentCall.setMuted(true)}if(e.isNew){i.currentCall.setVideoEnabled(t);i.currentCall.inviteUsers()}else{i.currentCall.answer({useVideo:t})}}).catch(function(e){c.Logger.warn("creating call error",e)})}},{key:"endCall",value:function e(){if(this.currentCall){this.removeCallEvents();this.currentCall.hangup()}if(this.isRecording()){BXDesktopSystem.CallRecordStop()}this.callRecordState=BX.Call.View.RecordState.Stopped;if(b.Utils.platform.isBitrixDesktop()){this.floatingScreenShareWindow.destroy();this.floatingScreenShareWindow=null;window.close()}else{this.callView.releaseLocalMedia();this.callView.close();this.setError(C.CallApplicationErrorCode.userLeftCall);this.controller.getStore().commit("callApplication/endCall")}}},{key:"kickFromCall",value:function e(){this.setError(C.CallApplicationErrorCode.kickedFromCall);this.pullClient.disconnect();this.endCall()}},{key:"getCallUsers",value:function e(t){var i=Object.keys(this.currentCall.getUsers());if(t){i.push(this.currentCall.userId)}return i}},{key:"setLocalVideoStream",value:function e(t){this.localVideoStream=t}},{key:"stopLocalVideoStream",value:function e(){if(this.localVideoStream){this.localVideoStream.getTracks().forEach(function(e){return e.stop()})}this.localVideoStream=null}},{key:"setSelectedCamera",value:function e(t){if(this.callView){this.callView.setCameraId(t)}}},{key:"setSelectedMic",value:function e(t){if(this.callView){this.callView.setMicrophoneId(t)}}},{key:"getFeature",value:function t(i){if(typeof this.featureConfig[i]==="undefined"){return{id:i,state:e.FeatureState.Enabled,articleCode:""}}return this.featureConfig[i]}},{key:"getFeatureState",value:function e(t){return this.getFeature(t).state}},{key:"canRecord",value:function e(){return b.Utils.platform.isBitrixDesktop()&&b.Utils.platform.getDesktopVersion()>=54}},{key:"isRecording",value:function e(){return this.canRecord()&&this.callRecordState!=BX.Call.View.RecordState.Stopped}},{key:"showFeatureLimitSlider",value:function e(t){var i=this.getFeature(t).articleCode;if(!i||!window.BX.UI.InfoHelper){console.warn("Limit article not found",t);return false}window.BX.UI.InfoHelper.show(i);return true}},{key:"onCallReplaceCamera",value:function e(t){var i=t.data.deviceId;BX.Call.Hardware.defaultCamera=i;if(this.currentCall){this.currentCall.setCameraId(i)}else{this.template.$emit("cameraSelected",i)}}},{key:"onCallReplaceMicrophone",value:function e(t){var i=t.data.deviceId;BX.Call.Hardware.defaultMicrophone=i.deviceId;if(this.callView){this.callView.setMicrophoneId(i)}if(this.currentCall){this.currentCall.setMicrophoneId(i)}else{this.template.$emit("micSelected",t.data.deviceId)}}},{key:"onCallReplaceSpeaker",value:function e(t){BX.Call.Hardware.defaultSpeaker=t.data.deviceId}},{key:"onCallViewChangeHdVideo",value:function e(t){BX.Call.Hardware.preferHdQuality=t.data.allowHdVideo}},{key:"onCallViewChangeMicAutoParams",value:function e(t){BX.Call.Hardware.enableMicAutoParameters=t.data.allowMicAutoParams}},{key:"onCallViewUserNameMouseOver",value:function e(){if(!this.isExternalUser()){return false}this.callView.toggleLocalUserNameEditIcon()}},{key:"onCallViewUserNameMouseOut",value:function e(){if(!this.isExternalUser()){return false}this.callView.toggleLocalUserNameEditIcon()}},{key:"onCallViewUserNameClick",value:function e(){if(!this.isExternalUser()){return false}this.callView.toggleLocalUserNameInput()}},{key:"onCallViewUserChangeNameClick",value:function e(t){if(!this.isExternalUser()){return false}if(b.Utils.device.isMobile()){this.renameGuestMobile(t)}else{this.renameGuest(t)}}},{key:"renameGuest",value:function e(t){if(t.data.needToUpdate){this.callView.toggleLocalUserNameLoader();this.setUserName(t.data.newName).then(function(){c.Logger.log("setting name to",t.data.newName)}).catch(function(e){c.Logger.log("error setting name",e)})}else{this.callView.toggleLocalUserNameInput()}}},{key:"renameGuestMobile",value:function e(t){var i=this;if(t.data.needToUpdate){this.callView.toggleRenameSliderInputLoader();this.setUserName(t.data.newName).then(function(){c.Logger.log("setting name to",t.data.newName);if(i.callView.renameSlider){i.callView.renameSlider.close()}}).catch(function(e){c.Logger.log("error setting name",e)})}else if(!t.data.needToUpdate&&this.callView.renameSlider){this.callView.renameSlider.close()}}},{key:"onCallButtonClick",value:function e(t){var i=t.data.buttonName;c.Logger.warn("Button clicked!",i);var a={hangup:this.onCallViewHangupButtonClick.bind(this),close:this.onCallViewCloseButtonClick.bind(this),toggleMute:this.onCallViewToggleMuteButtonClick.bind(this),toggleScreenSharing:this.onCallViewToggleScreenSharingButtonClick.bind(this),record:this.onCallViewRecordButtonClick.bind(this),toggleVideo:this.onCallViewToggleVideoButtonClick.bind(this),showChat:this.onCallViewShowChatButtonClick.bind(this),share:this.onCallViewShareButtonClick.bind(this),fullscreen:this.onCallViewFullScreenButtonClick.bind(this),floorRequest:this.onCallViewFloorRequestButtonClick.bind(this)};if(a[i]){a[i](t)}else{c.Logger.error("Button handler not found!",i)}}},{key:"onCallViewHangupButtonClick",value:function e(t){this.endCall()}},{key:"onCallViewCloseButtonClick",value:function e(t){this.endCall()}},{key:"onCallViewToggleMuteButtonClick",value:function e(t){if(this.currentCall){this.currentCall.setMuted(t.data.muted)}else{this.template.$emit("setMicState",!t.data.muted)}if(this.isRecording()){BXDesktopSystem.CallRecordMute(t.data.muted)}this.callView.setMuted(t.data.muted)}},{key:"onCallViewToggleScreenSharingButtonClick",value:function t(){if(this.getFeatureState("screenSharing")===e.FeatureState.Limited){this.showFeatureLimitSlider("screenSharing");return}if(this.getFeatureState("screenSharing")===e.FeatureState.Disabled){return}if(this.currentCall.isScreenSharingStarted()){this.currentCall.stopScreenSharing();if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}}else{this.restClient.callMethod("im.call.onShareScreen",{callId:this.currentCall.id});this.currentCall.startScreenSharing()}}},{key:"onCallViewRecordButtonClick",value:function t(i){if(i.data.recordState===BX.Call.View.RecordState.Started){if(this.getFeatureState("record")===e.FeatureState.Limited){this.showFeatureLimitSlider("record");return}if(this.getFeatureState("record")===e.FeatureState.Disabled){return}if(this.canRecord()){this.callView.setButtonActive("record",true)}else{if(window.BX.Helper){window.BX.Helper.show("redirect=detail&code=12398134")}return}}else if(i.data.recordState===BX.Call.View.RecordState.Paused){if(this.canRecord()){BXDesktopSystem.CallRecordPause(true)}}else if(i.data.recordState===BX.Call.View.RecordState.Resumed){if(this.canRecord()){BXDesktopSystem.CallRecordPause(false)}}else if(i.data.recordState===BX.Call.View.RecordState.Stopped){this.callView.setButtonActive("record",false)}this.currentCall.sendRecordState({action:i.data.recordState,date:new Date});this.callRecordState=i.data.recordState}},{key:"onCallViewToggleVideoButtonClick",value:function e(t){if(this.currentCall){if(!BX.Call.Hardware.initialized){return}if(t.data.video&&Object.values(BX.Call.Hardware.cameraList).length===0){return}if(!t.data.video){this.callView.releaseLocalMedia()}this.currentCall.setVideoEnabled(t.data.video)}else{this.template.$emit("setCameraState",t.data.video)}}},{key:"onCallViewShareButtonClick",value:function e(){var t=400;if(b.Utils.device.isMobile()&&document.body.clientWidth<400){t=document.body.clientWidth-40}BX.UI.Notification.Center.notify({content:w.Loc.getMessage("BX_IM_VIDEOCONF_LINK_COPY_DONE"),autoHideDelay:4e3,width:t});u.Clipboard.copy(this.getDialogData().public.link)}},{key:"onCallViewFullScreenButtonClick",value:function e(){this.toggleFullScreen()}},{key:"onFloatingScreenShareBackToCallClick",value:function e(){BXDesktopWindow.ExecuteCommand("show.active");if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.hide()}}},{key:"onFloatingScreenShareStopClick",value:function e(){BXDesktopWindow.ExecuteCommand("show.active");this.onCallViewToggleScreenSharingButtonClick()}},{key:"onWindowFocus",value:function e(){if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.hide()}}},{key:"onWindowBlur",value:function e(){if(this.floatingScreenShareWindow&&this.currentCall&&this.currentCall.isScreenSharingStarted()){this.floatingScreenShareWindow.show()}}},{key:"isFullScreen",value:function e(){if("webkitFullscreenElement"in document){return!!document.webkitFullscreenElement}else if("fullscreenElement"in document){return!!document.fullscreenElement}return false}},{key:"toggleFullScreen",value:function e(){if(this.isFullScreen()){this.exitFullScreen()}else{this.enterFullScreen()}}},{key:"enterFullScreen",value:function e(){if(BX.browser.IsChrome()||BX.browser.IsSafari()){document.body.webkitRequestFullScreen()}else if(BX.browser.IsFirefox()){document.body.requestFullscreen()}}},{key:"exitFullScreen",value:function e(){if(document.cancelFullScreen){document.cancelFullScreen()}else if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else if(document.webkitCancelFullScreen){document.webkitCancelFullScreen()}else if(document.document.exitFullscreen()){document.exitFullscreen()}}},{key:"onCallViewShowChatButtonClick",value:function e(){this.toggleChat()}},{key:"onCallViewFloorRequestButtonClick",value:function e(){var t=this;var i=this.callView.getUserFloorRequestState(BX.CallEngine.getCurrentUserId());var a=this.callView.getUserTalking(BX.CallEngine.getCurrentUserId());this.callView.setUserFloorRequestState(BX.CallEngine.getCurrentUserId(),!i);if(this.currentCall){this.currentCall.requestFloor(!i)}clearTimeout(this.callViewFloorRequestTimeout);if(a&&!i){this.callViewFloorRequestTimeout=setTimeout(function(){if(t.currentCall){t.currentCall.requestFloor(false)}},1500)}}},{key:"bindCallEvents",value:function e(){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.onLocalMediaReceived,this.onCallLocalMediaReceivedHandler);this.currentCall.addEventListener(BX.Call.Event.onStreamReceived,this.onCallUserStreamReceivedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserVoiceStarted,this.onCallUserVoiceStartedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserVoiceStopped,this.onCallUserVoiceStoppedHandler);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.onJoin,this._onCallJoinHandler);this.currentCall.addEventListener(BX.Call.Event.onLeave,this.onCallLeaveHandler)}},{key:"removeCallEvents",value:function e(){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.onLocalMediaReceived,this.onCallLocalMediaReceivedHandler);this.currentCall.removeEventListener(BX.Call.Event.onStreamReceived,this.onCallUserStreamReceivedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserVoiceStarted,this.onCallUserVoiceStartedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserVoiceStopped,this.onCallUserVoiceStoppedHandler);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.onLeave,this.onCallLeaveHandler)}},{key:"onCallUserInvited",value:function e(t){var i=this;this.callView.addUser(t.userId);BX.Call.Util.getUsers(this.currentCall.id,[t.userId]).then(function(e){i.callView.updateUserData(e)})}},{key:"onCallUserStateChanged",value:function e(t){this.callView.setUserState(t.userId,t.state)}},{key:"onCallUserMicrophoneState",value:function e(t){this.callView.setUserMicrophoneState(t.userId,t.microphoneState)}},{key:"onCallLocalMediaReceived",value:function e(t){this.stopLocalVideoStream();this.callView.setLocalStream(t.stream,t.tag=="main");this.callView.setButtonActive("screen",t.tag=="screen");if(t.tag=="screen"){this.callView.blockSwitchCamera();this.callView.updateButtons()}else{if(!this.currentCall.callFromMobile){this.callView.unblockSwitchCamera();this.callView.updateButtons()}}}},{key:"onCallUserStreamReceived",value:function e(t){if(this.callView){if("stream"in t){this.callView.setStream(t.userId,t.stream)}if("mediaRenderer"in t&&t.mediaRenderer.kind==="audio"){this.callView.setStream(t.userId,t.mediaRenderer.stream)}if("mediaRenderer"in t&&t.mediaRenderer.kind==="video"){this.callView.setVideoRenderer(t.userId,t.mediaRenderer)}}}},{key:"onCallUserVoiceStarted",value:function e(t){this.callView.setUserTalking(t.userId,true);this.callView.setUserFloorRequestState(t.userId,false)}},{key:"onCallUserVoiceStopped",value:function e(t){this.callView.setUserTalking(t.userId,false)}},{key:"onCallUserScreenState",value:function e(t){if(this.callView){this.callView.setUserScreenState(t.userId,t.screenState)}}},{key:"onCallUserRecordState",value:function e(t){this.callRecordState=t.recordState.state;this.callView.setRecordState(t.recordState);if(!this.canRecord()||t.userId!=this.controller.getUserId()){return true}if(t.recordState.state===BX.Call.View.RecordState.Started&&t.recordState.userId==this.controller.getUserId()){var i=window.bxdWindowId||window.document.title;var a=BX.message("IM_CALL_RECORD_NAME");var l=this.currentCall.associatedEntity.id;var r=this.currentCall.associatedEntity.name;var n=this.currentCall.id;var s=BX.Main.Date.format(this.params.formatRecordDate||"d.m.Y");if(a){a=a.replace("#CHAT_TITLE#",r).replace("#CALL_ID#",n).replace("#DATE#",s)}else{a="call_record_"+this.currentCall.id}BX.CallEngine.getRestClient().callMethod("im.call.onStartRecord",{callId:this.currentCall.id});BXDesktopSystem.CallRecordStart({windowId:i,fileName:a,callId:n,callDate:s,dialogId:l,dialogName:r,muted:this.currentCall.isMuted(),cropTop:72,cropBottom:73})}else if(t.recordState.state===BX.Call.View.RecordState.Stopped){BXDesktopSystem.CallRecordStop()}return true}},{key:"onCallUserFloorRequest",value:function e(t){this.callView.setUserFloorRequestState(t.userId,t.requestActive)}},{key:"onCallJoin",value:function e(t){if(!t.local){return}this.callView.unblockButtons(["camera","floorRequest","screen","record"]);this.callView.setUiState(BX.Call.View.UiState.Connected)}},{key:"onCallLeave",value:function e(t){if(!t.local){return}this.endCall()}},{key:"onCallDestroy",value:function e(t){this.currentCall=null;if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close}this.restart()}},{key:"onCheckDevicesSave",value:function e(t){if(t["camera"]){BX.Call.Hardware.defaultCamera=t["camera"]}if(t["microphone"]){BX.Call.Hardware.defaultMicrophone=t["microphone"]}if(t["audioOutput"]){BX.Call.Hardware.defaultSpeaker=t["audioOutput"]}if(t["preferHDQuality"]){BX.Call.Hardware.preferHdQuality=t["preferHDQuality"]}if(t["enableMicAutoParameters"]){BX.Call.Hardware.enableMicAutoParameters=t["enableMicAutoParameters"]}}},{key:"setCameraState",value:function e(t){this.callView.setCameraState(t)}},{key:"isChatShow",value:function e(){return this.controller.getStore().state.callApplication.common.showChat}},{key:"toggleChat",value:function e(){var t=!this.isChatShow();this.controller.getStore().state.callApplication.common.showChat=t;this.callView.setButtonActive("chat",t)}},{key:"setDialogInited",value:function e(){this.dialogInited=true;var t=this.getDialogData();document.title=t.name}},{key:"changeVideoconfUrl",value:function e(t){window.history.pushState("","",t)}},{key:"sendNewMessageNotify",value:function e(t){var i=this;if(b.Utils.device.isMobile()){return true}var a=40;var l=4e3;t=t.replace(/<br \/>/gi," ");t=t.replace(/\[USER=([0-9]+)](.*?)\[\/USER]/gi,function(e,t,i){return i});t=t.replace(/\[CHAT=(imol\|)?([0-9]+)](.*?)\[\/CHAT]/gi,function(e,t,i,a){return a});t=t.replace(/\[PCH=([0-9]+)](.*?)\[\/PCH]/gi,function(e,t,i){return i});t=t.replace(/\[SEND(?:=(.+?))?](.+?)?\[\/SEND]/gi,function(e,t,i){return i?i:t});t=t.replace(/\[PUT(?:=(.+?))?](.+?)?\[\/PUT]/gi,function(e,t,i){return i?i:t});t=t.replace(/\[CALL(?:=(.+?))?](.+?)?\[\/CALL]/gi,function(e,t,i){return i?i:t});t=t.replace(/\[ATTACH=([0-9]+)]/gi,function(e,t,i){return""});if(t.length>a){t=t.substring(0,a-1)+"..."}var r=BX.create("div",{props:{className:"bx-im-application-call-notify-new-message"},html:t});var n=BX.UI.Notification.Center.notify({content:r,autoHideDelay:l});r.addEventListener("click",function(e){n.close();i.toggleChat()});return true}},{key:"insertText",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.template.$emit(C.EventType.textarea.insertText,t)}},{key:"setError",value:function e(t){this.controller.getStore().commit("callApplication/setError",{errorCode:t})}},{key:"toggleSmiles",value:function e(){this.controller.getStore().commit("callApplication/toggleSmiles")}},{key:"setJoinType",value:function e(t){this.controller.getStore().commit("callApplication/setJoinType",{joinWithVideo:t})}},{key:"setConferenceStatus",value:function e(t){this.controller.getStore().commit("callApplication/setConferenceStatus",{conferenceStarted:t})}},{key:"setConferenceStartDate",value:function e(t){this.controller.getStore().commit("callApplication/setConferenceStartDate",{conferenceStartDate:t})}},{key:"setUserReadyToJoin",value:function e(){this.controller.getStore().commit("callApplication/setUserReadyToJoin")}},{key:"setUserName",value:function e(t){var i=this;return new Promise(function(e,a){i.restClient.callMethod("im.call.user.update",{name:t,chat_id:i.getChatId()}).then(function(){e()})})}},{key:"checkPassword",value:function e(t){var i=this;return new Promise(function(e,a){i.restClient.callMethod("im.videoconf.password.check",{password:t,alias:i.params.alias}).then(function(l){if(l.data()===true){i.restClient.setPassword(t);i.controller.getStore().commit("callApplication/common",{passChecked:true});i.initUserComplete();e()}else{a()}})})}},{key:"addMessage",value:function e(){var t=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(!i&&!a){return false}if(!this.controller.application.isUnreadMessagesLoaded()){this.sendMessage({id:0,text:i,file:a});this.processSendMessages();return true}var l={};if(a){l.FILE_ID=[a.id]}this.controller.getStore().commit("application/increaseDialogExtraCount");this.controller.getStore().dispatch("messages/add",{chatId:this.getChatId(),authorId:this.controller.getUserId(),text:i,params:l,sending:!a}).then(function(e){t.messagesQueue.push({id:e,text:i,file:a,sending:false});t.processSendMessages()});return true}},{key:"processSendMessages",value:function e(){var t=this;if(!this.getDiskFolderId()){this.requestDiskFolderId().then(function(){t.processSendMessages()}).catch(function(){c.Logger.warn("uploadFile","Error get disk folder id");return false});return false}this.messagesQueue.filter(function(e){return!e.sending}).forEach(function(e){e.sending=true;if(e.file){t.sendMessageWithFile(e)}else{t.sendMessage(e)}});return true}},{key:"sendMessage",value:function e(t){var i=this;this.controller.application.stopWriting();t.chatId=this.getChatId();this.controller.restClient.callMethod(C.RestMethod.imMessageAdd,{TEMPLATE_ID:t.id,CHAT_ID:t.chatId,MESSAGE:t.text},null,null).then(function(e){i.controller.getStore().dispatch("messages/update",{id:t.id,chatId:t.chatId,fields:{id:e.data(),sending:false,error:false}}).then(function(){i.controller.getStore().dispatch("messages/actionFinish",{id:e.data(),chatId:t.chatId})})}).catch(function(e){});return true}},{key:"sendMessageWithFile",value:function e(t){this.controller.application.stopWriting();var i=this.getDiskFolderId();t.chatId=this.getChatId();this.uploader.senderOptions.customHeaders["Call-Auth-Id"]=this.getUserHash();this.uploader.senderOptions.customHeaders["Call-Chat-Id"]=t.chatId;this.uploader.addTask({taskId:t.file.id,fileData:t.file.source.file,fileName:t.file.source.file.name,generateUniqueName:true,diskFolderId:i,previewBlob:t.file.previewBlob})}},{key:"requestDiskFolderId",value:function e(){var t=this;if(this.requestDiskFolderPromise){return this.requestDiskFolderPromise}this.requestDiskFolderPromise=new Promise(function(e,i){if(t.flagRequestDiskFolderIdSended||t.getDiskFolderId()){t.flagRequestDiskFolderIdSended=false;e();return true}t.flagRequestDiskFolderIdSended=true;t.controller.restClient.callMethod(C.RestMethod.imDiskFolderGet,{chat_id:t.controller.application.getChatId()}).then(function(i){t.controller.executeRestAnswer(C.RestMethodHandler.imDiskFolderGet,i);t.flagRequestDiskFolderIdSended=false;e()}).catch(function(e){t.flagRequestDiskFolderIdSended=false;t.controller.executeRestAnswer(C.RestMethodHandler.imDiskFolderGet,e);i()})});return this.requestDiskFolderPromise}},{key:"addLocalize",value:function e(t){return this.controller.addLocalize(t)}},{key:"getLocalize",value:function e(t){return this.controller.getLocalize(t)}},{key:"isExternalUser",value:function e(){return!!this.getUserHash()}},{key:"getChatId",value:function e(){return parseInt(this.params.chatId)}},{key:"getDialogId",value:function e(){return this.params.dialogId}},{key:"getDialogData",value:function e(){if(!this.dialogInited){return false}return this.controller.getStore().getters["dialogues/get"](this.getDialogId())}},{key:"getHost",value:function e(){return location.origin||""}},{key:"getStartupErrorCode",value:function e(){return this.params.startupErrorCode?this.params.startupErrorCode:""}},{key:"getDiskFolderId",value:function e(){return this.controller.getStore().state.application.dialog.diskFolderId}},{key:"isHttps",value:function e(){return location.protocol==="https:"}},{key:"getUserHash",value:function e(){return this.controller.getStore().state.callApplication.user.hash}},{key:"getUserHashCookie",value:function e(){var t="";var i=s.Cookie.get(null,"BITRIX_CALL_HASH");if(typeof i==="string"&&i.match(/^[a-f0-9]{32}$/)){t=i}return t}},{key:"getAlias",value:function e(){return this.params.alias?this.params.alias:""}},{key:"switchToSessAuth",value:function e(){this.restClient.restClient.queryParams=undefined;return true}}]);return e}();R.FeatureState={Enabled:"enabled",Disabled:"disabled",Limited:"limited"};e.CallApplication=R})(this.BX.Messenger.Application=this.BX.Messenger.Application||{},BX,BX,BX.Messenger.Application,BX.Messenger,BX.Messenger.Model,BX.Messenger,BX.Messenger.Lib,BX.Messenger.Lib,BX.Messenger.Lib,BX.Messenger.Lib,BX.Messenger.Lib,BX.Messenger.Lib,BX.Messenger.Const,BX,BX.UI,BX,BX,BX,BX,BX,BX.Event,BX,BX,BX,BX.Messenger.Provider.Pull,BX,BX.Messenger.Lib); //# sourceMappingURL=call.bundle.map.js