call-control-sdk 6.4.5-dev.1 → 6.4.5-dev.11

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.js CHANGED
@@ -1,2 +1,3900 @@
1
- "use strict";var dn=Object.create;var Ie=Object.defineProperty,un=Object.defineProperties,gn=Object.getOwnPropertyDescriptor,fn=Object.getOwnPropertyDescriptors,mn=Object.getOwnPropertyNames,qo=Object.getOwnPropertySymbols,xn=Object.getPrototypeOf,Fo=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable;var Ve=(e,o,t)=>o in e?Ie(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,d=(e,o)=>{for(var t in o||(o={}))Fo.call(o,t)&&Ve(e,t,o[t]);if(qo)for(var t of qo(o))Cn.call(o,t)&&Ve(e,t,o[t]);return e},W=(e,o)=>un(e,fn(o));var bn=(e,o)=>{for(var t in o)Ie(e,t,{get:o[t],enumerable:!0})},Ko=(e,o,t,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of mn(o))!Fo.call(e,r)&&r!==t&&Ie(e,r,{get:()=>o[r],enumerable:!(l=gn(o,r))||l.enumerable});return e};var yn=(e,o,t)=>(t=e!=null?dn(xn(e)):{},Ko(o||!e||!e.__esModule?Ie(t,"default",{value:e,enumerable:!0}):t,e)),En=e=>Ko(Ie({},"__esModule",{value:!0}),e);var le=(e,o,t)=>Ve(e,typeof o!="symbol"?o+"":o,t);var Mn={};bn(Mn,{CallControlPanel:()=>st,getSDKVersion:()=>On,initSDK:()=>kn,isSDKInitialized:()=>Pn,useClickToCall:()=>Jo,useEndCall:()=>Xo,useGetAuthorizationToken:()=>Zo,useGetCallerData:()=>Vo,useLogout:()=>jo});module.exports=En(Mn);var Fe="uat-cti.aighospitals.com",$=`https://${Fe}:8095`,hn=`wss://${Fe}:8095`,G={v1:"/api/v1"},R={LOGIN:`${$}${G.v1}/cti/login?provider=convox`,READY_AGENT:`${$}${G.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${$}${G.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${$}${G.v1}/cti/calls?provider=convox`,HOLD_CALL:`${$}${G.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${$}${G.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${$}${G.v1}/cti/unmute-call?provider=convox`,END_CALL:`${$}${G.v1}/cti/calls/end?provider=convox`,LOGOUT:`${$}${G.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${$}${G.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${$}${G.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${$}${G.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${$}${G.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${$}${G.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${$}${G.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${$}${G.v1}/cti/users`,PROCESS_LIST:`${$}${G.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${$}${G.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${$}${G.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${$}${G.v1}/users/get_sentiment_analysis`},Wo={WS:`${hn}${G.v1}/cti/ws`},fe="call-control-sdk-state";var Ze=class{constructor(){le(this,"state");le(this,"listeners",[]);le(this,"STORAGE_KEY",fe);le(this,"apiKey");le(this,"tenantId");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{authorization:void 0,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 t=JSON.parse(o);this.state=W(d({},this.state),{agentId:t.agentId||"",authorization:t.authorization||void 0,process:t.process||null,openConferenceDialog:(t==null?void 0:t.openConferenceDialog)||!1,openCallTransferDialog:(t==null?void 0:t.openCallTransferDialog)||!1,isInitialized:t.isInitialized||!1,sdkConfig:t.sdkConfig||{disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,disabled:{},enabled:{},outlined:{}},isHolding:t.isHolding||!1,isMuted:t.isMuted||!1,status:t.status||"idle",callStartTime:t.callStartTime||null,controlPanelPosition:t.controlPanelPosition||{x:10,y:10},iframePosition:t.iframePosition||{x:10,y:80},callData:t.callData||{mobileNumber:"",callReferenceId:"",agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:t.conferenceLine&&Array.isArray(t.conferenceLine)&&t.conferenceLine.length>0?t.conferenceLine:this.state.conferenceLine})}}catch(o){console.warn("Failed to load SDK state from localStorage:",o)}}saveToStorage(){try{let o={agentId:this.state.agentId,authorization:this.state.authorization,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())}validateCredentials(o,t){if(!o||typeof o!="string"||o.trim().length===0)throw new Error("API key not available");if(!t||typeof t!="string"||t.trim().length===0)throw new Error("Tenant ID not available");this.apiKey=o.trim(),this.tenantId=t.trim()}initialize(o,t,l,r,a){if(this.validateCredentials(o,t),!l||typeof l!="string"||l.trim().length===0)throw new Error("Agent ID not available");this.state.agentId=l,this.state.openConferenceDialog=!1,this.state.openCallTransferDialog=!1,this.state.authorization=a,this.state.sdkConfig=d({disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,disabled:{},enabled:{},outlined:{}},r),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return d({},this.state)}getCredentials(){return{apiKey:this.apiKey,tenantId:this.tenantId}}getSdkAuthToken(){var o;return(o=this.state.authorization)==null?void 0:o.accessToken}subscribe(o){return this.listeners.push(o),()=>{let t=this.listeners.indexOf(o);t>-1&&this.listeners.splice(t,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=d(d({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}updateConferenceData(o){this.state.conferenceLine=[...o],this.saveToStorage(),this.notifyListeners()}setConferenceLine(o){var l;(!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 t=(l=this.state.conferenceLine)==null?void 0:l.map(r=>r.line===o.line?o:r);this.state.conferenceLine=t,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||[]}},C=new Ze;var Qe=class{constructor(){le(this,"config",null);le(this,"ticketId",null);le(this,"baseUrl","");le(this,"eventQueue",[]);le(this,"flushTimer",null)}async init(o){this.config=d({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},o),this.baseUrl=o.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let t=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),t}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 C.setInitCheck(),new Error(`Failed to initialize: ${o.status} ${o.statusText}`);let t=await o.json();return this.ticketId=t.ticketId,this.config.autoTrack&&this.setupAutoTracking(),t}catch(o){throw console.error("EventTracker initialization failed:",o),o}}async logEvent(o,t){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",o);return}let l={eventType:o,eventData:t,timestamp:Date.now()};this.eventQueue.push(l),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift()}async makeRequest(o,t){var a;let l=`${this.baseUrl}${o}`,r=((a=this.config)==null?void 0:a.retryAttempts)||3;for(let c=1;c<=r;c++)try{return await fetch(l,t)}catch(x){if(c===r)throw x;let E=Math.min(1e3*Math.pow(2,c-1),1e4);await new Promise(b=>setTimeout(b,E))}throw new Error("Max retries exceeded")}setupAutoTracking(){var l;if(typeof window=="undefined"||!((l=this.config)!=null&&l.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 c;let a=r.target;(a.tagName==="BUTTON"||a.tagName==="A"||a.onclick||a.getAttribute("role")==="button"||a instanceof HTMLButtonElement&&a.type==="button")&&this.logEvent("click",{element:a.tagName,text:(c=a.textContent)==null?void 0:c.trim().substring(0,100),href:a.getAttribute("href"),id:a.id,className:a.className,role:a.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 a=r.target,c=new FormData(a),x={};c.forEach((E,b)=>{x[b]=E.toString()}),this.logEvent("formSubmission",{formId:a.id,action:a.action,method:a.method,fields:Object.keys(x),fieldCount:Object.keys(x).length,timestamp:new Date().toISOString()}).catch(E=>console.warn("Failed to track form submission:",E))}),o.inputs!==!1){let r;document.addEventListener("input",a=>{let c=a.target;(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.tagName==="SELECT")&&(clearTimeout(r),r=setTimeout(()=>{var x;this.logEvent("fieldChange",{element:c.tagName,type:c.getAttribute("type"),name:c.getAttribute("name"),id:c.id,valueLength:((x=c.value)==null?void 0:x.length)||0,timestamp:new Date().toISOString()}).catch(E=>console.warn("Failed to track field change:",E))},1e3))})}let t=Date.now();window.addEventListener("beforeunload",()=>{let r=Date.now()-t;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:r,timestamp:new Date().toISOString()})}),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 a;this.logEvent("unhandledRejection",{reason:(a=r.reason)==null?void 0:a.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let r=window.performance.navigation,a=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:a.navigationStart,loadTime:a.loadEventEnd-a.navigationStart,domReady:a.domContentLoadedEventEnd-a.navigationStart,renderTime:a.loadEventEnd-a.domContentLoadedEventEnd,navigationType:r.type,redirectCount:r.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(window.addEventListener("online",()=>{console.log("EventTracker: Back online, flushing queued events")}),window.addEventListener("offline",()=>{console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){this.flushTimer&&clearInterval(this.flushTimer)}},et=new Qe;typeof window!="undefined"&&(window.EventTracker=et);var me=require("react");var Yo=yn(require("axios"));var Go,Sn=(Go=C.getSdkAuthToken())!=null?Go:"",Tn=6e4;function vn(){var e;return(e=C.getSdkAuthToken())!=null?e:""}function Dn(){var o,t,l,r;let e=Yo.default.create({baseURL:$,headers:{"Content-Type":"application/json",Accept:"application/json","x-tenant-id":(t=(o=C.getCredentials())==null?void 0:o.tenantId)!=null?t:"","x-api-key":(r=(l=C.getCredentials())==null?void 0:l.apiKey)!=null?r:"",Authorization:`${Sn}`},timeout:Tn,withCredentials:!1});return e.interceptors.request.use(a=>{let c=vn();return c&&a.headers&&(a.headers.Authorization=`${c}`),a.metadata={startTime:new Date().getTime()},a},a=>(console.error("Request interceptor error:",a),Promise.reject(a))),e.interceptors.response.use(a=>{var E;let c=new Date().getTime(),x=(E=a.config.metadata)==null?void 0:E.startTime;return x&&console.log(`Request to ${a.config.url} took ${c-x}ms`),a},async a=>{var x;let c=a.config;return((x=a.response)==null?void 0:x.status)===401&&!c._retry&&(C.setInitCheck(),console.warn("Unauthorized request, attempting retry...")),a.response||(console.error("Network error:",a.message),a.message="Network error: Please check your internet connection"),a.response&&a.response.status>=500&&(console.error("Server error:",a.response.status,a.response.data),a.message="Server error: Please try again later"),Promise.reject(a)}),e}var Ln=Dn(),oe=Ln;var jo=()=>{let[e,o]=(0,me.useState)(!1),[t,l]=(0,me.useState)(!1),[r,a]=(0,me.useState)(!1),[c,x]=(0,me.useState)(null),[E,b]=(0,me.useState)(null);return{logout:(0,me.useCallback)(async()=>{var y;let u=JSON.parse((y=localStorage.getItem(fe))!=null?y:"");o(!0);let g={action:"LOGOUTUSER",userId:u.agentId||""};return oe.post(R.LOGOUT,g).then(m=>(C.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),b(m==null?void 0:m.data),l(!0),m==null?void 0:m.data)).catch(m=>{var h;return a(!0),x(m),(h=m==null?void 0:m.response)==null?void 0:h.data}).finally(()=>{o(!1)})},[]),isLoading:e,isSuccess:t,isError:r,error:c,data:E}};var xe=require("react");var Xo=()=>{let[e,o]=(0,xe.useState)(!1),[t,l]=(0,xe.useState)(!1),[r,a]=(0,xe.useState)(!1),[c,x]=(0,xe.useState)(null),[E,b]=(0,xe.useState)(null);return{handleEndCall:(0,xe.useCallback)(async u=>{var m,h,N,U,H,M,q,te,K,O,T,D,ne,se,I;let g=JSON.parse((m=localStorage.getItem(fe))!=null?m:"");o(!0);let y={action:"ENDCALL",userId:g==null?void 0:g.agentId,processid:(U=(N=(h=g==null?void 0:g.process)==null?void 0:h.process_id)==null?void 0:N.toString())!=null?U:"",process_name:(M=(H=g==null?void 0:g.process)==null?void 0:H.process_name)!=null?M:"",callreferenceid:(te=(q=g==null?void 0:g.callData)==null?void 0:q.convox_id)!=null?te:"",mobile_number:(O=(K=g==null?void 0:g.callData)==null?void 0:K.phone_number)!=null?O:"",disposition:(T=u==null?void 0:u.disposition)!=null?T:"RES",set_followUp:(D=u==null?void 0:u.followUp)!=null?D:"N",callback_date:(ne=u==null?void 0:u.callbackDate)!=null?ne:"",callback_hrs:(se=u==null?void 0:u.callbackHrs)!=null?se:"",callback_mins:(I=u==null?void 0:u.callbackMins)!=null?I:"",endcall_type:"CLOSE"};return oe.post(R.END_CALL,y).then(v=>(C.endCall(),b(v==null?void 0:v.data),l(!0),v==null?void 0:v.data)).catch(v=>{var P;return a(!0),x(v),(P=v==null?void 0:v.response)==null?void 0:P.data}).finally(()=>{o(!1)})},[]),isLoading:e,isSuccess:t,isError:r,error:c,data:E}};var Ce=require("react");var Jo=()=>{let[e,o]=(0,Ce.useState)(!1),[t,l]=(0,Ce.useState)(!1),[r,a]=(0,Ce.useState)(!1),[c,x]=(0,Ce.useState)(null),[E,b]=(0,Ce.useState)(null);return{handleStartCall:(0,Ce.useCallback)(async u=>{var y,m,h,N,U,H,M,q,te;let g=JSON.parse((y=localStorage.getItem(fe))!=null?y:"");if(o(!0),((m=g==null?void 0:g.callData)==null?void 0:m.status)==="IDLE"){let K={action:"CALL",userId:g==null?void 0:g.agentId,phone_number:u==null?void 0:u.mobileNumber};return oe.post(R.CLICK_TO_CALL,K).then(O=>(b(O==null?void 0:O.data),l(!0),O==null?void 0:O.data)).catch(O=>{var T;return a(!0),x(O),(T=O==null?void 0:O.response)==null?void 0:T.data}).finally(()=>{o(!1)})}else if(((h=g==null?void 0:g.callData)==null?void 0:h.status)==="ONCALL"){let K=(U=(N=g==null?void 0:g.conferenceLine)==null?void 0:N.filter(T=>T.line!==1))==null?void 0:U.find(T=>T.status==="IDLE"&&!(T!=null&&T.isCallStart)),O={action:"EXTERNAL_CONFERENCE",operation:`CALL${K.line}`,line_used:String(K.line),thirdparty_no:u==null?void 0:u.mobileNumber,userid:(M=(H=g.callData)==null?void 0:H.agent_id)!=null?M:"",process:(te=(q=g.callData)==null?void 0:q.process_name)!=null?te:""};return oe.post(R.CONFERENCE_CALL,O).then(T=>(b(T==null?void 0:T.data),l(!0),C.setConferenceLine(W(d({},K),{isCallStart:!0,status:"ONCALL",phone:u==null?void 0:u.mobileNumber})),C.setOpenConferenceDialog(!0),T==null?void 0:T.data)).catch(T=>{var D;return a(!0),x(T),(D=T==null?void 0:T.response)==null?void 0:D.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:e,isSuccess:t,isError:r,error:c,data:E}};var Ke=require("react");var Vo=()=>{let{process_id:e,process_name:o,status:t,phone_number:l,agent_id:r,convox_id:a}=C.getState().callData,c={phone_number:l,status:t,callReferenceId:a,agent_id:r,process_id:e,process_name:o},[x,E]=(0,Ke.useState)(c);return(0,Ke.useEffect)(()=>C.subscribe(()=>{let{process_id:w,process_name:u,status:g,phone_number:y,agent_id:m,convox_id:h}=C.getState().callData;E({phone_number:y,status:g,callReferenceId:h,agent_id:m,process_id:w,process_name:u})}),[]),x};var We=require("react");var Zo=()=>{let[e,o]=(0,We.useState)(C.getSdkAuthToken());return(0,We.useEffect)(()=>C.subscribe(()=>{o(C.getSdkAuthToken())}),[]),e};var Je=require("react");var L=require("@mui/icons-material"),f=require("@mui/material"),ee=require("react");var re=require("react");function tt(e,o){let[t,l]=(0,re.useState)(e),[r,a]=(0,re.useState)(!1),c=(0,re.useRef)(),x=(0,re.useRef)({x:0,y:0}),E=(0,re.useRef)({x:0,y:0}),b=(0,re.useCallback)(y=>{let m=c.current;if(!m)return;let h=m.getBoundingClientRect(),N=window.innerWidth,U=window.innerHeight,H={x:Math.max(0,Math.min(y.x,N-h.width)),y:Math.max(0,Math.min(y.y,U-h.height))};l(H),o==null||o(H)},[o]),w=(0,re.useCallback)((y,m)=>{a(!0),x.current={x:y,y:m},E.current=t;let h=(M,q)=>{let te=M-x.current.x,K=q-x.current.y;b({x:E.current.x+te,y:E.current.y+K})},N=M=>{M.preventDefault(),h(M.clientX,M.clientY)},U=M=>{M.preventDefault();let q=M.touches[0];q&&h(q.clientX,q.clientY)},H=()=>{a(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",H),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",H)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",H),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",H)},[t,b]),u=(0,re.useCallback)(y=>{y.preventDefault(),w(y.clientX,y.clientY)},[w]),g=(0,re.useCallback)(y=>{y.preventDefault();let m=y.touches[0];m&&w(m.clientX,m.clientY)},[w]);return{position:t,isDragging:r,dragRef:c,handleMouseDown:u,handleTouchStart:g}}var Ge=require("react");function he(){let[e,o]=(0,Ge.useState)(C.getState());return(0,Ge.useEffect)(()=>C.subscribe(()=>{o(C.getState())}),[]),e}var je=require("react");var be=require("react"),Ye=require("@mui/material"),Re=require("react/jsx-runtime"),Qo=(0,be.createContext)(void 0),Ee=()=>{let e=(0,be.useContext)(Qo);if(!e)throw new Error("useToast must be used inside ToastProvider");return e},en=({children:e})=>{let[o,t]=(0,be.useState)(!1),[l,r]=(0,be.useState)(""),[a,c]=(0,be.useState)("info"),x=(E,b="info")=>{r(E),c(b),t(!0)};return(0,Re.jsxs)(Qo.Provider,{value:{showToast:x},children:[e,(0,Re.jsx)(Ye.Snackbar,{open:o,color:a,autoHideDuration:3e3,onClose:()=>t(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,Re.jsx)(Ye.Alert,{variant:"filled",severity:a,onClose:()=>t(!1),sx:{width:"100%"},children:l})})]})};var _n={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},In=(e,o)=>{if(o.type==="isLoading")return W(d({},e),{isLoading:o.payload});if(o.type==="isSuccess")return W(d({},e),{isSuccess:!0,data:o.payload});if(o.type==="isError")return W(d({},e),{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=(e={})=>{let{onSuccess:o=null,onError:t=null,disabledSuccessToast:l=!1}=e,{showToast:r}=Ee(),[a,c]=(0,je.useReducer)(In,_n);return[(0,je.useCallback)((E,b,w={})=>{c({type:"isLoading",payload:!0}),oe.post(E,b,w).then(u=>{var g,y;c({type:"isSuccess",payload:u.data}),o==null||o(u.data,b),console.log((g=u.data)==null?void 0:g.message,"res45"),l||r((y=u.data)==null?void 0:y.message,"success")}).catch(u=>{var y,m,h,N,U,H,M,q,te,K,O,T;let g={status:(m=(y=u.response)==null?void 0:y.status)!=null?m:500,message:((N=(h=u.response)==null?void 0:h.data)==null?void 0:N.detail)||((H=(U=u.response)==null?void 0:U.data)==null?void 0:H.message)||u.message||"An unknown error occurred",data:(q=(M=u.response)==null?void 0:M.data)!=null?q:null,statusText:(K=(te=u.response)==null?void 0:te.statusText)!=null?K:"",code:(O=u==null?void 0:u.code)!=null?O:"",name:(T=u==null?void 0:u.name)!=null?T:""};r(g.message,"error"),c({type:"isError",payload:g}),t==null||t(g,b)}).finally(()=>{c({type:"isLoading",payload:!1})})},[o,t,r]),a]};var A=require("@mui/icons-material"),s=require("@mui/material"),pe=require("react");var tn=require("@mui/material");var Rn=({disabled:e,enabled:o,outlined:t})=>{let l=(0,tn.useTheme)();return{disabled:d({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 ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},e),enabled:d({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${l.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},o),outlined:d({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:l.palette.grey[200],boxShadow:`0px 2px 1px ${l.palette.primary.light}`,border:`0px solid ${l.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${l.palette.primary.main}`,border:`0px solid ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},t)}},Xe=Rn;var n=require("react/jsx-runtime"),An=({each:e})=>{var O,T,D,ne,se;let o=he(),{showToast:t}=Ee(),{disabled:l,enabled:r,outlined:a}=Xe({disabled:((O=o.sdkConfig)==null?void 0:O.disabled)||{},enabled:((T=o.sdkConfig)==null?void 0:T.enabled)||{},outlined:((D=o.sdkConfig)==null?void 0:D.outlined)||{}}),c=(0,s.useTheme)(),[x,E]=(0,pe.useState)(!1),[b,w]=(0,pe.useState)(!1),[u,g]=(0,pe.useState)(!1),[y,m]=(0,pe.useState)(!1),[h,N]=(0,pe.useState)(!1),U=(I,v)=>{C.setConferenceLine(d(d({},I),v))},H=(I,v)=>{var j,z,J,V;let P=d(d({},I),v);E(!0);let Y={action:"EXTERNAL_CONFERENCE",operation:`CALL${P.line}`,line_used:String(P.line),thirdparty_no:P.phone,userid:(z=(j=o.callData)==null?void 0:j.agent_id)!=null?z:"",process:(V=(J=o.callData)==null?void 0:J.process_name)!=null?V:""};oe.post(R.CONFERENCE_CALL,Y).then(k=>{var _;t((_=k.data)==null?void 0:_.message,"success"),C.setConferenceLine(d(d({},I),v))}).catch(k=>{var F,Z,Q,X;let _=((Z=(F=k.response)==null?void 0:F.data)==null?void 0:Z.detail)||((X=(Q=k.response)==null?void 0:Q.data)==null?void 0:X.message)||k.message||"An unknown error occurred";t(_,"error")}).finally(()=>{E(!1)})},M=(I,v)=>{var j,z,J,V;let P=d(d({},I),v);w(!0);let Y={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(P.line),thirdparty_no:P.phone,userid:(z=(j=o.callData)==null?void 0:j.agent_id)!=null?z:"",process:(V=(J=o.callData)==null?void 0:J.process_name)!=null?V:""};oe.post(R.CONFERENCE_CALL,Y).then(k=>{var _;t((_=k.data)==null?void 0:_.message,"success"),C.setConferenceLine(d(d({},I),v))}).catch(k=>{var F,Z,Q,X;let _=((Z=(F=k.response)==null?void 0:F.data)==null?void 0:Z.detail)||((X=(Q=k.response)==null?void 0:Q.data)==null?void 0:X.message)||k.message||"An unknown error occurred";t(_,"error")}).finally(()=>{w(!1)})},q=(I,v,P)=>{var z,J,V,k;let Y=d(d({},I),v);g(!0);let j={action:"EXTERNAL_CONFERENCE",operation:P,hold_channel_no:P==="HOLDUSER"?`hold${Y.line}`:`unhold${Y.line}`,userid:(J=(z=o.callData)==null?void 0:z.agent_id)!=null?J:"",process:(k=(V=o.callData)==null?void 0:V.process_name)!=null?k:""};oe.post(R.CONFERENCE_CALL_HOLD_OR_UN_HOLD,j).then(_=>{var F;t((F=_.data)==null?void 0:F.message,"success"),C.setConferenceLine(d(d({},I),v))}).catch(_=>{var Z,Q,X,de;let F=((Q=(Z=_.response)==null?void 0:Z.data)==null?void 0:Q.detail)||((de=(X=_.response)==null?void 0:X.data)==null?void 0:de.message)||_.message||"An unknown error occurred";t(F,"error")}).finally(()=>{g(!1)})},te=(I,v,P)=>{var z,J,V,k;let Y=d(d({},I),v);m(!0);let j={action:"EXTERNAL_CONFERENCE",operation:P,channel_no:P==="MUTEUSER"?`mute${Y.line}`:`play${Y.line}`,userid:(J=(z=o.callData)==null?void 0:z.agent_id)!=null?J:"",thirdparty_no:Y.phone,process:(k=(V=o.callData)==null?void 0:V.process_name)!=null?k:""};oe.post(R.CONFERENCE_CALL_MUTE_OT_UN_MUTE,j).then(_=>{var F;t((F=_.data)==null?void 0:F.message,"success"),C.setConferenceLine(d(d({},I),v))}).catch(_=>{var Z,Q,X,de;let F=((Q=(Z=_.response)==null?void 0:Z.data)==null?void 0:Q.detail)||((de=(X=_.response)==null?void 0:X.data)==null?void 0:de.message)||_.message||"An unknown error occurred";t(F,"error")}).finally(()=>{m(!1)})},K=(I,v)=>{var j,z,J,V;let P=d(d({},I),v);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:(z=(j=o.callData)==null?void 0:j.agent_id)!=null?z:"",process:(V=(J=o.callData)==null?void 0:J.process_name)!=null?V:""};oe.post(R.CONFERENCE_CALL_END,Y).then(k=>{var _;t((_=k.data)==null?void 0:_.message,"success"),C.setConferenceLine(d(d({},I),v))}).catch(k=>{var F,Z,Q,X;let _=((Z=(F=k.response)==null?void 0:F.data)==null?void 0:Z.detail)||((X=(Q=k.response)==null?void 0:Q.data)==null?void 0:X.message)||k.message||"An unknown error occurred";t(_,"error")}).finally(()=>{N(!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=e==null?void 0:e.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=e==null?void 0:e.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:(e==null?void 0:e.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:(e==null?void 0:e.phone)||"",disabled:(e==null?void 0:e.line)===1||(e==null?void 0:e.status)==="ONCALL"||(e==null?void 0:e.status)==="DISCONNECTED"||(e==null?void 0:e.status)==="CONFERENCE",onChange:I=>{U(e,{phone:I.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:[e.line!==1&&(0,n.jsx)(s.Tooltip,{title:"Call",children:(0,n.jsx)(s.Button,{variant:(e==null?void 0:e.status)!=="IDLE"?"outlined":"contained",color:"success",sx:(e==null?void 0:e.status)!=="IDLE"?d({},l):W(d({},r),{border:`0px solid ${c.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${c.palette.success.light}`,border:`0px solid ${c.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${c.palette.primary.light}`}}),onClick:()=>{H(e,{})},disabled:(e==null?void 0:e.status)!=="IDLE",children:x?(0,n.jsx)(s.CircularProgress,{size:"20px",color:"success"}):(0,n.jsx)(A.Call,{sx:{color:(e==null?void 0:e.status)!=="IDLE"?"default":"#f3f2f2"}})})}),e.line===1&&(0,n.jsx)(s.Tooltip,{title:"Merge Call",children:(0,n.jsxs)(s.Button,{variant:e!=null&&e.isMergeCall&&(e==null?void 0:e.status)==="ONCALL"?"contained":"outlined",sx:e!=null&&e.isMergeCall&&(e==null?void 0:e.status)==="ONCALL"?W(d({},l),{padding:"0px 16px"}):(e==null?void 0:e.status)==="ONCALL"?W(d({},a),{padding:"0px 16px"}):W(d({},l),{padding:"0px 16px"}),onClick:()=>{M(e,{isMergeCall:!0})},disabled:(e==null?void 0:e.status)!=="ONCALL"||b,children:[e!=null&&e.isMergeCall?"Merged":"Merge",b?(0,n.jsx)(s.CircularProgress,{size:"20px"}):(0,n.jsx)(A.CallSplit,{})]})}),(0,n.jsx)(s.Tooltip,{title:e.isHold?"Hold":"Un Hold",children:(0,n.jsx)(s.Button,{variant:e!=null&&e.isHold?"contained":"outlined",sx:e!=null&&e.isHold&&(e==null?void 0:e.status)==="ONCALL"||(e==null?void 0:e.status)==="CONFERENCE"?d({},l):(e==null?void 0:e.status)==="ONCALL"||(e==null?void 0:e.status)==="CONFERENCE"?d({},a):d({},l),onClick:()=>{e.isHold?q(e,{isHold:!1},"UNHOLDUSER"):q(e,{isHold:!0},"HOLDUSER")},disabled:(e==null?void 0:e.status)!=="ONCALL"&&(e==null?void 0:e.status)!=="CONFERENCE"||u,children:u?(0,n.jsx)(s.CircularProgress,{size:"20px",sx:{color:c.palette.primary.main}}):e.isHold?(0,n.jsx)(A.PlayArrow,{}):(0,n.jsx)(A.Pause,{})})}),(0,n.jsx)(s.Tooltip,{title:e.isMute?"Mute":"Un Mute",children:(0,n.jsx)(s.Button,{variant:e!=null&&e.isMute?"contained":"outlined",sx:e!=null&&e.isMute&&(e==null?void 0:e.status)==="ONCALL"||(e==null?void 0:e.status)==="CONFERENCE"?d({},l):(e==null?void 0:e.status)==="ONCALL"||(e==null?void 0:e.status)==="CONFERENCE"?d({},a):d({},l),onClick:()=>{e.isMute?te(e,{isMute:!1},"PLAYUSER"):te(e,{isMute:!0},"MUTEUSER")},disabled:(e==null?void 0:e.status)!=="ONCALL"&&(e==null?void 0:e.status)!=="CONFERENCE"||y,children:y?(0,n.jsx)(s.CircularProgress,{size:"20px",sx:{color:c.palette.primary.main}}):e.isMute?(0,n.jsx)(A.MicOff,{}):(0,n.jsx)(A.Mic,{})})}),(e==null?void 0:e.line)!==1?(0,n.jsx)(s.Tooltip,{title:"End Call",children:(0,n.jsx)(s.Button,{variant:(e==null?void 0:e.status)==="ONCALL"||(e==null?void 0:e.status)==="CONFERENCE"||(e==null?void 0:e.status)==="DIALING"?"contained":"outlined",color:"error",sx:(e==null?void 0:e.status)==="ONCALL"||(e==null?void 0:e.status)==="CONFERENCE"||(e==null?void 0:e.status)==="DIALING"?W(d({},r),{border:`0px solid ${c.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${c.palette.error.light}`,border:`0px solid ${c.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${c.palette.primary.light}`}}):d({},l),onClick:()=>{K(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1})},disabled:(e==null?void 0:e.status)!=="ONCALL"&&(e==null?void 0:e.status)!=="CONFERENCE"&&(e==null?void 0:e.status)!=="DIALING"||h,children:h?(0,n.jsx)(s.CircularProgress,{size:"20px",color:"error"}):(0,n.jsx)(A.CallEnd,{})})}):(0,n.jsx)(s.Button,{variant:e!=null&&e.isCallStart?"contained":"outlined",color:"error",sx:{display:"none"},onClick:()=>{K(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1})},disabled:!(e!=null&&e.isCallStart)||h,children:h?(0,n.jsx)(s.CircularProgress,{size:"20px",color:"error"}):(0,n.jsx)(A.CallEnd,{})})]})})]},e.line)};function on(){var c;let e=he(),{showToast:o}=Ee(),[t,l]=(0,pe.useState)(!1),r=()=>{C.setOpenConferenceDialog(!1)},a=()=>{var E,b,w,u;l(!0);let x={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(b=(E=e.callData)==null?void 0:E.agent_id)!=null?b:"",process:(u=(w=e.callData)==null?void 0:w.process_name)!=null?u:""};oe.post(R.CONFERENCE_CALL_END_ALL,x).then(g=>{var y;o((y=g.data)==null?void 0:y.message,"success"),C.resetConferenceLines(),r()}).catch(g=>{var m,h,N,U;let y=((h=(m=g.response)==null?void 0:m.data)==null?void 0:h.detail)||((U=(N=g.response)==null?void 0:N.data)==null?void 0:U.message)||g.message||"An unknown error occurred";o(y,"error")}).finally(()=>{l(!1)})};return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:e.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:[(c=e==null?void 0:e.agentId)!=null?c:""," conference"]}),(0,n.jsx)(s.IconButton,{onClick:r,children:(0,n.jsx)(A.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:e==null?void 0:e.conferenceLine.map(x=>(0,n.jsx)(An,{each:x}))})]})})}),(0,n.jsx)(s.Box,{textAlign:"center",m:2,children:(0,n.jsxs)(s.Button,{variant:"outlined",color:"error",size:"large",onClick:a,disabled:t,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[t?(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)(A.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function nn({open:e}){var y,m,h,N,U,H,M,q,te,K,O,T;let o=he(),[t]=ce({onSuccess:()=>{C.setOpenCallTransferDialog(!1)}}),[l,r]=(0,pe.useState)("process"),[a,{data:c,isLoading:x}]=ce({disabledSuccessToast:!0}),[E,{data:b,isLoading:w}]=ce({disabledSuccessToast:!0}),u=()=>{C.setOpenCallTransferDialog(!1)},g=(D,ne)=>{var se,I,v,P,Y,j,z,J,V,k,_,F,Z,Q,X,de,Se,Ae,Te,we,Ne,ke,ve,Oe,Pe,Me,De,Ue,Be,He,ze,$e,qe;if(console.log(D,"data34"),ne==="PROCESS"){let ye={mobile_number:(I=(se=o.callData)==null?void 0:se.phone_number)!=null?I:"",userid:(P=(v=o.callData)==null?void 0:v.agent_id)!=null?P:"",type:"PROCESS",transfer_to:(Y=D==null?void 0:D.process_name)!=null?Y:"",callreferenceid:(z=(j=o.callData)==null?void 0:j.convox_id)!=null?z:"",processid:String((V=(J=o.callData)==null?void 0:J.process_id)!=null?V:""),process_name:(_=(k=o.callData)==null?void 0:k.process_name)!=null?_:""};t(R.TRANSFER_CALL,ye)}else if(ne==="QUEUE"){let ye={mobile_number:(Z=(F=o.callData)==null?void 0:F.phone_number)!=null?Z:"",userid:(X=(Q=o.callData)==null?void 0:Q.agent_id)!=null?X:"",type:"QUEUE",transfer_to:(de=D==null?void 0:D.queue_name)!=null?de:"",callreferenceid:(Ae=(Se=o.callData)==null?void 0:Se.convox_id)!=null?Ae:"",processid:String((we=(Te=o.callData)==null?void 0:Te.process_id)!=null?we:""),process_name:(ke=(Ne=o.callData)==null?void 0:Ne.process_name)!=null?ke:""};t(R.TRANSFER_CALL,ye)}else if(ne==="AGENT"){let ye={mobile_number:(Oe=(ve=o.callData)==null?void 0:ve.phone_number)!=null?Oe:"",userid:(Me=(Pe=o.callData)==null?void 0:Pe.agent_id)!=null?Me:"",type:"AGENT",transfer_to:(De=D==null?void 0:D.user_id)!=null?De:"",callreferenceid:(Be=(Ue=o.callData)==null?void 0:Ue.convox_id)!=null?Be:"",processid:String((ze=(He=o.callData)==null?void 0:He.process_id)!=null?ze:""),process_name:(qe=($e=o.callData)==null?void 0:$e.process_name)!=null?qe:""};t(R.TRANSFER_CALL,ye)}};return(0,pe.useEffect)(()=>{a(R.AGENTS_LIST,{status:"IDLE",active:!0}),E(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:e,"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:u,children:(0,n.jsx)(A.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:l==="process"?"contained":"outlined",onClick:()=>{r("process"),E(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Process"}),(0,n.jsx)(s.Button,{variant:l==="queues"?"contained":"outlined",onClick:()=>{r("queues"),E(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Queues"}),(0,n.jsx)(s.Button,{variant:l==="agents"?"contained":"outlined",onClick:()=>{r("agents"),a(R.AGENTS_LIST,{status:"IDLE",active:!0})},children:"Agents"})]}),(w||x)&&(0,n.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"80px"},children:[(0,n.jsx)(s.CircularProgress,{})," "]}),!w&&!x&&l==="process"&&(0,n.jsx)(s.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(y=b==null?void 0:b.data)!=null&&y.process&&((h=(m=b==null?void 0:b.data)==null?void 0:m.process)==null?void 0:h.length)>0?(U=(N=b==null?void 0:b.data)==null?void 0:N.process)==null?void 0:U.map((D,ne)=>(0,n.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",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)(A.SupportAgent,{sx:{marginRight:"4px"}}),D.process_name]}),(0,n.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(D,"PROCESS")},children:(0,n.jsx)(A.Call,{})})]},ne)):(0,n.jsx)(s.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"})}),!w&&!x&&l==="queues"&&(0,n.jsx)(s.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(H=b==null?void 0:b.data)!=null&&H.queue&&((q=(M=b==null?void 0:b.data)==null?void 0:M.queue)==null?void 0:q.length)>0?(K=(te=b==null?void 0:b.data)==null?void 0:te.queue)==null?void 0:K.map((D,ne)=>{var se,I,v,P,Y,j;return(0,n.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",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)(A.SupportAgent,{sx:{marginRight:"4px"}}),D.queue_name,(v=(I=(se=b==null?void 0:b.data)==null?void 0:se.process)==null?void 0:I.find(z=>z.process_id===D.process_id))!=null&&v.process_name?(0,n.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((j=(Y=(P=b==null?void 0:b.data)==null?void 0:P.process)==null?void 0:Y.find(z=>z.process_id===D.process_id))==null?void 0:j.process_name)+")"}):""]}),(0,n.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(D,"QUEUE")},children:(0,n.jsx)(A.Call,{})})]},ne)}):(0,n.jsx)(s.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"})}),!w&&!x&&l==="agents"&&(0,n.jsx)(s.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:c!=null&&c.data&&((O=c==null?void 0:c.data)==null?void 0:O.length)>0?(T=c==null?void 0:c.data)==null?void 0:T.map((D,ne)=>(0,n.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",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)(A.SupportAgent,{sx:{marginRight:"4px"}}),D.name]}),(0,n.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(D,"AGENT")},children:(0,n.jsx)(A.Call,{})})]},ne)):(0,n.jsx)(s.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 sn({open:e,setOpen:o,onSubmitDisposition:t}){var w,u,g,y;let[l,r]=(0,pe.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),a=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],c=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],x=(m,h)=>{r(N=>W(d({},N),{[m]:h}))},E=()=>{r({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},b=()=>{E(),o(!1)};return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:e,"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:l.disposition,options:a,getOptionLabel:m=>m.label,onChange:(m,h)=>x("disposition",h),size:"small",renderInput:m=>(0,n.jsx)(s.TextField,W(d({},m),{label:"Disposition",fullWidth:!0})),sx:{flex:1}}),(0,n.jsx)(s.Autocomplete,{options:c,getOptionLabel:m=>m.label,value:l.followUp,onChange:(m,h)=>x("followUp",h),size:"small",renderInput:m=>(0,n.jsx)(s.TextField,W(d({},m),{label:"Follow Up",fullWidth:!0})),sx:{flex:1}})]}),((u=(w=l==null?void 0:l.followUp)==null?void 0:w.label)==null?void 0:u.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:l.callbackDate,onChange:m=>x("callbackDate",m.target.value),fullWidth:!0,sx:{flex:1}}),(0,n.jsx)(s.TextField,{size:"small",label:"Hours (0-23)",type:"text",value:l.callbackHrs,onChange:m=>x("callbackHrs",m.target.value),fullWidth:!0,sx:{flex:1}})]}),((y=(g=l==null?void 0:l.followUp)==null?void 0:g.label)==null?void 0:y.toLowerCase())==="yes"&&(0,n.jsxs)(s.Box,{display:"flex",gap:2,mt:2,children:[(0,n.jsx)(s.TextField,{size:"small",label:"Minutes (0-59)",type:"text",value:l.callbackMins,onChange:m=>x("callbackMins",m.target.value),fullWidth:!0,sx:{flex:1}}),(0,n.jsx)(s.Box,{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:b,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),(0,n.jsx)(s.Button,{variant:"contained",color:"primary",size:"large",onClick:()=>t(l),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function an({open:e,setOpen:o,processList:t=null,handleSelectedProcessor:l}){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:e,"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:()=>{o(!1)},children:(0,n.jsx)(A.Close,{})})]}),(0,n.jsx)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:t.length>0?t==null?void 0:t.map((a,c)=>(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:()=>{l(a)},children:(0,n.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(A.SupportAgent,{sx:{marginRight:"4px"}}),a.process_name]})},c)):null})]})})})}function ln({open:e,setOpen:o}){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:e,"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)(A.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 p=require("react/jsx-runtime"),wn=(e,o,t)=>e.map(r=>{var a,c,x;if((r==null?void 0:r.line)===1)return{line:1,status:(a=t==null?void 0:t.status)!=null?a:"",type:"internal",phone:(c=t==null?void 0:t.phone_number)!=null?c:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};{let E=`line_${r.line}_status`,b=`line_${r.line}_phonenumber`;return W(d({},r),{status:(x=o[E])!=null?x:"IDLE",phone:o[b]!=="0"?o[b]:""})}}),Nn=e=>{let o=Math.floor(e/60),t=e%60;return`${o.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`};function rn({onDataChange:e}){var at,it,lt,rt,ct,pt,dt,ut,gt,ft,mt,xt,Ct,bt,yt,Et,ht,St,Tt,vt,Dt,Lt,_t,It,Rt,At,wt,Nt,kt,Ot,Pt,Mt,Ut,Bt,Ht,zt,$t,qt,Ft,Kt,Wt,Gt,Yt,jt,Xt,Jt,Vt,Zt,Qt,eo,to,oo,no,so,ao,io,lo,ro,co,po,uo,go,fo,mo,xo,Co,bo,yo,Eo,ho,So,To,vo,Do,Lo,_o,Io,Ro,Ao,wo,No;let o=(0,f.useTheme)(),t=he(),{showToast:l}=Ee(),{disabled:r,enabled:a,outlined:c}=Xe({disabled:((at=t.sdkConfig)==null?void 0:at.disabled)||{},enabled:((it=t.sdkConfig)==null?void 0:it.enabled)||{},outlined:((lt=t.sdkConfig)==null?void 0:lt.outlined)||{}}),x=(0,ee.useRef)(null),[E,b]=(0,ee.useState)(null),[w,u]=(0,ee.useState)(!0),[g,y]=(0,ee.useState)(null),[m,h]=(0,ee.useState)(null),[N,U]=(0,ee.useState)(!1),[H,M]=(0,ee.useState)(!1),[q,te]=(0,ee.useState)(!1),[K,O]=(0,ee.useState)(null),[T,D]=(0,ee.useState)(""),[ne,se]=(0,ee.useState)(0),{position:I,isDragging:v,dragRef:P,handleMouseDown:Y,handleTouchStart:j}=tt(t.controlPanelPosition,i=>C.setControlPanelPosition(i)),{position:z,isDragging:J,dragRef:V,handleMouseDown:k,handleTouchStart:_}=tt(t.iframePosition,i=>C.setIframePosition(i)),[F,{isLoading:Z}]=ce({onSuccess:()=>{D(""),h(null)}}),[Q,{isLoading:X}]=ce({onSuccess:()=>{C.setHolding(!t.isHolding)},onError:i=>{console.log("\u274C Hold operation error:",i)}}),[de,{isLoading:Se}]=ce({onSuccess:()=>{C.setMuted(!t.isMuted)},onError:i=>{console.log("\u274C Mute operation error:",i)}}),[Ae,{isLoading:Te}]=ce(),[we,{isLoading:Ne}]=ce(),[ke,{isLoading:ve}]=ce(),Oe=()=>{b(null)},Pe=i=>{u(!0),h(i.currentTarget),C.setStatus("dial")},Me=()=>{t.status!=="on call"&&C.setStatus("idle"),h(null)},De=i=>{y(i.currentTarget)},Ue=()=>{y(null)},Be=()=>{let i={action:"READYAGENT",userId:t.agentId};Ae(R.READY_AGENT,i)},He=i=>{y(null);let S={action:"AGENTBREAK",break_type:i,userId:t.agentId};we(R.UPDATE_AGENT_BREAK,S)},ze=i=>{if(i.length!==10)l("Invalid phone number","error");else if(!/^\d+$/.test(i))l("Invalid phone number","error");else{let S={action:"CALL",phone_number:i,userId:t.agentId};F(R.CLICK_TO_CALL,S)}},$e=()=>{let i={action:t.isHolding?"UNHOLD":"HOLD",userId:t.agentId};Q(R.HOLD_CALL,i)},qe=()=>{let i={action:t.isMuted?"UNMUTE":"MUTE",userId:t.agentId};de(R.MUTE_CALL,i)},ye=i=>{var B,ae,ie,ue,ge,Le,_e,ko,Oo,Po,Mo,Uo,Bo,Ho,zo,$o;console.log("data",i);let S={action:"ENDCALL",userId:t.agentId,processid:(ie=(ae=(B=t.process)==null?void 0:B.process_id)==null?void 0:ae.toString())!=null?ie:"",process_name:(ge=(ue=t.process)==null?void 0:ue.process_name)!=null?ge:"",callreferenceid:(_e=(Le=t.callData)==null?void 0:Le.convox_id)!=null?_e:"",mobile_number:(Oo=(ko=t.callData)==null?void 0:ko.phone_number)!=null?Oo:"",disposition:(Mo=(Po=i==null?void 0:i.disposition)==null?void 0:Po.value)!=null?Mo:"",set_followUp:(Bo=(Uo=i==null?void 0:i.followUp)==null?void 0:Uo.value)!=null?Bo:"",callback_date:(Ho=i==null?void 0:i.callbackDate)!=null?Ho:"",callback_hrs:(zo=i==null?void 0:i.callbackHrs)!=null?zo:"",callback_mins:($o=i==null?void 0:i.callbackMins)!=null?$o:"",endcall_type:"CLOSE"};D(""),ke(R.END_CALL,S),C.endCall(),U(!1)};return(0,ee.useEffect)(()=>{let i=S=>{S.preventDefault()};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i)}},[]),(0,ee.useEffect)(()=>{let i;return t.callData.status&&t.callData.status==="ONCALL"?i=setInterval(()=>{let S=Math.floor((Date.now()-t.callStartTime)/1e3);se(S)},1e3):se(0),()=>{i&&clearInterval(i)}},[t.callData.status]),(0,ee.useEffect)(()=>{if(e&&t.callData){let{process_id:i,process_name:S,status:B,phone_number:ae,agent_id:ie,convox_id:ue}=t.callData;e({phone_number:ae,status:B,callReferenceId:ue,agent_id:ie,process_id:i,process_name:S})}},[t.callData,e]),(0,ee.useEffect)(()=>{t.agentId?oe.post(R.PROCESS_LIST,{userId:t.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}).then(i=>{var S,B;console.log(i.data.data,"res4"),i&&i.data&&((S=i==null?void 0:i.data)==null?void 0:S.length)>1?(O(i.data.data),M(!0)):(C.setProcess((B=i==null?void 0:i.data)==null?void 0:B.data[0]),M(!1))}).catch(i=>{l(i.response.data.message,"error")}):console.log("No agentId available, skipping API call")},[t.agentId]),(0,ee.useEffect)(()=>(t.agentId&&(x.current=new WebSocket(`${Wo.WS}?agent_id=${t.agentId}`),x.current.onopen=()=>{console.log("\u{1F310} WebSocket connection established")},x.current.onmessage=i=>{try{let S=JSON.parse(i.data),B=wn(t==null?void 0:t.conferenceLine,S==null?void 0:S.conferencestatus,S);console.log(B,"\u{1F4CA} Parsed JSON:",S),C.updateCallData(S),C.updateConferenceData([...B]),S.status==="ONCALL"&&(C.startCall(),w||u(!0)),S.status==="WRAPUP"&&C.endCall()}catch(S){console.log("\u{1F4E8} Raw message:",i.data)}},x.current.onclose=()=>{console.log("\u{1F50C} WebSocket connection closed")},x.current.onerror=i=>{console.error("\u274C WebSocket error:",i)}),()=>{var i;(i=x.current)==null||i.close()}),[t.agentId]),!t.isInitialized||!t.process?(0,p.jsx)(f.Box,{children:!!H&&(0,p.jsx)(an,{processList:K,open:H,setOpen:M,handleSelectedProcessor:i=>{C.setProcess(i)}})}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(f.Box,{children:(0,p.jsx)(f.Fade,{in:!0,timeout:300,children:(0,p.jsx)(f.Paper,{ref:(rt=t.sdkConfig)!=null&&rt.isDraggable?P:null,elevation:v?4:(ct=t.sdkConfig)!=null&&ct.isDraggable?1:0,sx:{position:(pt=t.sdkConfig)!=null&&pt.isDraggable?"fixed":"relative",left:(dt=t.sdkConfig)!=null&&dt.isDraggable?I.x:"auto",top:(ut=t.sdkConfig)!=null&&ut.isDraggable?I.y:"auto",display:"inline-block",width:"auto",flexShrink:0,whiteSpace:"nowrap",p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:(gt=t.sdkConfig)!=null&&gt.isDraggable?Number.MAX_SAFE_INTEGER:0,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),userSelect:"none"},children:(0,p.jsxs)(f.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,p.jsxs)(f.Box,{sx:{display:"flex",alignItems:"center",gap:1,margin:"0px 10px"},children:[((ft=t.sdkConfig)==null?void 0:ft.isDraggable)&&(0,p.jsxs)(f.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:Y,onTouchStart:j,children:[(0,p.jsx)(L.DragIndicator,{})," "]}),(0,p.jsx)(f.Box,{children:!((mt=t.sdkConfig)!=null&&mt.disabledDialButton)&&(0,p.jsx)(f.Tooltip,{title:"Dial",children:(0,p.jsx)(f.IconButton,{size:"small",onClick:i=>{var S,B,ae,ie,ue,ge,Le,_e;((B=(S=t.callData)==null?void 0:S.status)==null?void 0:B.toUpperCase())!=="ONCALL"&&((ie=(ae=t.callData)==null?void 0:ae.status)==null?void 0:ie.toUpperCase())!=="BREAK"&&((ge=(ue=t.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())!=="RINGING"&&((_e=(Le=t.callData)==null?void 0:Le.status)==null?void 0:_e.toUpperCase())!=="WRAPUP"&&Pe(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,p.jsx)(L.WifiCalling3,{sx:{color:((Ct=(xt=t.callData)==null?void 0:xt.status)==null?void 0:Ct.toUpperCase())==="ONCALL"||((yt=(bt=t.callData)==null?void 0:bt.status)==null?void 0:yt.toUpperCase())==="BREAK"||((ht=(Et=t.callData)==null?void 0:Et.status)==null?void 0:ht.toUpperCase())==="RINGING"||((Tt=(St=t.callData)==null?void 0:St.status)==null?void 0:Tt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,p.jsx)(f.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px",fontSize:"18px",fontWeight:"600"},children:Nn(ne)}),(0,p.jsx)(f.Chip,{sx:{padding:"18px 0px"},label:Ne||Te?(0,p.jsx)(f.Box,{sx:{fontWeight:"bold",width:"60px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,p.jsx)(f.CircularProgress,{size:"20px"})}):(0,p.jsx)(f.Typography,{variant:"body2",sx:{fontWeight:"bold",width:"60px",textAlign:"center"},children:(Lt=(Dt=(vt=t.callData)==null?void 0:vt.status)==null?void 0:Dt.toUpperCase())!=null?Lt:"N/A"}),onClick:De,deleteIcon:(0,p.jsx)(L.KeyboardArrowDown,{color:"primary"}),onDelete:De})]}),(0,p.jsxs)(f.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,p.jsx)(f.Tooltip,{title:"Agent Ready",children:(0,p.jsx)(f.Button,{variant:((It=(_t=t.callData)==null?void 0:_t.status)==null?void 0:It.toUpperCase())==="BREAK"||((At=(Rt=t.callData)==null?void 0:Rt.status)==null?void 0:At.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var S,B,ae,ie;(((B=(S=t.callData)==null?void 0:S.status)==null?void 0:B.toUpperCase())==="BREAK"||((ie=(ae=t.callData)==null?void 0:ae.status)==null?void 0:ie.toUpperCase())==="MISSED")&&(i.stopPropagation(),Be())},classes:{root:((Nt=(wt=t.callData)==null?void 0:wt.status)==null?void 0:Nt.toUpperCase())==="BREAK"||((Ot=(kt=t.callData)==null?void 0:kt.status)==null?void 0:Ot.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:d({},((Mt=(Pt=t.callData)==null?void 0:Pt.status)==null?void 0:Mt.toUpperCase())==="BREAK"||((Bt=(Ut=t.callData)==null?void 0:Ut.status)==null?void 0:Bt.toUpperCase())==="MISSED"?c:a),disabled:Te,children:(0,p.jsx)(L.SupportAgent,{})})}),(0,p.jsx)(f.Tooltip,{title:t.isHolding?"Resume":"Hold",children:(0,p.jsx)(f.Button,{variant:t.isHolding&&((zt=(Ht=t.callData)==null?void 0:Ht.status)==null?void 0:zt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),$e()},sx:t.isHolding&&((qt=($t=t.callData)==null?void 0:$t.status)==null?void 0:qt.toUpperCase())==="ONCALL"?d({},a):((Kt=(Ft=t.callData)==null?void 0:Ft.status)==null?void 0:Kt.toUpperCase())==="ONCALL"?d({},c):d({},r),disabled:((Gt=(Wt=t.callData)==null?void 0:Wt.status)==null?void 0:Gt.toUpperCase())!=="ONCALL"&&!t.isHolding||X,children:X?(0,p.jsx)(f.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):t.isHolding?(0,p.jsx)(L.PlayArrow,{}):(0,p.jsx)(L.Pause,{})})}),(0,p.jsx)(f.Tooltip,{title:t.isMuted?"Unmute":"Mute",children:(0,p.jsx)(f.Button,{variant:t.isMuted&&((jt=(Yt=t.callData)==null?void 0:Yt.status)==null?void 0:jt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),qe()},sx:t.isMuted&&((Jt=(Xt=t.callData)==null?void 0:Xt.status)==null?void 0:Jt.toUpperCase())==="ONCALL"?d({},a):((Zt=(Vt=t.callData)==null?void 0:Vt.status)==null?void 0:Zt.toUpperCase())==="ONCALL"?d({},c):d({},r),disabled:((eo=(Qt=t.callData)==null?void 0:Qt.status)==null?void 0:eo.toUpperCase())!=="ONCALL"&&!t.isMuted||Se,children:Se?(0,p.jsx)(f.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):t.isMuted?(0,p.jsx)(L.MicOff,{}):(0,p.jsx)(L.Mic,{})})}),!((to=t.sdkConfig)!=null&&to.disableCallTransferButton)&&(0,p.jsx)(f.Tooltip,{title:"Transfer Call",children:(0,p.jsx)(f.Button,{variant:t.openCallTransferDialog?"contained":"outlined",onClick:i=>{var S,B;((B=(S=t.callData)==null?void 0:S.status)==null?void 0:B.toUpperCase())==="ONCALL"&&(i.stopPropagation(),C.setOpenCallTransferDialog(!0))},sx:t.openCallTransferDialog?d({},a):((no=(oo=t.callData)==null?void 0:oo.status)==null?void 0:no.toUpperCase())==="ONCALL"?d({},c):d({},r),disabled:((ao=(so=t.callData)==null?void 0:so.status)==null?void 0:ao.toUpperCase())!=="ONCALL",children:(0,p.jsx)(L.TransferWithinAStation,{})})}),!((io=t.sdkConfig)!=null&&io.disableConferenceButton)&&(0,p.jsx)(f.Tooltip,{title:"Conference Call",children:(0,p.jsx)(f.Button,{variant:t.openConferenceDialog?"contained":"outlined",onClick:i=>{var S,B;((B=(S=t.callData)==null?void 0:S.status)==null?void 0:B.toUpperCase())==="ONCALL"&&(i.stopPropagation(),C.setOpenConferenceDialog(!0))},sx:t.openConferenceDialog?d({},a):((ro=(lo=t.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())==="ONCALL"?d({},c):d({},r),disabled:((po=(co=t.callData)==null?void 0:co.status)==null?void 0:po.toUpperCase())!=="ONCALL",children:(0,p.jsx)(L.Group,{})})}),!((uo=t.sdkConfig)!=null&&uo.disableEndCallButton)&&(0,p.jsx)(f.Tooltip,{title:"End Call",children:(0,p.jsx)(f.Button,{variant:((fo=(go=t.callData)==null?void 0:go.status)==null?void 0:fo.toUpperCase())==="ONCALL"||((xo=(mo=t.callData)==null?void 0:mo.status)==null?void 0:xo.toUpperCase())==="RINGING"||((bo=(Co=t.callData)==null?void 0:Co.status)==null?void 0:bo.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var S,B,ae,ie,ue,ge;(((B=(S=t.callData)==null?void 0:S.status)==null?void 0:B.toUpperCase())==="ONCALL"||((ie=(ae=t.callData)==null?void 0:ae.status)==null?void 0:ie.toUpperCase())==="RINGING"||((ge=(ue=t.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())==="WRAPUP")&&(i.stopPropagation(),U(!0))},sx:((Eo=(yo=t.callData)==null?void 0:yo.status)==null?void 0:Eo.toUpperCase())==="ONCALL"||((So=(ho=t.callData)==null?void 0:ho.status)==null?void 0:So.toUpperCase())==="RINGING"||((vo=(To=t.callData)==null?void 0:To.status)==null?void 0:vo.toUpperCase())==="WRAPUP"?W(d({},a),{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(d({},r),{minWidth:"60px !important"}),disabled:((Lo=(Do=t.callData)==null?void 0:Do.status)==null?void 0:Lo.toUpperCase())!=="ONCALL"&&((Io=(_o=t.callData)==null?void 0:_o.status)==null?void 0:Io.toUpperCase())!=="RINGING"&&((Ao=(Ro=t.callData)==null?void 0:Ro.status)==null?void 0:Ao.toUpperCase())!=="WRAPUP"||ve,children:ve?(0,p.jsx)(f.CircularProgress,{size:"20px",color:"error"}):(0,p.jsx)(L.CallEnd,{})})})]})]})})})}),(0,p.jsx)(f.Fade,{in:!0,timeout:300,children:(0,p.jsxs)(f.Paper,{ref:V,elevation:J?4:1,sx:{position:"absolute",left:z.x,top:z.y,borderRadius:2,bgcolor:"background.paper",zIndex:Number.MAX_SAFE_INTEGER,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),visibility:w&&!((wo=t.sdkConfig)!=null&&wo.disableSoftPhone)?"visible":"hidden",userSelect:"none"},children:[(0,p.jsxs)(f.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll",padding:"0px 10px"},onMouseDown:k,onTouchStart:_,children:[(0,p.jsx)(L.DragIndicator,{sx:{transform:"rotate(90deg)",color:"#7b7b7b"}})," ",(0,p.jsx)(f.IconButton,{onClick:()=>u(!1),children:(0,p.jsx)(L.Close,{})})]}),(0,p.jsx)(f.Box,{children:(0,p.jsx)("iframe",{src:`https://${Fe}/ConVoxCCS/iframe?agent_id=${t.agentId}&process_id=${(No=t.process)==null?void 0:No.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})})]})}),(0,p.jsx)(f.Menu,{anchorEl:m,open:!!m,onClose:Me,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,p.jsxs)(f.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,p.jsx)(f.TextField,{size:"small",value:T,placeholder:"Enter Mobile No.",onChange:i=>{D(i.target.value)}}),(0,p.jsx)(f.IconButton,{color:"info",onClick:()=>{ze(T)},children:Z?(0,p.jsx)(f.CircularProgress,{size:"20px",sx:{color:o.palette.success.main}}):(0,p.jsx)(L.Phone,{color:"success"})})]})}),(0,p.jsx)(f.Menu,{anchorEl:g,open:!!g,onClose:Ue,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,p.jsx)(f.MenuItem,{onClick:()=>He("Lunch"),children:"- Break"})}),(0,p.jsx)(f.Menu,{anchorEl:E,open:!!E,onClose:Oe,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,p.jsxs)(f.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,p.jsx)(f.Chip,{icon:(0,p.jsx)(L.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,p.jsx)(f.Chip,{icon:(0,p.jsx)(L.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,p.jsx)(f.Chip,{icon:(0,p.jsx)(L.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!t.openConferenceDialog&&(0,p.jsx)(on,{}),!!t.openCallTransferDialog&&(0,p.jsx)(nn,{open:t.openCallTransferDialog}),!!N&&(0,p.jsx)(sn,{open:N,setOpen:U,onSubmitDisposition:ye}),!!q&&(0,p.jsx)(ln,{open:q,setOpen:te})]})}var cn=require("react");var pn=require("react/jsx-runtime"),ot=(0,cn.memo)(({children:e})=>(0,pn.jsx)(en,{children:e}));ot.displayName="SDKProvider";var nt=require("react/jsx-runtime"),st=(0,Je.memo)(({onDataChange:e})=>{let o=(0,Je.useCallback)(t=>{try{e&&typeof e=="function"&&e(t)}catch(l){console.error("Error in CallControlPanel data change handler:",l)}},[e]);return(0,nt.jsx)(ot,{children:(0,nt.jsx)(rn,{onDataChange:o})})});st.displayName="CallControlPanel";async function kn({apiKey:e,tenantId:o,agentId:t,sdkConfig:l}){if(!e||typeof e!="string"||e.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(!t||typeof t!="string"||t.trim().length===0)throw new Error("SDK initialization failed: Agent ID is required and must be a non-empty string");try{let r=await et.init({apiKey:e.trim(),tenantId:o.trim(),agentId:t.trim(),baseUrl:$});if(r)console.log("SDK initialized successfully"),C.initialize(e.trim(),o.trim(),t.trim(),l,r);else throw console.error("SDK initialization failed: Event tracker initialization returned false"),C.setInitCheck(),new Error("SDK initialization failed: Unable to establish connection with the CTI system")}catch(r){throw console.error("SDK initialization error:",r),C.setInitCheck(),r instanceof Error?r:new Error(`SDK initialization failed: ${String(r)}`)}}function On(){return"6.x.x"}function Pn(){return C.getState().isInitialized}0&&(module.exports={CallControlPanel,getSDKVersion,initSDK,isSDKInitialized,useClickToCall,useEndCall,useGetAuthorizationToken,useGetCallerData,useLogout});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
47
+
48
+ // call-control-sdk/index.ts
49
+ var index_exports = {};
50
+ __export(index_exports, {
51
+ CallControlPanel: () => CallControlPanel,
52
+ getSDKVersion: () => getSDKVersion,
53
+ initSDK: () => initSDK,
54
+ isSDKInitialized: () => isSDKInitialized,
55
+ useClickToCall: () => useClickToCall,
56
+ useEndCall: () => useEndCall,
57
+ useGetAuthorizationToken: () => useGetAuthorizationToken,
58
+ useGetCallerData: () => useGetCallerData,
59
+ useLogout: () => useLogout
60
+ });
61
+ module.exports = __toCommonJS(index_exports);
62
+
63
+ // call-control-sdk/lib/services/endPoint.ts
64
+ var IP = "uat-cti.aighospitals.com";
65
+ var BASE_URL = `https://${IP}:8095`;
66
+ var WS_BASE_URL = `wss://${IP}:8095`;
67
+ var VERSION = {
68
+ v1: "/api/v1"
69
+ };
70
+ var END_POINT = {
71
+ LOGIN: `${BASE_URL}${VERSION.v1}/cti/login?provider=convox`,
72
+ READY_AGENT: `${BASE_URL}${VERSION.v1}/cti/ready-agent?provider=convox`,
73
+ UPDATE_AGENT_BREAK: `${BASE_URL}${VERSION.v1}/cti/update-agent-status?provider=convox`,
74
+ CLICK_TO_CALL: `${BASE_URL}${VERSION.v1}/cti/calls?provider=convox`,
75
+ HOLD_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/hold?provider=convox`,
76
+ MUTE_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/mute?provider=convox`,
77
+ UNMUTE_CALL: `${BASE_URL}${VERSION.v1}/cti/unmute-call?provider=convox`,
78
+ END_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/end?provider=convox`,
79
+ LOGOUT: `${BASE_URL}${VERSION.v1}/cti/logout?provider=convox`,
80
+ CONFERENCE_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/conference?provider=convox`,
81
+ CONFERENCE_CALL_HOLD_OR_UN_HOLD: `${BASE_URL}${VERSION.v1}/cti/calls/conference/hold?provider=convox`,
82
+ CONFERENCE_CALL_MUTE_OT_UN_MUTE: `${BASE_URL}${VERSION.v1}/cti/calls/conference/mute?provider=convox`,
83
+ CONFERENCE_CALL_END: `${BASE_URL}${VERSION.v1}/cti/calls/conference/hangup?provider=convox`,
84
+ CONFERENCE_CALL_END_ALL: `${BASE_URL}${VERSION.v1}/cti/calls/conference/hangup/all?provider=convox`,
85
+ TRANSFER_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/transfer?provider=convox`,
86
+ AGENTS_LIST: `${BASE_URL}${VERSION.v1}/cti/users`,
87
+ PROCESS_LIST: `${BASE_URL}${VERSION.v1}/cti/processes-list`,
88
+ TRANSFER_TO_DETAILS: `${BASE_URL}${VERSION.v1}/cti/transfer-to-details?provider=convox`,
89
+ CALL_HISTORY: `${BASE_URL}${VERSION.v1}/dashboard/call-history`,
90
+ SENTIMENTAL_ANALYSIS: `${BASE_URL}${VERSION.v1}/users/get_sentiment_analysis`
91
+ };
92
+ var WS_END_POINT = {
93
+ WS: `${WS_BASE_URL}${VERSION.v1}/cti/ws`
94
+ };
95
+ var STORAGE_KEY = "call-control-sdk-state";
96
+
97
+ // call-control-sdk/lib/hooks/sdk-state.ts
98
+ var SDKStateManager = class {
99
+ constructor() {
100
+ __publicField(this, "state");
101
+ __publicField(this, "listeners", []);
102
+ __publicField(this, "STORAGE_KEY", STORAGE_KEY);
103
+ __publicField(this, "apiKey");
104
+ __publicField(this, "tenantId");
105
+ this.state = this.getInitialState();
106
+ this.loadFromStorage();
107
+ }
108
+ getInitialState() {
109
+ return {
110
+ authorization: void 0,
111
+ process: null,
112
+ agentId: "",
113
+ openConferenceDialog: false,
114
+ openCallTransferDialog: false,
115
+ isInitialized: false,
116
+ sdkConfig: {
117
+ disableEndCallButton: false,
118
+ disabledDialButton: false,
119
+ disableCallTransferButton: false,
120
+ isDraggable: true,
121
+ disableSoftPhone: false,
122
+ disableConferenceButton: false,
123
+ disabled: {},
124
+ enabled: {},
125
+ outlined: {}
126
+ },
127
+ isHolding: false,
128
+ isMuted: false,
129
+ status: "idle",
130
+ callStartTime: null,
131
+ controlPanelPosition: { x: 10, y: 10 },
132
+ iframePosition: { x: 10, y: 80 },
133
+ callData: {
134
+ agent_id: "",
135
+ status: "",
136
+ type: "",
137
+ event_time: "",
138
+ phone_number: ""
139
+ },
140
+ conferenceLine: [
141
+ {
142
+ line: 1,
143
+ status: "IDLE",
144
+ type: "",
145
+ phone: "",
146
+ isMute: false,
147
+ isHold: false,
148
+ isCallStart: false,
149
+ isMergeCall: false
150
+ },
151
+ {
152
+ line: 2,
153
+ status: "IDLE",
154
+ type: "",
155
+ phone: "",
156
+ isMute: false,
157
+ isHold: false,
158
+ isCallStart: false,
159
+ isMergeCall: false
160
+ },
161
+ {
162
+ line: 3,
163
+ status: "IDLE",
164
+ type: "",
165
+ phone: "",
166
+ isMute: false,
167
+ isHold: false,
168
+ isCallStart: false,
169
+ isMergeCall: false
170
+ },
171
+ {
172
+ line: 4,
173
+ status: "IDLE",
174
+ type: "",
175
+ phone: "",
176
+ isMute: false,
177
+ isHold: false,
178
+ isCallStart: false,
179
+ isMergeCall: false
180
+ },
181
+ {
182
+ line: 5,
183
+ status: "IDLE",
184
+ type: "",
185
+ phone: "",
186
+ isMute: false,
187
+ isHold: false,
188
+ isCallStart: false,
189
+ isMergeCall: false
190
+ }
191
+ ]
192
+ };
193
+ }
194
+ loadFromStorage() {
195
+ try {
196
+ const stored = localStorage.getItem(this.STORAGE_KEY);
197
+ if (stored) {
198
+ const parsedState = JSON.parse(stored);
199
+ this.state = __spreadProps(__spreadValues({}, this.state), {
200
+ agentId: parsedState.agentId || "",
201
+ authorization: parsedState.authorization || void 0,
202
+ process: parsedState.process || null,
203
+ openConferenceDialog: (parsedState == null ? void 0 : parsedState.openConferenceDialog) || false,
204
+ openCallTransferDialog: (parsedState == null ? void 0 : parsedState.openCallTransferDialog) || false,
205
+ isInitialized: parsedState.isInitialized || false,
206
+ sdkConfig: parsedState.sdkConfig || {
207
+ disableEndCallButton: false,
208
+ disabledDialButton: false,
209
+ disableCallTransferButton: false,
210
+ isDraggable: true,
211
+ disableSoftPhone: false,
212
+ disableConferenceButton: false,
213
+ disabled: {},
214
+ enabled: {},
215
+ outlined: {}
216
+ },
217
+ isHolding: parsedState.isHolding || false,
218
+ isMuted: parsedState.isMuted || false,
219
+ status: parsedState.status || "idle",
220
+ callStartTime: parsedState.callStartTime || null,
221
+ controlPanelPosition: parsedState.controlPanelPosition || {
222
+ x: 10,
223
+ y: 10
224
+ },
225
+ iframePosition: parsedState.iframePosition || { x: 10, y: 80 },
226
+ callData: parsedState.callData || {
227
+ mobileNumber: "",
228
+ callReferenceId: "",
229
+ agent_id: "",
230
+ status: "",
231
+ type: "",
232
+ event_time: "",
233
+ phone_number: ""
234
+ },
235
+ // Fix: Properly handle conferenceLine with fallback to initial state
236
+ conferenceLine: parsedState.conferenceLine && Array.isArray(parsedState.conferenceLine) && parsedState.conferenceLine.length > 0 ? parsedState.conferenceLine : this.state.conferenceLine
237
+ });
238
+ }
239
+ } catch (error) {
240
+ console.warn("Failed to load SDK state from localStorage:", error);
241
+ }
242
+ }
243
+ saveToStorage() {
244
+ try {
245
+ const persistentState = {
246
+ agentId: this.state.agentId,
247
+ authorization: this.state.authorization,
248
+ process: this.state.process,
249
+ isInitialized: this.state.isInitialized,
250
+ openConferenceDialog: this.state.openConferenceDialog,
251
+ openCallTransferDialog: this.state.openCallTransferDialog,
252
+ sdkConfig: this.state.sdkConfig,
253
+ isHolding: this.state.isHolding,
254
+ isMuted: this.state.isMuted,
255
+ status: this.state.status,
256
+ callStartTime: this.state.callStartTime,
257
+ controlPanelPosition: this.state.controlPanelPosition,
258
+ iframePosition: this.state.iframePosition,
259
+ callData: this.state.callData,
260
+ conferenceLine: this.state.conferenceLine
261
+ };
262
+ localStorage.setItem(this.STORAGE_KEY, JSON.stringify(persistentState));
263
+ } catch (error) {
264
+ console.warn("Failed to save SDK state to localStorage:", error);
265
+ }
266
+ }
267
+ notifyListeners() {
268
+ this.listeners.forEach((listener) => listener());
269
+ }
270
+ validateCredentials(apiKey, tenantId) {
271
+ if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
272
+ throw new Error("API key not available");
273
+ }
274
+ if (!tenantId || typeof tenantId !== "string" || tenantId.trim().length === 0) {
275
+ throw new Error("Tenant ID not available");
276
+ }
277
+ this.apiKey = apiKey.trim();
278
+ this.tenantId = tenantId.trim();
279
+ }
280
+ initialize(apiKey, tenantId, agentId, sdkConfig, initResult) {
281
+ this.validateCredentials(apiKey, tenantId);
282
+ if (!agentId || typeof agentId !== "string" || agentId.trim().length === 0) {
283
+ throw new Error("Agent ID not available");
284
+ } else {
285
+ this.state.agentId = agentId;
286
+ this.state.openConferenceDialog = false;
287
+ this.state.openCallTransferDialog = false;
288
+ this.state.authorization = initResult;
289
+ this.state.sdkConfig = __spreadValues({
290
+ disableEndCallButton: false,
291
+ disabledDialButton: false,
292
+ disableCallTransferButton: false,
293
+ isDraggable: true,
294
+ disableSoftPhone: false,
295
+ disableConferenceButton: false,
296
+ disabled: {},
297
+ enabled: {},
298
+ outlined: {}
299
+ }, sdkConfig);
300
+ this.state.isInitialized = true;
301
+ this.saveToStorage();
302
+ this.notifyListeners();
303
+ }
304
+ }
305
+ getState() {
306
+ return __spreadValues({}, this.state);
307
+ }
308
+ getCredentials() {
309
+ return { apiKey: this.apiKey, tenantId: this.tenantId };
310
+ }
311
+ getSdkAuthToken() {
312
+ var _a2;
313
+ return (_a2 = this.state.authorization) == null ? void 0 : _a2.accessToken;
314
+ }
315
+ subscribe(listener) {
316
+ this.listeners.push(listener);
317
+ return () => {
318
+ const index = this.listeners.indexOf(listener);
319
+ if (index > -1) {
320
+ this.listeners.splice(index, 1);
321
+ }
322
+ };
323
+ }
324
+ setHolding(isHolding) {
325
+ this.state.isHolding = isHolding;
326
+ this.saveToStorage();
327
+ this.notifyListeners();
328
+ }
329
+ setMuted(isMuted) {
330
+ this.state.isMuted = isMuted;
331
+ this.saveToStorage();
332
+ this.notifyListeners();
333
+ }
334
+ setStatus(status) {
335
+ this.state.status = status;
336
+ this.saveToStorage();
337
+ this.notifyListeners();
338
+ }
339
+ setProcess(process) {
340
+ this.state.process = process;
341
+ this.saveToStorage();
342
+ this.notifyListeners();
343
+ }
344
+ setControlPanelPosition(position) {
345
+ this.state.controlPanelPosition = position;
346
+ this.saveToStorage();
347
+ this.notifyListeners();
348
+ }
349
+ setIframePosition(position) {
350
+ this.state.iframePosition = position;
351
+ this.saveToStorage();
352
+ this.notifyListeners();
353
+ }
354
+ startCall() {
355
+ this.state.callStartTime = Date.now();
356
+ this.state.status = "on call";
357
+ this.saveToStorage();
358
+ this.notifyListeners();
359
+ }
360
+ endCall() {
361
+ this.state.callStartTime = null;
362
+ this.state.status = "idle";
363
+ this.state.isHolding = false;
364
+ this.state.isMuted = false;
365
+ this.saveToStorage();
366
+ this.notifyListeners();
367
+ }
368
+ setInitCheck() {
369
+ this.state.isInitialized = false;
370
+ this.saveToStorage();
371
+ this.notifyListeners();
372
+ }
373
+ setOpenConferenceDialog(open) {
374
+ this.state.openConferenceDialog = open;
375
+ this.saveToStorage();
376
+ this.notifyListeners();
377
+ }
378
+ setOpenCallTransferDialog(open) {
379
+ this.state.openCallTransferDialog = open;
380
+ this.saveToStorage();
381
+ this.notifyListeners();
382
+ }
383
+ updateCallData(data) {
384
+ this.state.callData = __spreadValues(__spreadValues({}, this.state.callData), data);
385
+ this.saveToStorage();
386
+ this.notifyListeners();
387
+ }
388
+ updateConferenceData(data) {
389
+ this.state.conferenceLine = [...data];
390
+ this.saveToStorage();
391
+ this.notifyListeners();
392
+ }
393
+ setConferenceLine(line) {
394
+ var _a2;
395
+ if (!this.state.conferenceLine || !Array.isArray(this.state.conferenceLine)) {
396
+ console.warn("Conference line data corrupted, resetting to initial state");
397
+ this.state.conferenceLine = this.getInitialState().conferenceLine;
398
+ }
399
+ const conferenceLineData = (_a2 = this.state.conferenceLine) == null ? void 0 : _a2.map((each) => {
400
+ if (each.line === line.line) {
401
+ return line;
402
+ }
403
+ return each;
404
+ });
405
+ this.state.conferenceLine = conferenceLineData;
406
+ this.saveToStorage();
407
+ this.notifyListeners();
408
+ }
409
+ resetConferenceLines() {
410
+ this.state.conferenceLine = this.getInitialState().conferenceLine;
411
+ this.saveToStorage();
412
+ this.notifyListeners();
413
+ }
414
+ clearStorageAndReset() {
415
+ try {
416
+ localStorage.removeItem(this.STORAGE_KEY);
417
+ this.state = this.getInitialState();
418
+ this.notifyListeners();
419
+ } catch (error) {
420
+ console.warn("Failed to clear localStorage:", error);
421
+ }
422
+ }
423
+ debugStorage() {
424
+ try {
425
+ const stored = localStorage.getItem(this.STORAGE_KEY);
426
+ console.log("Current localStorage data:", stored);
427
+ if (stored) {
428
+ console.log("Parsed localStorage data:", JSON.parse(stored));
429
+ }
430
+ console.log("Current state:", this.state);
431
+ } catch (error) {
432
+ console.error("Error debugging storage:", error);
433
+ }
434
+ }
435
+ getConferenceLines() {
436
+ return this.state.conferenceLine || [];
437
+ }
438
+ };
439
+ var sdkStateManager = new SDKStateManager();
440
+
441
+ // call-control-sdk/lib/hooks/eventsTracker.ts
442
+ var EventTrackerSDK = class {
443
+ constructor() {
444
+ __publicField(this, "config", null);
445
+ __publicField(this, "ticketId", null);
446
+ __publicField(this, "baseUrl", "");
447
+ __publicField(this, "eventQueue", []);
448
+ // private isOnline: boolean = true;
449
+ // private retryQueue: Array<() => Promise<void>> = [];
450
+ __publicField(this, "flushTimer", null);
451
+ }
452
+ async init(config) {
453
+ this.config = __spreadValues({
454
+ autoTrack: true,
455
+ retryAttempts: 3,
456
+ queueSize: 100,
457
+ flushInterval: 5e3
458
+ }, config);
459
+ this.baseUrl = config.baseUrl || (typeof window !== "undefined" ? window.location.origin : "");
460
+ this.setupNetworkDetection();
461
+ const ticket = await this.createTicket();
462
+ this.startPeriodicFlush();
463
+ console.log("EventTracker SDK initialized successfully");
464
+ return ticket;
465
+ }
466
+ isInitialized() {
467
+ return this.config !== null && this.ticketId !== null;
468
+ }
469
+ getConfig() {
470
+ return this.config;
471
+ }
472
+ getTicketId() {
473
+ return this.ticketId;
474
+ }
475
+ async createTicket() {
476
+ if (!this.config) {
477
+ throw new Error("EventTracker not initialized");
478
+ }
479
+ try {
480
+ const response = await this.makeRequest("/api/v1/et/init", {
481
+ method: "POST",
482
+ headers: {
483
+ "Content-Type": "application/json",
484
+ "X-API-Key": this.config.apiKey
485
+ },
486
+ body: JSON.stringify({
487
+ agentId: this.config.agentId,
488
+ sessionId: this.config.sessionId
489
+ })
490
+ });
491
+ if (!response.ok) {
492
+ sdkStateManager.setInitCheck();
493
+ throw new Error(`Failed to initialize: ${response.status} ${response.statusText}`);
494
+ }
495
+ const data = await response.json();
496
+ this.ticketId = data.ticketId;
497
+ if (this.config.autoTrack) {
498
+ this.setupAutoTracking();
499
+ }
500
+ return data;
501
+ } catch (error) {
502
+ console.error("EventTracker initialization failed:", error);
503
+ throw error;
504
+ }
505
+ }
506
+ async logEvent(eventType, eventData) {
507
+ if (!this.config || !this.ticketId) {
508
+ console.warn("EventTracker not initialized, skipping event:", eventType);
509
+ return;
510
+ }
511
+ const event = {
512
+ eventType,
513
+ eventData,
514
+ timestamp: Date.now()
515
+ };
516
+ this.eventQueue.push(event);
517
+ if (this.eventQueue.length > (this.config.queueSize || 100)) {
518
+ this.eventQueue.shift();
519
+ }
520
+ }
521
+ // private async sendEvent(event: {
522
+ // eventType: string;
523
+ // eventData?: EventData;
524
+ // timestamp: number;
525
+ // }): Promise<void> {
526
+ // if (!this.config || !this.ticketId) return;
527
+ // try {
528
+ // const response = await this.makeRequest("/api/v1/et/event", {
529
+ // method: "POST",
530
+ // headers: {
531
+ // "Content-Type": "application/json",
532
+ // "X-API-Key": this.config.apiKey,
533
+ // },
534
+ // body: JSON.stringify({
535
+ // ticketId: this.ticketId,
536
+ // eventType: event.eventType,
537
+ // eventData: event.eventData,
538
+ // }),
539
+ // });
540
+ // if (!response.ok) {
541
+ // throw new Error(`Failed to log event: ${response.status} ${response.statusText}`);
542
+ // }
543
+ // const index = this.eventQueue.findIndex((e) => e.timestamp === event.timestamp);
544
+ // if (index > -1) {
545
+ // this.eventQueue.splice(index, 1);
546
+ // }
547
+ // } catch (error) {
548
+ // console.error("Event logging failed:", error);
549
+ // // this.retryQueue.push(() => this.sendEvent(event));
550
+ // }
551
+ // }
552
+ // async closeTicket(): Promise<void> {
553
+ // if (!this.config || !this.ticketId) {
554
+ // throw new Error("EventTracker not initialized");
555
+ // }
556
+ // await this.flush();
557
+ // try {
558
+ // const response = await this.makeRequest("/api/v1/et/close", {
559
+ // method: "POST",
560
+ // headers: {
561
+ // "Content-Type": "application/json",
562
+ // "X-API-Key": this.config.apiKey,
563
+ // },
564
+ // body: JSON.stringify({
565
+ // ticketId: this.ticketId,
566
+ // }),
567
+ // });
568
+ // if (!response.ok) {
569
+ // throw new Error(`Failed to close ticket: ${response.status} ${response.statusText}`);
570
+ // }
571
+ // this.ticketId = null;
572
+ // this.stopPeriodicFlush();
573
+ // console.log("Ticket closed successfully");
574
+ // } catch (error) {
575
+ // console.error("Ticket close failed:", error);
576
+ // throw error;
577
+ // }
578
+ // }
579
+ // async flush(): Promise<void> {
580
+ // if (!this.isOnline || this.eventQueue.length === 0) return;
581
+ // // const eventsToFlush = [...this.eventQueue];
582
+ // // for (const event of eventsToFlush) {
583
+ // // await this.sendEvent(event);
584
+ // // }
585
+ // const retryItems = [...this.retryQueue];
586
+ // this.retryQueue = [];
587
+ // for (const retryFn of retryItems) {
588
+ // try {
589
+ // await retryFn();
590
+ // } catch (error) {
591
+ // console.error("Retry failed:", error);
592
+ // }
593
+ // }
594
+ // }
595
+ async makeRequest(url, options) {
596
+ var _a2;
597
+ const fullUrl = `${this.baseUrl}${url}`;
598
+ const maxRetries = ((_a2 = this.config) == null ? void 0 : _a2.retryAttempts) || 3;
599
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
600
+ try {
601
+ const response = await fetch(fullUrl, options);
602
+ return response;
603
+ } catch (error) {
604
+ if (attempt === maxRetries) {
605
+ throw error;
606
+ }
607
+ const delay = Math.min(1e3 * Math.pow(2, attempt - 1), 1e4);
608
+ await new Promise((resolve) => setTimeout(resolve, delay));
609
+ }
610
+ }
611
+ throw new Error("Max retries exceeded");
612
+ }
613
+ setupAutoTracking() {
614
+ var _a2;
615
+ if (typeof window === "undefined" || !((_a2 = this.config) == null ? void 0 : _a2.autoTrack)) return;
616
+ const autoTrackConfig = this.config.autoTrack === true ? {} : this.config.autoTrack;
617
+ if (autoTrackConfig.pageVisits !== false) {
618
+ this.logEvent("pageVisit", {
619
+ url: window.location.href,
620
+ title: document.title,
621
+ referrer: document.referrer,
622
+ userAgent: navigator.userAgent,
623
+ viewport: {
624
+ width: window.innerWidth,
625
+ height: window.innerHeight
626
+ },
627
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
628
+ }).catch((error) => console.warn("Failed to track page visit:", error));
629
+ }
630
+ if (autoTrackConfig.clicks !== false) {
631
+ document.addEventListener("click", (event) => {
632
+ var _a3;
633
+ const target = event.target;
634
+ if (target.tagName === "BUTTON" || target.tagName === "A" || target.onclick || target.getAttribute("role") === "button" || target instanceof HTMLButtonElement && target.type === "button") {
635
+ this.logEvent("click", {
636
+ element: target.tagName,
637
+ text: (_a3 = target.textContent) == null ? void 0 : _a3.trim().substring(0, 100),
638
+ href: target.getAttribute("href"),
639
+ id: target.id,
640
+ className: target.className,
641
+ role: target.getAttribute("role"),
642
+ position: {
643
+ x: event.clientX,
644
+ y: event.clientY
645
+ },
646
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
647
+ }).catch((error) => console.warn("Failed to track click:", error));
648
+ }
649
+ });
650
+ }
651
+ if (autoTrackConfig.forms !== false) {
652
+ document.addEventListener("submit", (event) => {
653
+ const target = event.target;
654
+ const formData = new FormData(target);
655
+ const formFields = {};
656
+ formData.forEach((value, key) => {
657
+ formFields[key] = value.toString();
658
+ });
659
+ this.logEvent("formSubmission", {
660
+ formId: target.id,
661
+ action: target.action,
662
+ method: target.method,
663
+ fields: Object.keys(formFields),
664
+ fieldCount: Object.keys(formFields).length,
665
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
666
+ }).catch((error) => console.warn("Failed to track form submission:", error));
667
+ });
668
+ }
669
+ if (autoTrackConfig.inputs !== false) {
670
+ let inputTimer;
671
+ document.addEventListener("input", (event) => {
672
+ const target = event.target;
673
+ if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT") {
674
+ clearTimeout(inputTimer);
675
+ inputTimer = setTimeout(() => {
676
+ var _a3;
677
+ this.logEvent("fieldChange", {
678
+ element: target.tagName,
679
+ type: target.getAttribute("type"),
680
+ name: target.getAttribute("name"),
681
+ id: target.id,
682
+ valueLength: ((_a3 = target.value) == null ? void 0 : _a3.length) || 0,
683
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
684
+ }).catch((error) => console.warn("Failed to track field change:", error));
685
+ }, 1e3);
686
+ }
687
+ });
688
+ }
689
+ const sessionStartTime = Date.now();
690
+ window.addEventListener("beforeunload", () => {
691
+ const sessionDuration = Date.now() - sessionStartTime;
692
+ this.logEvent("pageUnload", {
693
+ url: window.location.href,
694
+ sessionDuration,
695
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
696
+ });
697
+ });
698
+ if (autoTrackConfig.visibility !== false) {
699
+ document.addEventListener("visibilitychange", () => {
700
+ this.logEvent("visibilityChange", {
701
+ hidden: document.hidden,
702
+ visibilityState: document.visibilityState,
703
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
704
+ });
705
+ });
706
+ }
707
+ if (autoTrackConfig.errors !== false) {
708
+ window.addEventListener("error", (event) => {
709
+ this.logEvent("jsError", {
710
+ message: event.message,
711
+ filename: event.filename,
712
+ lineno: event.lineno,
713
+ colno: event.colno,
714
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
715
+ });
716
+ });
717
+ window.addEventListener("unhandledrejection", (event) => {
718
+ var _a3;
719
+ this.logEvent("unhandledRejection", {
720
+ reason: (_a3 = event.reason) == null ? void 0 : _a3.toString(),
721
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
722
+ });
723
+ });
724
+ }
725
+ if (autoTrackConfig.performance !== false && typeof window.performance !== "undefined" && window.performance.navigation) {
726
+ window.addEventListener("load", () => {
727
+ setTimeout(() => {
728
+ const navigation = window.performance.navigation;
729
+ const timing = window.performance.timing;
730
+ this.logEvent("performanceMetrics", {
731
+ navigationTime: timing.navigationStart,
732
+ loadTime: timing.loadEventEnd - timing.navigationStart,
733
+ domReady: timing.domContentLoadedEventEnd - timing.navigationStart,
734
+ renderTime: timing.loadEventEnd - timing.domContentLoadedEventEnd,
735
+ navigationType: navigation.type,
736
+ redirectCount: navigation.redirectCount,
737
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
738
+ });
739
+ }, 1e3);
740
+ });
741
+ }
742
+ }
743
+ setupNetworkDetection() {
744
+ if (typeof window === "undefined") return;
745
+ window.addEventListener("online", () => {
746
+ console.log("EventTracker: Back online, flushing queued events");
747
+ });
748
+ window.addEventListener("offline", () => {
749
+ console.log("EventTracker: Offline, queueing events");
750
+ });
751
+ }
752
+ startPeriodicFlush() {
753
+ if (this.flushTimer) {
754
+ clearInterval(this.flushTimer);
755
+ }
756
+ }
757
+ // private stopPeriodicFlush(): void {
758
+ // if (this.flushTimer) {
759
+ // clearInterval(this.flushTimer);
760
+ // this.flushTimer = null;
761
+ // }
762
+ // }
763
+ };
764
+ var eventTracker = new EventTrackerSDK();
765
+ if (typeof window !== "undefined") {
766
+ window.EventTracker = eventTracker;
767
+ }
768
+
769
+ // call-control-sdk/lib/hooks/useLogout.ts
770
+ var import_react = require("react");
771
+
772
+ // call-control-sdk/lib/services/axios.ts
773
+ var import_axios = __toESM(require("axios"));
774
+ var _a;
775
+ var DEFAULT_TOKEN = (_a = sdkStateManager.getSdkAuthToken()) != null ? _a : "";
776
+ var REQUEST_TIMEOUT = 6e4;
777
+ function getAuthToken() {
778
+ var _a2;
779
+ return (_a2 = sdkStateManager.getSdkAuthToken()) != null ? _a2 : "";
780
+ }
781
+ function createAxiosInstance() {
782
+ var _a2, _b, _c, _d;
783
+ const instance = import_axios.default.create({
784
+ baseURL: BASE_URL,
785
+ headers: {
786
+ "Content-Type": "application/json",
787
+ Accept: "application/json",
788
+ "x-tenant-id": (_b = (_a2 = sdkStateManager.getCredentials()) == null ? void 0 : _a2.tenantId) != null ? _b : "",
789
+ "x-api-key": (_d = (_c = sdkStateManager.getCredentials()) == null ? void 0 : _c.apiKey) != null ? _d : "",
790
+ Authorization: `${DEFAULT_TOKEN}`
791
+ },
792
+ timeout: REQUEST_TIMEOUT,
793
+ withCredentials: false
794
+ });
795
+ instance.interceptors.request.use(
796
+ (config) => {
797
+ const token = getAuthToken();
798
+ if (token && config.headers) {
799
+ config.headers.Authorization = `${token}`;
800
+ }
801
+ config.metadata = { startTime: (/* @__PURE__ */ new Date()).getTime() };
802
+ return config;
803
+ },
804
+ (error) => {
805
+ console.error("Request interceptor error:", error);
806
+ return Promise.reject(error);
807
+ }
808
+ );
809
+ instance.interceptors.response.use(
810
+ (response) => {
811
+ var _a3;
812
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
813
+ const startTime = (_a3 = response.config.metadata) == null ? void 0 : _a3.startTime;
814
+ if (startTime) {
815
+ console.log(`Request to ${response.config.url} took ${endTime - startTime}ms`);
816
+ }
817
+ return response;
818
+ },
819
+ async (error) => {
820
+ var _a3;
821
+ const originalRequest = error.config;
822
+ if (((_a3 = error.response) == null ? void 0 : _a3.status) === 401 && !originalRequest._retry) {
823
+ sdkStateManager.setInitCheck();
824
+ console.warn("Unauthorized request, attempting retry...");
825
+ }
826
+ if (!error.response) {
827
+ console.error("Network error:", error.message);
828
+ error.message = "Network error: Please check your internet connection";
829
+ }
830
+ if (error.response && error.response.status >= 500) {
831
+ console.error("Server error:", error.response.status, error.response.data);
832
+ error.message = "Server error: Please try again later";
833
+ }
834
+ return Promise.reject(error);
835
+ }
836
+ );
837
+ return instance;
838
+ }
839
+ var axiosInstance = createAxiosInstance();
840
+ var axios_default = axiosInstance;
841
+
842
+ // call-control-sdk/lib/hooks/useLogout.ts
843
+ var useLogout = () => {
844
+ const [loading, setLoading] = (0, import_react.useState)(false);
845
+ const [success, setSuccess] = (0, import_react.useState)(false);
846
+ const [isError, setIsError] = (0, import_react.useState)(false);
847
+ const [error, setError] = (0, import_react.useState)(null);
848
+ const [data, setData] = (0, import_react.useState)(null);
849
+ const handleLogout = (0, import_react.useCallback)(async () => {
850
+ var _a2;
851
+ const state = JSON.parse((_a2 = localStorage.getItem(STORAGE_KEY)) != null ? _a2 : "");
852
+ setLoading(true);
853
+ const payload = {
854
+ action: "LOGOUTUSER",
855
+ userId: state.agentId || ""
856
+ };
857
+ return axios_default.post(END_POINT.LOGOUT, payload).then((res) => {
858
+ sdkStateManager.clearStorageAndReset();
859
+ localStorage.clear();
860
+ sessionStorage.clear();
861
+ setData(res == null ? void 0 : res.data);
862
+ setSuccess(true);
863
+ return res == null ? void 0 : res.data;
864
+ }).catch((err) => {
865
+ var _a3;
866
+ setIsError(true);
867
+ setError(err);
868
+ return (_a3 = err == null ? void 0 : err.response) == null ? void 0 : _a3.data;
869
+ }).finally(() => {
870
+ setLoading(false);
871
+ });
872
+ }, []);
873
+ return {
874
+ logout: handleLogout,
875
+ isLoading: loading,
876
+ isSuccess: success,
877
+ isError,
878
+ error,
879
+ data
880
+ };
881
+ };
882
+
883
+ // call-control-sdk/lib/hooks/useEndCall.ts
884
+ var import_react2 = require("react");
885
+ var useEndCall = () => {
886
+ const [loading, setLoading] = (0, import_react2.useState)(false);
887
+ const [success, setSuccess] = (0, import_react2.useState)(false);
888
+ const [isError, setIsError] = (0, import_react2.useState)(false);
889
+ const [error, setError] = (0, import_react2.useState)(null);
890
+ const [data, setData] = (0, import_react2.useState)(null);
891
+ const handleEndCall = (0, import_react2.useCallback)(
892
+ async (data2) => {
893
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
894
+ const state = JSON.parse((_a2 = localStorage.getItem(STORAGE_KEY)) != null ? _a2 : "");
895
+ setLoading(true);
896
+ const payload = {
897
+ action: "ENDCALL",
898
+ userId: state == null ? void 0 : state.agentId,
899
+ processid: (_d = (_c = (_b = state == null ? void 0 : state.process) == null ? void 0 : _b.process_id) == null ? void 0 : _c.toString()) != null ? _d : "",
900
+ process_name: (_f = (_e = state == null ? void 0 : state.process) == null ? void 0 : _e.process_name) != null ? _f : "",
901
+ callreferenceid: (_h = (_g = state == null ? void 0 : state.callData) == null ? void 0 : _g.convox_id) != null ? _h : "",
902
+ mobile_number: (_j = (_i = state == null ? void 0 : state.callData) == null ? void 0 : _i.phone_number) != null ? _j : "",
903
+ disposition: (_k = data2 == null ? void 0 : data2.disposition) != null ? _k : "RES",
904
+ set_followUp: (_l = data2 == null ? void 0 : data2.followUp) != null ? _l : "N",
905
+ callback_date: (_m = data2 == null ? void 0 : data2.callbackDate) != null ? _m : "",
906
+ callback_hrs: (_n = data2 == null ? void 0 : data2.callbackHrs) != null ? _n : "",
907
+ callback_mins: (_o = data2 == null ? void 0 : data2.callbackMins) != null ? _o : "",
908
+ endcall_type: "CLOSE"
909
+ };
910
+ return axios_default.post(END_POINT.END_CALL, payload).then((res) => {
911
+ sdkStateManager.endCall();
912
+ setData(res == null ? void 0 : res.data);
913
+ setSuccess(true);
914
+ return res == null ? void 0 : res.data;
915
+ }).catch((err) => {
916
+ var _a3;
917
+ setIsError(true);
918
+ setError(err);
919
+ return (_a3 = err == null ? void 0 : err.response) == null ? void 0 : _a3.data;
920
+ }).finally(() => {
921
+ setLoading(false);
922
+ });
923
+ },
924
+ []
925
+ );
926
+ return {
927
+ handleEndCall,
928
+ isLoading: loading,
929
+ isSuccess: success,
930
+ isError,
931
+ error,
932
+ data
933
+ };
934
+ };
935
+
936
+ // call-control-sdk/lib/hooks/useClickToCall.ts
937
+ var import_react3 = require("react");
938
+ var useClickToCall = () => {
939
+ const [loading, setLoading] = (0, import_react3.useState)(false);
940
+ const [success, setSuccess] = (0, import_react3.useState)(false);
941
+ const [isError, setIsError] = (0, import_react3.useState)(false);
942
+ const [error, setError] = (0, import_react3.useState)(null);
943
+ const [data, setData] = (0, import_react3.useState)(null);
944
+ const handleStartCall = (0, import_react3.useCallback)(async (data2) => {
945
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
946
+ const state = JSON.parse((_a2 = localStorage.getItem(STORAGE_KEY)) != null ? _a2 : "");
947
+ setLoading(true);
948
+ if (((_b = state == null ? void 0 : state.callData) == null ? void 0 : _b.status) === "IDLE") {
949
+ const payload = {
950
+ action: "CALL",
951
+ userId: state == null ? void 0 : state.agentId,
952
+ phone_number: data2 == null ? void 0 : data2.mobileNumber
953
+ };
954
+ return axios_default.post(END_POINT.CLICK_TO_CALL, payload).then((res) => {
955
+ setData(res == null ? void 0 : res.data);
956
+ setSuccess(true);
957
+ return res == null ? void 0 : res.data;
958
+ }).catch((err) => {
959
+ var _a3;
960
+ setIsError(true);
961
+ setError(err);
962
+ return (_a3 = err == null ? void 0 : err.response) == null ? void 0 : _a3.data;
963
+ }).finally(() => {
964
+ setLoading(false);
965
+ });
966
+ } else if (((_c = state == null ? void 0 : state.callData) == null ? void 0 : _c.status) === "ONCALL") {
967
+ const line_used = (_e = (_d = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _d.filter((each) => each.line !== 1)) == null ? void 0 : _e.find((each) => each.status === "IDLE" && !(each == null ? void 0 : each.isCallStart));
968
+ const payload = {
969
+ action: "EXTERNAL_CONFERENCE",
970
+ operation: `CALL${line_used.line}`,
971
+ line_used: String(line_used.line),
972
+ thirdparty_no: data2 == null ? void 0 : data2.mobileNumber,
973
+ userid: (_g = (_f = state.callData) == null ? void 0 : _f.agent_id) != null ? _g : "",
974
+ process: (_i = (_h = state.callData) == null ? void 0 : _h.process_name) != null ? _i : ""
975
+ };
976
+ return axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
977
+ setData(res == null ? void 0 : res.data);
978
+ setSuccess(true);
979
+ sdkStateManager.setConferenceLine(__spreadProps(__spreadValues({}, line_used), {
980
+ isCallStart: true,
981
+ status: "ONCALL",
982
+ phone: data2 == null ? void 0 : data2.mobileNumber
983
+ }));
984
+ sdkStateManager.setOpenConferenceDialog(true);
985
+ return res == null ? void 0 : res.data;
986
+ }).catch((err) => {
987
+ var _a3;
988
+ setIsError(true);
989
+ setError(err);
990
+ return (_a3 = err == null ? void 0 : err.response) == null ? void 0 : _a3.data;
991
+ }).finally(() => {
992
+ setLoading(false);
993
+ });
994
+ } else {
995
+ alert("Agent is not ready");
996
+ }
997
+ }, []);
998
+ return {
999
+ handleStartCall,
1000
+ isLoading: loading,
1001
+ isSuccess: success,
1002
+ isError,
1003
+ error,
1004
+ data
1005
+ };
1006
+ };
1007
+
1008
+ // call-control-sdk/lib/hooks/useGetCallerData.ts
1009
+ var import_react4 = require("react");
1010
+ var useGetCallerData = () => {
1011
+ const { process_id, process_name, status, phone_number, agent_id, convox_id } = sdkStateManager.getState().callData;
1012
+ const initialCallData = {
1013
+ phone_number,
1014
+ status,
1015
+ callReferenceId: convox_id,
1016
+ agent_id,
1017
+ process_id,
1018
+ process_name
1019
+ };
1020
+ const [callData, setCallData] = (0, import_react4.useState)(initialCallData);
1021
+ (0, import_react4.useEffect)(() => {
1022
+ const unsubscribe = sdkStateManager.subscribe(() => {
1023
+ const { process_id: process_id2, process_name: process_name2, status: status2, phone_number: phone_number2, agent_id: agent_id2, convox_id: convox_id2 } = sdkStateManager.getState().callData;
1024
+ const currentCallData = {
1025
+ phone_number: phone_number2,
1026
+ status: status2,
1027
+ callReferenceId: convox_id2,
1028
+ agent_id: agent_id2,
1029
+ process_id: process_id2,
1030
+ process_name: process_name2
1031
+ };
1032
+ setCallData(currentCallData);
1033
+ });
1034
+ return unsubscribe;
1035
+ }, []);
1036
+ return callData;
1037
+ };
1038
+
1039
+ // call-control-sdk/lib/hooks/useGetAuthorizationToken.ts
1040
+ var import_react5 = require("react");
1041
+ var useGetAuthorizationToken = () => {
1042
+ const [token, setToken] = (0, import_react5.useState)(sdkStateManager.getSdkAuthToken());
1043
+ (0, import_react5.useEffect)(() => {
1044
+ const unsubscribe = sdkStateManager.subscribe(() => {
1045
+ setToken(sdkStateManager.getSdkAuthToken());
1046
+ });
1047
+ return unsubscribe;
1048
+ }, []);
1049
+ return token;
1050
+ };
1051
+
1052
+ // call-control-sdk/lib/components/callControlPanel.tsx
1053
+ var import_react13 = require("react");
1054
+
1055
+ // call-control-sdk/lib/components/callControls.tsx
1056
+ var import_icons_material2 = require("@mui/icons-material");
1057
+ var import_material4 = require("@mui/material");
1058
+ var import_react11 = require("react");
1059
+
1060
+ // call-control-sdk/lib/hooks/useDraggable.ts
1061
+ var import_react6 = require("react");
1062
+ function useDraggable(initialPosition, onPositionChange) {
1063
+ const [position, setPosition] = (0, import_react6.useState)(initialPosition);
1064
+ const [isDragging, setIsDragging] = (0, import_react6.useState)(false);
1065
+ const dragRef = (0, import_react6.useRef)();
1066
+ const dragStart = (0, import_react6.useRef)({ x: 0, y: 0 });
1067
+ const elementStart = (0, import_react6.useRef)({ x: 0, y: 0 });
1068
+ const updatePosition = (0, import_react6.useCallback)(
1069
+ (newPosition) => {
1070
+ const element = dragRef.current;
1071
+ if (!element) return;
1072
+ const rect = element.getBoundingClientRect();
1073
+ const viewportWidth = window.innerWidth;
1074
+ const viewportHeight = window.innerHeight;
1075
+ const constrainedPosition = {
1076
+ x: Math.max(0, Math.min(newPosition.x, viewportWidth - rect.width)),
1077
+ y: Math.max(0, Math.min(newPosition.y, viewportHeight - rect.height))
1078
+ };
1079
+ setPosition(constrainedPosition);
1080
+ onPositionChange == null ? void 0 : onPositionChange(constrainedPosition);
1081
+ },
1082
+ [onPositionChange]
1083
+ );
1084
+ const handleStart = (0, import_react6.useCallback)(
1085
+ (clientX, clientY) => {
1086
+ setIsDragging(true);
1087
+ dragStart.current = { x: clientX, y: clientY };
1088
+ elementStart.current = position;
1089
+ const handleMove = (moveClientX, moveClientY) => {
1090
+ const deltaX = moveClientX - dragStart.current.x;
1091
+ const deltaY = moveClientY - dragStart.current.y;
1092
+ updatePosition({
1093
+ x: elementStart.current.x + deltaX,
1094
+ y: elementStart.current.y + deltaY
1095
+ });
1096
+ };
1097
+ const handleMouseMove = (e) => {
1098
+ e.preventDefault();
1099
+ handleMove(e.clientX, e.clientY);
1100
+ };
1101
+ const handleTouchMove = (e) => {
1102
+ e.preventDefault();
1103
+ const touch = e.touches[0];
1104
+ if (touch) {
1105
+ handleMove(touch.clientX, touch.clientY);
1106
+ }
1107
+ };
1108
+ const handleEnd = () => {
1109
+ setIsDragging(false);
1110
+ document.removeEventListener("mousemove", handleMouseMove);
1111
+ document.removeEventListener("mouseup", handleEnd);
1112
+ document.removeEventListener("touchmove", handleTouchMove);
1113
+ document.removeEventListener("touchend", handleEnd);
1114
+ };
1115
+ document.addEventListener("mousemove", handleMouseMove);
1116
+ document.addEventListener("mouseup", handleEnd);
1117
+ document.addEventListener("touchmove", handleTouchMove, {
1118
+ passive: false
1119
+ });
1120
+ document.addEventListener("touchend", handleEnd);
1121
+ },
1122
+ [position, updatePosition]
1123
+ );
1124
+ const handleMouseDown = (0, import_react6.useCallback)(
1125
+ (e) => {
1126
+ e.preventDefault();
1127
+ handleStart(e.clientX, e.clientY);
1128
+ },
1129
+ [handleStart]
1130
+ );
1131
+ const handleTouchStart = (0, import_react6.useCallback)(
1132
+ (e) => {
1133
+ e.preventDefault();
1134
+ const touch = e.touches[0];
1135
+ if (touch) {
1136
+ handleStart(touch.clientX, touch.clientY);
1137
+ }
1138
+ },
1139
+ [handleStart]
1140
+ );
1141
+ return {
1142
+ position,
1143
+ isDragging,
1144
+ dragRef,
1145
+ handleMouseDown,
1146
+ handleTouchStart
1147
+ };
1148
+ }
1149
+
1150
+ // call-control-sdk/lib/hooks/useSDKState.ts
1151
+ var import_react7 = require("react");
1152
+ function useSDKState() {
1153
+ const [state, setState] = (0, import_react7.useState)(sdkStateManager.getState());
1154
+ (0, import_react7.useEffect)(() => {
1155
+ const unsubscribe = sdkStateManager.subscribe(() => {
1156
+ setState(sdkStateManager.getState());
1157
+ });
1158
+ return unsubscribe;
1159
+ }, []);
1160
+ return state;
1161
+ }
1162
+
1163
+ // call-control-sdk/lib/services/request.ts
1164
+ var import_react9 = require("react");
1165
+
1166
+ // call-control-sdk/lib/services/toastMessage.tsx
1167
+ var import_react8 = require("react");
1168
+ var import_material = require("@mui/material");
1169
+ var import_jsx_runtime = require("react/jsx-runtime");
1170
+ var ToastContext = (0, import_react8.createContext)(void 0);
1171
+ var useToast = () => {
1172
+ const ctx = (0, import_react8.useContext)(ToastContext);
1173
+ if (!ctx) throw new Error("useToast must be used inside ToastProvider");
1174
+ return ctx;
1175
+ };
1176
+ var ToastProvider = ({ children }) => {
1177
+ const [open, setOpen] = (0, import_react8.useState)(false);
1178
+ const [message, setMessage] = (0, import_react8.useState)("");
1179
+ const [severity, setSeverity] = (0, import_react8.useState)("info");
1180
+ const showToast = (msg, sev = "info") => {
1181
+ setMessage(msg);
1182
+ setSeverity(sev);
1183
+ setOpen(true);
1184
+ };
1185
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ToastContext.Provider, { value: { showToast }, children: [
1186
+ children,
1187
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1188
+ import_material.Snackbar,
1189
+ {
1190
+ open,
1191
+ color: severity,
1192
+ autoHideDuration: 3e3,
1193
+ onClose: () => setOpen(false),
1194
+ anchorOrigin: { vertical: "top", horizontal: "right" },
1195
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1196
+ import_material.Alert,
1197
+ {
1198
+ variant: "filled",
1199
+ severity,
1200
+ onClose: () => setOpen(false),
1201
+ sx: { width: "100%" },
1202
+ children: message
1203
+ }
1204
+ )
1205
+ }
1206
+ )
1207
+ ] });
1208
+ };
1209
+
1210
+ // call-control-sdk/lib/services/request.ts
1211
+ var initialState = {
1212
+ isLoading: false,
1213
+ isSuccess: false,
1214
+ isError: false,
1215
+ error: null,
1216
+ data: null
1217
+ };
1218
+ var reducer = (state, action) => {
1219
+ if (action.type === "isLoading") {
1220
+ return __spreadProps(__spreadValues({}, state), {
1221
+ isLoading: action.payload
1222
+ });
1223
+ } else if (action.type === "isSuccess") {
1224
+ return __spreadProps(__spreadValues({}, state), {
1225
+ isSuccess: true,
1226
+ data: action.payload
1227
+ });
1228
+ } else if (action.type === "isError") {
1229
+ return __spreadProps(__spreadValues({}, state), {
1230
+ isError: true,
1231
+ error: action.payload
1232
+ });
1233
+ } else if (action.type === "reset") {
1234
+ return {
1235
+ isLoading: false,
1236
+ isSuccess: false,
1237
+ isError: false,
1238
+ error: null,
1239
+ data: null
1240
+ };
1241
+ }
1242
+ throw Error("Unknown action.");
1243
+ };
1244
+ var usePostRequest = (props = {}) => {
1245
+ const { onSuccess = null, onError = null, disabledSuccessToast = false } = props;
1246
+ const { showToast } = useToast();
1247
+ const [state, dispatch] = (0, import_react9.useReducer)(reducer, initialState);
1248
+ const postRequest = (0, import_react9.useCallback)(
1249
+ (url, payload, config = {}) => {
1250
+ dispatch({
1251
+ type: "isLoading",
1252
+ payload: true
1253
+ });
1254
+ axios_default.post(url, payload, config).then((res) => {
1255
+ var _a2;
1256
+ dispatch({
1257
+ type: "isSuccess",
1258
+ payload: res.data
1259
+ });
1260
+ onSuccess == null ? void 0 : onSuccess(res.data, payload);
1261
+ if (!disabledSuccessToast) {
1262
+ showToast((_a2 = res.data) == null ? void 0 : _a2.message, "success");
1263
+ }
1264
+ }).catch((err) => {
1265
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1266
+ const error = {
1267
+ status: (_b = (_a2 = err.response) == null ? void 0 : _a2.status) != null ? _b : 500,
1268
+ message: ((_d = (_c = err.response) == null ? void 0 : _c.data) == null ? void 0 : _d.detail) || ((_f = (_e = err.response) == null ? void 0 : _e.data) == null ? void 0 : _f.message) || err.message || "An unknown error occurred",
1269
+ data: (_h = (_g = err.response) == null ? void 0 : _g.data) != null ? _h : null,
1270
+ statusText: (_j = (_i = err.response) == null ? void 0 : _i.statusText) != null ? _j : "",
1271
+ code: (_k = err == null ? void 0 : err.code) != null ? _k : "",
1272
+ name: (_l = err == null ? void 0 : err.name) != null ? _l : ""
1273
+ };
1274
+ showToast(error.message, "error");
1275
+ dispatch({
1276
+ type: "isError",
1277
+ payload: error
1278
+ });
1279
+ onError == null ? void 0 : onError(error, payload);
1280
+ }).finally(() => {
1281
+ dispatch({
1282
+ type: "isLoading",
1283
+ payload: false
1284
+ });
1285
+ });
1286
+ },
1287
+ [onSuccess, onError, showToast]
1288
+ );
1289
+ return [postRequest, state];
1290
+ };
1291
+
1292
+ // call-control-sdk/lib/components/dialog.tsx
1293
+ var import_icons_material = require("@mui/icons-material");
1294
+ var import_material3 = require("@mui/material");
1295
+ var import_react10 = require("react");
1296
+
1297
+ // call-control-sdk/lib/components/styles.ts
1298
+ var import_material2 = require("@mui/material");
1299
+ var useStyles = ({
1300
+ disabled,
1301
+ enabled,
1302
+ outlined
1303
+ }) => {
1304
+ const theme = (0, import_material2.useTheme)();
1305
+ return {
1306
+ disabled: __spreadValues({
1307
+ padding: "0px",
1308
+ margin: "0px",
1309
+ minWidth: "40px !important",
1310
+ borderRadius: "16px",
1311
+ border: `1px solid rgb(206, 204, 204)`,
1312
+ height: "40px",
1313
+ "&:hover": {
1314
+ boxShadow: " 0px 2px 2px rgba(0, 0, 0, 0.79)",
1315
+ border: `1px solid ${theme.palette.primary.main}`
1316
+ },
1317
+ "&:active": {
1318
+ bgcolor: "primary.main",
1319
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1320
+ }
1321
+ }, disabled),
1322
+ enabled: __spreadValues({
1323
+ padding: "0px",
1324
+ margin: "0px",
1325
+ minWidth: "40px !important",
1326
+ borderRadius: "16px",
1327
+ boxShadow: " 0px 2px 1px rgba(0, 0, 0, 0.507)",
1328
+ border: `1px solid ${theme.palette.primary.main}`,
1329
+ height: "40px",
1330
+ "&:hover": {
1331
+ boxShadow: " 0px 2px 1px rgba(0, 0, 0, 0.507)",
1332
+ border: `1px solid ${theme.palette.primary.main}`
1333
+ },
1334
+ "&:active": {
1335
+ bgcolor: "primary.main",
1336
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1337
+ }
1338
+ }, enabled),
1339
+ outlined: __spreadValues({
1340
+ padding: "0px",
1341
+ margin: "0px",
1342
+ minWidth: "40px !important",
1343
+ borderRadius: "16px",
1344
+ backgroundColor: theme.palette.grey[200],
1345
+ boxShadow: `0px 2px 1px ${theme.palette.primary.light}`,
1346
+ border: `0px solid ${theme.palette.primary.main}`,
1347
+ height: "40px",
1348
+ "&:hover": {
1349
+ boxShadow: `0px 2px 1px ${theme.palette.primary.main}`,
1350
+ border: `0px solid ${theme.palette.primary.main}`
1351
+ },
1352
+ "&:active": {
1353
+ bgcolor: "primary.main",
1354
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1355
+ }
1356
+ }, outlined)
1357
+ };
1358
+ };
1359
+ var styles_default = useStyles;
1360
+
1361
+ // call-control-sdk/lib/components/dialog.tsx
1362
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1363
+ var ConferenceTableRow = ({ each }) => {
1364
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
1365
+ const state = useSDKState();
1366
+ const { showToast } = useToast();
1367
+ const { disabled, enabled, outlined } = styles_default({
1368
+ disabled: ((_a2 = state.sdkConfig) == null ? void 0 : _a2.disabled) || {},
1369
+ enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
1370
+ outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
1371
+ });
1372
+ const theme = (0, import_material3.useTheme)();
1373
+ const [conferenceCallStart, setConferenceCallStart] = (0, import_react10.useState)(false);
1374
+ const [conferenceCallMerge, setConferenceCallMerge] = (0, import_react10.useState)(false);
1375
+ const [conferenceCallHoldOrUnHold, setConferenceCallHoldOrUnHold] = (0, import_react10.useState)(false);
1376
+ const [conferenceCallEnd, setConferenceCallEnd] = (0, import_react10.useState)(false);
1377
+ const onConferenceLineUpdate = (line, data) => {
1378
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1379
+ };
1380
+ const onConferenceCallStart = (line, data) => {
1381
+ var _a3, _b2, _c2, _d2;
1382
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1383
+ setConferenceCallStart(true);
1384
+ const payload = {
1385
+ action: "EXTERNAL_CONFERENCE",
1386
+ operation: `CALL${line_used.line}`,
1387
+ line_used: String(line_used.line),
1388
+ thirdparty_no: line_used.phone,
1389
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1390
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1391
+ };
1392
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
1393
+ var _a4;
1394
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1395
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1396
+ }).catch((err) => {
1397
+ var _a4, _b3, _c3, _d3;
1398
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1399
+ showToast(message, "error");
1400
+ }).finally(() => {
1401
+ setConferenceCallStart(false);
1402
+ });
1403
+ };
1404
+ const onMergeConferenceCall = (line, data) => {
1405
+ var _a3, _b2, _c2, _d2;
1406
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1407
+ setConferenceCallMerge(true);
1408
+ const payload = {
1409
+ action: "EXTERNAL_CONFERENCE",
1410
+ operation: `CONFERENCE`,
1411
+ line_used: String(line_used.line),
1412
+ thirdparty_no: line_used.phone,
1413
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1414
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1415
+ };
1416
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
1417
+ var _a4;
1418
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1419
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1420
+ }).catch((err) => {
1421
+ var _a4, _b3, _c3, _d3;
1422
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1423
+ showToast(message, "error");
1424
+ }).finally(() => {
1425
+ setConferenceCallMerge(false);
1426
+ });
1427
+ };
1428
+ const onHoldOrUnHoldConferenceCall = (line, data, type) => {
1429
+ var _a3, _b2, _c2, _d2;
1430
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1431
+ setConferenceCallHoldOrUnHold(true);
1432
+ const payload = {
1433
+ action: "EXTERNAL_CONFERENCE",
1434
+ operation: type,
1435
+ hold_channel_no: type === "HOLDUSER" ? `hold${line_used.line}` : `unhold${line_used.line}`,
1436
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1437
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1438
+ };
1439
+ axios_default.post(END_POINT.CONFERENCE_CALL_HOLD_OR_UN_HOLD, payload).then((res) => {
1440
+ var _a4;
1441
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1442
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1443
+ }).catch((err) => {
1444
+ var _a4, _b3, _c3, _d3;
1445
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1446
+ showToast(message, "error");
1447
+ }).finally(() => {
1448
+ setConferenceCallHoldOrUnHold(false);
1449
+ });
1450
+ };
1451
+ const onEndConferenceCall = (line, data) => {
1452
+ var _a3, _b2, _c2, _d2;
1453
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1454
+ setConferenceCallEnd(true);
1455
+ const payload = {
1456
+ action: "EXTERNAL_CONFERENCE",
1457
+ operation: "HANGUP_CHANNEL",
1458
+ line_used: String(line_used.line),
1459
+ user_type: `THIRDPARTY${line_used.line - 1}`,
1460
+ thirdparty_no: line_used.phone,
1461
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1462
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1463
+ };
1464
+ axios_default.post(END_POINT.CONFERENCE_CALL_END, payload).then((res) => {
1465
+ var _a4;
1466
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1467
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1468
+ }).catch((err) => {
1469
+ var _a4, _b3, _c3, _d3;
1470
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1471
+ showToast(message, "error");
1472
+ }).finally(() => {
1473
+ setConferenceCallEnd(false);
1474
+ });
1475
+ };
1476
+ const [holdOrUnHold, { isLoading: holdOrUnHoldLoading }] = usePostRequest({
1477
+ onSuccess: () => {
1478
+ sdkStateManager.setHolding(!state.isHolding);
1479
+ },
1480
+ onError: (error) => {
1481
+ console.log("\u274C Hold operation error:", error);
1482
+ }
1483
+ });
1484
+ const [muteOrUnMute, { isLoading: muteOrUnMuteLoading }] = usePostRequest({
1485
+ onSuccess: () => {
1486
+ sdkStateManager.setMuted(!state.isMuted);
1487
+ },
1488
+ onError: (error) => {
1489
+ console.log("\u274C Mute operation error:", error);
1490
+ }
1491
+ });
1492
+ const handleHoldToggle = () => {
1493
+ var _a3;
1494
+ const payload = {
1495
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1 ? "UNHOLD" : "HOLD",
1496
+ userId: state.agentId
1497
+ };
1498
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
1499
+ };
1500
+ const handleMuteToggle = () => {
1501
+ var _a3;
1502
+ const payload = {
1503
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.mute) === 1 ? "UNMUTE" : "MUTE",
1504
+ userId: state.agentId
1505
+ };
1506
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
1507
+ };
1508
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1509
+ import_material3.TableRow,
1510
+ {
1511
+ sx: {
1512
+ border: "2px solid #fff"
1513
+ },
1514
+ children: [
1515
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1516
+ import_material3.TableCell,
1517
+ {
1518
+ sx: {
1519
+ padding: "6px",
1520
+ flex: 1,
1521
+ width: "100px"
1522
+ },
1523
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Typography, { children: [
1524
+ "Line ",
1525
+ (_d = each == null ? void 0 : each.line) != null ? _d : "",
1526
+ ". "
1527
+ ] })
1528
+ }
1529
+ ),
1530
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1531
+ import_material3.TableCell,
1532
+ {
1533
+ sx: {
1534
+ padding: "6px",
1535
+ width: "100px"
1536
+ },
1537
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1538
+ import_material3.Typography,
1539
+ {
1540
+ variant: "body2",
1541
+ sx: {
1542
+ px: 1,
1543
+ borderRadius: "10px",
1544
+ flex: 1
1545
+ },
1546
+ children: (_e = each == null ? void 0 : each.status) != null ? _e : ""
1547
+ }
1548
+ )
1549
+ }
1550
+ ),
1551
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1552
+ import_material3.TableCell,
1553
+ {
1554
+ sx: {
1555
+ padding: "6px",
1556
+ flex: 1
1557
+ },
1558
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1559
+ import_material3.TextField,
1560
+ {
1561
+ size: "small",
1562
+ placeholder: "Phone Number",
1563
+ fullWidth: true,
1564
+ value: (each == null ? void 0 : each.phone) || "",
1565
+ disabled: (each == null ? void 0 : each.line) === 1 || (each == null ? void 0 : each.status) === "ONCALL" || (each == null ? void 0 : each.status) === "DISCONNECTED" || (each == null ? void 0 : each.status) === "CONFERENCE" || (each == null ? void 0 : each.status) === "HOLD" || (each == null ? void 0 : each.status) === "MUTE" || (each == null ? void 0 : each.status) === "DIALING" || (each == null ? void 0 : each.status) === "RINGING",
1566
+ onChange: (e) => {
1567
+ onConferenceLineUpdate(each, { phone: e.target.value });
1568
+ }
1569
+ }
1570
+ )
1571
+ }
1572
+ ),
1573
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1574
+ import_material3.TableCell,
1575
+ {
1576
+ sx: {
1577
+ padding: "6px",
1578
+ // width: "200px",
1579
+ flex: 1
1580
+ },
1581
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1582
+ import_material3.Box,
1583
+ {
1584
+ sx: {
1585
+ width: "100%",
1586
+ display: "flex",
1587
+ alignItems: "center",
1588
+ justifyContent: "flex-start",
1589
+ gap: "10px"
1590
+ },
1591
+ children: [
1592
+ (each == null ? void 0 : each.line) === 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: ((_f = state.callData) == null ? void 0 : _f.hold) === 1 ? "Resume" : "Hold", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1593
+ import_material3.Button,
1594
+ {
1595
+ variant: ((_g = state.callData) == null ? void 0 : _g.hold) === 1 && ((_i = (_h = state.callData) == null ? void 0 : _h.status) == null ? void 0 : _i.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
1596
+ onClick: (e) => {
1597
+ e.stopPropagation();
1598
+ handleHoldToggle();
1599
+ },
1600
+ sx: ((_j = state.callData) == null ? void 0 : _j.hold) === 1 && ((_l = (_k = state.callData) == null ? void 0 : _k.status) == null ? void 0 : _l.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_n = (_m = state.callData) == null ? void 0 : _m.status) == null ? void 0 : _n.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1601
+ disabled: ((_p = (_o = state.callData) == null ? void 0 : _o.status) == null ? void 0 : _p.toUpperCase()) !== "ONCALL" && ((_q = state.callData) == null ? void 0 : _q.hold) !== 1 || holdOrUnHoldLoading,
1602
+ children: ((_r = state.callData) == null ? void 0 : _r.hold) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1603
+ import_material3.Box,
1604
+ {
1605
+ sx: {
1606
+ display: "flex",
1607
+ alignItems: "center",
1608
+ justifyContent: "center",
1609
+ gap: "5px",
1610
+ width: "98px"
1611
+ },
1612
+ children: [
1613
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1614
+ import_material3.Typography,
1615
+ {
1616
+ sx: {
1617
+ color: ((_s = state.callData) == null ? void 0 : _s.hold) === 1 ? "#fff" : "initial"
1618
+ },
1619
+ children: "Unhold"
1620
+ }
1621
+ ),
1622
+ holdOrUnHoldLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1623
+ import_material3.CircularProgress,
1624
+ {
1625
+ size: "16px",
1626
+ sx: {
1627
+ color: theme.palette.primary.main
1628
+ }
1629
+ }
1630
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.PlayArrow, {})
1631
+ ]
1632
+ }
1633
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1634
+ import_material3.Box,
1635
+ {
1636
+ sx: {
1637
+ display: "flex",
1638
+ alignItems: "center",
1639
+ justifyContent: "center",
1640
+ gap: "5px",
1641
+ width: "98px"
1642
+ },
1643
+ children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1645
+ import_material3.Typography,
1646
+ {
1647
+ sx: {
1648
+ color: ((_t = state.callData) == null ? void 0 : _t.hold) === 1 ? "#fff" : "#000"
1649
+ },
1650
+ children: "Hold"
1651
+ }
1652
+ ),
1653
+ holdOrUnHoldLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1654
+ import_material3.CircularProgress,
1655
+ {
1656
+ size: "16px",
1657
+ sx: {
1658
+ color: theme.palette.primary.main
1659
+ }
1660
+ }
1661
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Pause, {})
1662
+ ]
1663
+ }
1664
+ )
1665
+ }
1666
+ ) }),
1667
+ (each == null ? void 0 : each.line) === 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: ((_u = state.callData) == null ? void 0 : _u.mute) === 1 ? "Unmute" : "Mute", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1668
+ import_material3.Button,
1669
+ {
1670
+ variant: state.isHolding ? "outlined" : ((_v = state.callData) == null ? void 0 : _v.mute) === 1 && ((_x = (_w = state.callData) == null ? void 0 : _w.status) == null ? void 0 : _x.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
1671
+ onClick: (e) => {
1672
+ e.stopPropagation();
1673
+ handleMuteToggle();
1674
+ },
1675
+ sx: ((_y = state.callData) == null ? void 0 : _y.hold) === 1 ? __spreadValues({}, disabled) : ((_z = state.callData) == null ? void 0 : _z.mute) === 1 && ((_B = (_A = state.callData) == null ? void 0 : _A.status) == null ? void 0 : _B.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_D = (_C = state.callData) == null ? void 0 : _C.status) == null ? void 0 : _D.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1676
+ disabled: ((_F = (_E = state.callData) == null ? void 0 : _E.status) == null ? void 0 : _F.toUpperCase()) !== "ONCALL" && ((_G = state.callData) == null ? void 0 : _G.mute) !== 1 || muteOrUnMuteLoading || ((_H = state.callData) == null ? void 0 : _H.hold) === 1,
1677
+ children: ((_I = state.callData) == null ? void 0 : _I.mute) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1678
+ import_material3.Box,
1679
+ {
1680
+ sx: {
1681
+ display: "flex",
1682
+ alignItems: "center",
1683
+ justifyContent: "center",
1684
+ gap: "5px",
1685
+ width: "98px"
1686
+ },
1687
+ children: [
1688
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1689
+ import_material3.Typography,
1690
+ {
1691
+ sx: {
1692
+ color: ((_J = state.callData) == null ? void 0 : _J.mute) === 1 ? "#fff" : "initial"
1693
+ },
1694
+ children: "Unmute"
1695
+ }
1696
+ ),
1697
+ muteOrUnMuteLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1698
+ import_material3.CircularProgress,
1699
+ {
1700
+ size: "16px",
1701
+ sx: {
1702
+ color: theme.palette.primary.main
1703
+ }
1704
+ }
1705
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.MicOff, {})
1706
+ ]
1707
+ }
1708
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1709
+ import_material3.Box,
1710
+ {
1711
+ sx: {
1712
+ display: "flex",
1713
+ alignItems: "center",
1714
+ justifyContent: "center",
1715
+ gap: "5px",
1716
+ width: "98px"
1717
+ },
1718
+ children: [
1719
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1720
+ import_material3.Typography,
1721
+ {
1722
+ sx: {
1723
+ color: ((_K = state.callData) == null ? void 0 : _K.mute) === 1 ? "#fff" : "#000"
1724
+ },
1725
+ children: "Mute"
1726
+ }
1727
+ ),
1728
+ muteOrUnMuteLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1729
+ import_material3.CircularProgress,
1730
+ {
1731
+ size: "16px",
1732
+ sx: {
1733
+ color: theme.palette.primary.main
1734
+ }
1735
+ }
1736
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Mic, {})
1737
+ ]
1738
+ }
1739
+ )
1740
+ }
1741
+ ) }),
1742
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1743
+ import_material3.Button,
1744
+ {
1745
+ variant: (each == null ? void 0 : each.status) !== "IDLE" ? "outlined" : "contained",
1746
+ color: "success",
1747
+ sx: (each == null ? void 0 : each.status) !== "IDLE" ? __spreadValues({}, disabled) : __spreadProps(__spreadValues({}, enabled), {
1748
+ border: `0px solid ${theme.palette.success.light}`,
1749
+ "&:hover": {
1750
+ bgcolor: "success.light",
1751
+ boxShadow: `0px 2px 1px ${theme.palette.success.light}`,
1752
+ border: `0px solid ${theme.palette.success.light}`
1753
+ },
1754
+ "&:active": {
1755
+ bgcolor: "success.light",
1756
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1757
+ }
1758
+ }),
1759
+ onClick: () => {
1760
+ onConferenceCallStart(each, {});
1761
+ },
1762
+ disabled: (each == null ? void 0 : each.status) !== "IDLE",
1763
+ children: conferenceCallStart ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1764
+ import_material3.CircularProgress,
1765
+ {
1766
+ size: "20px",
1767
+ color: "success"
1768
+ }
1769
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1770
+ import_icons_material.Call,
1771
+ {
1772
+ sx: {
1773
+ color: (each == null ? void 0 : each.status) !== "IDLE" ? "default" : "#f3f2f2"
1774
+ }
1775
+ }
1776
+ )
1777
+ }
1778
+ ) }),
1779
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "Merge Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1780
+ import_material3.Button,
1781
+ {
1782
+ variant: (each == null ? void 0 : each.status) === "ONCALL" ? "contained" : "outlined",
1783
+ sx: (each == null ? void 0 : each.status) === "ONCALL" ? __spreadValues({}, enabled) : __spreadValues({}, disabled),
1784
+ onClick: () => {
1785
+ onMergeConferenceCall(each, {
1786
+ isMergeCall: true
1787
+ });
1788
+ },
1789
+ disabled: (each == null ? void 0 : each.status) !== "ONCALL",
1790
+ children: conferenceCallMerge ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.CircularProgress, { size: "20px" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.CallSplit, {})
1791
+ }
1792
+ ) }),
1793
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" ? "Hold" : "Un Hold", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1794
+ import_material3.Button,
1795
+ {
1796
+ variant: (each == null ? void 0 : each.status) === "HOLD" ? "contained" : "outlined",
1797
+ sx: (each == null ? void 0 : each.status) === "CONFERENCE" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1798
+ onClick: () => {
1799
+ if (each.status === "HOLD") {
1800
+ onHoldOrUnHoldConferenceCall(each, { isHold: false }, "UNHOLDUSER");
1801
+ } else {
1802
+ onHoldOrUnHoldConferenceCall(each, { isHold: true }, "HOLDUSER");
1803
+ }
1804
+ },
1805
+ disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" && (each == null ? void 0 : each.status) !== "HOLD" || // each?.status === "IDLE" ||
1806
+ // each?.status === "ONCALL" ||
1807
+ // each?.status === "DIALING" ||
1808
+ // each?.status === "RINGING" ||
1809
+ conferenceCallHoldOrUnHold,
1810
+ children: conferenceCallHoldOrUnHold ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1811
+ import_material3.CircularProgress,
1812
+ {
1813
+ size: "20px",
1814
+ sx: {
1815
+ color: theme.palette.primary.main
1816
+ }
1817
+ }
1818
+ ) : each.status === "HOLD" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Pause, {})
1819
+ }
1820
+ ) }),
1821
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "End Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1822
+ import_material3.Button,
1823
+ {
1824
+ variant: (each == null ? void 0 : each.status) !== "IDLE" && (each == null ? void 0 : each.status) !== "DISCONNECTED" ? "contained" : "outlined",
1825
+ color: "error",
1826
+ sx: (each == null ? void 0 : each.status) !== "IDLE" && (each == null ? void 0 : each.status) !== "DISCONNECTED" ? __spreadProps(__spreadValues({}, enabled), {
1827
+ border: `0px solid ${theme.palette.error.light}`,
1828
+ "&:hover": {
1829
+ bgcolor: "error.light",
1830
+ boxShadow: `0px 2px 1px ${theme.palette.error.light}`,
1831
+ border: `0px solid ${theme.palette.error.light}`
1832
+ },
1833
+ "&:active": {
1834
+ bgcolor: "error.light",
1835
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1836
+ }
1837
+ }) : __spreadValues({}, disabled),
1838
+ onClick: () => {
1839
+ onEndConferenceCall(each, {
1840
+ isCallStart: false,
1841
+ isMergeCall: false,
1842
+ isMute: false,
1843
+ isHold: false
1844
+ });
1845
+ },
1846
+ disabled: (each == null ? void 0 : each.status) === "IDLE" || (each == null ? void 0 : each.status) === "DISCONNECTED" || conferenceCallEnd,
1847
+ children: conferenceCallEnd ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1848
+ import_material3.CircularProgress,
1849
+ {
1850
+ size: "20px",
1851
+ color: "error"
1852
+ }
1853
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.CallEnd, {})
1854
+ }
1855
+ ) })
1856
+ ]
1857
+ }
1858
+ )
1859
+ }
1860
+ )
1861
+ ]
1862
+ },
1863
+ each.line
1864
+ );
1865
+ };
1866
+ function ConferenceDialog() {
1867
+ var _a2;
1868
+ const state = useSDKState();
1869
+ const { showToast } = useToast();
1870
+ const [conferenceCallEndAll, setConferenceCallEndAll] = (0, import_react10.useState)(false);
1871
+ const handleClose = () => {
1872
+ sdkStateManager.setOpenConferenceDialog(false);
1873
+ };
1874
+ const onEndAllConferenceCalls = () => {
1875
+ var _a3, _b, _c, _d;
1876
+ setConferenceCallEndAll(true);
1877
+ const payload = {
1878
+ action: "EXTERNAL_CONFERENCE",
1879
+ operation: "ENDCONFERENCE",
1880
+ userid: (_b = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b : "",
1881
+ process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
1882
+ };
1883
+ axios_default.post(END_POINT.CONFERENCE_CALL_END_ALL, payload).then((res) => {
1884
+ var _a4;
1885
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1886
+ sdkStateManager.resetConferenceLines();
1887
+ handleClose();
1888
+ }).catch((err) => {
1889
+ var _a4, _b2, _c2, _d2;
1890
+ const message = ((_b2 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b2.detail) || ((_d2 = (_c2 = err.response) == null ? void 0 : _c2.data) == null ? void 0 : _d2.message) || err.message || "An unknown error occurred";
1891
+ showToast(message, "error");
1892
+ }).finally(() => {
1893
+ setConferenceCallEndAll(false);
1894
+ });
1895
+ };
1896
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1897
+ import_material3.Dialog,
1898
+ {
1899
+ open: state.openConferenceDialog,
1900
+ "aria-labelledby": "alert-dialog-title",
1901
+ "aria-describedby": "alert-dialog-description",
1902
+ maxWidth: "md",
1903
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
1904
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1905
+ import_material3.Box,
1906
+ {
1907
+ sx: {
1908
+ display: "flex",
1909
+ justifyContent: "space-between",
1910
+ alignItems: "center",
1911
+ padding: "10px 16px"
1912
+ },
1913
+ children: [
1914
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Typography, { variant: "body1", children: [
1915
+ (_a2 = state == null ? void 0 : state.agentId) != null ? _a2 : "",
1916
+ " conference"
1917
+ ] }),
1918
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
1919
+ ]
1920
+ }
1921
+ ),
1922
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1923
+ import_material3.Box,
1924
+ {
1925
+ sx: {
1926
+ boxShadow: "1px 1px 2px #e7e5e5ff",
1927
+ margin: "0px 15px",
1928
+ borderRadius: "20px"
1929
+ },
1930
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1931
+ import_material3.TableContainer,
1932
+ {
1933
+ component: import_material3.Paper,
1934
+ sx: {
1935
+ outline: "0px solid gray !important",
1936
+ boxShadow: "1px 1px 6px #e7e5e5ff"
1937
+ },
1938
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1939
+ import_material3.Table,
1940
+ {
1941
+ sx: {
1942
+ border: "4px solid #ffffff !important"
1943
+ },
1944
+ children: [
1945
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1946
+ import_material3.TableRow,
1947
+ {
1948
+ sx: {
1949
+ border: "2px solid #f3f3f3ff !important"
1950
+ },
1951
+ children: [
1952
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1953
+ import_material3.TableCell,
1954
+ {
1955
+ sx: {
1956
+ padding: "6px"
1957
+ },
1958
+ children: "Line"
1959
+ }
1960
+ ),
1961
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1962
+ import_material3.TableCell,
1963
+ {
1964
+ sx: {
1965
+ padding: "6px"
1966
+ },
1967
+ children: "Status"
1968
+ }
1969
+ ),
1970
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1971
+ import_material3.TableCell,
1972
+ {
1973
+ sx: {
1974
+ padding: "6px"
1975
+ },
1976
+ children: "Mobile Number"
1977
+ }
1978
+ ),
1979
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1980
+ import_material3.TableCell,
1981
+ {
1982
+ sx: {
1983
+ padding: "6px"
1984
+ },
1985
+ children: "Call Actions"
1986
+ }
1987
+ )
1988
+ ]
1989
+ }
1990
+ ) }),
1991
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConferenceTableRow, { each })) })
1992
+ ]
1993
+ }
1994
+ )
1995
+ }
1996
+ )
1997
+ }
1998
+ ),
1999
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2000
+ import_material3.Box,
2001
+ {
2002
+ textAlign: "center",
2003
+ m: 2,
2004
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2005
+ import_material3.Button,
2006
+ {
2007
+ variant: "outlined",
2008
+ color: "error",
2009
+ size: "large",
2010
+ onClick: onEndAllConferenceCalls,
2011
+ disabled: conferenceCallEndAll,
2012
+ sx: { px: 2, borderRadius: "20px", textTransform: "capitalize" },
2013
+ children: [
2014
+ conferenceCallEndAll ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2015
+ import_material3.CircularProgress,
2016
+ {
2017
+ size: "20px",
2018
+ color: "error",
2019
+ sx: {
2020
+ marginRight: "8px"
2021
+ }
2022
+ }
2023
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2024
+ import_material3.IconButton,
2025
+ {
2026
+ sx: {
2027
+ bgcolor: "error.main",
2028
+ "&:hover": { bgcolor: "error.dark" },
2029
+ marginRight: "8px",
2030
+ width: "28px",
2031
+ height: "28px",
2032
+ fontSize: "12px",
2033
+ fontWeight: "600",
2034
+ lineHeight: "16px",
2035
+ letterSpacing: "0.02em",
2036
+ textTransform: "capitalize",
2037
+ color: "white",
2038
+ display: "flex",
2039
+ alignItems: "center",
2040
+ justifyContent: "center",
2041
+ borderRadius: "50%"
2042
+ },
2043
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2044
+ import_icons_material.PhoneDisabled,
2045
+ {
2046
+ sx: {
2047
+ color: "white",
2048
+ fontSize: "16px",
2049
+ fontWeight: "600"
2050
+ }
2051
+ }
2052
+ )
2053
+ }
2054
+ ),
2055
+ "End Conference"
2056
+ ]
2057
+ }
2058
+ )
2059
+ }
2060
+ )
2061
+ ] })
2062
+ }
2063
+ ) });
2064
+ }
2065
+ function CallTransferDialog({ open }) {
2066
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2067
+ const state = useSDKState();
2068
+ const [transferCall] = usePostRequest({
2069
+ onSuccess: () => {
2070
+ sdkStateManager.setOpenCallTransferDialog(false);
2071
+ }
2072
+ });
2073
+ const [currentselecteTab, setCurrentselecteTab] = (0, import_react10.useState)("process");
2074
+ const [getIdelAgentsList, { data: idleAgentsList, isLoading: isIdleAgentsListLoading }] = usePostRequest({
2075
+ disabledSuccessToast: true
2076
+ });
2077
+ const [
2078
+ getProcessAndQueuesList,
2079
+ { data: processAndQueuesList, isLoading: isProcessAndQueuesListLoading }
2080
+ ] = usePostRequest({
2081
+ disabledSuccessToast: true
2082
+ });
2083
+ const handleClose = () => {
2084
+ sdkStateManager.setOpenCallTransferDialog(false);
2085
+ };
2086
+ const handleTransferCall = (data, type) => {
2087
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
2088
+ if (type === "PROCESS") {
2089
+ const payload = {
2090
+ mobile_number: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.phone_number) != null ? _b2 : "",
2091
+ userid: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.agent_id) != null ? _d2 : "",
2092
+ type: "PROCESS",
2093
+ transfer_to: (_e2 = data == null ? void 0 : data.process_name) != null ? _e2 : "",
2094
+ callreferenceid: (_g2 = (_f2 = state.callData) == null ? void 0 : _f2.convox_id) != null ? _g2 : "",
2095
+ processid: String((_i2 = (_h2 = state.callData) == null ? void 0 : _h2.process_id) != null ? _i2 : ""),
2096
+ process_name: (_k2 = (_j2 = state.callData) == null ? void 0 : _j2.process_name) != null ? _k2 : ""
2097
+ };
2098
+ transferCall(END_POINT.TRANSFER_CALL, payload);
2099
+ } else if (type === "QUEUE") {
2100
+ const payload = {
2101
+ mobile_number: (_m = (_l2 = state.callData) == null ? void 0 : _l2.phone_number) != null ? _m : "",
2102
+ userid: (_o = (_n = state.callData) == null ? void 0 : _n.agent_id) != null ? _o : "",
2103
+ type: "QUEUE",
2104
+ transfer_to: (_p = data == null ? void 0 : data.queue_name) != null ? _p : "",
2105
+ callreferenceid: (_r = (_q = state.callData) == null ? void 0 : _q.convox_id) != null ? _r : "",
2106
+ processid: String((_t = (_s = state.callData) == null ? void 0 : _s.process_id) != null ? _t : ""),
2107
+ process_name: (_v = (_u = state.callData) == null ? void 0 : _u.process_name) != null ? _v : ""
2108
+ };
2109
+ transferCall(END_POINT.TRANSFER_CALL, payload);
2110
+ } else if (type === "AGENT") {
2111
+ const payload = {
2112
+ mobile_number: (_x = (_w = state.callData) == null ? void 0 : _w.phone_number) != null ? _x : "",
2113
+ userid: (_z = (_y = state.callData) == null ? void 0 : _y.agent_id) != null ? _z : "",
2114
+ type: "AGENT",
2115
+ transfer_to: (_A = data == null ? void 0 : data.user_id) != null ? _A : "",
2116
+ callreferenceid: (_C = (_B = state.callData) == null ? void 0 : _B.convox_id) != null ? _C : "",
2117
+ processid: String((_E = (_D = state.callData) == null ? void 0 : _D.process_id) != null ? _E : ""),
2118
+ process_name: (_G = (_F = state.callData) == null ? void 0 : _F.process_name) != null ? _G : ""
2119
+ };
2120
+ transferCall(END_POINT.TRANSFER_CALL, payload);
2121
+ }
2122
+ };
2123
+ (0, import_react10.useEffect)(() => {
2124
+ getIdelAgentsList(END_POINT.AGENTS_LIST, {
2125
+ status: "IDLE",
2126
+ active: true
2127
+ });
2128
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, {
2129
+ status: "ACTIVE",
2130
+ active: true
2131
+ });
2132
+ }, []);
2133
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2134
+ import_material3.Dialog,
2135
+ {
2136
+ open,
2137
+ "aria-labelledby": "alert-dialog-title",
2138
+ "aria-describedby": "alert-dialog-description",
2139
+ fullWidth: true,
2140
+ maxWidth: "md",
2141
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2142
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2143
+ import_material3.Box,
2144
+ {
2145
+ sx: {
2146
+ display: "flex",
2147
+ justifyContent: "space-between",
2148
+ alignItems: "center",
2149
+ padding: "4px 16px",
2150
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2151
+ },
2152
+ children: [
2153
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Call Transfer" }),
2154
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
2155
+ ]
2156
+ }
2157
+ ),
2158
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2159
+ import_material3.Box,
2160
+ {
2161
+ sx: {
2162
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2163
+ padding: "6px 10px",
2164
+ margin: "10px",
2165
+ borderRadius: "10px"
2166
+ },
2167
+ children: [
2168
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Box, { sx: { display: "flex", gap: 1 }, children: [
2169
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2170
+ import_material3.Button,
2171
+ {
2172
+ variant: currentselecteTab === "process" ? "contained" : "outlined",
2173
+ onClick: () => {
2174
+ setCurrentselecteTab("process");
2175
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, {
2176
+ status: "ACTIVE",
2177
+ active: true
2178
+ });
2179
+ },
2180
+ children: "Process"
2181
+ }
2182
+ ),
2183
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2184
+ import_material3.Button,
2185
+ {
2186
+ variant: currentselecteTab === "queues" ? "contained" : "outlined",
2187
+ onClick: () => {
2188
+ setCurrentselecteTab("queues");
2189
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, {
2190
+ status: "ACTIVE",
2191
+ active: true
2192
+ });
2193
+ },
2194
+ children: "Queues"
2195
+ }
2196
+ ),
2197
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2198
+ import_material3.Button,
2199
+ {
2200
+ variant: currentselecteTab === "agents" ? "contained" : "outlined",
2201
+ onClick: () => {
2202
+ setCurrentselecteTab("agents");
2203
+ getIdelAgentsList(END_POINT.AGENTS_LIST, {
2204
+ status: "IDLE",
2205
+ active: true
2206
+ });
2207
+ },
2208
+ children: "Agents"
2209
+ }
2210
+ )
2211
+ ] }),
2212
+ (isProcessAndQueuesListLoading || isIdleAgentsListLoading) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2213
+ import_material3.Box,
2214
+ {
2215
+ sx: {
2216
+ display: "flex",
2217
+ justifyContent: "center",
2218
+ alignItems: "center",
2219
+ height: "80px"
2220
+ },
2221
+ children: [
2222
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.CircularProgress, {}),
2223
+ " "
2224
+ ]
2225
+ }
2226
+ ),
2227
+ !isProcessAndQueuesListLoading && !isIdleAgentsListLoading && currentselecteTab === "process" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Box, { sx: { display: "flex", gap: 1, flexWrap: "wrap" }, children: ((_a2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _a2.process) && ((_c = (_b = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _b.process) == null ? void 0 : _c.length) > 0 ? (_e = (_d = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _d.process) == null ? void 0 : _e.map((process, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2228
+ import_material3.Box,
2229
+ {
2230
+ sx: {
2231
+ p: 1,
2232
+ display: "flex",
2233
+ alignItems: "center",
2234
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2235
+ padding: "6px",
2236
+ borderRadius: "10px",
2237
+ "&:hover": { bgcolor: "action.selected" }
2238
+ },
2239
+ children: [
2240
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2241
+ import_material3.Typography,
2242
+ {
2243
+ variant: "body1",
2244
+ sx: {
2245
+ mx: 1,
2246
+ width: "200px",
2247
+ maxWidth: "250px",
2248
+ display: "flex",
2249
+ alignItems: "center"
2250
+ },
2251
+ children: [
2252
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2253
+ process.process_name
2254
+ ]
2255
+ }
2256
+ ),
2257
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2258
+ import_material3.IconButton,
2259
+ {
2260
+ color: "success",
2261
+ sx: {
2262
+ bgcolor: "action.hover",
2263
+ "&:hover": { bgcolor: "action.selected" }
2264
+ },
2265
+ onClick: () => {
2266
+ handleTransferCall(process, "PROCESS");
2267
+ },
2268
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2269
+ }
2270
+ )
2271
+ ]
2272
+ },
2273
+ index
2274
+ )) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2275
+ import_material3.Typography,
2276
+ {
2277
+ variant: "body1",
2278
+ sx: {
2279
+ fontSize: "16px",
2280
+ letterSpacing: "0.02em",
2281
+ textTransform: "capitalize",
2282
+ display: "flex",
2283
+ alignItems: "center",
2284
+ justifyContent: "center",
2285
+ width: "100%",
2286
+ margin: "10px 0px",
2287
+ color: "gray",
2288
+ height: "60px"
2289
+ },
2290
+ children: "No Process Found"
2291
+ }
2292
+ ) }),
2293
+ !isProcessAndQueuesListLoading && !isIdleAgentsListLoading && currentselecteTab === "queues" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Box, { sx: { display: "flex", gap: 1, flexWrap: "wrap" }, children: ((_f = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _f.queue) && ((_h = (_g = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _g.queue) == null ? void 0 : _h.length) > 0 ? (_j = (_i = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _i.queue) == null ? void 0 : _j.map((queue, index) => {
2294
+ var _a3, _b2, _c2, _d2, _e2, _f2;
2295
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2296
+ import_material3.Box,
2297
+ {
2298
+ sx: {
2299
+ p: 1,
2300
+ display: "flex",
2301
+ alignItems: "center",
2302
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2303
+ padding: "6px",
2304
+ borderRadius: "10px",
2305
+ "&:hover": { bgcolor: "action.selected" }
2306
+ },
2307
+ children: [
2308
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2309
+ import_material3.Typography,
2310
+ {
2311
+ variant: "body1",
2312
+ sx: {
2313
+ mx: 1,
2314
+ width: "200px",
2315
+ maxWidth: "250px",
2316
+ display: "flex",
2317
+ alignItems: "center"
2318
+ },
2319
+ children: [
2320
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2321
+ queue.queue_name,
2322
+ ((_c2 = (_b2 = (_a3 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _a3.process) == null ? void 0 : _b2.find(
2323
+ (process) => process.process_id === queue.process_id
2324
+ )) == null ? void 0 : _c2.process_name) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2325
+ import_material3.Typography,
2326
+ {
2327
+ variant: "body1",
2328
+ sx: {
2329
+ fontSize: "12px",
2330
+ fontWeight: "600",
2331
+ letterSpacing: "0.02em",
2332
+ textTransform: "capitalize",
2333
+ color: "gray"
2334
+ },
2335
+ children: "(" + ((_f2 = (_e2 = (_d2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _d2.process) == null ? void 0 : _e2.find(
2336
+ (process) => process.process_id === queue.process_id
2337
+ )) == null ? void 0 : _f2.process_name) + ")"
2338
+ }
2339
+ ) : ""
2340
+ ]
2341
+ }
2342
+ ),
2343
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2344
+ import_material3.IconButton,
2345
+ {
2346
+ color: "success",
2347
+ sx: {
2348
+ bgcolor: "action.hover",
2349
+ "&:hover": { bgcolor: "action.selected" }
2350
+ },
2351
+ onClick: () => {
2352
+ handleTransferCall(queue, "QUEUE");
2353
+ },
2354
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2355
+ }
2356
+ )
2357
+ ]
2358
+ },
2359
+ index
2360
+ );
2361
+ }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2362
+ import_material3.Typography,
2363
+ {
2364
+ variant: "body1",
2365
+ sx: {
2366
+ fontSize: "16px",
2367
+ letterSpacing: "0.02em",
2368
+ textTransform: "capitalize",
2369
+ display: "flex",
2370
+ alignItems: "center",
2371
+ justifyContent: "center",
2372
+ width: "100%",
2373
+ margin: "10px 0px",
2374
+ color: "gray",
2375
+ height: "60px"
2376
+ },
2377
+ children: "No Queues Found"
2378
+ }
2379
+ ) }),
2380
+ !isProcessAndQueuesListLoading && !isIdleAgentsListLoading && currentselecteTab === "agents" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Box, { sx: { display: "flex", gap: 1, flexWrap: "wrap" }, children: (idleAgentsList == null ? void 0 : idleAgentsList.data) && ((_k = idleAgentsList == null ? void 0 : idleAgentsList.data) == null ? void 0 : _k.length) > 0 ? (_l = idleAgentsList == null ? void 0 : idleAgentsList.data) == null ? void 0 : _l.map((agent, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2381
+ import_material3.Box,
2382
+ {
2383
+ sx: {
2384
+ p: 1,
2385
+ display: "flex",
2386
+ alignItems: "center",
2387
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2388
+ padding: "6px",
2389
+ borderRadius: "10px",
2390
+ "&:hover": { bgcolor: "action.selected" }
2391
+ },
2392
+ children: [
2393
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2394
+ import_material3.Typography,
2395
+ {
2396
+ variant: "body1",
2397
+ sx: {
2398
+ mx: 1,
2399
+ width: "200px",
2400
+ maxWidth: "250px",
2401
+ display: "flex",
2402
+ alignItems: "center"
2403
+ },
2404
+ children: [
2405
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2406
+ agent.name
2407
+ ]
2408
+ }
2409
+ ),
2410
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2411
+ import_material3.IconButton,
2412
+ {
2413
+ color: "success",
2414
+ sx: {
2415
+ bgcolor: "action.hover",
2416
+ "&:hover": { bgcolor: "action.selected" }
2417
+ },
2418
+ onClick: () => {
2419
+ handleTransferCall(agent, "AGENT");
2420
+ },
2421
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2422
+ }
2423
+ )
2424
+ ]
2425
+ },
2426
+ index
2427
+ )) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2428
+ import_material3.Typography,
2429
+ {
2430
+ variant: "body1",
2431
+ sx: {
2432
+ fontSize: "16px",
2433
+ letterSpacing: "0.02em",
2434
+ textTransform: "capitalize",
2435
+ display: "flex",
2436
+ alignItems: "center",
2437
+ justifyContent: "center",
2438
+ width: "100%",
2439
+ margin: "10px 0px",
2440
+ color: "gray",
2441
+ height: "60px"
2442
+ },
2443
+ children: "No Agents Found"
2444
+ }
2445
+ ) })
2446
+ ]
2447
+ }
2448
+ )
2449
+ ] })
2450
+ }
2451
+ ) });
2452
+ }
2453
+ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2454
+ var _a2, _b, _c, _d;
2455
+ const [formData, setFormData] = (0, import_react10.useState)({
2456
+ disposition: { label: "Resolved", value: "RES" },
2457
+ followUp: { label: "No", value: "N" },
2458
+ callbackDate: "",
2459
+ callbackHrs: "",
2460
+ callbackMins: ""
2461
+ });
2462
+ const dispositionOptions = [
2463
+ { label: "Not Interested", value: "NI" },
2464
+ { label: "Resolved", value: "RES" }
2465
+ ];
2466
+ const followUpOptions = [
2467
+ { label: "Yes", value: "Y" },
2468
+ { label: "No", value: "N" }
2469
+ ];
2470
+ const handleChange = (field, value) => {
2471
+ setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [field]: value }));
2472
+ };
2473
+ const handleReset = () => {
2474
+ setFormData({
2475
+ disposition: { label: "Resolved", value: "RES" },
2476
+ followUp: { label: "No", value: "N" },
2477
+ callbackDate: "",
2478
+ callbackHrs: "",
2479
+ callbackMins: ""
2480
+ });
2481
+ };
2482
+ const handleClose = () => {
2483
+ handleReset();
2484
+ setOpen(false);
2485
+ };
2486
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2487
+ import_material3.Dialog,
2488
+ {
2489
+ open,
2490
+ "aria-labelledby": "alert-dialog-title",
2491
+ "aria-describedby": "alert-dialog-description",
2492
+ fullWidth: true,
2493
+ maxWidth: "xs",
2494
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2495
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2496
+ import_material3.Box,
2497
+ {
2498
+ sx: {
2499
+ display: "flex",
2500
+ justifyContent: "center",
2501
+ alignItems: "center",
2502
+ padding: "4px 16px",
2503
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2504
+ },
2505
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2506
+ import_material3.Typography,
2507
+ {
2508
+ variant: "body1",
2509
+ m: 1,
2510
+ children: [
2511
+ " ",
2512
+ "Call Disposition"
2513
+ ]
2514
+ }
2515
+ )
2516
+ }
2517
+ ),
2518
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2519
+ import_material3.Box,
2520
+ {
2521
+ sx: {
2522
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2523
+ padding: "10px",
2524
+ margin: "10px",
2525
+ borderRadius: "10px"
2526
+ },
2527
+ children: [
2528
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2529
+ import_material3.Box,
2530
+ {
2531
+ display: "flex",
2532
+ gap: 2,
2533
+ children: [
2534
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2535
+ import_material3.Autocomplete,
2536
+ {
2537
+ value: formData.disposition,
2538
+ options: dispositionOptions,
2539
+ getOptionLabel: (opt) => opt.label,
2540
+ onChange: (_, val) => handleChange("disposition", val),
2541
+ size: "small",
2542
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2543
+ import_material3.TextField,
2544
+ __spreadProps(__spreadValues({}, params), {
2545
+ label: "Disposition",
2546
+ fullWidth: true
2547
+ })
2548
+ ),
2549
+ sx: { flex: 1 }
2550
+ }
2551
+ ),
2552
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2553
+ import_material3.Autocomplete,
2554
+ {
2555
+ options: followUpOptions,
2556
+ getOptionLabel: (opt) => opt.label,
2557
+ value: formData.followUp,
2558
+ onChange: (_, val) => handleChange("followUp", val),
2559
+ size: "small",
2560
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2561
+ import_material3.TextField,
2562
+ __spreadProps(__spreadValues({}, params), {
2563
+ label: "Follow Up",
2564
+ fullWidth: true
2565
+ })
2566
+ ),
2567
+ sx: { flex: 1 }
2568
+ }
2569
+ )
2570
+ ]
2571
+ }
2572
+ ),
2573
+ ((_b = (_a2 = formData == null ? void 0 : formData.followUp) == null ? void 0 : _a2.label) == null ? void 0 : _b.toLowerCase()) === "yes" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2574
+ import_material3.Box,
2575
+ {
2576
+ display: "flex",
2577
+ gap: 2,
2578
+ mt: 2,
2579
+ children: [
2580
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2581
+ import_material3.TextField,
2582
+ {
2583
+ size: "small",
2584
+ label: "Callback Date",
2585
+ type: "date",
2586
+ slotProps: {
2587
+ inputLabel: { shrink: true }
2588
+ },
2589
+ value: formData.callbackDate,
2590
+ onChange: (e) => handleChange("callbackDate", e.target.value),
2591
+ fullWidth: true,
2592
+ sx: { flex: 1 }
2593
+ }
2594
+ ),
2595
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2596
+ import_material3.TextField,
2597
+ {
2598
+ size: "small",
2599
+ label: "Hours (0-23)",
2600
+ type: "text",
2601
+ value: formData.callbackHrs,
2602
+ onChange: (e) => handleChange("callbackHrs", e.target.value),
2603
+ fullWidth: true,
2604
+ sx: { flex: 1 }
2605
+ }
2606
+ )
2607
+ ]
2608
+ }
2609
+ ),
2610
+ ((_d = (_c = formData == null ? void 0 : formData.followUp) == null ? void 0 : _c.label) == null ? void 0 : _d.toLowerCase()) === "yes" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2611
+ import_material3.Box,
2612
+ {
2613
+ display: "flex",
2614
+ gap: 2,
2615
+ mt: 2,
2616
+ children: [
2617
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2618
+ import_material3.TextField,
2619
+ {
2620
+ size: "small",
2621
+ label: "Minutes (0-59)",
2622
+ type: "text",
2623
+ value: formData.callbackMins,
2624
+ onChange: (e) => handleChange("callbackMins", e.target.value),
2625
+ fullWidth: true,
2626
+ sx: { flex: 1 }
2627
+ }
2628
+ ),
2629
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Box, { sx: { flex: 1 } })
2630
+ ]
2631
+ }
2632
+ )
2633
+ ]
2634
+ }
2635
+ ),
2636
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2637
+ import_material3.Box,
2638
+ {
2639
+ textAlign: "right",
2640
+ m: 2,
2641
+ children: [
2642
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2643
+ import_material3.Button,
2644
+ {
2645
+ variant: "outlined",
2646
+ color: "error",
2647
+ size: "large",
2648
+ onClick: handleClose,
2649
+ sx: {
2650
+ px: 2,
2651
+ mx: 1,
2652
+ borderRadius: "10px",
2653
+ textTransform: "capitalize"
2654
+ },
2655
+ children: "cancel"
2656
+ }
2657
+ ),
2658
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2659
+ import_material3.Button,
2660
+ {
2661
+ variant: "contained",
2662
+ color: "primary",
2663
+ size: "large",
2664
+ onClick: () => onSubmitDisposition(formData),
2665
+ sx: { px: 2, borderRadius: "10px", textTransform: "capitalize" },
2666
+ children: "Submit"
2667
+ }
2668
+ )
2669
+ ]
2670
+ }
2671
+ )
2672
+ ] })
2673
+ }
2674
+ ) });
2675
+ }
2676
+ function ProcessorListDialog({
2677
+ open,
2678
+ setOpen,
2679
+ processList = null,
2680
+ handleSelectedProcessor
2681
+ }) {
2682
+ const handleClose = () => {
2683
+ setOpen(false);
2684
+ };
2685
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2686
+ import_material3.Dialog,
2687
+ {
2688
+ open,
2689
+ "aria-labelledby": "alert-dialog-title",
2690
+ "aria-describedby": "alert-dialog-description",
2691
+ maxWidth: "xs",
2692
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2693
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2694
+ import_material3.Box,
2695
+ {
2696
+ sx: {
2697
+ display: "flex",
2698
+ justifyContent: "space-between",
2699
+ alignItems: "center",
2700
+ padding: "4px 16px",
2701
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2702
+ },
2703
+ children: [
2704
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Process List" }),
2705
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
2706
+ ]
2707
+ }
2708
+ ),
2709
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2710
+ import_material3.Box,
2711
+ {
2712
+ sx: {
2713
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2714
+ padding: "6px 10px",
2715
+ margin: "10px",
2716
+ borderRadius: "10px"
2717
+ },
2718
+ children: processList.length > 0 ? processList == null ? void 0 : processList.map((process, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2719
+ import_material3.Box,
2720
+ {
2721
+ sx: {
2722
+ p: 1,
2723
+ display: "flex",
2724
+ alignItems: "center",
2725
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2726
+ padding: "6px",
2727
+ margin: "10px 0px",
2728
+ borderRadius: "10px",
2729
+ cursor: "pointer",
2730
+ "&:hover": { bgcolor: "action.selected" }
2731
+ },
2732
+ onClick: () => {
2733
+ handleSelectedProcessor(process);
2734
+ },
2735
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2736
+ import_material3.Typography,
2737
+ {
2738
+ variant: "body1",
2739
+ sx: {
2740
+ mx: 1,
2741
+ width: "200px",
2742
+ maxWidth: "250px",
2743
+ display: "flex",
2744
+ alignItems: "center"
2745
+ },
2746
+ children: [
2747
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2748
+ process.process_name
2749
+ ]
2750
+ }
2751
+ )
2752
+ },
2753
+ index
2754
+ )) : null
2755
+ }
2756
+ )
2757
+ ] })
2758
+ }
2759
+ ) });
2760
+ }
2761
+ function CallHistoryDialog({ open, setOpen }) {
2762
+ const handleClose = () => {
2763
+ setOpen(false);
2764
+ };
2765
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2766
+ import_material3.Dialog,
2767
+ {
2768
+ open,
2769
+ "aria-labelledby": "alert-dialog-title",
2770
+ "aria-describedby": "alert-dialog-description",
2771
+ fullWidth: true,
2772
+ maxWidth: "md",
2773
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2774
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2775
+ import_material3.Box,
2776
+ {
2777
+ sx: {
2778
+ display: "flex",
2779
+ justifyContent: "space-between",
2780
+ alignItems: "center",
2781
+ padding: "4px 16px",
2782
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2783
+ },
2784
+ children: [
2785
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Call History" }),
2786
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
2787
+ ]
2788
+ }
2789
+ ),
2790
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2791
+ import_material3.Box,
2792
+ {
2793
+ sx: {
2794
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2795
+ margin: "10px",
2796
+ borderRadius: "10px",
2797
+ textAlign: "center",
2798
+ fontSize: "16px",
2799
+ fontWeight: "bold"
2800
+ },
2801
+ p: 6,
2802
+ children: "Coming Soon..."
2803
+ }
2804
+ )
2805
+ ] })
2806
+ }
2807
+ ) });
2808
+ }
2809
+
2810
+ // call-control-sdk/lib/utils/audioLoader.ts
2811
+ var import_incoming = __toESM(require("./incoming-4WP3FJI4.mp3"));
2812
+ var audioBlobUrl = null;
2813
+ var audioBuffer = null;
2814
+ async function loadAudioAsBlob() {
2815
+ if (audioBlobUrl) {
2816
+ return audioBlobUrl;
2817
+ }
2818
+ if (import_incoming.default.startsWith("data:") || import_incoming.default.startsWith("http://") || import_incoming.default.startsWith("https://") || import_incoming.default.startsWith("blob:")) {
2819
+ return import_incoming.default;
2820
+ }
2821
+ try {
2822
+ const response = await fetch(import_incoming.default);
2823
+ if (!response.ok) {
2824
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
2825
+ }
2826
+ const blob = await response.blob();
2827
+ if (blob.size === 0) {
2828
+ throw new Error("Empty blob");
2829
+ }
2830
+ audioBlobUrl = URL.createObjectURL(blob);
2831
+ return audioBlobUrl;
2832
+ } catch (error) {
2833
+ console.warn("Could not create blob URL, using direct URL:", error);
2834
+ return import_incoming.default;
2835
+ }
2836
+ }
2837
+ async function createAudioElement() {
2838
+ const audio = new Audio();
2839
+ audio.loop = true;
2840
+ audio.volume = 0.7;
2841
+ audio.preload = "auto";
2842
+ let audioUrl = "";
2843
+ try {
2844
+ audioUrl = await loadAudioAsBlob();
2845
+ } catch (error) {
2846
+ console.warn("Failed to load audio as blob, trying direct URL:", error);
2847
+ audioUrl = import_incoming.default;
2848
+ }
2849
+ const tryLoadAudio = async (url) => {
2850
+ return new Promise((resolve) => {
2851
+ const checkCanPlay = () => {
2852
+ const canPlay = audio.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA;
2853
+ if (canPlay) {
2854
+ resolve(true);
2855
+ return;
2856
+ }
2857
+ if (audio.error) {
2858
+ resolve(false);
2859
+ return;
2860
+ }
2861
+ setTimeout(checkCanPlay, 100);
2862
+ };
2863
+ audio.addEventListener("canplay", () => resolve(true), { once: true });
2864
+ audio.addEventListener("error", () => resolve(false), { once: true });
2865
+ audio.src = url;
2866
+ audio.load();
2867
+ setTimeout(() => resolve(false), 2e3);
2868
+ });
2869
+ };
2870
+ let loaded = await tryLoadAudio(audioUrl);
2871
+ if (!loaded && audioUrl !== import_incoming.default) {
2872
+ console.log("Primary URL failed, trying original import URL:", import_incoming.default);
2873
+ loaded = await tryLoadAudio(import_incoming.default);
2874
+ if (loaded) {
2875
+ audioUrl = import_incoming.default;
2876
+ }
2877
+ }
2878
+ if (!loaded) {
2879
+ console.error("Failed to load audio with all methods. URL:", audioUrl);
2880
+ }
2881
+ return audio;
2882
+ }
2883
+ function cleanupAudioResources() {
2884
+ if (audioBlobUrl) {
2885
+ URL.revokeObjectURL(audioBlobUrl);
2886
+ audioBlobUrl = null;
2887
+ }
2888
+ audioBuffer = null;
2889
+ }
2890
+
2891
+ // call-control-sdk/lib/components/callControls.tsx
2892
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2893
+ var getCombineConfrenceData = (localState, apiData) => {
2894
+ const localConfrenceData = localState == null ? void 0 : localState.conferenceLine;
2895
+ const apiConferenceData = apiData == null ? void 0 : apiData.conferencestatus;
2896
+ const updatedConferenceData = localConfrenceData.map((item) => {
2897
+ var _a2, _b, _c, _d, _e;
2898
+ if ((item == null ? void 0 : item.line) === 1) {
2899
+ const statusKey = `line_${item.line}_status`;
2900
+ return __spreadProps(__spreadValues({}, item), {
2901
+ line: 1,
2902
+ status: (_b = apiConferenceData[statusKey]) != null ? _b : (_a2 = localState == null ? void 0 : localState.callData) == null ? void 0 : _a2.status,
2903
+ phone: (_d = (_c = localState == null ? void 0 : localState.callData) == null ? void 0 : _c.phone_number) != null ? _d : ""
2904
+ });
2905
+ } else {
2906
+ const statusKey = `line_${item.line}_status`;
2907
+ const phoneKey = `line_${item.line}_phonenumber`;
2908
+ return __spreadProps(__spreadValues({}, item), {
2909
+ status: (_e = apiConferenceData[statusKey]) != null ? _e : item.status,
2910
+ phone: apiConferenceData[phoneKey] === null || apiConferenceData[phoneKey] === "0" ? item.phone : apiConferenceData[phoneKey]
2911
+ });
2912
+ }
2913
+ });
2914
+ return updatedConferenceData;
2915
+ };
2916
+ var formatDuration = (seconds) => {
2917
+ const mins = Math.floor(seconds / 60);
2918
+ const secs = seconds % 60;
2919
+ return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
2920
+ };
2921
+ function CallControls({ onDataChange }) {
2922
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma;
2923
+ const theme = (0, import_material4.useTheme)();
2924
+ const state = useSDKState();
2925
+ const { showToast } = useToast();
2926
+ const { disabled, enabled, outlined } = styles_default({
2927
+ disabled: ((_a2 = state.sdkConfig) == null ? void 0 : _a2.disabled) || {},
2928
+ enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
2929
+ outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
2930
+ });
2931
+ const webSocketRef = (0, import_react11.useRef)(null);
2932
+ const audioRef = (0, import_react11.useRef)(null);
2933
+ const reconnectTimeoutRef = (0, import_react11.useRef)(null);
2934
+ const pingIntervalRef = (0, import_react11.useRef)(null);
2935
+ const reconnectAttemptsRef = (0, import_react11.useRef)(0);
2936
+ const maxReconnectAttempts = 60;
2937
+ const baseReconnectDelay = 2e3;
2938
+ const maxReconnectDelay = 3e4;
2939
+ const [anchorEl, setAnchorEl] = (0, import_react11.useState)(null);
2940
+ const [showIframe, setShowIframe] = (0, import_react11.useState)(true);
2941
+ const [statusAnchorEl, setStatusAnchorEl] = (0, import_react11.useState)(null);
2942
+ const [dialerAnchorEl, setDialerAnchorEl] = (0, import_react11.useState)(null);
2943
+ const [openCallDisposition, setOpenCallDisposition] = (0, import_react11.useState)(false);
2944
+ const [openProcessorDialog, setOpenProcessorDialog] = (0, import_react11.useState)(false);
2945
+ const [openCallHistoryDialog, setOpenCallHistoryDialog] = (0, import_react11.useState)(false);
2946
+ const [processList, setProcessList] = (0, import_react11.useState)(null);
2947
+ const [phoneNumber, setPhoneNumber] = (0, import_react11.useState)("");
2948
+ const [callDuration, setCallDuration] = (0, import_react11.useState)(0);
2949
+ const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
2950
+ state.controlPanelPosition,
2951
+ (newPosition) => sdkStateManager.setControlPanelPosition(newPosition)
2952
+ );
2953
+ const {
2954
+ position: iframePosition,
2955
+ isDragging: iframeIsDragging,
2956
+ dragRef: iframeDragRef,
2957
+ handleMouseDown: iframeHandleMouseDown,
2958
+ handleTouchStart: iframeHandleTouchStart
2959
+ } = useDraggable(
2960
+ state.iframePosition,
2961
+ (newPosition) => sdkStateManager.setIframePosition(newPosition)
2962
+ );
2963
+ const [clickToCall, { isLoading: clickToCallLoading }] = usePostRequest({
2964
+ onSuccess: () => {
2965
+ setPhoneNumber("");
2966
+ setDialerAnchorEl(null);
2967
+ }
2968
+ });
2969
+ const [holdOrUnHold, { isLoading: holdOrUnHoldLoading }] = usePostRequest({
2970
+ onSuccess: () => {
2971
+ sdkStateManager.setHolding(!state.isHolding);
2972
+ },
2973
+ onError: (error) => {
2974
+ console.log("\u274C Hold operation error:", error);
2975
+ }
2976
+ });
2977
+ const [muteOrUnMute, { isLoading: muteOrUnMuteLoading }] = usePostRequest({
2978
+ onSuccess: () => {
2979
+ sdkStateManager.setMuted(!state.isMuted);
2980
+ },
2981
+ onError: (error) => {
2982
+ console.log("\u274C Mute operation error:", error);
2983
+ }
2984
+ });
2985
+ const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest();
2986
+ const [updateAgentStatus, { isLoading }] = usePostRequest();
2987
+ const [endCall, { isLoading: endCallLoading }] = usePostRequest({
2988
+ onSuccess: () => {
2989
+ sdkStateManager.resetConferenceLines();
2990
+ }
2991
+ });
2992
+ const handleCloseQueueCounts = () => {
2993
+ setAnchorEl(null);
2994
+ };
2995
+ const handleOpenDialer = (event) => {
2996
+ setShowIframe(true);
2997
+ setDialerAnchorEl(event.currentTarget);
2998
+ sdkStateManager.setStatus("dial");
2999
+ };
3000
+ const handleCloseDialer = () => {
3001
+ if (state.status !== "on call") {
3002
+ sdkStateManager.setStatus("idle");
3003
+ }
3004
+ setDialerAnchorEl(null);
3005
+ };
3006
+ const handleOpenAgentStatus = (event) => {
3007
+ setStatusAnchorEl(event.currentTarget);
3008
+ };
3009
+ const handleCloseAgentStatus = () => {
3010
+ setStatusAnchorEl(null);
3011
+ };
3012
+ const handleAgentReady = () => {
3013
+ const payload = {
3014
+ action: "READYAGENT",
3015
+ userId: state.agentId
3016
+ };
3017
+ readyAgentStatus(END_POINT.READY_AGENT, payload);
3018
+ };
3019
+ const handleUpdateAgentStatus = (status) => {
3020
+ setStatusAnchorEl(null);
3021
+ const payload = {
3022
+ action: "AGENTBREAK",
3023
+ break_type: status,
3024
+ userId: state.agentId
3025
+ };
3026
+ updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload);
3027
+ };
3028
+ const handleStartCall = (number) => {
3029
+ if (number.length !== 10) {
3030
+ showToast("Invalid phone number", "error");
3031
+ } else if (!/^\d+$/.test(number)) {
3032
+ showToast("Invalid phone number", "error");
3033
+ } else {
3034
+ const payload = {
3035
+ action: "CALL",
3036
+ phone_number: number,
3037
+ userId: state.agentId
3038
+ };
3039
+ clickToCall(END_POINT.CLICK_TO_CALL, payload);
3040
+ }
3041
+ };
3042
+ const handleHoldToggle = () => {
3043
+ var _a3;
3044
+ const payload = {
3045
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1 ? "UNHOLD" : "HOLD",
3046
+ userId: state.agentId
3047
+ };
3048
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
3049
+ };
3050
+ const handleMuteToggle = () => {
3051
+ var _a3;
3052
+ const payload = {
3053
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.mute) === 1 ? "UNMUTE" : "MUTE",
3054
+ userId: state.agentId
3055
+ };
3056
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
3057
+ };
3058
+ const handleEndCall = (data) => {
3059
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
3060
+ const payload = {
3061
+ action: "ENDCALL",
3062
+ userId: state.agentId,
3063
+ processid: (_c2 = (_b2 = (_a3 = state.process) == null ? void 0 : _a3.process_id) == null ? void 0 : _b2.toString()) != null ? _c2 : "",
3064
+ process_name: (_e2 = (_d2 = state.process) == null ? void 0 : _d2.process_name) != null ? _e2 : "",
3065
+ callreferenceid: (_g2 = (_f2 = state.callData) == null ? void 0 : _f2.convox_id) != null ? _g2 : "",
3066
+ mobile_number: (_i2 = (_h2 = state.callData) == null ? void 0 : _h2.phone_number) != null ? _i2 : "",
3067
+ disposition: (_k2 = (_j2 = data == null ? void 0 : data.disposition) == null ? void 0 : _j2.value) != null ? _k2 : "",
3068
+ set_followUp: (_m2 = (_l2 = data == null ? void 0 : data.followUp) == null ? void 0 : _l2.value) != null ? _m2 : "",
3069
+ callback_date: (_n2 = data == null ? void 0 : data.callbackDate) != null ? _n2 : "",
3070
+ callback_hrs: (_o2 = data == null ? void 0 : data.callbackHrs) != null ? _o2 : "",
3071
+ callback_mins: (_p2 = data == null ? void 0 : data.callbackMins) != null ? _p2 : "",
3072
+ endcall_type: "CLOSE"
3073
+ };
3074
+ setPhoneNumber("");
3075
+ endCall(END_POINT.END_CALL, payload);
3076
+ sdkStateManager.endCall();
3077
+ setOpenCallDisposition(false);
3078
+ };
3079
+ (0, import_react11.useEffect)(() => {
3080
+ const handleBeforeUnload = (e) => {
3081
+ e.preventDefault();
3082
+ };
3083
+ window.addEventListener("beforeunload", handleBeforeUnload);
3084
+ return () => {
3085
+ window.removeEventListener("beforeunload", handleBeforeUnload);
3086
+ };
3087
+ }, []);
3088
+ (0, import_react11.useEffect)(() => {
3089
+ let interval;
3090
+ if (state.callData.status && state.callData.status === "ONCALL") {
3091
+ interval = setInterval(() => {
3092
+ const elapsed = Math.floor((Date.now() - state.callStartTime) / 1e3);
3093
+ setCallDuration(elapsed);
3094
+ }, 1e3);
3095
+ } else {
3096
+ setCallDuration(0);
3097
+ }
3098
+ return () => {
3099
+ if (interval) clearInterval(interval);
3100
+ };
3101
+ }, [state.callData.status]);
3102
+ (0, import_react11.useEffect)(() => {
3103
+ createAudioElement().then((audio) => {
3104
+ audioRef.current = audio;
3105
+ }).catch((error) => {
3106
+ console.error("Failed to load audio element:", error);
3107
+ });
3108
+ return () => {
3109
+ if (audioRef.current) {
3110
+ audioRef.current.pause();
3111
+ audioRef.current.currentTime = 0;
3112
+ audioRef.current.src = "";
3113
+ audioRef.current = null;
3114
+ }
3115
+ cleanupAudioResources();
3116
+ };
3117
+ }, []);
3118
+ (0, import_react11.useEffect)(() => {
3119
+ if (onDataChange && state.callData) {
3120
+ const { process_id, process_name, status, phone_number, agent_id, convox_id } = state.callData;
3121
+ const callData = {
3122
+ phone_number,
3123
+ status,
3124
+ callReferenceId: convox_id,
3125
+ agent_id,
3126
+ process_id,
3127
+ process_name
3128
+ };
3129
+ onDataChange(callData);
3130
+ }
3131
+ }, [state.callData, onDataChange]);
3132
+ (0, import_react11.useEffect)(() => {
3133
+ if (state.agentId) {
3134
+ axios_default.post(END_POINT.PROCESS_LIST, {
3135
+ userId: state.agentId,
3136
+ action: "GETAGENTPROCESSLIST",
3137
+ refno: "1234221233"
3138
+ }).then((res) => {
3139
+ var _a3, _b2;
3140
+ if (res && res.data && ((_a3 = res == null ? void 0 : res.data) == null ? void 0 : _a3.length) > 1) {
3141
+ setProcessList(res.data.data);
3142
+ setOpenProcessorDialog(true);
3143
+ } else {
3144
+ sdkStateManager.setProcess((_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.data[0]);
3145
+ setOpenProcessorDialog(false);
3146
+ }
3147
+ }).catch((err) => {
3148
+ showToast(err.response.data.message, "error");
3149
+ });
3150
+ } else {
3151
+ console.log("No agentId available, skipping API call");
3152
+ }
3153
+ }, [state.agentId]);
3154
+ const connectWebSocket = () => {
3155
+ if (!state.agentId) {
3156
+ console.log("No agentId available, cannot connect WebSocket");
3157
+ return;
3158
+ }
3159
+ if (reconnectTimeoutRef.current) {
3160
+ clearTimeout(reconnectTimeoutRef.current);
3161
+ reconnectTimeoutRef.current = null;
3162
+ }
3163
+ try {
3164
+ webSocketRef.current = new WebSocket(`${WS_END_POINT.WS}?agent_id=${state.agentId}`);
3165
+ webSocketRef.current.onopen = () => {
3166
+ console.log("\u{1F310} WebSocket connection established");
3167
+ reconnectAttemptsRef.current = 0;
3168
+ if (pingIntervalRef.current) {
3169
+ clearInterval(pingIntervalRef.current);
3170
+ }
3171
+ pingIntervalRef.current = setInterval(() => {
3172
+ if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) {
3173
+ try {
3174
+ webSocketRef.current.send(JSON.stringify({ type: "ping" }));
3175
+ console.log("\u{1F4E1} WebSocket ping sent");
3176
+ } catch (error) {
3177
+ console.error("Failed to send ping:", error);
3178
+ }
3179
+ }
3180
+ }, 3e4);
3181
+ };
3182
+ webSocketRef.current.onmessage = (event) => {
3183
+ try {
3184
+ const data = JSON.parse(event.data);
3185
+ if (data.type === "pong") {
3186
+ console.log("\u{1F4E1} WebSocket pong received");
3187
+ return;
3188
+ }
3189
+ const rls = localStorage.getItem("call-control-sdk-state");
3190
+ const confrence = getCombineConfrenceData(JSON.parse(rls || "{}"), data);
3191
+ sdkStateManager.updateCallData(data);
3192
+ sdkStateManager.updateConferenceData([...confrence]);
3193
+ if (data.status === "RINGING" || data.status === "DIALING") {
3194
+ if (audioRef.current) {
3195
+ audioRef.current.play().catch((error) => {
3196
+ console.error("Failed to play ringtone:", error);
3197
+ });
3198
+ }
3199
+ } else {
3200
+ if (audioRef.current) {
3201
+ audioRef.current.pause();
3202
+ audioRef.current.currentTime = 0;
3203
+ }
3204
+ }
3205
+ if (data.status === "ONCALL") {
3206
+ sdkStateManager.startCall();
3207
+ if (!showIframe) {
3208
+ setShowIframe(true);
3209
+ }
3210
+ }
3211
+ if (data.status === "WRAPUP") {
3212
+ sdkStateManager.endCall();
3213
+ }
3214
+ } catch (e) {
3215
+ console.log("\u{1F4E8} Raw message:", event.data);
3216
+ }
3217
+ };
3218
+ webSocketRef.current.onclose = (event) => {
3219
+ console.log("\u{1F50C} WebSocket connection closed", event.code, event.reason);
3220
+ if (pingIntervalRef.current) {
3221
+ clearInterval(pingIntervalRef.current);
3222
+ pingIntervalRef.current = null;
3223
+ }
3224
+ if (event.code !== 1e3 && reconnectAttemptsRef.current < maxReconnectAttempts) {
3225
+ reconnectAttemptsRef.current += 1;
3226
+ const delay = Math.min(
3227
+ baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3228
+ maxReconnectDelay
3229
+ );
3230
+ console.log(
3231
+ `\u{1F504} Attempting to reconnect WebSocket (attempt ${reconnectAttemptsRef.current}/${maxReconnectAttempts}) in ${delay}ms`
3232
+ );
3233
+ reconnectTimeoutRef.current = setTimeout(() => {
3234
+ connectWebSocket();
3235
+ }, delay);
3236
+ } else if (reconnectAttemptsRef.current >= maxReconnectAttempts) {
3237
+ console.error("\u274C Maximum reconnection attempts reached. Please refresh the page.");
3238
+ showToast("WebSocket connection failed. Please refresh the page.", "error");
3239
+ }
3240
+ };
3241
+ webSocketRef.current.onerror = (error) => {
3242
+ console.error("\u274C WebSocket error:", error);
3243
+ };
3244
+ } catch (error) {
3245
+ console.error("\u274C Failed to create WebSocket:", error);
3246
+ if (reconnectAttemptsRef.current < maxReconnectAttempts) {
3247
+ reconnectAttemptsRef.current += 1;
3248
+ const delay = Math.min(
3249
+ baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3250
+ maxReconnectDelay
3251
+ );
3252
+ reconnectTimeoutRef.current = setTimeout(() => {
3253
+ connectWebSocket();
3254
+ }, delay);
3255
+ }
3256
+ }
3257
+ };
3258
+ (0, import_react11.useEffect)(() => {
3259
+ if (state.agentId) {
3260
+ connectWebSocket();
3261
+ }
3262
+ return () => {
3263
+ if (reconnectTimeoutRef.current) {
3264
+ clearTimeout(reconnectTimeoutRef.current);
3265
+ reconnectTimeoutRef.current = null;
3266
+ }
3267
+ if (pingIntervalRef.current) {
3268
+ clearInterval(pingIntervalRef.current);
3269
+ pingIntervalRef.current = null;
3270
+ }
3271
+ if (webSocketRef.current) {
3272
+ webSocketRef.current.close(1e3, "Component unmounting");
3273
+ webSocketRef.current = null;
3274
+ }
3275
+ reconnectAttemptsRef.current = 0;
3276
+ };
3277
+ }, [state.agentId]);
3278
+ if (!state.isInitialized || !state.process) {
3279
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: Boolean(openProcessorDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3280
+ ProcessorListDialog,
3281
+ {
3282
+ processList,
3283
+ open: openProcessorDialog,
3284
+ setOpen: setOpenProcessorDialog,
3285
+ handleSelectedProcessor: (data) => {
3286
+ sdkStateManager.setProcess(data);
3287
+ }
3288
+ }
3289
+ ) });
3290
+ }
3291
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
3292
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3293
+ import_material4.Fade,
3294
+ {
3295
+ in: true,
3296
+ timeout: 300,
3297
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3298
+ import_material4.Paper,
3299
+ {
3300
+ ref: ((_d = state.sdkConfig) == null ? void 0 : _d.isDraggable) ? dragRef : null,
3301
+ elevation: isDragging ? 4 : ((_e = state.sdkConfig) == null ? void 0 : _e.isDraggable) ? 1 : 0,
3302
+ sx: {
3303
+ position: ((_f = state.sdkConfig) == null ? void 0 : _f.isDraggable) ? "fixed" : "relative",
3304
+ left: ((_g = state.sdkConfig) == null ? void 0 : _g.isDraggable) ? position.x : "auto",
3305
+ top: ((_h = state.sdkConfig) == null ? void 0 : _h.isDraggable) ? position.y : "auto",
3306
+ display: "inline-block",
3307
+ width: "auto",
3308
+ flexShrink: 0,
3309
+ whiteSpace: "nowrap",
3310
+ p: 0.5,
3311
+ borderRadius: 3,
3312
+ bgcolor: "background.paper",
3313
+ zIndex: ((_i = state.sdkConfig) == null ? void 0 : _i.isDraggable) ? Number.MAX_SAFE_INTEGER : 0,
3314
+ transition: theme.transitions.create(["box-shadow", "transform"], {
3315
+ duration: theme.transitions.duration.short
3316
+ }),
3317
+ userSelect: "none"
3318
+ },
3319
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3320
+ import_material4.Box,
3321
+ {
3322
+ sx: {
3323
+ display: "flex",
3324
+ alignItems: "center"
3325
+ },
3326
+ children: [
3327
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3328
+ import_material4.Box,
3329
+ {
3330
+ sx: {
3331
+ display: "flex",
3332
+ alignItems: "center",
3333
+ gap: 1,
3334
+ margin: "0px 10px"
3335
+ },
3336
+ children: [
3337
+ ((_j = state.sdkConfig) == null ? void 0 : _j.isDraggable) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3338
+ import_material4.IconButton,
3339
+ {
3340
+ component: "div",
3341
+ size: "small",
3342
+ sx: {
3343
+ cursor: "all-scroll"
3344
+ },
3345
+ onMouseDown: handleMouseDown,
3346
+ onTouchStart: handleTouchStart,
3347
+ children: [
3348
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.DragIndicator, {}),
3349
+ " "
3350
+ ]
3351
+ }
3352
+ ),
3353
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: !((_k = state.sdkConfig) == null ? void 0 : _k.disabledDialButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Dial", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3354
+ import_material4.IconButton,
3355
+ {
3356
+ size: "small",
3357
+ onClick: (e) => {
3358
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
3359
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) !== "ONCALL" && ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) !== "BREAK" && ((_f2 = (_e2 = state.callData) == null ? void 0 : _e2.status) == null ? void 0 : _f2.toUpperCase()) !== "RINGING" && ((_h2 = (_g2 = state.callData) == null ? void 0 : _g2.status) == null ? void 0 : _h2.toUpperCase()) !== "WRAPUP") {
3360
+ handleOpenDialer(e);
3361
+ }
3362
+ },
3363
+ sx: {
3364
+ bgcolor: "action.hover",
3365
+ "&:hover": {
3366
+ bgcolor: "warning"
3367
+ }
3368
+ },
3369
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3370
+ import_icons_material2.WifiCalling3,
3371
+ {
3372
+ sx: {
3373
+ color: ((_m = (_l = state.callData) == null ? void 0 : _l.status) == null ? void 0 : _m.toUpperCase()) === "ONCALL" || ((_o = (_n = state.callData) == null ? void 0 : _n.status) == null ? void 0 : _o.toUpperCase()) === "BREAK" || ((_q = (_p = state.callData) == null ? void 0 : _p.status) == null ? void 0 : _q.toUpperCase()) === "RINGING" || ((_s = (_r = state.callData) == null ? void 0 : _r.status) == null ? void 0 : _s.toUpperCase()) === "WRAPUP" ? "action.selected" : "success.main"
3374
+ }
3375
+ }
3376
+ )
3377
+ }
3378
+ ) }) }),
3379
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3380
+ import_material4.Typography,
3381
+ {
3382
+ sx: {
3383
+ color: "success.main",
3384
+ width: "40px",
3385
+ marginRight: "10px",
3386
+ fontSize: "18px",
3387
+ fontWeight: "600"
3388
+ },
3389
+ children: formatDuration(callDuration)
3390
+ }
3391
+ ),
3392
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3393
+ import_material4.Chip,
3394
+ {
3395
+ sx: {
3396
+ padding: "18px 0px"
3397
+ },
3398
+ label: isLoading || agentReadyLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3399
+ import_material4.Box,
3400
+ {
3401
+ sx: {
3402
+ fontWeight: "bold",
3403
+ width: "60px",
3404
+ display: "flex",
3405
+ alignItems: "center",
3406
+ justifyContent: "center"
3407
+ },
3408
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.CircularProgress, { size: "20px" })
3409
+ }
3410
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3411
+ import_material4.Typography,
3412
+ {
3413
+ variant: "body2",
3414
+ sx: {
3415
+ fontWeight: "bold",
3416
+ width: "60px",
3417
+ textAlign: "center"
3418
+ },
3419
+ children: (_v = (_u = (_t = state.callData) == null ? void 0 : _t.status) == null ? void 0 : _u.toUpperCase()) != null ? _v : "N/A"
3420
+ }
3421
+ ),
3422
+ onClick: handleOpenAgentStatus,
3423
+ deleteIcon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.KeyboardArrowDown, { color: "primary" }),
3424
+ onDelete: handleOpenAgentStatus
3425
+ }
3426
+ )
3427
+ ]
3428
+ }
3429
+ ),
3430
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3431
+ import_material4.Box,
3432
+ {
3433
+ sx: {
3434
+ display: "flex",
3435
+ gap: 1,
3436
+ justifyContent: "center",
3437
+ alignItems: "center"
3438
+ },
3439
+ children: [
3440
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Agent Ready", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3441
+ import_material4.Button,
3442
+ {
3443
+ variant: ((_x = (_w = state.callData) == null ? void 0 : _w.status) == null ? void 0 : _x.toUpperCase()) === "BREAK" || ((_z = (_y = state.callData) == null ? void 0 : _y.status) == null ? void 0 : _z.toUpperCase()) === "MISSED" ? "outlined" : "contained",
3444
+ onClick: (e) => {
3445
+ var _a3, _b2, _c2, _d2;
3446
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "BREAK" || ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) === "MISSED") {
3447
+ e.stopPropagation();
3448
+ handleAgentReady();
3449
+ }
3450
+ },
3451
+ classes: {
3452
+ root: ((_B = (_A = state.callData) == null ? void 0 : _A.status) == null ? void 0 : _B.toUpperCase()) === "BREAK" || ((_D = (_C = state.callData) == null ? void 0 : _C.status) == null ? void 0 : _D.toUpperCase()) === "MISSED" ? "outlined" : "enabled"
3453
+ },
3454
+ sx: __spreadValues({}, ((_F = (_E = state.callData) == null ? void 0 : _E.status) == null ? void 0 : _F.toUpperCase()) === "BREAK" || ((_H = (_G = state.callData) == null ? void 0 : _G.status) == null ? void 0 : _H.toUpperCase()) === "MISSED" ? outlined : enabled),
3455
+ disabled: agentReadyLoading,
3456
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.SupportAgent, {})
3457
+ }
3458
+ ) }),
3459
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: ((_I = state.callData) == null ? void 0 : _I.hold) === 1 ? "Resume" : "Hold", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3460
+ import_material4.Button,
3461
+ {
3462
+ variant: ((_J = state.callData) == null ? void 0 : _J.hold) === 1 && ((_L = (_K = state.callData) == null ? void 0 : _K.status) == null ? void 0 : _L.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
3463
+ onClick: (e) => {
3464
+ e.stopPropagation();
3465
+ handleHoldToggle();
3466
+ },
3467
+ sx: ((_M = state.callData) == null ? void 0 : _M.hold) === 1 && ((_O = (_N = state.callData) == null ? void 0 : _N.status) == null ? void 0 : _O.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_Q = (_P = state.callData) == null ? void 0 : _P.status) == null ? void 0 : _Q.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3468
+ disabled: ((_S = (_R = state.callData) == null ? void 0 : _R.status) == null ? void 0 : _S.toUpperCase()) !== "ONCALL" && ((_T = state.callData) == null ? void 0 : _T.hold) !== 1 || holdOrUnHoldLoading,
3469
+ children: holdOrUnHoldLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3470
+ import_material4.CircularProgress,
3471
+ {
3472
+ size: "20px",
3473
+ sx: {
3474
+ color: theme.palette.primary.main
3475
+ }
3476
+ }
3477
+ ) : ((_U = state.callData) == null ? void 0 : _U.hold) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Pause, {})
3478
+ }
3479
+ ) }),
3480
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: ((_V = state.callData) == null ? void 0 : _V.mute) === 1 ? "Unmute" : "Mute", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3481
+ import_material4.Button,
3482
+ {
3483
+ variant: state.isHolding ? "outlined" : ((_W = state.callData) == null ? void 0 : _W.mute) === 1 && ((_Y = (_X = state.callData) == null ? void 0 : _X.status) == null ? void 0 : _Y.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
3484
+ onClick: (e) => {
3485
+ e.stopPropagation();
3486
+ handleMuteToggle();
3487
+ },
3488
+ sx: ((_Z = state.callData) == null ? void 0 : _Z.hold) === 1 ? __spreadValues({}, disabled) : ((__ = state.callData) == null ? void 0 : __.mute) === 1 && ((_aa = (_$ = state.callData) == null ? void 0 : _$.status) == null ? void 0 : _aa.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_ca = (_ba = state.callData) == null ? void 0 : _ba.status) == null ? void 0 : _ca.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3489
+ disabled: ((_ea = (_da = state.callData) == null ? void 0 : _da.status) == null ? void 0 : _ea.toUpperCase()) !== "ONCALL" && ((_fa = state.callData) == null ? void 0 : _fa.mute) !== 1 || muteOrUnMuteLoading || ((_ga = state.callData) == null ? void 0 : _ga.hold) === 1,
3490
+ children: muteOrUnMuteLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3491
+ import_material4.CircularProgress,
3492
+ {
3493
+ size: "20px",
3494
+ sx: {
3495
+ color: theme.palette.primary.main
3496
+ }
3497
+ }
3498
+ ) : ((_ha = state.callData) == null ? void 0 : _ha.mute) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.MicOff, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Mic, {})
3499
+ }
3500
+ ) }),
3501
+ !((_ia = state.sdkConfig) == null ? void 0 : _ia.disableCallTransferButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Transfer Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3502
+ import_material4.Button,
3503
+ {
3504
+ variant: state.openCallTransferDialog ? "contained" : "outlined",
3505
+ onClick: (e) => {
3506
+ var _a3, _b2;
3507
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL") {
3508
+ e.stopPropagation();
3509
+ sdkStateManager.setOpenCallTransferDialog(true);
3510
+ }
3511
+ },
3512
+ sx: state.openCallTransferDialog ? __spreadValues({}, enabled) : ((_ka = (_ja = state.callData) == null ? void 0 : _ja.status) == null ? void 0 : _ka.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3513
+ disabled: ((_ma = (_la = state.callData) == null ? void 0 : _la.status) == null ? void 0 : _ma.toUpperCase()) !== "ONCALL",
3514
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.TransferWithinAStation, {})
3515
+ }
3516
+ ) }),
3517
+ !((_na = state.sdkConfig) == null ? void 0 : _na.disableConferenceButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Conference Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3518
+ import_material4.Button,
3519
+ {
3520
+ variant: state.openConferenceDialog ? "contained" : "outlined",
3521
+ onClick: (e) => {
3522
+ var _a3, _b2;
3523
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL") {
3524
+ e.stopPropagation();
3525
+ sdkStateManager.setOpenConferenceDialog(true);
3526
+ }
3527
+ },
3528
+ sx: state.openConferenceDialog ? __spreadValues({}, enabled) : ((_pa = (_oa = state.callData) == null ? void 0 : _oa.status) == null ? void 0 : _pa.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3529
+ disabled: ((_ra = (_qa = state.callData) == null ? void 0 : _qa.status) == null ? void 0 : _ra.toUpperCase()) !== "ONCALL",
3530
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Group, {})
3531
+ }
3532
+ ) }),
3533
+ !((_sa = state.sdkConfig) == null ? void 0 : _sa.disableEndCallButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "End Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3534
+ import_material4.Button,
3535
+ {
3536
+ variant: ((_ua = (_ta = state.callData) == null ? void 0 : _ta.status) == null ? void 0 : _ua.toUpperCase()) === "ONCALL" || ((_wa = (_va = state.callData) == null ? void 0 : _va.status) == null ? void 0 : _wa.toUpperCase()) === "RINGING" || ((_ya = (_xa = state.callData) == null ? void 0 : _xa.status) == null ? void 0 : _ya.toUpperCase()) === "WRAPUP" ? "contained" : "outlined",
3537
+ onClick: (e) => {
3538
+ var _a3, _b2, _c2, _d2, _e2, _f2;
3539
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" || ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) === "RINGING" || ((_f2 = (_e2 = state.callData) == null ? void 0 : _e2.status) == null ? void 0 : _f2.toUpperCase()) === "WRAPUP") {
3540
+ e.stopPropagation();
3541
+ setOpenCallDisposition(true);
3542
+ }
3543
+ },
3544
+ sx: ((_Aa = (_za = state.callData) == null ? void 0 : _za.status) == null ? void 0 : _Aa.toUpperCase()) === "ONCALL" || ((_Ca = (_Ba = state.callData) == null ? void 0 : _Ba.status) == null ? void 0 : _Ca.toUpperCase()) === "RINGING" || ((_Ea = (_Da = state.callData) == null ? void 0 : _Da.status) == null ? void 0 : _Ea.toUpperCase()) === "WRAPUP" ? __spreadProps(__spreadValues({}, enabled), {
3545
+ borderRight: "1px",
3546
+ backgroundColor: "error.main",
3547
+ minWidth: "60px !important",
3548
+ boxShadow: " 0px 2px 1px #5f3f3f",
3549
+ border: `1px solid ${theme.palette.error.light}`,
3550
+ height: "40px",
3551
+ "&:hover": {
3552
+ bgcolor: "error.light",
3553
+ boxShadow: " 0px 2px 1px #5f3f3f",
3554
+ border: `0px solid ${theme.palette.error.light}`
3555
+ },
3556
+ "&:active": {
3557
+ bgcolor: "error.light",
3558
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
3559
+ }
3560
+ }) : __spreadProps(__spreadValues({}, disabled), {
3561
+ minWidth: "60px !important"
3562
+ }),
3563
+ disabled: ((_Ga = (_Fa = state.callData) == null ? void 0 : _Fa.status) == null ? void 0 : _Ga.toUpperCase()) !== "ONCALL" && ((_Ia = (_Ha = state.callData) == null ? void 0 : _Ha.status) == null ? void 0 : _Ia.toUpperCase()) !== "RINGING" && ((_Ka = (_Ja = state.callData) == null ? void 0 : _Ja.status) == null ? void 0 : _Ka.toUpperCase()) !== "WRAPUP" || endCallLoading,
3564
+ children: endCallLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3565
+ import_material4.CircularProgress,
3566
+ {
3567
+ size: "20px",
3568
+ color: "error"
3569
+ }
3570
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.CallEnd, {})
3571
+ }
3572
+ ) })
3573
+ ]
3574
+ }
3575
+ )
3576
+ ]
3577
+ }
3578
+ )
3579
+ }
3580
+ )
3581
+ }
3582
+ ) }),
3583
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3584
+ import_material4.Fade,
3585
+ {
3586
+ in: true,
3587
+ timeout: 300,
3588
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3589
+ import_material4.Paper,
3590
+ {
3591
+ ref: iframeDragRef,
3592
+ elevation: iframeIsDragging ? 4 : 1,
3593
+ sx: {
3594
+ position: "absolute",
3595
+ left: iframePosition.x,
3596
+ top: iframePosition.y,
3597
+ borderRadius: 2,
3598
+ bgcolor: "background.paper",
3599
+ zIndex: Number.MAX_SAFE_INTEGER,
3600
+ transition: theme.transitions.create(["box-shadow", "transform"], {
3601
+ duration: theme.transitions.duration.short
3602
+ }),
3603
+ visibility: showIframe && !((_La = state.sdkConfig) == null ? void 0 : _La.disableSoftPhone) ? "visible" : "hidden",
3604
+ userSelect: "none"
3605
+ },
3606
+ children: [
3607
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3608
+ import_material4.Box,
3609
+ {
3610
+ sx: {
3611
+ display: "flex",
3612
+ alignItems: "center",
3613
+ justifyContent: "space-between",
3614
+ cursor: "all-scroll",
3615
+ padding: "0px 10px"
3616
+ },
3617
+ onMouseDown: iframeHandleMouseDown,
3618
+ onTouchStart: iframeHandleTouchStart,
3619
+ children: [
3620
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3621
+ import_icons_material2.DragIndicator,
3622
+ {
3623
+ sx: {
3624
+ transform: "rotate(90deg)",
3625
+ color: "#7b7b7b"
3626
+ }
3627
+ }
3628
+ ),
3629
+ " ",
3630
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.IconButton, { onClick: () => setShowIframe(false), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Close, {}) })
3631
+ ]
3632
+ }
3633
+ ),
3634
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3635
+ "iframe",
3636
+ {
3637
+ src: `https://${IP}/ConVoxCCS/iframe?agent_id=${state.agentId}&process_id=${(_Ma = state.process) == null ? void 0 : _Ma.process_id}`,
3638
+ height: 380,
3639
+ width: 420,
3640
+ allow: "camera; microphone; autoplay",
3641
+ style: {
3642
+ border: "none"
3643
+ }
3644
+ }
3645
+ ) })
3646
+ ]
3647
+ }
3648
+ )
3649
+ }
3650
+ ),
3651
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3652
+ import_material4.Menu,
3653
+ {
3654
+ anchorEl: dialerAnchorEl,
3655
+ open: Boolean(dialerAnchorEl),
3656
+ onClose: handleCloseDialer,
3657
+ onClick: (e) => e.stopPropagation(),
3658
+ sx: {
3659
+ zIndex: 99999
3660
+ },
3661
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3662
+ import_material4.Box,
3663
+ {
3664
+ sx: {
3665
+ all: "unset",
3666
+ padding: "10px",
3667
+ "&hover": {
3668
+ backgroundColor: "white"
3669
+ }
3670
+ },
3671
+ children: [
3672
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3673
+ import_material4.TextField,
3674
+ {
3675
+ size: "small",
3676
+ value: phoneNumber,
3677
+ placeholder: "Enter Mobile No.",
3678
+ onChange: (e) => {
3679
+ setPhoneNumber(e.target.value);
3680
+ }
3681
+ }
3682
+ ),
3683
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3684
+ import_material4.IconButton,
3685
+ {
3686
+ color: "info",
3687
+ onClick: () => {
3688
+ handleStartCall(phoneNumber);
3689
+ },
3690
+ children: clickToCallLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3691
+ import_material4.CircularProgress,
3692
+ {
3693
+ size: "20px",
3694
+ sx: {
3695
+ color: theme.palette.success.main
3696
+ }
3697
+ }
3698
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Phone, { color: "success" })
3699
+ }
3700
+ )
3701
+ ]
3702
+ }
3703
+ )
3704
+ }
3705
+ ),
3706
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3707
+ import_material4.Menu,
3708
+ {
3709
+ anchorEl: statusAnchorEl,
3710
+ open: Boolean(statusAnchorEl),
3711
+ onClose: handleCloseAgentStatus,
3712
+ onClick: (e) => e.stopPropagation(),
3713
+ sx: {
3714
+ zIndex: 99999
3715
+ },
3716
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" })
3717
+ }
3718
+ ),
3719
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3720
+ import_material4.Menu,
3721
+ {
3722
+ anchorEl,
3723
+ open: Boolean(anchorEl),
3724
+ onClose: handleCloseQueueCounts,
3725
+ onClick: (e) => e.stopPropagation(),
3726
+ sx: {
3727
+ zIndex: 99999
3728
+ },
3729
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3730
+ import_material4.Box,
3731
+ {
3732
+ sx: {
3733
+ display: "flex",
3734
+ justifyContent: "flex-start",
3735
+ flexDirection: "column",
3736
+ padding: "0px 10px",
3737
+ "&hover": {
3738
+ backgroundColor: "white"
3739
+ }
3740
+ },
3741
+ children: [
3742
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3743
+ import_material4.Chip,
3744
+ {
3745
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Layers, { color: "secondary" }),
3746
+ variant: "outlined",
3747
+ label: "Waiting - 25",
3748
+ sx: {
3749
+ margin: "4px 2px"
3750
+ }
3751
+ }
3752
+ ),
3753
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3754
+ import_material4.Chip,
3755
+ {
3756
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Pending, { color: "info" }),
3757
+ label: "Pending - 99+",
3758
+ variant: "outlined",
3759
+ sx: {
3760
+ margin: "4px 2px"
3761
+ }
3762
+ }
3763
+ ),
3764
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3765
+ import_material4.Chip,
3766
+ {
3767
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Upcoming, { color: "success" }),
3768
+ variant: "outlined",
3769
+ label: "Upcoming - 66",
3770
+ sx: {
3771
+ margin: "4px 2px"
3772
+ }
3773
+ }
3774
+ )
3775
+ ]
3776
+ }
3777
+ )
3778
+ }
3779
+ ),
3780
+ Boolean(state.openConferenceDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConferenceDialog, {}),
3781
+ Boolean(state.openCallTransferDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CallTransferDialog, { open: state.openCallTransferDialog }),
3782
+ Boolean(openCallDisposition) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3783
+ EndCallDispositionDialog,
3784
+ {
3785
+ open: openCallDisposition,
3786
+ setOpen: setOpenCallDisposition,
3787
+ onSubmitDisposition: handleEndCall
3788
+ }
3789
+ ),
3790
+ Boolean(openCallHistoryDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3791
+ CallHistoryDialog,
3792
+ {
3793
+ open: openCallHistoryDialog,
3794
+ setOpen: setOpenCallHistoryDialog
3795
+ }
3796
+ )
3797
+ ] });
3798
+ }
3799
+
3800
+ // call-control-sdk/lib/components/SDKProvider.tsx
3801
+ var import_react12 = require("react");
3802
+ var import_jsx_runtime4 = require("react/jsx-runtime");
3803
+ var SDKProvider = (0, import_react12.memo)(({ children }) => {
3804
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ToastProvider, { children });
3805
+ });
3806
+ SDKProvider.displayName = "SDKProvider";
3807
+
3808
+ // call-control-sdk/lib/components/callControlPanel.tsx
3809
+ var import_jsx_runtime5 = require("react/jsx-runtime");
3810
+ var CallControlPanel = (0, import_react13.memo)(({ onDataChange }) => {
3811
+ const handleDataChange = (0, import_react13.useCallback)(
3812
+ (data) => {
3813
+ try {
3814
+ if (onDataChange && typeof onDataChange === "function") {
3815
+ onDataChange(data);
3816
+ }
3817
+ } catch (error) {
3818
+ console.error("Error in CallControlPanel data change handler:", error);
3819
+ }
3820
+ },
3821
+ [onDataChange]
3822
+ );
3823
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SDKProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CallControls, { onDataChange: handleDataChange }) });
3824
+ });
3825
+ CallControlPanel.displayName = "CallControlPanel";
3826
+
3827
+ // call-control-sdk/index.ts
3828
+ async function initSDK({
3829
+ apiKey,
3830
+ tenantId,
3831
+ agentId,
3832
+ sdkConfig
3833
+ }) {
3834
+ if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
3835
+ throw new Error(
3836
+ "SDK initialization failed: API key is required and must be a non-empty string"
3837
+ );
3838
+ }
3839
+ if (!tenantId || typeof tenantId !== "string" || tenantId.trim().length === 0) {
3840
+ throw new Error(
3841
+ "SDK initialization failed: Tenant ID is required and must be a non-empty string"
3842
+ );
3843
+ }
3844
+ if (!agentId || typeof agentId !== "string" || agentId.trim().length === 0) {
3845
+ throw new Error(
3846
+ "SDK initialization failed: Agent ID is required and must be a non-empty string"
3847
+ );
3848
+ }
3849
+ try {
3850
+ const initResult = await eventTracker.init({
3851
+ apiKey: apiKey.trim(),
3852
+ tenantId: tenantId.trim(),
3853
+ agentId: agentId.trim(),
3854
+ baseUrl: BASE_URL
3855
+ });
3856
+ if (initResult) {
3857
+ console.log("SDK initialized successfully");
3858
+ sdkStateManager.initialize(
3859
+ apiKey.trim(),
3860
+ tenantId.trim(),
3861
+ agentId.trim(),
3862
+ sdkConfig,
3863
+ initResult
3864
+ );
3865
+ } else {
3866
+ console.error("SDK initialization failed: Event tracker initialization returned false");
3867
+ sdkStateManager.setInitCheck();
3868
+ throw new Error(
3869
+ "SDK initialization failed: Unable to establish connection with the CTI system"
3870
+ );
3871
+ }
3872
+ } catch (error) {
3873
+ console.error("SDK initialization error:", error);
3874
+ sdkStateManager.setInitCheck();
3875
+ if (error instanceof Error) {
3876
+ throw error;
3877
+ } else {
3878
+ throw new Error(`SDK initialization failed: ${String(error)}`);
3879
+ }
3880
+ }
3881
+ }
3882
+ function getSDKVersion() {
3883
+ return "6.x.x";
3884
+ }
3885
+ function isSDKInitialized() {
3886
+ return sdkStateManager.getState().isInitialized;
3887
+ }
3888
+ // Annotate the CommonJS export names for ESM import in node:
3889
+ 0 && (module.exports = {
3890
+ CallControlPanel,
3891
+ getSDKVersion,
3892
+ initSDK,
3893
+ isSDKInitialized,
3894
+ useClickToCall,
3895
+ useEndCall,
3896
+ useGetAuthorizationToken,
3897
+ useGetCallerData,
3898
+ useLogout
3899
+ });
2
3900
  //# sourceMappingURL=index.js.map