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