call-control-sdk 6.4.5-beta.4 → 6.4.5-beta.6

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,3747 @@
1
- "use strict";var bn=Object.create;var Pe=Object.defineProperty,hn=Object.defineProperties,Dn=Object.getOwnPropertyDescriptor,En=Object.getOwnPropertyDescriptors,Sn=Object.getOwnPropertyNames,Xo=Object.getOwnPropertySymbols,Tn=Object.getPrototypeOf,jo=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable;var ze=(t,o,e)=>o in t?Pe(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,p=(t,o)=>{for(var e in o||(o={}))jo.call(o,e)&&ze(t,e,o[e]);if(Xo)for(var e of Xo(o))Ln.call(o,e)&&ze(t,e,o[e]);return t},J=(t,o)=>hn(t,En(o));var yn=(t,o)=>{for(var e in o)Pe(t,e,{get:o[e],enumerable:!0})},Ko=(t,o,e,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Sn(o))!jo.call(t,i)&&i!==e&&Pe(t,i,{get:()=>o[i],enumerable:!(l=Dn(o,i))||l.enumerable});return t};var An=(t,o,e)=>(e=t!=null?bn(Tn(t)):{},Ko(o||!t||!t.__esModule?Pe(e,"default",{value:t,enumerable:!0}):e,t)),Pn=t=>Ko(Pe({},"__esModule",{value:!0}),t);var de=(t,o,e)=>ze(t,typeof o!="symbol"?o+"":o,e);var Wn={};yn(Wn,{CallControlPanel:()=>st,getSDKVersion:()=>jn,initSDK:()=>Xn,isSDKInitialized:()=>Kn,useClickToCall:()=>Vo,useEndCall:()=>Yo,useGetAuthorizationToken:()=>Zo,useGetCallerData:()=>zo,useLogout:()=>Go});module.exports=Pn(Wn);var Xe="uat-cti.aighospitals.com",w=`https://${Xe}:8095`,kn=`wss://${Xe}:8095`,q={v1:"/api/v1"},P={LOGIN:`${w}${q.v1}/cti/login?provider=convox`,READY_AGENT:`${w}${q.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${w}${q.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${w}${q.v1}/cti/calls?provider=convox`,HOLD_CALL:`${w}${q.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${w}${q.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${w}${q.v1}/cti/unmute-call?provider=convox`,END_CALL:`${w}${q.v1}/cti/calls/end?provider=convox`,LOGOUT:`${w}${q.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${w}${q.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${w}${q.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${w}${q.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${w}${q.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${w}${q.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${w}${q.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${w}${q.v1}/cti/users`,PROCESS_LIST:`${w}${q.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${w}${q.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${w}${q.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${w}${q.v1}/users/get_sentiment_analysis`},Wo={WS:`${kn}${q.v1}/cti/ws`},Re="call-control-sdk-state";var Ze=class{constructor(){de(this,"state");de(this,"listeners",[]);de(this,"STORAGE_KEY",Re);de(this,"apiKey");de(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 e=JSON.parse(o);this.state=J(p({},this.state),{agentId:e.agentId||"",authorization:e.authorization||void 0,process:e.process||null,openConferenceDialog:(e==null?void 0:e.openConferenceDialog)||!1,openCallTransferDialog:(e==null?void 0:e.openCallTransferDialog)||!1,isInitialized:e.isInitialized||!1,sdkConfig:e.sdkConfig||{disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,disabled:{},enabled:{},outlined:{}},isHolding:e.isHolding||!1,isMuted:e.isMuted||!1,status:e.status||"idle",callStartTime:e.callStartTime||null,controlPanelPosition:e.controlPanelPosition||{x:10,y:10},iframePosition:e.iframePosition||{x:10,y:80},callData:e.callData||{mobileNumber:"",callReferenceId:"",agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:e.conferenceLine&&Array.isArray(e.conferenceLine)&&e.conferenceLine.length>0?e.conferenceLine:this.state.conferenceLine})}}catch(o){console.warn("Failed to load SDK state from localStorage:",o)}}saveToStorage(){try{let o={agentId:this.state.agentId,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,e){if(!o||typeof o!="string"||o.trim().length===0)throw new Error("API key not available");if(!e||typeof e!="string"||e.trim().length===0)throw new Error("Tenant ID not available");this.apiKey=o.trim(),this.tenantId=e.trim()}initialize(o,e,l,i,s){if(this.validateCredentials(o,e),!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=s,this.state.sdkConfig=p({disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,disabled:{},enabled:{},outlined:{}},i),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return p({},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 e=this.listeners.indexOf(o);e>-1&&this.listeners.splice(e,1)}}setHolding(o){this.state.isHolding=o,this.saveToStorage(),this.notifyListeners()}setMuted(o){this.state.isMuted=o,this.saveToStorage(),this.notifyListeners()}setStatus(o){this.state.status=o,this.saveToStorage(),this.notifyListeners()}setProcess(o){this.state.process=o,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(o){this.state.controlPanelPosition=o,this.saveToStorage(),this.notifyListeners()}setIframePosition(o){this.state.iframePosition=o,this.saveToStorage(),this.notifyListeners()}startCall(){this.state.callStartTime=Date.now(),this.state.status="on call",this.saveToStorage(),this.notifyListeners()}endCall(){this.state.callStartTime=null,this.state.status="idle",this.state.isHolding=!1,this.state.isMuted=!1,this.saveToStorage(),this.notifyListeners()}setInitCheck(){this.state.isInitialized=!1,this.saveToStorage(),this.notifyListeners()}setOpenConferenceDialog(o){this.state.openConferenceDialog=o,this.saveToStorage(),this.notifyListeners()}setOpenCallTransferDialog(o){this.state.openCallTransferDialog=o,this.saveToStorage(),this.notifyListeners()}updateCallData(o){this.state.callData=p(p({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}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 e=(l=this.state.conferenceLine)==null?void 0:l.map(i=>i.line===o.line?o:i);this.state.conferenceLine=e,this.saveToStorage(),this.notifyListeners()}resetConferenceLines(){this.state.conferenceLine=this.getInitialState().conferenceLine,this.saveToStorage(),this.notifyListeners()}clearStorageAndReset(){try{localStorage.removeItem(this.STORAGE_KEY),this.state=this.getInitialState(),this.notifyListeners()}catch(o){console.warn("Failed to clear localStorage:",o)}}debugStorage(){try{let o=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",o),o&&console.log("Parsed localStorage data:",JSON.parse(o)),console.log("Current state:",this.state)}catch(o){console.error("Error debugging storage:",o)}}getConferenceLines(){return this.state.conferenceLine||[]}},x=new Ze;var et=class{constructor(){de(this,"config",null);de(this,"ticketId",null);de(this,"baseUrl","");de(this,"eventQueue",[]);de(this,"flushTimer",null)}async init(o){this.config=p({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},o),this.baseUrl=o.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let e=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),e}isInitialized(){return this.config!==null&&this.ticketId!==null}getConfig(){return this.config}getTicketId(){return this.ticketId}async createTicket(){if(!this.config)throw new Error("EventTracker not initialized");try{let o=await this.makeRequest("/api/v1/et/init",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({agentId:this.config.agentId,sessionId:this.config.sessionId})});if(!o.ok)throw x.setInitCheck(),new Error(`Failed to initialize: ${o.status} ${o.statusText}`);let e=await o.json();return this.ticketId=e.ticketId,this.config.autoTrack&&this.setupAutoTracking(),e}catch(o){throw console.error("EventTracker initialization failed:",o),o}}async logEvent(o,e){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",o);return}let l={eventType:o,eventData:e,timestamp:Date.now()};this.eventQueue.push(l),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift()}async makeRequest(o,e){var s;let l=`${this.baseUrl}${o}`,i=((s=this.config)==null?void 0:s.retryAttempts)||3;for(let u=1;u<=i;u++)try{return await fetch(l,e)}catch(c){if(u===i)throw c;let m=Math.min(1e3*Math.pow(2,u-1),1e4);await new Promise(f=>setTimeout(f,m))}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(i=>console.warn("Failed to track page visit:",i)),o.clicks!==!1&&document.addEventListener("click",i=>{var u;let s=i.target;(s.tagName==="BUTTON"||s.tagName==="A"||s.onclick||s.getAttribute("role")==="button"||s instanceof HTMLButtonElement&&s.type==="button")&&this.logEvent("click",{element:s.tagName,text:(u=s.textContent)==null?void 0:u.trim().substring(0,100),href:s.getAttribute("href"),id:s.id,className:s.className,role:s.getAttribute("role"),position:{x:i.clientX,y:i.clientY},timestamp:new Date().toISOString()}).catch(c=>console.warn("Failed to track click:",c))}),o.forms!==!1&&document.addEventListener("submit",i=>{let s=i.target,u=new FormData(s),c={};u.forEach((m,f)=>{c[f]=m.toString()}),this.logEvent("formSubmission",{formId:s.id,action:s.action,method:s.method,fields:Object.keys(c),fieldCount:Object.keys(c).length,timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track form submission:",m))}),o.inputs!==!1){let i;document.addEventListener("input",s=>{let u=s.target;(u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.tagName==="SELECT")&&(clearTimeout(i),i=setTimeout(()=>{var c;this.logEvent("fieldChange",{element:u.tagName,type:u.getAttribute("type"),name:u.getAttribute("name"),id:u.id,valueLength:((c=u.value)==null?void 0:c.length)||0,timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track field change:",m))},1e3))})}let e=Date.now();window.addEventListener("beforeunload",()=>{let i=Date.now()-e;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:i,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",i=>{this.logEvent("jsError",{message:i.message,filename:i.filename,lineno:i.lineno,colno:i.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",i=>{var s;this.logEvent("unhandledRejection",{reason:(s=i.reason)==null?void 0:s.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let i=window.performance.navigation,s=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:s.navigationStart,loadTime:s.loadEventEnd-s.navigationStart,domReady:s.domContentLoadedEventEnd-s.navigationStart,renderTime:s.loadEventEnd-s.domContentLoadedEventEnd,navigationType:i.type,redirectCount:i.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)}},tt=new et;typeof window!="undefined"&&(window.EventTracker=tt);var me=require("react");var qo=An(require("axios"));var Jo,vn=(Jo=x.getSdkAuthToken())!=null?Jo:"",In=6e4;function $n(){var t;return(t=x.getSdkAuthToken())!=null?t:""}function _n(){var o,e,l,i;let t=qo.default.create({baseURL:w,headers:{"Content-Type":"application/json",Accept:"application/json","x-tenant-id":(e=(o=x.getCredentials())==null?void 0:o.tenantId)!=null?e:"","x-api-key":(i=(l=x.getCredentials())==null?void 0:l.apiKey)!=null?i:"",Authorization:`${vn}`},timeout:In,withCredentials:!1});return t.interceptors.request.use(s=>{let u=$n();return u&&s.headers&&(s.headers.Authorization=`${u}`),s.metadata={startTime:new Date().getTime()},s},s=>(console.error("Request interceptor error:",s),Promise.reject(s))),t.interceptors.response.use(s=>{var m;let u=new Date().getTime(),c=(m=s.config.metadata)==null?void 0:m.startTime;return c&&console.log(`Request to ${s.config.url} took ${u-c}ms`),s},async s=>{var c;let u=s.config;return((c=s.response)==null?void 0:c.status)===401&&!u._retry&&(x.setInitCheck(),console.warn("Unauthorized request, attempting retry...")),s.response||(console.error("Network error:",s.message),s.message="Network error: Please check your internet connection"),s.response&&s.response.status>=500&&(console.error("Server error:",s.response.status,s.response.data),s.message="Server error: Please try again later"),Promise.reject(s)}),t}var Nn=_n(),ne=Nn;var Go=()=>{let[t,o]=(0,me.useState)(!1),[e,l]=(0,me.useState)(!1),[i,s]=(0,me.useState)(!1),[u,c]=(0,me.useState)(null),[m,f]=(0,me.useState)(null);return{logout:(0,me.useCallback)(async()=>{var h;let g=JSON.parse((h=localStorage.getItem(Re))!=null?h:"");o(!0);let C={action:"LOGOUTUSER",userId:g.agentId||""};return ne.post(P.LOGOUT,C).then(U=>(x.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(U==null?void 0:U.data),l(!0),U==null?void 0:U.data)).catch(U=>{var E;return s(!0),c(U),(E=U==null?void 0:U.response)==null?void 0:E.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:m}};var Ce=require("react");var Yo=()=>{let[t,o]=(0,Ce.useState)(!1),[e,l]=(0,Ce.useState)(!1),[i,s]=(0,Ce.useState)(!1),[u,c]=(0,Ce.useState)(null),[m,f]=(0,Ce.useState)(null);return{handleEndCall:(0,Ce.useCallback)(async g=>{var U,E,v,O,I,M,Q,z,X,$,S,y,Z,se,ie;let C=JSON.parse((U=localStorage.getItem(Re))!=null?U:"");o(!0);let h={action:"ENDCALL",userId:C==null?void 0:C.agentId,processid:(O=(v=(E=C==null?void 0:C.process)==null?void 0:E.process_id)==null?void 0:v.toString())!=null?O:"",process_name:(M=(I=C==null?void 0:C.process)==null?void 0:I.process_name)!=null?M:"",callreferenceid:(z=(Q=C==null?void 0:C.callData)==null?void 0:Q.convox_id)!=null?z:"",mobile_number:($=(X=C==null?void 0:C.callData)==null?void 0:X.phone_number)!=null?$:"",disposition:(S=g==null?void 0:g.disposition)!=null?S:"RES",set_followUp:(y=g==null?void 0:g.followUp)!=null?y:"N",callback_date:(Z=g==null?void 0:g.callbackDate)!=null?Z:"",callback_hrs:(se=g==null?void 0:g.callbackHrs)!=null?se:"",callback_mins:(ie=g==null?void 0:g.callbackMins)!=null?ie:"",endcall_type:"CLOSE"};return ne.post(P.END_CALL,h).then(D=>(x.endCall(),f(D==null?void 0:D.data),l(!0),D==null?void 0:D.data)).catch(D=>{var N;return s(!0),c(D),(N=D==null?void 0:D.response)==null?void 0:N.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:m}};var xe=require("react");var Vo=()=>{let[t,o]=(0,xe.useState)(!1),[e,l]=(0,xe.useState)(!1),[i,s]=(0,xe.useState)(!1),[u,c]=(0,xe.useState)(null),[m,f]=(0,xe.useState)(null);return{handleStartCall:(0,xe.useCallback)(async g=>{var h,U,E,v,O,I,M,Q,z;let C=JSON.parse((h=localStorage.getItem(Re))!=null?h:"");if(o(!0),((U=C==null?void 0:C.callData)==null?void 0:U.status)==="IDLE"){let X={action:"CALL",userId:C==null?void 0:C.agentId,phone_number:g==null?void 0:g.mobileNumber};return ne.post(P.CLICK_TO_CALL,X).then($=>(f($==null?void 0:$.data),l(!0),$==null?void 0:$.data)).catch($=>{var S;return s(!0),c($),(S=$==null?void 0:$.response)==null?void 0:S.data}).finally(()=>{o(!1)})}else if(((E=C==null?void 0:C.callData)==null?void 0:E.status)==="ONCALL"){let X=(O=(v=C==null?void 0:C.conferenceLine)==null?void 0:v.filter(S=>S.line!==1))==null?void 0:O.find(S=>S.status==="IDLE"&&!(S!=null&&S.isCallStart)),$={action:"EXTERNAL_CONFERENCE",operation:`CALL${X.line}`,line_used:String(X.line),thirdparty_no:g==null?void 0:g.mobileNumber,userid:(M=(I=C.callData)==null?void 0:I.agent_id)!=null?M:"",process:(z=(Q=C.callData)==null?void 0:Q.process_name)!=null?z:""};return ne.post(P.CONFERENCE_CALL,$).then(S=>(f(S==null?void 0:S.data),l(!0),x.setConferenceLine(J(p({},X),{isCallStart:!0,status:"ONCALL",phone:g==null?void 0:g.mobileNumber})),x.setOpenConferenceDialog(!0),S==null?void 0:S.data)).catch(S=>{var y;return s(!0),c(S),(y=S==null?void 0:S.response)==null?void 0:y.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:m}};var je=require("react");var zo=()=>{let{process_id:t,process_name:o,status:e,phone_number:l,agent_id:i,convox_id:s}=x.getState().callData,u={phone_number:l,status:e,callReferenceId:s,agent_id:i,process_id:t,process_name:o},[c,m]=(0,je.useState)(u);return(0,je.useEffect)(()=>x.subscribe(()=>{let{process_id:T,process_name:g,status:C,phone_number:h,agent_id:U,convox_id:E}=x.getState().callData;m({phone_number:h,status:C,callReferenceId:E,agent_id:U,process_id:T,process_name:g})}),[]),c};var Ke=require("react");var Zo=()=>{let[t,o]=(0,Ke.useState)(x.getSdkAuthToken());return(0,Ke.useEffect)(()=>x.subscribe(()=>{o(x.getSdkAuthToken())}),[]),t};var Ye=require("react");var L=require("@mui/icons-material"),R=require("@mui/material"),F=require("react");var pe=require("react");function ot(t,o){let[e,l]=(0,pe.useState)(t),[i,s]=(0,pe.useState)(!1),u=(0,pe.useRef)(),c=(0,pe.useRef)({x:0,y:0}),m=(0,pe.useRef)({x:0,y:0}),f=(0,pe.useCallback)(h=>{let U=u.current;if(!U)return;let E=U.getBoundingClientRect(),v=window.innerWidth,O=window.innerHeight,I={x:Math.max(0,Math.min(h.x,v-E.width)),y:Math.max(0,Math.min(h.y,O-E.height))};l(I),o==null||o(I)},[o]),T=(0,pe.useCallback)((h,U)=>{s(!0),c.current={x:h,y:U},m.current=e;let E=(M,Q)=>{let z=M-c.current.x,X=Q-c.current.y;f({x:m.current.x+z,y:m.current.y+X})},v=M=>{M.preventDefault(),E(M.clientX,M.clientY)},O=M=>{M.preventDefault();let Q=M.touches[0];Q&&E(Q.clientX,Q.clientY)},I=()=>{s(!1),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",I),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",I)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",I),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",I)},[e,f]),g=(0,pe.useCallback)(h=>{h.preventDefault(),T(h.clientX,h.clientY)},[T]),C=(0,pe.useCallback)(h=>{h.preventDefault();let U=h.touches[0];U&&T(U.clientX,U.clientY)},[T]);return{position:e,isDragging:i,dragRef:u,handleMouseDown:g,handleTouchStart:C}}var We=require("react");function De(){let[t,o]=(0,We.useState)(x.getState());return(0,We.useEffect)(()=>x.subscribe(()=>{o(x.getState())}),[]),t}var qe=require("react");var be=require("react"),Je=require("@mui/material"),ke=require("react/jsx-runtime"),en=(0,be.createContext)(void 0),he=()=>{let t=(0,be.useContext)(en);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},tn=({children:t})=>{let[o,e]=(0,be.useState)(!1),[l,i]=(0,be.useState)(""),[s,u]=(0,be.useState)("info"),c=(m,f="info")=>{i(m),u(f),e(!0)};return(0,ke.jsxs)(en.Provider,{value:{showToast:c},children:[t,(0,ke.jsx)(Je.Snackbar,{open:o,color:s,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,ke.jsx)(Je.Alert,{variant:"filled",severity:s,onClose:()=>e(!1),sx:{width:"100%"},children:l})})]})};var On={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},Mn=(t,o)=>{if(o.type==="isLoading")return J(p({},t),{isLoading:o.payload});if(o.type==="isSuccess")return J(p({},t),{isSuccess:!0,data:o.payload});if(o.type==="isError")return J(p({},t),{isError:!0,error:o.payload});if(o.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var ce=(t={})=>{let{onSuccess:o=null,onError:e=null,disabledSuccessToast:l=!1}=t,{showToast:i}=he(),[s,u]=(0,qe.useReducer)(Mn,On);return[(0,qe.useCallback)((m,f,T={})=>{u({type:"isLoading",payload:!0}),ne.post(m,f,T).then(g=>{var C;u({type:"isSuccess",payload:g.data}),o==null||o(g.data,f),l||i((C=g.data)==null?void 0:C.message,"success")}).catch(g=>{var h,U,E,v,O,I,M,Q,z,X,$,S;let C={status:(U=(h=g.response)==null?void 0:h.status)!=null?U:500,message:((v=(E=g.response)==null?void 0:E.data)==null?void 0:v.detail)||((I=(O=g.response)==null?void 0:O.data)==null?void 0:I.message)||g.message||"An unknown error occurred",data:(Q=(M=g.response)==null?void 0:M.data)!=null?Q:null,statusText:(X=(z=g.response)==null?void 0:z.statusText)!=null?X:"",code:($=g==null?void 0:g.code)!=null?$:"",name:(S=g==null?void 0:g.name)!=null?S:""};i(C.message,"error"),u({type:"isError",payload:C}),e==null||e(C,f)}).finally(()=>{u({type:"isLoading",payload:!1})})},[o,e,i]),s]};var k=require("@mui/icons-material"),a=require("@mui/material"),le=require("react");var on=require("@mui/material");var Bn=({disabled:t,enabled:o,outlined:e})=>{let l=(0,on.useTheme)();return{disabled:p({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",border:"1px solid rgb(206, 204, 204)",height:"40px","&:hover":{boxShadow:" 0px 2px 2px rgba(0, 0, 0, 0.79)",border:`1px solid ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},t),enabled:p({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${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:p({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}`}},e)}},Ge=Bn;var n=require("react/jsx-runtime"),Hn=({each:t,isMergeCall:o})=>{var S,y,Z,se,ie;let e=De(),{showToast:l}=he(),{disabled:i,enabled:s,outlined:u}=Ge({disabled:((S=e.sdkConfig)==null?void 0:S.disabled)||{},enabled:((y=e.sdkConfig)==null?void 0:y.enabled)||{},outlined:((Z=e.sdkConfig)==null?void 0:Z.outlined)||{}}),c=(0,a.useTheme)(),[m,f]=(0,le.useState)(!1),[T,g]=(0,le.useState)(!1),[C,h]=(0,le.useState)(!1),[U,E]=(0,le.useState)(!1),[v,O]=(0,le.useState)(!1),I=(D,N)=>{x.setConferenceLine(p(p({},D),N))},M=(D,N)=>{var W,G,Y,ee;let B=p(p({},D),N);f(!0);let K={action:"EXTERNAL_CONFERENCE",operation:`CALL${B.line}`,line_used:String(B.line),thirdparty_no:B.phone,userid:(G=(W=e.callData)==null?void 0:W.agent_id)!=null?G:"",process:(ee=(Y=e.callData)==null?void 0:Y.process_name)!=null?ee:""};ne.post(P.CONFERENCE_CALL,K).then(_=>{var A;l((A=_.data)==null?void 0:A.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(_=>{var j,V,te,oe;let A=((V=(j=_.response)==null?void 0:j.data)==null?void 0:V.detail)||((oe=(te=_.response)==null?void 0:te.data)==null?void 0:oe.message)||_.message||"An unknown error occurred";l(A,"error")}).finally(()=>{f(!1)})},Q=(D,N)=>{var W,G,Y,ee;let B=p(p({},D),N);g(!0);let K={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(B.line),thirdparty_no:B.phone,userid:(G=(W=e.callData)==null?void 0:W.agent_id)!=null?G:"",process:(ee=(Y=e.callData)==null?void 0:Y.process_name)!=null?ee:""};ne.post(P.CONFERENCE_CALL,K).then(_=>{var A;l((A=_.data)==null?void 0:A.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(_=>{var j,V,te,oe;let A=((V=(j=_.response)==null?void 0:j.data)==null?void 0:V.detail)||((oe=(te=_.response)==null?void 0:te.data)==null?void 0:oe.message)||_.message||"An unknown error occurred";l(A,"error")}).finally(()=>{g(!1)})},z=(D,N,B)=>{var G,Y,ee,_;let K=p(p({},D),N);h(!0);let W={action:"EXTERNAL_CONFERENCE",operation:B,hold_channel_no:B==="HOLDUSER"?`hold${K.line}`:`unhold${K.line}`,userid:(Y=(G=e.callData)==null?void 0:G.agent_id)!=null?Y:"",process:(_=(ee=e.callData)==null?void 0:ee.process_name)!=null?_:""};ne.post(P.CONFERENCE_CALL_HOLD_OR_UN_HOLD,W).then(A=>{var j;l((j=A.data)==null?void 0:j.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(A=>{var V,te,oe,ue;let j=((te=(V=A.response)==null?void 0:V.data)==null?void 0:te.detail)||((ue=(oe=A.response)==null?void 0:oe.data)==null?void 0:ue.message)||A.message||"An unknown error occurred";l(j,"error")}).finally(()=>{h(!1)})},X=(D,N,B)=>{var G,Y,ee,_;let K=p(p({},D),N);E(!0);let W={action:"EXTERNAL_CONFERENCE",operation:B,channel_no:B==="MUTEUSER"?`mute${K.line}`:`play${K.line}`,userid:(Y=(G=e.callData)==null?void 0:G.agent_id)!=null?Y:"",thirdparty_no:K.phone,process:(_=(ee=e.callData)==null?void 0:ee.process_name)!=null?_:""};ne.post(P.CONFERENCE_CALL_MUTE_OT_UN_MUTE,W).then(A=>{var j;l((j=A.data)==null?void 0:j.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(A=>{var V,te,oe,ue;let j=((te=(V=A.response)==null?void 0:V.data)==null?void 0:te.detail)||((ue=(oe=A.response)==null?void 0:oe.data)==null?void 0:ue.message)||A.message||"An unknown error occurred";l(j,"error")}).finally(()=>{E(!1)})},$=(D,N)=>{var W,G,Y,ee;let B=p(p({},D),N);O(!0);let K={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(B.line),user_type:`THIRDPARTY${B.line-1}`,thirdparty_no:B.phone,userid:(G=(W=e.callData)==null?void 0:W.agent_id)!=null?G:"",process:(ee=(Y=e.callData)==null?void 0:Y.process_name)!=null?ee:""};ne.post(P.CONFERENCE_CALL_END,K).then(_=>{var A;l((A=_.data)==null?void 0:A.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(_=>{var j,V,te,oe;let A=((V=(j=_.response)==null?void 0:j.data)==null?void 0:V.detail)||((oe=(te=_.response)==null?void 0:te.data)==null?void 0:oe.message)||_.message||"An unknown error occurred";l(A,"error")}).finally(()=>{O(!1)})};return(0,n.jsxs)(a.TableRow,{sx:{border:"2px solid #fff"},children:[(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsxs)(a.Typography,{children:["Line ",(se=t==null?void 0:t.line)!=null?se:"",". "]})}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(a.Typography,{variant:"body2",sx:{px:1,borderRadius:"10px"},children:(ie=t==null?void 0:t.status)!=null?ie:""})}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(a.Button,{sx:{textTransform:"capitalize"},size:"small",children:(0,n.jsx)(a.Typography,{variant:"body2",children:(t==null?void 0:t.line)===1?"Internal":"External"})})}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(a.TextField,{size:"small",placeholder:"Phone Number",fullWidth:!0,value:(t==null?void 0:t.phone)||"",disabled:(t==null?void 0:t.line)===1||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="CONFERENCE"||(t==null?void 0:t.status)==="HOLD"||(t==null?void 0:t.status)==="MUTE",onChange:D=>{I(t,{phone:D.target.value})}})}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsxs)(a.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[t.line!==1&&(0,n.jsx)(a.Tooltip,{title:"Call",children:(0,n.jsx)(a.Button,{variant:(t==null?void 0:t.status)!=="IDLE"?"outlined":"contained",color:"success",sx:(t==null?void 0:t.status)!=="IDLE"?p({},i):J(p({},s),{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:()=>{M(t,{})},disabled:(t==null?void 0:t.status)!=="IDLE",children:m?(0,n.jsx)(a.CircularProgress,{size:"20px",color:"success"}):(0,n.jsx)(k.Call,{sx:{color:(t==null?void 0:t.status)!=="IDLE"?"default":"#f3f2f2"}})})}),t.line===1&&(0,n.jsx)(a.Tooltip,{title:"Merge Call",children:(0,n.jsxs)(a.Button,{variant:o?"contained":"outlined",sx:o?J(p({},s),{padding:"0px 16px"}):J(p({},i),{padding:"0px 16px"}),onClick:()=>{Q(t,{isMergeCall:!0})},disabled:!o||T,children:[t!=null&&t.isMergeCall?"Merged":"Merge",T?(0,n.jsx)(a.CircularProgress,{size:"20px"}):(0,n.jsx)(k.CallSplit,{})]})}),(0,n.jsx)(a.Tooltip,{title:t.status!=="HOLD"?"Hold":"Un Hold",children:(0,n.jsx)(a.Button,{variant:t.status==="HOLD"?"contained":"outlined",sx:t.status==="DISCONNECTED"||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},i):(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},u):p({},i),onClick:()=>{t.status==="HOLD"?z(t,{isHold:!1},"UNHOLDUSER"):z(t,{isHold:!0},"HOLDUSER")},disabled:(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="IDLE"||C,children:C?(0,n.jsx)(a.CircularProgress,{size:"20px",sx:{color:c.palette.primary.main}}):t.status==="HOLD"?(0,n.jsx)(k.PlayArrow,{}):(0,n.jsx)(k.Pause,{})})}),(0,n.jsx)(a.Tooltip,{title:t.status!=="MUTE"?"Mute":"Un Mute",children:(0,n.jsx)(a.Button,{variant:t.status==="MUTE"?"contained":"outlined",sx:t.status==="DISCONNECTED"||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},i):(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},u):p({},i),onClick:()=>{t.status==="MUTE"?X(t,{isMute:!1},"PLAYUSER"):X(t,{isMute:!0},"MUTEUSER")},disabled:(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="HOLD"||U,children:U?(0,n.jsx)(a.CircularProgress,{size:"20px",sx:{color:c.palette.primary.main}}):t.status==="MUTE"?(0,n.jsx)(k.MicOff,{}):(0,n.jsx)(k.Mic,{})})}),(t==null?void 0:t.line)!==1?(0,n.jsx)(a.Tooltip,{title:"End Call",children:(0,n.jsx)(a.Button,{variant:(t==null?void 0:t.status)!=="IDLE"&&(t==null?void 0:t.status)!=="DISCONNECTED"?"contained":"outlined",color:"error",sx:(t==null?void 0:t.status)!=="IDLE"&&(t==null?void 0:t.status)!=="DISCONNECTED"?J(p({},s),{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}`}}):p({},i),onClick:()=>{$(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1})},disabled:(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="DISCONNECTED"||v,children:v?(0,n.jsx)(a.CircularProgress,{size:"20px",color:"error"}):(0,n.jsx)(k.CallEnd,{})})}):(0,n.jsx)(a.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",color:"error",sx:{display:"none"},onClick:()=>{$(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1})},disabled:(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="DISCONNECTED"||v,children:v?(0,n.jsx)(a.CircularProgress,{size:"20px",color:"error"}):(0,n.jsx)(k.CallEnd,{})})]})})]},t.line)};function nn(){var c;let t=De(),{showToast:o}=he(),[e,l]=(0,le.useState)(!1),i=()=>{x.setOpenConferenceDialog(!1)},s=()=>{var f,T,g,C;l(!0);let m={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(T=(f=t.callData)==null?void 0:f.agent_id)!=null?T:"",process:(C=(g=t.callData)==null?void 0:g.process_name)!=null?C:""};ne.post(P.CONFERENCE_CALL_END_ALL,m).then(h=>{var U;o((U=h.data)==null?void 0:U.message,"success"),x.resetConferenceLines(),i()}).catch(h=>{var E,v,O,I;let U=((v=(E=h.response)==null?void 0:E.data)==null?void 0:v.detail)||((I=(O=h.response)==null?void 0:O.data)==null?void 0:I.message)||h.message||"An unknown error occurred";o(U,"error")}).finally(()=>{l(!1)})},u=(0,le.useMemo)(()=>{var m;return(m=t==null?void 0:t.conferenceLine)==null?void 0:m.some(f=>f.line!==1?f.status==="ONCALL":!1)},[t.conferenceLine]);return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t.openConferenceDialog,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 16px"},children:[(0,n.jsxs)(a.Typography,{variant:"body1",children:[(c=t==null?void 0:t.agentId)!=null?c:""," conference"]}),(0,n.jsx)(a.IconButton,{onClick:i,children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(a.Box,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:(0,n.jsx)(a.TableContainer,{component:a.Paper,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:(0,n.jsxs)(a.Table,{sx:{border:"4px solid #ffffff !important"},children:[(0,n.jsx)(a.TableHead,{children:(0,n.jsxs)(a.TableRow,{sx:{border:"2px solid #f3f3f3ff !important"},children:[(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Line"}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Status"}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Call Type"}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Mobile Number"}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Call Actions"})]})}),(0,n.jsx)(a.TableBody,{children:t==null?void 0:t.conferenceLine.map(m=>(0,n.jsx)(Hn,{each:m,isMergeCall:u}))})]})})}),(0,n.jsx)(a.Box,{textAlign:"center",m:2,children:(0,n.jsxs)(a.Button,{variant:"outlined",color:"error",size:"large",onClick:s,disabled:e,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[e?(0,n.jsx)(a.CircularProgress,{size:"20px",color:"error",sx:{marginRight:"8px"}}):(0,n.jsx)(a.IconButton,{sx:{bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},marginRight:"8px",width:"28px",height:"28px",fontSize:"12px",fontWeight:"600",lineHeight:"16px",letterSpacing:"0.02em",textTransform:"capitalize",color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%"},children:(0,n.jsx)(k.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function an({open:t}){var h,U,E,v,O,I,M,Q,z,X,$,S;let o=De(),[e]=ce({onSuccess:()=>{x.setOpenCallTransferDialog(!1)}}),[l,i]=(0,le.useState)("process"),[s,{data:u,isLoading:c}]=ce({disabledSuccessToast:!0}),[m,{data:f,isLoading:T}]=ce({disabledSuccessToast:!0}),g=()=>{x.setOpenCallTransferDialog(!1)},C=(y,Z)=>{var se,ie,D,N,B,K,W,G,Y,ee,_,A,j,V,te,oe,ue,ve,Ie,$e,_e,Ee,Ne,Se,Oe,Te,Me,Be,He,Le,we,Fe,Qe;if(Z==="PROCESS"){let Ue={mobile_number:(ie=(se=o.callData)==null?void 0:se.phone_number)!=null?ie:"",userid:(N=(D=o.callData)==null?void 0:D.agent_id)!=null?N:"",type:"PROCESS",transfer_to:(B=y==null?void 0:y.process_name)!=null?B:"",callreferenceid:(W=(K=o.callData)==null?void 0:K.convox_id)!=null?W:"",processid:String((Y=(G=o.callData)==null?void 0:G.process_id)!=null?Y:""),process_name:(_=(ee=o.callData)==null?void 0:ee.process_name)!=null?_:""};e(P.TRANSFER_CALL,Ue)}else if(Z==="QUEUE"){let Ue={mobile_number:(j=(A=o.callData)==null?void 0:A.phone_number)!=null?j:"",userid:(te=(V=o.callData)==null?void 0:V.agent_id)!=null?te:"",type:"QUEUE",transfer_to:(oe=y==null?void 0:y.queue_name)!=null?oe:"",callreferenceid:(ve=(ue=o.callData)==null?void 0:ue.convox_id)!=null?ve:"",processid:String(($e=(Ie=o.callData)==null?void 0:Ie.process_id)!=null?$e:""),process_name:(Ee=(_e=o.callData)==null?void 0:_e.process_name)!=null?Ee:""};e(P.TRANSFER_CALL,Ue)}else if(Z==="AGENT"){let Ue={mobile_number:(Se=(Ne=o.callData)==null?void 0:Ne.phone_number)!=null?Se:"",userid:(Te=(Oe=o.callData)==null?void 0:Oe.agent_id)!=null?Te:"",type:"AGENT",transfer_to:(Me=y==null?void 0:y.user_id)!=null?Me:"",callreferenceid:(He=(Be=o.callData)==null?void 0:Be.convox_id)!=null?He:"",processid:String((we=(Le=o.callData)==null?void 0:Le.process_id)!=null?we:""),process_name:(Qe=(Fe=o.callData)==null?void 0:Fe.process_name)!=null?Qe:""};e(P.TRANSFER_CALL,Ue)}};return(0,le.useEffect)(()=>{s(P.AGENTS_LIST,{status:"IDLE",active:!0}),m(P.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(a.Typography,{variant:"body1",children:" Call Transfer"}),(0,n.jsx)(a.IconButton,{onClick:g,children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsxs)(a.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",gap:1},children:[(0,n.jsx)(a.Button,{variant:l==="process"?"contained":"outlined",onClick:()=>{i("process"),m(P.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Process"}),(0,n.jsx)(a.Button,{variant:l==="queues"?"contained":"outlined",onClick:()=>{i("queues"),m(P.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Queues"}),(0,n.jsx)(a.Button,{variant:l==="agents"?"contained":"outlined",onClick:()=>{i("agents"),s(P.AGENTS_LIST,{status:"IDLE",active:!0})},children:"Agents"})]}),(T||c)&&(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"80px"},children:[(0,n.jsx)(a.CircularProgress,{})," "]}),!T&&!c&&l==="process"&&(0,n.jsx)(a.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(h=f==null?void 0:f.data)!=null&&h.process&&((E=(U=f==null?void 0:f.data)==null?void 0:U.process)==null?void 0:E.length)>0?(O=(v=f==null?void 0:f.data)==null?void 0:v.process)==null?void 0:O.map((y,Z)=>(0,n.jsxs)(a.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)(a.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),y.process_name]}),(0,n.jsx)(a.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{C(y,"PROCESS")},children:(0,n.jsx)(k.Call,{})})]},Z)):(0,n.jsx)(a.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"})}),!T&&!c&&l==="queues"&&(0,n.jsx)(a.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(I=f==null?void 0:f.data)!=null&&I.queue&&((Q=(M=f==null?void 0:f.data)==null?void 0:M.queue)==null?void 0:Q.length)>0?(X=(z=f==null?void 0:f.data)==null?void 0:z.queue)==null?void 0:X.map((y,Z)=>{var se,ie,D,N,B,K;return(0,n.jsxs)(a.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)(a.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),y.queue_name,(D=(ie=(se=f==null?void 0:f.data)==null?void 0:se.process)==null?void 0:ie.find(W=>W.process_id===y.process_id))!=null&&D.process_name?(0,n.jsx)(a.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((K=(B=(N=f==null?void 0:f.data)==null?void 0:N.process)==null?void 0:B.find(W=>W.process_id===y.process_id))==null?void 0:K.process_name)+")"}):""]}),(0,n.jsx)(a.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{C(y,"QUEUE")},children:(0,n.jsx)(k.Call,{})})]},Z)}):(0,n.jsx)(a.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"})}),!T&&!c&&l==="agents"&&(0,n.jsx)(a.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:u!=null&&u.data&&(($=u==null?void 0:u.data)==null?void 0:$.length)>0?(S=u==null?void 0:u.data)==null?void 0:S.map((y,Z)=>(0,n.jsxs)(a.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)(a.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),y.name]}),(0,n.jsx)(a.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{C(y,"AGENT")},children:(0,n.jsx)(k.Call,{})})]},Z)):(0,n.jsx)(a.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:t,setOpen:o,onSubmitDisposition:e}){var T,g,C,h;let[l,i]=(0,le.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),s=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],u=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],c=(U,E)=>{i(v=>J(p({},v),{[U]:E}))},m=()=>{i({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{m(),o(!1)};return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsx)(a.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:(0,n.jsxs)(a.Typography,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),(0,n.jsxs)(a.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:[(0,n.jsxs)(a.Box,{display:"flex",gap:2,children:[(0,n.jsx)(a.Autocomplete,{value:l.disposition,options:s,getOptionLabel:U=>U.label,onChange:(U,E)=>c("disposition",E),size:"small",renderInput:U=>(0,n.jsx)(a.TextField,J(p({},U),{label:"Disposition",fullWidth:!0})),sx:{flex:1}}),(0,n.jsx)(a.Autocomplete,{options:u,getOptionLabel:U=>U.label,value:l.followUp,onChange:(U,E)=>c("followUp",E),size:"small",renderInput:U=>(0,n.jsx)(a.TextField,J(p({},U),{label:"Follow Up",fullWidth:!0})),sx:{flex:1}})]}),((g=(T=l==null?void 0:l.followUp)==null?void 0:T.label)==null?void 0:g.toLowerCase())==="yes"&&(0,n.jsxs)(a.Box,{display:"flex",gap:2,mt:2,children:[(0,n.jsx)(a.TextField,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:l.callbackDate,onChange:U=>c("callbackDate",U.target.value),fullWidth:!0,sx:{flex:1}}),(0,n.jsx)(a.TextField,{size:"small",label:"Hours (0-23)",type:"text",value:l.callbackHrs,onChange:U=>c("callbackHrs",U.target.value),fullWidth:!0,sx:{flex:1}})]}),((h=(C=l==null?void 0:l.followUp)==null?void 0:C.label)==null?void 0:h.toLowerCase())==="yes"&&(0,n.jsxs)(a.Box,{display:"flex",gap:2,mt:2,children:[(0,n.jsx)(a.TextField,{size:"small",label:"Minutes (0-59)",type:"text",value:l.callbackMins,onChange:U=>c("callbackMins",U.target.value),fullWidth:!0,sx:{flex:1}}),(0,n.jsx)(a.Box,{sx:{flex:1}})]})]}),(0,n.jsxs)(a.Box,{textAlign:"right",m:2,children:[(0,n.jsx)(a.Button,{variant:"outlined",color:"error",size:"large",onClick:f,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),(0,n.jsx)(a.Button,{variant:"contained",color:"primary",size:"large",onClick:()=>e(l),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function rn({open:t,setOpen:o,processList:e=null,handleSelectedProcessor:l}){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(a.Typography,{variant:"body1",children:" Process List"}),(0,n.jsx)(a.IconButton,{onClick:()=>{o(!1)},children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(a.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:e.length>0?e==null?void 0:e.map((s,u)=>(0,n.jsx)(a.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(s)},children:(0,n.jsxs)(a.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),s.process_name]})},u)):null})]})})})}function ln({open:t,setOpen:o}){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(a.Typography,{variant:"body1",children:" Call History"}),(0,n.jsx)(a.IconButton,{onClick:()=>{o(!1)},children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(a.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}var dn="./incoming-4WP3FJI4-4WP3FJI4.mp3";var d=require("react/jsx-runtime"),Fn=(t,o,e)=>t.map(i=>{var s,u,c;if((i==null?void 0:i.line)===1){let m=`line_${i.line}_status`;return J(p({},i),{line:1,status:(s=o[m])!=null?s:e==null?void 0:e.status,phone:(u=e==null?void 0:e.phone_number)!=null?u:""})}else{let m=`line_${i.line}_status`,f=`line_${i.line}_phonenumber`;return J(p({},i),{status:(c=o[m])!=null?c:"IDLE",phone:o[f]!=="0"?o[f]:""})}}),Qn=t=>{let o=Math.floor(t/60),e=t%60;return`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`};function pn({onDataChange:t}){var it,rt,lt,dt,pt,ct,ut,gt,ft,Ut,Rt,mt,Ct,xt,bt,ht,Dt,Et,St,Tt,Lt,yt,At,Pt,kt,vt,It,$t,_t,Nt,Ot,Mt,Bt,Ht,wt,Ft,Qt,Xt,jt,Kt,Wt,Jt,qt,Gt,Yt,Vt,zt,Zt,eo,to,oo,no,ao,so,io,ro,lo,po,co,uo,go,fo,Uo,Ro,mo,Co,xo,bo,ho,Do,Eo,So,To,Lo,yo,Ao,Po,ko,vo,Io,$o;let o=(0,R.useTheme)(),e=De(),{showToast:l}=he(),{disabled:i,enabled:s,outlined:u}=Ge({disabled:((it=e.sdkConfig)==null?void 0:it.disabled)||{},enabled:((rt=e.sdkConfig)==null?void 0:rt.enabled)||{},outlined:((lt=e.sdkConfig)==null?void 0:lt.outlined)||{}}),c=(0,F.useRef)(null),m=(0,F.useRef)(null),f=(0,F.useRef)(null),T=(0,F.useRef)(null),g=(0,F.useRef)(0),C=60,h=1e3,U=3e4,[E,v]=(0,F.useState)(null),[O,I]=(0,F.useState)(!0),[M,Q]=(0,F.useState)(null),[z,X]=(0,F.useState)(null),[$,S]=(0,F.useState)(!1),[y,Z]=(0,F.useState)(!1),[se,ie]=(0,F.useState)(!1),[D,N]=(0,F.useState)(null),[B,K]=(0,F.useState)(""),[W,G]=(0,F.useState)(0),{position:Y,isDragging:ee,dragRef:_,handleMouseDown:A,handleTouchStart:j}=ot(e.controlPanelPosition,r=>x.setControlPanelPosition(r)),{position:V,isDragging:te,dragRef:oe,handleMouseDown:ue,handleTouchStart:ve}=ot(e.iframePosition,r=>x.setIframePosition(r)),[Ie,{isLoading:$e}]=ce({onSuccess:()=>{K(""),X(null)}}),[_e,{isLoading:Ee}]=ce({onSuccess:()=>{x.setHolding(!e.isHolding)},onError:r=>{console.log("\u274C Hold operation error:",r)}}),[Ne,{isLoading:Se}]=ce({onSuccess:()=>{x.setMuted(!e.isMuted)},onError:r=>{console.log("\u274C Mute operation error:",r)}}),[Oe,{isLoading:Te}]=ce(),[Me,{isLoading:Be}]=ce(),[He,{isLoading:Le}]=ce(),we=()=>{v(null)},Fe=r=>{I(!0),X(r.currentTarget),x.setStatus("dial")},Qe=()=>{e.status!=="on call"&&x.setStatus("idle"),X(null)},Ue=r=>{Q(r.currentTarget)},gn=()=>{Q(null)},fn=()=>{let r={action:"READYAGENT",userId:e.agentId};Oe(P.READY_AGENT,r)},Un=r=>{Q(null);let b={action:"AGENTBREAK",break_type:r,userId:e.agentId};Me(P.UPDATE_AGENT_BREAK,b)},Rn=r=>{if(r.length!==10)l("Invalid phone number","error");else if(!/^\d+$/.test(r))l("Invalid phone number","error");else{let b={action:"CALL",phone_number:r,userId:e.agentId};Ie(P.CLICK_TO_CALL,b)}},mn=()=>{let r={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};_e(P.HOLD_CALL,r)},Cn=()=>{let r={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};Ne(P.MUTE_CALL,r)},xn=r=>{var H,ae,re,ge,fe,ye,Ae,_o,No,Oo,Mo,Bo,Ho,wo,Fo,Qo;let b={action:"ENDCALL",userId:e.agentId,processid:(re=(ae=(H=e.process)==null?void 0:H.process_id)==null?void 0:ae.toString())!=null?re:"",process_name:(fe=(ge=e.process)==null?void 0:ge.process_name)!=null?fe:"",callreferenceid:(Ae=(ye=e.callData)==null?void 0:ye.convox_id)!=null?Ae:"",mobile_number:(No=(_o=e.callData)==null?void 0:_o.phone_number)!=null?No:"",disposition:(Mo=(Oo=r==null?void 0:r.disposition)==null?void 0:Oo.value)!=null?Mo:"",set_followUp:(Ho=(Bo=r==null?void 0:r.followUp)==null?void 0:Bo.value)!=null?Ho:"",callback_date:(wo=r==null?void 0:r.callbackDate)!=null?wo:"",callback_hrs:(Fo=r==null?void 0:r.callbackHrs)!=null?Fo:"",callback_mins:(Qo=r==null?void 0:r.callbackMins)!=null?Qo:"",endcall_type:"CLOSE"};K(""),He(P.END_CALL,b),x.endCall(),S(!1)};(0,F.useEffect)(()=>{let r=b=>{b.preventDefault()};return window.addEventListener("beforeunload",r),()=>{window.removeEventListener("beforeunload",r)}},[]),(0,F.useEffect)(()=>{let r;return e.callData.status&&e.callData.status==="ONCALL"?r=setInterval(()=>{let b=Math.floor((Date.now()-e.callStartTime)/1e3);G(b)},1e3):G(0),()=>{r&&clearInterval(r)}},[e.callData.status]),(0,F.useEffect)(()=>(m.current=new Audio(dn),m.current.loop=!0,m.current.volume=.7,()=>{m.current&&(m.current.pause(),m.current.currentTime=0,m.current=null)}),[]),(0,F.useEffect)(()=>{if(t&&e.callData){let{process_id:r,process_name:b,status:H,phone_number:ae,agent_id:re,convox_id:ge}=e.callData;t({phone_number:ae,status:H,callReferenceId:ge,agent_id:re,process_id:r,process_name:b})}},[e.callData,t]),(0,F.useEffect)(()=>{e.agentId?ne.post(P.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}).then(r=>{var b,H;r&&r.data&&((b=r==null?void 0:r.data)==null?void 0:b.length)>1?(N(r.data.data),Z(!0)):(x.setProcess((H=r==null?void 0:r.data)==null?void 0:H.data[0]),Z(!1))}).catch(r=>{l(r.response.data.message,"error")}):console.log("No agentId available, skipping API call")},[e.agentId]);let Ve=()=>{if(!e.agentId){console.log("No agentId available, cannot connect WebSocket");return}f.current&&(clearTimeout(f.current),f.current=null);try{c.current=new WebSocket(`${Wo.WS}?agent_id=${e.agentId}`),c.current.onopen=()=>{console.log("\u{1F310} WebSocket connection established"),g.current=0,T.current&&clearInterval(T.current),T.current=setInterval(()=>{if(c.current&&c.current.readyState===WebSocket.OPEN)try{c.current.send(JSON.stringify({type:"ping"})),console.log("\u{1F4E1} WebSocket ping sent")}catch(r){console.error("Failed to send ping:",r)}},3e4)},c.current.onmessage=r=>{try{let b=JSON.parse(r.data);if(b.type==="pong"){console.log("\u{1F4E1} WebSocket pong received");return}let H=Fn(e==null?void 0:e.conferenceLine,b==null?void 0:b.conferencestatus,b);x.updateCallData(b),x.updateConferenceData([...H]),(b.status==="RINGING"||b.status==="DIALING")&&m.current&&m.current.play().catch(ae=>{console.error("Failed to play ringtone:",ae)}),b.status==="ONCALL"&&(m.current&&(m.current.pause(),m.current.currentTime=0),x.startCall(),O||I(!0)),b.status==="WRAPUP"&&(m.current&&(m.current.pause(),m.current.currentTime=0),x.endCall())}catch(b){console.log("\u{1F4E8} Raw message:",r.data)}},c.current.onclose=r=>{if(console.log("\u{1F50C} WebSocket connection closed",r.code,r.reason),T.current&&(clearInterval(T.current),T.current=null),r.code!==1e3&&g.current<C){g.current+=1;let b=Math.min(h*Math.pow(2,g.current-1),U);console.log(`\u{1F504} Attempting to reconnect WebSocket (attempt ${g.current}/${C}) in ${b}ms`),f.current=setTimeout(()=>{Ve()},b)}else g.current>=C&&(console.error("\u274C Maximum reconnection attempts reached. Please refresh the page."),l("WebSocket connection failed. Please refresh the page.","error"))},c.current.onerror=r=>{console.error("\u274C WebSocket error:",r)}}catch(r){if(console.error("\u274C Failed to create WebSocket:",r),g.current<C){g.current+=1;let b=Math.min(h*Math.pow(2,g.current-1),U);f.current=setTimeout(()=>{Ve()},b)}}};return(0,F.useEffect)(()=>(e.agentId&&Ve(),()=>{f.current&&(clearTimeout(f.current),f.current=null),T.current&&(clearInterval(T.current),T.current=null),c.current&&(c.current.close(1e3,"Component unmounting"),c.current=null),g.current=0}),[e.agentId]),!e.isInitialized||!e.process?(0,d.jsx)(R.Box,{children:!!y&&(0,d.jsx)(rn,{processList:D,open:y,setOpen:Z,handleSelectedProcessor:r=>{x.setProcess(r)}})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(R.Box,{children:(0,d.jsx)(R.Fade,{in:!0,timeout:300,children:(0,d.jsx)(R.Paper,{ref:(dt=e.sdkConfig)!=null&&dt.isDraggable?_:null,elevation:ee?4:(pt=e.sdkConfig)!=null&&pt.isDraggable?1:0,sx:{position:(ct=e.sdkConfig)!=null&&ct.isDraggable?"fixed":"relative",left:(ut=e.sdkConfig)!=null&&ut.isDraggable?Y.x:"auto",top:(gt=e.sdkConfig)!=null&&gt.isDraggable?Y.y:"auto",display:"inline-block",width:"auto",flexShrink:0,whiteSpace:"nowrap",p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:(ft=e.sdkConfig)!=null&&ft.isDraggable?Number.MAX_SAFE_INTEGER:0,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),userSelect:"none"},children:(0,d.jsxs)(R.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,d.jsxs)(R.Box,{sx:{display:"flex",alignItems:"center",gap:1,margin:"0px 10px"},children:[((Ut=e.sdkConfig)==null?void 0:Ut.isDraggable)&&(0,d.jsxs)(R.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:A,onTouchStart:j,children:[(0,d.jsx)(L.DragIndicator,{})," "]}),(0,d.jsx)(R.Box,{children:!((Rt=e.sdkConfig)!=null&&Rt.disabledDialButton)&&(0,d.jsx)(R.Tooltip,{title:"Dial",children:(0,d.jsx)(R.IconButton,{size:"small",onClick:r=>{var b,H,ae,re,ge,fe,ye,Ae;((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())!=="ONCALL"&&((re=(ae=e.callData)==null?void 0:ae.status)==null?void 0:re.toUpperCase())!=="BREAK"&&((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())!=="RINGING"&&((Ae=(ye=e.callData)==null?void 0:ye.status)==null?void 0:Ae.toUpperCase())!=="WRAPUP"&&Fe(r)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,d.jsx)(L.WifiCalling3,{sx:{color:((Ct=(mt=e.callData)==null?void 0:mt.status)==null?void 0:Ct.toUpperCase())==="ONCALL"||((bt=(xt=e.callData)==null?void 0:xt.status)==null?void 0:bt.toUpperCase())==="BREAK"||((Dt=(ht=e.callData)==null?void 0:ht.status)==null?void 0:Dt.toUpperCase())==="RINGING"||((St=(Et=e.callData)==null?void 0:Et.status)==null?void 0:St.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,d.jsx)(R.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px",fontSize:"18px",fontWeight:"600"},children:Qn(W)}),(0,d.jsx)(R.Chip,{sx:{padding:"18px 0px"},label:Be||Te?(0,d.jsx)(R.Box,{sx:{fontWeight:"bold",width:"60px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,d.jsx)(R.CircularProgress,{size:"20px"})}):(0,d.jsx)(R.Typography,{variant:"body2",sx:{fontWeight:"bold",width:"60px",textAlign:"center"},children:(yt=(Lt=(Tt=e.callData)==null?void 0:Tt.status)==null?void 0:Lt.toUpperCase())!=null?yt:"N/A"}),onClick:Ue,deleteIcon:(0,d.jsx)(L.KeyboardArrowDown,{color:"primary"}),onDelete:Ue})]}),(0,d.jsxs)(R.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,d.jsx)(R.Tooltip,{title:"Agent Ready",children:(0,d.jsx)(R.Button,{variant:((Pt=(At=e.callData)==null?void 0:At.status)==null?void 0:Pt.toUpperCase())==="BREAK"||((vt=(kt=e.callData)==null?void 0:kt.status)==null?void 0:vt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:r=>{var b,H,ae,re;(((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())==="BREAK"||((re=(ae=e.callData)==null?void 0:ae.status)==null?void 0:re.toUpperCase())==="MISSED")&&(r.stopPropagation(),fn())},classes:{root:(($t=(It=e.callData)==null?void 0:It.status)==null?void 0:$t.toUpperCase())==="BREAK"||((Nt=(_t=e.callData)==null?void 0:_t.status)==null?void 0:Nt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:p({},((Mt=(Ot=e.callData)==null?void 0:Ot.status)==null?void 0:Mt.toUpperCase())==="BREAK"||((Ht=(Bt=e.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())==="MISSED"?u:s),disabled:Te,children:(0,d.jsx)(L.SupportAgent,{})})}),(0,d.jsx)(R.Tooltip,{title:e.isHolding?"Resume":"Hold",children:(0,d.jsx)(R.Button,{variant:e.isHolding&&((Ft=(wt=e.callData)==null?void 0:wt.status)==null?void 0:Ft.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:r=>{r.stopPropagation(),mn()},sx:e.isHolding&&((Xt=(Qt=e.callData)==null?void 0:Qt.status)==null?void 0:Xt.toUpperCase())==="ONCALL"?p({},s):((Kt=(jt=e.callData)==null?void 0:jt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((Jt=(Wt=e.callData)==null?void 0:Wt.status)==null?void 0:Jt.toUpperCase())!=="ONCALL"&&!e.isHolding||Ee,children:Ee?(0,d.jsx)(R.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?(0,d.jsx)(L.PlayArrow,{}):(0,d.jsx)(L.Pause,{})})}),(0,d.jsx)(R.Tooltip,{title:e.isMuted?"Unmute":"Mute",children:(0,d.jsx)(R.Button,{variant:e.isMuted&&((Gt=(qt=e.callData)==null?void 0:qt.status)==null?void 0:Gt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:r=>{r.stopPropagation(),Cn()},sx:e.isMuted&&((Vt=(Yt=e.callData)==null?void 0:Yt.status)==null?void 0:Vt.toUpperCase())==="ONCALL"?p({},s):((Zt=(zt=e.callData)==null?void 0:zt.status)==null?void 0:Zt.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((to=(eo=e.callData)==null?void 0:eo.status)==null?void 0:to.toUpperCase())!=="ONCALL"&&!e.isMuted||Se,children:Se?(0,d.jsx)(R.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?(0,d.jsx)(L.MicOff,{}):(0,d.jsx)(L.Mic,{})})}),!((oo=e.sdkConfig)!=null&&oo.disableCallTransferButton)&&(0,d.jsx)(R.Tooltip,{title:"Transfer Call",children:(0,d.jsx)(R.Button,{variant:e.openCallTransferDialog?"contained":"outlined",onClick:r=>{var b,H;((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())==="ONCALL"&&(r.stopPropagation(),x.setOpenCallTransferDialog(!0))},sx:e.openCallTransferDialog?p({},s):((ao=(no=e.callData)==null?void 0:no.status)==null?void 0:ao.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((io=(so=e.callData)==null?void 0:so.status)==null?void 0:io.toUpperCase())!=="ONCALL",children:(0,d.jsx)(L.TransferWithinAStation,{})})}),!((ro=e.sdkConfig)!=null&&ro.disableConferenceButton)&&(0,d.jsx)(R.Tooltip,{title:"Conference Call",children:(0,d.jsx)(R.Button,{variant:e.openConferenceDialog?"contained":"outlined",onClick:r=>{var b,H;((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())==="ONCALL"&&(r.stopPropagation(),x.setOpenConferenceDialog(!0))},sx:e.openConferenceDialog?p({},s):((po=(lo=e.callData)==null?void 0:lo.status)==null?void 0:po.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((uo=(co=e.callData)==null?void 0:co.status)==null?void 0:uo.toUpperCase())!=="ONCALL",children:(0,d.jsx)(L.Group,{})})}),!((go=e.sdkConfig)!=null&&go.disableEndCallButton)&&(0,d.jsx)(R.Tooltip,{title:"End Call",children:(0,d.jsx)(R.Button,{variant:((Uo=(fo=e.callData)==null?void 0:fo.status)==null?void 0:Uo.toUpperCase())==="ONCALL"||((mo=(Ro=e.callData)==null?void 0:Ro.status)==null?void 0:mo.toUpperCase())==="RINGING"||((xo=(Co=e.callData)==null?void 0:Co.status)==null?void 0:xo.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:r=>{var b,H,ae,re,ge,fe;(((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())==="ONCALL"||((re=(ae=e.callData)==null?void 0:ae.status)==null?void 0:re.toUpperCase())==="RINGING"||((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())==="WRAPUP")&&(r.stopPropagation(),S(!0))},sx:((ho=(bo=e.callData)==null?void 0:bo.status)==null?void 0:ho.toUpperCase())==="ONCALL"||((Eo=(Do=e.callData)==null?void 0:Do.status)==null?void 0:Eo.toUpperCase())==="RINGING"||((To=(So=e.callData)==null?void 0:So.status)==null?void 0:To.toUpperCase())==="WRAPUP"?J(p({},s),{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}`}}):J(p({},i),{minWidth:"60px !important"}),disabled:((yo=(Lo=e.callData)==null?void 0:Lo.status)==null?void 0:yo.toUpperCase())!=="ONCALL"&&((Po=(Ao=e.callData)==null?void 0:Ao.status)==null?void 0:Po.toUpperCase())!=="RINGING"&&((vo=(ko=e.callData)==null?void 0:ko.status)==null?void 0:vo.toUpperCase())!=="WRAPUP"||Le,children:Le?(0,d.jsx)(R.CircularProgress,{size:"20px",color:"error"}):(0,d.jsx)(L.CallEnd,{})})})]})]})})})}),(0,d.jsx)(R.Fade,{in:!0,timeout:300,children:(0,d.jsxs)(R.Paper,{ref:oe,elevation:te?4:1,sx:{position:"absolute",left:V.x,top:V.y,borderRadius:2,bgcolor:"background.paper",zIndex:Number.MAX_SAFE_INTEGER,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),visibility:O&&!((Io=e.sdkConfig)!=null&&Io.disableSoftPhone)?"visible":"hidden",userSelect:"none"},children:[(0,d.jsxs)(R.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll",padding:"0px 10px"},onMouseDown:ue,onTouchStart:ve,children:[(0,d.jsx)(L.DragIndicator,{sx:{transform:"rotate(90deg)",color:"#7b7b7b"}})," ",(0,d.jsx)(R.IconButton,{onClick:()=>I(!1),children:(0,d.jsx)(L.Close,{})})]}),(0,d.jsx)(R.Box,{children:(0,d.jsx)("iframe",{src:`https://${Xe}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${($o=e.process)==null?void 0:$o.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})})]})}),(0,d.jsx)(R.Menu,{anchorEl:z,open:!!z,onClose:Qe,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsxs)(R.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,d.jsx)(R.TextField,{size:"small",value:B,placeholder:"Enter Mobile No.",onChange:r=>{K(r.target.value)}}),(0,d.jsx)(R.IconButton,{color:"info",onClick:()=>{Rn(B)},children:$e?(0,d.jsx)(R.CircularProgress,{size:"20px",sx:{color:o.palette.success.main}}):(0,d.jsx)(L.Phone,{color:"success"})})]})}),(0,d.jsx)(R.Menu,{anchorEl:M,open:!!M,onClose:gn,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsx)(R.MenuItem,{onClick:()=>Un("Lunch"),children:"- Break"})}),(0,d.jsx)(R.Menu,{anchorEl:E,open:!!E,onClose:we,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsxs)(R.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,d.jsx)(R.Chip,{icon:(0,d.jsx)(L.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,d.jsx)(R.Chip,{icon:(0,d.jsx)(L.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,d.jsx)(R.Chip,{icon:(0,d.jsx)(L.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!e.openConferenceDialog&&(0,d.jsx)(nn,{}),!!e.openCallTransferDialog&&(0,d.jsx)(an,{open:e.openCallTransferDialog}),!!$&&(0,d.jsx)(sn,{open:$,setOpen:S,onSubmitDisposition:xn}),!!se&&(0,d.jsx)(ln,{open:se,setOpen:ie})]})}var cn=require("react");var un=require("react/jsx-runtime"),nt=(0,cn.memo)(({children:t})=>(0,un.jsx)(tn,{children:t}));nt.displayName="SDKProvider";var at=require("react/jsx-runtime"),st=(0,Ye.memo)(({onDataChange:t})=>{let o=(0,Ye.useCallback)(e=>{try{t&&typeof t=="function"&&t(e)}catch(l){console.error("Error in CallControlPanel data change handler:",l)}},[t]);return(0,at.jsx)(nt,{children:(0,at.jsx)(pn,{onDataChange:o})})});st.displayName="CallControlPanel";async function Xn({apiKey:t,tenantId:o,agentId:e,sdkConfig:l}){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("SDK initialization failed: API key is required and must be a non-empty string");if(!o||typeof o!="string"||o.trim().length===0)throw new Error("SDK initialization failed: Tenant ID is required and must be a non-empty string");if(!e||typeof e!="string"||e.trim().length===0)throw new Error("SDK initialization failed: Agent ID is required and must be a non-empty string");try{let i=await tt.init({apiKey:t.trim(),tenantId:o.trim(),agentId:e.trim(),baseUrl:w});if(i)console.log("SDK initialized successfully"),x.initialize(t.trim(),o.trim(),e.trim(),l,i);else throw console.error("SDK initialization failed: Event tracker initialization returned false"),x.setInitCheck(),new Error("SDK initialization failed: Unable to establish connection with the CTI system")}catch(i){throw console.error("SDK initialization error:",i),x.setInitCheck(),i instanceof Error?i:new Error(`SDK initialization failed: ${String(i)}`)}}function jn(){return"6.x.x"}function Kn(){return x.getState().isInitialized}0&&(module.exports={CallControlPanel,getSDKVersion,initSDK,isSDKInitialized,useClickToCall,useEndCall,useGetAuthorizationToken,useGetCallerData,useLogout});
2
- //# sourceMappingURL=index.js.map
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, isMergeCall }) => {
1364
+ var _a2, _b, _c, _d, _e;
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 [conferenceCallMuteOrUnMute, setConferenceCallMuteOrUnMute] = (0, import_react10.useState)(false);
1377
+ const [conferenceCallEnd, setConferenceCallEnd] = (0, import_react10.useState)(false);
1378
+ const onConferenceLineUpdate = (line, data) => {
1379
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1380
+ };
1381
+ const onConferenceCallStart = (line, data) => {
1382
+ var _a3, _b2, _c2, _d2;
1383
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1384
+ setConferenceCallStart(true);
1385
+ const payload = {
1386
+ action: "EXTERNAL_CONFERENCE",
1387
+ operation: `CALL${line_used.line}`,
1388
+ line_used: String(line_used.line),
1389
+ thirdparty_no: line_used.phone,
1390
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1391
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1392
+ };
1393
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
1394
+ var _a4;
1395
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1396
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1397
+ }).catch((err) => {
1398
+ var _a4, _b3, _c3, _d3;
1399
+ 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";
1400
+ showToast(message, "error");
1401
+ }).finally(() => {
1402
+ setConferenceCallStart(false);
1403
+ });
1404
+ };
1405
+ const onMergeConferenceCall = (line, data) => {
1406
+ var _a3, _b2, _c2, _d2;
1407
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1408
+ setConferenceCallMerge(true);
1409
+ const payload = {
1410
+ action: "EXTERNAL_CONFERENCE",
1411
+ operation: `CONFERENCE`,
1412
+ line_used: String(line_used.line),
1413
+ thirdparty_no: line_used.phone,
1414
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1415
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1416
+ };
1417
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
1418
+ var _a4;
1419
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1420
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1421
+ }).catch((err) => {
1422
+ var _a4, _b3, _c3, _d3;
1423
+ 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";
1424
+ showToast(message, "error");
1425
+ }).finally(() => {
1426
+ setConferenceCallMerge(false);
1427
+ });
1428
+ };
1429
+ const onHoldOrUnHoldConferenceCall = (line, data, type) => {
1430
+ var _a3, _b2, _c2, _d2;
1431
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1432
+ setConferenceCallHoldOrUnHold(true);
1433
+ const payload = {
1434
+ action: "EXTERNAL_CONFERENCE",
1435
+ operation: type,
1436
+ hold_channel_no: type === "HOLDUSER" ? `hold${line_used.line}` : `unhold${line_used.line}`,
1437
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1438
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1439
+ };
1440
+ axios_default.post(END_POINT.CONFERENCE_CALL_HOLD_OR_UN_HOLD, payload).then((res) => {
1441
+ var _a4;
1442
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1443
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1444
+ }).catch((err) => {
1445
+ var _a4, _b3, _c3, _d3;
1446
+ 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";
1447
+ showToast(message, "error");
1448
+ }).finally(() => {
1449
+ setConferenceCallHoldOrUnHold(false);
1450
+ });
1451
+ };
1452
+ const onMuteOrUnMuteConferenceCall = (line, data, type) => {
1453
+ var _a3, _b2, _c2, _d2;
1454
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1455
+ setConferenceCallMuteOrUnMute(true);
1456
+ const payload = {
1457
+ action: "EXTERNAL_CONFERENCE",
1458
+ operation: type,
1459
+ channel_no: type === "MUTEUSER" ? `mute${line_used.line}` : `play${line_used.line}`,
1460
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1461
+ thirdparty_no: line_used.phone,
1462
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1463
+ };
1464
+ axios_default.post(END_POINT.CONFERENCE_CALL_MUTE_OT_UN_MUTE, 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
+ setConferenceCallMuteOrUnMute(false);
1474
+ });
1475
+ };
1476
+ const onEndConferenceCall = (line, data) => {
1477
+ var _a3, _b2, _c2, _d2;
1478
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1479
+ setConferenceCallEnd(true);
1480
+ const payload = {
1481
+ action: "EXTERNAL_CONFERENCE",
1482
+ operation: "HANGUP_CHANNEL",
1483
+ line_used: String(line_used.line),
1484
+ user_type: `THIRDPARTY${line_used.line - 1}`,
1485
+ thirdparty_no: line_used.phone,
1486
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1487
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1488
+ };
1489
+ axios_default.post(END_POINT.CONFERENCE_CALL_END, payload).then((res) => {
1490
+ var _a4;
1491
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1492
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1493
+ }).catch((err) => {
1494
+ var _a4, _b3, _c3, _d3;
1495
+ 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";
1496
+ showToast(message, "error");
1497
+ }).finally(() => {
1498
+ setConferenceCallEnd(false);
1499
+ });
1500
+ };
1501
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1502
+ import_material3.TableRow,
1503
+ {
1504
+ sx: {
1505
+ border: "2px solid #fff"
1506
+ },
1507
+ children: [
1508
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1509
+ import_material3.TableCell,
1510
+ {
1511
+ sx: {
1512
+ padding: "6px"
1513
+ },
1514
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Typography, { children: [
1515
+ "Line ",
1516
+ (_d = each == null ? void 0 : each.line) != null ? _d : "",
1517
+ ". "
1518
+ ] })
1519
+ }
1520
+ ),
1521
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1522
+ import_material3.TableCell,
1523
+ {
1524
+ sx: {
1525
+ padding: "6px"
1526
+ },
1527
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1528
+ import_material3.Typography,
1529
+ {
1530
+ variant: "body2",
1531
+ sx: {
1532
+ px: 1,
1533
+ borderRadius: "10px"
1534
+ },
1535
+ children: (_e = each == null ? void 0 : each.status) != null ? _e : ""
1536
+ }
1537
+ )
1538
+ }
1539
+ ),
1540
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1541
+ import_material3.TableCell,
1542
+ {
1543
+ sx: {
1544
+ padding: "6px"
1545
+ },
1546
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1547
+ import_material3.Button,
1548
+ {
1549
+ sx: {
1550
+ textTransform: "capitalize"
1551
+ },
1552
+ size: "small",
1553
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body2", children: (each == null ? void 0 : each.line) === 1 ? "Internal" : "External" })
1554
+ }
1555
+ )
1556
+ }
1557
+ ),
1558
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1559
+ import_material3.TableCell,
1560
+ {
1561
+ sx: {
1562
+ padding: "6px"
1563
+ },
1564
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1565
+ import_material3.TextField,
1566
+ {
1567
+ size: "small",
1568
+ placeholder: "Phone Number",
1569
+ fullWidth: true,
1570
+ value: (each == null ? void 0 : each.phone) || "",
1571
+ 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",
1572
+ onChange: (e) => {
1573
+ onConferenceLineUpdate(each, { phone: e.target.value });
1574
+ }
1575
+ }
1576
+ )
1577
+ }
1578
+ ),
1579
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1580
+ import_material3.TableCell,
1581
+ {
1582
+ sx: {
1583
+ padding: "6px"
1584
+ },
1585
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1586
+ import_material3.Box,
1587
+ {
1588
+ sx: {
1589
+ display: "flex",
1590
+ alignItems: "center",
1591
+ justifyContent: "space-around"
1592
+ },
1593
+ children: [
1594
+ each.line !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1595
+ import_material3.Button,
1596
+ {
1597
+ variant: (each == null ? void 0 : each.status) !== "IDLE" ? "outlined" : "contained",
1598
+ color: "success",
1599
+ sx: (each == null ? void 0 : each.status) !== "IDLE" ? __spreadValues({}, disabled) : __spreadProps(__spreadValues({}, enabled), {
1600
+ border: `0px solid ${theme.palette.success.light}`,
1601
+ "&:hover": {
1602
+ bgcolor: "success.light",
1603
+ boxShadow: `0px 2px 1px ${theme.palette.success.light}`,
1604
+ border: `0px solid ${theme.palette.success.light}`
1605
+ },
1606
+ "&:active": {
1607
+ bgcolor: "success.light",
1608
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1609
+ }
1610
+ }),
1611
+ onClick: () => {
1612
+ onConferenceCallStart(each, {});
1613
+ },
1614
+ disabled: (each == null ? void 0 : each.status) !== "IDLE",
1615
+ children: conferenceCallStart ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1616
+ import_material3.CircularProgress,
1617
+ {
1618
+ size: "20px",
1619
+ color: "success"
1620
+ }
1621
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1622
+ import_icons_material.Call,
1623
+ {
1624
+ sx: {
1625
+ color: (each == null ? void 0 : each.status) !== "IDLE" ? "default" : "#f3f2f2"
1626
+ }
1627
+ }
1628
+ )
1629
+ }
1630
+ ) }),
1631
+ each.line === 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "Merge Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1632
+ import_material3.Button,
1633
+ {
1634
+ variant: isMergeCall ? "contained" : "outlined",
1635
+ sx: isMergeCall ? __spreadProps(__spreadValues({}, enabled), { padding: "0px 16px" }) : __spreadProps(__spreadValues({}, disabled), { padding: "0px 16px" }),
1636
+ onClick: () => {
1637
+ onMergeConferenceCall(each, {
1638
+ isMergeCall: true
1639
+ });
1640
+ },
1641
+ disabled: !isMergeCall || conferenceCallMerge,
1642
+ children: [
1643
+ (each == null ? void 0 : each.isMergeCall) ? "Merged" : "Merge",
1644
+ conferenceCallMerge ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.CircularProgress, { size: "20px" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.CallSplit, {})
1645
+ ]
1646
+ }
1647
+ ) }),
1648
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: each.status !== "HOLD" ? "Hold" : "Un Hold", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1649
+ import_material3.Button,
1650
+ {
1651
+ variant: each.status === "HOLD" ? "contained" : "outlined",
1652
+ sx: each.status === "DISCONNECTED" || (each == null ? void 0 : each.status) === "ONCALL" || (each == null ? void 0 : each.status) === "CONFERENCE" ? __spreadValues({}, disabled) : (each == null ? void 0 : each.status) === "ONCALL" || (each == null ? void 0 : each.status) === "CONFERENCE" ? (
1653
+ // each.status === "IDLE"
1654
+ __spreadValues({}, outlined)
1655
+ ) : __spreadValues({}, disabled),
1656
+ onClick: () => {
1657
+ if (each.status === "HOLD") {
1658
+ onHoldOrUnHoldConferenceCall(each, { isHold: false }, "UNHOLDUSER");
1659
+ } else {
1660
+ onHoldOrUnHoldConferenceCall(each, { isHold: true }, "HOLDUSER");
1661
+ }
1662
+ },
1663
+ disabled: (each == null ? void 0 : each.status) === "DISCONNECTED" || (each == null ? void 0 : each.status) === "IDLE" || conferenceCallHoldOrUnHold,
1664
+ children: conferenceCallHoldOrUnHold ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1665
+ import_material3.CircularProgress,
1666
+ {
1667
+ size: "20px",
1668
+ sx: {
1669
+ color: theme.palette.primary.main
1670
+ }
1671
+ }
1672
+ ) : each.status === "HOLD" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Pause, {})
1673
+ }
1674
+ ) }),
1675
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: each.status !== "MUTE" ? "Mute" : "Un Mute", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1676
+ import_material3.Button,
1677
+ {
1678
+ variant: each.status === "MUTE" ? "contained" : "outlined",
1679
+ sx: each.status === "DISCONNECTED" || (each == null ? void 0 : each.status) === "ONCALL" || (each == null ? void 0 : each.status) === "CONFERENCE" ? __spreadValues({}, disabled) : (each == null ? void 0 : each.status) === "ONCALL" || (each == null ? void 0 : each.status) === "CONFERENCE" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1680
+ onClick: () => {
1681
+ if (each.status === "MUTE") {
1682
+ onMuteOrUnMuteConferenceCall(each, { isMute: false }, "PLAYUSER");
1683
+ } else {
1684
+ onMuteOrUnMuteConferenceCall(each, { isMute: true }, "MUTEUSER");
1685
+ }
1686
+ },
1687
+ disabled: (each == null ? void 0 : each.status) === "DISCONNECTED" || (each == null ? void 0 : each.status) === "IDLE" || (each == null ? void 0 : each.status) === "HOLD" || conferenceCallMuteOrUnMute,
1688
+ children: conferenceCallMuteOrUnMute ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1689
+ import_material3.CircularProgress,
1690
+ {
1691
+ size: "20px",
1692
+ sx: {
1693
+ color: theme.palette.primary.main
1694
+ }
1695
+ }
1696
+ ) : each.status === "MUTE" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.MicOff, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Mic, {})
1697
+ }
1698
+ ) }),
1699
+ (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)(
1700
+ import_material3.Button,
1701
+ {
1702
+ variant: (each == null ? void 0 : each.status) !== "IDLE" && (each == null ? void 0 : each.status) !== "DISCONNECTED" ? "contained" : "outlined",
1703
+ color: "error",
1704
+ sx: (each == null ? void 0 : each.status) !== "IDLE" && (each == null ? void 0 : each.status) !== "DISCONNECTED" ? __spreadProps(__spreadValues({}, enabled), {
1705
+ border: `0px solid ${theme.palette.error.light}`,
1706
+ "&:hover": {
1707
+ bgcolor: "error.light",
1708
+ boxShadow: `0px 2px 1px ${theme.palette.error.light}`,
1709
+ border: `0px solid ${theme.palette.error.light}`
1710
+ },
1711
+ "&:active": {
1712
+ bgcolor: "error.light",
1713
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1714
+ }
1715
+ }) : __spreadValues({}, disabled),
1716
+ onClick: () => {
1717
+ onEndConferenceCall(each, {
1718
+ isCallStart: false,
1719
+ isMergeCall: false,
1720
+ isMute: false,
1721
+ isHold: false
1722
+ });
1723
+ },
1724
+ disabled: (each == null ? void 0 : each.status) === "IDLE" || (each == null ? void 0 : each.status) === "DISCONNECTED" || conferenceCallEnd,
1725
+ children: conferenceCallEnd ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1726
+ import_material3.CircularProgress,
1727
+ {
1728
+ size: "20px",
1729
+ color: "error"
1730
+ }
1731
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.CallEnd, {})
1732
+ }
1733
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1734
+ import_material3.Button,
1735
+ {
1736
+ variant: (each == null ? void 0 : each.isCallStart) ? "contained" : "outlined",
1737
+ color: "error",
1738
+ sx: {
1739
+ display: "none"
1740
+ },
1741
+ onClick: () => {
1742
+ onEndConferenceCall(each, {
1743
+ isCallStart: false,
1744
+ isMergeCall: false,
1745
+ isMute: false,
1746
+ isHold: false
1747
+ });
1748
+ },
1749
+ disabled: (each == null ? void 0 : each.status) === "IDLE" || (each == null ? void 0 : each.status) === "DISCONNECTED" || conferenceCallEnd,
1750
+ children: conferenceCallEnd ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1751
+ import_material3.CircularProgress,
1752
+ {
1753
+ size: "20px",
1754
+ color: "error"
1755
+ }
1756
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.CallEnd, {})
1757
+ }
1758
+ )
1759
+ ]
1760
+ }
1761
+ )
1762
+ }
1763
+ )
1764
+ ]
1765
+ },
1766
+ each.line
1767
+ );
1768
+ };
1769
+ function ConferenceDialog() {
1770
+ var _a2;
1771
+ const state = useSDKState();
1772
+ const { showToast } = useToast();
1773
+ const [conferenceCallEndAll, setConferenceCallEndAll] = (0, import_react10.useState)(false);
1774
+ const handleClose = () => {
1775
+ sdkStateManager.setOpenConferenceDialog(false);
1776
+ };
1777
+ const onEndAllConferenceCalls = () => {
1778
+ var _a3, _b, _c, _d;
1779
+ setConferenceCallEndAll(true);
1780
+ const payload = {
1781
+ action: "EXTERNAL_CONFERENCE",
1782
+ operation: "ENDCONFERENCE",
1783
+ userid: (_b = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b : "",
1784
+ process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
1785
+ };
1786
+ axios_default.post(END_POINT.CONFERENCE_CALL_END_ALL, payload).then((res) => {
1787
+ var _a4;
1788
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1789
+ sdkStateManager.resetConferenceLines();
1790
+ handleClose();
1791
+ }).catch((err) => {
1792
+ var _a4, _b2, _c2, _d2;
1793
+ 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";
1794
+ showToast(message, "error");
1795
+ }).finally(() => {
1796
+ setConferenceCallEndAll(false);
1797
+ });
1798
+ };
1799
+ const isMergeCall = (0, import_react10.useMemo)(() => {
1800
+ var _a3;
1801
+ return (_a3 = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _a3.some((each) => {
1802
+ if (each.line !== 1) {
1803
+ return each.status === "ONCALL";
1804
+ }
1805
+ return false;
1806
+ });
1807
+ }, [state.conferenceLine]);
1808
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1809
+ import_material3.Dialog,
1810
+ {
1811
+ open: state.openConferenceDialog,
1812
+ "aria-labelledby": "alert-dialog-title",
1813
+ "aria-describedby": "alert-dialog-description",
1814
+ fullWidth: true,
1815
+ maxWidth: "md",
1816
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
1817
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1818
+ import_material3.Box,
1819
+ {
1820
+ sx: {
1821
+ display: "flex",
1822
+ justifyContent: "space-between",
1823
+ alignItems: "center",
1824
+ padding: "10px 16px"
1825
+ },
1826
+ children: [
1827
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Typography, { variant: "body1", children: [
1828
+ (_a2 = state == null ? void 0 : state.agentId) != null ? _a2 : "",
1829
+ " conference"
1830
+ ] }),
1831
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
1832
+ ]
1833
+ }
1834
+ ),
1835
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1836
+ import_material3.Box,
1837
+ {
1838
+ sx: {
1839
+ boxShadow: "1px 1px 2px #e7e5e5ff",
1840
+ margin: "0px 15px",
1841
+ borderRadius: "20px"
1842
+ },
1843
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1844
+ import_material3.TableContainer,
1845
+ {
1846
+ component: import_material3.Paper,
1847
+ sx: {
1848
+ outline: "0px solid gray !important",
1849
+ boxShadow: "1px 1px 6px #e7e5e5ff"
1850
+ },
1851
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1852
+ import_material3.Table,
1853
+ {
1854
+ sx: {
1855
+ border: "4px solid #ffffff !important"
1856
+ },
1857
+ children: [
1858
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1859
+ import_material3.TableRow,
1860
+ {
1861
+ sx: {
1862
+ border: "2px solid #f3f3f3ff !important"
1863
+ },
1864
+ children: [
1865
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1866
+ import_material3.TableCell,
1867
+ {
1868
+ sx: {
1869
+ padding: "6px"
1870
+ },
1871
+ children: "Line"
1872
+ }
1873
+ ),
1874
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1875
+ import_material3.TableCell,
1876
+ {
1877
+ sx: {
1878
+ padding: "6px"
1879
+ },
1880
+ children: "Status"
1881
+ }
1882
+ ),
1883
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1884
+ import_material3.TableCell,
1885
+ {
1886
+ sx: {
1887
+ padding: "6px"
1888
+ },
1889
+ children: "Call Type"
1890
+ }
1891
+ ),
1892
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1893
+ import_material3.TableCell,
1894
+ {
1895
+ sx: {
1896
+ padding: "6px"
1897
+ },
1898
+ children: "Mobile Number"
1899
+ }
1900
+ ),
1901
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1902
+ import_material3.TableCell,
1903
+ {
1904
+ sx: {
1905
+ padding: "6px"
1906
+ },
1907
+ children: "Call Actions"
1908
+ }
1909
+ )
1910
+ ]
1911
+ }
1912
+ ) }),
1913
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1914
+ ConferenceTableRow,
1915
+ {
1916
+ each,
1917
+ isMergeCall
1918
+ }
1919
+ )) })
1920
+ ]
1921
+ }
1922
+ )
1923
+ }
1924
+ )
1925
+ }
1926
+ ),
1927
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1928
+ import_material3.Box,
1929
+ {
1930
+ textAlign: "center",
1931
+ m: 2,
1932
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1933
+ import_material3.Button,
1934
+ {
1935
+ variant: "outlined",
1936
+ color: "error",
1937
+ size: "large",
1938
+ onClick: onEndAllConferenceCalls,
1939
+ disabled: conferenceCallEndAll,
1940
+ sx: { px: 2, borderRadius: "20px", textTransform: "capitalize" },
1941
+ children: [
1942
+ conferenceCallEndAll ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1943
+ import_material3.CircularProgress,
1944
+ {
1945
+ size: "20px",
1946
+ color: "error",
1947
+ sx: {
1948
+ marginRight: "8px"
1949
+ }
1950
+ }
1951
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1952
+ import_material3.IconButton,
1953
+ {
1954
+ sx: {
1955
+ bgcolor: "error.main",
1956
+ "&:hover": { bgcolor: "error.dark" },
1957
+ marginRight: "8px",
1958
+ width: "28px",
1959
+ height: "28px",
1960
+ fontSize: "12px",
1961
+ fontWeight: "600",
1962
+ lineHeight: "16px",
1963
+ letterSpacing: "0.02em",
1964
+ textTransform: "capitalize",
1965
+ color: "white",
1966
+ display: "flex",
1967
+ alignItems: "center",
1968
+ justifyContent: "center",
1969
+ borderRadius: "50%"
1970
+ },
1971
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1972
+ import_icons_material.PhoneDisabled,
1973
+ {
1974
+ sx: {
1975
+ color: "white",
1976
+ fontSize: "16px",
1977
+ fontWeight: "600"
1978
+ }
1979
+ }
1980
+ )
1981
+ }
1982
+ ),
1983
+ "End Conference"
1984
+ ]
1985
+ }
1986
+ )
1987
+ }
1988
+ )
1989
+ ] })
1990
+ }
1991
+ ) });
1992
+ }
1993
+ function CallTransferDialog({ open }) {
1994
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1995
+ const state = useSDKState();
1996
+ const [transferCall] = usePostRequest({
1997
+ onSuccess: () => {
1998
+ sdkStateManager.setOpenCallTransferDialog(false);
1999
+ }
2000
+ });
2001
+ const [currentselecteTab, setCurrentselecteTab] = (0, import_react10.useState)("process");
2002
+ const [getIdelAgentsList, { data: idleAgentsList, isLoading: isIdleAgentsListLoading }] = usePostRequest({
2003
+ disabledSuccessToast: true
2004
+ });
2005
+ const [
2006
+ getProcessAndQueuesList,
2007
+ { data: processAndQueuesList, isLoading: isProcessAndQueuesListLoading }
2008
+ ] = usePostRequest({
2009
+ disabledSuccessToast: true
2010
+ });
2011
+ const handleClose = () => {
2012
+ sdkStateManager.setOpenCallTransferDialog(false);
2013
+ };
2014
+ const handleTransferCall = (data, type) => {
2015
+ 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;
2016
+ if (type === "PROCESS") {
2017
+ const payload = {
2018
+ mobile_number: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.phone_number) != null ? _b2 : "",
2019
+ userid: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.agent_id) != null ? _d2 : "",
2020
+ type: "PROCESS",
2021
+ transfer_to: (_e2 = data == null ? void 0 : data.process_name) != null ? _e2 : "",
2022
+ callreferenceid: (_g2 = (_f2 = state.callData) == null ? void 0 : _f2.convox_id) != null ? _g2 : "",
2023
+ processid: String((_i2 = (_h2 = state.callData) == null ? void 0 : _h2.process_id) != null ? _i2 : ""),
2024
+ process_name: (_k2 = (_j2 = state.callData) == null ? void 0 : _j2.process_name) != null ? _k2 : ""
2025
+ };
2026
+ transferCall(END_POINT.TRANSFER_CALL, payload);
2027
+ } else if (type === "QUEUE") {
2028
+ const payload = {
2029
+ mobile_number: (_m = (_l2 = state.callData) == null ? void 0 : _l2.phone_number) != null ? _m : "",
2030
+ userid: (_o = (_n = state.callData) == null ? void 0 : _n.agent_id) != null ? _o : "",
2031
+ type: "QUEUE",
2032
+ transfer_to: (_p = data == null ? void 0 : data.queue_name) != null ? _p : "",
2033
+ callreferenceid: (_r = (_q = state.callData) == null ? void 0 : _q.convox_id) != null ? _r : "",
2034
+ processid: String((_t = (_s = state.callData) == null ? void 0 : _s.process_id) != null ? _t : ""),
2035
+ process_name: (_v = (_u = state.callData) == null ? void 0 : _u.process_name) != null ? _v : ""
2036
+ };
2037
+ transferCall(END_POINT.TRANSFER_CALL, payload);
2038
+ } else if (type === "AGENT") {
2039
+ const payload = {
2040
+ mobile_number: (_x = (_w = state.callData) == null ? void 0 : _w.phone_number) != null ? _x : "",
2041
+ userid: (_z = (_y = state.callData) == null ? void 0 : _y.agent_id) != null ? _z : "",
2042
+ type: "AGENT",
2043
+ transfer_to: (_A = data == null ? void 0 : data.user_id) != null ? _A : "",
2044
+ callreferenceid: (_C = (_B = state.callData) == null ? void 0 : _B.convox_id) != null ? _C : "",
2045
+ processid: String((_E = (_D = state.callData) == null ? void 0 : _D.process_id) != null ? _E : ""),
2046
+ process_name: (_G = (_F = state.callData) == null ? void 0 : _F.process_name) != null ? _G : ""
2047
+ };
2048
+ transferCall(END_POINT.TRANSFER_CALL, payload);
2049
+ }
2050
+ };
2051
+ (0, import_react10.useEffect)(() => {
2052
+ getIdelAgentsList(END_POINT.AGENTS_LIST, {
2053
+ status: "IDLE",
2054
+ active: true
2055
+ });
2056
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, {
2057
+ status: "ACTIVE",
2058
+ active: true
2059
+ });
2060
+ }, []);
2061
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2062
+ import_material3.Dialog,
2063
+ {
2064
+ open,
2065
+ "aria-labelledby": "alert-dialog-title",
2066
+ "aria-describedby": "alert-dialog-description",
2067
+ fullWidth: true,
2068
+ maxWidth: "md",
2069
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2070
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2071
+ import_material3.Box,
2072
+ {
2073
+ sx: {
2074
+ display: "flex",
2075
+ justifyContent: "space-between",
2076
+ alignItems: "center",
2077
+ padding: "4px 16px",
2078
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2079
+ },
2080
+ children: [
2081
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Call Transfer" }),
2082
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
2083
+ ]
2084
+ }
2085
+ ),
2086
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2087
+ import_material3.Box,
2088
+ {
2089
+ sx: {
2090
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2091
+ padding: "6px 10px",
2092
+ margin: "10px",
2093
+ borderRadius: "10px"
2094
+ },
2095
+ children: [
2096
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Box, { sx: { display: "flex", gap: 1 }, children: [
2097
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2098
+ import_material3.Button,
2099
+ {
2100
+ variant: currentselecteTab === "process" ? "contained" : "outlined",
2101
+ onClick: () => {
2102
+ setCurrentselecteTab("process");
2103
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, {
2104
+ status: "ACTIVE",
2105
+ active: true
2106
+ });
2107
+ },
2108
+ children: "Process"
2109
+ }
2110
+ ),
2111
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2112
+ import_material3.Button,
2113
+ {
2114
+ variant: currentselecteTab === "queues" ? "contained" : "outlined",
2115
+ onClick: () => {
2116
+ setCurrentselecteTab("queues");
2117
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, {
2118
+ status: "ACTIVE",
2119
+ active: true
2120
+ });
2121
+ },
2122
+ children: "Queues"
2123
+ }
2124
+ ),
2125
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2126
+ import_material3.Button,
2127
+ {
2128
+ variant: currentselecteTab === "agents" ? "contained" : "outlined",
2129
+ onClick: () => {
2130
+ setCurrentselecteTab("agents");
2131
+ getIdelAgentsList(END_POINT.AGENTS_LIST, {
2132
+ status: "IDLE",
2133
+ active: true
2134
+ });
2135
+ },
2136
+ children: "Agents"
2137
+ }
2138
+ )
2139
+ ] }),
2140
+ (isProcessAndQueuesListLoading || isIdleAgentsListLoading) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2141
+ import_material3.Box,
2142
+ {
2143
+ sx: {
2144
+ display: "flex",
2145
+ justifyContent: "center",
2146
+ alignItems: "center",
2147
+ height: "80px"
2148
+ },
2149
+ children: [
2150
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.CircularProgress, {}),
2151
+ " "
2152
+ ]
2153
+ }
2154
+ ),
2155
+ !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)(
2156
+ import_material3.Box,
2157
+ {
2158
+ sx: {
2159
+ p: 1,
2160
+ display: "flex",
2161
+ alignItems: "center",
2162
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2163
+ padding: "6px",
2164
+ borderRadius: "10px",
2165
+ "&:hover": { bgcolor: "action.selected" }
2166
+ },
2167
+ children: [
2168
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2169
+ import_material3.Typography,
2170
+ {
2171
+ variant: "body1",
2172
+ sx: {
2173
+ mx: 1,
2174
+ width: "200px",
2175
+ maxWidth: "250px",
2176
+ display: "flex",
2177
+ alignItems: "center"
2178
+ },
2179
+ children: [
2180
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2181
+ process.process_name
2182
+ ]
2183
+ }
2184
+ ),
2185
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2186
+ import_material3.IconButton,
2187
+ {
2188
+ color: "success",
2189
+ sx: {
2190
+ bgcolor: "action.hover",
2191
+ "&:hover": { bgcolor: "action.selected" }
2192
+ },
2193
+ onClick: () => {
2194
+ handleTransferCall(process, "PROCESS");
2195
+ },
2196
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2197
+ }
2198
+ )
2199
+ ]
2200
+ },
2201
+ index
2202
+ )) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2203
+ import_material3.Typography,
2204
+ {
2205
+ variant: "body1",
2206
+ sx: {
2207
+ fontSize: "16px",
2208
+ letterSpacing: "0.02em",
2209
+ textTransform: "capitalize",
2210
+ display: "flex",
2211
+ alignItems: "center",
2212
+ justifyContent: "center",
2213
+ width: "100%",
2214
+ margin: "10px 0px",
2215
+ color: "gray",
2216
+ height: "60px"
2217
+ },
2218
+ children: "No Process Found"
2219
+ }
2220
+ ) }),
2221
+ !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) => {
2222
+ var _a3, _b2, _c2, _d2, _e2, _f2;
2223
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2224
+ import_material3.Box,
2225
+ {
2226
+ sx: {
2227
+ p: 1,
2228
+ display: "flex",
2229
+ alignItems: "center",
2230
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2231
+ padding: "6px",
2232
+ borderRadius: "10px",
2233
+ "&:hover": { bgcolor: "action.selected" }
2234
+ },
2235
+ children: [
2236
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2237
+ import_material3.Typography,
2238
+ {
2239
+ variant: "body1",
2240
+ sx: {
2241
+ mx: 1,
2242
+ width: "200px",
2243
+ maxWidth: "250px",
2244
+ display: "flex",
2245
+ alignItems: "center"
2246
+ },
2247
+ children: [
2248
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2249
+ queue.queue_name,
2250
+ ((_c2 = (_b2 = (_a3 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _a3.process) == null ? void 0 : _b2.find(
2251
+ (process) => process.process_id === queue.process_id
2252
+ )) == null ? void 0 : _c2.process_name) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2253
+ import_material3.Typography,
2254
+ {
2255
+ variant: "body1",
2256
+ sx: {
2257
+ fontSize: "12px",
2258
+ fontWeight: "600",
2259
+ letterSpacing: "0.02em",
2260
+ textTransform: "capitalize",
2261
+ color: "gray"
2262
+ },
2263
+ children: "(" + ((_f2 = (_e2 = (_d2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _d2.process) == null ? void 0 : _e2.find(
2264
+ (process) => process.process_id === queue.process_id
2265
+ )) == null ? void 0 : _f2.process_name) + ")"
2266
+ }
2267
+ ) : ""
2268
+ ]
2269
+ }
2270
+ ),
2271
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2272
+ import_material3.IconButton,
2273
+ {
2274
+ color: "success",
2275
+ sx: {
2276
+ bgcolor: "action.hover",
2277
+ "&:hover": { bgcolor: "action.selected" }
2278
+ },
2279
+ onClick: () => {
2280
+ handleTransferCall(queue, "QUEUE");
2281
+ },
2282
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2283
+ }
2284
+ )
2285
+ ]
2286
+ },
2287
+ index
2288
+ );
2289
+ }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2290
+ import_material3.Typography,
2291
+ {
2292
+ variant: "body1",
2293
+ sx: {
2294
+ fontSize: "16px",
2295
+ letterSpacing: "0.02em",
2296
+ textTransform: "capitalize",
2297
+ display: "flex",
2298
+ alignItems: "center",
2299
+ justifyContent: "center",
2300
+ width: "100%",
2301
+ margin: "10px 0px",
2302
+ color: "gray",
2303
+ height: "60px"
2304
+ },
2305
+ children: "No Queues Found"
2306
+ }
2307
+ ) }),
2308
+ !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)(
2309
+ import_material3.Box,
2310
+ {
2311
+ sx: {
2312
+ p: 1,
2313
+ display: "flex",
2314
+ alignItems: "center",
2315
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2316
+ padding: "6px",
2317
+ borderRadius: "10px",
2318
+ "&:hover": { bgcolor: "action.selected" }
2319
+ },
2320
+ children: [
2321
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2322
+ import_material3.Typography,
2323
+ {
2324
+ variant: "body1",
2325
+ sx: {
2326
+ mx: 1,
2327
+ width: "200px",
2328
+ maxWidth: "250px",
2329
+ display: "flex",
2330
+ alignItems: "center"
2331
+ },
2332
+ children: [
2333
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2334
+ agent.name
2335
+ ]
2336
+ }
2337
+ ),
2338
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2339
+ import_material3.IconButton,
2340
+ {
2341
+ color: "success",
2342
+ sx: {
2343
+ bgcolor: "action.hover",
2344
+ "&:hover": { bgcolor: "action.selected" }
2345
+ },
2346
+ onClick: () => {
2347
+ handleTransferCall(agent, "AGENT");
2348
+ },
2349
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2350
+ }
2351
+ )
2352
+ ]
2353
+ },
2354
+ index
2355
+ )) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2356
+ import_material3.Typography,
2357
+ {
2358
+ variant: "body1",
2359
+ sx: {
2360
+ fontSize: "16px",
2361
+ letterSpacing: "0.02em",
2362
+ textTransform: "capitalize",
2363
+ display: "flex",
2364
+ alignItems: "center",
2365
+ justifyContent: "center",
2366
+ width: "100%",
2367
+ margin: "10px 0px",
2368
+ color: "gray",
2369
+ height: "60px"
2370
+ },
2371
+ children: "No Agents Found"
2372
+ }
2373
+ ) })
2374
+ ]
2375
+ }
2376
+ )
2377
+ ] })
2378
+ }
2379
+ ) });
2380
+ }
2381
+ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2382
+ var _a2, _b, _c, _d;
2383
+ const [formData, setFormData] = (0, import_react10.useState)({
2384
+ disposition: { label: "Resolved", value: "RES" },
2385
+ followUp: { label: "No", value: "N" },
2386
+ callbackDate: "",
2387
+ callbackHrs: "",
2388
+ callbackMins: ""
2389
+ });
2390
+ const dispositionOptions = [
2391
+ { label: "Not Interested", value: "NI" },
2392
+ { label: "Resolved", value: "RES" }
2393
+ ];
2394
+ const followUpOptions = [
2395
+ { label: "Yes", value: "Y" },
2396
+ { label: "No", value: "N" }
2397
+ ];
2398
+ const handleChange = (field, value) => {
2399
+ setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [field]: value }));
2400
+ };
2401
+ const handleReset = () => {
2402
+ setFormData({
2403
+ disposition: { label: "Resolved", value: "RES" },
2404
+ followUp: { label: "No", value: "N" },
2405
+ callbackDate: "",
2406
+ callbackHrs: "",
2407
+ callbackMins: ""
2408
+ });
2409
+ };
2410
+ const handleClose = () => {
2411
+ handleReset();
2412
+ setOpen(false);
2413
+ };
2414
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2415
+ import_material3.Dialog,
2416
+ {
2417
+ open,
2418
+ "aria-labelledby": "alert-dialog-title",
2419
+ "aria-describedby": "alert-dialog-description",
2420
+ fullWidth: true,
2421
+ maxWidth: "xs",
2422
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2423
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2424
+ import_material3.Box,
2425
+ {
2426
+ sx: {
2427
+ display: "flex",
2428
+ justifyContent: "center",
2429
+ alignItems: "center",
2430
+ padding: "4px 16px",
2431
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2432
+ },
2433
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2434
+ import_material3.Typography,
2435
+ {
2436
+ variant: "body1",
2437
+ m: 1,
2438
+ children: [
2439
+ " ",
2440
+ "Call Disposition"
2441
+ ]
2442
+ }
2443
+ )
2444
+ }
2445
+ ),
2446
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2447
+ import_material3.Box,
2448
+ {
2449
+ sx: {
2450
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2451
+ padding: "10px",
2452
+ margin: "10px",
2453
+ borderRadius: "10px"
2454
+ },
2455
+ children: [
2456
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2457
+ import_material3.Box,
2458
+ {
2459
+ display: "flex",
2460
+ gap: 2,
2461
+ children: [
2462
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2463
+ import_material3.Autocomplete,
2464
+ {
2465
+ value: formData.disposition,
2466
+ options: dispositionOptions,
2467
+ getOptionLabel: (opt) => opt.label,
2468
+ onChange: (_, val) => handleChange("disposition", val),
2469
+ size: "small",
2470
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2471
+ import_material3.TextField,
2472
+ __spreadProps(__spreadValues({}, params), {
2473
+ label: "Disposition",
2474
+ fullWidth: true
2475
+ })
2476
+ ),
2477
+ sx: { flex: 1 }
2478
+ }
2479
+ ),
2480
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2481
+ import_material3.Autocomplete,
2482
+ {
2483
+ options: followUpOptions,
2484
+ getOptionLabel: (opt) => opt.label,
2485
+ value: formData.followUp,
2486
+ onChange: (_, val) => handleChange("followUp", val),
2487
+ size: "small",
2488
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2489
+ import_material3.TextField,
2490
+ __spreadProps(__spreadValues({}, params), {
2491
+ label: "Follow Up",
2492
+ fullWidth: true
2493
+ })
2494
+ ),
2495
+ sx: { flex: 1 }
2496
+ }
2497
+ )
2498
+ ]
2499
+ }
2500
+ ),
2501
+ ((_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)(
2502
+ import_material3.Box,
2503
+ {
2504
+ display: "flex",
2505
+ gap: 2,
2506
+ mt: 2,
2507
+ children: [
2508
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2509
+ import_material3.TextField,
2510
+ {
2511
+ size: "small",
2512
+ label: "Callback Date",
2513
+ type: "date",
2514
+ slotProps: {
2515
+ inputLabel: { shrink: true }
2516
+ },
2517
+ value: formData.callbackDate,
2518
+ onChange: (e) => handleChange("callbackDate", e.target.value),
2519
+ fullWidth: true,
2520
+ sx: { flex: 1 }
2521
+ }
2522
+ ),
2523
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2524
+ import_material3.TextField,
2525
+ {
2526
+ size: "small",
2527
+ label: "Hours (0-23)",
2528
+ type: "text",
2529
+ value: formData.callbackHrs,
2530
+ onChange: (e) => handleChange("callbackHrs", e.target.value),
2531
+ fullWidth: true,
2532
+ sx: { flex: 1 }
2533
+ }
2534
+ )
2535
+ ]
2536
+ }
2537
+ ),
2538
+ ((_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)(
2539
+ import_material3.Box,
2540
+ {
2541
+ display: "flex",
2542
+ gap: 2,
2543
+ mt: 2,
2544
+ children: [
2545
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2546
+ import_material3.TextField,
2547
+ {
2548
+ size: "small",
2549
+ label: "Minutes (0-59)",
2550
+ type: "text",
2551
+ value: formData.callbackMins,
2552
+ onChange: (e) => handleChange("callbackMins", e.target.value),
2553
+ fullWidth: true,
2554
+ sx: { flex: 1 }
2555
+ }
2556
+ ),
2557
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Box, { sx: { flex: 1 } })
2558
+ ]
2559
+ }
2560
+ )
2561
+ ]
2562
+ }
2563
+ ),
2564
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2565
+ import_material3.Box,
2566
+ {
2567
+ textAlign: "right",
2568
+ m: 2,
2569
+ children: [
2570
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2571
+ import_material3.Button,
2572
+ {
2573
+ variant: "outlined",
2574
+ color: "error",
2575
+ size: "large",
2576
+ onClick: handleClose,
2577
+ sx: {
2578
+ px: 2,
2579
+ mx: 1,
2580
+ borderRadius: "10px",
2581
+ textTransform: "capitalize"
2582
+ },
2583
+ children: "cancel"
2584
+ }
2585
+ ),
2586
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2587
+ import_material3.Button,
2588
+ {
2589
+ variant: "contained",
2590
+ color: "primary",
2591
+ size: "large",
2592
+ onClick: () => onSubmitDisposition(formData),
2593
+ sx: { px: 2, borderRadius: "10px", textTransform: "capitalize" },
2594
+ children: "Submit"
2595
+ }
2596
+ )
2597
+ ]
2598
+ }
2599
+ )
2600
+ ] })
2601
+ }
2602
+ ) });
2603
+ }
2604
+ function ProcessorListDialog({
2605
+ open,
2606
+ setOpen,
2607
+ processList = null,
2608
+ handleSelectedProcessor
2609
+ }) {
2610
+ const handleClose = () => {
2611
+ setOpen(false);
2612
+ };
2613
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2614
+ import_material3.Dialog,
2615
+ {
2616
+ open,
2617
+ "aria-labelledby": "alert-dialog-title",
2618
+ "aria-describedby": "alert-dialog-description",
2619
+ maxWidth: "xs",
2620
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2621
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2622
+ import_material3.Box,
2623
+ {
2624
+ sx: {
2625
+ display: "flex",
2626
+ justifyContent: "space-between",
2627
+ alignItems: "center",
2628
+ padding: "4px 16px",
2629
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2630
+ },
2631
+ children: [
2632
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Process List" }),
2633
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
2634
+ ]
2635
+ }
2636
+ ),
2637
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2638
+ import_material3.Box,
2639
+ {
2640
+ sx: {
2641
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2642
+ padding: "6px 10px",
2643
+ margin: "10px",
2644
+ borderRadius: "10px"
2645
+ },
2646
+ children: processList.length > 0 ? processList == null ? void 0 : processList.map((process, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2647
+ import_material3.Box,
2648
+ {
2649
+ sx: {
2650
+ p: 1,
2651
+ display: "flex",
2652
+ alignItems: "center",
2653
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2654
+ padding: "6px",
2655
+ margin: "10px 0px",
2656
+ borderRadius: "10px",
2657
+ cursor: "pointer",
2658
+ "&:hover": { bgcolor: "action.selected" }
2659
+ },
2660
+ onClick: () => {
2661
+ handleSelectedProcessor(process);
2662
+ },
2663
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2664
+ import_material3.Typography,
2665
+ {
2666
+ variant: "body1",
2667
+ sx: {
2668
+ mx: 1,
2669
+ width: "200px",
2670
+ maxWidth: "250px",
2671
+ display: "flex",
2672
+ alignItems: "center"
2673
+ },
2674
+ children: [
2675
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2676
+ process.process_name
2677
+ ]
2678
+ }
2679
+ )
2680
+ },
2681
+ index
2682
+ )) : null
2683
+ }
2684
+ )
2685
+ ] })
2686
+ }
2687
+ ) });
2688
+ }
2689
+ function CallHistoryDialog({ open, setOpen }) {
2690
+ const handleClose = () => {
2691
+ setOpen(false);
2692
+ };
2693
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2694
+ import_material3.Dialog,
2695
+ {
2696
+ open,
2697
+ "aria-labelledby": "alert-dialog-title",
2698
+ "aria-describedby": "alert-dialog-description",
2699
+ fullWidth: true,
2700
+ maxWidth: "md",
2701
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2702
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2703
+ import_material3.Box,
2704
+ {
2705
+ sx: {
2706
+ display: "flex",
2707
+ justifyContent: "space-between",
2708
+ alignItems: "center",
2709
+ padding: "4px 16px",
2710
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2711
+ },
2712
+ children: [
2713
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Call History" }),
2714
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
2715
+ ]
2716
+ }
2717
+ ),
2718
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2719
+ import_material3.Box,
2720
+ {
2721
+ sx: {
2722
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2723
+ margin: "10px",
2724
+ borderRadius: "10px",
2725
+ textAlign: "center",
2726
+ fontSize: "16px",
2727
+ fontWeight: "bold"
2728
+ },
2729
+ p: 6,
2730
+ children: "Coming Soon..."
2731
+ }
2732
+ )
2733
+ ] })
2734
+ }
2735
+ ) });
2736
+ }
2737
+
2738
+ // call-control-sdk/lib/ringtones/incoming.mp3
2739
+ var incoming_default = "./incoming-4WP3FJI4.mp3";
2740
+
2741
+ // call-control-sdk/lib/components/callControls.tsx
2742
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2743
+ var getCombineConfrenceData = (conferenceData, apiData, data) => {
2744
+ const updatedConferenceData = conferenceData.map((item) => {
2745
+ var _a2, _b, _c;
2746
+ if ((item == null ? void 0 : item.line) === 1) {
2747
+ const statusKey = `line_${item.line}_status`;
2748
+ return __spreadProps(__spreadValues({}, item), {
2749
+ line: 1,
2750
+ status: (_a2 = apiData[statusKey]) != null ? _a2 : data == null ? void 0 : data.status,
2751
+ phone: (_b = data == null ? void 0 : data.phone_number) != null ? _b : ""
2752
+ // isMute: false,
2753
+ // isHold: false,
2754
+ // isMergeCall: false,
2755
+ // isCallStart: true,
2756
+ });
2757
+ } else {
2758
+ const statusKey = `line_${item.line}_status`;
2759
+ const phoneKey = `line_${item.line}_phonenumber`;
2760
+ return __spreadProps(__spreadValues({}, item), {
2761
+ status: (_c = apiData[statusKey]) != null ? _c : "IDLE",
2762
+ phone: apiData[phoneKey] !== "0" ? apiData[phoneKey] : ""
2763
+ });
2764
+ }
2765
+ });
2766
+ return updatedConferenceData;
2767
+ };
2768
+ var formatDuration = (seconds) => {
2769
+ const mins = Math.floor(seconds / 60);
2770
+ const secs = seconds % 60;
2771
+ return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
2772
+ };
2773
+ function CallControls({ onDataChange }) {
2774
+ 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;
2775
+ const theme = (0, import_material4.useTheme)();
2776
+ const state = useSDKState();
2777
+ const { showToast } = useToast();
2778
+ const { disabled, enabled, outlined } = styles_default({
2779
+ disabled: ((_a2 = state.sdkConfig) == null ? void 0 : _a2.disabled) || {},
2780
+ enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
2781
+ outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
2782
+ });
2783
+ const webSocketRef = (0, import_react11.useRef)(null);
2784
+ const audioRef = (0, import_react11.useRef)(null);
2785
+ const reconnectTimeoutRef = (0, import_react11.useRef)(null);
2786
+ const pingIntervalRef = (0, import_react11.useRef)(null);
2787
+ const reconnectAttemptsRef = (0, import_react11.useRef)(0);
2788
+ const maxReconnectAttempts = 60;
2789
+ const baseReconnectDelay = 1e3;
2790
+ const maxReconnectDelay = 3e4;
2791
+ const [anchorEl, setAnchorEl] = (0, import_react11.useState)(null);
2792
+ const [showIframe, setShowIframe] = (0, import_react11.useState)(true);
2793
+ const [statusAnchorEl, setStatusAnchorEl] = (0, import_react11.useState)(null);
2794
+ const [dialerAnchorEl, setDialerAnchorEl] = (0, import_react11.useState)(null);
2795
+ const [openCallDisposition, setOpenCallDisposition] = (0, import_react11.useState)(false);
2796
+ const [openProcessorDialog, setOpenProcessorDialog] = (0, import_react11.useState)(false);
2797
+ const [openCallHistoryDialog, setOpenCallHistoryDialog] = (0, import_react11.useState)(false);
2798
+ const [processList, setProcessList] = (0, import_react11.useState)(null);
2799
+ const [phoneNumber, setPhoneNumber] = (0, import_react11.useState)("");
2800
+ const [callDuration, setCallDuration] = (0, import_react11.useState)(0);
2801
+ const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
2802
+ state.controlPanelPosition,
2803
+ (newPosition) => sdkStateManager.setControlPanelPosition(newPosition)
2804
+ );
2805
+ const {
2806
+ position: iframePosition,
2807
+ isDragging: iframeIsDragging,
2808
+ dragRef: iframeDragRef,
2809
+ handleMouseDown: iframeHandleMouseDown,
2810
+ handleTouchStart: iframeHandleTouchStart
2811
+ } = useDraggable(
2812
+ state.iframePosition,
2813
+ (newPosition) => sdkStateManager.setIframePosition(newPosition)
2814
+ );
2815
+ const [clickToCall, { isLoading: clickToCallLoading }] = usePostRequest({
2816
+ onSuccess: () => {
2817
+ setPhoneNumber("");
2818
+ setDialerAnchorEl(null);
2819
+ }
2820
+ });
2821
+ const [holdOrUnHold, { isLoading: holdOrUnHoldLoading }] = usePostRequest({
2822
+ onSuccess: () => {
2823
+ sdkStateManager.setHolding(!state.isHolding);
2824
+ },
2825
+ onError: (error) => {
2826
+ console.log("\u274C Hold operation error:", error);
2827
+ }
2828
+ });
2829
+ const [muteOrUnMute, { isLoading: muteOrUnMuteLoading }] = usePostRequest({
2830
+ onSuccess: () => {
2831
+ sdkStateManager.setMuted(!state.isMuted);
2832
+ },
2833
+ onError: (error) => {
2834
+ console.log("\u274C Mute operation error:", error);
2835
+ }
2836
+ });
2837
+ const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest();
2838
+ const [updateAgentStatus, { isLoading }] = usePostRequest();
2839
+ const [endCall, { isLoading: endCallLoading }] = usePostRequest();
2840
+ const handleCloseQueueCounts = () => {
2841
+ setAnchorEl(null);
2842
+ };
2843
+ const handleOpenDialer = (event) => {
2844
+ setShowIframe(true);
2845
+ setDialerAnchorEl(event.currentTarget);
2846
+ sdkStateManager.setStatus("dial");
2847
+ };
2848
+ const handleCloseDialer = () => {
2849
+ if (state.status !== "on call") {
2850
+ sdkStateManager.setStatus("idle");
2851
+ }
2852
+ setDialerAnchorEl(null);
2853
+ };
2854
+ const handleOpenAgentStatus = (event) => {
2855
+ setStatusAnchorEl(event.currentTarget);
2856
+ };
2857
+ const handleCloseAgentStatus = () => {
2858
+ setStatusAnchorEl(null);
2859
+ };
2860
+ const handleAgentReady = () => {
2861
+ const payload = {
2862
+ action: "READYAGENT",
2863
+ userId: state.agentId
2864
+ };
2865
+ readyAgentStatus(END_POINT.READY_AGENT, payload);
2866
+ };
2867
+ const handleUpdateAgentStatus = (status) => {
2868
+ setStatusAnchorEl(null);
2869
+ const payload = {
2870
+ action: "AGENTBREAK",
2871
+ break_type: status,
2872
+ userId: state.agentId
2873
+ };
2874
+ updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload);
2875
+ };
2876
+ const handleStartCall = (number) => {
2877
+ if (number.length !== 10) {
2878
+ showToast("Invalid phone number", "error");
2879
+ } else if (!/^\d+$/.test(number)) {
2880
+ showToast("Invalid phone number", "error");
2881
+ } else {
2882
+ const payload = {
2883
+ action: "CALL",
2884
+ phone_number: number,
2885
+ userId: state.agentId
2886
+ };
2887
+ clickToCall(END_POINT.CLICK_TO_CALL, payload);
2888
+ }
2889
+ };
2890
+ const handleHoldToggle = () => {
2891
+ const payload = {
2892
+ action: state.isHolding ? "UNHOLD" : "HOLD",
2893
+ userId: state.agentId
2894
+ };
2895
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
2896
+ };
2897
+ const handleMuteToggle = () => {
2898
+ const payload = {
2899
+ action: state.isMuted ? "UNMUTE" : "MUTE",
2900
+ userId: state.agentId
2901
+ };
2902
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
2903
+ };
2904
+ const handleEndCall = (data) => {
2905
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
2906
+ const payload = {
2907
+ action: "ENDCALL",
2908
+ userId: state.agentId,
2909
+ processid: (_c2 = (_b2 = (_a3 = state.process) == null ? void 0 : _a3.process_id) == null ? void 0 : _b2.toString()) != null ? _c2 : "",
2910
+ process_name: (_e2 = (_d2 = state.process) == null ? void 0 : _d2.process_name) != null ? _e2 : "",
2911
+ callreferenceid: (_g2 = (_f2 = state.callData) == null ? void 0 : _f2.convox_id) != null ? _g2 : "",
2912
+ mobile_number: (_i2 = (_h2 = state.callData) == null ? void 0 : _h2.phone_number) != null ? _i2 : "",
2913
+ disposition: (_k2 = (_j2 = data == null ? void 0 : data.disposition) == null ? void 0 : _j2.value) != null ? _k2 : "",
2914
+ set_followUp: (_m2 = (_l2 = data == null ? void 0 : data.followUp) == null ? void 0 : _l2.value) != null ? _m2 : "",
2915
+ callback_date: (_n2 = data == null ? void 0 : data.callbackDate) != null ? _n2 : "",
2916
+ callback_hrs: (_o2 = data == null ? void 0 : data.callbackHrs) != null ? _o2 : "",
2917
+ callback_mins: (_p2 = data == null ? void 0 : data.callbackMins) != null ? _p2 : "",
2918
+ endcall_type: "CLOSE"
2919
+ };
2920
+ setPhoneNumber("");
2921
+ endCall(END_POINT.END_CALL, payload);
2922
+ sdkStateManager.endCall();
2923
+ setOpenCallDisposition(false);
2924
+ };
2925
+ (0, import_react11.useEffect)(() => {
2926
+ const handleBeforeUnload = (e) => {
2927
+ e.preventDefault();
2928
+ };
2929
+ window.addEventListener("beforeunload", handleBeforeUnload);
2930
+ return () => {
2931
+ window.removeEventListener("beforeunload", handleBeforeUnload);
2932
+ };
2933
+ }, []);
2934
+ (0, import_react11.useEffect)(() => {
2935
+ let interval;
2936
+ if (state.callData.status && state.callData.status === "ONCALL") {
2937
+ interval = setInterval(() => {
2938
+ const elapsed = Math.floor((Date.now() - state.callStartTime) / 1e3);
2939
+ setCallDuration(elapsed);
2940
+ }, 1e3);
2941
+ } else {
2942
+ setCallDuration(0);
2943
+ }
2944
+ return () => {
2945
+ if (interval) clearInterval(interval);
2946
+ };
2947
+ }, [state.callData.status]);
2948
+ (0, import_react11.useEffect)(() => {
2949
+ audioRef.current = new Audio(incoming_default);
2950
+ audioRef.current.loop = true;
2951
+ audioRef.current.volume = 0.7;
2952
+ return () => {
2953
+ if (audioRef.current) {
2954
+ audioRef.current.pause();
2955
+ audioRef.current.currentTime = 0;
2956
+ audioRef.current = null;
2957
+ }
2958
+ };
2959
+ }, []);
2960
+ (0, import_react11.useEffect)(() => {
2961
+ if (onDataChange && state.callData) {
2962
+ const { process_id, process_name, status, phone_number, agent_id, convox_id } = state.callData;
2963
+ const callData = {
2964
+ phone_number,
2965
+ status,
2966
+ callReferenceId: convox_id,
2967
+ agent_id,
2968
+ process_id,
2969
+ process_name
2970
+ };
2971
+ onDataChange(callData);
2972
+ }
2973
+ }, [state.callData, onDataChange]);
2974
+ (0, import_react11.useEffect)(() => {
2975
+ if (state.agentId) {
2976
+ axios_default.post(END_POINT.PROCESS_LIST, {
2977
+ userId: state.agentId,
2978
+ action: "GETAGENTPROCESSLIST",
2979
+ refno: "1234221233"
2980
+ }).then((res) => {
2981
+ var _a3, _b2;
2982
+ if (res && res.data && ((_a3 = res == null ? void 0 : res.data) == null ? void 0 : _a3.length) > 1) {
2983
+ setProcessList(res.data.data);
2984
+ setOpenProcessorDialog(true);
2985
+ } else {
2986
+ sdkStateManager.setProcess((_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.data[0]);
2987
+ setOpenProcessorDialog(false);
2988
+ }
2989
+ }).catch((err) => {
2990
+ showToast(err.response.data.message, "error");
2991
+ });
2992
+ } else {
2993
+ console.log("No agentId available, skipping API call");
2994
+ }
2995
+ }, [state.agentId]);
2996
+ const connectWebSocket = () => {
2997
+ if (!state.agentId) {
2998
+ console.log("No agentId available, cannot connect WebSocket");
2999
+ return;
3000
+ }
3001
+ if (reconnectTimeoutRef.current) {
3002
+ clearTimeout(reconnectTimeoutRef.current);
3003
+ reconnectTimeoutRef.current = null;
3004
+ }
3005
+ try {
3006
+ webSocketRef.current = new WebSocket(`${WS_END_POINT.WS}?agent_id=${state.agentId}`);
3007
+ webSocketRef.current.onopen = () => {
3008
+ console.log("\u{1F310} WebSocket connection established");
3009
+ reconnectAttemptsRef.current = 0;
3010
+ if (pingIntervalRef.current) {
3011
+ clearInterval(pingIntervalRef.current);
3012
+ }
3013
+ pingIntervalRef.current = setInterval(() => {
3014
+ if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) {
3015
+ try {
3016
+ webSocketRef.current.send(JSON.stringify({ type: "ping" }));
3017
+ console.log("\u{1F4E1} WebSocket ping sent");
3018
+ } catch (error) {
3019
+ console.error("Failed to send ping:", error);
3020
+ }
3021
+ }
3022
+ }, 3e4);
3023
+ };
3024
+ webSocketRef.current.onmessage = (event) => {
3025
+ try {
3026
+ const data = JSON.parse(event.data);
3027
+ if (data.type === "pong") {
3028
+ console.log("\u{1F4E1} WebSocket pong received");
3029
+ return;
3030
+ }
3031
+ const confrence = getCombineConfrenceData(
3032
+ state == null ? void 0 : state.conferenceLine,
3033
+ data == null ? void 0 : data.conferencestatus,
3034
+ data
3035
+ );
3036
+ sdkStateManager.updateCallData(data);
3037
+ sdkStateManager.updateConferenceData([...confrence]);
3038
+ if (data.status === "RINGING" || data.status === "DIALING") {
3039
+ if (audioRef.current) {
3040
+ audioRef.current.play().catch((error) => {
3041
+ console.error("Failed to play ringtone:", error);
3042
+ });
3043
+ }
3044
+ }
3045
+ if (data.status === "ONCALL") {
3046
+ if (audioRef.current) {
3047
+ audioRef.current.pause();
3048
+ audioRef.current.currentTime = 0;
3049
+ }
3050
+ sdkStateManager.startCall();
3051
+ if (!showIframe) {
3052
+ setShowIframe(true);
3053
+ }
3054
+ }
3055
+ if (data.status === "WRAPUP") {
3056
+ if (audioRef.current) {
3057
+ audioRef.current.pause();
3058
+ audioRef.current.currentTime = 0;
3059
+ }
3060
+ sdkStateManager.endCall();
3061
+ }
3062
+ } catch (e) {
3063
+ console.log("\u{1F4E8} Raw message:", event.data);
3064
+ }
3065
+ };
3066
+ webSocketRef.current.onclose = (event) => {
3067
+ console.log("\u{1F50C} WebSocket connection closed", event.code, event.reason);
3068
+ if (pingIntervalRef.current) {
3069
+ clearInterval(pingIntervalRef.current);
3070
+ pingIntervalRef.current = null;
3071
+ }
3072
+ if (event.code !== 1e3 && reconnectAttemptsRef.current < maxReconnectAttempts) {
3073
+ reconnectAttemptsRef.current += 1;
3074
+ const delay = Math.min(
3075
+ baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3076
+ maxReconnectDelay
3077
+ );
3078
+ console.log(
3079
+ `\u{1F504} Attempting to reconnect WebSocket (attempt ${reconnectAttemptsRef.current}/${maxReconnectAttempts}) in ${delay}ms`
3080
+ );
3081
+ reconnectTimeoutRef.current = setTimeout(() => {
3082
+ connectWebSocket();
3083
+ }, delay);
3084
+ } else if (reconnectAttemptsRef.current >= maxReconnectAttempts) {
3085
+ console.error("\u274C Maximum reconnection attempts reached. Please refresh the page.");
3086
+ showToast("WebSocket connection failed. Please refresh the page.", "error");
3087
+ }
3088
+ };
3089
+ webSocketRef.current.onerror = (error) => {
3090
+ console.error("\u274C WebSocket error:", error);
3091
+ };
3092
+ } catch (error) {
3093
+ console.error("\u274C Failed to create WebSocket:", error);
3094
+ if (reconnectAttemptsRef.current < maxReconnectAttempts) {
3095
+ reconnectAttemptsRef.current += 1;
3096
+ const delay = Math.min(
3097
+ baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3098
+ maxReconnectDelay
3099
+ );
3100
+ reconnectTimeoutRef.current = setTimeout(() => {
3101
+ connectWebSocket();
3102
+ }, delay);
3103
+ }
3104
+ }
3105
+ };
3106
+ (0, import_react11.useEffect)(() => {
3107
+ if (state.agentId) {
3108
+ connectWebSocket();
3109
+ }
3110
+ return () => {
3111
+ if (reconnectTimeoutRef.current) {
3112
+ clearTimeout(reconnectTimeoutRef.current);
3113
+ reconnectTimeoutRef.current = null;
3114
+ }
3115
+ if (pingIntervalRef.current) {
3116
+ clearInterval(pingIntervalRef.current);
3117
+ pingIntervalRef.current = null;
3118
+ }
3119
+ if (webSocketRef.current) {
3120
+ webSocketRef.current.close(1e3, "Component unmounting");
3121
+ webSocketRef.current = null;
3122
+ }
3123
+ reconnectAttemptsRef.current = 0;
3124
+ };
3125
+ }, [state.agentId]);
3126
+ if (!state.isInitialized || !state.process) {
3127
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: Boolean(openProcessorDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3128
+ ProcessorListDialog,
3129
+ {
3130
+ processList,
3131
+ open: openProcessorDialog,
3132
+ setOpen: setOpenProcessorDialog,
3133
+ handleSelectedProcessor: (data) => {
3134
+ sdkStateManager.setProcess(data);
3135
+ }
3136
+ }
3137
+ ) });
3138
+ }
3139
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
3140
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3141
+ import_material4.Fade,
3142
+ {
3143
+ in: true,
3144
+ timeout: 300,
3145
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3146
+ import_material4.Paper,
3147
+ {
3148
+ ref: ((_d = state.sdkConfig) == null ? void 0 : _d.isDraggable) ? dragRef : null,
3149
+ elevation: isDragging ? 4 : ((_e = state.sdkConfig) == null ? void 0 : _e.isDraggable) ? 1 : 0,
3150
+ sx: {
3151
+ position: ((_f = state.sdkConfig) == null ? void 0 : _f.isDraggable) ? "fixed" : "relative",
3152
+ left: ((_g = state.sdkConfig) == null ? void 0 : _g.isDraggable) ? position.x : "auto",
3153
+ top: ((_h = state.sdkConfig) == null ? void 0 : _h.isDraggable) ? position.y : "auto",
3154
+ display: "inline-block",
3155
+ width: "auto",
3156
+ flexShrink: 0,
3157
+ whiteSpace: "nowrap",
3158
+ p: 0.5,
3159
+ borderRadius: 3,
3160
+ bgcolor: "background.paper",
3161
+ zIndex: ((_i = state.sdkConfig) == null ? void 0 : _i.isDraggable) ? Number.MAX_SAFE_INTEGER : 0,
3162
+ transition: theme.transitions.create(["box-shadow", "transform"], {
3163
+ duration: theme.transitions.duration.short
3164
+ }),
3165
+ userSelect: "none"
3166
+ },
3167
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3168
+ import_material4.Box,
3169
+ {
3170
+ sx: {
3171
+ display: "flex",
3172
+ alignItems: "center"
3173
+ },
3174
+ children: [
3175
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3176
+ import_material4.Box,
3177
+ {
3178
+ sx: {
3179
+ display: "flex",
3180
+ alignItems: "center",
3181
+ gap: 1,
3182
+ margin: "0px 10px"
3183
+ },
3184
+ children: [
3185
+ ((_j = state.sdkConfig) == null ? void 0 : _j.isDraggable) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3186
+ import_material4.IconButton,
3187
+ {
3188
+ component: "div",
3189
+ size: "small",
3190
+ sx: {
3191
+ cursor: "all-scroll"
3192
+ },
3193
+ onMouseDown: handleMouseDown,
3194
+ onTouchStart: handleTouchStart,
3195
+ children: [
3196
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.DragIndicator, {}),
3197
+ " "
3198
+ ]
3199
+ }
3200
+ ),
3201
+ /* @__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)(
3202
+ import_material4.IconButton,
3203
+ {
3204
+ size: "small",
3205
+ onClick: (e) => {
3206
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
3207
+ 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") {
3208
+ handleOpenDialer(e);
3209
+ }
3210
+ },
3211
+ sx: {
3212
+ bgcolor: "action.hover",
3213
+ "&:hover": {
3214
+ bgcolor: "warning"
3215
+ }
3216
+ },
3217
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3218
+ import_icons_material2.WifiCalling3,
3219
+ {
3220
+ sx: {
3221
+ 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"
3222
+ }
3223
+ }
3224
+ )
3225
+ }
3226
+ ) }) }),
3227
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3228
+ import_material4.Typography,
3229
+ {
3230
+ sx: {
3231
+ color: "success.main",
3232
+ width: "40px",
3233
+ marginRight: "10px",
3234
+ fontSize: "18px",
3235
+ fontWeight: "600"
3236
+ },
3237
+ children: formatDuration(callDuration)
3238
+ }
3239
+ ),
3240
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3241
+ import_material4.Chip,
3242
+ {
3243
+ sx: {
3244
+ padding: "18px 0px"
3245
+ },
3246
+ label: isLoading || agentReadyLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3247
+ import_material4.Box,
3248
+ {
3249
+ sx: {
3250
+ fontWeight: "bold",
3251
+ width: "60px",
3252
+ display: "flex",
3253
+ alignItems: "center",
3254
+ justifyContent: "center"
3255
+ },
3256
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.CircularProgress, { size: "20px" })
3257
+ }
3258
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3259
+ import_material4.Typography,
3260
+ {
3261
+ variant: "body2",
3262
+ sx: {
3263
+ fontWeight: "bold",
3264
+ width: "60px",
3265
+ textAlign: "center"
3266
+ },
3267
+ children: (_v = (_u = (_t = state.callData) == null ? void 0 : _t.status) == null ? void 0 : _u.toUpperCase()) != null ? _v : "N/A"
3268
+ }
3269
+ ),
3270
+ onClick: handleOpenAgentStatus,
3271
+ deleteIcon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.KeyboardArrowDown, { color: "primary" }),
3272
+ onDelete: handleOpenAgentStatus
3273
+ }
3274
+ )
3275
+ ]
3276
+ }
3277
+ ),
3278
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3279
+ import_material4.Box,
3280
+ {
3281
+ sx: {
3282
+ display: "flex",
3283
+ gap: 1,
3284
+ justifyContent: "center",
3285
+ alignItems: "center"
3286
+ },
3287
+ children: [
3288
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Agent Ready", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3289
+ import_material4.Button,
3290
+ {
3291
+ 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",
3292
+ onClick: (e) => {
3293
+ var _a3, _b2, _c2, _d2;
3294
+ 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") {
3295
+ e.stopPropagation();
3296
+ handleAgentReady();
3297
+ }
3298
+ },
3299
+ classes: {
3300
+ 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"
3301
+ },
3302
+ 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),
3303
+ disabled: agentReadyLoading,
3304
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.SupportAgent, {})
3305
+ }
3306
+ ) }),
3307
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: state.isHolding ? "Resume" : "Hold", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3308
+ import_material4.Button,
3309
+ {
3310
+ variant: state.isHolding && ((_J = (_I = state.callData) == null ? void 0 : _I.status) == null ? void 0 : _J.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
3311
+ onClick: (e) => {
3312
+ e.stopPropagation();
3313
+ handleHoldToggle();
3314
+ },
3315
+ sx: state.isHolding && ((_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),
3316
+ disabled: ((_P = (_O = state.callData) == null ? void 0 : _O.status) == null ? void 0 : _P.toUpperCase()) !== "ONCALL" && !state.isHolding || holdOrUnHoldLoading,
3317
+ children: holdOrUnHoldLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3318
+ import_material4.CircularProgress,
3319
+ {
3320
+ size: "20px",
3321
+ sx: {
3322
+ color: theme.palette.primary.main
3323
+ }
3324
+ }
3325
+ ) : state.isHolding ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Pause, {})
3326
+ }
3327
+ ) }),
3328
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: state.isMuted ? "Unmute" : "Mute", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3329
+ import_material4.Button,
3330
+ {
3331
+ variant: state.isMuted && ((_R = (_Q = state.callData) == null ? void 0 : _Q.status) == null ? void 0 : _R.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
3332
+ onClick: (e) => {
3333
+ e.stopPropagation();
3334
+ handleMuteToggle();
3335
+ },
3336
+ sx: state.isMuted && ((_T = (_S = state.callData) == null ? void 0 : _S.status) == null ? void 0 : _T.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_V = (_U = state.callData) == null ? void 0 : _U.status) == null ? void 0 : _V.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3337
+ disabled: ((_X = (_W = state.callData) == null ? void 0 : _W.status) == null ? void 0 : _X.toUpperCase()) !== "ONCALL" && !state.isMuted || muteOrUnMuteLoading,
3338
+ children: muteOrUnMuteLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3339
+ import_material4.CircularProgress,
3340
+ {
3341
+ size: "20px",
3342
+ sx: {
3343
+ color: theme.palette.primary.main
3344
+ }
3345
+ }
3346
+ ) : state.isMuted ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.MicOff, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Mic, {})
3347
+ }
3348
+ ) }),
3349
+ !((_Y = state.sdkConfig) == null ? void 0 : _Y.disableCallTransferButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Transfer Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3350
+ import_material4.Button,
3351
+ {
3352
+ variant: state.openCallTransferDialog ? "contained" : "outlined",
3353
+ onClick: (e) => {
3354
+ var _a3, _b2;
3355
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL") {
3356
+ e.stopPropagation();
3357
+ sdkStateManager.setOpenCallTransferDialog(true);
3358
+ }
3359
+ },
3360
+ sx: state.openCallTransferDialog ? __spreadValues({}, enabled) : ((__ = (_Z = state.callData) == null ? void 0 : _Z.status) == null ? void 0 : __.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3361
+ disabled: ((_aa = (_$ = state.callData) == null ? void 0 : _$.status) == null ? void 0 : _aa.toUpperCase()) !== "ONCALL",
3362
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.TransferWithinAStation, {})
3363
+ }
3364
+ ) }),
3365
+ !((_ba = state.sdkConfig) == null ? void 0 : _ba.disableConferenceButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Conference Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3366
+ import_material4.Button,
3367
+ {
3368
+ variant: state.openConferenceDialog ? "contained" : "outlined",
3369
+ onClick: (e) => {
3370
+ var _a3, _b2;
3371
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL") {
3372
+ e.stopPropagation();
3373
+ sdkStateManager.setOpenConferenceDialog(true);
3374
+ }
3375
+ },
3376
+ sx: state.openConferenceDialog ? __spreadValues({}, enabled) : ((_da = (_ca = state.callData) == null ? void 0 : _ca.status) == null ? void 0 : _da.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3377
+ disabled: ((_fa = (_ea = state.callData) == null ? void 0 : _ea.status) == null ? void 0 : _fa.toUpperCase()) !== "ONCALL",
3378
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Group, {})
3379
+ }
3380
+ ) }),
3381
+ !((_ga = state.sdkConfig) == null ? void 0 : _ga.disableEndCallButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "End Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3382
+ import_material4.Button,
3383
+ {
3384
+ variant: ((_ia = (_ha = state.callData) == null ? void 0 : _ha.status) == null ? void 0 : _ia.toUpperCase()) === "ONCALL" || ((_ka = (_ja = state.callData) == null ? void 0 : _ja.status) == null ? void 0 : _ka.toUpperCase()) === "RINGING" || ((_ma = (_la = state.callData) == null ? void 0 : _la.status) == null ? void 0 : _ma.toUpperCase()) === "WRAPUP" ? "contained" : "outlined",
3385
+ onClick: (e) => {
3386
+ var _a3, _b2, _c2, _d2, _e2, _f2;
3387
+ 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") {
3388
+ e.stopPropagation();
3389
+ setOpenCallDisposition(true);
3390
+ }
3391
+ },
3392
+ sx: ((_oa = (_na = state.callData) == null ? void 0 : _na.status) == null ? void 0 : _oa.toUpperCase()) === "ONCALL" || ((_qa = (_pa = state.callData) == null ? void 0 : _pa.status) == null ? void 0 : _qa.toUpperCase()) === "RINGING" || ((_sa = (_ra = state.callData) == null ? void 0 : _ra.status) == null ? void 0 : _sa.toUpperCase()) === "WRAPUP" ? __spreadProps(__spreadValues({}, enabled), {
3393
+ borderRight: "1px",
3394
+ backgroundColor: "error.main",
3395
+ minWidth: "60px !important",
3396
+ boxShadow: " 0px 2px 1px #5f3f3f",
3397
+ border: `1px solid ${theme.palette.error.light}`,
3398
+ height: "40px",
3399
+ "&:hover": {
3400
+ bgcolor: "error.light",
3401
+ boxShadow: " 0px 2px 1px #5f3f3f",
3402
+ border: `0px solid ${theme.palette.error.light}`
3403
+ },
3404
+ "&:active": {
3405
+ bgcolor: "error.light",
3406
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
3407
+ }
3408
+ }) : __spreadProps(__spreadValues({}, disabled), {
3409
+ minWidth: "60px !important"
3410
+ }),
3411
+ disabled: ((_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" || endCallLoading,
3412
+ children: endCallLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3413
+ import_material4.CircularProgress,
3414
+ {
3415
+ size: "20px",
3416
+ color: "error"
3417
+ }
3418
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.CallEnd, {})
3419
+ }
3420
+ ) })
3421
+ ]
3422
+ }
3423
+ )
3424
+ ]
3425
+ }
3426
+ )
3427
+ }
3428
+ )
3429
+ }
3430
+ ) }),
3431
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3432
+ import_material4.Fade,
3433
+ {
3434
+ in: true,
3435
+ timeout: 300,
3436
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3437
+ import_material4.Paper,
3438
+ {
3439
+ ref: iframeDragRef,
3440
+ elevation: iframeIsDragging ? 4 : 1,
3441
+ sx: {
3442
+ position: "absolute",
3443
+ left: iframePosition.x,
3444
+ top: iframePosition.y,
3445
+ borderRadius: 2,
3446
+ bgcolor: "background.paper",
3447
+ zIndex: Number.MAX_SAFE_INTEGER,
3448
+ transition: theme.transitions.create(["box-shadow", "transform"], {
3449
+ duration: theme.transitions.duration.short
3450
+ }),
3451
+ visibility: showIframe && !((_za = state.sdkConfig) == null ? void 0 : _za.disableSoftPhone) ? "visible" : "hidden",
3452
+ userSelect: "none"
3453
+ },
3454
+ children: [
3455
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3456
+ import_material4.Box,
3457
+ {
3458
+ sx: {
3459
+ display: "flex",
3460
+ alignItems: "center",
3461
+ justifyContent: "space-between",
3462
+ cursor: "all-scroll",
3463
+ padding: "0px 10px"
3464
+ },
3465
+ onMouseDown: iframeHandleMouseDown,
3466
+ onTouchStart: iframeHandleTouchStart,
3467
+ children: [
3468
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3469
+ import_icons_material2.DragIndicator,
3470
+ {
3471
+ sx: {
3472
+ transform: "rotate(90deg)",
3473
+ color: "#7b7b7b"
3474
+ }
3475
+ }
3476
+ ),
3477
+ " ",
3478
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.IconButton, { onClick: () => setShowIframe(false), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Close, {}) })
3479
+ ]
3480
+ }
3481
+ ),
3482
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3483
+ "iframe",
3484
+ {
3485
+ src: `https://${IP}/ConVoxCCS/iframe?agent_id=${state.agentId}&process_id=${(_Aa = state.process) == null ? void 0 : _Aa.process_id}`,
3486
+ height: 380,
3487
+ width: 420,
3488
+ allow: "camera; microphone; autoplay",
3489
+ style: {
3490
+ border: "none"
3491
+ }
3492
+ }
3493
+ ) })
3494
+ ]
3495
+ }
3496
+ )
3497
+ }
3498
+ ),
3499
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3500
+ import_material4.Menu,
3501
+ {
3502
+ anchorEl: dialerAnchorEl,
3503
+ open: Boolean(dialerAnchorEl),
3504
+ onClose: handleCloseDialer,
3505
+ onClick: (e) => e.stopPropagation(),
3506
+ sx: {
3507
+ zIndex: 99999
3508
+ },
3509
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3510
+ import_material4.Box,
3511
+ {
3512
+ sx: {
3513
+ all: "unset",
3514
+ padding: "10px",
3515
+ "&hover": {
3516
+ backgroundColor: "white"
3517
+ }
3518
+ },
3519
+ children: [
3520
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3521
+ import_material4.TextField,
3522
+ {
3523
+ size: "small",
3524
+ value: phoneNumber,
3525
+ placeholder: "Enter Mobile No.",
3526
+ onChange: (e) => {
3527
+ setPhoneNumber(e.target.value);
3528
+ }
3529
+ }
3530
+ ),
3531
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3532
+ import_material4.IconButton,
3533
+ {
3534
+ color: "info",
3535
+ onClick: () => {
3536
+ handleStartCall(phoneNumber);
3537
+ },
3538
+ children: clickToCallLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3539
+ import_material4.CircularProgress,
3540
+ {
3541
+ size: "20px",
3542
+ sx: {
3543
+ color: theme.palette.success.main
3544
+ }
3545
+ }
3546
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Phone, { color: "success" })
3547
+ }
3548
+ )
3549
+ ]
3550
+ }
3551
+ )
3552
+ }
3553
+ ),
3554
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3555
+ import_material4.Menu,
3556
+ {
3557
+ anchorEl: statusAnchorEl,
3558
+ open: Boolean(statusAnchorEl),
3559
+ onClose: handleCloseAgentStatus,
3560
+ onClick: (e) => e.stopPropagation(),
3561
+ sx: {
3562
+ zIndex: 99999
3563
+ },
3564
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" })
3565
+ }
3566
+ ),
3567
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3568
+ import_material4.Menu,
3569
+ {
3570
+ anchorEl,
3571
+ open: Boolean(anchorEl),
3572
+ onClose: handleCloseQueueCounts,
3573
+ onClick: (e) => e.stopPropagation(),
3574
+ sx: {
3575
+ zIndex: 99999
3576
+ },
3577
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3578
+ import_material4.Box,
3579
+ {
3580
+ sx: {
3581
+ display: "flex",
3582
+ justifyContent: "flex-start",
3583
+ flexDirection: "column",
3584
+ padding: "0px 10px",
3585
+ "&hover": {
3586
+ backgroundColor: "white"
3587
+ }
3588
+ },
3589
+ children: [
3590
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3591
+ import_material4.Chip,
3592
+ {
3593
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Layers, { color: "secondary" }),
3594
+ variant: "outlined",
3595
+ label: "Waiting - 25",
3596
+ sx: {
3597
+ margin: "4px 2px"
3598
+ }
3599
+ }
3600
+ ),
3601
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3602
+ import_material4.Chip,
3603
+ {
3604
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Pending, { color: "info" }),
3605
+ label: "Pending - 99+",
3606
+ variant: "outlined",
3607
+ sx: {
3608
+ margin: "4px 2px"
3609
+ }
3610
+ }
3611
+ ),
3612
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3613
+ import_material4.Chip,
3614
+ {
3615
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Upcoming, { color: "success" }),
3616
+ variant: "outlined",
3617
+ label: "Upcoming - 66",
3618
+ sx: {
3619
+ margin: "4px 2px"
3620
+ }
3621
+ }
3622
+ )
3623
+ ]
3624
+ }
3625
+ )
3626
+ }
3627
+ ),
3628
+ Boolean(state.openConferenceDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConferenceDialog, {}),
3629
+ Boolean(state.openCallTransferDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CallTransferDialog, { open: state.openCallTransferDialog }),
3630
+ Boolean(openCallDisposition) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3631
+ EndCallDispositionDialog,
3632
+ {
3633
+ open: openCallDisposition,
3634
+ setOpen: setOpenCallDisposition,
3635
+ onSubmitDisposition: handleEndCall
3636
+ }
3637
+ ),
3638
+ Boolean(openCallHistoryDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3639
+ CallHistoryDialog,
3640
+ {
3641
+ open: openCallHistoryDialog,
3642
+ setOpen: setOpenCallHistoryDialog
3643
+ }
3644
+ )
3645
+ ] });
3646
+ }
3647
+
3648
+ // call-control-sdk/lib/components/SDKProvider.tsx
3649
+ var import_react12 = require("react");
3650
+ var import_jsx_runtime4 = require("react/jsx-runtime");
3651
+ var SDKProvider = (0, import_react12.memo)(({ children }) => {
3652
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ToastProvider, { children });
3653
+ });
3654
+ SDKProvider.displayName = "SDKProvider";
3655
+
3656
+ // call-control-sdk/lib/components/callControlPanel.tsx
3657
+ var import_jsx_runtime5 = require("react/jsx-runtime");
3658
+ var CallControlPanel = (0, import_react13.memo)(({ onDataChange }) => {
3659
+ const handleDataChange = (0, import_react13.useCallback)(
3660
+ (data) => {
3661
+ try {
3662
+ if (onDataChange && typeof onDataChange === "function") {
3663
+ onDataChange(data);
3664
+ }
3665
+ } catch (error) {
3666
+ console.error("Error in CallControlPanel data change handler:", error);
3667
+ }
3668
+ },
3669
+ [onDataChange]
3670
+ );
3671
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SDKProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CallControls, { onDataChange: handleDataChange }) });
3672
+ });
3673
+ CallControlPanel.displayName = "CallControlPanel";
3674
+
3675
+ // call-control-sdk/index.ts
3676
+ async function initSDK({
3677
+ apiKey,
3678
+ tenantId,
3679
+ agentId,
3680
+ sdkConfig
3681
+ }) {
3682
+ if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
3683
+ throw new Error(
3684
+ "SDK initialization failed: API key is required and must be a non-empty string"
3685
+ );
3686
+ }
3687
+ if (!tenantId || typeof tenantId !== "string" || tenantId.trim().length === 0) {
3688
+ throw new Error(
3689
+ "SDK initialization failed: Tenant ID is required and must be a non-empty string"
3690
+ );
3691
+ }
3692
+ if (!agentId || typeof agentId !== "string" || agentId.trim().length === 0) {
3693
+ throw new Error(
3694
+ "SDK initialization failed: Agent ID is required and must be a non-empty string"
3695
+ );
3696
+ }
3697
+ try {
3698
+ const initResult = await eventTracker.init({
3699
+ apiKey: apiKey.trim(),
3700
+ tenantId: tenantId.trim(),
3701
+ agentId: agentId.trim(),
3702
+ baseUrl: BASE_URL
3703
+ });
3704
+ if (initResult) {
3705
+ console.log("SDK initialized successfully");
3706
+ sdkStateManager.initialize(
3707
+ apiKey.trim(),
3708
+ tenantId.trim(),
3709
+ agentId.trim(),
3710
+ sdkConfig,
3711
+ initResult
3712
+ );
3713
+ } else {
3714
+ console.error("SDK initialization failed: Event tracker initialization returned false");
3715
+ sdkStateManager.setInitCheck();
3716
+ throw new Error(
3717
+ "SDK initialization failed: Unable to establish connection with the CTI system"
3718
+ );
3719
+ }
3720
+ } catch (error) {
3721
+ console.error("SDK initialization error:", error);
3722
+ sdkStateManager.setInitCheck();
3723
+ if (error instanceof Error) {
3724
+ throw error;
3725
+ } else {
3726
+ throw new Error(`SDK initialization failed: ${String(error)}`);
3727
+ }
3728
+ }
3729
+ }
3730
+ function getSDKVersion() {
3731
+ return "6.x.x";
3732
+ }
3733
+ function isSDKInitialized() {
3734
+ return sdkStateManager.getState().isInitialized;
3735
+ }
3736
+ // Annotate the CommonJS export names for ESM import in node:
3737
+ 0 && (module.exports = {
3738
+ CallControlPanel,
3739
+ getSDKVersion,
3740
+ initSDK,
3741
+ isSDKInitialized,
3742
+ useClickToCall,
3743
+ useEndCall,
3744
+ useGetAuthorizationToken,
3745
+ useGetCallerData,
3746
+ useLogout
3747
+ });