"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../node_modules/tslib/tslib.es6.js"),n=require("../node_modules/@rematch/core/dist/core.esm.js"),r=require("../events/CallEvents.js");require("react");var t=require("../utils/genericFunctions/eventDispatch.js");require("../store/index.js"),require("../node_modules/react-redux/es/index.js");var i={displayName:"",username:"",number:"",incomingSocket:!1,incomingWebRTC:!1,incoming:!1,acceptedSocket:!1,acceptedWebRTC:!1,accepted:!1,outgoingSocket:!1,outgoingWebRTC:!1,parked:!1,outgoing:!1,startTime:"",muted:!1,paused:!1,keypadValue:"",conversationId:"",transferring:!1,conferencing:!1,transferringName:"",transferringNumber:"",transferringStartTime:"",transferSwitching:!1,transferCalls:new Array,ownerExtension:"",isRecording:!1,isLocalVideoEnabled:!1,showRemoteVideoPlaceHolder:!0,hasVideoTrackAdded:!1,isStartingVideoCall:!1,streamingSourceNumber:"",chDest:new Array,chSource:new Array,throughQueue:!1,queueId:"",queueName:"",queueNumber:"",queuePosition:"",queueWaitingTime:0},a=n.createModel()({state:i,reducers:{updateCurrentCall:function(n,r){return Number(r.startTime)&&n.startTime&&delete r.startTime,!1===r.throughQueue&&(r.queueId="",r.queueName="",r.queueNumber="",r.queuePosition="",r.queueWaitingTime=0),e.__assign(e.__assign(e.__assign({},n),r),{transferCalls:n.transferCalls})},updateKeypadValue:function(n,r){return e.__assign(e.__assign({},n),{keypadValue:r})},updateTransferring:function(n,r){return e.__assign(e.__assign({},n),{transferring:r})},updateTransferSwitching:function(n,r){return e.__assign(e.__assign({},n),{transferSwitching:r})},addTransferCalls:function(n,r){return n.transferCalls.find((function(e){return e.number===r.number}))?n:e.__assign(e.__assign({},n),{transferCalls:e.__spreadArray(e.__spreadArray([],n.transferCalls,!0),[r],!1)})},deleteTransferCalls:function(n){return e.__assign(e.__assign({},n),{transferCalls:n.transferCalls.filter((function(e){return"transferred"!==e.type}))})},setParked:function(e,n){return e.parked=n,e},updateRecordingStatus:function(e,n){return e.isRecording=n,e},updateStartTime:function(e,n){return e.startTime=n,e},updateIncoming:function(e,n){return e.incoming=n,e},reset:function(){return i},setLocalVideoEnabled:function(e,n){return e.isLocalVideoEnabled=n,e},setVideoTrackAdded:function(e,n){return e.hasVideoTrackAdded=n,e},updateConferencing:function(n,r){return e.__assign(e.__assign({},n),{conferencing:r})}},effects:function(n){return{checkIncomingUpdatePlay:function(r,t){var i,a,u,s,o,d,l,c;if("webrtc"===(null===(a=null===(i=null==t?void 0:t.currentUser)||void 0===i?void 0:i.default_device)||void 0===a?void 0:a.type)&&(null==r?void 0:r.incomingWebRTC)||"physical"===(null===(s=null===(u=null==t?void 0:t.currentUser)||void 0===u?void 0:u.default_device)||void 0===s?void 0:s.type)&&(null==r?void 0:r.incomingSocket)||"nethlink"===(null===(d=null===(o=null==t?void 0:t.currentUser)||void 0===o?void 0:o.default_device)||void 0===d?void 0:d.type)&&(null==r?void 0:r.incomingWebRTC)){r.incoming=!0;var g=t.ringtones?(null===(l=t.ringtones.availableRingtones.find((function(e){return e.name===t.ringtones.selectedRingtone})))||void 0===l?void 0:l.base64Audio)||(null===(c=t.ringtones.availableRingtones[0])||void 0===c?void 0:c.base64Audio):void 0;g&&n.player.updateStartAudioPlayer({src:g,loop:!0,useRingtoneOutput:!0})}n.currentCall.updateCurrentCall(e.__assign({},r))},checkOutgoingUpdate:function(t,i){var a,u,s;("webrtc"===(null===(a=i.currentUser.default_device)||void 0===a?void 0:a.type)&&t.outgoingWebRTC||"physical"===(null===(u=i.currentUser.default_device)||void 0===u?void 0:u.type)&&t.outgoingSocket||"nethlink"===(null===(s=i.currentUser.default_device)||void 0===s?void 0:s.type)&&t.outgoingWebRTC)&&(t.outgoing=!0,r.dispatchOutgoingCallStarted(t.displayName,t.number)),n.currentCall.updateCurrentCall(e.__assign({},t))},checkAcceptedUpdate:function(r,i){var a,u,s;("webrtc"===(null===(a=i.currentUser.default_device)||void 0===a?void 0:a.type)&&r.acceptedWebRTC||"physical"===(null===(u=i.currentUser.default_device)||void 0===u?void 0:u.type)&&r.acceptedSocket||"nethlink"===(null===(s=i.currentUser.default_device)||void 0===s?void 0:s.type)&&r.acceptedWebRTC)&&(r.accepted=!0,t.eventDispatch("phone-island-call-answered",{})),n.currentCall.updateCurrentCall(e.__assign({},r))}}}});exports.currentCall=a;
//# sourceMappingURL=currentCall.js.map
