ysyt-agent-sdk 1.0.43 → 1.0.44

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.
@@ -518,7 +518,7 @@ const us=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
518
518
  <div class="popup ${this.open?"":"hidden"}">
519
519
  <slot name="content"></slot>
520
520
  </div>
521
- `}};ds([Es()],Ds.prototype,"open",void 0),Ds=ds([us("my-icon-popup")],Ds);class Ts{constructor(){this.roleData={agentInfo:()=>{if(!St.agentInfo?.agent_no)throw new Error("请先登录")},requestInfo:A=>{if(!A.data)throw new Error("请传入参数")},changeDevice:A=>{if(!A)throw new Error('Parameter "device" is required');const{answer_devices:e}=St.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error("当前设备不支持")},changeState:(A,e)=>{if(!A)throw new Error('Parameter "state" is required');if(!e)throw new Error('Parameter "state_name" is required');if(2===A&&"通话中"===e)throw new Error("当前状态不支持");if(![1,2].includes(A))throw new Error("当前状态不支持")}}}async _agentLogin(A){try{const t=await(e={agent_no:A},ls(`${as}/agent/login`,e));St.agentInfo=t.data}catch(A){throw console.log(A),new Error("登录失败")}var e}async changeDevice(A){try{if(Dt.get("isCalling"))throw new Error("当前正在通话中,请勿切换设备");this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;this.roleData.changeDevice(s);const{agent_no:i}=St.agentInfo;await(A=>ls(`${as}/device/change`,A))({agent_no:i,answer_device:s}),Dt.updateAnswerDevice(s);const r=Dt.get("actionConfigs");Dt.updateActionConfigs(r),t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async changeState(A){try{St.autoStateTimer&&(clearTimeout(St.autoStateTimer),St.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:r}=St.agentInfo;await(A=>ls(`${as}/state/change`,A))({agent_no:r,state_name:i,state:s}),s===Ae.IDLE?Dt.updateActionConfigs(mt):s===Ae.BUSY&&Dt.updateActionConfigs(Ct),St.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async getIdleAgentList(A){const{agent_no:e}=St.agentInfo;try{this.roleData.agentInfo();const t=await(A=>ls(`${as}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){console.log(A)}}async getAgentState(A){try{const e=await ls(`${ns}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw new Error(A.message)}}}let Rs=class extends dt{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=ge`
521
+ `}};ds([Es()],Ds.prototype,"open",void 0),Ds=ds([us("my-icon-popup")],Ds);class Ts{constructor(){this.roleData={agentInfo:()=>{if(!St.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=St.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&"通话中"===e)throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))}}}async _agentLogin(A){try{const t=await(e={agent_no:A},ls(`${as}/agent/login`,e));St.agentInfo=t.data}catch(A){throw console.log(A),new Error(JSON.stringify({code:1,msg:"登录失败"}))}var e}async changeDevice(A){try{if(Dt.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;this.roleData.changeDevice(s);const{agent_no:i}=St.agentInfo;await(A=>ls(`${as}/device/change`,A))({agent_no:i,answer_device:s}),Dt.updateAnswerDevice(s);const r=Dt.get("actionConfigs");Dt.updateActionConfigs(r),t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async changeState(A){try{St.autoStateTimer&&(clearTimeout(St.autoStateTimer),St.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:r}=St.agentInfo;await(A=>ls(`${as}/state/change`,A))({agent_no:r,state_name:i,state:s}),s===Ae.IDLE?Dt.updateActionConfigs(mt):s===Ae.BUSY&&Dt.updateActionConfigs(Ct),St.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async getIdleAgentList(A){const{agent_no:e}=St.agentInfo;try{this.roleData.agentInfo();const t=await(A=>ls(`${as}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){console.log(A)}}async getAgentState(A){try{const e=await ls(`${ns}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw new Error(A.message)}}}let Rs=class extends dt{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=ge`
522
522
  :host {
523
523
  display: block;
524
524
  margin-top: 10px;
@@ -581,7 +581,7 @@ const us=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
581
581
  border: 1px solid #595959;
582
582
  color: #595959;
583
583
  }
584
- `}connectedCallback(){super.connectedCallback(),setTimeout(()=>{this.remove()},this.duration+300)}render(){return ze`<div>${this.content}</div>`}};ds([Cs({type:String})],Rs.prototype,"type",void 0),ds([Cs({type:String})],Rs.prototype,"content",void 0),ds([Cs({type:Number})],Rs.prototype,"duration",void 0),Rs=ds([us("my-message")],Rs);const Us=(A,e,t=3e3)=>{let s=document.querySelector("#message-container");s||(s=document.createElement("div"),s.id="message-container",Object.assign(s.style,{position:"fixed",top:"14px",left:"50%",transform:"translateX(-50%)",zIndex:"9999"}),document.body.appendChild(s));const i=document.createElement("my-message");i.setAttribute("type",A),i.setAttribute("content",e),i.setAttribute("duration",String(t)),i.style.setProperty("--fade-delay",t/1e3+"s"),s.appendChild(i)},ks=(A,e=3e3)=>Us("success",A,e),Gs=(A,e=3e3)=>Us("error",A,e),Ys=(A,e=3e3)=>Us("warning",A,e);class Fs{constructor({container:A,rttHTML:e,statusParams:t},s){this.VoiceSDKInstance=s,this.apiClient=new Ts,this.isOpenSelect=!1,this.statusParams={state:Ae.IDLE,statusName:"空闲"},this.consultShow=!1,this.modalRoot=null,this.agentStateData=[],this.default_device=1,this.handleNetworkInfoChange=A=>{this.rttHTML&&this.renderRtt(A.rttObject)},this.handleCallInfoChange=A=>{this.render()},this.hiddenSelect=()=>{if(!this.isOpenSelect)return;const A=document.querySelector(".ysyt-select");A.style.height="0px",setTimeout(()=>{A.style.padding="0px"},100),this.isOpenSelect=!1,this.render()},this.toggle=A=>{A.stopPropagation(),this.isOpenSelect=!this.isOpenSelect;const e=document.querySelector(".ysyt-select");this.isOpenSelect?(e.style.height=e.scrollHeight+"px",e.style.padding="4px 0px",this.render()):this.hiddenSelect()},this.changeStatus=async A=>{const{state:e,statusName:t}=A;await this.apiClient.changeState({data:{state:e,state_name:t},success:()=>{this.statusParams=A;const e=document.getElementById("my-timer");e?.reset(),this.hiddenSelect()}})},this.onChangeDevices=async A=>{try{await this.apiClient.changeDevice({data:{device:A},success:({code:e})=>{0===e&&(1!==A&&this.VoiceSDKInstance.destroyRtc(),ks("切换成功"),this.default_device=A,this.render())}})}catch(A){console.log(A),Gs(A.message),this.render()}},this.ruleCall=async A=>{if(A)try{await this.VoiceSDKInstance.call_api.makeCall(A)}catch(A){console.error(A)}},this.onCall=()=>{const A=document.querySelector("my-input");this.ruleCall(A.value)},this.renderCallPopover=()=>ze`
584
+ `}connectedCallback(){super.connectedCallback(),setTimeout(()=>{this.remove()},this.duration+300)}render(){return ze`<div>${this.content}</div>`}};ds([Cs({type:String})],Rs.prototype,"type",void 0),ds([Cs({type:String})],Rs.prototype,"content",void 0),ds([Cs({type:Number})],Rs.prototype,"duration",void 0),Rs=ds([us("my-message")],Rs);const Us=(A,e,t=3e3)=>{let s=document.querySelector("#message-container");s||(s=document.createElement("div"),s.id="message-container",Object.assign(s.style,{position:"fixed",top:"14px",left:"50%",transform:"translateX(-50%)",zIndex:"9999"}),document.body.appendChild(s));const i=document.createElement("my-message");i.setAttribute("type",A),i.setAttribute("content",e),i.setAttribute("duration",String(t)),i.style.setProperty("--fade-delay",t/1e3+"s"),s.appendChild(i)},ks=(A,e=3e3)=>Us("success",A,e),Gs=(A,e=3e3)=>Us("error",A,e),Ys=(A,e=3e3)=>Us("warning",A,e);class Fs{constructor({container:A,rttHTML:e,statusParams:t},s){this.VoiceSDKInstance=s,this.apiClient=new Ts,this.isOpenSelect=!1,this.statusParams={state:Ae.IDLE,statusName:"空闲"},this.consultShow=!1,this.modalRoot=null,this.agentStateData=[],this.default_device=1,this.handleNetworkInfoChange=A=>{this.rttHTML&&this.renderRtt(A.rttObject)},this.handleCallInfoChange=A=>{this.render()},this.hiddenSelect=()=>{if(!this.isOpenSelect)return;const A=document.querySelector(".ysyt-select");A.style.height="0px",setTimeout(()=>{A.style.padding="0px"},100),this.isOpenSelect=!1,this.render()},this.toggle=A=>{A.stopPropagation(),this.isOpenSelect=!this.isOpenSelect;const e=document.querySelector(".ysyt-select");this.isOpenSelect?(e.style.height=e.scrollHeight+"px",e.style.padding="4px 0px",this.render()):this.hiddenSelect()},this.changeStatus=async A=>{const{state:e,statusName:t}=A;await this.apiClient.changeState({data:{state:e,state_name:t},success:()=>{this.statusParams=A;const e=document.getElementById("my-timer");e?.reset(),this.hiddenSelect()}})},this.onChangeDevices=async A=>{try{await this.apiClient.changeDevice({data:{device:A},success:({code:e})=>{0===e&&(1!==A&&this.VoiceSDKInstance.destroyRtc(),ks("切换成功"),this.default_device=A,this.render())}})}catch(A){Gs(JSON.parse(A.message).msg),this.render()}},this.ruleCall=async A=>{if(A)try{await this.VoiceSDKInstance.call_api.makeCall(A)}catch(A){console.error(A)}},this.onCall=()=>{const A=document.querySelector("my-input");this.ruleCall(A.value)},this.renderCallPopover=()=>ze`
585
585
  <my-icon-popup>
586
586
  <div slot="icon">
587
587
  <i class="ysyt icon-boda my-icon"></i>
@@ -518,7 +518,7 @@ const ps=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
518
518
  <div class="popup ${this.open?"":"hidden"}">
519
519
  <slot name="content"></slot>
520
520
  </div>
521
- `}};us([Is()],Ts.prototype,"open",void 0),Ts=us([ps("my-icon-popup")],Ts);class Rs{constructor(){this.roleData={agentInfo:()=>{if(!St.agentInfo?.agent_no)throw new Error("请先登录")},requestInfo:A=>{if(!A.data)throw new Error("请传入参数")},changeDevice:A=>{if(!A)throw new Error('Parameter "device" is required');const{answer_devices:e}=St.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error("当前设备不支持")},changeState:(A,e)=>{if(!A)throw new Error('Parameter "state" is required');if(!e)throw new Error('Parameter "state_name" is required');if(2===A&&"通话中"===e)throw new Error("当前状态不支持");if(![1,2].includes(A))throw new Error("当前状态不支持")}}}async _agentLogin(A){try{const t=await(e={agent_no:A},qs(`${Vs}/agent/login`,e));St.agentInfo=t.data}catch(A){throw console.log(A),new Error("登录失败")}var e}async changeDevice(A){try{if(Dt.get("isCalling"))throw new Error("当前正在通话中,请勿切换设备");this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;this.roleData.changeDevice(s);const{agent_no:i}=St.agentInfo;await(A=>qs(`${Vs}/device/change`,A))({agent_no:i,answer_device:s}),Dt.updateAnswerDevice(s);const r=Dt.get("actionConfigs");Dt.updateActionConfigs(r),t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async changeState(A){try{St.autoStateTimer&&(clearTimeout(St.autoStateTimer),St.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:r}=St.agentInfo;await(A=>qs(`${Vs}/state/change`,A))({agent_no:r,state_name:i,state:s}),s===Ae.IDLE?Dt.updateActionConfigs(mt):s===Ae.BUSY&&Dt.updateActionConfigs(Ct),St.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async getIdleAgentList(A){const{agent_no:e}=St.agentInfo;try{this.roleData.agentInfo();const t=await(A=>qs(`${Vs}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){console.log(A)}}async getAgentState(A){try{const e=await qs(`${as}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw new Error(A.message)}}}let Us=class extends dt{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=ge`
521
+ `}};us([Is()],Ts.prototype,"open",void 0),Ts=us([ps("my-icon-popup")],Ts);class Rs{constructor(){this.roleData={agentInfo:()=>{if(!St.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=St.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&"通话中"===e)throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))}}}async _agentLogin(A){try{const t=await(e={agent_no:A},qs(`${Vs}/agent/login`,e));St.agentInfo=t.data}catch(A){throw console.log(A),new Error(JSON.stringify({code:1,msg:"登录失败"}))}var e}async changeDevice(A){try{if(Dt.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;this.roleData.changeDevice(s);const{agent_no:i}=St.agentInfo;await(A=>qs(`${Vs}/device/change`,A))({agent_no:i,answer_device:s}),Dt.updateAnswerDevice(s);const r=Dt.get("actionConfigs");Dt.updateActionConfigs(r),t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async changeState(A){try{St.autoStateTimer&&(clearTimeout(St.autoStateTimer),St.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:r}=St.agentInfo;await(A=>qs(`${Vs}/state/change`,A))({agent_no:r,state_name:i,state:s}),s===Ae.IDLE?Dt.updateActionConfigs(mt):s===Ae.BUSY&&Dt.updateActionConfigs(Ct),St.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async getIdleAgentList(A){const{agent_no:e}=St.agentInfo;try{this.roleData.agentInfo();const t=await(A=>qs(`${Vs}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){console.log(A)}}async getAgentState(A){try{const e=await qs(`${as}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw new Error(A.message)}}}let Us=class extends dt{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=ge`
522
522
  :host {
523
523
  display: block;
524
524
  margin-top: 10px;
@@ -581,7 +581,7 @@ const ps=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
581
581
  border: 1px solid #595959;
582
582
  color: #595959;
583
583
  }
584
- `}connectedCallback(){super.connectedCallback(),setTimeout(()=>{this.remove()},this.duration+300)}render(){return ze`<div>${this.content}</div>`}};us([Es({type:String})],Us.prototype,"type",void 0),us([Es({type:String})],Us.prototype,"content",void 0),us([Es({type:Number})],Us.prototype,"duration",void 0),Us=us([ps("my-message")],Us);const ks=(A,e,t=3e3)=>{let s=document.querySelector("#message-container");s||(s=document.createElement("div"),s.id="message-container",Object.assign(s.style,{position:"fixed",top:"14px",left:"50%",transform:"translateX(-50%)",zIndex:"9999"}),document.body.appendChild(s));const i=document.createElement("my-message");i.setAttribute("type",A),i.setAttribute("content",e),i.setAttribute("duration",String(t)),i.style.setProperty("--fade-delay",t/1e3+"s"),s.appendChild(i)},Gs=(A,e=3e3)=>ks("success",A,e),Ys=(A,e=3e3)=>ks("error",A,e),Fs=(A,e=3e3)=>ks("warning",A,e);class Zs{constructor({container:A,rttHTML:e,statusParams:t},s){this.VoiceSDKInstance=s,this.apiClient=new Rs,this.isOpenSelect=!1,this.statusParams={state:Ae.IDLE,statusName:"空闲"},this.consultShow=!1,this.modalRoot=null,this.agentStateData=[],this.default_device=1,this.handleNetworkInfoChange=A=>{this.rttHTML&&this.renderRtt(A.rttObject)},this.handleCallInfoChange=A=>{this.render()},this.hiddenSelect=()=>{if(!this.isOpenSelect)return;const A=document.querySelector(".ysyt-select");A.style.height="0px",setTimeout(()=>{A.style.padding="0px"},100),this.isOpenSelect=!1,this.render()},this.toggle=A=>{A.stopPropagation(),this.isOpenSelect=!this.isOpenSelect;const e=document.querySelector(".ysyt-select");this.isOpenSelect?(e.style.height=e.scrollHeight+"px",e.style.padding="4px 0px",this.render()):this.hiddenSelect()},this.changeStatus=async A=>{const{state:e,statusName:t}=A;await this.apiClient.changeState({data:{state:e,state_name:t},success:()=>{this.statusParams=A;const e=document.getElementById("my-timer");e?.reset(),this.hiddenSelect()}})},this.onChangeDevices=async A=>{try{await this.apiClient.changeDevice({data:{device:A},success:({code:e})=>{0===e&&(1!==A&&this.VoiceSDKInstance.destroyRtc(),Gs("切换成功"),this.default_device=A,this.render())}})}catch(A){console.log(A),Ys(A.message),this.render()}},this.ruleCall=async A=>{if(A)try{await this.VoiceSDKInstance.call_api.makeCall(A)}catch(A){console.error(A)}},this.onCall=()=>{const A=document.querySelector("my-input");this.ruleCall(A.value)},this.renderCallPopover=()=>ze`
584
+ `}connectedCallback(){super.connectedCallback(),setTimeout(()=>{this.remove()},this.duration+300)}render(){return ze`<div>${this.content}</div>`}};us([Es({type:String})],Us.prototype,"type",void 0),us([Es({type:String})],Us.prototype,"content",void 0),us([Es({type:Number})],Us.prototype,"duration",void 0),Us=us([ps("my-message")],Us);const ks=(A,e,t=3e3)=>{let s=document.querySelector("#message-container");s||(s=document.createElement("div"),s.id="message-container",Object.assign(s.style,{position:"fixed",top:"14px",left:"50%",transform:"translateX(-50%)",zIndex:"9999"}),document.body.appendChild(s));const i=document.createElement("my-message");i.setAttribute("type",A),i.setAttribute("content",e),i.setAttribute("duration",String(t)),i.style.setProperty("--fade-delay",t/1e3+"s"),s.appendChild(i)},Gs=(A,e=3e3)=>ks("success",A,e),Ys=(A,e=3e3)=>ks("error",A,e),Fs=(A,e=3e3)=>ks("warning",A,e);class Zs{constructor({container:A,rttHTML:e,statusParams:t},s){this.VoiceSDKInstance=s,this.apiClient=new Rs,this.isOpenSelect=!1,this.statusParams={state:Ae.IDLE,statusName:"空闲"},this.consultShow=!1,this.modalRoot=null,this.agentStateData=[],this.default_device=1,this.handleNetworkInfoChange=A=>{this.rttHTML&&this.renderRtt(A.rttObject)},this.handleCallInfoChange=A=>{this.render()},this.hiddenSelect=()=>{if(!this.isOpenSelect)return;const A=document.querySelector(".ysyt-select");A.style.height="0px",setTimeout(()=>{A.style.padding="0px"},100),this.isOpenSelect=!1,this.render()},this.toggle=A=>{A.stopPropagation(),this.isOpenSelect=!this.isOpenSelect;const e=document.querySelector(".ysyt-select");this.isOpenSelect?(e.style.height=e.scrollHeight+"px",e.style.padding="4px 0px",this.render()):this.hiddenSelect()},this.changeStatus=async A=>{const{state:e,statusName:t}=A;await this.apiClient.changeState({data:{state:e,state_name:t},success:()=>{this.statusParams=A;const e=document.getElementById("my-timer");e?.reset(),this.hiddenSelect()}})},this.onChangeDevices=async A=>{try{await this.apiClient.changeDevice({data:{device:A},success:({code:e})=>{0===e&&(1!==A&&this.VoiceSDKInstance.destroyRtc(),Gs("切换成功"),this.default_device=A,this.render())}})}catch(A){Ys(JSON.parse(A.message).msg),this.render()}},this.ruleCall=async A=>{if(A)try{await this.VoiceSDKInstance.call_api.makeCall(A)}catch(A){console.error(A)}},this.onCall=()=>{const A=document.querySelector("my-input");this.ruleCall(A.value)},this.renderCallPopover=()=>ze`
585
585
  <my-icon-popup>
586
586
  <div slot="icon">
587
587
  <i class="ysyt icon-boda my-icon"></i>
@@ -518,7 +518,7 @@ const us=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
518
518
  <div class="popup ${this.open?"":"hidden"}">
519
519
  <slot name="content"></slot>
520
520
  </div>
521
- `}};ds([Es()],Ds.prototype,"open",void 0),Ds=ds([us("my-icon-popup")],Ds);class Ts{constructor(){this.roleData={agentInfo:()=>{if(!St.agentInfo?.agent_no)throw new Error("请先登录")},requestInfo:A=>{if(!A.data)throw new Error("请传入参数")},changeDevice:A=>{if(!A)throw new Error('Parameter "device" is required');const{answer_devices:e}=St.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error("当前设备不支持")},changeState:(A,e)=>{if(!A)throw new Error('Parameter "state" is required');if(!e)throw new Error('Parameter "state_name" is required');if(2===A&&"通话中"===e)throw new Error("当前状态不支持");if(![1,2].includes(A))throw new Error("当前状态不支持")}}}async _agentLogin(A){try{const t=await(e={agent_no:A},ls(`${as}/agent/login`,e));St.agentInfo=t.data}catch(A){throw console.log(A),new Error("登录失败")}var e}async changeDevice(A){try{if(Dt.get("isCalling"))throw new Error("当前正在通话中,请勿切换设备");this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;this.roleData.changeDevice(s);const{agent_no:i}=St.agentInfo;await(A=>ls(`${as}/device/change`,A))({agent_no:i,answer_device:s}),Dt.updateAnswerDevice(s);const r=Dt.get("actionConfigs");Dt.updateActionConfigs(r),t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async changeState(A){try{St.autoStateTimer&&(clearTimeout(St.autoStateTimer),St.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:r}=St.agentInfo;await(A=>ls(`${as}/state/change`,A))({agent_no:r,state_name:i,state:s}),s===Ae.IDLE?Dt.updateActionConfigs(mt):s===Ae.BUSY&&Dt.updateActionConfigs(Ct),St.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async getIdleAgentList(A){const{agent_no:e}=St.agentInfo;try{this.roleData.agentInfo();const t=await(A=>ls(`${as}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){console.log(A)}}async getAgentState(A){try{const e=await ls(`${ns}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw new Error(A.message)}}}let Rs=class extends dt{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=ge`
521
+ `}};ds([Es()],Ds.prototype,"open",void 0),Ds=ds([us("my-icon-popup")],Ds);class Ts{constructor(){this.roleData={agentInfo:()=>{if(!St.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=St.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&"通话中"===e)throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))}}}async _agentLogin(A){try{const t=await(e={agent_no:A},ls(`${as}/agent/login`,e));St.agentInfo=t.data}catch(A){throw console.log(A),new Error(JSON.stringify({code:1,msg:"登录失败"}))}var e}async changeDevice(A){try{if(Dt.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;this.roleData.changeDevice(s);const{agent_no:i}=St.agentInfo;await(A=>ls(`${as}/device/change`,A))({agent_no:i,answer_device:s}),Dt.updateAnswerDevice(s);const r=Dt.get("actionConfigs");Dt.updateActionConfigs(r),t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async changeState(A){try{St.autoStateTimer&&(clearTimeout(St.autoStateTimer),St.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:r}=St.agentInfo;await(A=>ls(`${as}/state/change`,A))({agent_no:r,state_name:i,state:s}),s===Ae.IDLE?Dt.updateActionConfigs(mt):s===Ae.BUSY&&Dt.updateActionConfigs(Ct),St.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw new Error(A.message)}}async getIdleAgentList(A){const{agent_no:e}=St.agentInfo;try{this.roleData.agentInfo();const t=await(A=>ls(`${as}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){console.log(A)}}async getAgentState(A){try{const e=await ls(`${ns}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw new Error(A.message)}}}let Rs=class extends dt{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=ge`
522
522
  :host {
523
523
  display: block;
524
524
  margin-top: 10px;
@@ -581,7 +581,7 @@ const us=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
581
581
  border: 1px solid #595959;
582
582
  color: #595959;
583
583
  }
584
- `}connectedCallback(){super.connectedCallback(),setTimeout(()=>{this.remove()},this.duration+300)}render(){return ze`<div>${this.content}</div>`}};ds([Cs({type:String})],Rs.prototype,"type",void 0),ds([Cs({type:String})],Rs.prototype,"content",void 0),ds([Cs({type:Number})],Rs.prototype,"duration",void 0),Rs=ds([us("my-message")],Rs);const Us=(A,e,t=3e3)=>{let s=document.querySelector("#message-container");s||(s=document.createElement("div"),s.id="message-container",Object.assign(s.style,{position:"fixed",top:"14px",left:"50%",transform:"translateX(-50%)",zIndex:"9999"}),document.body.appendChild(s));const i=document.createElement("my-message");i.setAttribute("type",A),i.setAttribute("content",e),i.setAttribute("duration",String(t)),i.style.setProperty("--fade-delay",t/1e3+"s"),s.appendChild(i)},ks=(A,e=3e3)=>Us("success",A,e),Gs=(A,e=3e3)=>Us("error",A,e),Ys=(A,e=3e3)=>Us("warning",A,e);class Fs{constructor({container:A,rttHTML:e,statusParams:t},s){this.VoiceSDKInstance=s,this.apiClient=new Ts,this.isOpenSelect=!1,this.statusParams={state:Ae.IDLE,statusName:"空闲"},this.consultShow=!1,this.modalRoot=null,this.agentStateData=[],this.default_device=1,this.handleNetworkInfoChange=A=>{this.rttHTML&&this.renderRtt(A.rttObject)},this.handleCallInfoChange=A=>{this.render()},this.hiddenSelect=()=>{if(!this.isOpenSelect)return;const A=document.querySelector(".ysyt-select");A.style.height="0px",setTimeout(()=>{A.style.padding="0px"},100),this.isOpenSelect=!1,this.render()},this.toggle=A=>{A.stopPropagation(),this.isOpenSelect=!this.isOpenSelect;const e=document.querySelector(".ysyt-select");this.isOpenSelect?(e.style.height=e.scrollHeight+"px",e.style.padding="4px 0px",this.render()):this.hiddenSelect()},this.changeStatus=async A=>{const{state:e,statusName:t}=A;await this.apiClient.changeState({data:{state:e,state_name:t},success:()=>{this.statusParams=A;const e=document.getElementById("my-timer");e?.reset(),this.hiddenSelect()}})},this.onChangeDevices=async A=>{try{await this.apiClient.changeDevice({data:{device:A},success:({code:e})=>{0===e&&(1!==A&&this.VoiceSDKInstance.destroyRtc(),ks("切换成功"),this.default_device=A,this.render())}})}catch(A){console.log(A),Gs(A.message),this.render()}},this.ruleCall=async A=>{if(A)try{await this.VoiceSDKInstance.call_api.makeCall(A)}catch(A){console.error(A)}},this.onCall=()=>{const A=document.querySelector("my-input");this.ruleCall(A.value)},this.renderCallPopover=()=>ze`
584
+ `}connectedCallback(){super.connectedCallback(),setTimeout(()=>{this.remove()},this.duration+300)}render(){return ze`<div>${this.content}</div>`}};ds([Cs({type:String})],Rs.prototype,"type",void 0),ds([Cs({type:String})],Rs.prototype,"content",void 0),ds([Cs({type:Number})],Rs.prototype,"duration",void 0),Rs=ds([us("my-message")],Rs);const Us=(A,e,t=3e3)=>{let s=document.querySelector("#message-container");s||(s=document.createElement("div"),s.id="message-container",Object.assign(s.style,{position:"fixed",top:"14px",left:"50%",transform:"translateX(-50%)",zIndex:"9999"}),document.body.appendChild(s));const i=document.createElement("my-message");i.setAttribute("type",A),i.setAttribute("content",e),i.setAttribute("duration",String(t)),i.style.setProperty("--fade-delay",t/1e3+"s"),s.appendChild(i)},ks=(A,e=3e3)=>Us("success",A,e),Gs=(A,e=3e3)=>Us("error",A,e),Ys=(A,e=3e3)=>Us("warning",A,e);class Fs{constructor({container:A,rttHTML:e,statusParams:t},s){this.VoiceSDKInstance=s,this.apiClient=new Ts,this.isOpenSelect=!1,this.statusParams={state:Ae.IDLE,statusName:"空闲"},this.consultShow=!1,this.modalRoot=null,this.agentStateData=[],this.default_device=1,this.handleNetworkInfoChange=A=>{this.rttHTML&&this.renderRtt(A.rttObject)},this.handleCallInfoChange=A=>{this.render()},this.hiddenSelect=()=>{if(!this.isOpenSelect)return;const A=document.querySelector(".ysyt-select");A.style.height="0px",setTimeout(()=>{A.style.padding="0px"},100),this.isOpenSelect=!1,this.render()},this.toggle=A=>{A.stopPropagation(),this.isOpenSelect=!this.isOpenSelect;const e=document.querySelector(".ysyt-select");this.isOpenSelect?(e.style.height=e.scrollHeight+"px",e.style.padding="4px 0px",this.render()):this.hiddenSelect()},this.changeStatus=async A=>{const{state:e,statusName:t}=A;await this.apiClient.changeState({data:{state:e,state_name:t},success:()=>{this.statusParams=A;const e=document.getElementById("my-timer");e?.reset(),this.hiddenSelect()}})},this.onChangeDevices=async A=>{try{await this.apiClient.changeDevice({data:{device:A},success:({code:e})=>{0===e&&(1!==A&&this.VoiceSDKInstance.destroyRtc(),ks("切换成功"),this.default_device=A,this.render())}})}catch(A){Gs(JSON.parse(A.message).msg),this.render()}},this.ruleCall=async A=>{if(A)try{await this.VoiceSDKInstance.call_api.makeCall(A)}catch(A){console.error(A)}},this.onCall=()=>{const A=document.querySelector("my-input");this.ruleCall(A.value)},this.renderCallPopover=()=>ze`
585
585
  <my-icon-popup>
586
586
  <div slot="icon">
587
587
  <i class="ysyt icon-boda my-icon"></i>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ysyt-agent-sdk",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "main": "dist/ysyt-agent-sdk.cjs.js",
5
5
  "module": "dist/ysyt-agent-sdk.esm.js",
6
6
  "types": "dist/src/index.d.ts",