call-control-sdk 5.0.7 → 5.0.9
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/dist/index.d.mts +22 -21
- package/dist/index.d.ts +22 -21
- 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 Ko=Object.defineProperty,jo=Object.defineProperties;var Yo=Object.getOwnPropertyDescriptors;var Do=Object.getOwnPropertySymbols;var Xo=Object.prototype.hasOwnProperty,Jo=Object.prototype.propertyIsEnumerable;var Xt=(r,t,n)=>t in r?Ko(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,l=(r,t)=>{for(var n in t||(t={}))Xo.call(t,n)&&Xt(r,n,t[n]);if(Do)for(var n of Do(t))Jo.call(t,n)&&Xt(r,n,t[n]);return r},M=(r,t)=>jo(r,Yo(t));var W=(r,t,n)=>Xt(r,typeof t!="symbol"?t+"":t,n);import{ArrowDropDown as vn,CallEnd as Cn,Close as bn,DragIndicator as Ho,Group as Sn,History as En,Layers as Tn,Mic as Ln,MicOff as Dn,Pause as In,Pending as Rn,Phone as wn,PlayArrow as _n,SupportAgent as kn,TransferWithinAStation as An,Upcoming as Nn,WifiCalling3 as Pn}from"@mui/icons-material";import{Box as et,Button as ot,Chip as te,Fade as $o,IconButton as jt,Menu as ee,MenuItem as zo,Paper as Wo,TextField as On,Tooltip as nt,Typography as qo,useTheme as Un}from"@mui/material";import{useCallback as Mn,useEffect as Yt,useRef as Bn,useState as G}from"react";var Jt=class{constructor(){W(this,"state");W(this,"listeners",[]);W(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 n=JSON.parse(t);this.state=M(l({},this.state),{apiKey:n.apiKey||"",agentId:n.agentId||"",process:n.process||null,isInitialized:n.isInitialized||!1,isHolding:n.isHolding||!1,isMuted:n.isMuted||!1,status:n.status||"idle",callStartTime:n.callStartTime||null,controlPanelPosition:n.controlPanelPosition||{x:10,y:10},iframePosition:n.iframePosition||{x:10,y:80},callData:n.callData||{mobileNumber:"",callReferenceId:"",agentLoginId:""},conferenceLine:n.conferenceLine&&Array.isArray(n.conferenceLine)&&n.conferenceLine.length>0?n.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,n){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("API key not available");this.state.apiKey=t,this.state.agentId=n,this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return l({},this.state)}subscribe(t){return this.listeners.push(t),()=>{let n=this.listeners.indexOf(t);n>-1&&this.listeners.splice(n,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=l(l({},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 n=(i=this.state.conferenceLine)==null?void 0:i.map(c=>c.line===t.line?t:c);this.state.conferenceLine=n,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||[]}},T=new Jt;import{useCallback as Wt,useRef as Qt,useState as Io}from"react";function Vt(r,t){let[n,i]=Io(r),[c,e]=Io(!1),u=Qt(),m=Qt({x:0,y:0}),S=Qt({x:0,y:0}),h=Wt(E=>{let k=u.current;if(!k)return;let U=k.getBoundingClientRect(),O=window.innerWidth,o=window.innerHeight,g={x:Math.max(0,Math.min(E.x,O-U.width)),y:Math.max(0,Math.min(E.y,o-U.height))};i(g),t==null||t(g)},[t]),L=Wt((E,k)=>{e(!0),m.current={x:E,y:k},S.current=n;let U=(f,x)=>{let v=f-m.current.x,d=x-m.current.y;h({x:S.current.x+v,y:S.current.y+d})},O=f=>{f.preventDefault(),U(f.clientX,f.clientY)},o=f=>{f.preventDefault();let x=f.touches[0];x&&U(x.clientX,x.clientY)},g=()=>{e(!1),document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",g),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",g)};document.addEventListener("mousemove",O),document.addEventListener("mouseup",g),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",g)},[n,h]),P=Wt(E=>{E.preventDefault(),L(E.clientX,E.clientY)},[L]),b=Wt(E=>{E.preventDefault();let k=E.touches[0];k&&L(k.clientX,k.clientY)},[L]);return{position:n,isDragging:c,dragRef:u,handleMouseDown:P,handleTouchStart:b}}import{useState as Qo,useEffect as Vo}from"react";function it(){let[r,t]=Qo(T.getState());return Vo(()=>T.subscribe(()=>{t(T.getState())}),[]),r}var R="http://192.168.100.143:8095",Zo="ws://192.168.100.143:8095",N={v1:"/api/v1"},w={LOGIN:`${R}${N.v1}/cti/login?provider=convox`,READY_AGENT:`${R}${N.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${R}${N.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${R}${N.v1}/cti/calls?provider=convox`,HOLD_CALL:`${R}${N.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${R}${N.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${R}${N.v1}/cti/unmute-call?provider=convox`,END_CALL:`${R}${N.v1}/cti/calls/end?provider=convox`,LOGOUT:`${R}${N.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${R}${N.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${R}${N.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${R}${N.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${R}${N.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${R}${N.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${R}${N.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${R}${N.v1}/cti/users`,PROCESS_LIST:`${R}${N.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${R}${N.v1}/cti/transfer-to-details?provider=convox`},Ro={WS:`${Zo}${N.v1}/cti/ws`};import{useCallback as sn,useReducer as rn}from"react";import tn from"axios";var en="12345",Zt=tn.create({baseURL:R,headers:{"Content-Type":"application/json",Authorization:en},timeout:1e4});Zt.interceptors.request.use(r=>{let t="12345";return t&&r.headers&&(r.headers.Authorization=`Bearer ${t}`),r},r=>Promise.reject(r instanceof Error?r:new Error(String(r))));Zt.interceptors.response.use(r=>r,async r=>{var n;let t=r.config;return((n=r.response)==null?void 0:n.status)===401&&!t._retry&&(t._retry=!0),Promise.reject(r instanceof Error?r:new Error(String(r)))});var Y=Zt;import{Alert as on,Snackbar as nn}from"@mui/material";import{useState as an}from"react";import{jsx as wo}from"react/jsx-runtime";function mt(){let[r,t]=an(!1),n=(c,e)=>{e!=="clickaway"&&t(!1)};return{showToast:(c,e)=>(t(!0),wo(nn,{anchorOrigin:{vertical:"top",horizontal:"right"},open:r,onClose:n,children:wo(on,{onClose:n,severity:e,variant:"filled",sx:{width:"100%"},children:c})}))}}var ln={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},cn=(r,t)=>{if(t.type==="isLoading")return M(l({},r),{isLoading:t.payload});if(t.type==="isSuccess")return M(l({},r),{isSuccess:!0,data:t.payload});if(t.type==="isError")return M(l({},r),{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 $=(r={})=>{let{onSuccess:t=null,onError:n=null}=r,{showToast:i}=mt(),[c,e]=rn(cn,ln);return[sn((m,S,h={})=>{e({type:"isLoading",payload:!0}),Y.post(m,S,h).then(L=>{e({type:"isSuccess",payload:L.data}),t==null||t(L.data,S)}).catch(L=>{var b,E,k,U,O,o,g,f,x,v,d,C;let P={status:(E=(b=L.response)==null?void 0:b.status)!=null?E:500,message:((U=(k=L.response)==null?void 0:k.data)==null?void 0:U.detail)||((o=(O=L.response)==null?void 0:O.data)==null?void 0:o.message)||L.message||"An unknown error occurred",data:(f=(g=L.response)==null?void 0:g.data)!=null?f:null,statusText:(v=(x=L.response)==null?void 0:x.statusText)!=null?v:"",code:(d=L==null?void 0:L.code)!=null?d:"",name:(C=L==null?void 0:L.name)!=null?C:""};i(P.message,"error"),e({type:"isError",payload:P}),n==null||n(P,S)}).finally(()=>{e({type:"isLoading",payload:!1})})},[t,n,i]),c]};import{Call as Ft,CallEnd as _o,CallSplit as un,Close as Kt,Mic as gn,MicOff as fn,Pause as mn,PhoneDisabled as xn,PlayArrow as hn,SupportAgent as Gt}from"@mui/icons-material";import{Box as _,Button as z,Dialog as ht,IconButton as tt,Paper as yt,TextField as ct,Typography as B,Autocomplete as ko,Grid as lt,Tooltip as xt,useTheme as yn}from"@mui/material";import{useEffect as Ao,useState as No}from"react";import{useTheme as pn}from"@mui/material";var dn=()=>{let r=pn();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 ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.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 ${r.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.palette.primary.light}`}},outlined:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:r.palette.grey[200],boxShadow:`0px 2px 1px ${r.palette.primary.light}`,border:`0px solid ${r.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${r.palette.primary.main}`,border:`0px solid ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.palette.primary.light}`}}}},qt=dn;import{Fragment as pt,jsx as s,jsxs as I}from"react/jsx-runtime";function Po({open:r,setOpen:t}){var U,O;let n=it(),{disabled:i,enabled:c,outlined:e}=qt(),u=yn(),m=()=>{t(!1)},S=(o,g)=>{T.setConferenceLine(l(l({},o),g))},h=(o,g)=>{var v,d,C,D;let f=l(l({},o),g),x={action:"EXTERNAL_CONFERENCE",operation:`CALL${f.line}`,line_used:String(f.line),thirdparty_no:f.phone,userid:(d=(v=n.callData)==null?void 0:v.agent_id)!=null?d:"",process:(D=(C=n.callData)==null?void 0:C.process_name)!=null?D:""};Y.post(w.CONFERENCE_CALL,x).then(()=>{T.setConferenceLine(l(l({},o),g))})},L=(o,g)=>{var v,d,C,D;let f=l(l({},o),g),x={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(f.line),thirdparty_no:f.phone,userid:(d=(v=n.callData)==null?void 0:v.agent_id)!=null?d:"",process:(D=(C=n.callData)==null?void 0:C.process_name)!=null?D:""};Y.post(w.CONFERENCE_CALL,x).then(()=>{T.setConferenceLine(l(l({},o),g))})},P=(o,g,f)=>{var d,C,D,H;let x=l(l({},o),g),v={action:"EXTERNAL_CONFERENCE",operation:f,hold_channel_no:f==="HOLDUSER"?`hold${x.line}`:`unhold${x.line}`,userid:(C=(d=n.callData)==null?void 0:d.agent_id)!=null?C:"",process:(H=(D=n.callData)==null?void 0:D.process_name)!=null?H:""};Y.post(w.CONFERENCE_CALL_HOLD_OR_UN_HOLD,v).then(()=>{T.setConferenceLine(l(l({},o),g))})},b=(o,g,f)=>{var d,C,D,H;let x=l(l({},o),g),v={action:"EXTERNAL_CONFERENCE",operation:f,channel_no:f==="MUTEUSER"?`mute${x.line}`:`play${x.line}`,userid:(C=(d=n.callData)==null?void 0:d.agent_id)!=null?C:"",thirdparty_no:x.phone,process:(H=(D=n.callData)==null?void 0:D.process_name)!=null?H:""};Y.post(w.CONFERENCE_CALL_MUTE_OT_UN_MUTE,v).then(()=>{T.setConferenceLine(l(l({},o),g))})},E=(o,g)=>{var v,d,C,D;let f=l(l({},o),g),x={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(f.line-1),user_type:`THIRDPARTY${f.line-1}`,thirdparty_no:f.phone,userid:(d=(v=n.callData)==null?void 0:v.agent_id)!=null?d:"",process:(D=(C=n.callData)==null?void 0:C.process_name)!=null?D:""};Y.post(w.CONFERENCE_CALL_END,x).then(()=>{T.setConferenceLine(l(l({},o),g))})},k=()=>{var g,f,x,v;let o={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(f=(g=n.callData)==null?void 0:g.agent_id)!=null?f:"",process:(v=(x=n.callData)==null?void 0:x.process_name)!=null?v:""};Y.post(w.CONFERENCE_CALL_END_ALL,o).then(()=>{T.resetConferenceLines(),m()})};return Ao(()=>{var g,f,x,v;let o={line:1,status:(f=(g=n.callData)==null?void 0:g.status)!=null?f:"",type:"internal",phone:(v=(x=n.callData)==null?void 0:x.phone_number)!=null?v:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};T.setConferenceLine(o)},[]),s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(yt,{sx:{borderRadius:2},children:[I(_,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[I(B,{variant:"body1",children:[(U=n==null?void 0:n.agentId)!=null?U:""," conference"]}),s(tt,{onClick:m,children:s(Kt,{})})]}),s(_,{sx:{boxShadow:"0px 1px 2px #e7e5e5ff",padding:"2px 6px",margin:"0px 10px",borderRadius:"20px"},children:(O=n==null?void 0:n.conferenceLine)==null?void 0:O.map((o,g)=>{var f,x;return I(_,{sx:{p:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[s(_,{sx:{color:"white",bgcolor:"warning.main",fontWeight:"bold",fontSize:14,minWidth:70,textAlign:"center",border:"2px solid primary.main",borderRadius:"10px 50px 50px 10px"},children:s(B,{children:(f=o==null?void 0:o.line)!=null?f:""})}),s(B,{variant:"body2",sx:{px:1,border:"2px solid gray",borderRadius:"10px",textAlign:"center",width:"80px",maxWidth:"100px"},children:(x=o==null?void 0:o.status)!=null?x:""}),s(z,{sx:{textTransform:"capitalize"},size:"small",children:s(B,{variant:"body2",children:(o==null?void 0:o.line)===1?"Internal":"External"})}),s(ct,{size:"small",placeholder:"Phone Number",value:(o==null?void 0:o.phone)||"",disabled:(o==null?void 0:o.line)===1,onChange:v=>{S(o,{phone:v.target.value})}}),s(xt,{title:"Call",children:s(z,{variant:o!=null&&o.isCallStart?"outlined":"contained",color:"success",sx:o!=null&&o.isCallStart?l({},i):M(l({},c),{border:`0px solid ${u.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${u.palette.success.light}`,border:`0px solid ${u.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${u.palette.primary.light}`}}),onClick:()=>{h(o,{isCallStart:!0,status:"ONCALL"})},disabled:o==null?void 0:o.isCallStart,children:s(Ft,{sx:{color:o!=null&&o.isCallStart?"default":"#fff"}})})}),s(xt,{title:"Merge Call",children:s(z,{variant:o!=null&&o.isMergeCall?"contained":"outlined",sx:o!=null&&o.isMergeCall&&(o!=null&&o.isCallStart)?l({},i):o!=null&&o.isCallStart?l({},e):l({},i),onClick:()=>{L(o,{isMergeCall:!0,status:"ONCALL"})},disabled:!(o!=null&&o.isCallStart),children:s(un,{})})}),s(xt,{title:o.isHold?"Hold":"Un Hold",children:s(z,{variant:o!=null&&o.isHold?"contained":"outlined",sx:o!=null&&o.isHold&&(o!=null&&o.isCallStart)?l({},i):o!=null&&o.isCallStart?l({},e):l({},i),onClick:()=>{o.isHold?P(o,{isHold:!1},"UNHOLDUSER"):P(o,{isHold:!0},"HOLDUSER")},disabled:!(o!=null&&o.isCallStart),children:o.isHold?s(hn,{}):s(mn,{})})}),s(xt,{title:o.isMute?"Mute":"Un Mute",children:s(z,{variant:o!=null&&o.isMute?"contained":"outlined",sx:o!=null&&o.isMute&&(o!=null&&o.isCallStart)?l({},i):o!=null&&o.isCallStart?l({},e):l({},i),onClick:()=>{o.isMute?b(o,{isMute:!1},"PLAYUSER"):b(o,{isMute:!0},"MUTEUSER")},disabled:!(o!=null&&o.isCallStart),children:o.isMute?s(fn,{}):s(gn,{})})}),s(xt,{title:"End Call",children:(o==null?void 0:o.line)!==1?s(z,{variant:o!=null&&o.isCallStart?"contained":"outlined",color:"error",sx:o!=null&&o.isCallStart?M(l({},c),{minWidth:"60px !important",border:`0px solid ${u.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${u.palette.error.light}`,border:`0px solid ${u.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${u.palette.primary.light}`}}):M(l({},i),{minWidth:"60px !important"}),onClick:()=>{E(o,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE"})},disabled:!(o!=null&&o.isCallStart),children:s(_o,{})}):s(z,{variant:o!=null&&o.isCallStart?"contained":"outlined",sx:M(l({},i),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{E(o,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE"})},disabled:!(o!=null&&o.isCallStart),children:s(B,{children:s(_o,{sx:{visibility:"hidden"}})})})})]},g)})}),s(_,{textAlign:"center",m:2,children:I(z,{variant:"outlined",color:"error",size:"large",onClick:k,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[s(tt,{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:s(xn,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function Oo({open:r,setOpen:t}){var b,E,k,U,O,o,g,f,x,v;let[n]=$({onSuccess:d=>{console.log("res",d),t(!1)},onError:d=>{console.log("error",d)}}),i=it(),[c,e]=No("process"),[u,{data:m}]=$(),[S,{data:h}]=$(),L=()=>{t(!1)},P=(d,C)=>{var D,H,X,J,at,Q,j,vt,Ct,bt,St,dt,Et,Tt,Lt,Dt,It,rt,Rt,wt,_t,kt,At,Nt,Pt,Ot,Ut,Mt,Bt,Ht,$t,ut,zt;if(console.log(d,"data34"),C==="PROCESS"){let st={mobile_number:(H=(D=i.callData)==null?void 0:D.phone_number)!=null?H:"",userid:(J=(X=i.callData)==null?void 0:X.agent_id)!=null?J:"",type:"PROCESS",transfer_to:(at=d==null?void 0:d.process_name)!=null?at:"",callreferenceid:(j=(Q=i.callData)==null?void 0:Q.convox_id)!=null?j:"",processid:String((Ct=(vt=i.callData)==null?void 0:vt.process_id)!=null?Ct:""),process_name:(St=(bt=i.callData)==null?void 0:bt.process_name)!=null?St:""};n(w.TRANSFER_CALL,st)}else if(C==="QUEUE"){let st={mobile_number:(Et=(dt=i.callData)==null?void 0:dt.phone_number)!=null?Et:"",userid:(Lt=(Tt=i.callData)==null?void 0:Tt.agent_id)!=null?Lt:"",type:"QUEUE",transfer_to:(Dt=d==null?void 0:d.queue_name)!=null?Dt:"",callreferenceid:(rt=(It=i.callData)==null?void 0:It.convox_id)!=null?rt:"",processid:String((wt=(Rt=i.callData)==null?void 0:Rt.process_id)!=null?wt:""),process_name:(kt=(_t=i.callData)==null?void 0:_t.process_name)!=null?kt:""};n(w.TRANSFER_CALL,st)}else if(C==="AGENT"){let st={mobile_number:(Nt=(At=i.callData)==null?void 0:At.phone_number)!=null?Nt:"",userid:(Ot=(Pt=i.callData)==null?void 0:Pt.agent_id)!=null?Ot:"",type:"AGENT",transfer_to:(Ut=d==null?void 0:d.user_id)!=null?Ut:"",callreferenceid:(Bt=(Mt=i.callData)==null?void 0:Mt.convox_id)!=null?Bt:"",processid:String(($t=(Ht=i.callData)==null?void 0:Ht.process_id)!=null?$t:""),process_name:(zt=(ut=i.callData)==null?void 0:ut.process_name)!=null?zt:""};n(w.TRANSFER_CALL,st)}};return Ao(()=>{u(w.AGENTS_LIST,{status:"IDLE",active:!0}),S(w.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(yt,{sx:{borderRadius:2},children:[I(_,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(B,{variant:"body1",children:" Call Transfer"}),s(tt,{onClick:L,children:s(Kt,{})})]}),I(_,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[I(_,{sx:{display:"flex",gap:1},children:[s(z,{variant:c==="process"?"contained":"outlined",onClick:()=>e("process"),children:"Process"}),s(z,{variant:c==="queues"?"contained":"outlined",onClick:()=>e("queues"),children:"Queues"}),s(z,{variant:c==="agents"?"contained":"outlined",onClick:()=>e("agents"),children:"Agents"})]}),c==="process"&&s(_,{sx:{display:"flex",gap:1},children:((E=(b=h==null?void 0:h.data)==null?void 0:b.process)==null?void 0:E.length)>0?(U=(k=h==null?void 0:h.data)==null?void 0:k.process)==null?void 0:U.map((d,C)=>I(_,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[I(B,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(Gt,{sx:{marginRight:"4px"}}),d.process_name]}),s(tt,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{P(d,"PROCESS")},children:s(Ft,{})})]},C)):s(B,{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"})}),c==="queues"&&s(_,{sx:{display:"flex",gap:1},children:((o=(O=h==null?void 0:h.data)==null?void 0:O.queue)==null?void 0:o.length)>0?(f=(g=h==null?void 0:h.data)==null?void 0:g.queue)==null?void 0:f.map((d,C)=>{var D,H,X,J,at,Q;return I(_,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[I(B,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(Gt,{sx:{marginRight:"4px"}}),d.queue_name,(X=(H=(D=h==null?void 0:h.data)==null?void 0:D.process)==null?void 0:H.find(j=>j.process_id===d.process_id))!=null&&X.process_name?s(B,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((Q=(at=(J=h==null?void 0:h.data)==null?void 0:J.process)==null?void 0:at.find(j=>j.process_id===d.process_id))==null?void 0:Q.process_name)+")"}):""]}),s(tt,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{P(d,"QUEUE")},children:s(Ft,{})})]},C)}):s(B,{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"})}),c==="agents"&&s(_,{sx:{display:"flex",gap:1},children:((x=m==null?void 0:m.data)==null?void 0:x.length)>0?(v=m==null?void 0:m.data)==null?void 0:v.map((d,C)=>I(_,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[I(B,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(Gt,{sx:{marginRight:"4px"}}),d.name]}),s(tt,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{P(d,"AGENT")},children:s(Ft,{})})]},C)):s(B,{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 Uo({open:r,setOpen:t,onSubmitDisposition:n}){var L,P;let[i,c]=No({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),e=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],u=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],m=(b,E)=>{c(k=>M(l({},k),{[b]:E}))},S=()=>{c({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},h=()=>{S(),t(!1)};return s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:I(yt,{sx:{borderRadius:2},children:[s(_,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:I(B,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),s(_,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:I(lt,{container:!0,spacing:2,children:[s(lt,{size:6,children:s(ko,{value:i.disposition,options:e,getOptionLabel:b=>b.label,onChange:(b,E)=>m("disposition",E),size:"small",renderInput:b=>s(ct,M(l({},b),{label:"Disposition",fullWidth:!0}))})}),s(lt,{size:6,children:s(ko,{options:u,getOptionLabel:b=>b.label,value:i.followUp,onChange:(b,E)=>m("followUp",E),size:"small",renderInput:b=>s(ct,M(l({},b),{label:"Follow Up",fullWidth:!0}))})}),((P=(L=i==null?void 0:i.followUp)==null?void 0:L.label)==null?void 0:P.toLowerCase())==="yes"&&I(pt,{children:[s(lt,{size:6,children:s(ct,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:i.callbackDate,onChange:b=>m("callbackDate",b.target.value),fullWidth:!0})}),s(lt,{size:6,children:s(ct,{size:"small",label:"Hours (0-23)",type:"text",inputProps:{min:0,max:23},value:i.callbackHrs,onChange:b=>m("callbackHrs",b.target.value),fullWidth:!0})}),s(lt,{size:6,children:s(ct,{size:"small",label:"Minutes (0-59)",type:"text",inputProps:{min:0,max:59},value:i.callbackMins,onChange:b=>m("callbackMins",b.target.value),fullWidth:!0})})]})]})}),I(_,{textAlign:"right",m:2,children:[s(z,{variant:"outlined",color:"error",size:"large",onClick:h,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),s(z,{variant:"contained",color:"primary",size:"large",onClick:()=>n(i),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function Mo({open:r,setOpen:t,processList:n=[],handleSelectedProcessor:i}){return s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:I(yt,{sx:{borderRadius:2},children:[I(_,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(B,{variant:"body1",children:" Process List"}),s(tt,{onClick:()=>{t(!1)},children:s(Kt,{})})]}),s(_,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:(n==null?void 0:n.length)>0?n==null?void 0:n.map((e,u)=>s(_,{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(e)},children:I(B,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(Gt,{sx:{marginRight:"4px"}}),e.process_name]})},u)):null})]})})})}function Bo({open:r,setOpen:t}){return s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(yt,{sx:{borderRadius:2},children:[I(_,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(B,{variant:"body1",children:" Call History"}),s(tt,{onClick:()=>{t(!1)},children:s(Kt,{})})]}),s(_,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}import{Fragment as $n,jsx as p,jsxs as K}from"react/jsx-runtime";function Hn({onDataChange:r}){var ae,se,ie,re,le,ce,pe,de,ue,ge,fe,me,xe,he,ye,ve,Ce,be,Se,Ee,Te,Le,De,Ie,Re,we,_e,ke,Ae,Ne,Pe,Oe,Ue,Me,Be,He,$e,ze,We,qe,Fe,Ge,Ke,je,Ye,Xe,Je,Qe,Ve,Ze,to,eo,oo,no,ao,so,io,ro,lo,co,po,uo,go,fo,mo,xo;let t=Un(),{disabled:n,enabled:i,outlined:c}=qt(),e=it(),{showToast:u}=mt(),m=Bn(null),[S,h]=G(null),[L,P]=G(!0),[b,E]=G(null),[k,U]=G(null),[O,o]=G(!1),[g,f]=G(!1),[x,v]=G(!1),[d,C]=G(!1),[D,H]=G(!1),[X,J]=G(""),[at,Q]=G(0),{position:j,isDragging:vt,dragRef:Ct,handleMouseDown:bt,handleTouchStart:St}=Vt(e.controlPanelPosition,a=>T.setControlPanelPosition(a)),{position:dt,isDragging:Et,dragRef:Tt,handleMouseDown:Lt,handleTouchStart:Dt}=Vt(e.iframePosition,a=>T.setIframePosition(a)),[It,{data:rt}]=$({onSuccess:a=>{var y;console.log("res",a),a&&a.data&&((y=a==null?void 0:a.data)==null?void 0:y.length)>1?C(!0):(T.setProcess(a==null?void 0:a.data[0]),C(!1))},onError:()=>{C(!1)}}),[Rt]=$(),[wt]=$({onSuccess:()=>{T.setHolding(!e.isHolding)},onError:a=>{console.log("error",a)}}),[_t]=$({onSuccess:()=>{T.setMuted(!e.isMuted)},onError:a=>{console.log("error",a)}}),[kt]=$(),[At]=$(),[Nt]=$(),Pt=Mn(a=>{let y=Math.floor(a/60),A=a%60;return`${y.toString().padStart(2,"0")}:${A.toString().padStart(2,"0")}`},[]),Ot=()=>{h(null)},Ut=a=>{P(!0),U(a.currentTarget),T.setStatus("dial")},Mt=()=>{e.status!=="on call"&&T.setStatus("idle"),U(null)},Bt=a=>{E(a.currentTarget)},Ht=()=>{E(null)},$t=()=>{let a={action:"READYAGENT",userId:e.agentId};kt(w.READY_AGENT,a)},ut=a=>{E(null);let y={action:"AGENTBREAK",break_type:a,userId:e.agentId};At(w.UPDATE_AGENT_BREAK,y)},zt=a=>{if(a.length!==10)u("Invalid phone number","error"),alert("Invalid phone number");else if(!/^\d+$/.test(a))u("Invalid phone number","error");else{let y={action:"CALL",phone_number:a,userId:e.agentId};Rt(w.CLICK_TO_CALL,y)}},st=()=>{let a={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};wt(w.HOLD_CALL,a)},Fo=()=>{let a={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};_t(w.MUTE_CALL,a)},Go=a=>{var A,q,F,V,Z,gt,ft,ho,yo,vo,Co,bo,So,Eo,To,Lo;console.log("data",a);let y={action:"ENDCALL",userId:e.agentId,processid:(F=(q=(A=e.process)==null?void 0:A.process_id)==null?void 0:q.toString())!=null?F:"",process_name:(Z=(V=e.process)==null?void 0:V.process_name)!=null?Z:"",callreferenceid:(ft=(gt=e.callData)==null?void 0:gt.convox_id)!=null?ft:"",mobile_number:(yo=(ho=e.callData)==null?void 0:ho.phone_number)!=null?yo:"",disposition:(Co=(vo=a==null?void 0:a.disposition)==null?void 0:vo.value)!=null?Co:"",set_followUp:(So=(bo=a==null?void 0:a.followUp)==null?void 0:bo.value)!=null?So:"",callback_date:(Eo=a==null?void 0:a.callbackDate)!=null?Eo:"",callback_hrs:(To=a==null?void 0:a.callbackHrs)!=null?To:"",callback_mins:(Lo=a==null?void 0:a.callbackMins)!=null?Lo:"",endcall_type:"CLOSE"};J(""),Nt(w.END_CALL,y),T.endCall(),v(!1)};return Yt(()=>{let a;return e.callData.status&&e.callData.status==="ONCALL"?a=setInterval(()=>{let y=Math.floor((Date.now()-e.callStartTime)/1e3);Q(y)},1e3):Q(0),()=>{a&&clearInterval(a)}},[e.callData.status]),Yt(()=>{r&&r(e.callData)},[e.callData,r]),Yt(()=>{e.agentId?It(w.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),Yt(()=>(e.agentId&&(m.current=new WebSocket(`${Ro.WS}?agent_id=${e.agentId}`),m.current.onopen=()=>{console.log("WebSocket connection established")},m.current.onmessage=a=>{try{let y=JSON.parse(a.data);console.log("parsedJSON:",y),T.updateCallData(y),y.status==="ONCALL"&&T.startCall(),y.status==="WRAPUP"&&T.endCall()}catch(y){console.log("Raw message:",a.data)}},m.current.onclose=()=>{console.log("WebSocket connection closed")},m.current.onerror=a=>{console.error("WebSocket error:",a)}),()=>{var a;(a=m.current)==null||a.close()}),[e.agentId]),!e.isInitialized||!e.process?p(et,{children:!!d&&p(Mo,{processList:rt==null?void 0:rt.processes,open:d,setOpen:C,handleSelectedProcessor:a=>{T.setProcess(a)}})}):K($n,{children:[p($o,{in:!0,timeout:300,children:p(Wo,{ref:Ct,elevation:vt?4:1,sx:{position:"fixed",left:j.x,top:j.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:9999999999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),userSelect:"none"},children:K(et,{sx:{display:"flex",alignItems:"center"},children:[K(et,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K(jt,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:bt,onTouchStart:St,children:[p(Ho,{})," "]}),p(et,{sx:{marginRight:"10px"},children:p(nt,{title:"Dial",children:p(jt,{size:"small",onClick:a=>{var y,A,q,F,V,Z,gt,ft;((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())!=="ONCALL"&&((F=(q=e.callData)==null?void 0:q.status)==null?void 0:F.toUpperCase())!=="BREAK"&&((Z=(V=e.callData)==null?void 0:V.status)==null?void 0:Z.toUpperCase())!=="RINGING"&&((ft=(gt=e.callData)==null?void 0:gt.status)==null?void 0:ft.toUpperCase())!=="WRAPUP"&&Ut(a)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:p(Pn,{sx:{color:((se=(ae=e.callData)==null?void 0:ae.status)==null?void 0:se.toUpperCase())==="ONCALL"||((re=(ie=e.callData)==null?void 0:ie.status)==null?void 0:re.toUpperCase())==="BREAK"||((ce=(le=e.callData)==null?void 0:le.status)==null?void 0:ce.toUpperCase())==="RINGING"||((de=(pe=e.callData)==null?void 0:pe.status)==null?void 0:de.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),p(qo,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Pt(at)}),p(qo,{variant:"body2",sx:{fontWeight:"bold"},children:(fe=(ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())!=null?fe:"N/A"}),K(ot,{size:"small",variant:"text",onClick:Bt,disabled:!!e.callStartTime,children:[p(vn,{})," "]})]}),K(et,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[p(nt,{title:"Agent Ready",children:p(ot,{variant:((xe=(me=e.callData)==null?void 0:me.status)==null?void 0:xe.toUpperCase())==="BREAK"||((ye=(he=e.callData)==null?void 0:he.status)==null?void 0:ye.toUpperCase())==="MISSED"?"outlined":"contained",onClick:a=>{var y,A,q,F;(((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())==="BREAK"||((F=(q=e.callData)==null?void 0:q.status)==null?void 0:F.toUpperCase())==="MISSED")&&(a.stopPropagation(),$t())},classes:{root:((Ce=(ve=e.callData)==null?void 0:ve.status)==null?void 0:Ce.toUpperCase())==="BREAK"||((Se=(be=e.callData)==null?void 0:be.status)==null?void 0:Se.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:l({},((Te=(Ee=e.callData)==null?void 0:Ee.status)==null?void 0:Te.toUpperCase())==="BREAK"||((De=(Le=e.callData)==null?void 0:Le.status)==null?void 0:De.toUpperCase())==="MISSED"?c:i),children:p(kn,{})})}),p(nt,{title:e.isHolding?"Resume":"Hold",children:p(ot,{variant:e.isHolding&&((Re=(Ie=e.callData)==null?void 0:Ie.status)==null?void 0:Re.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:a=>{a.stopPropagation(),st()},sx:e.isHolding&&((_e=(we=e.callData)==null?void 0:we.status)==null?void 0:_e.toUpperCase())==="ONCALL"?l({},i):((Ae=(ke=e.callData)==null?void 0:ke.status)==null?void 0:Ae.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((Pe=(Ne=e.callData)==null?void 0:Ne.status)==null?void 0:Pe.toUpperCase())!=="ONCALL"&&!e.isHolding,children:e.isHolding?p(_n,{}):p(In,{})})}),p(nt,{title:e.isMuted?"Unmute":"Mute",children:p(ot,{variant:e.isMuted&&((Ue=(Oe=e.callData)==null?void 0:Oe.status)==null?void 0:Ue.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:a=>{a.stopPropagation(),Fo()},sx:e.isMuted&&((Be=(Me=e.callData)==null?void 0:Me.status)==null?void 0:Be.toUpperCase())==="ONCALL"?l({},i):(($e=(He=e.callData)==null?void 0:He.status)==null?void 0:$e.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((We=(ze=e.callData)==null?void 0:ze.status)==null?void 0:We.toUpperCase())!=="ONCALL"&&!e.isMuted,children:e.isMuted?p(Dn,{}):p(Ln,{})})}),p(nt,{title:"Transfer Call",children:p(ot,{variant:g?"contained":"outlined",onClick:a=>{var y,A;((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())==="ONCALL"&&(a.stopPropagation(),f(!0))},sx:g?l({},i):((Fe=(qe=e.callData)==null?void 0:qe.status)==null?void 0:Fe.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((Ke=(Ge=e.callData)==null?void 0:Ge.status)==null?void 0:Ke.toUpperCase())!=="ONCALL",children:p(An,{})})}),p(nt,{title:"Conference Call",children:p(ot,{variant:O?"contained":"outlined",onClick:a=>{var y,A;((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())==="ONCALL"&&(a.stopPropagation(),o(!0))},sx:O?l({},i):((Ye=(je=e.callData)==null?void 0:je.status)==null?void 0:Ye.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((Je=(Xe=e.callData)==null?void 0:Xe.status)==null?void 0:Je.toUpperCase())!=="ONCALL",children:p(Sn,{})})}),p(nt,{title:"Call History",children:p(ot,{variant:D?"contained":"outlined",onClick:a=>{a.stopPropagation(),H(!0)},sx:D?l({},i):l({},c),children:p(En,{})})}),p(nt,{title:"End Call",children:p(ot,{variant:((Ve=(Qe=e.callData)==null?void 0:Qe.status)==null?void 0:Ve.toUpperCase())==="ONCALL"||((to=(Ze=e.callData)==null?void 0:Ze.status)==null?void 0:to.toUpperCase())==="RINGING"||((oo=(eo=e.callData)==null?void 0:eo.status)==null?void 0:oo.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:a=>{var y,A,q,F,V,Z;(((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())==="ONCALL"||((F=(q=e.callData)==null?void 0:q.status)==null?void 0:F.toUpperCase())==="RINGING"||((Z=(V=e.callData)==null?void 0:V.status)==null?void 0:Z.toUpperCase())==="WRAPUP")&&(a.stopPropagation(),v(!0))},sx:((ao=(no=e.callData)==null?void 0:no.status)==null?void 0:ao.toUpperCase())==="ONCALL"||((io=(so=e.callData)==null?void 0:so.status)==null?void 0:io.toUpperCase())==="RINGING"||((lo=(ro=e.callData)==null?void 0:ro.status)==null?void 0:lo.toUpperCase())==="WRAPUP"?M(l({},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}`}}):M(l({},n),{minWidth:"60px !important"}),disabled:((po=(co=e.callData)==null?void 0:co.status)==null?void 0:po.toUpperCase())!=="ONCALL"&&((go=(uo=e.callData)==null?void 0:uo.status)==null?void 0:go.toUpperCase())!=="RINGING"&&((mo=(fo=e.callData)==null?void 0:fo.status)==null?void 0:mo.toUpperCase())!=="WRAPUP",children:p(Cn,{})})})]})]})})}),p($o,{in:!0,timeout:300,children:K(Wo,{ref:Tt,elevation:Et?4:1,sx:{position:"fixed",left:dt.x,top:dt.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:9999999999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),visibility:L?"visible":"hidden",userSelect:"none"},children:[K(et,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:Lt,onTouchStart:Dt,children:[p(Ho,{sx:{transform:"rotate(90deg)"}})," ",p(jt,{onClick:()=>P(!1),children:p(bn,{})})]}),p("iframe",{src:`https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(xo=e.process)==null?void 0:xo.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay"})]})}),p(ee,{anchorEl:k,open:!!k,onClose:Mt,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:K(et,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[p(On,{size:"small",value:X,placeholder:"Enter Mobile No.",onChange:a=>{J(a.target.value)}}),p(jt,{color:"info",onClick:()=>{zt(X)},children:p(wn,{color:"success"})})]})}),K(ee,{anchorEl:b,open:!!b,onClose:Ht,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:[p(zo,{onClick:()=>ut("Lunch"),children:"- Lunch"}),p(zo,{onClick:()=>ut("Tea"),children:"- Tea"})]}),p(ee,{anchorEl:S,open:!!S,onClose:Ot,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:K(et,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[p(te,{icon:p(Tn,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),p(te,{icon:p(Rn,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),p(te,{icon:p(Nn,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!O&&p(Po,{open:O,setOpen:o}),!!g&&p(Oo,{open:g,setOpen:f}),!!x&&p(Uo,{open:x,setOpen:v,onSubmitDisposition:Go}),!!D&&p(Bo,{open:D,setOpen:H})]})}var oe=class{constructor(){W(this,"config",null);W(this,"ticketId",null);W(this,"baseUrl","");W(this,"eventQueue",[]);W(this,"isOnline",!0);W(this,"retryQueue",[]);W(this,"flushTimer",null)}async init(t){this.config=l({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},t),this.baseUrl=t.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let n=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),n}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 n=await t.json();return this.ticketId=n.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(t){throw console.error("EventTracker initialization failed:",t),t}}async logEvent(t,n){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",t);return}let i={eventType:t,eventData:n,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(c){console.warn("Failed to send event, will retry later:",c)}}async sendEvent(t){if(!(!this.config||!this.ticketId))try{let n=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(!n.ok)throw new Error(`Failed to log event: ${n.status} ${n.statusText}`);let i=this.eventQueue.findIndex(c=>c.timestamp===t.timestamp);i>-1&&this.eventQueue.splice(i,1)}catch(n){console.error("Event logging failed:",n),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 n=[...this.retryQueue];this.retryQueue=[];for(let i of n)try{await i()}catch(c){console.error("Retry failed:",c)}}async makeRequest(t,n){var e;let i=`${this.baseUrl}${t}`,c=((e=this.config)==null?void 0:e.retryAttempts)||3;for(let u=1;u<=c;u++)try{return await fetch(i,n)}catch(m){if(u===c)throw m;let S=Math.min(1e3*Math.pow(2,u-1),1e4);await new Promise(h=>setTimeout(h,S))}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(c=>console.warn("Failed to track page visit:",c)),t.clicks!==!1&&document.addEventListener("click",c=>{var u;let e=c.target;(e.tagName==="BUTTON"||e.tagName==="A"||e.onclick||e.getAttribute("role")==="button"||e instanceof HTMLButtonElement&&e.type==="button")&&this.logEvent("click",{element:e.tagName,text:(u=e.textContent)==null?void 0:u.trim().substring(0,100),href:e.getAttribute("href"),id:e.id,className:e.className,role:e.getAttribute("role"),position:{x:c.clientX,y:c.clientY},timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track click:",m))}),t.forms!==!1&&document.addEventListener("submit",c=>{let e=c.target,u=new FormData(e),m={};u.forEach((S,h)=>{m[h]=S.toString()}),this.logEvent("formSubmission",{formId:e.id,action:e.action,method:e.method,fields:Object.keys(m),fieldCount:Object.keys(m).length,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track form submission:",S))}),t.inputs!==!1){let c;document.addEventListener("input",e=>{let u=e.target;(u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.tagName==="SELECT")&&(clearTimeout(c),c=setTimeout(()=>{var m;this.logEvent("fieldChange",{element:u.tagName,type:u.getAttribute("type"),name:u.getAttribute("name"),id:u.id,valueLength:((m=u.value)==null?void 0:m.length)||0,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track field change:",S))},1e3))})}let n=Date.now();window.addEventListener("beforeunload",()=>{let c=Date.now()-n;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:c,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",c=>{this.logEvent("jsError",{message:c.message,filename:c.filename,lineno:c.lineno,colno:c.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",c=>{var e;this.logEvent("unhandledRejection",{reason:(e=c.reason)==null?void 0:e.toString(),timestamp:new Date().toISOString()})})),t.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let c=window.performance.navigation,e=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:e.navigationStart,loadTime:e.loadEventEnd-e.navigationStart,domReady:e.domContentLoadedEventEnd-e.navigationStart,renderTime:e.loadEventEnd-e.domContentLoadedEventEnd,navigationType:c.type,redirectCount:c.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 n;this.flushTimer&&clearInterval(this.flushTimer);let t=((n=this.config)==null?void 0:n.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},t)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},ne=new oe;typeof window!="undefined"&&(window.EventTracker=ne);import{useCallback as zn}from"react";var Wn=(r={})=>{let{onSuccess:t,onError:n,onComplete:i}=r,c=it(),[e,u]=$({onSuccess:S=>{t==null||t(S),i==null||i(),T.clearStorageAndReset(),localStorage.clear()},onError:S=>{n==null||n(S),i==null||i()}});return{logout:zn(()=>{let S={action:"LOGOUTUSER",userId:c.agentId||""};e(w.LOGOUT,S)},[e]),isLoading:u.isLoading,isSuccess:u.isSuccess,isError:u.isError,error:u.error,data:u.data}},qn=Wn;function Va({apiKey:r,tenantId:t,agentId:n}){T.initialize(r,n),ne.init({apiKey:r,tenantId:t,agentId:n,baseUrl:R})}export{Hn as CallControlPanel,Va as initSDK,qn as useLogout};
|
|
1
|
+
var jo=Object.defineProperty,Yo=Object.defineProperties;var Xo=Object.getOwnPropertyDescriptors;var Do=Object.getOwnPropertySymbols;var Jo=Object.prototype.hasOwnProperty,Qo=Object.prototype.propertyIsEnumerable;var Xt=(r,t,n)=>t in r?jo(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,l=(r,t)=>{for(var n in t||(t={}))Jo.call(t,n)&&Xt(r,n,t[n]);if(Do)for(var n of Do(t))Qo.call(t,n)&&Xt(r,n,t[n]);return r},M=(r,t)=>Yo(r,Xo(t));var W=(r,t,n)=>Xt(r,typeof t!="symbol"?t+"":t,n);var Jt=class{constructor(){W(this,"config",null);W(this,"ticketId",null);W(this,"baseUrl","");W(this,"eventQueue",[]);W(this,"isOnline",!0);W(this,"retryQueue",[]);W(this,"flushTimer",null)}async init(t){this.config=l({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},t),this.baseUrl=t.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let n=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),n}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 n=await t.json();return this.ticketId=n.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(t){throw console.error("EventTracker initialization failed:",t),t}}async logEvent(t,n){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",t);return}let i={eventType:t,eventData:n,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(c){console.warn("Failed to send event, will retry later:",c)}}async sendEvent(t){if(!(!this.config||!this.ticketId))try{let n=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(!n.ok)throw new Error(`Failed to log event: ${n.status} ${n.statusText}`);let i=this.eventQueue.findIndex(c=>c.timestamp===t.timestamp);i>-1&&this.eventQueue.splice(i,1)}catch(n){console.error("Event logging failed:",n),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 n=[...this.retryQueue];this.retryQueue=[];for(let i of n)try{await i()}catch(c){console.error("Retry failed:",c)}}async makeRequest(t,n){var e;let i=`${this.baseUrl}${t}`,c=((e=this.config)==null?void 0:e.retryAttempts)||3;for(let u=1;u<=c;u++)try{return await fetch(i,n)}catch(m){if(u===c)throw m;let E=Math.min(1e3*Math.pow(2,u-1),1e4);await new Promise(h=>setTimeout(h,E))}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(c=>console.warn("Failed to track page visit:",c)),t.clicks!==!1&&document.addEventListener("click",c=>{var u;let e=c.target;(e.tagName==="BUTTON"||e.tagName==="A"||e.onclick||e.getAttribute("role")==="button"||e instanceof HTMLButtonElement&&e.type==="button")&&this.logEvent("click",{element:e.tagName,text:(u=e.textContent)==null?void 0:u.trim().substring(0,100),href:e.getAttribute("href"),id:e.id,className:e.className,role:e.getAttribute("role"),position:{x:c.clientX,y:c.clientY},timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track click:",m))}),t.forms!==!1&&document.addEventListener("submit",c=>{let e=c.target,u=new FormData(e),m={};u.forEach((E,h)=>{m[h]=E.toString()}),this.logEvent("formSubmission",{formId:e.id,action:e.action,method:e.method,fields:Object.keys(m),fieldCount:Object.keys(m).length,timestamp:new Date().toISOString()}).catch(E=>console.warn("Failed to track form submission:",E))}),t.inputs!==!1){let c;document.addEventListener("input",e=>{let u=e.target;(u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.tagName==="SELECT")&&(clearTimeout(c),c=setTimeout(()=>{var m;this.logEvent("fieldChange",{element:u.tagName,type:u.getAttribute("type"),name:u.getAttribute("name"),id:u.id,valueLength:((m=u.value)==null?void 0:m.length)||0,timestamp:new Date().toISOString()}).catch(E=>console.warn("Failed to track field change:",E))},1e3))})}let n=Date.now();window.addEventListener("beforeunload",()=>{let c=Date.now()-n;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:c,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",c=>{this.logEvent("jsError",{message:c.message,filename:c.filename,lineno:c.lineno,colno:c.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",c=>{var e;this.logEvent("unhandledRejection",{reason:(e=c.reason)==null?void 0:e.toString(),timestamp:new Date().toISOString()})})),t.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let c=window.performance.navigation,e=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:e.navigationStart,loadTime:e.loadEventEnd-e.navigationStart,domReady:e.domContentLoadedEventEnd-e.navigationStart,renderTime:e.loadEventEnd-e.domContentLoadedEventEnd,navigationType:c.type,redirectCount:c.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 n;this.flushTimer&&clearInterval(this.flushTimer);let t=((n=this.config)==null?void 0:n.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},t)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},Qt=new Jt;typeof window!="undefined"&&(window.EventTracker=Qt);var Vt=class{constructor(){W(this,"state");W(this,"listeners",[]);W(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{url:"",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 n=JSON.parse(t);this.state=M(l({},this.state),{apiKey:n.apiKey||"",agentId:n.agentId||"",process:n.process||null,isInitialized:n.isInitialized||!1,isHolding:n.isHolding||!1,isMuted:n.isMuted||!1,status:n.status||"idle",url:n.url||"",callStartTime:n.callStartTime||null,controlPanelPosition:n.controlPanelPosition||{x:10,y:10},iframePosition:n.iframePosition||{x:10,y:80},callData:n.callData||{mobileNumber:"",callReferenceId:"",agentLoginId:""},conferenceLine:n.conferenceLine&&Array.isArray(n.conferenceLine)&&n.conferenceLine.length>0?n.conferenceLine:this.state.conferenceLine})}}catch(t){console.warn("Failed to load SDK state from localStorage:",t)}}saveToStorage(){try{let t={url:this.state.url,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,n,i){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("API key not available");this.state.apiKey=t,this.state.agentId=n,this.state.isInitialized=!0,this.state.url=i,this.saveToStorage(),this.notifyListeners()}getState(){return l({},this.state)}subscribe(t){return this.listeners.push(t),()=>{let n=this.listeners.indexOf(t);n>-1&&this.listeners.splice(n,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=l(l({},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 n=(i=this.state.conferenceLine)==null?void 0:i.map(c=>c.line===t.line?t:c);this.state.conferenceLine=n,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||[]}getUrl(){return this.state.url||""}},b=new Vt;import{useCallback as dn}from"react";import{useCallback as an,useReducer as sn}from"react";import Zo from"axios";var Io=b.getUrl(),k=`http://${Io}`,Vo=`ws://${Io}`,N={v1:"/api/v1"},R={LOGIN:`${k}${N.v1}/cti/login?provider=convox`,READY_AGENT:`${k}${N.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${k}${N.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${k}${N.v1}/cti/calls?provider=convox`,HOLD_CALL:`${k}${N.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${k}${N.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${k}${N.v1}/cti/unmute-call?provider=convox`,END_CALL:`${k}${N.v1}/cti/calls/end?provider=convox`,LOGOUT:`${k}${N.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${k}${N.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${k}${N.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${k}${N.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${k}${N.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${k}${N.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${k}${N.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${k}${N.v1}/cti/users`,PROCESS_LIST:`${k}${N.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${k}${N.v1}/cti/transfer-to-details?provider=convox`},Ro={WS:`${Vo}${N.v1}/cti/ws`};var tn="12345",Zt=Zo.create({baseURL:k,headers:{"Content-Type":"application/json",Authorization:tn},timeout:1e4});Zt.interceptors.request.use(r=>{let t="12345";return t&&r.headers&&(r.headers.Authorization=`Bearer ${t}`),r},r=>Promise.reject(r instanceof Error?r:new Error(String(r))));Zt.interceptors.response.use(r=>r,async r=>{var n;let t=r.config;return((n=r.response)==null?void 0:n.status)===401&&!t._retry&&(t._retry=!0),Promise.reject(r instanceof Error?r:new Error(String(r)))});var Y=Zt;import{Alert as en,Snackbar as on}from"@mui/material";import{useState as nn}from"react";import{jsx as wo}from"react/jsx-runtime";function mt(){let[r,t]=nn(!1),n=(c,e)=>{e!=="clickaway"&&t(!1)};return{showToast:(c,e)=>(t(!0),wo(on,{anchorOrigin:{vertical:"top",horizontal:"right"},open:r,onClose:n,children:wo(en,{onClose:n,severity:e,variant:"filled",sx:{width:"100%"},children:c})}))}}var rn={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},ln=(r,t)=>{if(t.type==="isLoading")return M(l({},r),{isLoading:t.payload});if(t.type==="isSuccess")return M(l({},r),{isSuccess:!0,data:t.payload});if(t.type==="isError")return M(l({},r),{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 $=(r={})=>{let{onSuccess:t=null,onError:n=null}=r,{showToast:i}=mt(),[c,e]=sn(ln,rn);return[an((m,E,h={})=>{e({type:"isLoading",payload:!0}),Y.post(m,E,h).then(L=>{e({type:"isSuccess",payload:L.data}),t==null||t(L.data,E)}).catch(L=>{var S,T,_,U,O,o,g,f,x,v,d,C;let P={status:(T=(S=L.response)==null?void 0:S.status)!=null?T:500,message:((U=(_=L.response)==null?void 0:_.data)==null?void 0:U.detail)||((o=(O=L.response)==null?void 0:O.data)==null?void 0:o.message)||L.message||"An unknown error occurred",data:(f=(g=L.response)==null?void 0:g.data)!=null?f:null,statusText:(v=(x=L.response)==null?void 0:x.statusText)!=null?v:"",code:(d=L==null?void 0:L.code)!=null?d:"",name:(C=L==null?void 0:L.name)!=null?C:""};i(P.message,"error"),e({type:"isError",payload:P}),n==null||n(P,E)}).finally(()=>{e({type:"isLoading",payload:!1})})},[t,n,i]),c]};import{useState as cn,useEffect as pn}from"react";function it(){let[r,t]=cn(b.getState());return pn(()=>b.subscribe(()=>{t(b.getState())}),[]),r}var un=(r={})=>{let{onSuccess:t,onError:n,onComplete:i}=r,c=it(),[e,u]=$({onSuccess:E=>{t==null||t(E),i==null||i(),b.clearStorageAndReset(),localStorage.clear()},onError:E=>{n==null||n(E),i==null||i()}});return{logout:dn(()=>{let E={action:"LOGOUTUSER",userId:c.agentId||""};e(R.LOGOUT,E)},[e]),isLoading:u.isLoading,isSuccess:u.isSuccess,isError:u.isError,error:u.error,data:u.data}},gn=un;import{ArrowDropDown as En,CallEnd as Tn,Close as Ln,DragIndicator as $o,Group as Dn,History as In,Layers as Rn,Mic as wn,MicOff as _n,Pause as kn,Pending as An,Phone as Nn,PlayArrow as Pn,SupportAgent as On,TransferWithinAStation as Un,Upcoming as Mn,WifiCalling3 as Bn}from"@mui/icons-material";import{Box as et,Button as ot,Chip as oe,Fade as zo,IconButton as jt,Menu as ne,MenuItem as Wo,Paper as qo,TextField as Hn,Tooltip as nt,Typography as Fo,useTheme as $n}from"@mui/material";import{useCallback as zn,useEffect as Yt,useRef as Wn,useState as G}from"react";import{useCallback as Wt,useRef as te,useState as _o}from"react";function ee(r,t){let[n,i]=_o(r),[c,e]=_o(!1),u=te(),m=te({x:0,y:0}),E=te({x:0,y:0}),h=Wt(T=>{let _=u.current;if(!_)return;let U=_.getBoundingClientRect(),O=window.innerWidth,o=window.innerHeight,g={x:Math.max(0,Math.min(T.x,O-U.width)),y:Math.max(0,Math.min(T.y,o-U.height))};i(g),t==null||t(g)},[t]),L=Wt((T,_)=>{e(!0),m.current={x:T,y:_},E.current=n;let U=(f,x)=>{let v=f-m.current.x,d=x-m.current.y;h({x:E.current.x+v,y:E.current.y+d})},O=f=>{f.preventDefault(),U(f.clientX,f.clientY)},o=f=>{f.preventDefault();let x=f.touches[0];x&&U(x.clientX,x.clientY)},g=()=>{e(!1),document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",g),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",g)};document.addEventListener("mousemove",O),document.addEventListener("mouseup",g),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",g)},[n,h]),P=Wt(T=>{T.preventDefault(),L(T.clientX,T.clientY)},[L]),S=Wt(T=>{T.preventDefault();let _=T.touches[0];_&&L(_.clientX,_.clientY)},[L]);return{position:n,isDragging:c,dragRef:u,handleMouseDown:P,handleTouchStart:S}}import{Call as Ft,CallEnd as ko,CallSplit as xn,Close as Kt,Mic as hn,MicOff as yn,Pause as vn,PhoneDisabled as Cn,PlayArrow as bn,SupportAgent as Gt}from"@mui/icons-material";import{Box as w,Button as z,Dialog as ht,IconButton as tt,Paper as yt,TextField as ct,Typography as B,Autocomplete as Ao,Grid as lt,Tooltip as xt,useTheme as Sn}from"@mui/material";import{useEffect as No,useState as Po}from"react";import{useTheme as fn}from"@mui/material";var mn=()=>{let r=fn();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 ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.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 ${r.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.palette.primary.light}`}},outlined:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:r.palette.grey[200],boxShadow:`0px 2px 1px ${r.palette.primary.light}`,border:`0px solid ${r.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${r.palette.primary.main}`,border:`0px solid ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.palette.primary.light}`}}}},qt=mn;import{Fragment as pt,jsx as s,jsxs as I}from"react/jsx-runtime";function Oo({open:r,setOpen:t}){var U,O;let n=it(),{disabled:i,enabled:c,outlined:e}=qt(),u=Sn(),m=()=>{t(!1)},E=(o,g)=>{b.setConferenceLine(l(l({},o),g))},h=(o,g)=>{var v,d,C,D;let f=l(l({},o),g),x={action:"EXTERNAL_CONFERENCE",operation:`CALL${f.line}`,line_used:String(f.line),thirdparty_no:f.phone,userid:(d=(v=n.callData)==null?void 0:v.agent_id)!=null?d:"",process:(D=(C=n.callData)==null?void 0:C.process_name)!=null?D:""};Y.post(R.CONFERENCE_CALL,x).then(()=>{b.setConferenceLine(l(l({},o),g))})},L=(o,g)=>{var v,d,C,D;let f=l(l({},o),g),x={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(f.line),thirdparty_no:f.phone,userid:(d=(v=n.callData)==null?void 0:v.agent_id)!=null?d:"",process:(D=(C=n.callData)==null?void 0:C.process_name)!=null?D:""};Y.post(R.CONFERENCE_CALL,x).then(()=>{b.setConferenceLine(l(l({},o),g))})},P=(o,g,f)=>{var d,C,D,H;let x=l(l({},o),g),v={action:"EXTERNAL_CONFERENCE",operation:f,hold_channel_no:f==="HOLDUSER"?`hold${x.line}`:`unhold${x.line}`,userid:(C=(d=n.callData)==null?void 0:d.agent_id)!=null?C:"",process:(H=(D=n.callData)==null?void 0:D.process_name)!=null?H:""};Y.post(R.CONFERENCE_CALL_HOLD_OR_UN_HOLD,v).then(()=>{b.setConferenceLine(l(l({},o),g))})},S=(o,g,f)=>{var d,C,D,H;let x=l(l({},o),g),v={action:"EXTERNAL_CONFERENCE",operation:f,channel_no:f==="MUTEUSER"?`mute${x.line}`:`play${x.line}`,userid:(C=(d=n.callData)==null?void 0:d.agent_id)!=null?C:"",thirdparty_no:x.phone,process:(H=(D=n.callData)==null?void 0:D.process_name)!=null?H:""};Y.post(R.CONFERENCE_CALL_MUTE_OT_UN_MUTE,v).then(()=>{b.setConferenceLine(l(l({},o),g))})},T=(o,g)=>{var v,d,C,D;let f=l(l({},o),g),x={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(f.line-1),user_type:`THIRDPARTY${f.line-1}`,thirdparty_no:f.phone,userid:(d=(v=n.callData)==null?void 0:v.agent_id)!=null?d:"",process:(D=(C=n.callData)==null?void 0:C.process_name)!=null?D:""};Y.post(R.CONFERENCE_CALL_END,x).then(()=>{b.setConferenceLine(l(l({},o),g))})},_=()=>{var g,f,x,v;let o={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(f=(g=n.callData)==null?void 0:g.agent_id)!=null?f:"",process:(v=(x=n.callData)==null?void 0:x.process_name)!=null?v:""};Y.post(R.CONFERENCE_CALL_END_ALL,o).then(()=>{b.resetConferenceLines(),m()})};return No(()=>{var g,f,x,v;let o={line:1,status:(f=(g=n.callData)==null?void 0:g.status)!=null?f:"",type:"internal",phone:(v=(x=n.callData)==null?void 0:x.phone_number)!=null?v:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};b.setConferenceLine(o)},[]),s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(yt,{sx:{borderRadius:2},children:[I(w,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[I(B,{variant:"body1",children:[(U=n==null?void 0:n.agentId)!=null?U:""," conference"]}),s(tt,{onClick:m,children:s(Kt,{})})]}),s(w,{sx:{boxShadow:"0px 1px 2px #e7e5e5ff",padding:"2px 6px",margin:"0px 10px",borderRadius:"20px"},children:(O=n==null?void 0:n.conferenceLine)==null?void 0:O.map((o,g)=>{var f,x;return I(w,{sx:{p:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[s(w,{sx:{color:"white",bgcolor:"warning.main",fontWeight:"bold",fontSize:14,minWidth:70,textAlign:"center",border:"2px solid primary.main",borderRadius:"10px 50px 50px 10px"},children:s(B,{children:(f=o==null?void 0:o.line)!=null?f:""})}),s(B,{variant:"body2",sx:{px:1,border:"2px solid gray",borderRadius:"10px",textAlign:"center",width:"80px",maxWidth:"100px"},children:(x=o==null?void 0:o.status)!=null?x:""}),s(z,{sx:{textTransform:"capitalize"},size:"small",children:s(B,{variant:"body2",children:(o==null?void 0:o.line)===1?"Internal":"External"})}),s(ct,{size:"small",placeholder:"Phone Number",value:(o==null?void 0:o.phone)||"",disabled:(o==null?void 0:o.line)===1,onChange:v=>{E(o,{phone:v.target.value})}}),s(xt,{title:"Call",children:s(z,{variant:o!=null&&o.isCallStart?"outlined":"contained",color:"success",sx:o!=null&&o.isCallStart?l({},i):M(l({},c),{border:`0px solid ${u.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${u.palette.success.light}`,border:`0px solid ${u.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${u.palette.primary.light}`}}),onClick:()=>{h(o,{isCallStart:!0,status:"ONCALL"})},disabled:o==null?void 0:o.isCallStart,children:s(Ft,{sx:{color:o!=null&&o.isCallStart?"default":"#fff"}})})}),s(xt,{title:"Merge Call",children:s(z,{variant:o!=null&&o.isMergeCall?"contained":"outlined",sx:o!=null&&o.isMergeCall&&(o!=null&&o.isCallStart)?l({},i):o!=null&&o.isCallStart?l({},e):l({},i),onClick:()=>{L(o,{isMergeCall:!0,status:"ONCALL"})},disabled:!(o!=null&&o.isCallStart),children:s(xn,{})})}),s(xt,{title:o.isHold?"Hold":"Un Hold",children:s(z,{variant:o!=null&&o.isHold?"contained":"outlined",sx:o!=null&&o.isHold&&(o!=null&&o.isCallStart)?l({},i):o!=null&&o.isCallStart?l({},e):l({},i),onClick:()=>{o.isHold?P(o,{isHold:!1},"UNHOLDUSER"):P(o,{isHold:!0},"HOLDUSER")},disabled:!(o!=null&&o.isCallStart),children:o.isHold?s(bn,{}):s(vn,{})})}),s(xt,{title:o.isMute?"Mute":"Un Mute",children:s(z,{variant:o!=null&&o.isMute?"contained":"outlined",sx:o!=null&&o.isMute&&(o!=null&&o.isCallStart)?l({},i):o!=null&&o.isCallStart?l({},e):l({},i),onClick:()=>{o.isMute?S(o,{isMute:!1},"PLAYUSER"):S(o,{isMute:!0},"MUTEUSER")},disabled:!(o!=null&&o.isCallStart),children:o.isMute?s(yn,{}):s(hn,{})})}),s(xt,{title:"End Call",children:(o==null?void 0:o.line)!==1?s(z,{variant:o!=null&&o.isCallStart?"contained":"outlined",color:"error",sx:o!=null&&o.isCallStart?M(l({},c),{minWidth:"60px !important",border:`0px solid ${u.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${u.palette.error.light}`,border:`0px solid ${u.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${u.palette.primary.light}`}}):M(l({},i),{minWidth:"60px !important"}),onClick:()=>{T(o,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE"})},disabled:!(o!=null&&o.isCallStart),children:s(ko,{})}):s(z,{variant:o!=null&&o.isCallStart?"contained":"outlined",sx:M(l({},i),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{T(o,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE"})},disabled:!(o!=null&&o.isCallStart),children:s(B,{children:s(ko,{sx:{visibility:"hidden"}})})})})]},g)})}),s(w,{textAlign:"center",m:2,children:I(z,{variant:"outlined",color:"error",size:"large",onClick:_,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[s(tt,{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:s(Cn,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function Uo({open:r,setOpen:t}){var S,T,_,U,O,o,g,f,x,v;let[n]=$({onSuccess:d=>{console.log("res",d),t(!1)},onError:d=>{console.log("error",d)}}),i=it(),[c,e]=Po("process"),[u,{data:m}]=$(),[E,{data:h}]=$(),L=()=>{t(!1)},P=(d,C)=>{var D,H,X,J,at,Q,j,vt,Ct,bt,St,dt,Et,Tt,Lt,Dt,It,rt,Rt,wt,_t,kt,At,Nt,Pt,Ot,Ut,Mt,Bt,Ht,$t,ut,zt;if(console.log(d,"data34"),C==="PROCESS"){let st={mobile_number:(H=(D=i.callData)==null?void 0:D.phone_number)!=null?H:"",userid:(J=(X=i.callData)==null?void 0:X.agent_id)!=null?J:"",type:"PROCESS",transfer_to:(at=d==null?void 0:d.process_name)!=null?at:"",callreferenceid:(j=(Q=i.callData)==null?void 0:Q.convox_id)!=null?j:"",processid:String((Ct=(vt=i.callData)==null?void 0:vt.process_id)!=null?Ct:""),process_name:(St=(bt=i.callData)==null?void 0:bt.process_name)!=null?St:""};n(R.TRANSFER_CALL,st)}else if(C==="QUEUE"){let st={mobile_number:(Et=(dt=i.callData)==null?void 0:dt.phone_number)!=null?Et:"",userid:(Lt=(Tt=i.callData)==null?void 0:Tt.agent_id)!=null?Lt:"",type:"QUEUE",transfer_to:(Dt=d==null?void 0:d.queue_name)!=null?Dt:"",callreferenceid:(rt=(It=i.callData)==null?void 0:It.convox_id)!=null?rt:"",processid:String((wt=(Rt=i.callData)==null?void 0:Rt.process_id)!=null?wt:""),process_name:(kt=(_t=i.callData)==null?void 0:_t.process_name)!=null?kt:""};n(R.TRANSFER_CALL,st)}else if(C==="AGENT"){let st={mobile_number:(Nt=(At=i.callData)==null?void 0:At.phone_number)!=null?Nt:"",userid:(Ot=(Pt=i.callData)==null?void 0:Pt.agent_id)!=null?Ot:"",type:"AGENT",transfer_to:(Ut=d==null?void 0:d.user_id)!=null?Ut:"",callreferenceid:(Bt=(Mt=i.callData)==null?void 0:Mt.convox_id)!=null?Bt:"",processid:String(($t=(Ht=i.callData)==null?void 0:Ht.process_id)!=null?$t:""),process_name:(zt=(ut=i.callData)==null?void 0:ut.process_name)!=null?zt:""};n(R.TRANSFER_CALL,st)}};return No(()=>{u(R.AGENTS_LIST,{status:"IDLE",active:!0}),E(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(yt,{sx:{borderRadius:2},children:[I(w,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(B,{variant:"body1",children:" Call Transfer"}),s(tt,{onClick:L,children:s(Kt,{})})]}),I(w,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[I(w,{sx:{display:"flex",gap:1},children:[s(z,{variant:c==="process"?"contained":"outlined",onClick:()=>e("process"),children:"Process"}),s(z,{variant:c==="queues"?"contained":"outlined",onClick:()=>e("queues"),children:"Queues"}),s(z,{variant:c==="agents"?"contained":"outlined",onClick:()=>e("agents"),children:"Agents"})]}),c==="process"&&s(w,{sx:{display:"flex",gap:1},children:((T=(S=h==null?void 0:h.data)==null?void 0:S.process)==null?void 0:T.length)>0?(U=(_=h==null?void 0:h.data)==null?void 0:_.process)==null?void 0:U.map((d,C)=>I(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:[I(B,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(Gt,{sx:{marginRight:"4px"}}),d.process_name]}),s(tt,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{P(d,"PROCESS")},children:s(Ft,{})})]},C)):s(B,{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"})}),c==="queues"&&s(w,{sx:{display:"flex",gap:1},children:((o=(O=h==null?void 0:h.data)==null?void 0:O.queue)==null?void 0:o.length)>0?(f=(g=h==null?void 0:h.data)==null?void 0:g.queue)==null?void 0:f.map((d,C)=>{var D,H,X,J,at,Q;return I(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:[I(B,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(Gt,{sx:{marginRight:"4px"}}),d.queue_name,(X=(H=(D=h==null?void 0:h.data)==null?void 0:D.process)==null?void 0:H.find(j=>j.process_id===d.process_id))!=null&&X.process_name?s(B,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((Q=(at=(J=h==null?void 0:h.data)==null?void 0:J.process)==null?void 0:at.find(j=>j.process_id===d.process_id))==null?void 0:Q.process_name)+")"}):""]}),s(tt,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{P(d,"QUEUE")},children:s(Ft,{})})]},C)}):s(B,{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"})}),c==="agents"&&s(w,{sx:{display:"flex",gap:1},children:((x=m==null?void 0:m.data)==null?void 0:x.length)>0?(v=m==null?void 0:m.data)==null?void 0:v.map((d,C)=>I(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:[I(B,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(Gt,{sx:{marginRight:"4px"}}),d.name]}),s(tt,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{P(d,"AGENT")},children:s(Ft,{})})]},C)):s(B,{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 Mo({open:r,setOpen:t,onSubmitDisposition:n}){var L,P;let[i,c]=Po({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),e=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],u=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],m=(S,T)=>{c(_=>M(l({},_),{[S]:T}))},E=()=>{c({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},h=()=>{E(),t(!1)};return s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:I(yt,{sx:{borderRadius:2},children:[s(w,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:I(B,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),s(w,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:I(lt,{container:!0,spacing:2,children:[s(lt,{size:6,children:s(Ao,{value:i.disposition,options:e,getOptionLabel:S=>S.label,onChange:(S,T)=>m("disposition",T),size:"small",renderInput:S=>s(ct,M(l({},S),{label:"Disposition",fullWidth:!0}))})}),s(lt,{size:6,children:s(Ao,{options:u,getOptionLabel:S=>S.label,value:i.followUp,onChange:(S,T)=>m("followUp",T),size:"small",renderInput:S=>s(ct,M(l({},S),{label:"Follow Up",fullWidth:!0}))})}),((P=(L=i==null?void 0:i.followUp)==null?void 0:L.label)==null?void 0:P.toLowerCase())==="yes"&&I(pt,{children:[s(lt,{size:6,children:s(ct,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:i.callbackDate,onChange:S=>m("callbackDate",S.target.value),fullWidth:!0})}),s(lt,{size:6,children:s(ct,{size:"small",label:"Hours (0-23)",type:"text",inputProps:{min:0,max:23},value:i.callbackHrs,onChange:S=>m("callbackHrs",S.target.value),fullWidth:!0})}),s(lt,{size:6,children:s(ct,{size:"small",label:"Minutes (0-59)",type:"text",inputProps:{min:0,max:59},value:i.callbackMins,onChange:S=>m("callbackMins",S.target.value),fullWidth:!0})})]})]})}),I(w,{textAlign:"right",m:2,children:[s(z,{variant:"outlined",color:"error",size:"large",onClick:h,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),s(z,{variant:"contained",color:"primary",size:"large",onClick:()=>n(i),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function Bo({open:r,setOpen:t,processList:n=[],handleSelectedProcessor:i}){return s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:I(yt,{sx:{borderRadius:2},children:[I(w,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(B,{variant:"body1",children:" Process List"}),s(tt,{onClick:()=>{t(!1)},children:s(Kt,{})})]}),s(w,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:(n==null?void 0:n.length)>0?n==null?void 0:n.map((e,u)=>s(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(e)},children:I(B,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(Gt,{sx:{marginRight:"4px"}}),e.process_name]})},u)):null})]})})})}function Ho({open:r,setOpen:t}){return s(pt,{children:s(ht,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(yt,{sx:{borderRadius:2},children:[I(w,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(B,{variant:"body1",children:" Call History"}),s(tt,{onClick:()=>{t(!1)},children:s(Kt,{})})]}),s(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 Fn,jsx as p,jsxs as K}from"react/jsx-runtime";function qn({onDataChange:r}){var ae,se,ie,re,le,ce,pe,de,ue,ge,fe,me,xe,he,ye,ve,Ce,be,Se,Ee,Te,Le,De,Ie,Re,we,_e,ke,Ae,Ne,Pe,Oe,Ue,Me,Be,He,$e,ze,We,qe,Fe,Ge,Ke,je,Ye,Xe,Je,Qe,Ve,Ze,to,eo,oo,no,ao,so,io,ro,lo,co,po,uo,go,fo,mo,xo;let t=$n(),{disabled:n,enabled:i,outlined:c}=qt(),e=it(),{showToast:u}=mt(),m=Wn(null),[E,h]=G(null),[L,P]=G(!0),[S,T]=G(null),[_,U]=G(null),[O,o]=G(!1),[g,f]=G(!1),[x,v]=G(!1),[d,C]=G(!1),[D,H]=G(!1),[X,J]=G(""),[at,Q]=G(0),{position:j,isDragging:vt,dragRef:Ct,handleMouseDown:bt,handleTouchStart:St}=ee(e.controlPanelPosition,a=>b.setControlPanelPosition(a)),{position:dt,isDragging:Et,dragRef:Tt,handleMouseDown:Lt,handleTouchStart:Dt}=ee(e.iframePosition,a=>b.setIframePosition(a)),[It,{data:rt}]=$({onSuccess:a=>{var y;console.log("res",a),a&&a.data&&((y=a==null?void 0:a.data)==null?void 0:y.length)>1?C(!0):(b.setProcess(a==null?void 0:a.data[0]),C(!1))},onError:()=>{C(!1)}}),[Rt]=$(),[wt]=$({onSuccess:()=>{b.setHolding(!e.isHolding)},onError:a=>{console.log("error",a)}}),[_t]=$({onSuccess:()=>{b.setMuted(!e.isMuted)},onError:a=>{console.log("error",a)}}),[kt]=$(),[At]=$(),[Nt]=$(),Pt=zn(a=>{let y=Math.floor(a/60),A=a%60;return`${y.toString().padStart(2,"0")}:${A.toString().padStart(2,"0")}`},[]),Ot=()=>{h(null)},Ut=a=>{P(!0),U(a.currentTarget),b.setStatus("dial")},Mt=()=>{e.status!=="on call"&&b.setStatus("idle"),U(null)},Bt=a=>{T(a.currentTarget)},Ht=()=>{T(null)},$t=()=>{let a={action:"READYAGENT",userId:e.agentId};kt(R.READY_AGENT,a)},ut=a=>{T(null);let y={action:"AGENTBREAK",break_type:a,userId:e.agentId};At(R.UPDATE_AGENT_BREAK,y)},zt=a=>{if(a.length!==10)u("Invalid phone number","error"),alert("Invalid phone number");else if(!/^\d+$/.test(a))u("Invalid phone number","error");else{let y={action:"CALL",phone_number:a,userId:e.agentId};Rt(R.CLICK_TO_CALL,y)}},st=()=>{let a={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};wt(R.HOLD_CALL,a)},Go=()=>{let a={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};_t(R.MUTE_CALL,a)},Ko=a=>{var A,q,F,V,Z,gt,ft,ho,yo,vo,Co,bo,So,Eo,To,Lo;console.log("data",a);let y={action:"ENDCALL",userId:e.agentId,processid:(F=(q=(A=e.process)==null?void 0:A.process_id)==null?void 0:q.toString())!=null?F:"",process_name:(Z=(V=e.process)==null?void 0:V.process_name)!=null?Z:"",callreferenceid:(ft=(gt=e.callData)==null?void 0:gt.convox_id)!=null?ft:"",mobile_number:(yo=(ho=e.callData)==null?void 0:ho.phone_number)!=null?yo:"",disposition:(Co=(vo=a==null?void 0:a.disposition)==null?void 0:vo.value)!=null?Co:"",set_followUp:(So=(bo=a==null?void 0:a.followUp)==null?void 0:bo.value)!=null?So:"",callback_date:(Eo=a==null?void 0:a.callbackDate)!=null?Eo:"",callback_hrs:(To=a==null?void 0:a.callbackHrs)!=null?To:"",callback_mins:(Lo=a==null?void 0:a.callbackMins)!=null?Lo:"",endcall_type:"CLOSE"};J(""),Nt(R.END_CALL,y),b.endCall(),v(!1)};return Yt(()=>{let a;return e.callData.status&&e.callData.status==="ONCALL"?a=setInterval(()=>{let y=Math.floor((Date.now()-e.callStartTime)/1e3);Q(y)},1e3):Q(0),()=>{a&&clearInterval(a)}},[e.callData.status]),Yt(()=>{r&&r(e.callData)},[e.callData,r]),Yt(()=>{e.agentId?It(R.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),Yt(()=>(e.agentId&&(m.current=new WebSocket(`${Ro.WS}?agent_id=${e.agentId}`),m.current.onopen=()=>{console.log("WebSocket connection established")},m.current.onmessage=a=>{try{let y=JSON.parse(a.data);console.log("parsedJSON:",y),b.updateCallData(y),y.status==="ONCALL"&&b.startCall(),y.status==="WRAPUP"&&b.endCall()}catch(y){console.log("Raw message:",a.data)}},m.current.onclose=()=>{console.log("WebSocket connection closed")},m.current.onerror=a=>{console.error("WebSocket error:",a)}),()=>{var a;(a=m.current)==null||a.close()}),[e.agentId]),!e.isInitialized||!e.process?p(et,{children:!!d&&p(Bo,{processList:rt==null?void 0:rt.processes,open:d,setOpen:C,handleSelectedProcessor:a=>{b.setProcess(a)}})}):K(Fn,{children:[p(zo,{in:!0,timeout:300,children:p(qo,{ref:Ct,elevation:vt?4:1,sx:{position:"fixed",left:j.x,top:j.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:9999999999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),userSelect:"none"},children:K(et,{sx:{display:"flex",alignItems:"center"},children:[K(et,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K(jt,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:bt,onTouchStart:St,children:[p($o,{})," "]}),p(et,{sx:{marginRight:"10px"},children:p(nt,{title:"Dial",children:p(jt,{size:"small",onClick:a=>{var y,A,q,F,V,Z,gt,ft;((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())!=="ONCALL"&&((F=(q=e.callData)==null?void 0:q.status)==null?void 0:F.toUpperCase())!=="BREAK"&&((Z=(V=e.callData)==null?void 0:V.status)==null?void 0:Z.toUpperCase())!=="RINGING"&&((ft=(gt=e.callData)==null?void 0:gt.status)==null?void 0:ft.toUpperCase())!=="WRAPUP"&&Ut(a)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:p(Bn,{sx:{color:((se=(ae=e.callData)==null?void 0:ae.status)==null?void 0:se.toUpperCase())==="ONCALL"||((re=(ie=e.callData)==null?void 0:ie.status)==null?void 0:re.toUpperCase())==="BREAK"||((ce=(le=e.callData)==null?void 0:le.status)==null?void 0:ce.toUpperCase())==="RINGING"||((de=(pe=e.callData)==null?void 0:pe.status)==null?void 0:de.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),p(Fo,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Pt(at)}),p(Fo,{variant:"body2",sx:{fontWeight:"bold"},children:(fe=(ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())!=null?fe:"N/A"}),K(ot,{size:"small",variant:"text",onClick:Bt,disabled:!!e.callStartTime,children:[p(En,{})," "]})]}),K(et,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[p(nt,{title:"Agent Ready",children:p(ot,{variant:((xe=(me=e.callData)==null?void 0:me.status)==null?void 0:xe.toUpperCase())==="BREAK"||((ye=(he=e.callData)==null?void 0:he.status)==null?void 0:ye.toUpperCase())==="MISSED"?"outlined":"contained",onClick:a=>{var y,A,q,F;(((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())==="BREAK"||((F=(q=e.callData)==null?void 0:q.status)==null?void 0:F.toUpperCase())==="MISSED")&&(a.stopPropagation(),$t())},classes:{root:((Ce=(ve=e.callData)==null?void 0:ve.status)==null?void 0:Ce.toUpperCase())==="BREAK"||((Se=(be=e.callData)==null?void 0:be.status)==null?void 0:Se.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:l({},((Te=(Ee=e.callData)==null?void 0:Ee.status)==null?void 0:Te.toUpperCase())==="BREAK"||((De=(Le=e.callData)==null?void 0:Le.status)==null?void 0:De.toUpperCase())==="MISSED"?c:i),children:p(On,{})})}),p(nt,{title:e.isHolding?"Resume":"Hold",children:p(ot,{variant:e.isHolding&&((Re=(Ie=e.callData)==null?void 0:Ie.status)==null?void 0:Re.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:a=>{a.stopPropagation(),st()},sx:e.isHolding&&((_e=(we=e.callData)==null?void 0:we.status)==null?void 0:_e.toUpperCase())==="ONCALL"?l({},i):((Ae=(ke=e.callData)==null?void 0:ke.status)==null?void 0:Ae.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((Pe=(Ne=e.callData)==null?void 0:Ne.status)==null?void 0:Pe.toUpperCase())!=="ONCALL"&&!e.isHolding,children:e.isHolding?p(Pn,{}):p(kn,{})})}),p(nt,{title:e.isMuted?"Unmute":"Mute",children:p(ot,{variant:e.isMuted&&((Ue=(Oe=e.callData)==null?void 0:Oe.status)==null?void 0:Ue.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:a=>{a.stopPropagation(),Go()},sx:e.isMuted&&((Be=(Me=e.callData)==null?void 0:Me.status)==null?void 0:Be.toUpperCase())==="ONCALL"?l({},i):(($e=(He=e.callData)==null?void 0:He.status)==null?void 0:$e.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((We=(ze=e.callData)==null?void 0:ze.status)==null?void 0:We.toUpperCase())!=="ONCALL"&&!e.isMuted,children:e.isMuted?p(_n,{}):p(wn,{})})}),p(nt,{title:"Transfer Call",children:p(ot,{variant:g?"contained":"outlined",onClick:a=>{var y,A;((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())==="ONCALL"&&(a.stopPropagation(),f(!0))},sx:g?l({},i):((Fe=(qe=e.callData)==null?void 0:qe.status)==null?void 0:Fe.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((Ke=(Ge=e.callData)==null?void 0:Ge.status)==null?void 0:Ke.toUpperCase())!=="ONCALL",children:p(Un,{})})}),p(nt,{title:"Conference Call",children:p(ot,{variant:O?"contained":"outlined",onClick:a=>{var y,A;((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())==="ONCALL"&&(a.stopPropagation(),o(!0))},sx:O?l({},i):((Ye=(je=e.callData)==null?void 0:je.status)==null?void 0:Ye.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((Je=(Xe=e.callData)==null?void 0:Xe.status)==null?void 0:Je.toUpperCase())!=="ONCALL",children:p(Dn,{})})}),p(nt,{title:"Call History",children:p(ot,{variant:D?"contained":"outlined",onClick:a=>{a.stopPropagation(),H(!0)},sx:D?l({},i):l({},c),children:p(In,{})})}),p(nt,{title:"End Call",children:p(ot,{variant:((Ve=(Qe=e.callData)==null?void 0:Qe.status)==null?void 0:Ve.toUpperCase())==="ONCALL"||((to=(Ze=e.callData)==null?void 0:Ze.status)==null?void 0:to.toUpperCase())==="RINGING"||((oo=(eo=e.callData)==null?void 0:eo.status)==null?void 0:oo.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:a=>{var y,A,q,F,V,Z;(((A=(y=e.callData)==null?void 0:y.status)==null?void 0:A.toUpperCase())==="ONCALL"||((F=(q=e.callData)==null?void 0:q.status)==null?void 0:F.toUpperCase())==="RINGING"||((Z=(V=e.callData)==null?void 0:V.status)==null?void 0:Z.toUpperCase())==="WRAPUP")&&(a.stopPropagation(),v(!0))},sx:((ao=(no=e.callData)==null?void 0:no.status)==null?void 0:ao.toUpperCase())==="ONCALL"||((io=(so=e.callData)==null?void 0:so.status)==null?void 0:io.toUpperCase())==="RINGING"||((lo=(ro=e.callData)==null?void 0:ro.status)==null?void 0:lo.toUpperCase())==="WRAPUP"?M(l({},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}`}}):M(l({},n),{minWidth:"60px !important"}),disabled:((po=(co=e.callData)==null?void 0:co.status)==null?void 0:po.toUpperCase())!=="ONCALL"&&((go=(uo=e.callData)==null?void 0:uo.status)==null?void 0:go.toUpperCase())!=="RINGING"&&((mo=(fo=e.callData)==null?void 0:fo.status)==null?void 0:mo.toUpperCase())!=="WRAPUP",children:p(Tn,{})})})]})]})})}),p(zo,{in:!0,timeout:300,children:K(qo,{ref:Tt,elevation:Et?4:1,sx:{position:"fixed",left:dt.x,top:dt.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:9999999999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),visibility:L?"visible":"hidden",userSelect:"none"},children:[K(et,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:Lt,onTouchStart:Dt,children:[p($o,{sx:{transform:"rotate(90deg)"}})," ",p(jt,{onClick:()=>P(!1),children:p(Ln,{})})]}),p("iframe",{src:`https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(xo=e.process)==null?void 0:xo.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay"})]})}),p(ne,{anchorEl:_,open:!!_,onClose:Mt,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:K(et,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[p(Hn,{size:"small",value:X,placeholder:"Enter Mobile No.",onChange:a=>{J(a.target.value)}}),p(jt,{color:"info",onClick:()=>{zt(X)},children:p(Nn,{color:"success"})})]})}),K(ne,{anchorEl:S,open:!!S,onClose:Ht,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:[p(Wo,{onClick:()=>ut("Lunch"),children:"- Lunch"}),p(Wo,{onClick:()=>ut("Tea"),children:"- Tea"})]}),p(ne,{anchorEl:E,open:!!E,onClose:Ot,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:K(et,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[p(oe,{icon:p(Rn,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),p(oe,{icon:p(An,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),p(oe,{icon:p(Mn,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!O&&p(Oo,{open:O,setOpen:o}),!!g&&p(Uo,{open:g,setOpen:f}),!!x&&p(Mo,{open:x,setOpen:v,onSubmitDisposition:Ko}),!!D&&p(Ho,{open:D,setOpen:H})]})}function Za({apiKey:r,tenantId:t,agentId:n,baseURL:i}){b.initialize(r,n,i),Qt.init({apiKey:r,tenantId:t,agentId:n,baseUrl:i})}export{qn as CallControlPanel,Za as initSDK,gn as useLogout};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|