call-control-sdk 5.2.0 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var cs=Object.defineProperty,ps=Object.defineProperties;var ds=Object.getOwnPropertyDescriptors;var Mo=Object.getOwnPropertySymbols;var us=Object.prototype.hasOwnProperty,gs=Object.prototype.propertyIsEnumerable;var st=(e,t,s)=>t in e?cs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,r=(e,t)=>{for(var s in t||(t={}))us.call(t,s)&&st(e,s,t[s]);if(Mo)for(var s of Mo(t))gs.call(t,s)&&st(e,s,t[s]);return e},X=(e,t)=>ps(e,ds(t));var te=(e,t,s)=>st(e,typeof t!="symbol"?t+"":t,s);var at=class{constructor(){te(this,"config",null);te(this,"ticketId",null);te(this,"baseUrl","");te(this,"eventQueue",[]);te(this,"isOnline",!0);te(this,"retryQueue",[]);te(this,"flushTimer",null)}async init(t){this.config=r({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},t),this.baseUrl=t.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let s=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),s}isInitialized(){return this.config!==null&&this.ticketId!==null}getConfig(){return this.config}getTicketId(){return this.ticketId}async createTicket(){if(!this.config)throw new Error("EventTracker not initialized");try{let t=await this.makeRequest("/api/v1/et/init",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({agentId:this.config.agentId,sessionId:this.config.sessionId})});if(!t.ok)throw new Error(`Failed to initialize: ${t.status} ${t.statusText}`);let s=await t.json();return this.ticketId=s.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(t){throw console.error("EventTracker initialization failed:",t),t}}async logEvent(t,s){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",t);return}let i={eventType:t,eventData:s,timestamp:Date.now()};if(this.eventQueue.push(i),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(i)}catch(l){console.warn("Failed to send event, will retry later:",l)}}async sendEvent(t){if(!(!this.config||!this.ticketId))try{let s=await this.makeRequest("/api/v1/et/event",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId,eventType:t.eventType,eventData:t.eventData})});if(!s.ok)throw new Error(`Failed to log event: ${s.status} ${s.statusText}`);let i=this.eventQueue.findIndex(l=>l.timestamp===t.timestamp);i>-1&&this.eventQueue.splice(i,1)}catch(s){console.error("Event logging failed:",s),this.retryQueue.push(()=>this.sendEvent(t))}}async closeTicket(){if(!this.config||!this.ticketId)throw new Error("EventTracker not initialized");await this.flush();try{let t=await this.makeRequest("/api/v1/et/close",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId})});if(!t.ok)throw new Error(`Failed to close ticket: ${t.status} ${t.statusText}`);this.ticketId=null,this.stopPeriodicFlush(),console.log("Ticket closed successfully")}catch(t){throw console.error("Ticket close failed:",t),t}}async flush(){if(!this.isOnline||this.eventQueue.length===0)return;let t=[...this.eventQueue];for(let i of t)await this.sendEvent(i);let s=[...this.retryQueue];this.retryQueue=[];for(let i of s)try{await i()}catch(l){console.error("Retry failed:",l)}}async makeRequest(t,s){var o;let i=`${this.baseUrl}${t}`,l=((o=this.config)==null?void 0:o.retryAttempts)||3;for(let d=1;d<=l;d++)try{return await fetch(i,s)}catch(g){if(d===l)throw g;let h=Math.min(1e3*Math.pow(2,d-1),1e4);await new Promise(u=>setTimeout(u,h))}throw new Error("Max retries exceeded")}setupAutoTracking(){var i;if(typeof window=="undefined"||!((i=this.config)!=null&&i.autoTrack))return;let t=this.config.autoTrack===!0?{}:this.config.autoTrack;if(t.pageVisits!==!1&&this.logEvent("pageVisit",{url:window.location.href,title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},timestamp:new Date().toISOString()}).catch(l=>console.warn("Failed to track page visit:",l)),t.clicks!==!1&&document.addEventListener("click",l=>{var d;let o=l.target;(o.tagName==="BUTTON"||o.tagName==="A"||o.onclick||o.getAttribute("role")==="button"||o instanceof HTMLButtonElement&&o.type==="button")&&this.logEvent("click",{element:o.tagName,text:(d=o.textContent)==null?void 0:d.trim().substring(0,100),href:o.getAttribute("href"),id:o.id,className:o.className,role:o.getAttribute("role"),position:{x:l.clientX,y:l.clientY},timestamp:new Date().toISOString()}).catch(g=>console.warn("Failed to track click:",g))}),t.forms!==!1&&document.addEventListener("submit",l=>{let o=l.target,d=new FormData(o),g={};d.forEach((h,u)=>{g[u]=h.toString()}),this.logEvent("formSubmission",{formId:o.id,action:o.action,method:o.method,fields:Object.keys(g),fieldCount:Object.keys(g).length,timestamp:new Date().toISOString()}).catch(h=>console.warn("Failed to track form submission:",h))}),t.inputs!==!1){let l;document.addEventListener("input",o=>{let d=o.target;(d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.tagName==="SELECT")&&(clearTimeout(l),l=setTimeout(()=>{var g;this.logEvent("fieldChange",{element:d.tagName,type:d.getAttribute("type"),name:d.getAttribute("name"),id:d.id,valueLength:((g=d.value)==null?void 0:g.length)||0,timestamp:new Date().toISOString()}).catch(h=>console.warn("Failed to track field change:",h))},1e3))})}let s=Date.now();window.addEventListener("beforeunload",()=>{let l=Date.now()-s;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:l,timestamp:new Date().toISOString()}),this.ticketId&&navigator.sendBeacon(`${this.baseUrl}/api/v1/et/close`,JSON.stringify({ticketId:this.ticketId}))}),t.visibility!==!1&&document.addEventListener("visibilitychange",()=>{this.logEvent("visibilityChange",{hidden:document.hidden,visibilityState:document.visibilityState,timestamp:new Date().toISOString()})}),t.errors!==!1&&(window.addEventListener("error",l=>{this.logEvent("jsError",{message:l.message,filename:l.filename,lineno:l.lineno,colno:l.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",l=>{var o;this.logEvent("unhandledRejection",{reason:(o=l.reason)==null?void 0:o.toString(),timestamp:new Date().toISOString()})})),t.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let l=window.performance.navigation,o=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:o.navigationStart,loadTime:o.loadEventEnd-o.navigationStart,domReady:o.domContentLoadedEventEnd-o.navigationStart,renderTime:o.loadEventEnd-o.domContentLoadedEventEnd,navigationType:l.type,redirectCount:l.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(this.isOnline=navigator.onLine,window.addEventListener("online",()=>{this.isOnline=!0,console.log("EventTracker: Back online, flushing queued events"),this.flush()}),window.addEventListener("offline",()=>{this.isOnline=!1,console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){var s;this.flushTimer&&clearInterval(this.flushTimer);let t=((s=this.config)==null?void 0:s.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},t)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},nt=new at;typeof window!="undefined"&&(window.EventTracker=nt);var it=class{constructor(){te(this,"state");te(this,"listeners",[]);te(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{apiKey:null,process:null,agentId:"",isInitialized:!1,isHolding:!1,isMuted:!1,status:"idle",callStartTime:null,controlPanelPosition:{x:10,y:10},iframePosition:{x:10,y:80},callData:{agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:[{line:1,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:2,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:3,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:4,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:5,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1}]}}loadFromStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);if(t){let s=JSON.parse(t);this.state=X(r({},this.state),{apiKey:s.apiKey||"",agentId:s.agentId||"",process:s.process||null,isInitialized:s.isInitialized||!1,isHolding:s.isHolding||!1,isMuted:s.isMuted||!1,status:s.status||"idle",callStartTime:s.callStartTime||null,controlPanelPosition:s.controlPanelPosition||{x:10,y:10},iframePosition:s.iframePosition||{x:10,y:80},callData:s.callData||{mobileNumber:"",callReferenceId:"",agentLoginId:""},conferenceLine:s.conferenceLine&&Array.isArray(s.conferenceLine)&&s.conferenceLine.length>0?s.conferenceLine:this.state.conferenceLine})}}catch(t){console.warn("Failed to load SDK state from localStorage:",t)}}saveToStorage(){try{let t={apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,isHolding:this.state.isHolding,isMuted:this.state.isMuted,status:this.state.status,callStartTime:this.state.callStartTime,controlPanelPosition:this.state.controlPanelPosition,iframePosition:this.state.iframePosition,callData:this.state.callData,conferenceLine:this.state.conferenceLine};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(t))}catch(t){console.warn("Failed to save SDK state to localStorage:",t)}}notifyListeners(){this.listeners.forEach(t=>t())}initialize(t,s){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("API key not available");this.state.apiKey=t,this.state.agentId=s,this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return r({},this.state)}subscribe(t){return this.listeners.push(t),()=>{let s=this.listeners.indexOf(t);s>-1&&this.listeners.splice(s,1)}}setHolding(t){this.state.isHolding=t,this.saveToStorage(),this.notifyListeners()}setMuted(t){this.state.isMuted=t,this.saveToStorage(),this.notifyListeners()}setStatus(t){this.state.status=t,this.saveToStorage(),this.notifyListeners()}setProcess(t){this.state.process=t,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(t){this.state.controlPanelPosition=t,this.saveToStorage(),this.notifyListeners()}setIframePosition(t){this.state.iframePosition=t,this.saveToStorage(),this.notifyListeners()}startCall(){this.state.callStartTime=Date.now(),this.state.status="on call",this.saveToStorage(),this.notifyListeners()}endCall(){this.state.callStartTime=null,this.state.status="idle",this.state.isHolding=!1,this.state.isMuted=!1,this.saveToStorage(),this.notifyListeners()}updateCallData(t){this.state.callData=r(r({},this.state.callData),t),this.saveToStorage(),this.notifyListeners()}setConferenceLine(t){var i;(!this.state.conferenceLine||!Array.isArray(this.state.conferenceLine))&&(console.warn("Conference line data corrupted, resetting to initial state"),this.state.conferenceLine=this.getInitialState().conferenceLine);let s=(i=this.state.conferenceLine)==null?void 0:i.map(l=>l.line===t.line?t:l);this.state.conferenceLine=s,this.saveToStorage(),this.notifyListeners()}resetConferenceLines(){this.state.conferenceLine=this.getInitialState().conferenceLine,this.saveToStorage(),this.notifyListeners()}clearStorageAndReset(){try{localStorage.removeItem(this.STORAGE_KEY),this.state=this.getInitialState(),this.notifyListeners()}catch(t){console.warn("Failed to clear localStorage:",t)}}debugStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",t),t&&console.log("Parsed localStorage data:",JSON.parse(t)),console.log("Current state:",this.state)}catch(t){console.error("Error debugging storage:",t)}}getConferenceLines(){return this.state.conferenceLine||[]}},S=new it;import{useCallback as ys,useState as _e}from"react";var N="http://192.168.101.177:8095",fs="ws://192.168.101.177:8095",q={v1:"/api/v1"},P={LOGIN:`${N}${q.v1}/cti/login?provider=convox`,READY_AGENT:`${N}${q.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${N}${q.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${N}${q.v1}/cti/calls?provider=convox`,HOLD_CALL:`${N}${q.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${N}${q.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${N}${q.v1}/cti/unmute-call?provider=convox`,END_CALL:`${N}${q.v1}/cti/calls/end?provider=convox`,LOGOUT:`${N}${q.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${N}${q.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${N}${q.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${N}${q.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${N}${q.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${N}${q.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${N}${q.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${N}${q.v1}/cti/users`,PROCESS_LIST:`${N}${q.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${N}${q.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${N}${q.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${N}${q.v1}/users/get_sentiment_analysis`},Uo={WS:`${fs}${q.v1}/cti/ws`};import ms from"axios";var xs="12345",lt=ms.create({baseURL:N,headers:{"Content-Type":"application/json",Authorization:xs},timeout:1e4});lt.interceptors.request.use(e=>{let t="12345";return t&&e.headers&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e instanceof Error?e:new Error(String(e))));lt.interceptors.response.use(e=>e,async e=>{var s;let t=e.config;return((s=e.response)==null?void 0:s.status)===401&&!t._retry&&(t._retry=!0),Promise.reject(e instanceof Error?e:new Error(String(e)))});var Z=lt;var hs=()=>{let[e,t]=_e(!1),[s,i]=_e(!1),[l,o]=_e(!1),[d,g]=_e(null),[h,u]=_e(null);return{logout:ys(()=>{var x;let f=JSON.parse((x=localStorage.getItem("call-control-sdk-state"))!=null?x:"");t(!0);let p={action:"LOGOUTUSER",userId:f.agentId||""};Z.post(P.LOGOUT,p).then(y=>{S.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),u(y==null?void 0:y.data),i(!0)}).catch(y=>{o(!0),g(y)}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:s,isError:l,error:d,data:h}},Cs=hs;import{useCallback as bs,useState as we}from"react";var vs=()=>{let[e,t]=we(!1),[s,i]=we(!1),[l,o]=we(!1),[d,g]=we(null),[h,u]=we(null);return{handleEndCall:bs(f=>{var y,I,B,O,k,w,z,V,Y,Q,b,C,L,R,A;let p=JSON.parse((y=localStorage.getItem("call-control-sdk-state"))!=null?y:"");t(!0);let x={action:"ENDCALL",userId:p==null?void 0:p.agentId,processid:(O=(B=(I=p==null?void 0:p.process)==null?void 0:I.process_id)==null?void 0:B.toString())!=null?O:"",process_name:(w=(k=p==null?void 0:p.process)==null?void 0:k.process_name)!=null?w:"",callreferenceid:(V=(z=p==null?void 0:p.callData)==null?void 0:z.convox_id)!=null?V:"",mobile_number:(Q=(Y=p==null?void 0:p.callData)==null?void 0:Y.phone_number)!=null?Q:"",disposition:(b=f==null?void 0:f.disposition)!=null?b:"RES",set_followUp:(C=f==null?void 0:f.followUp)!=null?C:"N",callback_date:(L=f==null?void 0:f.callbackDate)!=null?L:"",callback_hrs:(R=f==null?void 0:f.callbackHrs)!=null?R:"",callback_mins:(A=f==null?void 0:f.callbackMins)!=null?A:"",endcall_type:"CLOSE"};Z.post(P.END_CALL,x).then(_=>{S.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),S.endCall(),u(_==null?void 0:_.data),i(!0)}).catch(_=>{o(!0),g(_)}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:s,isError:l,error:d,data:h}};import{ArrowDropDown as js,CallEnd as Ys,Close as Xs,DragIndicator as Vo,Group as Js,Layers as Vs,Mic as Qs,MicOff as Zs,Pause as ea,Pending as ta,Phone as oa,PlayArrow as sa,SupportAgent as aa,TransferWithinAStation as na,Upcoming as ia,WifiCalling3 as la}from"@mui/icons-material";import{Box as re,Button as Se,Chip as dt,CircularProgress as Pe,Fade as Qo,IconButton as tt,Menu as ut,MenuItem as Zo,Paper as es,TextField as ra,Tooltip as me,Typography as ts,useTheme as ca}from"@mui/material";import{useCallback as pa,useEffect as ot,useRef as da,useState as ne}from"react";import{useCallback as Je,useRef as rt,useState as Bo}from"react";function ct(e,t){let[s,i]=Bo(e),[l,o]=Bo(!1),d=rt(),g=rt({x:0,y:0}),h=rt({x:0,y:0}),u=Je(x=>{let y=d.current;if(!y)return;let I=y.getBoundingClientRect(),B=window.innerWidth,O=window.innerHeight,k={x:Math.max(0,Math.min(x.x,B-I.width)),y:Math.max(0,Math.min(x.y,O-I.height))};i(k),t==null||t(k)},[t]),m=Je((x,y)=>{o(!0),g.current={x,y},h.current=s;let I=(w,z)=>{let V=w-g.current.x,Y=z-g.current.y;u({x:h.current.x+V,y:h.current.y+Y})},B=w=>{w.preventDefault(),I(w.clientX,w.clientY)},O=w=>{w.preventDefault();let z=w.touches[0];z&&I(z.clientX,z.clientY)},k=()=>{o(!1),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",k),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",k)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",k),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",k)},[s,u]),f=Je(x=>{x.preventDefault(),m(x.clientX,x.clientY)},[m]),p=Je(x=>{x.preventDefault();let y=x.touches[0];y&&m(y.clientX,y.clientY)},[m]);return{position:s,isDragging:l,dragRef:d,handleMouseDown:f,handleTouchStart:p}}import{useState as Ss,useEffect as Ts}from"react";function xe(){let[e,t]=Ss(S.getState());return Ts(()=>S.subscribe(()=>{t(S.getState())}),[]),e}import{useCallback as _s,useReducer as ws}from"react";import{createContext as Es,useContext as Ls,useState as pt}from"react";import{Snackbar as Ds,Alert as Is}from"@mui/material";import{jsx as Ho,jsxs as Rs}from"react/jsx-runtime";var $o=Es(void 0),ke=()=>{let e=Ls($o);if(!e)throw new Error("useToast must be used inside ToastProvider");return e},zo=({children:e})=>{let[t,s]=pt(!1),[i,l]=pt(""),[o,d]=pt("info"),g=(h,u="info")=>{l(h),d(u),s(!0)};return Rs($o.Provider,{value:{showToast:g},children:[e,Ho(Ds,{open:t,color:o,autoHideDuration:3e3,onClose:()=>s(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:Ho(Is,{variant:"filled",severity:o,onClose:()=>s(!1),sx:{width:"100%"},children:i})})]})};var ks={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},As=(e,t)=>{if(t.type==="isLoading")return X(r({},e),{isLoading:t.payload});if(t.type==="isSuccess")return X(r({},e),{isSuccess:!0,data:t.payload});if(t.type==="isError")return X(r({},e),{isError:!0,error:t.payload});if(t.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var oe=(e={})=>{let{onSuccess:t=null,onError:s=null}=e,{showToast:i}=ke(),[l,o]=ws(As,ks);return[_s((g,h,u={})=>{o({type:"isLoading",payload:!0}),Z.post(g,h,u).then(m=>{var f,p;o({type:"isSuccess",payload:m.data}),t==null||t(m.data,h),console.log((f=m.data)==null?void 0:f.message,"res45"),i((p=m.data)==null?void 0:p.message,"success")}).catch(m=>{var p,x,y,I,B,O,k,w,z,V,Y,Q;let f={status:(x=(p=m.response)==null?void 0:p.status)!=null?x:500,message:((I=(y=m.response)==null?void 0:y.data)==null?void 0:I.detail)||((O=(B=m.response)==null?void 0:B.data)==null?void 0:O.message)||m.message||"An unknown error occurred",data:(w=(k=m.response)==null?void 0:k.data)!=null?w:null,statusText:(V=(z=m.response)==null?void 0:z.statusText)!=null?V:"",code:(Y=m==null?void 0:m.code)!=null?Y:"",name:(Q=m==null?void 0:m.name)!=null?Q:""};i(f.message,"error"),o({type:"isError",payload:f}),s==null||s(f,h)}).finally(()=>{o({type:"isLoading",payload:!1})})},[t,s,i]),l]};import{Call as Qe,CallEnd as qo,CallSplit as Os,Close as et,Mic as Ms,MicOff as Us,Pause as Bs,PhoneDisabled as Hs,PlayArrow as $s,SupportAgent as Ze}from"@mui/icons-material";import{Box as W,Button as ee,Dialog as Ne,IconButton as ge,Paper as be,TextField as he,Typography as J,Autocomplete as Wo,Grid as ye,Tooltip as Ae,useTheme as zs,TableContainer as qs,Table as Ws,TableHead as Fs,TableRow as Fo,TableCell as le,TableBody as Gs,CircularProgress as Ce}from"@mui/material";import{useEffect as Go,useState as ue}from"react";import{useTheme as Ns}from"@mui/material";var Ps=()=>{let e=Ns();return{disabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",border:"1px solid rgb(206, 204, 204)",height:"40px","&:hover":{boxShadow:" 0px 2px 2px rgba(0, 0, 0, 0.79)",border:`1px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}},enabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${e.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}},outlined:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:e.palette.grey[200],boxShadow:`0px 2px 1px ${e.palette.primary.light}`,border:`0px solid ${e.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${e.palette.primary.main}`,border:`0px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}}}},Ve=Ps;import{Fragment as ve,jsx as a,jsxs as E}from"react/jsx-runtime";var Ks=({each:e})=>{var Q,b;let t=xe(),{showToast:s}=ke(),{disabled:i,enabled:l,outlined:o}=Ve(),d=zs(),[g,h]=ue(!1),[u,m]=ue(!1),[f,p]=ue(!1),[x,y]=ue(!1),[I,B]=ue(!1),O=(C,L)=>{S.setConferenceLine(r(r({},C),L))},k=(C,L)=>{var _,H,$,M;let R=r(r({},C),L);h(!0);let A={action:"EXTERNAL_CONFERENCE",operation:`CALL${R.line}`,line_used:String(R.line),thirdparty_no:R.phone,userid:(H=(_=t.callData)==null?void 0:_.agent_id)!=null?H:"",process:(M=($=t.callData)==null?void 0:$.process_name)!=null?M:""};Z.post(P.CONFERENCE_CALL,A).then(D=>{var T;s((T=D.data)==null?void 0:T.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(D=>{var U,F,G,K;let T=((F=(U=D.response)==null?void 0:U.data)==null?void 0:F.detail)||((K=(G=D.response)==null?void 0:G.data)==null?void 0:K.message)||D.message||"An unknown error occurred";s(T,"error")}).finally(()=>{h(!1)})},w=(C,L)=>{var _,H,$,M;let R=r(r({},C),L);m(!0);let A={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(R.line),thirdparty_no:R.phone,userid:(H=(_=t.callData)==null?void 0:_.agent_id)!=null?H:"",process:(M=($=t.callData)==null?void 0:$.process_name)!=null?M:""};Z.post(P.CONFERENCE_CALL,A).then(D=>{var T;s((T=D.data)==null?void 0:T.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(D=>{var U,F,G,K;let T=((F=(U=D.response)==null?void 0:U.data)==null?void 0:F.detail)||((K=(G=D.response)==null?void 0:G.data)==null?void 0:K.message)||D.message||"An unknown error occurred";s(T,"error")}).finally(()=>{m(!1)})},z=(C,L,R)=>{var H,$,M,D;let A=r(r({},C),L);p(!0);let _={action:"EXTERNAL_CONFERENCE",operation:R,hold_channel_no:R==="HOLDUSER"?`hold${A.line}`:`unhold${A.line}`,userid:($=(H=t.callData)==null?void 0:H.agent_id)!=null?$:"",process:(D=(M=t.callData)==null?void 0:M.process_name)!=null?D:""};Z.post(P.CONFERENCE_CALL_HOLD_OR_UN_HOLD,_).then(T=>{var U;s((U=T.data)==null?void 0:U.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(T=>{var F,G,K,ie;let U=((G=(F=T.response)==null?void 0:F.data)==null?void 0:G.detail)||((ie=(K=T.response)==null?void 0:K.data)==null?void 0:ie.message)||T.message||"An unknown error occurred";s(U,"error")}).finally(()=>{p(!1)})},V=(C,L,R)=>{var H,$,M,D;let A=r(r({},C),L);y(!0);let _={action:"EXTERNAL_CONFERENCE",operation:R,channel_no:R==="MUTEUSER"?`mute${A.line}`:`play${A.line}`,userid:($=(H=t.callData)==null?void 0:H.agent_id)!=null?$:"",thirdparty_no:A.phone,process:(D=(M=t.callData)==null?void 0:M.process_name)!=null?D:""};Z.post(P.CONFERENCE_CALL_MUTE_OT_UN_MUTE,_).then(T=>{var U;s((U=T.data)==null?void 0:U.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(T=>{var F,G,K,ie;let U=((G=(F=T.response)==null?void 0:F.data)==null?void 0:G.detail)||((ie=(K=T.response)==null?void 0:K.data)==null?void 0:ie.message)||T.message||"An unknown error occurred";s(U,"error")}).finally(()=>{y(!1)})},Y=(C,L)=>{var _,H,$,M;let R=r(r({},C),L);B(!0);let A={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(R.line-1),user_type:`THIRDPARTY${R.line-1}`,thirdparty_no:R.phone,userid:(H=(_=t.callData)==null?void 0:_.agent_id)!=null?H:"",process:(M=($=t.callData)==null?void 0:$.process_name)!=null?M:""};Z.post(P.CONFERENCE_CALL_END,A).then(D=>{var T;s((T=D.data)==null?void 0:T.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(D=>{var U,F,G,K;let T=((F=(U=D.response)==null?void 0:U.data)==null?void 0:F.detail)||((K=(G=D.response)==null?void 0:G.data)==null?void 0:K.message)||D.message||"An unknown error occurred";s(T,"error")}).finally(()=>{B(!1)})};return E(Fo,{sx:{border:"2px solid #fff"},children:[a(le,{sx:{padding:"6px"},children:E(J,{children:["Line ",(Q=e==null?void 0:e.line)!=null?Q:"",". "]})}),a(le,{sx:{padding:"6px"},children:a(J,{variant:"body2",sx:{px:1,borderRadius:"10px",width:"80px",maxWidth:"100px"},children:(b=e==null?void 0:e.status)!=null?b:""})}),a(le,{sx:{padding:"6px"},children:a(ee,{sx:{textTransform:"capitalize"},size:"small",children:a(J,{variant:"body2",children:(e==null?void 0:e.line)===1?"Internal":"External"})})}),a(le,{sx:{padding:"6px"},children:a(he,{size:"small",placeholder:"Phone Number",value:(e==null?void 0:e.phone)||"",disabled:(e==null?void 0:e.line)===1,onChange:C=>{O(e,{phone:C.target.value})}})}),a(le,{sx:{padding:"6px"},children:E(W,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[a(Ae,{title:"Call",children:a(ee,{variant:e!=null&&e.isCallStart?"outlined":"contained",color:"success",sx:e!=null&&e.isCallStart?r({},i):X(r({},l),{border:`0px solid ${d.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${d.palette.success.light}`,border:`0px solid ${d.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${d.palette.primary.light}`}}),onClick:()=>{k(e,{isCallStart:!0,status:"ONCALL"})},disabled:(e==null?void 0:e.isCallStart)||g,children:g?a(Ce,{size:"20px",color:"success"}):a(Qe,{sx:{color:e!=null&&e.isCallStart?"default":"#e7e7e7ff"}})})}),a(Ae,{title:"Merge Call",children:a(ee,{variant:e!=null&&e.isMergeCall?"contained":"outlined",sx:e!=null&&e.isMergeCall&&(e!=null&&e.isCallStart)?r({},i):e!=null&&e.isCallStart?r({},o):r({},i),onClick:()=>{w(e,{isMergeCall:!0,status:"ONCALL"})},disabled:!(e!=null&&e.isCallStart)||u,children:u?a(Ce,{size:"20px",sx:{color:e!=null&&e.isMergeCall?"#e7e7e7ff":d.palette.primary.main}}):a(Os,{})})}),a(Ae,{title:e.isHold?"Hold":"Un Hold",children:a(ee,{variant:e!=null&&e.isHold?"contained":"outlined",sx:e!=null&&e.isHold&&(e!=null&&e.isCallStart)?r({},i):e!=null&&e.isCallStart?r({},o):r({},i),onClick:()=>{e.isHold?z(e,{isHold:!1},"UNHOLDUSER"):z(e,{isHold:!0},"HOLDUSER")},disabled:!(e!=null&&e.isCallStart)||f,children:f?a(Ce,{size:"20px",sx:{color:d.palette.primary.main}}):e.isHold?a($s,{}):a(Bs,{})})}),a(Ae,{title:e.isMute?"Mute":"Un Mute",children:a(ee,{variant:e!=null&&e.isMute?"contained":"outlined",sx:e!=null&&e.isMute&&(e!=null&&e.isCallStart)?r({},i):e!=null&&e.isCallStart?r({},o):r({},i),onClick:()=>{e.isMute?V(e,{isMute:!1},"PLAYUSER"):V(e,{isMute:!0},"MUTEUSER")},disabled:!(e!=null&&e.isCallStart)||x,children:x?a(Ce,{size:"20px",sx:{color:d.palette.primary.main}}):e.isMute?a(Us,{}):a(Ms,{})})}),a(Ae,{title:"End Call",children:(e==null?void 0:e.line)!==1?a(ee,{variant:e!=null&&e.isCallStart?"contained":"outlined",color:"error",sx:e!=null&&e.isCallStart?X(r({},l),{minWidth:"60px !important",border:`0px solid ${d.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${d.palette.error.light}`,border:`0px solid ${d.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${d.palette.primary.light}`}}):X(r({},i),{minWidth:"60px !important"}),onClick:()=>{Y(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart)||I,children:I?a(Ce,{size:"20px",color:"error"}):a(qo,{})}):a(ee,{variant:e!=null&&e.isCallStart?"contained":"outlined",sx:X(r({},i),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{Y(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart),children:a(J,{children:a(qo,{sx:{visibility:"hidden"}})})})})]})})]},e.line)};function Ko({open:e,setOpen:t}){var h;let s=xe(),{showToast:i}=ke(),[l,o]=ue(!1),d=()=>{t(!1)},g=()=>{var m,f,p,x;o(!0);let u={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(f=(m=s.callData)==null?void 0:m.agent_id)!=null?f:"",process:(x=(p=s.callData)==null?void 0:p.process_name)!=null?x:""};Z.post(P.CONFERENCE_CALL_END_ALL,u).then(y=>{var I;i((I=y.data)==null?void 0:I.message,"success"),S.resetConferenceLines(),d()}).catch(y=>{var B,O,k,w;let I=((O=(B=y.response)==null?void 0:B.data)==null?void 0:O.detail)||((w=(k=y.response)==null?void 0:k.data)==null?void 0:w.message)||y.message||"An unknown error occurred";i(I,"error")}).finally(()=>{o(!1)})};return Go(()=>{var m,f,p,x;let u={line:1,status:(f=(m=s.callData)==null?void 0:m.status)!=null?f:"",type:"internal",phone:(x=(p=s.callData)==null?void 0:p.phone_number)!=null?x:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};S.setConferenceLine(u)},[]),a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:E(be,{sx:{borderRadius:2},children:[E(W,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[E(J,{variant:"body1",children:[(h=s==null?void 0:s.agentId)!=null?h:""," conference"]}),a(ge,{onClick:d,children:a(et,{})})]}),a(W,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:a(qs,{component:be,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:E(Ws,{sx:{border:"4px solid #ffffff !important"},children:[a(Fs,{children:E(Fo,{sx:{border:"2px solid #f3f3f3ff !important"},children:[a(le,{sx:{padding:"6px"},children:"Line"}),a(le,{sx:{padding:"6px"},children:"Status"}),a(le,{sx:{padding:"6px"},children:"Call Type"}),a(le,{sx:{padding:"6px"},children:"Mobile Number"}),a(le,{sx:{padding:"6px"},children:"Call Actions"})]})}),a(Gs,{children:s==null?void 0:s.conferenceLine.map(u=>a(Ks,{each:u}))})]})})}),a(W,{textAlign:"center",m:2,children:E(ee,{variant:"outlined",color:"error",size:"large",onClick:g,disabled:l,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[l?a(Ce,{size:"20px",color:"error",sx:{marginRight:"8px"}}):a(ge,{sx:{bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},marginRight:"8px",width:"28px",height:"28px",fontSize:"12px",fontWeight:"600",lineHeight:"16px",letterSpacing:"0.02em",textTransform:"capitalize",color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%"},children:a(Hs,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function jo({open:e,setOpen:t}){var p,x,y,I,B,O,k,w,z,V,Y,Q;let[s]=oe({onSuccess:b=>{console.log("res",b),t(!1)},onError:b=>{console.log("error",b)}}),i=xe(),[l,o]=ue("process"),[d,{data:g}]=oe(),[h,{data:u}]=oe(),m=()=>{t(!1)},f=(b,C)=>{var L,R,A,_,H,$,M,D,T,U,F,G,K,ie,Oe,Me,Ue,Be,Te,He,Ee,$e,Le,ze,qe,We,De,Fe,Ge,Ke,je,Ye,Xe;if(console.log(b,"data34"),C==="PROCESS"){let fe={mobile_number:(R=(L=i.callData)==null?void 0:L.phone_number)!=null?R:"",userid:(_=(A=i.callData)==null?void 0:A.agent_id)!=null?_:"",type:"PROCESS",transfer_to:(H=b==null?void 0:b.process_name)!=null?H:"",callreferenceid:(M=($=i.callData)==null?void 0:$.convox_id)!=null?M:"",processid:String((T=(D=i.callData)==null?void 0:D.process_id)!=null?T:""),process_name:(F=(U=i.callData)==null?void 0:U.process_name)!=null?F:""};s(P.TRANSFER_CALL,fe)}else if(C==="QUEUE"){let fe={mobile_number:(K=(G=i.callData)==null?void 0:G.phone_number)!=null?K:"",userid:(Oe=(ie=i.callData)==null?void 0:ie.agent_id)!=null?Oe:"",type:"QUEUE",transfer_to:(Me=b==null?void 0:b.queue_name)!=null?Me:"",callreferenceid:(Be=(Ue=i.callData)==null?void 0:Ue.convox_id)!=null?Be:"",processid:String((He=(Te=i.callData)==null?void 0:Te.process_id)!=null?He:""),process_name:($e=(Ee=i.callData)==null?void 0:Ee.process_name)!=null?$e:""};s(P.TRANSFER_CALL,fe)}else if(C==="AGENT"){let fe={mobile_number:(ze=(Le=i.callData)==null?void 0:Le.phone_number)!=null?ze:"",userid:(We=(qe=i.callData)==null?void 0:qe.agent_id)!=null?We:"",type:"AGENT",transfer_to:(De=b==null?void 0:b.user_id)!=null?De:"",callreferenceid:(Ge=(Fe=i.callData)==null?void 0:Fe.convox_id)!=null?Ge:"",processid:String((je=(Ke=i.callData)==null?void 0:Ke.process_id)!=null?je:""),process_name:(Xe=(Ye=i.callData)==null?void 0:Ye.process_name)!=null?Xe:""};s(P.TRANSFER_CALL,fe)}};return Go(()=>{d(P.AGENTS_LIST,{status:"IDLE",active:!0}),h(P.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(g,"idleAgentsList"),a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:E(be,{sx:{borderRadius:2},children:[E(W,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[a(J,{variant:"body1",children:" Call Transfer"}),a(ge,{onClick:m,children:a(et,{})})]}),E(W,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[E(W,{sx:{display:"flex",gap:1},children:[a(ee,{variant:l==="process"?"contained":"outlined",onClick:()=>o("process"),children:"Process"}),a(ee,{variant:l==="queues"?"contained":"outlined",onClick:()=>o("queues"),children:"Queues"}),a(ee,{variant:l==="agents"?"contained":"outlined",onClick:()=>o("agents"),children:"Agents"})]}),l==="process"&&a(W,{sx:{display:"flex",gap:1},children:(p=u==null?void 0:u.data)!=null&&p.process&&((y=(x=u==null?void 0:u.data)==null?void 0:x.process)==null?void 0:y.length)>0?(B=(I=u==null?void 0:u.data)==null?void 0:I.process)==null?void 0:B.map((b,C)=>E(W,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[E(J,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[a(Ze,{sx:{marginRight:"4px"}}),b.process_name]}),a(ge,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{f(b,"PROCESS")},children:a(Qe,{})})]},C)):a(J,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Process Found"})}),l==="queues"&&a(W,{sx:{display:"flex",gap:1},children:(O=u==null?void 0:u.data)!=null&&O.queue&&((w=(k=u==null?void 0:u.data)==null?void 0:k.queue)==null?void 0:w.length)>0?(V=(z=u==null?void 0:u.data)==null?void 0:z.queue)==null?void 0:V.map((b,C)=>{var L,R,A,_,H,$;return E(W,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[E(J,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[a(Ze,{sx:{marginRight:"4px"}}),b.queue_name,(A=(R=(L=u==null?void 0:u.data)==null?void 0:L.process)==null?void 0:R.find(M=>M.process_id===b.process_id))!=null&&A.process_name?a(J,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+(($=(H=(_=u==null?void 0:u.data)==null?void 0:_.process)==null?void 0:H.find(M=>M.process_id===b.process_id))==null?void 0:$.process_name)+")"}):""]}),a(ge,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{f(b,"QUEUE")},children:a(Qe,{})})]},C)}):a(J,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Queues Found"})}),l==="agents"&&a(W,{sx:{display:"flex",gap:1},children:g!=null&&g.data&&((Y=g==null?void 0:g.data)==null?void 0:Y.length)>0?(Q=g==null?void 0:g.data)==null?void 0:Q.map((b,C)=>E(W,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[E(J,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[a(Ze,{sx:{marginRight:"4px"}}),b.name]}),a(ge,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{f(b,"AGENT")},children:a(Qe,{})})]},C)):a(J,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Agents Found"})})]})]})})})}function Yo({open:e,setOpen:t,onSubmitDisposition:s}){var m,f;let[i,l]=ue({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),o=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],d=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],g=(p,x)=>{l(y=>X(r({},y),{[p]:x}))},h=()=>{l({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},u=()=>{h(),t(!1)};return a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:E(be,{sx:{borderRadius:2},children:[a(W,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:E(J,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),a(W,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:E(ye,{container:!0,spacing:2,children:[a(ye,{size:6,children:a(Wo,{value:i.disposition,options:o,getOptionLabel:p=>p.label,onChange:(p,x)=>g("disposition",x),size:"small",renderInput:p=>a(he,X(r({},p),{label:"Disposition",fullWidth:!0}))})}),a(ye,{size:6,children:a(Wo,{options:d,getOptionLabel:p=>p.label,value:i.followUp,onChange:(p,x)=>g("followUp",x),size:"small",renderInput:p=>a(he,X(r({},p),{label:"Follow Up",fullWidth:!0}))})}),((f=(m=i==null?void 0:i.followUp)==null?void 0:m.label)==null?void 0:f.toLowerCase())==="yes"&&E(ve,{children:[a(ye,{size:6,children:a(he,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:i.callbackDate,onChange:p=>g("callbackDate",p.target.value),fullWidth:!0})}),a(ye,{size:6,children:a(he,{size:"small",label:"Hours (0-23)",type:"text",inputProps:{min:0,max:23},value:i.callbackHrs,onChange:p=>g("callbackHrs",p.target.value),fullWidth:!0})}),a(ye,{size:6,children:a(he,{size:"small",label:"Minutes (0-59)",type:"text",inputProps:{min:0,max:59},value:i.callbackMins,onChange:p=>g("callbackMins",p.target.value),fullWidth:!0})})]})]})}),E(W,{textAlign:"right",m:2,children:[a(ee,{variant:"outlined",color:"error",size:"large",onClick:u,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),a(ee,{variant:"contained",color:"primary",size:"large",onClick:()=>s(i),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function Xo({open:e,setOpen:t,processList:s=null,handleSelectedProcessor:i}){var o,d;return a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:E(be,{sx:{borderRadius:2},children:[E(W,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[a(J,{variant:"body1",children:" Process List"}),a(ge,{onClick:()=>{t(!1)},children:a(et,{})})]}),a(W,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:((o=s==null?void 0:s.processes)==null?void 0:o.length)>0?(d=s==null?void 0:s.processes)==null?void 0:d.map((g,h)=>a(W,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px",cursor:"pointer","&:hover":{bgcolor:"action.selected"}},onClick:()=>{i(g)},children:E(J,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[a(Ze,{sx:{marginRight:"4px"}}),g.process_name]})},h)):null})]})})})}function Jo({open:e,setOpen:t}){return a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:E(be,{sx:{borderRadius:2},children:[E(W,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[a(J,{variant:"body1",children:" Call History"}),a(ge,{onClick:()=>{t(!1)},children:a(et,{})})]}),a(W,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}import{Fragment as ua,jsx as c,jsxs as ce}from"react/jsx-runtime";function os({onDataChange:e}){var ft,mt,xt,yt,ht,Ct,bt,vt,St,Tt,Et,Lt,Dt,It,Rt,_t,wt,kt,At,Nt,Pt,Ot,Mt,Ut,Bt,Ht,$t,zt,qt,Wt,Ft,Gt,Kt,jt,Yt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,ao,no,io,lo,ro,co,po,uo,go,fo,mo,xo,yo,ho,Co,bo,vo,So,To,Eo,Lo,Do;let t=ca(),{disabled:s,enabled:i,outlined:l}=Ve(),o=xe(),d=da(null),[g,h]=ne(null),[u,m]=ne(!0),[f,p]=ne(null),[x,y]=ne(null),[I,B]=ne(!1),[O,k]=ne(!1),[w,z]=ne(!1),[V,Y]=ne(!1),[Q,b]=ne(!1),[C,L]=ne(""),[R,A]=ne(0),{position:_,isDragging:H,dragRef:$,handleMouseDown:M,handleTouchStart:D}=ct(o.controlPanelPosition,n=>S.setControlPanelPosition(n)),{position:T,isDragging:U,dragRef:F,handleMouseDown:G,handleTouchStart:K}=ct(o.iframePosition,n=>S.setIframePosition(n)),[ie,{data:Oe}]=oe({onSuccess:n=>{var v;console.log("res",n),n&&n.data&&((v=n==null?void 0:n.data)==null?void 0:v.length)>1?Y(!0):(S.setProcess(n==null?void 0:n.data[0]),Y(!1))},onError:()=>{Y(!1)}}),[Me,{isLoading:Ue}]=oe(),[Be,{isLoading:Te}]=oe({onSuccess:()=>{S.setHolding(!o.isHolding)},onError:n=>{console.log("error",n)}}),[He,{isLoading:Ee}]=oe({onSuccess:()=>{S.setMuted(!o.isMuted)},onError:n=>{console.log("error",n)}}),[$e,{isLoading:Le}]=oe(),[ze,{isLoading:qe}]=oe(),[We,{isLoading:De}]=oe(),Fe=pa(n=>{let v=Math.floor(n/60),j=n%60;return`${v.toString().padStart(2,"0")}:${j.toString().padStart(2,"0")}`},[]),Ge=()=>{h(null)},Ke=n=>{m(!0),y(n.currentTarget),S.setStatus("dial")},je=()=>{o.status!=="on call"&&S.setStatus("idle"),y(null)},Ye=n=>{p(n.currentTarget)},Xe=()=>{p(null)},fe=()=>{let n={action:"READYAGENT",userId:o.agentId};$e(P.READY_AGENT,n)},gt=n=>{p(null);let v={action:"AGENTBREAK",break_type:n,userId:o.agentId};ze(P.UPDATE_AGENT_BREAK,v)},ns=n=>{if(n.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(n)){let v={action:"CALL",phone_number:n,userId:o.agentId};Me(P.CLICK_TO_CALL,v)}},is=()=>{let n={action:o.isHolding?"UNHOLD":"HOLD",userId:o.agentId};Be(P.HOLD_CALL,n)},ls=()=>{let n={action:o.isMuted?"UNMUTE":"MUTE",userId:o.agentId};He(P.MUTE_CALL,n)},rs=n=>{var j,se,ae,pe,de,Ie,Re,Io,Ro,_o,wo,ko,Ao,No,Po,Oo;console.log("data",n);let v={action:"ENDCALL",userId:o.agentId,processid:(ae=(se=(j=o.process)==null?void 0:j.process_id)==null?void 0:se.toString())!=null?ae:"",process_name:(de=(pe=o.process)==null?void 0:pe.process_name)!=null?de:"",callreferenceid:(Re=(Ie=o.callData)==null?void 0:Ie.convox_id)!=null?Re:"",mobile_number:(Ro=(Io=o.callData)==null?void 0:Io.phone_number)!=null?Ro:"",disposition:(wo=(_o=n==null?void 0:n.disposition)==null?void 0:_o.value)!=null?wo:"",set_followUp:(Ao=(ko=n==null?void 0:n.followUp)==null?void 0:ko.value)!=null?Ao:"",callback_date:(No=n==null?void 0:n.callbackDate)!=null?No:"",callback_hrs:(Po=n==null?void 0:n.callbackHrs)!=null?Po:"",callback_mins:(Oo=n==null?void 0:n.callbackMins)!=null?Oo:"",endcall_type:"CLOSE"};L(""),We(P.END_CALL,v),S.endCall(),z(!1)};return ot(()=>{let n;return o.callData.status&&o.callData.status==="ONCALL"?n=setInterval(()=>{let v=Math.floor((Date.now()-o.callStartTime)/1e3);A(v)},1e3):A(0),()=>{n&&clearInterval(n)}},[o.callData.status]),ot(()=>{e&&e(o.callData)},[o.callData,e]),ot(()=>{o.agentId?ie(P.PROCESS_LIST,{userId:o.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[o.agentId]),ot(()=>(o.agentId&&(d.current=new WebSocket(`${Uo.WS}?agent_id=${o.agentId}`),d.current.onopen=()=>{console.log("WebSocket connection established")},d.current.onmessage=n=>{try{let v=JSON.parse(n.data);console.log("parsedJSON:",v),S.updateCallData(v),v.status==="ONCALL"&&S.startCall(),v.status==="WRAPUP"&&S.endCall()}catch(v){console.log("Raw message:",n.data)}},d.current.onclose=()=>{console.log("WebSocket connection closed")},d.current.onerror=n=>{console.error("WebSocket error:",n)}),()=>{var n;(n=d.current)==null||n.close()}),[o.agentId]),!o.isInitialized||!o.process?c(re,{children:!!V&&c(Xo,{processList:Oe,open:V,setOpen:Y,handleSelectedProcessor:n=>{S.setProcess(n)}})}):ce(ua,{children:[c(Qo,{in:!0,timeout:300,children:c(es,{ref:$,elevation:H?4:1,sx:{position:"fixed",left:_.x,top:_.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:99999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),userSelect:"none"},children:ce(re,{sx:{display:"flex",alignItems:"center"},children:[ce(re,{sx:{display:"flex",alignItems:"center"},children:[ce(tt,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:M,onTouchStart:D,children:[c(Vo,{})," "]}),c(re,{sx:{marginRight:"10px"},children:c(me,{title:"Dial",children:c(tt,{size:"small",onClick:n=>{var v,j,se,ae,pe,de,Ie,Re;((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())!=="ONCALL"&&((ae=(se=o.callData)==null?void 0:se.status)==null?void 0:ae.toUpperCase())!=="BREAK"&&((de=(pe=o.callData)==null?void 0:pe.status)==null?void 0:de.toUpperCase())!=="RINGING"&&((Re=(Ie=o.callData)==null?void 0:Ie.status)==null?void 0:Re.toUpperCase())!=="WRAPUP"&&Ke(n)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:c(la,{sx:{color:((mt=(ft=o.callData)==null?void 0:ft.status)==null?void 0:mt.toUpperCase())==="ONCALL"||((yt=(xt=o.callData)==null?void 0:xt.status)==null?void 0:yt.toUpperCase())==="BREAK"||((Ct=(ht=o.callData)==null?void 0:ht.status)==null?void 0:Ct.toUpperCase())==="RINGING"||((vt=(bt=o.callData)==null?void 0:bt.status)==null?void 0:vt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),c(ts,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Fe(R)}),qe||Le?c(re,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:c(Pe,{size:"20px"})}):c(ts,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(Et=(Tt=(St=o.callData)==null?void 0:St.status)==null?void 0:Tt.toUpperCase())!=null?Et:"N/A"}),c(re,{onClick:Ye,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:c(js,{})})]}),ce(re,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[c(me,{title:"Agent Ready",children:c(Se,{variant:((Dt=(Lt=o.callData)==null?void 0:Lt.status)==null?void 0:Dt.toUpperCase())==="BREAK"||((Rt=(It=o.callData)==null?void 0:It.status)==null?void 0:Rt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:n=>{var v,j,se,ae;(((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())==="BREAK"||((ae=(se=o.callData)==null?void 0:se.status)==null?void 0:ae.toUpperCase())==="MISSED")&&(n.stopPropagation(),fe())},classes:{root:((wt=(_t=o.callData)==null?void 0:_t.status)==null?void 0:wt.toUpperCase())==="BREAK"||((At=(kt=o.callData)==null?void 0:kt.status)==null?void 0:At.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:r({},((Pt=(Nt=o.callData)==null?void 0:Nt.status)==null?void 0:Pt.toUpperCase())==="BREAK"||((Mt=(Ot=o.callData)==null?void 0:Ot.status)==null?void 0:Mt.toUpperCase())==="MISSED"?l:i),disabled:Le,children:c(aa,{})})}),c(me,{title:o.isHolding?"Resume":"Hold",children:c(Se,{variant:o.isHolding&&((Bt=(Ut=o.callData)==null?void 0:Ut.status)==null?void 0:Bt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:n=>{n.stopPropagation(),is()},sx:o.isHolding&&(($t=(Ht=o.callData)==null?void 0:Ht.status)==null?void 0:$t.toUpperCase())==="ONCALL"?r({},i):((qt=(zt=o.callData)==null?void 0:zt.status)==null?void 0:qt.toUpperCase())==="ONCALL"?r({},l):r({},s),disabled:((Ft=(Wt=o.callData)==null?void 0:Wt.status)==null?void 0:Ft.toUpperCase())!=="ONCALL"&&!o.isHolding||Te,children:Te?c(Pe,{size:"20px",sx:{color:t.palette.primary.main}}):o.isHolding?c(sa,{}):c(ea,{})})}),c(me,{title:o.isMuted?"Unmute":"Mute",children:c(Se,{variant:o.isMuted&&((Kt=(Gt=o.callData)==null?void 0:Gt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:n=>{n.stopPropagation(),ls()},sx:o.isMuted&&((Yt=(jt=o.callData)==null?void 0:jt.status)==null?void 0:Yt.toUpperCase())==="ONCALL"?r({},i):((Jt=(Xt=o.callData)==null?void 0:Xt.status)==null?void 0:Jt.toUpperCase())==="ONCALL"?r({},l):r({},s),disabled:((Qt=(Vt=o.callData)==null?void 0:Vt.status)==null?void 0:Qt.toUpperCase())!=="ONCALL"&&!o.isMuted||Ee,children:Ee?c(Pe,{size:"20px",sx:{color:t.palette.primary.main}}):o.isMuted?c(Zs,{}):c(Qs,{})})}),c(me,{title:"Transfer Call",children:c(Se,{variant:O?"contained":"outlined",onClick:n=>{var v,j;((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())==="ONCALL"&&(n.stopPropagation(),k(!0))},sx:O?r({},i):((eo=(Zt=o.callData)==null?void 0:Zt.status)==null?void 0:eo.toUpperCase())==="ONCALL"?r({},l):r({},s),disabled:((oo=(to=o.callData)==null?void 0:to.status)==null?void 0:oo.toUpperCase())!=="ONCALL",children:c(na,{})})}),c(me,{title:"Conference Call",children:c(Se,{variant:I?"contained":"outlined",onClick:n=>{var v,j;((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())==="ONCALL"&&(n.stopPropagation(),B(!0))},sx:I?r({},i):((ao=(so=o.callData)==null?void 0:so.status)==null?void 0:ao.toUpperCase())==="ONCALL"?r({},l):r({},s),disabled:((io=(no=o.callData)==null?void 0:no.status)==null?void 0:io.toUpperCase())!=="ONCALL",children:c(Js,{})})}),c(me,{title:"End Call",children:c(Se,{variant:((ro=(lo=o.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())==="ONCALL"||((po=(co=o.callData)==null?void 0:co.status)==null?void 0:po.toUpperCase())==="RINGING"||((go=(uo=o.callData)==null?void 0:uo.status)==null?void 0:go.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:n=>{var v,j,se,ae,pe,de;(((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())==="ONCALL"||((ae=(se=o.callData)==null?void 0:se.status)==null?void 0:ae.toUpperCase())==="RINGING"||((de=(pe=o.callData)==null?void 0:pe.status)==null?void 0:de.toUpperCase())==="WRAPUP")&&(n.stopPropagation(),z(!0))},sx:((mo=(fo=o.callData)==null?void 0:fo.status)==null?void 0:mo.toUpperCase())==="ONCALL"||((yo=(xo=o.callData)==null?void 0:xo.status)==null?void 0:yo.toUpperCase())==="RINGING"||((Co=(ho=o.callData)==null?void 0:ho.status)==null?void 0:Co.toUpperCase())==="WRAPUP"?X(r({},i),{borderRight:"1px",backgroundColor:"error.main",minWidth:"60px !important",boxShadow:" 0px 2px 1px #5f3f3f",border:`1px solid ${t.palette.error.light}`,height:"40px","&:hover":{bgcolor:"error.light",boxShadow:" 0px 2px 1px #5f3f3f",border:`0px solid ${t.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${t.palette.primary.light}`}}):X(r({},s),{minWidth:"60px !important"}),disabled:((vo=(bo=o.callData)==null?void 0:bo.status)==null?void 0:vo.toUpperCase())!=="ONCALL"&&((To=(So=o.callData)==null?void 0:So.status)==null?void 0:To.toUpperCase())!=="RINGING"&&((Lo=(Eo=o.callData)==null?void 0:Eo.status)==null?void 0:Lo.toUpperCase())!=="WRAPUP"||De,children:De?c(Pe,{size:"20px",color:"error"}):c(Ys,{})})})]})]})})}),c(Qo,{in:!0,timeout:300,children:ce(es,{ref:F,elevation:U?4:1,sx:{position:"fixed",left:T.x,top:T.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:99999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),visibility:u?"visible":"hidden",userSelect:"none"},children:[ce(re,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:G,onTouchStart:K,children:[c(Vo,{sx:{transform:"rotate(90deg)"}})," ",c(tt,{onClick:()=>m(!1),children:c(Xs,{})})]}),c("iframe",{src:`https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${o.agentId}&process_id=${(Do=o.process)==null?void 0:Do.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay"})]})}),c(ut,{anchorEl:x,open:!!x,onClose:je,onClick:n=>n.stopPropagation(),sx:{zIndex:99999},children:ce(re,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[c(ra,{size:"small",value:C,placeholder:"Enter Mobile No.",onChange:n=>{L(n.target.value)}}),c(tt,{color:"info",onClick:()=>{ns(C)},children:Ue?c(Pe,{size:"20px",sx:{color:t.palette.success.main}}):c(oa,{color:"success"})})]})}),ce(ut,{anchorEl:f,open:!!f,onClose:Xe,onClick:n=>n.stopPropagation(),sx:{zIndex:99999},children:[c(Zo,{onClick:()=>gt("Lunch"),children:"- Lunch"}),c(Zo,{onClick:()=>gt("Tea"),children:"- Tea"})]}),c(ut,{anchorEl:g,open:!!g,onClose:Ge,onClick:n=>n.stopPropagation(),sx:{zIndex:99999},children:ce(re,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[c(dt,{icon:c(Vs,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),c(dt,{icon:c(ta,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),c(dt,{icon:c(ia,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!I&&c(Ko,{open:I,setOpen:B}),!!O&&c(jo,{open:O,setOpen:k}),!!w&&c(Yo,{open:w,setOpen:z,onSubmitDisposition:rs}),!!Q&&c(Jo,{open:Q,setOpen:b})]})}import{jsx as ga}from"react/jsx-runtime";var ss=({children:e})=>ga(zo,{children:e});import{jsx as as}from"react/jsx-runtime";function fa({onDataChange:e}){return as(ss,{children:as(os,{onDataChange:e})})}function Bn({apiKey:e,tenantId:t,agentId:s}){S.initialize(e,s),nt.init({apiKey:e,tenantId:t,agentId:s,baseUrl:N})}export{fa as CallControlPanel,Bn as initSDK,vs as useEndCall,Cs as useLogout};
|
|
1
|
+
var cs=Object.defineProperty,ps=Object.defineProperties;var ds=Object.getOwnPropertyDescriptors;var Mo=Object.getOwnPropertySymbols;var us=Object.prototype.hasOwnProperty,gs=Object.prototype.propertyIsEnumerable;var st=(e,t,s)=>t in e?cs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,r=(e,t)=>{for(var s in t||(t={}))us.call(t,s)&&st(e,s,t[s]);if(Mo)for(var s of Mo(t))gs.call(t,s)&&st(e,s,t[s]);return e},X=(e,t)=>ps(e,ds(t));var te=(e,t,s)=>st(e,typeof t!="symbol"?t+"":t,s);var at=class{constructor(){te(this,"config",null);te(this,"ticketId",null);te(this,"baseUrl","");te(this,"eventQueue",[]);te(this,"isOnline",!0);te(this,"retryQueue",[]);te(this,"flushTimer",null)}async init(t){this.config=r({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},t),this.baseUrl=t.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let s=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),s}isInitialized(){return this.config!==null&&this.ticketId!==null}getConfig(){return this.config}getTicketId(){return this.ticketId}async createTicket(){if(!this.config)throw new Error("EventTracker not initialized");try{let t=await this.makeRequest("/api/v1/et/init",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({agentId:this.config.agentId,sessionId:this.config.sessionId})});if(!t.ok)throw new Error(`Failed to initialize: ${t.status} ${t.statusText}`);let s=await t.json();return this.ticketId=s.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(t){throw console.error("EventTracker initialization failed:",t),t}}async logEvent(t,s){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",t);return}let i={eventType:t,eventData:s,timestamp:Date.now()};if(this.eventQueue.push(i),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(i)}catch(l){console.warn("Failed to send event, will retry later:",l)}}async sendEvent(t){if(!(!this.config||!this.ticketId))try{let s=await this.makeRequest("/api/v1/et/event",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId,eventType:t.eventType,eventData:t.eventData})});if(!s.ok)throw new Error(`Failed to log event: ${s.status} ${s.statusText}`);let i=this.eventQueue.findIndex(l=>l.timestamp===t.timestamp);i>-1&&this.eventQueue.splice(i,1)}catch(s){console.error("Event logging failed:",s),this.retryQueue.push(()=>this.sendEvent(t))}}async closeTicket(){if(!this.config||!this.ticketId)throw new Error("EventTracker not initialized");await this.flush();try{let t=await this.makeRequest("/api/v1/et/close",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId})});if(!t.ok)throw new Error(`Failed to close ticket: ${t.status} ${t.statusText}`);this.ticketId=null,this.stopPeriodicFlush(),console.log("Ticket closed successfully")}catch(t){throw console.error("Ticket close failed:",t),t}}async flush(){if(!this.isOnline||this.eventQueue.length===0)return;let t=[...this.eventQueue];for(let i of t)await this.sendEvent(i);let s=[...this.retryQueue];this.retryQueue=[];for(let i of s)try{await i()}catch(l){console.error("Retry failed:",l)}}async makeRequest(t,s){var o;let i=`${this.baseUrl}${t}`,l=((o=this.config)==null?void 0:o.retryAttempts)||3;for(let d=1;d<=l;d++)try{return await fetch(i,s)}catch(g){if(d===l)throw g;let h=Math.min(1e3*Math.pow(2,d-1),1e4);await new Promise(u=>setTimeout(u,h))}throw new Error("Max retries exceeded")}setupAutoTracking(){var i;if(typeof window=="undefined"||!((i=this.config)!=null&&i.autoTrack))return;let t=this.config.autoTrack===!0?{}:this.config.autoTrack;if(t.pageVisits!==!1&&this.logEvent("pageVisit",{url:window.location.href,title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},timestamp:new Date().toISOString()}).catch(l=>console.warn("Failed to track page visit:",l)),t.clicks!==!1&&document.addEventListener("click",l=>{var d;let o=l.target;(o.tagName==="BUTTON"||o.tagName==="A"||o.onclick||o.getAttribute("role")==="button"||o instanceof HTMLButtonElement&&o.type==="button")&&this.logEvent("click",{element:o.tagName,text:(d=o.textContent)==null?void 0:d.trim().substring(0,100),href:o.getAttribute("href"),id:o.id,className:o.className,role:o.getAttribute("role"),position:{x:l.clientX,y:l.clientY},timestamp:new Date().toISOString()}).catch(g=>console.warn("Failed to track click:",g))}),t.forms!==!1&&document.addEventListener("submit",l=>{let o=l.target,d=new FormData(o),g={};d.forEach((h,u)=>{g[u]=h.toString()}),this.logEvent("formSubmission",{formId:o.id,action:o.action,method:o.method,fields:Object.keys(g),fieldCount:Object.keys(g).length,timestamp:new Date().toISOString()}).catch(h=>console.warn("Failed to track form submission:",h))}),t.inputs!==!1){let l;document.addEventListener("input",o=>{let d=o.target;(d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.tagName==="SELECT")&&(clearTimeout(l),l=setTimeout(()=>{var g;this.logEvent("fieldChange",{element:d.tagName,type:d.getAttribute("type"),name:d.getAttribute("name"),id:d.id,valueLength:((g=d.value)==null?void 0:g.length)||0,timestamp:new Date().toISOString()}).catch(h=>console.warn("Failed to track field change:",h))},1e3))})}let s=Date.now();window.addEventListener("beforeunload",()=>{let l=Date.now()-s;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:l,timestamp:new Date().toISOString()}),this.ticketId&&navigator.sendBeacon(`${this.baseUrl}/api/v1/et/close`,JSON.stringify({ticketId:this.ticketId}))}),t.visibility!==!1&&document.addEventListener("visibilitychange",()=>{this.logEvent("visibilityChange",{hidden:document.hidden,visibilityState:document.visibilityState,timestamp:new Date().toISOString()})}),t.errors!==!1&&(window.addEventListener("error",l=>{this.logEvent("jsError",{message:l.message,filename:l.filename,lineno:l.lineno,colno:l.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",l=>{var o;this.logEvent("unhandledRejection",{reason:(o=l.reason)==null?void 0:o.toString(),timestamp:new Date().toISOString()})})),t.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let l=window.performance.navigation,o=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:o.navigationStart,loadTime:o.loadEventEnd-o.navigationStart,domReady:o.domContentLoadedEventEnd-o.navigationStart,renderTime:o.loadEventEnd-o.domContentLoadedEventEnd,navigationType:l.type,redirectCount:l.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(this.isOnline=navigator.onLine,window.addEventListener("online",()=>{this.isOnline=!0,console.log("EventTracker: Back online, flushing queued events"),this.flush()}),window.addEventListener("offline",()=>{this.isOnline=!1,console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){var s;this.flushTimer&&clearInterval(this.flushTimer);let t=((s=this.config)==null?void 0:s.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},t)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},nt=new at;typeof window!="undefined"&&(window.EventTracker=nt);var it=class{constructor(){te(this,"state");te(this,"listeners",[]);te(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{apiKey:null,process:null,agentId:"",isInitialized:!1,isHolding:!1,isMuted:!1,status:"idle",callStartTime:null,controlPanelPosition:{x:10,y:10},iframePosition:{x:10,y:80},callData:{agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:[{line:1,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:2,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:3,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:4,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:5,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1}]}}loadFromStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);if(t){let s=JSON.parse(t);this.state=X(r({},this.state),{apiKey:s.apiKey||"",agentId:s.agentId||"",process:s.process||null,isInitialized:s.isInitialized||!1,isHolding:s.isHolding||!1,isMuted:s.isMuted||!1,status:s.status||"idle",callStartTime:s.callStartTime||null,controlPanelPosition:s.controlPanelPosition||{x:10,y:10},iframePosition:s.iframePosition||{x:10,y:80},callData:s.callData||{mobileNumber:"",callReferenceId:"",agentLoginId:""},conferenceLine:s.conferenceLine&&Array.isArray(s.conferenceLine)&&s.conferenceLine.length>0?s.conferenceLine:this.state.conferenceLine})}}catch(t){console.warn("Failed to load SDK state from localStorage:",t)}}saveToStorage(){try{let t={apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,isHolding:this.state.isHolding,isMuted:this.state.isMuted,status:this.state.status,callStartTime:this.state.callStartTime,controlPanelPosition:this.state.controlPanelPosition,iframePosition:this.state.iframePosition,callData:this.state.callData,conferenceLine:this.state.conferenceLine};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(t))}catch(t){console.warn("Failed to save SDK state to localStorage:",t)}}notifyListeners(){this.listeners.forEach(t=>t())}initialize(t,s){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("API key not available");this.state.apiKey=t,this.state.agentId=s,this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return r({},this.state)}subscribe(t){return this.listeners.push(t),()=>{let s=this.listeners.indexOf(t);s>-1&&this.listeners.splice(s,1)}}setHolding(t){this.state.isHolding=t,this.saveToStorage(),this.notifyListeners()}setMuted(t){this.state.isMuted=t,this.saveToStorage(),this.notifyListeners()}setStatus(t){this.state.status=t,this.saveToStorage(),this.notifyListeners()}setProcess(t){this.state.process=t,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(t){this.state.controlPanelPosition=t,this.saveToStorage(),this.notifyListeners()}setIframePosition(t){this.state.iframePosition=t,this.saveToStorage(),this.notifyListeners()}startCall(){this.state.callStartTime=Date.now(),this.state.status="on call",this.saveToStorage(),this.notifyListeners()}endCall(){this.state.callStartTime=null,this.state.status="idle",this.state.isHolding=!1,this.state.isMuted=!1,this.saveToStorage(),this.notifyListeners()}updateCallData(t){this.state.callData=r(r({},this.state.callData),t),this.saveToStorage(),this.notifyListeners()}setConferenceLine(t){var i;(!this.state.conferenceLine||!Array.isArray(this.state.conferenceLine))&&(console.warn("Conference line data corrupted, resetting to initial state"),this.state.conferenceLine=this.getInitialState().conferenceLine);let s=(i=this.state.conferenceLine)==null?void 0:i.map(l=>l.line===t.line?t:l);this.state.conferenceLine=s,this.saveToStorage(),this.notifyListeners()}resetConferenceLines(){this.state.conferenceLine=this.getInitialState().conferenceLine,this.saveToStorage(),this.notifyListeners()}clearStorageAndReset(){try{localStorage.removeItem(this.STORAGE_KEY),this.state=this.getInitialState(),this.notifyListeners()}catch(t){console.warn("Failed to clear localStorage:",t)}}debugStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",t),t&&console.log("Parsed localStorage data:",JSON.parse(t)),console.log("Current state:",this.state)}catch(t){console.error("Error debugging storage:",t)}}getConferenceLines(){return this.state.conferenceLine||[]}},S=new it;import{useCallback as ys,useState as _e}from"react";var N="http://192.168.101.177:8095",fs="ws://192.168.101.177:8095",q={v1:"/api/v1"},P={LOGIN:`${N}${q.v1}/cti/login?provider=convox`,READY_AGENT:`${N}${q.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${N}${q.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${N}${q.v1}/cti/calls?provider=convox`,HOLD_CALL:`${N}${q.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${N}${q.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${N}${q.v1}/cti/unmute-call?provider=convox`,END_CALL:`${N}${q.v1}/cti/calls/end?provider=convox`,LOGOUT:`${N}${q.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${N}${q.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${N}${q.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${N}${q.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${N}${q.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${N}${q.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${N}${q.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${N}${q.v1}/cti/users`,PROCESS_LIST:`${N}${q.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${N}${q.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${N}${q.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${N}${q.v1}/users/get_sentiment_analysis`},Uo={WS:`${fs}${q.v1}/cti/ws`};import ms from"axios";var xs="12345",lt=ms.create({baseURL:N,headers:{"Content-Type":"application/json",Authorization:xs},timeout:1e4});lt.interceptors.request.use(e=>{let t="12345";return t&&e.headers&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e instanceof Error?e:new Error(String(e))));lt.interceptors.response.use(e=>e,async e=>{var s;let t=e.config;return((s=e.response)==null?void 0:s.status)===401&&!t._retry&&(t._retry=!0),Promise.reject(e instanceof Error?e:new Error(String(e)))});var Z=lt;var hs=()=>{let[e,t]=_e(!1),[s,i]=_e(!1),[l,o]=_e(!1),[d,g]=_e(null),[h,u]=_e(null);return{logout:ys(()=>{var x;let f=JSON.parse((x=localStorage.getItem("call-control-sdk-state"))!=null?x:"");t(!0);let p={action:"LOGOUTUSER",userId:f.agentId||""};Z.post(P.LOGOUT,p).then(y=>{S.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),u(y==null?void 0:y.data),i(!0)}).catch(y=>{o(!0),g(y)}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:s,isError:l,error:d,data:h}},Cs=hs;import{useCallback as bs,useState as we}from"react";var vs=()=>{let[e,t]=we(!1),[s,i]=we(!1),[l,o]=we(!1),[d,g]=we(null),[h,u]=we(null);return{handleEndCall:bs(f=>{var y,I,B,O,k,w,z,V,Y,Q,b,C,L,R,A;let p=JSON.parse((y=localStorage.getItem("call-control-sdk-state"))!=null?y:"");t(!0);let x={action:"ENDCALL",userId:p==null?void 0:p.agentId,processid:(O=(B=(I=p==null?void 0:p.process)==null?void 0:I.process_id)==null?void 0:B.toString())!=null?O:"",process_name:(w=(k=p==null?void 0:p.process)==null?void 0:k.process_name)!=null?w:"",callreferenceid:(V=(z=p==null?void 0:p.callData)==null?void 0:z.convox_id)!=null?V:"",mobile_number:(Q=(Y=p==null?void 0:p.callData)==null?void 0:Y.phone_number)!=null?Q:"",disposition:(b=f==null?void 0:f.disposition)!=null?b:"RES",set_followUp:(C=f==null?void 0:f.followUp)!=null?C:"N",callback_date:(L=f==null?void 0:f.callbackDate)!=null?L:"",callback_hrs:(R=f==null?void 0:f.callbackHrs)!=null?R:"",callback_mins:(A=f==null?void 0:f.callbackMins)!=null?A:"",endcall_type:"CLOSE"};Z.post(P.END_CALL,x).then(_=>{S.endCall(),u(_==null?void 0:_.data),i(!0)}).catch(_=>{o(!0),g(_)}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:s,isError:l,error:d,data:h}};import{ArrowDropDown as js,CallEnd as Ys,Close as Xs,DragIndicator as Vo,Group as Js,Layers as Vs,Mic as Qs,MicOff as Zs,Pause as ea,Pending as ta,Phone as oa,PlayArrow as sa,SupportAgent as aa,TransferWithinAStation as na,Upcoming as ia,WifiCalling3 as la}from"@mui/icons-material";import{Box as re,Button as Te,Chip as dt,CircularProgress as Pe,Fade as Qo,IconButton as tt,Menu as ut,MenuItem as Zo,Paper as es,TextField as ra,Tooltip as me,Typography as ts,useTheme as ca}from"@mui/material";import{useCallback as pa,useEffect as ot,useRef as da,useState as ne}from"react";import{useCallback as Je,useRef as rt,useState as Bo}from"react";function ct(e,t){let[s,i]=Bo(e),[l,o]=Bo(!1),d=rt(),g=rt({x:0,y:0}),h=rt({x:0,y:0}),u=Je(x=>{let y=d.current;if(!y)return;let I=y.getBoundingClientRect(),B=window.innerWidth,O=window.innerHeight,k={x:Math.max(0,Math.min(x.x,B-I.width)),y:Math.max(0,Math.min(x.y,O-I.height))};i(k),t==null||t(k)},[t]),m=Je((x,y)=>{o(!0),g.current={x,y},h.current=s;let I=(w,z)=>{let V=w-g.current.x,Y=z-g.current.y;u({x:h.current.x+V,y:h.current.y+Y})},B=w=>{w.preventDefault(),I(w.clientX,w.clientY)},O=w=>{w.preventDefault();let z=w.touches[0];z&&I(z.clientX,z.clientY)},k=()=>{o(!1),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",k),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",k)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",k),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",k)},[s,u]),f=Je(x=>{x.preventDefault(),m(x.clientX,x.clientY)},[m]),p=Je(x=>{x.preventDefault();let y=x.touches[0];y&&m(y.clientX,y.clientY)},[m]);return{position:s,isDragging:l,dragRef:d,handleMouseDown:f,handleTouchStart:p}}import{useState as Ts,useEffect as Ss}from"react";function xe(){let[e,t]=Ts(S.getState());return Ss(()=>S.subscribe(()=>{t(S.getState())}),[]),e}import{useCallback as _s,useReducer as ws}from"react";import{createContext as Es,useContext as Ls,useState as pt}from"react";import{Snackbar as Ds,Alert as Is}from"@mui/material";import{jsx as Ho,jsxs as Rs}from"react/jsx-runtime";var $o=Es(void 0),ke=()=>{let e=Ls($o);if(!e)throw new Error("useToast must be used inside ToastProvider");return e},zo=({children:e})=>{let[t,s]=pt(!1),[i,l]=pt(""),[o,d]=pt("info"),g=(h,u="info")=>{l(h),d(u),s(!0)};return Rs($o.Provider,{value:{showToast:g},children:[e,Ho(Ds,{open:t,color:o,autoHideDuration:3e3,onClose:()=>s(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:Ho(Is,{variant:"filled",severity:o,onClose:()=>s(!1),sx:{width:"100%"},children:i})})]})};var ks={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},As=(e,t)=>{if(t.type==="isLoading")return X(r({},e),{isLoading:t.payload});if(t.type==="isSuccess")return X(r({},e),{isSuccess:!0,data:t.payload});if(t.type==="isError")return X(r({},e),{isError:!0,error:t.payload});if(t.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var oe=(e={})=>{let{onSuccess:t=null,onError:s=null}=e,{showToast:i}=ke(),[l,o]=ws(As,ks);return[_s((g,h,u={})=>{o({type:"isLoading",payload:!0}),Z.post(g,h,u).then(m=>{var f,p;o({type:"isSuccess",payload:m.data}),t==null||t(m.data,h),console.log((f=m.data)==null?void 0:f.message,"res45"),i((p=m.data)==null?void 0:p.message,"success")}).catch(m=>{var p,x,y,I,B,O,k,w,z,V,Y,Q;let f={status:(x=(p=m.response)==null?void 0:p.status)!=null?x:500,message:((I=(y=m.response)==null?void 0:y.data)==null?void 0:I.detail)||((O=(B=m.response)==null?void 0:B.data)==null?void 0:O.message)||m.message||"An unknown error occurred",data:(w=(k=m.response)==null?void 0:k.data)!=null?w:null,statusText:(V=(z=m.response)==null?void 0:z.statusText)!=null?V:"",code:(Y=m==null?void 0:m.code)!=null?Y:"",name:(Q=m==null?void 0:m.name)!=null?Q:""};i(f.message,"error"),o({type:"isError",payload:f}),s==null||s(f,h)}).finally(()=>{o({type:"isLoading",payload:!1})})},[t,s,i]),l]};import{Call as Qe,CallEnd as qo,CallSplit as Os,Close as et,Mic as Ms,MicOff as Us,Pause as Bs,PhoneDisabled as Hs,PlayArrow as $s,SupportAgent as Ze}from"@mui/icons-material";import{Box as W,Button as ee,Dialog as Ne,IconButton as ge,Paper as be,TextField as he,Typography as J,Autocomplete as Wo,Grid as ye,Tooltip as Ae,useTheme as zs,TableContainer as qs,Table as Ws,TableHead as Fs,TableRow as Fo,TableCell as le,TableBody as Gs,CircularProgress as Ce}from"@mui/material";import{useEffect as Go,useState as ue}from"react";import{useTheme as Ns}from"@mui/material";var Ps=()=>{let e=Ns();return{disabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",border:"1px solid rgb(206, 204, 204)",height:"40px","&:hover":{boxShadow:" 0px 2px 2px rgba(0, 0, 0, 0.79)",border:`1px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}},enabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${e.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}},outlined:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:e.palette.grey[200],boxShadow:`0px 2px 1px ${e.palette.primary.light}`,border:`0px solid ${e.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${e.palette.primary.main}`,border:`0px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}}}},Ve=Ps;import{Fragment as ve,jsx as a,jsxs as E}from"react/jsx-runtime";var Ks=({each:e})=>{var Q,b;let t=xe(),{showToast:s}=ke(),{disabled:i,enabled:l,outlined:o}=Ve(),d=zs(),[g,h]=ue(!1),[u,m]=ue(!1),[f,p]=ue(!1),[x,y]=ue(!1),[I,B]=ue(!1),O=(C,L)=>{S.setConferenceLine(r(r({},C),L))},k=(C,L)=>{var _,H,$,M;let R=r(r({},C),L);h(!0);let A={action:"EXTERNAL_CONFERENCE",operation:`CALL${R.line}`,line_used:String(R.line),thirdparty_no:R.phone,userid:(H=(_=t.callData)==null?void 0:_.agent_id)!=null?H:"",process:(M=($=t.callData)==null?void 0:$.process_name)!=null?M:""};Z.post(P.CONFERENCE_CALL,A).then(D=>{var T;s((T=D.data)==null?void 0:T.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(D=>{var U,F,G,K;let T=((F=(U=D.response)==null?void 0:U.data)==null?void 0:F.detail)||((K=(G=D.response)==null?void 0:G.data)==null?void 0:K.message)||D.message||"An unknown error occurred";s(T,"error")}).finally(()=>{h(!1)})},w=(C,L)=>{var _,H,$,M;let R=r(r({},C),L);m(!0);let A={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(R.line),thirdparty_no:R.phone,userid:(H=(_=t.callData)==null?void 0:_.agent_id)!=null?H:"",process:(M=($=t.callData)==null?void 0:$.process_name)!=null?M:""};Z.post(P.CONFERENCE_CALL,A).then(D=>{var T;s((T=D.data)==null?void 0:T.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(D=>{var U,F,G,K;let T=((F=(U=D.response)==null?void 0:U.data)==null?void 0:F.detail)||((K=(G=D.response)==null?void 0:G.data)==null?void 0:K.message)||D.message||"An unknown error occurred";s(T,"error")}).finally(()=>{m(!1)})},z=(C,L,R)=>{var H,$,M,D;let A=r(r({},C),L);p(!0);let _={action:"EXTERNAL_CONFERENCE",operation:R,hold_channel_no:R==="HOLDUSER"?`hold${A.line}`:`unhold${A.line}`,userid:($=(H=t.callData)==null?void 0:H.agent_id)!=null?$:"",process:(D=(M=t.callData)==null?void 0:M.process_name)!=null?D:""};Z.post(P.CONFERENCE_CALL_HOLD_OR_UN_HOLD,_).then(T=>{var U;s((U=T.data)==null?void 0:U.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(T=>{var F,G,K,ie;let U=((G=(F=T.response)==null?void 0:F.data)==null?void 0:G.detail)||((ie=(K=T.response)==null?void 0:K.data)==null?void 0:ie.message)||T.message||"An unknown error occurred";s(U,"error")}).finally(()=>{p(!1)})},V=(C,L,R)=>{var H,$,M,D;let A=r(r({},C),L);y(!0);let _={action:"EXTERNAL_CONFERENCE",operation:R,channel_no:R==="MUTEUSER"?`mute${A.line}`:`play${A.line}`,userid:($=(H=t.callData)==null?void 0:H.agent_id)!=null?$:"",thirdparty_no:A.phone,process:(D=(M=t.callData)==null?void 0:M.process_name)!=null?D:""};Z.post(P.CONFERENCE_CALL_MUTE_OT_UN_MUTE,_).then(T=>{var U;s((U=T.data)==null?void 0:U.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(T=>{var F,G,K,ie;let U=((G=(F=T.response)==null?void 0:F.data)==null?void 0:G.detail)||((ie=(K=T.response)==null?void 0:K.data)==null?void 0:ie.message)||T.message||"An unknown error occurred";s(U,"error")}).finally(()=>{y(!1)})},Y=(C,L)=>{var _,H,$,M;let R=r(r({},C),L);B(!0);let A={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(R.line-1),user_type:`THIRDPARTY${R.line-1}`,thirdparty_no:R.phone,userid:(H=(_=t.callData)==null?void 0:_.agent_id)!=null?H:"",process:(M=($=t.callData)==null?void 0:$.process_name)!=null?M:""};Z.post(P.CONFERENCE_CALL_END,A).then(D=>{var T;s((T=D.data)==null?void 0:T.message,"success"),S.setConferenceLine(r(r({},C),L))}).catch(D=>{var U,F,G,K;let T=((F=(U=D.response)==null?void 0:U.data)==null?void 0:F.detail)||((K=(G=D.response)==null?void 0:G.data)==null?void 0:K.message)||D.message||"An unknown error occurred";s(T,"error")}).finally(()=>{B(!1)})};return E(Fo,{sx:{border:"2px solid #fff"},children:[a(le,{sx:{padding:"6px"},children:E(J,{children:["Line ",(Q=e==null?void 0:e.line)!=null?Q:"",". "]})}),a(le,{sx:{padding:"6px"},children:a(J,{variant:"body2",sx:{px:1,borderRadius:"10px",width:"80px",maxWidth:"100px"},children:(b=e==null?void 0:e.status)!=null?b:""})}),a(le,{sx:{padding:"6px"},children:a(ee,{sx:{textTransform:"capitalize"},size:"small",children:a(J,{variant:"body2",children:(e==null?void 0:e.line)===1?"Internal":"External"})})}),a(le,{sx:{padding:"6px"},children:a(he,{size:"small",placeholder:"Phone Number",value:(e==null?void 0:e.phone)||"",disabled:(e==null?void 0:e.line)===1,onChange:C=>{O(e,{phone:C.target.value})}})}),a(le,{sx:{padding:"6px"},children:E(W,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[a(Ae,{title:"Call",children:a(ee,{variant:e!=null&&e.isCallStart?"outlined":"contained",color:"success",sx:e!=null&&e.isCallStart?r({},i):X(r({},l),{border:`0px solid ${d.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${d.palette.success.light}`,border:`0px solid ${d.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${d.palette.primary.light}`}}),onClick:()=>{k(e,{isCallStart:!0,status:"ONCALL"})},disabled:(e==null?void 0:e.isCallStart)||g,children:g?a(Ce,{size:"20px",color:"success"}):a(Qe,{sx:{color:e!=null&&e.isCallStart?"default":"#e7e7e7ff"}})})}),a(Ae,{title:"Merge Call",children:a(ee,{variant:e!=null&&e.isMergeCall?"contained":"outlined",sx:e!=null&&e.isMergeCall&&(e!=null&&e.isCallStart)?r({},i):e!=null&&e.isCallStart?r({},o):r({},i),onClick:()=>{w(e,{isMergeCall:!0,status:"ONCALL"})},disabled:!(e!=null&&e.isCallStart)||u,children:u?a(Ce,{size:"20px",sx:{color:e!=null&&e.isMergeCall?"#e7e7e7ff":d.palette.primary.main}}):a(Os,{})})}),a(Ae,{title:e.isHold?"Hold":"Un Hold",children:a(ee,{variant:e!=null&&e.isHold?"contained":"outlined",sx:e!=null&&e.isHold&&(e!=null&&e.isCallStart)?r({},i):e!=null&&e.isCallStart?r({},o):r({},i),onClick:()=>{e.isHold?z(e,{isHold:!1},"UNHOLDUSER"):z(e,{isHold:!0},"HOLDUSER")},disabled:!(e!=null&&e.isCallStart)||f,children:f?a(Ce,{size:"20px",sx:{color:d.palette.primary.main}}):e.isHold?a($s,{}):a(Bs,{})})}),a(Ae,{title:e.isMute?"Mute":"Un Mute",children:a(ee,{variant:e!=null&&e.isMute?"contained":"outlined",sx:e!=null&&e.isMute&&(e!=null&&e.isCallStart)?r({},i):e!=null&&e.isCallStart?r({},o):r({},i),onClick:()=>{e.isMute?V(e,{isMute:!1},"PLAYUSER"):V(e,{isMute:!0},"MUTEUSER")},disabled:!(e!=null&&e.isCallStart)||x,children:x?a(Ce,{size:"20px",sx:{color:d.palette.primary.main}}):e.isMute?a(Us,{}):a(Ms,{})})}),a(Ae,{title:"End Call",children:(e==null?void 0:e.line)!==1?a(ee,{variant:e!=null&&e.isCallStart?"contained":"outlined",color:"error",sx:e!=null&&e.isCallStart?X(r({},l),{minWidth:"60px !important",border:`0px solid ${d.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${d.palette.error.light}`,border:`0px solid ${d.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${d.palette.primary.light}`}}):X(r({},i),{minWidth:"60px !important"}),onClick:()=>{Y(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart)||I,children:I?a(Ce,{size:"20px",color:"error"}):a(qo,{})}):a(ee,{variant:e!=null&&e.isCallStart?"contained":"outlined",sx:X(r({},i),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{Y(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart),children:a(J,{children:a(qo,{sx:{visibility:"hidden"}})})})})]})})]},e.line)};function Ko({open:e,setOpen:t}){var h;let s=xe(),{showToast:i}=ke(),[l,o]=ue(!1),d=()=>{t(!1)},g=()=>{var m,f,p,x;o(!0);let u={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(f=(m=s.callData)==null?void 0:m.agent_id)!=null?f:"",process:(x=(p=s.callData)==null?void 0:p.process_name)!=null?x:""};Z.post(P.CONFERENCE_CALL_END_ALL,u).then(y=>{var I;i((I=y.data)==null?void 0:I.message,"success"),S.resetConferenceLines(),d()}).catch(y=>{var B,O,k,w;let I=((O=(B=y.response)==null?void 0:B.data)==null?void 0:O.detail)||((w=(k=y.response)==null?void 0:k.data)==null?void 0:w.message)||y.message||"An unknown error occurred";i(I,"error")}).finally(()=>{o(!1)})};return Go(()=>{var m,f,p,x;let u={line:1,status:(f=(m=s.callData)==null?void 0:m.status)!=null?f:"",type:"internal",phone:(x=(p=s.callData)==null?void 0:p.phone_number)!=null?x:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};S.setConferenceLine(u)},[]),a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:E(be,{sx:{borderRadius:2},children:[E(W,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[E(J,{variant:"body1",children:[(h=s==null?void 0:s.agentId)!=null?h:""," conference"]}),a(ge,{onClick:d,children:a(et,{})})]}),a(W,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:a(qs,{component:be,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:E(Ws,{sx:{border:"4px solid #ffffff !important"},children:[a(Fs,{children:E(Fo,{sx:{border:"2px solid #f3f3f3ff !important"},children:[a(le,{sx:{padding:"6px"},children:"Line"}),a(le,{sx:{padding:"6px"},children:"Status"}),a(le,{sx:{padding:"6px"},children:"Call Type"}),a(le,{sx:{padding:"6px"},children:"Mobile Number"}),a(le,{sx:{padding:"6px"},children:"Call Actions"})]})}),a(Gs,{children:s==null?void 0:s.conferenceLine.map(u=>a(Ks,{each:u}))})]})})}),a(W,{textAlign:"center",m:2,children:E(ee,{variant:"outlined",color:"error",size:"large",onClick:g,disabled:l,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[l?a(Ce,{size:"20px",color:"error",sx:{marginRight:"8px"}}):a(ge,{sx:{bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},marginRight:"8px",width:"28px",height:"28px",fontSize:"12px",fontWeight:"600",lineHeight:"16px",letterSpacing:"0.02em",textTransform:"capitalize",color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%"},children:a(Hs,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function jo({open:e,setOpen:t}){var p,x,y,I,B,O,k,w,z,V,Y,Q;let[s]=oe({onSuccess:b=>{console.log("res",b),t(!1)},onError:b=>{console.log("error",b)}}),i=xe(),[l,o]=ue("process"),[d,{data:g}]=oe(),[h,{data:u}]=oe(),m=()=>{t(!1)},f=(b,C)=>{var L,R,A,_,H,$,M,D,T,U,F,G,K,ie,Oe,Me,Ue,Be,Se,He,Ee,$e,Le,ze,qe,We,De,Fe,Ge,Ke,je,Ye,Xe;if(console.log(b,"data34"),C==="PROCESS"){let fe={mobile_number:(R=(L=i.callData)==null?void 0:L.phone_number)!=null?R:"",userid:(_=(A=i.callData)==null?void 0:A.agent_id)!=null?_:"",type:"PROCESS",transfer_to:(H=b==null?void 0:b.process_name)!=null?H:"",callreferenceid:(M=($=i.callData)==null?void 0:$.convox_id)!=null?M:"",processid:String((T=(D=i.callData)==null?void 0:D.process_id)!=null?T:""),process_name:(F=(U=i.callData)==null?void 0:U.process_name)!=null?F:""};s(P.TRANSFER_CALL,fe)}else if(C==="QUEUE"){let fe={mobile_number:(K=(G=i.callData)==null?void 0:G.phone_number)!=null?K:"",userid:(Oe=(ie=i.callData)==null?void 0:ie.agent_id)!=null?Oe:"",type:"QUEUE",transfer_to:(Me=b==null?void 0:b.queue_name)!=null?Me:"",callreferenceid:(Be=(Ue=i.callData)==null?void 0:Ue.convox_id)!=null?Be:"",processid:String((He=(Se=i.callData)==null?void 0:Se.process_id)!=null?He:""),process_name:($e=(Ee=i.callData)==null?void 0:Ee.process_name)!=null?$e:""};s(P.TRANSFER_CALL,fe)}else if(C==="AGENT"){let fe={mobile_number:(ze=(Le=i.callData)==null?void 0:Le.phone_number)!=null?ze:"",userid:(We=(qe=i.callData)==null?void 0:qe.agent_id)!=null?We:"",type:"AGENT",transfer_to:(De=b==null?void 0:b.user_id)!=null?De:"",callreferenceid:(Ge=(Fe=i.callData)==null?void 0:Fe.convox_id)!=null?Ge:"",processid:String((je=(Ke=i.callData)==null?void 0:Ke.process_id)!=null?je:""),process_name:(Xe=(Ye=i.callData)==null?void 0:Ye.process_name)!=null?Xe:""};s(P.TRANSFER_CALL,fe)}};return Go(()=>{d(P.AGENTS_LIST,{status:"IDLE",active:!0}),h(P.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(g,"idleAgentsList"),a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:E(be,{sx:{borderRadius:2},children:[E(W,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[a(J,{variant:"body1",children:" Call Transfer"}),a(ge,{onClick:m,children:a(et,{})})]}),E(W,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[E(W,{sx:{display:"flex",gap:1},children:[a(ee,{variant:l==="process"?"contained":"outlined",onClick:()=>o("process"),children:"Process"}),a(ee,{variant:l==="queues"?"contained":"outlined",onClick:()=>o("queues"),children:"Queues"}),a(ee,{variant:l==="agents"?"contained":"outlined",onClick:()=>o("agents"),children:"Agents"})]}),l==="process"&&a(W,{sx:{display:"flex",gap:1},children:(p=u==null?void 0:u.data)!=null&&p.process&&((y=(x=u==null?void 0:u.data)==null?void 0:x.process)==null?void 0:y.length)>0?(B=(I=u==null?void 0:u.data)==null?void 0:I.process)==null?void 0:B.map((b,C)=>E(W,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[E(J,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[a(Ze,{sx:{marginRight:"4px"}}),b.process_name]}),a(ge,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{f(b,"PROCESS")},children:a(Qe,{})})]},C)):a(J,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Process Found"})}),l==="queues"&&a(W,{sx:{display:"flex",gap:1},children:(O=u==null?void 0:u.data)!=null&&O.queue&&((w=(k=u==null?void 0:u.data)==null?void 0:k.queue)==null?void 0:w.length)>0?(V=(z=u==null?void 0:u.data)==null?void 0:z.queue)==null?void 0:V.map((b,C)=>{var L,R,A,_,H,$;return E(W,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[E(J,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[a(Ze,{sx:{marginRight:"4px"}}),b.queue_name,(A=(R=(L=u==null?void 0:u.data)==null?void 0:L.process)==null?void 0:R.find(M=>M.process_id===b.process_id))!=null&&A.process_name?a(J,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+(($=(H=(_=u==null?void 0:u.data)==null?void 0:_.process)==null?void 0:H.find(M=>M.process_id===b.process_id))==null?void 0:$.process_name)+")"}):""]}),a(ge,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{f(b,"QUEUE")},children:a(Qe,{})})]},C)}):a(J,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Queues Found"})}),l==="agents"&&a(W,{sx:{display:"flex",gap:1},children:g!=null&&g.data&&((Y=g==null?void 0:g.data)==null?void 0:Y.length)>0?(Q=g==null?void 0:g.data)==null?void 0:Q.map((b,C)=>E(W,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[E(J,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[a(Ze,{sx:{marginRight:"4px"}}),b.name]}),a(ge,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{f(b,"AGENT")},children:a(Qe,{})})]},C)):a(J,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Agents Found"})})]})]})})})}function Yo({open:e,setOpen:t,onSubmitDisposition:s}){var m,f;let[i,l]=ue({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),o=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],d=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],g=(p,x)=>{l(y=>X(r({},y),{[p]:x}))},h=()=>{l({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},u=()=>{h(),t(!1)};return a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:E(be,{sx:{borderRadius:2},children:[a(W,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:E(J,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),a(W,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:E(ye,{container:!0,spacing:2,children:[a(ye,{size:6,children:a(Wo,{value:i.disposition,options:o,getOptionLabel:p=>p.label,onChange:(p,x)=>g("disposition",x),size:"small",renderInput:p=>a(he,X(r({},p),{label:"Disposition",fullWidth:!0}))})}),a(ye,{size:6,children:a(Wo,{options:d,getOptionLabel:p=>p.label,value:i.followUp,onChange:(p,x)=>g("followUp",x),size:"small",renderInput:p=>a(he,X(r({},p),{label:"Follow Up",fullWidth:!0}))})}),((f=(m=i==null?void 0:i.followUp)==null?void 0:m.label)==null?void 0:f.toLowerCase())==="yes"&&E(ve,{children:[a(ye,{size:6,children:a(he,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:i.callbackDate,onChange:p=>g("callbackDate",p.target.value),fullWidth:!0})}),a(ye,{size:6,children:a(he,{size:"small",label:"Hours (0-23)",type:"text",inputProps:{min:0,max:23},value:i.callbackHrs,onChange:p=>g("callbackHrs",p.target.value),fullWidth:!0})}),a(ye,{size:6,children:a(he,{size:"small",label:"Minutes (0-59)",type:"text",inputProps:{min:0,max:59},value:i.callbackMins,onChange:p=>g("callbackMins",p.target.value),fullWidth:!0})})]})]})}),E(W,{textAlign:"right",m:2,children:[a(ee,{variant:"outlined",color:"error",size:"large",onClick:u,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),a(ee,{variant:"contained",color:"primary",size:"large",onClick:()=>s(i),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function Xo({open:e,setOpen:t,processList:s=null,handleSelectedProcessor:i}){var o,d;return a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:E(be,{sx:{borderRadius:2},children:[E(W,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[a(J,{variant:"body1",children:" Process List"}),a(ge,{onClick:()=>{t(!1)},children:a(et,{})})]}),a(W,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:((o=s==null?void 0:s.processes)==null?void 0:o.length)>0?(d=s==null?void 0:s.processes)==null?void 0:d.map((g,h)=>a(W,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px",cursor:"pointer","&:hover":{bgcolor:"action.selected"}},onClick:()=>{i(g)},children:E(J,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[a(Ze,{sx:{marginRight:"4px"}}),g.process_name]})},h)):null})]})})})}function Jo({open:e,setOpen:t}){return a(ve,{children:a(Ne,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:E(be,{sx:{borderRadius:2},children:[E(W,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[a(J,{variant:"body1",children:" Call History"}),a(ge,{onClick:()=>{t(!1)},children:a(et,{})})]}),a(W,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}import{Fragment as ua,jsx as c,jsxs as ce}from"react/jsx-runtime";function os({onDataChange:e}){var ft,mt,xt,yt,ht,Ct,bt,vt,Tt,St,Et,Lt,Dt,It,Rt,_t,wt,kt,At,Nt,Pt,Ot,Mt,Ut,Bt,Ht,$t,zt,qt,Wt,Ft,Gt,Kt,jt,Yt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,ao,no,io,lo,ro,co,po,uo,go,fo,mo,xo,yo,ho,Co,bo,vo,To,So,Eo,Lo,Do;let t=ca(),{disabled:s,enabled:i,outlined:l}=Ve(),o=xe(),d=da(null),[g,h]=ne(null),[u,m]=ne(!0),[f,p]=ne(null),[x,y]=ne(null),[I,B]=ne(!1),[O,k]=ne(!1),[w,z]=ne(!1),[V,Y]=ne(!1),[Q,b]=ne(!1),[C,L]=ne(""),[R,A]=ne(0),{position:_,isDragging:H,dragRef:$,handleMouseDown:M,handleTouchStart:D}=ct(o.controlPanelPosition,n=>S.setControlPanelPosition(n)),{position:T,isDragging:U,dragRef:F,handleMouseDown:G,handleTouchStart:K}=ct(o.iframePosition,n=>S.setIframePosition(n)),[ie,{data:Oe}]=oe({onSuccess:n=>{var v;console.log("res",n),n&&n.data&&((v=n==null?void 0:n.data)==null?void 0:v.length)>1?Y(!0):(S.setProcess(n==null?void 0:n.data[0]),Y(!1))},onError:()=>{Y(!1)}}),[Me,{isLoading:Ue}]=oe(),[Be,{isLoading:Se}]=oe({onSuccess:()=>{S.setHolding(!o.isHolding)},onError:n=>{console.log("error",n)}}),[He,{isLoading:Ee}]=oe({onSuccess:()=>{S.setMuted(!o.isMuted)},onError:n=>{console.log("error",n)}}),[$e,{isLoading:Le}]=oe(),[ze,{isLoading:qe}]=oe(),[We,{isLoading:De}]=oe(),Fe=pa(n=>{let v=Math.floor(n/60),j=n%60;return`${v.toString().padStart(2,"0")}:${j.toString().padStart(2,"0")}`},[]),Ge=()=>{h(null)},Ke=n=>{m(!0),y(n.currentTarget),S.setStatus("dial")},je=()=>{o.status!=="on call"&&S.setStatus("idle"),y(null)},Ye=n=>{p(n.currentTarget)},Xe=()=>{p(null)},fe=()=>{let n={action:"READYAGENT",userId:o.agentId};$e(P.READY_AGENT,n)},gt=n=>{p(null);let v={action:"AGENTBREAK",break_type:n,userId:o.agentId};ze(P.UPDATE_AGENT_BREAK,v)},ns=n=>{if(n.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(n)){let v={action:"CALL",phone_number:n,userId:o.agentId};Me(P.CLICK_TO_CALL,v)}},is=()=>{let n={action:o.isHolding?"UNHOLD":"HOLD",userId:o.agentId};Be(P.HOLD_CALL,n)},ls=()=>{let n={action:o.isMuted?"UNMUTE":"MUTE",userId:o.agentId};He(P.MUTE_CALL,n)},rs=n=>{var j,se,ae,pe,de,Ie,Re,Io,Ro,_o,wo,ko,Ao,No,Po,Oo;console.log("data",n);let v={action:"ENDCALL",userId:o.agentId,processid:(ae=(se=(j=o.process)==null?void 0:j.process_id)==null?void 0:se.toString())!=null?ae:"",process_name:(de=(pe=o.process)==null?void 0:pe.process_name)!=null?de:"",callreferenceid:(Re=(Ie=o.callData)==null?void 0:Ie.convox_id)!=null?Re:"",mobile_number:(Ro=(Io=o.callData)==null?void 0:Io.phone_number)!=null?Ro:"",disposition:(wo=(_o=n==null?void 0:n.disposition)==null?void 0:_o.value)!=null?wo:"",set_followUp:(Ao=(ko=n==null?void 0:n.followUp)==null?void 0:ko.value)!=null?Ao:"",callback_date:(No=n==null?void 0:n.callbackDate)!=null?No:"",callback_hrs:(Po=n==null?void 0:n.callbackHrs)!=null?Po:"",callback_mins:(Oo=n==null?void 0:n.callbackMins)!=null?Oo:"",endcall_type:"CLOSE"};L(""),We(P.END_CALL,v),S.endCall(),z(!1)};return ot(()=>{let n;return o.callData.status&&o.callData.status==="ONCALL"?n=setInterval(()=>{let v=Math.floor((Date.now()-o.callStartTime)/1e3);A(v)},1e3):A(0),()=>{n&&clearInterval(n)}},[o.callData.status]),ot(()=>{e&&e(o.callData)},[o.callData,e]),ot(()=>{o.agentId?ie(P.PROCESS_LIST,{userId:o.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[o.agentId]),ot(()=>(o.agentId&&(d.current=new WebSocket(`${Uo.WS}?agent_id=${o.agentId}`),d.current.onopen=()=>{console.log("WebSocket connection established")},d.current.onmessage=n=>{try{let v=JSON.parse(n.data);console.log("parsedJSON:",v),S.updateCallData(v),v.status==="ONCALL"&&S.startCall(),v.status==="WRAPUP"&&S.endCall()}catch(v){console.log("Raw message:",n.data)}},d.current.onclose=()=>{console.log("WebSocket connection closed")},d.current.onerror=n=>{console.error("WebSocket error:",n)}),()=>{var n;(n=d.current)==null||n.close()}),[o.agentId]),!o.isInitialized||!o.process?c(re,{children:!!V&&c(Xo,{processList:Oe,open:V,setOpen:Y,handleSelectedProcessor:n=>{S.setProcess(n)}})}):ce(ua,{children:[c(Qo,{in:!0,timeout:300,children:c(es,{ref:$,elevation:H?4:1,sx:{position:"fixed",left:_.x,top:_.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:99999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),userSelect:"none"},children:ce(re,{sx:{display:"flex",alignItems:"center"},children:[ce(re,{sx:{display:"flex",alignItems:"center"},children:[ce(tt,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:M,onTouchStart:D,children:[c(Vo,{})," "]}),c(re,{sx:{marginRight:"10px"},children:c(me,{title:"Dial",children:c(tt,{size:"small",onClick:n=>{var v,j,se,ae,pe,de,Ie,Re;((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())!=="ONCALL"&&((ae=(se=o.callData)==null?void 0:se.status)==null?void 0:ae.toUpperCase())!=="BREAK"&&((de=(pe=o.callData)==null?void 0:pe.status)==null?void 0:de.toUpperCase())!=="RINGING"&&((Re=(Ie=o.callData)==null?void 0:Ie.status)==null?void 0:Re.toUpperCase())!=="WRAPUP"&&Ke(n)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:c(la,{sx:{color:((mt=(ft=o.callData)==null?void 0:ft.status)==null?void 0:mt.toUpperCase())==="ONCALL"||((yt=(xt=o.callData)==null?void 0:xt.status)==null?void 0:yt.toUpperCase())==="BREAK"||((Ct=(ht=o.callData)==null?void 0:ht.status)==null?void 0:Ct.toUpperCase())==="RINGING"||((vt=(bt=o.callData)==null?void 0:bt.status)==null?void 0:vt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),c(ts,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Fe(R)}),qe||Le?c(re,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:c(Pe,{size:"20px"})}):c(ts,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(Et=(St=(Tt=o.callData)==null?void 0:Tt.status)==null?void 0:St.toUpperCase())!=null?Et:"N/A"}),c(re,{onClick:Ye,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:c(js,{})})]}),ce(re,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[c(me,{title:"Agent Ready",children:c(Te,{variant:((Dt=(Lt=o.callData)==null?void 0:Lt.status)==null?void 0:Dt.toUpperCase())==="BREAK"||((Rt=(It=o.callData)==null?void 0:It.status)==null?void 0:Rt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:n=>{var v,j,se,ae;(((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())==="BREAK"||((ae=(se=o.callData)==null?void 0:se.status)==null?void 0:ae.toUpperCase())==="MISSED")&&(n.stopPropagation(),fe())},classes:{root:((wt=(_t=o.callData)==null?void 0:_t.status)==null?void 0:wt.toUpperCase())==="BREAK"||((At=(kt=o.callData)==null?void 0:kt.status)==null?void 0:At.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:r({},((Pt=(Nt=o.callData)==null?void 0:Nt.status)==null?void 0:Pt.toUpperCase())==="BREAK"||((Mt=(Ot=o.callData)==null?void 0:Ot.status)==null?void 0:Mt.toUpperCase())==="MISSED"?l:i),disabled:Le,children:c(aa,{})})}),c(me,{title:o.isHolding?"Resume":"Hold",children:c(Te,{variant:o.isHolding&&((Bt=(Ut=o.callData)==null?void 0:Ut.status)==null?void 0:Bt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:n=>{n.stopPropagation(),is()},sx:o.isHolding&&(($t=(Ht=o.callData)==null?void 0:Ht.status)==null?void 0:$t.toUpperCase())==="ONCALL"?r({},i):((qt=(zt=o.callData)==null?void 0:zt.status)==null?void 0:qt.toUpperCase())==="ONCALL"?r({},l):r({},s),disabled:((Ft=(Wt=o.callData)==null?void 0:Wt.status)==null?void 0:Ft.toUpperCase())!=="ONCALL"&&!o.isHolding||Se,children:Se?c(Pe,{size:"20px",sx:{color:t.palette.primary.main}}):o.isHolding?c(sa,{}):c(ea,{})})}),c(me,{title:o.isMuted?"Unmute":"Mute",children:c(Te,{variant:o.isMuted&&((Kt=(Gt=o.callData)==null?void 0:Gt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:n=>{n.stopPropagation(),ls()},sx:o.isMuted&&((Yt=(jt=o.callData)==null?void 0:jt.status)==null?void 0:Yt.toUpperCase())==="ONCALL"?r({},i):((Jt=(Xt=o.callData)==null?void 0:Xt.status)==null?void 0:Jt.toUpperCase())==="ONCALL"?r({},l):r({},s),disabled:((Qt=(Vt=o.callData)==null?void 0:Vt.status)==null?void 0:Qt.toUpperCase())!=="ONCALL"&&!o.isMuted||Ee,children:Ee?c(Pe,{size:"20px",sx:{color:t.palette.primary.main}}):o.isMuted?c(Zs,{}):c(Qs,{})})}),c(me,{title:"Transfer Call",children:c(Te,{variant:O?"contained":"outlined",onClick:n=>{var v,j;((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())==="ONCALL"&&(n.stopPropagation(),k(!0))},sx:O?r({},i):((eo=(Zt=o.callData)==null?void 0:Zt.status)==null?void 0:eo.toUpperCase())==="ONCALL"?r({},l):r({},s),disabled:((oo=(to=o.callData)==null?void 0:to.status)==null?void 0:oo.toUpperCase())!=="ONCALL",children:c(na,{})})}),c(me,{title:"Conference Call",children:c(Te,{variant:I?"contained":"outlined",onClick:n=>{var v,j;((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())==="ONCALL"&&(n.stopPropagation(),B(!0))},sx:I?r({},i):((ao=(so=o.callData)==null?void 0:so.status)==null?void 0:ao.toUpperCase())==="ONCALL"?r({},l):r({},s),disabled:((io=(no=o.callData)==null?void 0:no.status)==null?void 0:io.toUpperCase())!=="ONCALL",children:c(Js,{})})}),c(me,{title:"End Call",children:c(Te,{variant:((ro=(lo=o.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())==="ONCALL"||((po=(co=o.callData)==null?void 0:co.status)==null?void 0:po.toUpperCase())==="RINGING"||((go=(uo=o.callData)==null?void 0:uo.status)==null?void 0:go.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:n=>{var v,j,se,ae,pe,de;(((j=(v=o.callData)==null?void 0:v.status)==null?void 0:j.toUpperCase())==="ONCALL"||((ae=(se=o.callData)==null?void 0:se.status)==null?void 0:ae.toUpperCase())==="RINGING"||((de=(pe=o.callData)==null?void 0:pe.status)==null?void 0:de.toUpperCase())==="WRAPUP")&&(n.stopPropagation(),z(!0))},sx:((mo=(fo=o.callData)==null?void 0:fo.status)==null?void 0:mo.toUpperCase())==="ONCALL"||((yo=(xo=o.callData)==null?void 0:xo.status)==null?void 0:yo.toUpperCase())==="RINGING"||((Co=(ho=o.callData)==null?void 0:ho.status)==null?void 0:Co.toUpperCase())==="WRAPUP"?X(r({},i),{borderRight:"1px",backgroundColor:"error.main",minWidth:"60px !important",boxShadow:" 0px 2px 1px #5f3f3f",border:`1px solid ${t.palette.error.light}`,height:"40px","&:hover":{bgcolor:"error.light",boxShadow:" 0px 2px 1px #5f3f3f",border:`0px solid ${t.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${t.palette.primary.light}`}}):X(r({},s),{minWidth:"60px !important"}),disabled:((vo=(bo=o.callData)==null?void 0:bo.status)==null?void 0:vo.toUpperCase())!=="ONCALL"&&((So=(To=o.callData)==null?void 0:To.status)==null?void 0:So.toUpperCase())!=="RINGING"&&((Lo=(Eo=o.callData)==null?void 0:Eo.status)==null?void 0:Lo.toUpperCase())!=="WRAPUP"||De,children:De?c(Pe,{size:"20px",color:"error"}):c(Ys,{})})})]})]})})}),c(Qo,{in:!0,timeout:300,children:ce(es,{ref:F,elevation:U?4:1,sx:{position:"fixed",left:T.x,top:T.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:99999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),visibility:u?"visible":"hidden",userSelect:"none"},children:[ce(re,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:G,onTouchStart:K,children:[c(Vo,{sx:{transform:"rotate(90deg)"}})," ",c(tt,{onClick:()=>m(!1),children:c(Xs,{})})]}),c("iframe",{src:`https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${o.agentId}&process_id=${(Do=o.process)==null?void 0:Do.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay"})]})}),c(ut,{anchorEl:x,open:!!x,onClose:je,onClick:n=>n.stopPropagation(),sx:{zIndex:99999},children:ce(re,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[c(ra,{size:"small",value:C,placeholder:"Enter Mobile No.",onChange:n=>{L(n.target.value)}}),c(tt,{color:"info",onClick:()=>{ns(C)},children:Ue?c(Pe,{size:"20px",sx:{color:t.palette.success.main}}):c(oa,{color:"success"})})]})}),ce(ut,{anchorEl:f,open:!!f,onClose:Xe,onClick:n=>n.stopPropagation(),sx:{zIndex:99999},children:[c(Zo,{onClick:()=>gt("Lunch"),children:"- Lunch"}),c(Zo,{onClick:()=>gt("Tea"),children:"- Tea"})]}),c(ut,{anchorEl:g,open:!!g,onClose:Ge,onClick:n=>n.stopPropagation(),sx:{zIndex:99999},children:ce(re,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[c(dt,{icon:c(Vs,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),c(dt,{icon:c(ta,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),c(dt,{icon:c(ia,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!I&&c(Ko,{open:I,setOpen:B}),!!O&&c(jo,{open:O,setOpen:k}),!!w&&c(Yo,{open:w,setOpen:z,onSubmitDisposition:rs}),!!Q&&c(Jo,{open:Q,setOpen:b})]})}import{jsx as ga}from"react/jsx-runtime";var ss=({children:e})=>ga(zo,{children:e});import{jsx as as}from"react/jsx-runtime";function fa({onDataChange:e}){return as(ss,{children:as(os,{onDataChange:e})})}function Bn({apiKey:e,tenantId:t,agentId:s}){S.initialize(e,s),nt.init({apiKey:e,tenantId:t,agentId:s,baseUrl:N})}export{fa as CallControlPanel,Bn as initSDK,vs as useEndCall,Cs as useLogout};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|