ysyt-react-agent-lib 1.2.16 → 1.2.18

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-xVt94WPB.js"),s=require("react"),i=require("./index-BbyVD3EV.js"),c=s.memo(({open:n,onCallBack:r,queryFetch:x})=>{const[o,a]=s.useState([]);return s.useEffect(()=>{(async()=>{try{await x({success:t=>{a(t.data||[])}})}catch(t){console.log(t)}})()},[n]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(i.Modal,{open:n,title:"咨询",footer:!1,onCancel:()=>r(),children:e.jsxRuntimeExports.jsx(e.ModelBody,{children:o.length===0?e.jsxRuntimeExports.jsx(e.Empty,{image:e.Empty.PRESENTED_IMAGE_SIMPLE,description:"暂无咨询坐席"}):e.jsxRuntimeExports.jsx(e.Space,{wrap:!0,children:o.map(t=>e.jsxRuntimeExports.jsx(i.Tag,{color:"processing",onClick:()=>r(t.agent_no),children:e.jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"zixun"}),e.jsxRuntimeExports.jsxs("span",{style:{marginLeft:10},children:["咨询坐席: ",t.agent_name]})]})},t.agent_no))})})})})});exports.default=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DlZp6-xz.js"),s=require("react"),i=require("./index-DH6Yz3O6.js"),c=s.memo(({open:n,onCallBack:r,queryFetch:x})=>{const[o,a]=s.useState([]);return s.useEffect(()=>{(async()=>{try{await x({success:t=>{a(t.data||[])}})}catch(t){console.log(t)}})()},[n]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(i.Modal,{open:n,title:"咨询",footer:!1,onCancel:()=>r(),children:e.jsxRuntimeExports.jsx(e.ModelBody,{children:o.length===0?e.jsxRuntimeExports.jsx(e.Empty,{image:e.Empty.PRESENTED_IMAGE_SIMPLE,description:"暂无咨询坐席"}):e.jsxRuntimeExports.jsx(e.Space,{wrap:!0,children:o.map(t=>e.jsxRuntimeExports.jsx(i.Tag,{color:"processing",onClick:()=>r(t.agent_no),children:e.jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"zixun"}),e.jsxRuntimeExports.jsxs("span",{style:{marginLeft:10},children:["咨询坐席: ",t.agent_name]})]})},t.agent_no))})})})})});exports.default=c;
@@ -1,6 +1,6 @@
1
- import { j as e, M as l, E as r, S as i, Y as d } from "./index-DExsNupU.mjs";
1
+ import { j as e, M as l, E as r, S as i, Y as d } from "./index-BrCg-39l.mjs";
2
2
  import { memo as m, useState as g, useEffect as x } from "react";
3
- import { M as p, T as j } from "./index-BVq1_8KS.mjs";
3
+ import { M as p, T as j } from "./index-Dc_QiC3y.mjs";
4
4
  const E = m(({ open: t, onCallBack: a, queryFetch: o }) => {
5
5
  const [n, c] = g([]);
6
6
  return x(() => {
@@ -1,6 +1,6 @@
1
- import { j as e, M as h, R as j, a as f, E as d, S as y, Y as c, I as v } from "./index-DExsNupU.mjs";
1
+ import { j as e, M as h, R as j, a as f, E as d, S as y, Y as c, I as v } from "./index-BrCg-39l.mjs";
2
2
  import { memo as E, useState as n, useEffect as T } from "react";
3
- import { M as I, T as M } from "./index-BVq1_8KS.mjs";
3
+ import { M as I, T as M } from "./index-Dc_QiC3y.mjs";
4
4
  const _ = E(({ open: l, onCallBack: a, queryFetch: p }) => {
5
5
  const [o, g] = n([]), [t, x] = n(0), [r, m] = n(""), [u, i] = n(!1);
6
6
  return T(() => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-xVt94WPB.js"),t=require("react"),l=require("./index-BbyVD3EV.js"),m=t.memo(({open:o,onCallBack:n,queryFetch:u})=>{const[x,p]=t.useState([]),[r,c]=t.useState(0),[i,d]=t.useState(""),[j,a]=t.useState(!1);return t.useEffect(()=>{(async()=>{a(!0);try{await u({success:s=>{p(s.data||[])}})}catch(s){console.log(s)}a(!1)})()},[o]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(l.Modal,{open:o,title:"转接",footer:!1,onCancel:()=>n(),children:e.jsxRuntimeExports.jsxs(e.ModelBody,{children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(e.Radio.Group,{options:[{label:"转接坐席",value:0},{label:"转接外线",value:1}],value:r,onChange:s=>c(s.target.value)})}),e.jsxRuntimeExports.jsx(e.Spin,{spinning:j,children:e.jsxRuntimeExports.jsxs("div",{style:{borderTop:"1px solid #eee",marginTop:10,paddingTop:10},children:[r===0&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:x.length===0?e.jsxRuntimeExports.jsx(e.Empty,{image:e.Empty.PRESENTED_IMAGE_SIMPLE,description:"暂无转接坐席"}):e.jsxRuntimeExports.jsx(e.Space,{wrap:!0,children:x.map(s=>e.jsxRuntimeExports.jsx(l.Tag,{color:"processing",onClick:()=>n(s.agent_no,0),children:e.jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"zixun"}),e.jsxRuntimeExports.jsxs("span",{style:{marginRight:10},children:["转接坐席: ",s.agent_name]})]})},s.agent_no))})}),r===1&&e.jsxRuntimeExports.jsxs("div",{style:{width:"100%",display:"flex",alignItems:"center",gap:"0 5px"},children:[e.jsxRuntimeExports.jsx(e.Input,{style:{flex:1},value:i,onChange:s=>d(s.target.value),placeholder:"请输入外线号码, 回车转接",onPressEnter:()=>{n(i,1)}}),e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"boda",color:"#1D92E9",size:25,onClick:()=>{n(i,1)}})]})]})})]})})})});exports.default=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DlZp6-xz.js"),t=require("react"),l=require("./index-DH6Yz3O6.js"),m=t.memo(({open:o,onCallBack:n,queryFetch:u})=>{const[x,p]=t.useState([]),[r,c]=t.useState(0),[i,d]=t.useState(""),[j,a]=t.useState(!1);return t.useEffect(()=>{(async()=>{a(!0);try{await u({success:s=>{p(s.data||[])}})}catch(s){console.log(s)}a(!1)})()},[o]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(l.Modal,{open:o,title:"转接",footer:!1,onCancel:()=>n(),children:e.jsxRuntimeExports.jsxs(e.ModelBody,{children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(e.Radio.Group,{options:[{label:"转接坐席",value:0},{label:"转接外线",value:1}],value:r,onChange:s=>c(s.target.value)})}),e.jsxRuntimeExports.jsx(e.Spin,{spinning:j,children:e.jsxRuntimeExports.jsxs("div",{style:{borderTop:"1px solid #eee",marginTop:10,paddingTop:10},children:[r===0&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:x.length===0?e.jsxRuntimeExports.jsx(e.Empty,{image:e.Empty.PRESENTED_IMAGE_SIMPLE,description:"暂无转接坐席"}):e.jsxRuntimeExports.jsx(e.Space,{wrap:!0,children:x.map(s=>e.jsxRuntimeExports.jsx(l.Tag,{color:"processing",onClick:()=>n(s.agent_no,0),children:e.jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"zixun"}),e.jsxRuntimeExports.jsxs("span",{style:{marginRight:10},children:["转接坐席: ",s.agent_name]})]})},s.agent_no))})}),r===1&&e.jsxRuntimeExports.jsxs("div",{style:{width:"100%",display:"flex",alignItems:"center",gap:"0 5px"},children:[e.jsxRuntimeExports.jsx(e.Input,{style:{flex:1},value:i,onChange:s=>d(s.target.value),placeholder:"请输入外线号码, 回车转接",onPressEnter:()=>{n(i,1)}}),e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"boda",color:"#1D92E9",size:25,onClick:()=>{n(i,1)}})]})]})})]})})})});exports.default=m;
@@ -11065,7 +11065,6 @@ class un {
11065
11065
  else if (o === it.CONSULT_TRANSFER_FAILED) ge.emit(oe.CONSULT_TRANSFER_FAILED, A.status);
11066
11066
  else if (o === it.CONSULT_TRANSFER_OFF_HOOK) j.updateDirection(bn.INCOMING), j.updateDisplayText(Zt.CALLING), ge.emit(oe.CONSULT_TRANSFER_OFF_HOOK), j.updateActionConfigs(Pi), j.updateIncomingIsAnswer(!0), j.updateConsultIsAnswer(!1);
11067
11067
  else if (o === it.INCOMING_CALL) {
11068
- if (X.sessionId !== A.session_id) return;
11069
11068
  clearTimeout(X.autoStateTimer), X.sessionId = A.session_id;
11070
11069
  try {
11071
11070
  await this.getCustomerInfo(A.trace_id || A.customer_phone);
@@ -11076,17 +11075,19 @@ class un {
11076
11075
  ge.emit(je.NOTIFICATION_CLICK, { customer_phone: A.customer_phone });
11077
11076
  }, X.browserAlertTime);
11078
11077
  } else if (o === it.INCOMING_CALL_OFF_HOOK) j.updateIncomingIsAnswer(!0), A.direction === 8 ? (j.updateActionConfigs(Pl), ge.emit(oe.INCOMING_CALL_IN_OFF_HOOK, { session_id: X.sessionId })) : (j.updateActionConfigs(Pi), ge.emit(oe.INCOMING_CALL_OFF_HOOK, { session_id: X.sessionId })), j.updateDisplayText(Zt.CALLING);
11079
- else if (o === it.INCOMING_CALL_END) if (j.updateDisplayText(""), A.device_type !== 1 && A.device_type !== 7 || A.agent_no !== X.agentInfo.agent_no) if (A.device_type === 2 && A.agent_no === X.agentInfo.agent_no) j.reset(), ge.emit(oe.OUR_SIDE_CONSULT_HANGUP, { session_id: A.session_id }), this.putAgentState(!0), j.updateActionConfigs(Kn);
11080
- else if (A.device_type === 2 && A.agent_no !== X.agentInfo.agent_no) j.updateDisplayText(Zt.CALLING), ge.emit(oe.OTHER_SIDE_CONSULT_HANGUP, { session_id: A.session_id }), j.updateActionConfigs(Ei);
11081
- else if (A.device_type === 3 && A.agent_no === X.agentInfo.agent_no) this.putAgentState(!0), j.reset(), ge.emit(oe.THREE_WAY_OUR_SIDE_HANGUP, { session_id: A.session_id }), j.updateActionConfigs(Kn);
11082
- else if (A.device_type === 4 && A.agent_no === X.agentInfo.agent_no) this.putAgentState(!0), j.reset(), ge.emit(oe.TRANSFER_END, { session_id: A.session_id }), j.updateActionConfigs(Kn);
11083
- else if (A.device_type === 4 && A.agent_no !== X.agentInfo.agent_no) {
11084
- ge.emit(oe.TRANSFER_FAILED, "未知原因"), ge.emit(je.FAIL_NOTIFICATION, "转接失败");
11085
- const d = j.get("direction");
11086
- d === bn.OUTGOING ? j.updateActionConfigs(Ei) : d === bn.INCOMING && j.updateActionConfigs(Pi);
11087
- } else A.device_type === 5 && A.agent_no === X.agentInfo.agent_no && (this.putAgentState(!0, 5), X.monitoredAgentNo = "", X.earSpeakAgent = "", j.reset(), ge.emit(oe.LISTEN_HANGUP, { session_id: A.session_id }), j.updateActionConfigs(Kn));
11088
- else this.putAgentState(!0), j.reset(), ge.emit(oe.INCOMING_CALL_END, { session_id: A.session_id }), j.updateActionConfigs(Kn);
11089
- else if (o === it.SATISFACTION_EVALUATION) a === 0 ? ge.emit(oe.SATISFACTION_EVALUATION_SUCCESS) : (ge.emit(oe.SATISFACTION_EVALUATION_FAILED, s), ge.emit(je.FAIL_NOTIFICATION, s));
11078
+ else if (o === it.INCOMING_CALL_END) {
11079
+ if (X.sessionId !== A.session_id) return;
11080
+ if (j.updateDisplayText(""), A.device_type !== 1 && A.device_type !== 7 || A.agent_no !== X.agentInfo.agent_no) if (A.device_type === 2 && A.agent_no === X.agentInfo.agent_no) j.reset(), ge.emit(oe.OUR_SIDE_CONSULT_HANGUP, { session_id: A.session_id }), this.putAgentState(!0), j.updateActionConfigs(Kn);
11081
+ else if (A.device_type === 2 && A.agent_no !== X.agentInfo.agent_no) j.updateDisplayText(Zt.CALLING), ge.emit(oe.OTHER_SIDE_CONSULT_HANGUP, { session_id: A.session_id }), j.updateActionConfigs(Ei);
11082
+ else if (A.device_type === 3 && A.agent_no === X.agentInfo.agent_no) this.putAgentState(!0), j.reset(), ge.emit(oe.THREE_WAY_OUR_SIDE_HANGUP, { session_id: A.session_id }), j.updateActionConfigs(Kn);
11083
+ else if (A.device_type === 4 && A.agent_no === X.agentInfo.agent_no) this.putAgentState(!0), j.reset(), ge.emit(oe.TRANSFER_END, { session_id: A.session_id }), j.updateActionConfigs(Kn);
11084
+ else if (A.device_type === 4 && A.agent_no !== X.agentInfo.agent_no) {
11085
+ ge.emit(oe.TRANSFER_FAILED, "未知原因"), ge.emit(je.FAIL_NOTIFICATION, "转接失败");
11086
+ const d = j.get("direction");
11087
+ d === bn.OUTGOING ? j.updateActionConfigs(Ei) : d === bn.INCOMING && j.updateActionConfigs(Pi);
11088
+ } else A.device_type === 5 && A.agent_no === X.agentInfo.agent_no && (this.putAgentState(!0, 5), X.monitoredAgentNo = "", X.earSpeakAgent = "", j.reset(), ge.emit(oe.LISTEN_HANGUP, { session_id: A.session_id }), j.updateActionConfigs(Kn));
11089
+ else this.putAgentState(!0), j.reset(), ge.emit(oe.INCOMING_CALL_END, { session_id: A.session_id }), j.updateActionConfigs(Kn);
11090
+ } else if (o === it.SATISFACTION_EVALUATION) a === 0 ? ge.emit(oe.SATISFACTION_EVALUATION_SUCCESS) : (ge.emit(oe.SATISFACTION_EVALUATION_FAILED, s), ge.emit(je.FAIL_NOTIFICATION, s));
11090
11091
  else if (o === it.CONSULT_THREE_WAY) a !== 0 ? (ge.emit(oe.CONSULT_THREE_WAY_FAILED, s), ge.emit(je.FAIL_NOTIFICATION, s)) : a === 0 && j.updateIsMeeting(!0);
11091
11092
  else if (o === it.CONSULT_THREE_WAY_RESULT) A.status === "success" ? (j.updateDirection(bn.MEETING), j.updateDisplayText(Zt.MEETING), j.updateActionConfigs(Xw), ge.emit(oe.CONSULT_THREE_WAY_SUCCESS)) : (ge.emit(oe.CONSULT_THREE_WAY_FAILED, { conf_name: A.conf_name }), j.updateIsMeeting(!1));
11092
11093
  else if (o === it.TRANSFER_INCOMING_CALL) clearTimeout(X.autoStateTimer), A.agent_no === X.agentInfo.agent_no ? (j.updateDisplayText(Zt.TRANSFERRING), ge.emit(oe.TRANSFER_PROGRESS), j.updateActionConfigs([]), j.updateTransferIsAnswer(!0)) : (X.sessionId = A.session_id, ge.emit(oe.TRANSFER_INCOMING_CALL, { agent_no: A.agent_no, agent_name: A.agent_name, session_id: A.session_id }), j.updateIsCalling(!0), j.updateDirection(bn.TRANSFER), j.updateDisplayText(Zt.TRANSFER_INCOMING_CALL), j.updateActionConfigs(Ia), X.enableBrowserAlert && xo.show("📞 转接来电", `坐席 [${A.agent_no}] 正在转接...`, () => {
@@ -11322,7 +11323,7 @@ const Bs = class Bs {
11322
11323
  j.updateDisplayText(""), ge.emit(oe.AGENT_STATE, { state: Tt.BUSY, state_name: "忙碌" });
11323
11324
  } }, "d");
11324
11325
  }, 10);
11325
- } else un.__internalClose(), j.updateDisplayText("离线");
11326
+ } else un.__internalClose(), j.updateIsCalling(!1), j.updateOutCallIsAnswer(!1), j.updateIncomingIsAnswer(!1), j.updateIsMuted(!1), j.updateConsultIsAnswer(!1), j.updateIsHold(!1), j.updateCustomerInfo(void 0), j.updateDisplayText("离线");
11326
11327
  })), Qn(this, ZA, j.subscribeKey("answerDevice", async (e) => {
11327
11328
  e === 1 ? X.stateObject.state === Tt.UNREGISTERED && await dt(this, hn)._changeState({ data: { ...X.stateBeforeChange, state_name: X.stateBeforeChange.state === Tt.IDLE ? "空闲" : "忙碌" } }, "qq") : await this.destroyRtc();
11328
11329
  })), this.on(je.KICK_OFF, () => {
@@ -32811,7 +32812,7 @@ const kO = {
32811
32812
  空闲: 1,
32812
32813
  离线: 0,
32813
32814
  未注册: 4
32814
- }, jO = _m(() => import("./ConsultModel-BIE_E7_R.mjs")), PO = _m(() => import("./TransferModel-BXNCzgl_.mjs")), gc = an.div`
32815
+ }, jO = _m(() => import("./ConsultModel-DPURtS_i.mjs")), PO = _m(() => import("./TransferModel-BFpiWV3W.mjs")), gc = an.div`
32815
32816
  width: 25px;
32816
32817
  height: 25px;
32817
32818
  background: ${({
@@ -1,4 +1,4 @@
1
- "use strict";const b=require("react"),a=require("./index-xVt94WPB.js");function st(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const s=st(b),it=new a.Keyframe("antFadeIn",{"0%":{opacity:0},"100%":{opacity:1}}),ct=new a.Keyframe("antFadeOut",{"0%":{opacity:1},"100%":{opacity:0}}),dt=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const{antCls:o}=e,n=`${o}-fade`,r=t?"&":"";return[a.initMotion(n,it,ct,e.motionDurationMid,t),{[`
1
+ "use strict";const b=require("react"),a=require("./index-DlZp6-xz.js");function st(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const s=st(b),it=new a.Keyframe("antFadeIn",{"0%":{opacity:0},"100%":{opacity:1}}),ct=new a.Keyframe("antFadeOut",{"0%":{opacity:1},"100%":{opacity:0}}),dt=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const{antCls:o}=e,n=`${o}-fade`,r=t?"&":"";return[a.initMotion(n,it,ct,e.motionDurationMid,t),{[`
2
2
  ${r}${n}-enter,
3
3
  ${r}${n}-appear
4
4
  `]:{opacity:0,animationTimingFunction:"linear"},[`${r}${n}-leave`]:{animationTimingFunction:"linear"}}]},ut=e=>{const{paddingXXS:t,lineWidth:o,tagPaddingHorizontal:n,componentCls:r,calc:l}=e,i=l(n).sub(o).equal(),u=l(t).sub(o).equal();return{[r]:Object.assign(Object.assign({},a.resetComponent(e)),{display:"inline-block",height:"auto",marginInlineEnd:e.marginXS,paddingInline:i,fontSize:e.tagFontSize,lineHeight:e.tagLineHeight,whiteSpace:"nowrap",background:e.defaultBg,border:`${a.unit(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,opacity:1,transition:`all ${e.motionDurationMid}`,textAlign:"start",position:"relative",[`&${r}-rtl`]:{direction:"rtl"},"&, a, a:hover":{color:e.defaultColor},[`${r}-close-icon`]:{marginInlineStart:u,fontSize:e.tagIconSize,color:e.colorTextDescription,cursor:"pointer",transition:`all ${e.motionDurationMid}`,"&:hover":{color:e.colorTextHeading}},[`&${r}-has-color`]:{borderColor:"transparent",[`&, a, a:hover, ${e.iconCls}-close, ${e.iconCls}-close:hover`]:{color:e.colorTextLightSolid}},"&-checkable":{backgroundColor:"transparent",borderColor:"transparent",cursor:"pointer",[`&:not(${r}-checkable-checked):hover`]:{color:e.colorPrimary,backgroundColor:e.colorFillSecondary},"&:active, &-checked":{color:e.colorTextLightSolid},"&-checked":{backgroundColor:e.colorPrimary,"&:hover":{backgroundColor:e.colorPrimaryHover}},"&:active":{backgroundColor:e.colorPrimaryActive}},"&-hidden":{display:"none"},[`> ${e.iconCls} + span, > span + ${e.iconCls}`]:{marginInlineStart:i}}),[`${r}-borderless`]:{borderColor:"transparent",background:e.tagBorderlessBg}}},Ce=e=>{const{lineWidth:t,fontSizeIcon:o,calc:n}=e,r=e.fontSizeSM;return a.merge(e,{tagFontSize:r,tagLineHeight:a.unit(n(e.lineHeightSM).mul(r).equal()),tagIconSize:n(o).sub(n(t).mul(2)).equal(),tagPaddingHorizontal:8,tagBorderlessBg:e.defaultBg})},pe=e=>({defaultBg:new a.FastColor(e.colorFillQuaternary).onBackground(e.colorBgContainer).toHexString(),defaultColor:e.colorText}),Re=a.genStyleHooks("Tag",e=>{const t=Ce(e);return ut(t)},pe);function oe(e){if(e)return{closable:e.closable,closeIcon:e.closeIcon}}function $e(e){const{closable:t,closeIcon:o}=e||{};return b.useMemo(()=>{if(!t&&(t===!1||o===!1||o===null))return!1;if(t===void 0&&o===void 0)return null;let n={closeIcon:typeof o!="boolean"&&o!==null?o:void 0};return t&&typeof t=="object"&&(n=Object.assign(Object.assign({},n),t)),n},[t,o])}function xe(){const e={};for(var t=arguments.length,o=new Array(t),n=0;n<t;n++)o[n]=arguments[n];return o.forEach(r=>{r&&Object.keys(r).forEach(l=>{r[l]!==void 0&&(e[l]=r[l])})}),e}const mt={};function Be(e,t){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mt;const n=$e(e),r=$e(t),l=typeof n!="boolean"?!!(n!=null&&n.disabled):!1,i=b.useMemo(()=>Object.assign({closeIcon:b.createElement(a.RefIcon,null)},o),[o]),u=b.useMemo(()=>n===!1?!1:n?xe(i,r,n):r===!1?!1:r?xe(i,r):i.closable?i:!1,[n,r,i]);return b.useMemo(()=>{if(u===!1)return[!1,null,l];const{closeIconRender:c}=i,{closeIcon:g}=u;let d=g;if(d!=null){c&&(d=c(g));const m=a.pickAttrs(u,!0);Object.keys(m).length&&(d=b.isValidElement(d)?b.cloneElement(d,m):b.createElement("span",Object.assign({},m),d))}return[!0,d,l]},[u,i])}var ft=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]]);return o};const gt=s.forwardRef((e,t)=>{const{prefixCls:o,style:n,className:r,checked:l,onChange:i,onClick:u}=e,c=ft(e,["prefixCls","style","className","checked","onChange","onClick"]),{getPrefixCls:g,tag:d}=s.useContext(a.ConfigContext),m=y=>{i==null||i(!l),u==null||u(y)},f=g("tag",o),[v,x,C]=Re(f),p=a.classNames(f,`${f}-checkable`,{[`${f}-checkable-checked`]:l},d==null?void 0:d.className,r,x,C);return v(s.createElement("span",Object.assign({},c,{ref:t,style:Object.assign(Object.assign({},n),d==null?void 0:d.style),className:p,onClick:m})))}),Ct=e=>a.genPresetColor(e,(t,o)=>{let{textColor:n,lightBorderColor:r,lightColor:l,darkColor:i}=o;return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:n,background:l,borderColor:r,"&-inverse":{color:e.colorTextLightSolid,background:i,borderColor:i},[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}}),pt=a.genSubStyleComponent(["Tag","preset"],e=>{const t=Ce(e);return Ct(t)},pe);function bt(e){return typeof e!="string"?e:e.charAt(0).toUpperCase()+e.slice(1)}const ne=(e,t,o)=>{const n=bt(o);return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:e[`color${o}`],background:e[`color${n}Bg`],borderColor:e[`color${n}Border`],[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}},vt=a.genSubStyleComponent(["Tag","status"],e=>{const t=Ce(e);return[ne(t,"success","Success"),ne(t,"processing","Info"),ne(t,"error","Error"),ne(t,"warning","Warning")]},pe);var ht=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]]);return o};const yt=s.forwardRef((e,t)=>{const{prefixCls:o,className:n,rootClassName:r,style:l,children:i,icon:u,color:c,onClose:g,bordered:d=!0,visible:m}=e,f=ht(e,["prefixCls","className","rootClassName","style","children","icon","color","onClose","bordered","visible"]),{getPrefixCls:v,direction:x,tag:C}=s.useContext(a.ConfigContext),[p,y]=s.useState(!0),h=a.omit(f,["closeIcon","closable"]);process.env.NODE_ENV!=="production"&&a.devUseWarning("Tag").deprecated(!("visible"in e),"visible","visible && <Tag />"),s.useEffect(()=>{m!==void 0&&y(m)},[m]);const S=a.isPresetColor(c),N=a.isPresetStatusColor(c),E=S||N,O=Object.assign(Object.assign({backgroundColor:c&&!E?c:void 0},C==null?void 0:C.style),l),$=v("tag",o),[P,j,H]=Re($),B=a.classNames($,C==null?void 0:C.className,{[`${$}-${c}`]:E,[`${$}-has-color`]:c&&!E,[`${$}-hidden`]:!p,[`${$}-rtl`]:x==="rtl",[`${$}-borderless`]:!d},n,r,j,H),_=I=>{I.stopPropagation(),g==null||g(I),!I.defaultPrevented&&y(!1)},[,V]=Be(oe(e),oe(C),{closable:!1,closeIconRender:I=>{const X=s.createElement("span",{className:`${$}-close-icon`,onClick:_},I);return a.replaceElement(I,X,M=>({onClick:q=>{var R;(R=M==null?void 0:M.onClick)===null||R===void 0||R.call(M,q),_(q)},className:a.classNames(M==null?void 0:M.className,`${$}-close-icon`)}))}}),A=typeof f.onClick=="function"||i&&i.type==="a",z=u||null,W=z?s.createElement(s.Fragment,null,z,i&&s.createElement("span",null,i)):i,L=s.createElement("span",Object.assign({},h,{ref:t,className:B,style:O}),W,V,S&&s.createElement(pt,{key:"preset",prefixCls:$}),N&&s.createElement(vt,{key:"status",prefixCls:$}));return P(A?s.createElement(a.Wave,{component:"Tag"},L):L)}),be=yt;process.env.NODE_ENV!=="production"&&(be.displayName="Tag");be.CheckableTag=gt;function ie(e){return!!(e!=null&&e.then)}const _e=e=>{const{type:t,children:o,prefixCls:n,buttonProps:r,close:l,autoFocus:i,emitEvent:u,isSilent:c,quitOnNullishReturnValue:g,actionFn:d}=e,m=s.useRef(!1),f=s.useRef(null),[v,x]=a.useSafeState(!1),C=function(){l==null||l.apply(void 0,arguments)};s.useEffect(()=>{let h=null;return i&&(h=setTimeout(()=>{var S;(S=f.current)===null||S===void 0||S.focus({preventScroll:!0})})),()=>{h&&clearTimeout(h)}},[]);const p=h=>{ie(h)&&(x(!0),h.then(function(){x(!1,!0),C.apply(void 0,arguments),m.current=!1},S=>{if(x(!1,!0),m.current=!1,!(c!=null&&c()))return Promise.reject(S)}))},y=h=>{if(m.current)return;if(m.current=!0,!d){C();return}let S;if(u){if(S=d(h),g&&!ie(S)){m.current=!1,C(h);return}}else if(d.length)S=d(l),m.current=!1;else if(S=d(),!ie(S)){C();return}p(S)};return s.createElement(a.Button,Object.assign({},a.convertLegacyProps(t),{onClick:y,loading:v,prefixCls:n},r,{ref:f}),o)},ee=b.createContext({}),{Provider:He}=ee,Se=()=>{const{autoFocusButton:e,cancelButtonProps:t,cancelTextLocale:o,isSilent:n,mergedOkCancel:r,rootPrefixCls:l,close:i,onCancel:u,onConfirm:c}=b.useContext(ee);return r?b.createElement(_e,{isSilent:n,actionFn:u,close:function(){i==null||i.apply(void 0,arguments),c==null||c(!1)},autoFocus:e==="cancel",buttonProps:t,prefixCls:`${l}-btn`},o):null},Oe=()=>{const{autoFocusButton:e,close:t,isSilent:o,okButtonProps:n,rootPrefixCls:r,okTextLocale:l,okType:i,onConfirm:u,onOk:c}=b.useContext(ee);return b.createElement(_e,{isSilent:o,type:i||"primary",actionFn:c,close:function(){t==null||t.apply(void 0,arguments),u==null||u(!0)},autoFocus:e==="ok",buttonProps:n,prefixCls:`${r}-btn`},l)};var ze=s.createContext({});function Ne(e,t,o){var n=t;return!n&&o&&(n="".concat(e,"-").concat(o)),n}function Ee(e,t){var o=e["page".concat(t?"Y":"X","Offset")],n="scroll".concat(t?"Top":"Left");if(typeof o!="number"){var r=e.document;o=r.documentElement[n],typeof o!="number"&&(o=r.body[n])}return o}function $t(e){var t=e.getBoundingClientRect(),o={left:t.left,top:t.top},n=e.ownerDocument,r=n.defaultView||n.parentWindow;return o.left+=Ee(r),o.top+=Ee(r,!0),o}const xt=s.memo(function(e){var t=e.children;return t},function(e,t){var o=t.shouldUpdate;return!o});var St={width:0,height:0,overflow:"hidden",outline:"none"},Ot={outline:"none"},ve=b.forwardRef(function(e,t){var o=e.prefixCls,n=e.className,r=e.style,l=e.title,i=e.ariaId,u=e.footer,c=e.closable,g=e.closeIcon,d=e.onClose,m=e.children,f=e.bodyStyle,v=e.bodyProps,x=e.modalRender,C=e.onMouseDown,p=e.onMouseUp,y=e.holderRef,h=e.visible,S=e.forceRender,N=e.width,E=e.height,O=e.classNames,$=e.styles,P=b.useContext(ze),j=P.panel,H=a.useComposeRef(y,j),B=b.useRef(),_=b.useRef();b.useImperativeHandle(t,function(){return{focus:function(){var R;(R=B.current)===null||R===void 0||R.focus({preventScroll:!0})},changeActive:function(R){var Y=document,G=Y.activeElement;R&&G===_.current?B.current.focus({preventScroll:!0}):!R&&G===B.current&&_.current.focus({preventScroll:!0})}}});var V={};N!==void 0&&(V.width=N),E!==void 0&&(V.height=E);var A=u?b.createElement("div",{className:a.classNames("".concat(o,"-footer"),O==null?void 0:O.footer),style:a._objectSpread2({},$==null?void 0:$.footer)},u):null,z=l?b.createElement("div",{className:a.classNames("".concat(o,"-header"),O==null?void 0:O.header),style:a._objectSpread2({},$==null?void 0:$.header)},b.createElement("div",{className:"".concat(o,"-title"),id:i},l)):null,W=b.useMemo(function(){return a._typeof(c)==="object"&&c!==null?c:c?{closeIcon:g??b.createElement("span",{className:"".concat(o,"-close-x")})}:{}},[c,g,o]),L=a.pickAttrs(W,!0),I=a._typeof(c)==="object"&&c.disabled,X=c?b.createElement("button",a._extends({type:"button",onClick:d,"aria-label":"Close"},L,{className:"".concat(o,"-close"),disabled:I}),W.closeIcon):null,M=b.createElement("div",{className:a.classNames("".concat(o,"-content"),O==null?void 0:O.content),style:$==null?void 0:$.content},X,z,b.createElement("div",a._extends({className:a.classNames("".concat(o,"-body"),O==null?void 0:O.body),style:a._objectSpread2(a._objectSpread2({},f),$==null?void 0:$.body)},v),m),A);return b.createElement("div",{key:"dialog-element",role:"dialog","aria-labelledby":l?i:null,"aria-modal":"true",ref:H,style:a._objectSpread2(a._objectSpread2({},r),V),className:a.classNames(o,n),onMouseDown:C,onMouseUp:p},b.createElement("div",{ref:B,tabIndex:0,style:Ot},b.createElement(xt,{shouldUpdate:h||S},x?x(M):M)),b.createElement("div",{tabIndex:0,ref:_,style:St}))});process.env.NODE_ENV!=="production"&&(ve.displayName="Panel");var Ae=s.forwardRef(function(e,t){var o=e.prefixCls,n=e.title,r=e.style,l=e.className,i=e.visible,u=e.forceRender,c=e.destroyOnClose,g=e.motionName,d=e.ariaId,m=e.onVisibleChanged,f=e.mousePosition,v=b.useRef(),x=s.useState(),C=a._slicedToArray(x,2),p=C[0],y=C[1],h={};p&&(h.transformOrigin=p);function S(){var N=$t(v.current);y(f&&(f.x||f.y)?"".concat(f.x-N.left,"px ").concat(f.y-N.top,"px"):"")}return s.createElement(a.CSSMotion,{visible:i,onVisibleChanged:m,onAppearPrepare:S,onEnterPrepare:S,forceRender:u,motionName:g,removeOnLeave:c,ref:v},function(N,E){var O=N.className,$=N.style;return s.createElement(ve,a._extends({},e,{ref:t,title:n,ariaId:d,prefixCls:o,holderRef:E,style:a._objectSpread2(a._objectSpread2(a._objectSpread2({},$),r),h),className:a.classNames(l,O)}))})});Ae.displayName="Content";var Nt=function(t){var o=t.prefixCls,n=t.style,r=t.visible,l=t.maskProps,i=t.motionName,u=t.className;return s.createElement(a.CSSMotion,{key:"mask",visible:r,motionName:i,leavedClassName:"".concat(o,"-mask-hidden")},function(c,g){var d=c.className,m=c.style;return s.createElement("div",a._extends({ref:g,style:a._objectSpread2(a._objectSpread2({},m),n),className:a.classNames("".concat(o,"-mask"),d,u)},l))})},Et=function(t){var o=t.prefixCls,n=o===void 0?"rc-dialog":o,r=t.zIndex,l=t.visible,i=l===void 0?!1:l,u=t.keyboard,c=u===void 0?!0:u,g=t.focusTriggerAfterClose,d=g===void 0?!0:g,m=t.wrapStyle,f=t.wrapClassName,v=t.wrapProps,x=t.onClose,C=t.afterOpenChange,p=t.afterClose,y=t.transitionName,h=t.animation,S=t.closable,N=S===void 0?!0:S,E=t.mask,O=E===void 0?!0:E,$=t.maskTransitionName,P=t.maskAnimation,j=t.maskClosable,H=j===void 0?!0:j,B=t.maskStyle,_=t.maskProps,V=t.rootClassName,A=t.classNames,z=t.styles;process.env.NODE_ENV!=="production"&&(["wrapStyle","bodyStyle","maskStyle"].forEach(function(w){a.warning(!(w in t),"".concat(w," is deprecated, please use styles instead."))}),"wrapClassName"in t&&a.warning(!1,"wrapClassName is deprecated, please use classNames instead."));var W=b.useRef(),L=b.useRef(),I=b.useRef(),X=s.useState(i),M=a._slicedToArray(X,2),q=M[0],R=M[1],Y=a.useId();function G(){a.contains(L.current,document.activeElement)||(W.current=document.activeElement)}function le(){if(!a.contains(L.current,document.activeElement)){var w;(w=I.current)===null||w===void 0||w.focus()}}function k(w){if(w)le();else{if(R(!1),O&&W.current&&d){try{W.current.focus({preventScroll:!0})}catch{}W.current=null}q&&(p==null||p())}C==null||C(w)}function T(w){x==null||x(w)}var D=b.useRef(!1),J=b.useRef(),ot=function(){clearTimeout(J.current),D.current=!0},at=function(){J.current=setTimeout(function(){D.current=!1})},ye=null;H&&(ye=function(se){D.current?D.current=!1:L.current===se.target&&T(se)});function rt(w){if(c&&w.keyCode===a.KeyCode.ESC){w.stopPropagation(),T(w);return}i&&w.keyCode===a.KeyCode.TAB&&I.current.changeActive(!w.shiftKey)}b.useEffect(function(){i&&(R(!0),G())},[i]),b.useEffect(function(){return function(){clearTimeout(J.current)}},[]);var lt=a._objectSpread2(a._objectSpread2(a._objectSpread2({zIndex:r},m),z==null?void 0:z.wrapper),{},{display:q?null:"none"});return s.createElement("div",a._extends({className:a.classNames("".concat(n,"-root"),V)},a.pickAttrs(t,{data:!0})),s.createElement(Nt,{prefixCls:n,visible:O&&i,motionName:Ne(n,$,P),style:a._objectSpread2(a._objectSpread2({zIndex:r},B),z==null?void 0:z.mask),maskProps:_,className:A==null?void 0:A.mask}),s.createElement("div",a._extends({tabIndex:-1,onKeyDown:rt,className:a.classNames("".concat(n,"-wrap"),f,A==null?void 0:A.wrapper),ref:L,onClick:ye,style:lt},v),s.createElement(Ae,a._extends({},t,{onMouseDown:ot,onMouseUp:at,ref:I,closable:N,ariaId:Y,prefixCls:n,visible:i&&q,onClose:T,onVisibleChanged:k,motionName:Ne(n,y,h)}))))},Le=function(t){var o=t.visible,n=t.getContainer,r=t.forceRender,l=t.destroyOnClose,i=l===void 0?!1:l,u=t.afterClose,c=t.panelRef,g=s.useState(o),d=a._slicedToArray(g,2),m=d[0],f=d[1],v=s.useMemo(function(){return{panel:c}},[c]);return s.useEffect(function(){o&&f(!0)},[o]),!r&&i&&!m?null:s.createElement(ze.Provider,{value:v},s.createElement(a.Portal,{open:o||r||m,autoDestroy:!1,getContainer:n,autoLock:o||m},s.createElement(Et,a._extends({},t,{destroyOnClose:i,afterClose:function(){u==null||u(),f(!1)}}))))};Le.displayName="Dialog";const wt=()=>a.canUseDom()&&window.document.documentElement,ae=e=>{const{prefixCls:t,className:o,style:n,size:r,shape:l}=e,i=a.classNames({[`${t}-lg`]:r==="large",[`${t}-sm`]:r==="small"}),u=a.classNames({[`${t}-circle`]:l==="circle",[`${t}-square`]:l==="square",[`${t}-round`]:l==="round"}),c=s.useMemo(()=>typeof r=="number"?{width:r,height:r,lineHeight:`${r}px`}:{},[r]);return s.createElement("span",{className:a.classNames(t,i,u,o),style:Object.assign(Object.assign({},c),n)})},jt=new a.Keyframe("ant-skeleton-loading",{"0%":{backgroundPosition:"100% 50%"},"100%":{backgroundPosition:"0 50%"}}),re=e=>({height:e,lineHeight:a.unit(e)}),Q=e=>Object.assign({width:e},re(e)),Pt=e=>({background:e.skeletonLoadingBackground,backgroundSize:"400% 100%",animationName:jt,animationDuration:e.skeletonLoadingMotionDuration,animationTimingFunction:"ease",animationIterationCount:"infinite"}),ce=(e,t)=>Object.assign({width:t(e).mul(5).equal(),minWidth:t(e).mul(5).equal()},re(e)),It=e=>{const{skeletonAvatarCls:t,gradientFromColor:o,controlHeight:n,controlHeightLG:r,controlHeightSM:l}=e;return{[t]:Object.assign({display:"inline-block",verticalAlign:"top",background:o},Q(n)),[`${t}${t}-circle`]:{borderRadius:"50%"},[`${t}${t}-lg`]:Object.assign({},Q(r)),[`${t}${t}-sm`]:Object.assign({},Q(l))}},Tt=e=>{const{controlHeight:t,borderRadiusSM:o,skeletonInputCls:n,controlHeightLG:r,controlHeightSM:l,gradientFromColor:i,calc:u}=e;return{[n]:Object.assign({display:"inline-block",verticalAlign:"top",background:i,borderRadius:o},ce(t,u)),[`${n}-lg`]:Object.assign({},ce(r,u)),[`${n}-sm`]:Object.assign({},ce(l,u))}},we=e=>Object.assign({width:e},re(e)),Mt=e=>{const{skeletonImageCls:t,imageSizeBase:o,gradientFromColor:n,borderRadiusSM:r,calc:l}=e;return{[t]:Object.assign(Object.assign({display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",background:n,borderRadius:r},we(l(o).mul(2).equal())),{[`${t}-path`]:{fill:"#bfbfbf"},[`${t}-svg`]:Object.assign(Object.assign({},we(o)),{maxWidth:l(o).mul(4).equal(),maxHeight:l(o).mul(4).equal()}),[`${t}-svg${t}-svg-circle`]:{borderRadius:"50%"}}),[`${t}${t}-circle`]:{borderRadius:"50%"}}},de=(e,t,o)=>{const{skeletonButtonCls:n}=e;return{[`${o}${n}-circle`]:{width:t,minWidth:t,borderRadius:"50%"},[`${o}${n}-round`]:{borderRadius:t}}},ue=(e,t)=>Object.assign({width:t(e).mul(2).equal(),minWidth:t(e).mul(2).equal()},re(e)),Rt=e=>{const{borderRadiusSM:t,skeletonButtonCls:o,controlHeight:n,controlHeightLG:r,controlHeightSM:l,gradientFromColor:i,calc:u}=e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({[o]:Object.assign({display:"inline-block",verticalAlign:"top",background:i,borderRadius:t,width:u(n).mul(2).equal(),minWidth:u(n).mul(2).equal()},ue(n,u))},de(e,n,o)),{[`${o}-lg`]:Object.assign({},ue(r,u))}),de(e,r,`${o}-lg`)),{[`${o}-sm`]:Object.assign({},ue(l,u))}),de(e,l,`${o}-sm`))},Bt=e=>{const{componentCls:t,skeletonAvatarCls:o,skeletonTitleCls:n,skeletonParagraphCls:r,skeletonButtonCls:l,skeletonInputCls:i,skeletonImageCls:u,controlHeight:c,controlHeightLG:g,controlHeightSM:d,gradientFromColor:m,padding:f,marginSM:v,borderRadius:x,titleHeight:C,blockRadius:p,paragraphLiHeight:y,controlHeightXS:h,paragraphMarginTop:S}=e;return{[t]:{display:"table",width:"100%",[`${t}-header`]:{display:"table-cell",paddingInlineEnd:f,verticalAlign:"top",[o]:Object.assign({display:"inline-block",verticalAlign:"top",background:m},Q(c)),[`${o}-circle`]:{borderRadius:"50%"},[`${o}-lg`]:Object.assign({},Q(g)),[`${o}-sm`]:Object.assign({},Q(d))},[`${t}-content`]:{display:"table-cell",width:"100%",verticalAlign:"top",[n]:{width:"100%",height:C,background:m,borderRadius:p,[`+ ${r}`]:{marginBlockStart:d}},[r]:{padding:0,"> li":{width:"100%",height:y,listStyle:"none",background:m,borderRadius:p,"+ li":{marginBlockStart:h}}},[`${r}> li:last-child:not(:first-child):not(:nth-child(2))`]:{width:"61%"}},[`&-round ${t}-content`]:{[`${n}, ${r} > li`]:{borderRadius:x}}},[`${t}-with-avatar ${t}-content`]:{[n]:{marginBlockStart:v,[`+ ${r}`]:{marginBlockStart:S}}},[`${t}${t}-element`]:Object.assign(Object.assign(Object.assign(Object.assign({display:"inline-block",width:"auto"},Rt(e)),It(e)),Tt(e)),Mt(e)),[`${t}${t}-block`]:{width:"100%",[l]:{width:"100%"},[i]:{width:"100%"}},[`${t}${t}-active`]:{[`
@@ -1,6 +1,6 @@
1
1
  import * as r from "react";
2
2
  import $, { useContext as re, useRef as Z, useMemo as Lt, useEffect as De } from "react";
3
- import { i as Dt, K as Ne, g as se, F as kt, m as fe, u as N, r as nt, b as Pe, p as je, C as q, c as O, d as Ie, e as At, o as ge, f as Ce, h as _t, k as Vt, l as Wt, W as qt, n as Gt, B as Te, q as ot, s as Xt, _ as R, t as ke, v as Y, w as Me, x as at, y as Ae, z as Ut, A as _e, D as Ve, P as Kt, G as Qt, H as K, J as Zt, L as Yt, N as Re, O as Jt, Q as lt, T as en, U as tn, V as rt, X as nn, Z as on, $ as an, a0 as ue, a1 as ln, a2 as st, a3 as rn, a4 as sn, a5 as cn, a6 as dn, a7 as un, a8 as mn, a9 as fn, aa as gn, ab as Cn, ac as it, ad as pn, ae as vn } from "./index-DExsNupU.mjs";
3
+ import { i as Dt, K as Ne, g as se, F as kt, m as fe, u as N, r as nt, b as Pe, p as je, C as q, c as O, d as Ie, e as At, o as ge, f as Ce, h as _t, k as Vt, l as Wt, W as qt, n as Gt, B as Te, q as ot, s as Xt, _ as R, t as ke, v as Y, w as Me, x as at, y as Ae, z as Ut, A as _e, D as Ve, P as Kt, G as Qt, H as K, J as Zt, L as Yt, N as Re, O as Jt, Q as lt, T as en, U as tn, V as rt, X as nn, Z as on, $ as an, a0 as ue, a1 as ln, a2 as st, a3 as rn, a4 as sn, a5 as cn, a6 as dn, a7 as un, a8 as mn, a9 as fn, aa as gn, ab as Cn, ac as it, ad as pn, ae as vn } from "./index-BrCg-39l.mjs";
4
4
  const bn = new Ne("antFadeIn", {
5
5
  "0%": {
6
6
  opacity: 0
@@ -160,7 +160,7 @@ React keys must be passed directly to JSX without using spread:
160
160
  * @author Chen, Yi-Cyuan [emn178@gmail.com]
161
161
  * @copyright Chen, Yi-Cyuan 2014-2023
162
162
  * @license MIT
163
- */Pl=T0,function(){var t="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_MD5_NO_WINDOW&&(e=!1);var r=!e&&typeof self=="object",i=!n.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;i?n=bw:r&&(n=self);var o,A=!n.JS_MD5_NO_COMMON_JS&&Pl.exports,a=!n.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",s="0123456789abcdef".split(""),l=[128,32768,8388608,-2147483648],u=[0,8,16,24],d=["hex","array","digest","buffer","arrayBuffer","base64"],g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),p=[];if(a){var V=new ArrayBuffer(68);o=new Uint8Array(V),p=new Uint32Array(V)}var v=Array.isArray;!n.JS_MD5_NO_NODE_JS&&v||(v=function(q){return Object.prototype.toString.call(q)==="[object Array]"});var m=ArrayBuffer.isView;!a||!n.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&m||(m=function(q){return typeof q=="object"&&q.buffer&&q.buffer.constructor===ArrayBuffer});var C=function(q){var E=typeof q;if(E==="string")return[q,!0];if(E!=="object"||q===null)throw new Error(t);if(a&&q.constructor===ArrayBuffer)return[new Uint8Array(q),!1];if(!v(q)&&!m(q))throw new Error(t);return[q,!1]},w=function(q){return function(E){return new I(!0).update(E)[q]()}},S=function(q){var E,h=wf,y=wf.Buffer;return E=y.from&&!n.JS_MD5_NO_BUFFER_FROM?y.from:function(x){return new y(x)},function(x){if(typeof x=="string")return h.createHash("md5").update(x,"utf8").digest("hex");if(x==null)throw new Error(t);return x.constructor===ArrayBuffer&&(x=new Uint8Array(x)),v(x)||m(x)||x.constructor===y?h.createHash("md5").update(E(x)).digest("hex"):q(x)}},M=function(q){return function(E,h){return new f(E,!0).update(h)[q]()}};function I(q){if(q)p[0]=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0,this.blocks=p,this.buffer8=o;else if(a){var E=new ArrayBuffer(68);this.buffer8=new Uint8Array(E),this.blocks=new Uint32Array(E)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function f(q,E){var h,y=C(q);if(q=y[0],y[1]){var x,b=[],B=q.length,O=0;for(h=0;h<B;++h)(x=q.charCodeAt(h))<128?b[O++]=x:x<2048?(b[O++]=192|x>>>6,b[O++]=128|63&x):x<55296||x>=57344?(b[O++]=224|x>>>12,b[O++]=128|x>>>6&63,b[O++]=128|63&x):(x=65536+((1023&x)<<10|1023&q.charCodeAt(++h)),b[O++]=240|x>>>18,b[O++]=128|x>>>12&63,b[O++]=128|x>>>6&63,b[O++]=128|63&x);q=b}q.length>64&&(q=new I(!0).update(q).array());var N=[],F=[];for(h=0;h<64;++h){var j=q[h]||0;N[h]=92^j,F[h]=54^j}I.call(this,E),this.update(F),this.oKeyPad=N,this.inner=!0,this.sharedMemory=E}I.prototype.update=function(q){if(this.finalized)throw new Error("finalize already called");var E=C(q);q=E[0];for(var h,y,x=E[1],b=0,B=q.length,O=this.blocks,N=this.buffer8;b<B;){if(this.hashed&&(this.hashed=!1,O[0]=O[16],O[16]=O[1]=O[2]=O[3]=O[4]=O[5]=O[6]=O[7]=O[8]=O[9]=O[10]=O[11]=O[12]=O[13]=O[14]=O[15]=0),x)if(a)for(y=this.start;b<B&&y<64;++b)(h=q.charCodeAt(b))<128?N[y++]=h:h<2048?(N[y++]=192|h>>>6,N[y++]=128|63&h):h<55296||h>=57344?(N[y++]=224|h>>>12,N[y++]=128|h>>>6&63,N[y++]=128|63&h):(h=65536+((1023&h)<<10|1023&q.charCodeAt(++b)),N[y++]=240|h>>>18,N[y++]=128|h>>>12&63,N[y++]=128|h>>>6&63,N[y++]=128|63&h);else for(y=this.start;b<B&&y<64;++b)(h=q.charCodeAt(b))<128?O[y>>>2]|=h<<u[3&y++]:h<2048?(O[y>>>2]|=(192|h>>>6)<<u[3&y++],O[y>>>2]|=(128|63&h)<<u[3&y++]):h<55296||h>=57344?(O[y>>>2]|=(224|h>>>12)<<u[3&y++],O[y>>>2]|=(128|h>>>6&63)<<u[3&y++],O[y>>>2]|=(128|63&h)<<u[3&y++]):(h=65536+((1023&h)<<10|1023&q.charCodeAt(++b)),O[y>>>2]|=(240|h>>>18)<<u[3&y++],O[y>>>2]|=(128|h>>>12&63)<<u[3&y++],O[y>>>2]|=(128|h>>>6&63)<<u[3&y++],O[y>>>2]|=(128|63&h)<<u[3&y++]);else if(a)for(y=this.start;b<B&&y<64;++b)N[y++]=q[b];else for(y=this.start;b<B&&y<64;++b)O[y>>>2]|=q[b]<<u[3&y++];this.lastByteIndex=y,this.bytes+=y-this.start,y>=64?(this.start=y-64,this.hash(),this.hashed=!0):this.start=y}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},I.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var q=this.blocks,E=this.lastByteIndex;q[E>>>2]|=l[3&E],E>=56&&(this.hashed||this.hash(),q[0]=q[16],q[16]=q[1]=q[2]=q[3]=q[4]=q[5]=q[6]=q[7]=q[8]=q[9]=q[10]=q[11]=q[12]=q[13]=q[14]=q[15]=0),q[14]=this.bytes<<3,q[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},I.prototype.hash=function(){var q,E,h,y,x,b,B=this.blocks;this.first?E=((E=((q=((q=B[0]-680876937)<<7|q>>>25)-271733879|0)^(h=((h=(-271733879^(y=((y=(-1732584194^2004318071&q)+B[1]-117830708)<<12|y>>>20)+q|0)&(-271733879^q))+B[2]-1126478375)<<17|h>>>15)+y|0)&(y^q))+B[3]-1316259209)<<22|E>>>10)+h|0:(q=this.h0,E=this.h1,h=this.h2,E=((E+=((q=((q+=((y=this.h3)^E&(h^y))+B[0]-680876936)<<7|q>>>25)+E|0)^(h=((h+=(E^(y=((y+=(h^q&(E^h))+B[1]-389564586)<<12|y>>>20)+q|0)&(q^E))+B[2]+606105819)<<17|h>>>15)+y|0)&(y^q))+B[3]-1044525330)<<22|E>>>10)+h|0),E=((E+=((q=((q+=(y^E&(h^y))+B[4]-176418897)<<7|q>>>25)+E|0)^(h=((h+=(E^(y=((y+=(h^q&(E^h))+B[5]+1200080426)<<12|y>>>20)+q|0)&(q^E))+B[6]-1473231341)<<17|h>>>15)+y|0)&(y^q))+B[7]-45705983)<<22|E>>>10)+h|0,E=((E+=((q=((q+=(y^E&(h^y))+B[8]+1770035416)<<7|q>>>25)+E|0)^(h=((h+=(E^(y=((y+=(h^q&(E^h))+B[9]-1958414417)<<12|y>>>20)+q|0)&(q^E))+B[10]-42063)<<17|h>>>15)+y|0)&(y^q))+B[11]-1990404162)<<22|E>>>10)+h|0,E=((E+=((q=((q+=(y^E&(h^y))+B[12]+1804603682)<<7|q>>>25)+E|0)^(h=((h+=(E^(y=((y+=(h^q&(E^h))+B[13]-40341101)<<12|y>>>20)+q|0)&(q^E))+B[14]-1502002290)<<17|h>>>15)+y|0)&(y^q))+B[15]+1236535329)<<22|E>>>10)+h|0,E=((E+=((y=((y+=(E^h&((q=((q+=(h^y&(E^h))+B[1]-165796510)<<5|q>>>27)+E|0)^E))+B[6]-1069501632)<<9|y>>>23)+q|0)^q&((h=((h+=(q^E&(y^q))+B[11]+643717713)<<14|h>>>18)+y|0)^y))+B[0]-373897302)<<20|E>>>12)+h|0,E=((E+=((y=((y+=(E^h&((q=((q+=(h^y&(E^h))+B[5]-701558691)<<5|q>>>27)+E|0)^E))+B[10]+38016083)<<9|y>>>23)+q|0)^q&((h=((h+=(q^E&(y^q))+B[15]-660478335)<<14|h>>>18)+y|0)^y))+B[4]-405537848)<<20|E>>>12)+h|0,E=((E+=((y=((y+=(E^h&((q=((q+=(h^y&(E^h))+B[9]+568446438)<<5|q>>>27)+E|0)^E))+B[14]-1019803690)<<9|y>>>23)+q|0)^q&((h=((h+=(q^E&(y^q))+B[3]-187363961)<<14|h>>>18)+y|0)^y))+B[8]+1163531501)<<20|E>>>12)+h|0,E=((E+=((y=((y+=(E^h&((q=((q+=(h^y&(E^h))+B[13]-1444681467)<<5|q>>>27)+E|0)^E))+B[2]-51403784)<<9|y>>>23)+q|0)^q&((h=((h+=(q^E&(y^q))+B[7]+1735328473)<<14|h>>>18)+y|0)^y))+B[12]-1926607734)<<20|E>>>12)+h|0,E=((E+=((b=(y=((y+=((x=E^h)^(q=((q+=(x^y)+B[5]-378558)<<4|q>>>28)+E|0))+B[8]-2022574463)<<11|y>>>21)+q|0)^q)^(h=((h+=(b^E)+B[11]+1839030562)<<16|h>>>16)+y|0))+B[14]-35309556)<<23|E>>>9)+h|0,E=((E+=((b=(y=((y+=((x=E^h)^(q=((q+=(x^y)+B[1]-1530992060)<<4|q>>>28)+E|0))+B[4]+1272893353)<<11|y>>>21)+q|0)^q)^(h=((h+=(b^E)+B[7]-155497632)<<16|h>>>16)+y|0))+B[10]-1094730640)<<23|E>>>9)+h|0,E=((E+=((b=(y=((y+=((x=E^h)^(q=((q+=(x^y)+B[13]+681279174)<<4|q>>>28)+E|0))+B[0]-358537222)<<11|y>>>21)+q|0)^q)^(h=((h+=(b^E)+B[3]-722521979)<<16|h>>>16)+y|0))+B[6]+76029189)<<23|E>>>9)+h|0,E=((E+=((b=(y=((y+=((x=E^h)^(q=((q+=(x^y)+B[9]-640364487)<<4|q>>>28)+E|0))+B[12]-421815835)<<11|y>>>21)+q|0)^q)^(h=((h+=(b^E)+B[15]+530742520)<<16|h>>>16)+y|0))+B[2]-995338651)<<23|E>>>9)+h|0,E=((E+=((y=((y+=(E^((q=((q+=(h^(E|~y))+B[0]-198630844)<<6|q>>>26)+E|0)|~h))+B[7]+1126891415)<<10|y>>>22)+q|0)^((h=((h+=(q^(y|~E))+B[14]-1416354905)<<15|h>>>17)+y|0)|~q))+B[5]-57434055)<<21|E>>>11)+h|0,E=((E+=((y=((y+=(E^((q=((q+=(h^(E|~y))+B[12]+1700485571)<<6|q>>>26)+E|0)|~h))+B[3]-1894986606)<<10|y>>>22)+q|0)^((h=((h+=(q^(y|~E))+B[10]-1051523)<<15|h>>>17)+y|0)|~q))+B[1]-2054922799)<<21|E>>>11)+h|0,E=((E+=((y=((y+=(E^((q=((q+=(h^(E|~y))+B[8]+1873313359)<<6|q>>>26)+E|0)|~h))+B[15]-30611744)<<10|y>>>22)+q|0)^((h=((h+=(q^(y|~E))+B[6]-1560198380)<<15|h>>>17)+y|0)|~q))+B[13]+1309151649)<<21|E>>>11)+h|0,E=((E+=((y=((y+=(E^((q=((q+=(h^(E|~y))+B[4]-145523070)<<6|q>>>26)+E|0)|~h))+B[11]-1120210379)<<10|y>>>22)+q|0)^((h=((h+=(q^(y|~E))+B[2]+718787259)<<15|h>>>17)+y|0)|~q))+B[9]-343485551)<<21|E>>>11)+h|0,this.first?(this.h0=q+1732584193|0,this.h1=E-271733879|0,this.h2=h-1732584194|0,this.h3=y+271733878|0,this.first=!1):(this.h0=this.h0+q|0,this.h1=this.h1+E|0,this.h2=this.h2+h|0,this.h3=this.h3+y|0)},I.prototype.hex=function(){this.finalize();var q=this.h0,E=this.h1,h=this.h2,y=this.h3;return s[q>>>4&15]+s[15&q]+s[q>>>12&15]+s[q>>>8&15]+s[q>>>20&15]+s[q>>>16&15]+s[q>>>28&15]+s[q>>>24&15]+s[E>>>4&15]+s[15&E]+s[E>>>12&15]+s[E>>>8&15]+s[E>>>20&15]+s[E>>>16&15]+s[E>>>28&15]+s[E>>>24&15]+s[h>>>4&15]+s[15&h]+s[h>>>12&15]+s[h>>>8&15]+s[h>>>20&15]+s[h>>>16&15]+s[h>>>28&15]+s[h>>>24&15]+s[y>>>4&15]+s[15&y]+s[y>>>12&15]+s[y>>>8&15]+s[y>>>20&15]+s[y>>>16&15]+s[y>>>28&15]+s[y>>>24&15]},I.prototype.toString=I.prototype.hex,I.prototype.digest=function(){this.finalize();var q=this.h0,E=this.h1,h=this.h2,y=this.h3;return[255&q,q>>>8&255,q>>>16&255,q>>>24&255,255&E,E>>>8&255,E>>>16&255,E>>>24&255,255&h,h>>>8&255,h>>>16&255,h>>>24&255,255&y,y>>>8&255,y>>>16&255,y>>>24&255]},I.prototype.array=I.prototype.digest,I.prototype.arrayBuffer=function(){this.finalize();var q=new ArrayBuffer(16),E=new Uint32Array(q);return E[0]=this.h0,E[1]=this.h1,E[2]=this.h2,E[3]=this.h3,q},I.prototype.buffer=I.prototype.arrayBuffer,I.prototype.base64=function(){for(var q,E,h,y="",x=this.array(),b=0;b<15;)q=x[b++],E=x[b++],h=x[b++],y+=g[q>>>2]+g[63&(q<<4|E>>>4)]+g[63&(E<<2|h>>>6)]+g[63&h];return q=x[b],y+=g[q>>>2]+g[q<<4&63]+"=="},f.prototype=new I,f.prototype.finalize=function(){if(I.prototype.finalize.call(this),this.inner){this.inner=!1;var q=this.array();I.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(q),I.prototype.finalize.call(this)}};var R=function(){var q=w("hex");i&&(q=S(q)),q.create=function(){return new I},q.update=function(y){return q.create().update(y)};for(var E=0;E<d.length;++E){var h=d[E];q[h]=w(h)}return q}();R.md5=R,R.md5.hmac=function(){var q=M("hex");q.create=function(y){return new f(y)},q.update=function(y,x){return q.create(y).update(x)};for(var E=0;E<d.length;++E){var h=d[E];q[h]=M(h)}return q}(),A?Pl.exports=R:n.md5=R}();var Mw=T0.exports;const B0=(t,e)=>{const n=Date.now(),r=`${t}:${n}:${Mw.md5(`${e}${n}`)}`,i=new TextEncoder().encode(r);return btoa(String.fromCharCode(...i))},eu=t=>{if(/^\d+$/.test(t)||!t||typeof t!="string"||t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return!1;try{const e=atob(t);return btoa(e)===t}catch{return!1}},ya="/v1/aicc/bmserver",br="/v1/aicc/ccs";let qo="",jd="",Pd="",Ll="";function O0(t){const e=B0(jd,Pd);return Iw.create({prefixUrl:`${qo}`,timeout:!1,headers:{Authorization:e,...t},hooks:{afterResponse:[async(n,r,i)=>{if(i.url.indexOf("heartbeat")!==-1)return i;const o=await i.clone().json();if(o.code!==0)throw new Error(JSON.stringify(o)||"请求失败");return i.json=async()=>o,i}]}})}async function Pn(t,e,n){const r=O0(n),i="api/"+t.replace(/^\/+/,"");return r.post(i,{json:e}).json()}class So{static requestPermission(){"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}static async requestMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(n=>n.kind==="audioinput"&&n.label!=="")?null:await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){return console.warn("获取音频权限失败:",e),null}}static show(e,n,r,i){if("Notification"in window&&Notification.permission==="granted"){const o=new Notification(e,{body:n,tag:`xy-global-notification${new Date().getTime()}`,renotify:!0});o.onclick=()=>{window.focus(),o.close(),r==null||r()},setTimeout(()=>o.close(),1e3*(i||3))}}static async checkMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(e=>e.kind==="audioinput"&&e.label!=="")}catch(e){return console.warn("无法检查设备权限:",e),!1}}}const Ff=(t,e)=>Pn(`${br}/state/change?h=${e}`,t,{h:e}),Rw=()=>async function(t,e){const n=O0(),r=t.replace(/^\/+/,"");return n.post(r,{json:e}).json()}("/heartbeat",{}),xw=[],Ln=["call_number"],cs=["call_number"],Tw=["hangup"],Vi=["hold","hangup","mute","transfer","consult","satisfaction","dtmf"],Yl=["hold","hangup","mute","transfer","consult"],Qf=["consult_transfer","conference","consult_retrieve"],Bw=["hangup"],Ow=["hangup"],wa=["answer","reject"],Ui=["hangup","consult","transfer","hold","mute","satisfaction","dtmf"],kf=["hangup","whisper","force_insert","force_disconnect"],Dw=["hangup"],Nw=["hangup","cancel_whisper","force_insert"],Fw=["hangup"],Qw=["hangup"];class OA{constructor(){this.roleData={agentInfo:()=>{var e;if(!((e=_.agentInfo)!=null&&e.agent_no))throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:e=>{if(!e.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:e=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:n}=_.agentInfo;if(!n.split(",").map(r=>Number(r)).includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(e,n)=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!n)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(e===2&&(n==="通话中"||n==="整理"))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:e=>{const{out_display_select_switch:n,out_display_data:r}=_.agentInfo;if(n!==1)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(r||"").split("#").includes(e))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}},this.changeDevice=async e=>{try{if(P.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:n,success:r}=e,{device:i}=n;i===1&&await OA.initRtcFn(),this.roleData.changeDevice(i);const{agent_no:o}=_.agentInfo;await(a=>Pn(`${br}/device/change`,a))({agent_no:o,answer_device:i}),P.updateAnswerDevice(i);const A=P.get("actionConfigs");P.updateActionConfigs(A),i===2&&_.stateObject.state===Rt.UNREGISTERED&&await this._changeState({data:{..._.stateBeforeChange,state_name:_.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},"q"),r==null||r({code:0,msg:"请求成功"})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}formatDate(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}static setInitRtcFn(e){this.initRtcFn=e}async _agentLogin(e){try{const r=await(n={agent_no:e},Pn(`${br}/agent/login`,n));_.agentInfo=r.data}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}var n}async _changeState(e,n){try{_.autoStateTimer&&(clearTimeout(_.autoStateTimer),_.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:A}=r,{agent_no:a}=_.agentInfo;await Ff({agent_no:a,state_name:A,state:o},n),o===Rt.IDLE?P.updateActionConfigs(Ln):o===Rt.BUSY&&P.updateActionConfigs(cs),_.stateObject={state:o,state_name:A},i==null||i({code:0,msg:"请求成功"})}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async _getInCallCrmDetail(e){var n;try{const{phone:r}=e.data,i={};eu(r)?i.trace_id=r:i.phone=r.replace(/[\s\r\n-]+/g,"");const o=await(A=>Pn(`${ya}/crm/popups`,A))({...i});(n=e.success)==null||n.call(e,o)}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async changeState(e,n){try{if(P.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));_.autoStateTimer&&(clearTimeout(_.autoStateTimer),_.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:A}=r;this.roleData.changeState(o,A);const{agent_no:a}=_.agentInfo;await Ff({agent_no:a,state_name:A,state:o},n),(_.stateObject.state===Rt.IDLE||_.stateObject.state===Rt.BUSY&&A!=="整理")&&(_.stateBeforeChange=_.stateObject),o===Rt.IDLE?P.updateActionConfigs(Ln):o===Rt.BUSY&&P.updateActionConfigs(cs),_.stateObject={state:o,state_name:A},i==null||i({code:0,msg:"请求成功"})}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getIdleAgentList(e){var r;const{agent_no:n}=_.agentInfo;try{this.roleData.agentInfo();const i=await(o=>Pn(`${br}/agent/free`,o))({agent_no:n});(r=e.success)==null||r.call(e,i)}catch(i){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(i.message).msg),i}}async getAgentState(e){var n;try{const r=await Pn(`${ya}/agent/statecfg/list`,{}),i=(r.data||[]).filter(o=>o.enable===0).filter(o=>o.state!==0&&o.state!==3).filter(o=>o.state_name!=="通话中"&&o.state_name!=="整理"&&o.state_name!=="未注册"&&o.state_name!=="离线接听").map(o=>({state:o.state,state_name:o.state_name})).reverse();(n=e.success)==null||n.call(e,{...r,data:i})}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async setAgentExplicit(e){var n;try{this.roleData.agentInfo(),this.roleData.requestInfo(e),this.roleData.setAgentExplicit(e.data.number);const{agent_id:r}=_.agentInfo;await(i=>Pn(`${ya}/agent/update`,i))({agent_id:r,out_display_number:e.data.number}),P.updateSelectOutNumber(e.data.number),(n=e.success)==null||n.call(e,{code:0,msg:"请求成功"})}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async checkAgentLogin(e){var n;try{this.roleData.requestInfo(e);const{agent_no:r}=e.data;if(!r)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const i=await(o=>Pn(`${br}/agent/islogin`,o))({agent_no:r});(n=e.success)==null||n.call(e,i)}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getCallRecord(e){try{this.roleData.agentInfo();const{success:n}=e,r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59),A=[this.formatDate(i),this.formatDate(o)],{agent_no:a}=_.agentInfo,s=await(g=>Pn(`${ya}/agent/recordpage`,g))({start_time:A[0],end_time:A[1],page_no:1,page_size:10,agent_no:a}),{code:l,msg:u,data:d}=s;n==null||n({code:l,msg:u,data:d})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async logout(e){this.roleData.agentInfo();try{const{agent_no:n}=_.agentInfo,{data:r,success:i}=e;await(o=>Pn(`${br}/agent/logout`,o))({...r,agent_no:n}),i==null||i({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async listenCall(e){try{const{agent_no:n}=_.agentInfo,{data:r,success:i}=e;if(this.roleData.agentInfo(),this.roleData.requestInfo(e),!r.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(o=>Pn(`${br}/call/monitor`,o))({...r,monitor_agent_no:n}),_.monitoredAgentNo=r.monitored_agent_no,i==null||i({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async earCall(e){try{const{agentInfo:n,monitoredAgentNo:r}=_,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(A=>Pn(`${br}/call/whisper`,A))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async stopEarCall(e){try{const{agentInfo:n,earSpeakAgent:r}=_;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;await(A=>Pn(`${br}/call/stopwhisper`,A))({monitor_agent_no:i,monitored_agent_no:r}),o==null||o({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceInsert(e){try{const{agentInfo:n,monitoredAgentNo:r}=_,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(A=>Pn(`${br}/call/bargein`,A))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceDisconnect(e){try{const{agentInfo:n,monitoredAgentNo:r}=_,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(A=>Pn(`${br}/call/intercept`,A))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}const kw=console.log,Uf=(...t)=>{_.logBuiltinEnabled&&kw(...t)};let ti=null;class ln{constructor(e,n){this.url=e,this.onOpenCallback=n,this.ws=null,this.heartbeatWorker=null,this.reconnectDelay=3e3,this.manualClose=!1,this.apiClient=new OA,this.sipClient=null,this.pendingMessages=new Map,this.initWebSocket()}static getInstance({url:e,sipClient:n,onOpen:r}){if(!ti){if(!e)throw new Error("WebSocket 尚未初始化");ti=new ln(e,r),ti.sipClient=n}return ti}setSipClient(e){this.sipClient=e}stateIdleChange(e){const{state:n}=_.stateObject;n!==Rt.IDLE&&this.apiClient._changeState({data:{..._.stateBeforeChange,state_name:_.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},e)}inCallAutoAnswer(){const{soft_device_auto_answer:e,auto_answer_time:n}=_.agentInfo,r=e===1,i=P.get("direction");if(r&&i===yn.INCOMING){const o=Number(n)||0;o>0&&(_.autoAnswerTimer=setTimeout(()=>{var A;(A=this.sipClient)==null||A.answerCall(),_.autoAnswerTimer=null},1e3*o-500))}}async getCustomerInfo(e){try{await this.apiClient._getInCallCrmDetail({data:{phone:e},success:n=>{P.updateCustomerInfo(n.data||{phone:n.data.phone,is_vip:0,customer_name:"未知客户",city:"未知",province:"未知",contact_count:0,in_contact_count:0,trace_id:n.data.trace_id,contact_count_month:0,in_contact_count_month:0})}})}catch{}}putAgentState(e,n){if(!e)return;if(n===5)return void this.stateIdleChange("device_type5");_.sessionId="";const{post_call_process_time:r}=_.agentInfo,i=r||0;if(_.autoStateTimer&&(clearTimeout(_.autoStateTimer),_.autoStateTimer=null),P.updateCustomerInfo(void 0),i>0){const{state:o}=_.stateObject;if(o===Rt.IDLE)return;this.apiClient._changeState({data:{state:Rt.BUSY,state_name:"整理"}},"ez"),_.autoStateTimer=setTimeout(()=>{_.autoStateTimer=null,this.stateIdleChange(`delay${i}`)},1e3*i)}else this.stateIdleChange("delay0")}stateBusyChange(){_.sessionId="",clearTimeout(_.autoStateTimer),P.updateCustomerInfo(void 0),this.apiClient._changeState({data:{state:Rt.BUSY,state_name:"忙碌"}},"dm")}initWebSocket(){var n;if(((n=this.ws)==null?void 0:n.readyState)===1||!P.get("isNextState")||this.manualClose)return;const e=B0(jd,Pd);this.ws=new WebSocket(this.url+e),this.ws.onopen=()=>{const r=new Date().getTime();this.sendMessage({type:0,msg_id:r}),this.pendingMessages.set(r,performance.now()),this.startHeartbeat(),this.manualClose=!1,this.onOpenCallback&&this.onOpenCallback()},this.ws.onmessage=async r=>{var u;const i=JSON.parse(r.data),{type:o,data:A,code:a,msg:s,msg_id:l}=i;if(o===0&&l){const d=this.pendingMessages.get(l),g=performance.now()-d;_.latency=parseFloat(g.toFixed(2)),this.pendingMessages.delete(l)}if(o!==0&&Uf("%cWebSocket 收到消息:","color: blue; font-weight: bold;",i),o!==rt.OUT_CALL&&o!==rt.PREVIEW_OUT_CALL||(a!==0?(P.reset(),ge.emit(oe.OUT_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s),P.updateActionConfigs(Ln),setTimeout(()=>{P.updateCustomerInfo(void 0)},500),this.stateIdleChange("h")):a===0&&(ge.emit(oe.OUT_SUCCESS),clearTimeout(_.autoStateTimer))),o===rt.AGENT_STATE){const{state:d,state_name:g}=A;_.stateObject={state:d,state_name:g},(u=_.stateBeforeChange)!=null&&u.state||_.stateObject.state!==Rt.IDLE&&(_.stateObject.state!==Rt.BUSY||g==="整理")||(_.stateBeforeChange=_.stateObject),g==="振铃中"&&P.updateDisplayText(Ht.AGENT_RINGING);const p=P.get("isCalling");d!==Rt.UNREGISTERED||p||P.updateActionConfigs(xw),d===Rt.IDLE&&_.stateObject.state===Rt.UNREGISTERED&&P.updateActionConfigs(Ln),ge.emit(oe.AGENT_STATE,{state:d,state_name:g})}else if(o===rt.OUT_CALL_INCOMING_CALL){try{await this.getCustomerInfo(A.trace_id||A.customer_phone)}catch(d){console.error(d)}A.preview_task_id?ge.emit(oe.PREVIEW_OUT_INCOMING_CALL,{customer_phone:A.customer_phone,session_id:A.session_id,preview_task_id:A.preview_task_id,trace_id:A.trace_id}):A.direction===1?ge.emit(oe.OUT_INCOMING_CALL,{customer_phone:A.customer_phone,session_id:A.session_id,trace_id:A.trace_id}):A.direction===8&&ge.emit(oe.INTERNAL_OUT_INCOMING_CALL,{customer_phone:A.customer_phone,session_id:A.session_id,trace_id:A.trace_id}),_.sessionId=A.session_id,P.updateActionConfigs(Tw,A.direction!==8)}else if(o===rt.OUT_CALL_END){if(_.sessionId!==A.session_id)return;if(P.updateDisplayText(""),A.device_type===1&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.OUT_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0);else if(A.device_type===2&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.OUR_SIDE_CONSULT_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0);else if(A.device_type===2&&A.agent_no!==_.agentInfo.agent_no)P.get("isCalling")&&(P.updateDisplayText(Ht.CALLING),ge.emit(oe.OTHER_SIDE_CONSULT_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Vi));else if(A.device_type===3&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.THREE_WAY_OUR_SIDE_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0);else if(A.device_type===4&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.TRANSFER_END,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0);else if(A.device_type===4&&A.agent_no!==_.agentInfo.agent_no){ge.emit(oe.TRANSFER_FAILED,"未知原因"),ge.emit(Ge.FAIL_NOTIFICATION,"转接失败");const d=P.get("direction");d===yn.OUTGOING?P.updateActionConfigs(Vi):d===yn.INCOMING&&P.updateActionConfigs(Ui)}else A.device_type===5&&A.agent_no===_.agentInfo.agent_no&&(_.monitoredAgentNo="",_.earSpeakAgent="",P.reset(),ge.emit(oe.LISTEN_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0,5))}else if(o===rt.OUT_CALL_RINGING)A.type===1&&(ge.emit(oe.OUT_RINGING,{session_id:_.sessionId,type:A.type}),P.updateDisplayText(Ht.RINGING));else if(o===rt.OUT_CALL_ANSWER)clearTimeout(_.autoStateTimer),P.updateIsCalling(!0),P.updateOutCallIsAnswer(!0),P.updateDisplayText(Ht.CALLING),A.direction===8?(ge.emit(oe.INTERNAL_OUT_OFF_ANSWER,{session_id:_.sessionId}),P.updateActionConfigs(Yl)):(ge.emit(oe.OUT_OFF_ANSWER,{session_id:_.sessionId}),P.updateActionConfigs(Vi));else if(o===rt.CONSULT_RINGING)ge.emit(oe.CONSULT_RINGING,{session_id:A.session_id}),P.updateDisplayText(Ht.AGENT_RINGING),P.updateActionConfigs([]),clearTimeout(_.autoStateTimer);else if(o===rt.CONSULT_ANSWER)ge.emit(oe.CONSULT_OFF_HOOK,{session_id:A.session_id}),P.updateConsultIsAnswer(!0),P.updateDisplayText(Ht.CONSULTING),P.updateActionConfigs(Qf);else if(o===rt.CONSULT_FAIL)ge.emit(oe.CONSULT_FAILED,{custom_reason:A.custom_reason}),P.updateDisplayText(Ht.CALLING),P.updateActionConfigs(Vi);else if(o===rt.CONSULT_CALL_IN)ge.emit(oe.CONSULT_INCOMING,{agent_no:A.agent_no,agent_mane:A.agent_name,session_id:A.session_id}),_.sessionId=A.session_id,P.updateIsCalling(!0),P.updateDirection(yn.CONSULT),P.updateDisplayText(Ht.CONSULT_CALL_IN),P.updateActionConfigs(wa),_.enableBrowserAlert&&So.show("📞 咨询来电",`坐席 [${A.agent_name}] 正在咨询...`,()=>{ge.emit(Ge.NOTIFICATION_CLICK,{agent_mane:A.agent_name,agent_no:A.agent_no})},_.browserAlertTime);else if(o===rt.CONSULT_CALL_IN_SUCCESS)ge.emit(oe.CONSULT_CALL_IN_SUCCESS,{session_id:A.session_id}),P.updateConsultIsAnswer(!0),P.updateDisplayText(Ht.CALLING),P.updateActionConfigs(Bw);else if(o===rt.CONSULT_RETURN_CALL_SUCCESS)A.status==="success"?(P.updateConsultIsAnswer(!1),ge.emit(oe.CONSULT_RETURN_CALL_SUCCESS),P.updateDisplayText(Ht.CALLING),ge.emit(oe.OTHER_SIDE_CONSULT_HANGUP),P.updateActionConfigs(Vi)):ge.emit(Ge.FAIL_NOTIFICATION,"媒体失败");else if(o===rt.MUTE)a===0?(P.updateIsMuted(!0),ge.emit(oe.MUTE_SUCCESS),P.updateDisplayText(Ht.MUTING)):(ge.emit(oe.MUTE_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.UNMUTE)a===0?(P.updateIsMuted(!1),ge.emit(oe.UNMUTE_SUCCESS),P.updateDisplayText(Ht.CALLING)):(ge.emit(oe.UNMUTE_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CALL_HOLD)a===0?(P.updateIsHold(!0),P.updateDisplayText(Ht.HOLDING),ge.emit(oe.HOLD_SUCCESS)):(ge.emit(oe.HOLD_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CALL_UNHOLD)a===0?(P.updateDisplayText(Ht.CALLING),P.updateIsHold(!1),ge.emit(oe.UNHOLD_SUCCESS)):(ge.emit(oe.UNHOLD_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CONSULT_TRANSFER)a===0?ge.emit(oe.CONSULT_TRANSFER_SUCCESS):(ge.emit(oe.CONSULT_TRANSFER_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CONSULT_TRANSFER_FAILED)ge.emit(oe.CONSULT_TRANSFER_FAILED,A.status);else if(o===rt.CONSULT_TRANSFER_OFF_HOOK)P.updateDirection(yn.INCOMING),P.updateDisplayText(Ht.CALLING),ge.emit(oe.CONSULT_TRANSFER_OFF_HOOK),P.updateActionConfigs(Ui),P.updateIncomingIsAnswer(!0),P.updateConsultIsAnswer(!1);else if(o===rt.INCOMING_CALL){if(_.sessionId!==A.session_id)return;clearTimeout(_.autoStateTimer),_.sessionId=A.session_id;try{await this.getCustomerInfo(A.trace_id||A.customer_phone)}catch(d){console.error(d)}P.updateIsCalling(!0),P.updateDirection(yn.INCOMING),P.updateDisplayText(Ht.INCOMING_CALL),this.inCallAutoAnswer(),A.direction===1&&ge.emit(oe.INCOMING_CALL,{customer_phone:A.customer_phone,trace_id:A.trace_id,session_id:A.session_id}),A.direction===8&&ge.emit(oe.INCOMING_CALL_IN,{customer_phone:A.customer_phone,trace_id:A.trace_id,session_id:A.session_id}),A.direction===3&&ge.emit(oe.PREDICT_INCOMING_CALL,{customer_phone:A.customer_phone,trace_id:A.trace_id,session_id:A.session_id}),A.direction===6&&ge.emit(oe.DUAL_CALL_INCOMING_CALL,{customer_phone:A.customer_phone,trace_id:A.trace_id,session_id:A.session_id}),P.updateActionConfigs(wa),_.enableBrowserAlert&&So.show("📞 客户来电",`客户 [${A.customer_phone}] 正在呼入...`,()=>{ge.emit(Ge.NOTIFICATION_CLICK,{customer_phone:A.customer_phone})},_.browserAlertTime)}else if(o===rt.INCOMING_CALL_OFF_HOOK)P.updateIncomingIsAnswer(!0),A.direction===8?(P.updateActionConfigs(Yl),ge.emit(oe.INCOMING_CALL_IN_OFF_HOOK,{session_id:_.sessionId})):(P.updateActionConfigs(Ui),ge.emit(oe.INCOMING_CALL_OFF_HOOK,{session_id:_.sessionId})),P.updateDisplayText(Ht.CALLING);else if(o===rt.INCOMING_CALL_END)if(P.updateDisplayText(""),A.device_type!==1&&A.device_type!==7||A.agent_no!==_.agentInfo.agent_no)if(A.device_type===2&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.OUR_SIDE_CONSULT_HANGUP,{session_id:A.session_id}),this.putAgentState(!0),P.updateActionConfigs(Ln);else if(A.device_type===2&&A.agent_no!==_.agentInfo.agent_no)P.updateDisplayText(Ht.CALLING),ge.emit(oe.OTHER_SIDE_CONSULT_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Vi);else if(A.device_type===3&&A.agent_no===_.agentInfo.agent_no)this.putAgentState(!0),P.reset(),ge.emit(oe.THREE_WAY_OUR_SIDE_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln);else if(A.device_type===4&&A.agent_no===_.agentInfo.agent_no)this.putAgentState(!0),P.reset(),ge.emit(oe.TRANSFER_END,{session_id:A.session_id}),P.updateActionConfigs(Ln);else if(A.device_type===4&&A.agent_no!==_.agentInfo.agent_no){ge.emit(oe.TRANSFER_FAILED,"未知原因"),ge.emit(Ge.FAIL_NOTIFICATION,"转接失败");const d=P.get("direction");d===yn.OUTGOING?P.updateActionConfigs(Vi):d===yn.INCOMING&&P.updateActionConfigs(Ui)}else A.device_type===5&&A.agent_no===_.agentInfo.agent_no&&(this.putAgentState(!0,5),_.monitoredAgentNo="",_.earSpeakAgent="",P.reset(),ge.emit(oe.LISTEN_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln));else this.putAgentState(!0),P.reset(),ge.emit(oe.INCOMING_CALL_END,{session_id:A.session_id}),P.updateActionConfigs(Ln);else if(o===rt.SATISFACTION_EVALUATION)a===0?ge.emit(oe.SATISFACTION_EVALUATION_SUCCESS):(ge.emit(oe.SATISFACTION_EVALUATION_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CONSULT_THREE_WAY)a!==0?(ge.emit(oe.CONSULT_THREE_WAY_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s)):a===0&&P.updateIsMeeting(!0);else if(o===rt.CONSULT_THREE_WAY_RESULT)A.status==="success"?(P.updateDirection(yn.MEETING),P.updateDisplayText(Ht.MEETING),P.updateActionConfigs(Ow),ge.emit(oe.CONSULT_THREE_WAY_SUCCESS)):(ge.emit(oe.CONSULT_THREE_WAY_FAILED,{conf_name:A.conf_name}),P.updateIsMeeting(!1));else if(o===rt.TRANSFER_INCOMING_CALL)clearTimeout(_.autoStateTimer),A.agent_no===_.agentInfo.agent_no?(P.updateDisplayText(Ht.TRANSFERRING),ge.emit(oe.TRANSFER_PROGRESS),P.updateActionConfigs([]),P.updateTransferIsAnswer(!0)):(_.sessionId=A.session_id,ge.emit(oe.TRANSFER_INCOMING_CALL,{agent_no:A.agent_no,agent_name:A.agent_name,session_id:A.session_id}),P.updateIsCalling(!0),P.updateDirection(yn.TRANSFER),P.updateDisplayText(Ht.TRANSFER_INCOMING_CALL),P.updateActionConfigs(wa),_.enableBrowserAlert&&So.show("📞 转接来电",`坐席 [${A.agent_no}] 正在转接...`,()=>{ge.emit(Ge.NOTIFICATION_CLICK,{agent_no:A.agent_no})},_.browserAlertTime));else if(o===rt.TRANSFER_OFF_HOOK)ge.emit(oe.TRANSFER_OFF_HOOK,{session_id:_.sessionId}),P.updateTransferIsAnswer(!1),P.updateDisplayText(Ht.CALLING),P.updateActionConfigs(Ui,A.direction!==8);else if(o===rt.TRANSFER_FAILED){if(A.status==="failed"){ge.emit(oe.TRANSFER_FAILED,"未知原因"),ge.emit(Ge.FAIL_NOTIFICATION,"转接失败");const d=P.get("direction");d===yn.OUTGOING?P.updateActionConfigs(Vi):d===yn.INCOMING&&P.updateActionConfigs(Ui)}}else o===rt.KICK_OFFLINE?ge.emit(Ge.KICK_OFF):o===rt.CONTINUOUS_NOT_ANSWER?(ge.emit(Ge.FAIL_NOTIFICATION,`已连续 ${A.miss_count} 次未接, 设置忙碌`),this.stateBusyChange()):o===rt.SIGN_OUT?ge.emit(Ge.SIGN_OUT):o===rt.SIGN_IN_SWITCH_DEVICE?ge.emit(Ge.SIGN_IN_SWITCH_DEVICE,A):o===rt.LISTEN_INCOMING_CALL?(clearTimeout(_.autoStateTimer),_.sessionId=A.session_id,P.updateIsCalling(!0),P.updateDirection(yn.INCOMING),this.inCallAutoAnswer(),P.updateDisplayText(Ht.LISTENING),P.updateActionConfigs(wa),ge.emit(oe.LISTEN_INCOMING_CALL,{session_id:A.session_id}),_.enableBrowserAlert&&So.show("📞 监听来电","正在来电...",()=>{ge.emit(Ge.NOTIFICATION_CLICK,{customer_phone:A.customer_phone})},_.browserAlertTime)):o===rt.LISTEN_INCOMING_CALL_OFF_HOOK?(_.monitoredAgentNo=A.monitored_agent_no,_.earSpeakAgent="",P.updateIncomingIsAnswer(!0),ge.emit(oe.LISTEN_INCOMING_CALL_OFF_HOOK,{session_id:_.sessionId,monitored_agent_no:A.monitored_agent_no}),P.updateActionConfigs(kf),P.updateDisplayText(Ht.CALLING)):o===rt.LISTEN_CALL_FAILED?A.status==="failed"&&(ge.emit(oe.LISTEN_CALL_FAILED),_.monitoredAgentNo=""):o===rt.EAR_SPEECH?A.status==="success"?(A.monitored_agent_no===_.agentInfo.agent_no&&(P.updateActionConfigs(Dw),ge.emit(oe.EAR_SPEECH_BE_SUCCESS)),A.monitor_agent_no===_.agentInfo.agent_no&&(P.updateActionConfigs(Nw),ge.emit(oe.EAR_SPEECH_SUCCESS,{monitored_agent_no:A.monitored_agent_no,monitor_agent_no:A.monitor_agent_no}),_.earSpeakAgent=A.monitored_agent_no)):ge.emit(oe.EAR_SPEECH_FAILED):o===rt.STOP_EAR_SPEECH?A.status==="success"?(A.monitored_agent_no===_.agentInfo.agent_no&&P.updateActionConfigs(Ui),A.monitor_agent_no===_.agentInfo.agent_no&&P.updateActionConfigs(kf),_.earSpeakAgent="",ge.emit(oe.STOP_EAR_SPEECH_SUCCESS)):ge.emit(oe.STOP_EAR_SPEECH_FAILED):o===rt.CALL_FORCE_INSERT?A.status==="success"?(A.monitored_agent_no===_.agentInfo.agent_no&&(P.updateActionConfigs(Qw),ge.emit(oe.CALL_FORCE_INSERT_SUCCESS,{monitored_agent_no:A.monitored_agent_no,monitor_agent_no:A.monitor_agent_no})),A.monitor_agent_no===_.agentInfo.agent_no&&(P.updateActionConfigs(Fw),ge.emit(oe.CALL_FORCE_INSERT_SUCCESS_LISTENER,{monitored_agent_no:A.monitored_agent_no,monitor_agent_no:A.monitor_agent_no}))):ge.emit(oe.CALL_FORCE_INSERT_FAILED):o===rt.INTERNAL_CALL_START_CONSULT?A.agent_no===_.agentInfo.agent_no?(P.updateConsultIsAnswer(!0),P.updateActionConfigs(Qf),P.updateDisplayText(Ht.CONSULTING)):(P.updateDisplayText(Ht.OTHER_SIDE_CONSULTING),P.updateActionConfigs([])):o===rt.INTERNAL_CALL_END_CONSULT?(P.updateActionConfigs(Yl),P.updateDisplayText(""),P.updateConsultIsAnswer(!1)):o===rt.CALL_SIP_INCOMING_CALL&&ge.emit(oe.CALL_SIP_INCOMING_CALL)},this.ws.onclose=r=>{ge.emit(Ge.FAIL_NOTIFICATION,"链接已断开,请检查网络"),this.stopHeartbeat();const i=P.get("isNextState");!this.manualClose&&i&&setTimeout(()=>this.initWebSocket(),this.reconnectDelay)},this.ws.onerror=r=>{var i;ge.emit(Ge.FAIL_NOTIFICATION,"连接失败,请检查网络"),(i=this.ws)==null||i.close()}}startHeartbeat(){const e=new Blob([`
163
+ */Pl=T0,function(){var t="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_MD5_NO_WINDOW&&(e=!1);var r=!e&&typeof self=="object",i=!n.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;i?n=bw:r&&(n=self);var o,A=!n.JS_MD5_NO_COMMON_JS&&Pl.exports,a=!n.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",s="0123456789abcdef".split(""),l=[128,32768,8388608,-2147483648],u=[0,8,16,24],d=["hex","array","digest","buffer","arrayBuffer","base64"],g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),p=[];if(a){var V=new ArrayBuffer(68);o=new Uint8Array(V),p=new Uint32Array(V)}var v=Array.isArray;!n.JS_MD5_NO_NODE_JS&&v||(v=function(q){return Object.prototype.toString.call(q)==="[object Array]"});var m=ArrayBuffer.isView;!a||!n.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&m||(m=function(q){return typeof q=="object"&&q.buffer&&q.buffer.constructor===ArrayBuffer});var C=function(q){var E=typeof q;if(E==="string")return[q,!0];if(E!=="object"||q===null)throw new Error(t);if(a&&q.constructor===ArrayBuffer)return[new Uint8Array(q),!1];if(!v(q)&&!m(q))throw new Error(t);return[q,!1]},w=function(q){return function(E){return new I(!0).update(E)[q]()}},S=function(q){var E,h=wf,y=wf.Buffer;return E=y.from&&!n.JS_MD5_NO_BUFFER_FROM?y.from:function(x){return new y(x)},function(x){if(typeof x=="string")return h.createHash("md5").update(x,"utf8").digest("hex");if(x==null)throw new Error(t);return x.constructor===ArrayBuffer&&(x=new Uint8Array(x)),v(x)||m(x)||x.constructor===y?h.createHash("md5").update(E(x)).digest("hex"):q(x)}},M=function(q){return function(E,h){return new f(E,!0).update(h)[q]()}};function I(q){if(q)p[0]=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0,this.blocks=p,this.buffer8=o;else if(a){var E=new ArrayBuffer(68);this.buffer8=new Uint8Array(E),this.blocks=new Uint32Array(E)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function f(q,E){var h,y=C(q);if(q=y[0],y[1]){var x,b=[],B=q.length,O=0;for(h=0;h<B;++h)(x=q.charCodeAt(h))<128?b[O++]=x:x<2048?(b[O++]=192|x>>>6,b[O++]=128|63&x):x<55296||x>=57344?(b[O++]=224|x>>>12,b[O++]=128|x>>>6&63,b[O++]=128|63&x):(x=65536+((1023&x)<<10|1023&q.charCodeAt(++h)),b[O++]=240|x>>>18,b[O++]=128|x>>>12&63,b[O++]=128|x>>>6&63,b[O++]=128|63&x);q=b}q.length>64&&(q=new I(!0).update(q).array());var N=[],F=[];for(h=0;h<64;++h){var j=q[h]||0;N[h]=92^j,F[h]=54^j}I.call(this,E),this.update(F),this.oKeyPad=N,this.inner=!0,this.sharedMemory=E}I.prototype.update=function(q){if(this.finalized)throw new Error("finalize already called");var E=C(q);q=E[0];for(var h,y,x=E[1],b=0,B=q.length,O=this.blocks,N=this.buffer8;b<B;){if(this.hashed&&(this.hashed=!1,O[0]=O[16],O[16]=O[1]=O[2]=O[3]=O[4]=O[5]=O[6]=O[7]=O[8]=O[9]=O[10]=O[11]=O[12]=O[13]=O[14]=O[15]=0),x)if(a)for(y=this.start;b<B&&y<64;++b)(h=q.charCodeAt(b))<128?N[y++]=h:h<2048?(N[y++]=192|h>>>6,N[y++]=128|63&h):h<55296||h>=57344?(N[y++]=224|h>>>12,N[y++]=128|h>>>6&63,N[y++]=128|63&h):(h=65536+((1023&h)<<10|1023&q.charCodeAt(++b)),N[y++]=240|h>>>18,N[y++]=128|h>>>12&63,N[y++]=128|h>>>6&63,N[y++]=128|63&h);else for(y=this.start;b<B&&y<64;++b)(h=q.charCodeAt(b))<128?O[y>>>2]|=h<<u[3&y++]:h<2048?(O[y>>>2]|=(192|h>>>6)<<u[3&y++],O[y>>>2]|=(128|63&h)<<u[3&y++]):h<55296||h>=57344?(O[y>>>2]|=(224|h>>>12)<<u[3&y++],O[y>>>2]|=(128|h>>>6&63)<<u[3&y++],O[y>>>2]|=(128|63&h)<<u[3&y++]):(h=65536+((1023&h)<<10|1023&q.charCodeAt(++b)),O[y>>>2]|=(240|h>>>18)<<u[3&y++],O[y>>>2]|=(128|h>>>12&63)<<u[3&y++],O[y>>>2]|=(128|h>>>6&63)<<u[3&y++],O[y>>>2]|=(128|63&h)<<u[3&y++]);else if(a)for(y=this.start;b<B&&y<64;++b)N[y++]=q[b];else for(y=this.start;b<B&&y<64;++b)O[y>>>2]|=q[b]<<u[3&y++];this.lastByteIndex=y,this.bytes+=y-this.start,y>=64?(this.start=y-64,this.hash(),this.hashed=!0):this.start=y}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},I.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var q=this.blocks,E=this.lastByteIndex;q[E>>>2]|=l[3&E],E>=56&&(this.hashed||this.hash(),q[0]=q[16],q[16]=q[1]=q[2]=q[3]=q[4]=q[5]=q[6]=q[7]=q[8]=q[9]=q[10]=q[11]=q[12]=q[13]=q[14]=q[15]=0),q[14]=this.bytes<<3,q[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},I.prototype.hash=function(){var q,E,h,y,x,b,B=this.blocks;this.first?E=((E=((q=((q=B[0]-680876937)<<7|q>>>25)-271733879|0)^(h=((h=(-271733879^(y=((y=(-1732584194^2004318071&q)+B[1]-117830708)<<12|y>>>20)+q|0)&(-271733879^q))+B[2]-1126478375)<<17|h>>>15)+y|0)&(y^q))+B[3]-1316259209)<<22|E>>>10)+h|0:(q=this.h0,E=this.h1,h=this.h2,E=((E+=((q=((q+=((y=this.h3)^E&(h^y))+B[0]-680876936)<<7|q>>>25)+E|0)^(h=((h+=(E^(y=((y+=(h^q&(E^h))+B[1]-389564586)<<12|y>>>20)+q|0)&(q^E))+B[2]+606105819)<<17|h>>>15)+y|0)&(y^q))+B[3]-1044525330)<<22|E>>>10)+h|0),E=((E+=((q=((q+=(y^E&(h^y))+B[4]-176418897)<<7|q>>>25)+E|0)^(h=((h+=(E^(y=((y+=(h^q&(E^h))+B[5]+1200080426)<<12|y>>>20)+q|0)&(q^E))+B[6]-1473231341)<<17|h>>>15)+y|0)&(y^q))+B[7]-45705983)<<22|E>>>10)+h|0,E=((E+=((q=((q+=(y^E&(h^y))+B[8]+1770035416)<<7|q>>>25)+E|0)^(h=((h+=(E^(y=((y+=(h^q&(E^h))+B[9]-1958414417)<<12|y>>>20)+q|0)&(q^E))+B[10]-42063)<<17|h>>>15)+y|0)&(y^q))+B[11]-1990404162)<<22|E>>>10)+h|0,E=((E+=((q=((q+=(y^E&(h^y))+B[12]+1804603682)<<7|q>>>25)+E|0)^(h=((h+=(E^(y=((y+=(h^q&(E^h))+B[13]-40341101)<<12|y>>>20)+q|0)&(q^E))+B[14]-1502002290)<<17|h>>>15)+y|0)&(y^q))+B[15]+1236535329)<<22|E>>>10)+h|0,E=((E+=((y=((y+=(E^h&((q=((q+=(h^y&(E^h))+B[1]-165796510)<<5|q>>>27)+E|0)^E))+B[6]-1069501632)<<9|y>>>23)+q|0)^q&((h=((h+=(q^E&(y^q))+B[11]+643717713)<<14|h>>>18)+y|0)^y))+B[0]-373897302)<<20|E>>>12)+h|0,E=((E+=((y=((y+=(E^h&((q=((q+=(h^y&(E^h))+B[5]-701558691)<<5|q>>>27)+E|0)^E))+B[10]+38016083)<<9|y>>>23)+q|0)^q&((h=((h+=(q^E&(y^q))+B[15]-660478335)<<14|h>>>18)+y|0)^y))+B[4]-405537848)<<20|E>>>12)+h|0,E=((E+=((y=((y+=(E^h&((q=((q+=(h^y&(E^h))+B[9]+568446438)<<5|q>>>27)+E|0)^E))+B[14]-1019803690)<<9|y>>>23)+q|0)^q&((h=((h+=(q^E&(y^q))+B[3]-187363961)<<14|h>>>18)+y|0)^y))+B[8]+1163531501)<<20|E>>>12)+h|0,E=((E+=((y=((y+=(E^h&((q=((q+=(h^y&(E^h))+B[13]-1444681467)<<5|q>>>27)+E|0)^E))+B[2]-51403784)<<9|y>>>23)+q|0)^q&((h=((h+=(q^E&(y^q))+B[7]+1735328473)<<14|h>>>18)+y|0)^y))+B[12]-1926607734)<<20|E>>>12)+h|0,E=((E+=((b=(y=((y+=((x=E^h)^(q=((q+=(x^y)+B[5]-378558)<<4|q>>>28)+E|0))+B[8]-2022574463)<<11|y>>>21)+q|0)^q)^(h=((h+=(b^E)+B[11]+1839030562)<<16|h>>>16)+y|0))+B[14]-35309556)<<23|E>>>9)+h|0,E=((E+=((b=(y=((y+=((x=E^h)^(q=((q+=(x^y)+B[1]-1530992060)<<4|q>>>28)+E|0))+B[4]+1272893353)<<11|y>>>21)+q|0)^q)^(h=((h+=(b^E)+B[7]-155497632)<<16|h>>>16)+y|0))+B[10]-1094730640)<<23|E>>>9)+h|0,E=((E+=((b=(y=((y+=((x=E^h)^(q=((q+=(x^y)+B[13]+681279174)<<4|q>>>28)+E|0))+B[0]-358537222)<<11|y>>>21)+q|0)^q)^(h=((h+=(b^E)+B[3]-722521979)<<16|h>>>16)+y|0))+B[6]+76029189)<<23|E>>>9)+h|0,E=((E+=((b=(y=((y+=((x=E^h)^(q=((q+=(x^y)+B[9]-640364487)<<4|q>>>28)+E|0))+B[12]-421815835)<<11|y>>>21)+q|0)^q)^(h=((h+=(b^E)+B[15]+530742520)<<16|h>>>16)+y|0))+B[2]-995338651)<<23|E>>>9)+h|0,E=((E+=((y=((y+=(E^((q=((q+=(h^(E|~y))+B[0]-198630844)<<6|q>>>26)+E|0)|~h))+B[7]+1126891415)<<10|y>>>22)+q|0)^((h=((h+=(q^(y|~E))+B[14]-1416354905)<<15|h>>>17)+y|0)|~q))+B[5]-57434055)<<21|E>>>11)+h|0,E=((E+=((y=((y+=(E^((q=((q+=(h^(E|~y))+B[12]+1700485571)<<6|q>>>26)+E|0)|~h))+B[3]-1894986606)<<10|y>>>22)+q|0)^((h=((h+=(q^(y|~E))+B[10]-1051523)<<15|h>>>17)+y|0)|~q))+B[1]-2054922799)<<21|E>>>11)+h|0,E=((E+=((y=((y+=(E^((q=((q+=(h^(E|~y))+B[8]+1873313359)<<6|q>>>26)+E|0)|~h))+B[15]-30611744)<<10|y>>>22)+q|0)^((h=((h+=(q^(y|~E))+B[6]-1560198380)<<15|h>>>17)+y|0)|~q))+B[13]+1309151649)<<21|E>>>11)+h|0,E=((E+=((y=((y+=(E^((q=((q+=(h^(E|~y))+B[4]-145523070)<<6|q>>>26)+E|0)|~h))+B[11]-1120210379)<<10|y>>>22)+q|0)^((h=((h+=(q^(y|~E))+B[2]+718787259)<<15|h>>>17)+y|0)|~q))+B[9]-343485551)<<21|E>>>11)+h|0,this.first?(this.h0=q+1732584193|0,this.h1=E-271733879|0,this.h2=h-1732584194|0,this.h3=y+271733878|0,this.first=!1):(this.h0=this.h0+q|0,this.h1=this.h1+E|0,this.h2=this.h2+h|0,this.h3=this.h3+y|0)},I.prototype.hex=function(){this.finalize();var q=this.h0,E=this.h1,h=this.h2,y=this.h3;return s[q>>>4&15]+s[15&q]+s[q>>>12&15]+s[q>>>8&15]+s[q>>>20&15]+s[q>>>16&15]+s[q>>>28&15]+s[q>>>24&15]+s[E>>>4&15]+s[15&E]+s[E>>>12&15]+s[E>>>8&15]+s[E>>>20&15]+s[E>>>16&15]+s[E>>>28&15]+s[E>>>24&15]+s[h>>>4&15]+s[15&h]+s[h>>>12&15]+s[h>>>8&15]+s[h>>>20&15]+s[h>>>16&15]+s[h>>>28&15]+s[h>>>24&15]+s[y>>>4&15]+s[15&y]+s[y>>>12&15]+s[y>>>8&15]+s[y>>>20&15]+s[y>>>16&15]+s[y>>>28&15]+s[y>>>24&15]},I.prototype.toString=I.prototype.hex,I.prototype.digest=function(){this.finalize();var q=this.h0,E=this.h1,h=this.h2,y=this.h3;return[255&q,q>>>8&255,q>>>16&255,q>>>24&255,255&E,E>>>8&255,E>>>16&255,E>>>24&255,255&h,h>>>8&255,h>>>16&255,h>>>24&255,255&y,y>>>8&255,y>>>16&255,y>>>24&255]},I.prototype.array=I.prototype.digest,I.prototype.arrayBuffer=function(){this.finalize();var q=new ArrayBuffer(16),E=new Uint32Array(q);return E[0]=this.h0,E[1]=this.h1,E[2]=this.h2,E[3]=this.h3,q},I.prototype.buffer=I.prototype.arrayBuffer,I.prototype.base64=function(){for(var q,E,h,y="",x=this.array(),b=0;b<15;)q=x[b++],E=x[b++],h=x[b++],y+=g[q>>>2]+g[63&(q<<4|E>>>4)]+g[63&(E<<2|h>>>6)]+g[63&h];return q=x[b],y+=g[q>>>2]+g[q<<4&63]+"=="},f.prototype=new I,f.prototype.finalize=function(){if(I.prototype.finalize.call(this),this.inner){this.inner=!1;var q=this.array();I.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(q),I.prototype.finalize.call(this)}};var R=function(){var q=w("hex");i&&(q=S(q)),q.create=function(){return new I},q.update=function(y){return q.create().update(y)};for(var E=0;E<d.length;++E){var h=d[E];q[h]=w(h)}return q}();R.md5=R,R.md5.hmac=function(){var q=M("hex");q.create=function(y){return new f(y)},q.update=function(y,x){return q.create(y).update(x)};for(var E=0;E<d.length;++E){var h=d[E];q[h]=M(h)}return q}(),A?Pl.exports=R:n.md5=R}();var Mw=T0.exports;const B0=(t,e)=>{const n=Date.now(),r=`${t}:${n}:${Mw.md5(`${e}${n}`)}`,i=new TextEncoder().encode(r);return btoa(String.fromCharCode(...i))},eu=t=>{if(/^\d+$/.test(t)||!t||typeof t!="string"||t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return!1;try{const e=atob(t);return btoa(e)===t}catch{return!1}},ya="/v1/aicc/bmserver",br="/v1/aicc/ccs";let qo="",jd="",Pd="",Ll="";function O0(t){const e=B0(jd,Pd);return Iw.create({prefixUrl:`${qo}`,timeout:!1,headers:{Authorization:e,...t},hooks:{afterResponse:[async(n,r,i)=>{if(i.url.indexOf("heartbeat")!==-1)return i;const o=await i.clone().json();if(o.code!==0)throw new Error(JSON.stringify(o)||"请求失败");return i.json=async()=>o,i}]}})}async function Pn(t,e,n){const r=O0(n),i="api/"+t.replace(/^\/+/,"");return r.post(i,{json:e}).json()}class So{static requestPermission(){"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}static async requestMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(n=>n.kind==="audioinput"&&n.label!=="")?null:await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){return console.warn("获取音频权限失败:",e),null}}static show(e,n,r,i){if("Notification"in window&&Notification.permission==="granted"){const o=new Notification(e,{body:n,tag:`xy-global-notification${new Date().getTime()}`,renotify:!0});o.onclick=()=>{window.focus(),o.close(),r==null||r()},setTimeout(()=>o.close(),1e3*(i||3))}}static async checkMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(e=>e.kind==="audioinput"&&e.label!=="")}catch(e){return console.warn("无法检查设备权限:",e),!1}}}const Ff=(t,e)=>Pn(`${br}/state/change?h=${e}`,t,{h:e}),Rw=()=>async function(t,e){const n=O0(),r=t.replace(/^\/+/,"");return n.post(r,{json:e}).json()}("/heartbeat",{}),xw=[],Ln=["call_number"],cs=["call_number"],Tw=["hangup"],Vi=["hold","hangup","mute","transfer","consult","satisfaction","dtmf"],Yl=["hold","hangup","mute","transfer","consult"],Qf=["consult_transfer","conference","consult_retrieve"],Bw=["hangup"],Ow=["hangup"],wa=["answer","reject"],Ui=["hangup","consult","transfer","hold","mute","satisfaction","dtmf"],kf=["hangup","whisper","force_insert","force_disconnect"],Dw=["hangup"],Nw=["hangup","cancel_whisper","force_insert"],Fw=["hangup"],Qw=["hangup"];class OA{constructor(){this.roleData={agentInfo:()=>{var e;if(!((e=_.agentInfo)!=null&&e.agent_no))throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:e=>{if(!e.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:e=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:n}=_.agentInfo;if(!n.split(",").map(r=>Number(r)).includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(e,n)=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!n)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(e===2&&(n==="通话中"||n==="整理"))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:e=>{const{out_display_select_switch:n,out_display_data:r}=_.agentInfo;if(n!==1)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(r||"").split("#").includes(e))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}},this.changeDevice=async e=>{try{if(P.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:n,success:r}=e,{device:i}=n;i===1&&await OA.initRtcFn(),this.roleData.changeDevice(i);const{agent_no:o}=_.agentInfo;await(a=>Pn(`${br}/device/change`,a))({agent_no:o,answer_device:i}),P.updateAnswerDevice(i);const A=P.get("actionConfigs");P.updateActionConfigs(A),i===2&&_.stateObject.state===Rt.UNREGISTERED&&await this._changeState({data:{..._.stateBeforeChange,state_name:_.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},"q"),r==null||r({code:0,msg:"请求成功"})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}formatDate(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}static setInitRtcFn(e){this.initRtcFn=e}async _agentLogin(e){try{const r=await(n={agent_no:e},Pn(`${br}/agent/login`,n));_.agentInfo=r.data}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}var n}async _changeState(e,n){try{_.autoStateTimer&&(clearTimeout(_.autoStateTimer),_.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:A}=r,{agent_no:a}=_.agentInfo;await Ff({agent_no:a,state_name:A,state:o},n),o===Rt.IDLE?P.updateActionConfigs(Ln):o===Rt.BUSY&&P.updateActionConfigs(cs),_.stateObject={state:o,state_name:A},i==null||i({code:0,msg:"请求成功"})}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async _getInCallCrmDetail(e){var n;try{const{phone:r}=e.data,i={};eu(r)?i.trace_id=r:i.phone=r.replace(/[\s\r\n-]+/g,"");const o=await(A=>Pn(`${ya}/crm/popups`,A))({...i});(n=e.success)==null||n.call(e,o)}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async changeState(e,n){try{if(P.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));_.autoStateTimer&&(clearTimeout(_.autoStateTimer),_.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:A}=r;this.roleData.changeState(o,A);const{agent_no:a}=_.agentInfo;await Ff({agent_no:a,state_name:A,state:o},n),(_.stateObject.state===Rt.IDLE||_.stateObject.state===Rt.BUSY&&A!=="整理")&&(_.stateBeforeChange=_.stateObject),o===Rt.IDLE?P.updateActionConfigs(Ln):o===Rt.BUSY&&P.updateActionConfigs(cs),_.stateObject={state:o,state_name:A},i==null||i({code:0,msg:"请求成功"})}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getIdleAgentList(e){var r;const{agent_no:n}=_.agentInfo;try{this.roleData.agentInfo();const i=await(o=>Pn(`${br}/agent/free`,o))({agent_no:n});(r=e.success)==null||r.call(e,i)}catch(i){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(i.message).msg),i}}async getAgentState(e){var n;try{const r=await Pn(`${ya}/agent/statecfg/list`,{}),i=(r.data||[]).filter(o=>o.enable===0).filter(o=>o.state!==0&&o.state!==3).filter(o=>o.state_name!=="通话中"&&o.state_name!=="整理"&&o.state_name!=="未注册"&&o.state_name!=="离线接听").map(o=>({state:o.state,state_name:o.state_name})).reverse();(n=e.success)==null||n.call(e,{...r,data:i})}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async setAgentExplicit(e){var n;try{this.roleData.agentInfo(),this.roleData.requestInfo(e),this.roleData.setAgentExplicit(e.data.number);const{agent_id:r}=_.agentInfo;await(i=>Pn(`${ya}/agent/update`,i))({agent_id:r,out_display_number:e.data.number}),P.updateSelectOutNumber(e.data.number),(n=e.success)==null||n.call(e,{code:0,msg:"请求成功"})}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async checkAgentLogin(e){var n;try{this.roleData.requestInfo(e);const{agent_no:r}=e.data;if(!r)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const i=await(o=>Pn(`${br}/agent/islogin`,o))({agent_no:r});(n=e.success)==null||n.call(e,i)}catch(r){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getCallRecord(e){try{this.roleData.agentInfo();const{success:n}=e,r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59),A=[this.formatDate(i),this.formatDate(o)],{agent_no:a}=_.agentInfo,s=await(g=>Pn(`${ya}/agent/recordpage`,g))({start_time:A[0],end_time:A[1],page_no:1,page_size:10,agent_no:a}),{code:l,msg:u,data:d}=s;n==null||n({code:l,msg:u,data:d})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async logout(e){this.roleData.agentInfo();try{const{agent_no:n}=_.agentInfo,{data:r,success:i}=e;await(o=>Pn(`${br}/agent/logout`,o))({...r,agent_no:n}),i==null||i({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async listenCall(e){try{const{agent_no:n}=_.agentInfo,{data:r,success:i}=e;if(this.roleData.agentInfo(),this.roleData.requestInfo(e),!r.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(o=>Pn(`${br}/call/monitor`,o))({...r,monitor_agent_no:n}),_.monitoredAgentNo=r.monitored_agent_no,i==null||i({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async earCall(e){try{const{agentInfo:n,monitoredAgentNo:r}=_,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(A=>Pn(`${br}/call/whisper`,A))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async stopEarCall(e){try{const{agentInfo:n,earSpeakAgent:r}=_;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;await(A=>Pn(`${br}/call/stopwhisper`,A))({monitor_agent_no:i,monitored_agent_no:r}),o==null||o({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceInsert(e){try{const{agentInfo:n,monitoredAgentNo:r}=_,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(A=>Pn(`${br}/call/bargein`,A))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceDisconnect(e){try{const{agentInfo:n,monitoredAgentNo:r}=_,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(A=>Pn(`${br}/call/intercept`,A))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ge.emit(Ge.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}const kw=console.log,Uf=(...t)=>{_.logBuiltinEnabled&&kw(...t)};let ti=null;class ln{constructor(e,n){this.url=e,this.onOpenCallback=n,this.ws=null,this.heartbeatWorker=null,this.reconnectDelay=3e3,this.manualClose=!1,this.apiClient=new OA,this.sipClient=null,this.pendingMessages=new Map,this.initWebSocket()}static getInstance({url:e,sipClient:n,onOpen:r}){if(!ti){if(!e)throw new Error("WebSocket 尚未初始化");ti=new ln(e,r),ti.sipClient=n}return ti}setSipClient(e){this.sipClient=e}stateIdleChange(e){const{state:n}=_.stateObject;n!==Rt.IDLE&&this.apiClient._changeState({data:{..._.stateBeforeChange,state_name:_.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},e)}inCallAutoAnswer(){const{soft_device_auto_answer:e,auto_answer_time:n}=_.agentInfo,r=e===1,i=P.get("direction");if(r&&i===yn.INCOMING){const o=Number(n)||0;o>0&&(_.autoAnswerTimer=setTimeout(()=>{var A;(A=this.sipClient)==null||A.answerCall(),_.autoAnswerTimer=null},1e3*o-500))}}async getCustomerInfo(e){try{await this.apiClient._getInCallCrmDetail({data:{phone:e},success:n=>{P.updateCustomerInfo(n.data||{phone:n.data.phone,is_vip:0,customer_name:"未知客户",city:"未知",province:"未知",contact_count:0,in_contact_count:0,trace_id:n.data.trace_id,contact_count_month:0,in_contact_count_month:0})}})}catch{}}putAgentState(e,n){if(!e)return;if(n===5)return void this.stateIdleChange("device_type5");_.sessionId="";const{post_call_process_time:r}=_.agentInfo,i=r||0;if(_.autoStateTimer&&(clearTimeout(_.autoStateTimer),_.autoStateTimer=null),P.updateCustomerInfo(void 0),i>0){const{state:o}=_.stateObject;if(o===Rt.IDLE)return;this.apiClient._changeState({data:{state:Rt.BUSY,state_name:"整理"}},"ez"),_.autoStateTimer=setTimeout(()=>{_.autoStateTimer=null,this.stateIdleChange(`delay${i}`)},1e3*i)}else this.stateIdleChange("delay0")}stateBusyChange(){_.sessionId="",clearTimeout(_.autoStateTimer),P.updateCustomerInfo(void 0),this.apiClient._changeState({data:{state:Rt.BUSY,state_name:"忙碌"}},"dm")}initWebSocket(){var n;if(((n=this.ws)==null?void 0:n.readyState)===1||!P.get("isNextState")||this.manualClose)return;const e=B0(jd,Pd);this.ws=new WebSocket(this.url+e),this.ws.onopen=()=>{const r=new Date().getTime();this.sendMessage({type:0,msg_id:r}),this.pendingMessages.set(r,performance.now()),this.startHeartbeat(),this.manualClose=!1,this.onOpenCallback&&this.onOpenCallback()},this.ws.onmessage=async r=>{var u;const i=JSON.parse(r.data),{type:o,data:A,code:a,msg:s,msg_id:l}=i;if(o===0&&l){const d=this.pendingMessages.get(l),g=performance.now()-d;_.latency=parseFloat(g.toFixed(2)),this.pendingMessages.delete(l)}if(o!==0&&Uf("%cWebSocket 收到消息:","color: blue; font-weight: bold;",i),o!==rt.OUT_CALL&&o!==rt.PREVIEW_OUT_CALL||(a!==0?(P.reset(),ge.emit(oe.OUT_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s),P.updateActionConfigs(Ln),setTimeout(()=>{P.updateCustomerInfo(void 0)},500),this.stateIdleChange("h")):a===0&&(ge.emit(oe.OUT_SUCCESS),clearTimeout(_.autoStateTimer))),o===rt.AGENT_STATE){const{state:d,state_name:g}=A;_.stateObject={state:d,state_name:g},(u=_.stateBeforeChange)!=null&&u.state||_.stateObject.state!==Rt.IDLE&&(_.stateObject.state!==Rt.BUSY||g==="整理")||(_.stateBeforeChange=_.stateObject),g==="振铃中"&&P.updateDisplayText(Ht.AGENT_RINGING);const p=P.get("isCalling");d!==Rt.UNREGISTERED||p||P.updateActionConfigs(xw),d===Rt.IDLE&&_.stateObject.state===Rt.UNREGISTERED&&P.updateActionConfigs(Ln),ge.emit(oe.AGENT_STATE,{state:d,state_name:g})}else if(o===rt.OUT_CALL_INCOMING_CALL){try{await this.getCustomerInfo(A.trace_id||A.customer_phone)}catch(d){console.error(d)}A.preview_task_id?ge.emit(oe.PREVIEW_OUT_INCOMING_CALL,{customer_phone:A.customer_phone,session_id:A.session_id,preview_task_id:A.preview_task_id,trace_id:A.trace_id}):A.direction===1?ge.emit(oe.OUT_INCOMING_CALL,{customer_phone:A.customer_phone,session_id:A.session_id,trace_id:A.trace_id}):A.direction===8&&ge.emit(oe.INTERNAL_OUT_INCOMING_CALL,{customer_phone:A.customer_phone,session_id:A.session_id,trace_id:A.trace_id}),_.sessionId=A.session_id,P.updateActionConfigs(Tw,A.direction!==8)}else if(o===rt.OUT_CALL_END){if(_.sessionId!==A.session_id)return;if(P.updateDisplayText(""),A.device_type===1&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.OUT_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0);else if(A.device_type===2&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.OUR_SIDE_CONSULT_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0);else if(A.device_type===2&&A.agent_no!==_.agentInfo.agent_no)P.get("isCalling")&&(P.updateDisplayText(Ht.CALLING),ge.emit(oe.OTHER_SIDE_CONSULT_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Vi));else if(A.device_type===3&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.THREE_WAY_OUR_SIDE_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0);else if(A.device_type===4&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.TRANSFER_END,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0);else if(A.device_type===4&&A.agent_no!==_.agentInfo.agent_no){ge.emit(oe.TRANSFER_FAILED,"未知原因"),ge.emit(Ge.FAIL_NOTIFICATION,"转接失败");const d=P.get("direction");d===yn.OUTGOING?P.updateActionConfigs(Vi):d===yn.INCOMING&&P.updateActionConfigs(Ui)}else A.device_type===5&&A.agent_no===_.agentInfo.agent_no&&(_.monitoredAgentNo="",_.earSpeakAgent="",P.reset(),ge.emit(oe.LISTEN_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln),this.putAgentState(!0,5))}else if(o===rt.OUT_CALL_RINGING)A.type===1&&(ge.emit(oe.OUT_RINGING,{session_id:_.sessionId,type:A.type}),P.updateDisplayText(Ht.RINGING));else if(o===rt.OUT_CALL_ANSWER)clearTimeout(_.autoStateTimer),P.updateIsCalling(!0),P.updateOutCallIsAnswer(!0),P.updateDisplayText(Ht.CALLING),A.direction===8?(ge.emit(oe.INTERNAL_OUT_OFF_ANSWER,{session_id:_.sessionId}),P.updateActionConfigs(Yl)):(ge.emit(oe.OUT_OFF_ANSWER,{session_id:_.sessionId}),P.updateActionConfigs(Vi));else if(o===rt.CONSULT_RINGING)ge.emit(oe.CONSULT_RINGING,{session_id:A.session_id}),P.updateDisplayText(Ht.AGENT_RINGING),P.updateActionConfigs([]),clearTimeout(_.autoStateTimer);else if(o===rt.CONSULT_ANSWER)ge.emit(oe.CONSULT_OFF_HOOK,{session_id:A.session_id}),P.updateConsultIsAnswer(!0),P.updateDisplayText(Ht.CONSULTING),P.updateActionConfigs(Qf);else if(o===rt.CONSULT_FAIL)ge.emit(oe.CONSULT_FAILED,{custom_reason:A.custom_reason}),P.updateDisplayText(Ht.CALLING),P.updateActionConfigs(Vi);else if(o===rt.CONSULT_CALL_IN)ge.emit(oe.CONSULT_INCOMING,{agent_no:A.agent_no,agent_mane:A.agent_name,session_id:A.session_id}),_.sessionId=A.session_id,P.updateIsCalling(!0),P.updateDirection(yn.CONSULT),P.updateDisplayText(Ht.CONSULT_CALL_IN),P.updateActionConfigs(wa),_.enableBrowserAlert&&So.show("📞 咨询来电",`坐席 [${A.agent_name}] 正在咨询...`,()=>{ge.emit(Ge.NOTIFICATION_CLICK,{agent_mane:A.agent_name,agent_no:A.agent_no})},_.browserAlertTime);else if(o===rt.CONSULT_CALL_IN_SUCCESS)ge.emit(oe.CONSULT_CALL_IN_SUCCESS,{session_id:A.session_id}),P.updateConsultIsAnswer(!0),P.updateDisplayText(Ht.CALLING),P.updateActionConfigs(Bw);else if(o===rt.CONSULT_RETURN_CALL_SUCCESS)A.status==="success"?(P.updateConsultIsAnswer(!1),ge.emit(oe.CONSULT_RETURN_CALL_SUCCESS),P.updateDisplayText(Ht.CALLING),ge.emit(oe.OTHER_SIDE_CONSULT_HANGUP),P.updateActionConfigs(Vi)):ge.emit(Ge.FAIL_NOTIFICATION,"媒体失败");else if(o===rt.MUTE)a===0?(P.updateIsMuted(!0),ge.emit(oe.MUTE_SUCCESS),P.updateDisplayText(Ht.MUTING)):(ge.emit(oe.MUTE_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.UNMUTE)a===0?(P.updateIsMuted(!1),ge.emit(oe.UNMUTE_SUCCESS),P.updateDisplayText(Ht.CALLING)):(ge.emit(oe.UNMUTE_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CALL_HOLD)a===0?(P.updateIsHold(!0),P.updateDisplayText(Ht.HOLDING),ge.emit(oe.HOLD_SUCCESS)):(ge.emit(oe.HOLD_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CALL_UNHOLD)a===0?(P.updateDisplayText(Ht.CALLING),P.updateIsHold(!1),ge.emit(oe.UNHOLD_SUCCESS)):(ge.emit(oe.UNHOLD_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CONSULT_TRANSFER)a===0?ge.emit(oe.CONSULT_TRANSFER_SUCCESS):(ge.emit(oe.CONSULT_TRANSFER_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CONSULT_TRANSFER_FAILED)ge.emit(oe.CONSULT_TRANSFER_FAILED,A.status);else if(o===rt.CONSULT_TRANSFER_OFF_HOOK)P.updateDirection(yn.INCOMING),P.updateDisplayText(Ht.CALLING),ge.emit(oe.CONSULT_TRANSFER_OFF_HOOK),P.updateActionConfigs(Ui),P.updateIncomingIsAnswer(!0),P.updateConsultIsAnswer(!1);else if(o===rt.INCOMING_CALL){clearTimeout(_.autoStateTimer),_.sessionId=A.session_id;try{await this.getCustomerInfo(A.trace_id||A.customer_phone)}catch(d){console.error(d)}P.updateIsCalling(!0),P.updateDirection(yn.INCOMING),P.updateDisplayText(Ht.INCOMING_CALL),this.inCallAutoAnswer(),A.direction===1&&ge.emit(oe.INCOMING_CALL,{customer_phone:A.customer_phone,trace_id:A.trace_id,session_id:A.session_id}),A.direction===8&&ge.emit(oe.INCOMING_CALL_IN,{customer_phone:A.customer_phone,trace_id:A.trace_id,session_id:A.session_id}),A.direction===3&&ge.emit(oe.PREDICT_INCOMING_CALL,{customer_phone:A.customer_phone,trace_id:A.trace_id,session_id:A.session_id}),A.direction===6&&ge.emit(oe.DUAL_CALL_INCOMING_CALL,{customer_phone:A.customer_phone,trace_id:A.trace_id,session_id:A.session_id}),P.updateActionConfigs(wa),_.enableBrowserAlert&&So.show("📞 客户来电",`客户 [${A.customer_phone}] 正在呼入...`,()=>{ge.emit(Ge.NOTIFICATION_CLICK,{customer_phone:A.customer_phone})},_.browserAlertTime)}else if(o===rt.INCOMING_CALL_OFF_HOOK)P.updateIncomingIsAnswer(!0),A.direction===8?(P.updateActionConfigs(Yl),ge.emit(oe.INCOMING_CALL_IN_OFF_HOOK,{session_id:_.sessionId})):(P.updateActionConfigs(Ui),ge.emit(oe.INCOMING_CALL_OFF_HOOK,{session_id:_.sessionId})),P.updateDisplayText(Ht.CALLING);else if(o===rt.INCOMING_CALL_END){if(_.sessionId!==A.session_id)return;if(P.updateDisplayText(""),A.device_type!==1&&A.device_type!==7||A.agent_no!==_.agentInfo.agent_no)if(A.device_type===2&&A.agent_no===_.agentInfo.agent_no)P.reset(),ge.emit(oe.OUR_SIDE_CONSULT_HANGUP,{session_id:A.session_id}),this.putAgentState(!0),P.updateActionConfigs(Ln);else if(A.device_type===2&&A.agent_no!==_.agentInfo.agent_no)P.updateDisplayText(Ht.CALLING),ge.emit(oe.OTHER_SIDE_CONSULT_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Vi);else if(A.device_type===3&&A.agent_no===_.agentInfo.agent_no)this.putAgentState(!0),P.reset(),ge.emit(oe.THREE_WAY_OUR_SIDE_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln);else if(A.device_type===4&&A.agent_no===_.agentInfo.agent_no)this.putAgentState(!0),P.reset(),ge.emit(oe.TRANSFER_END,{session_id:A.session_id}),P.updateActionConfigs(Ln);else if(A.device_type===4&&A.agent_no!==_.agentInfo.agent_no){ge.emit(oe.TRANSFER_FAILED,"未知原因"),ge.emit(Ge.FAIL_NOTIFICATION,"转接失败");const d=P.get("direction");d===yn.OUTGOING?P.updateActionConfigs(Vi):d===yn.INCOMING&&P.updateActionConfigs(Ui)}else A.device_type===5&&A.agent_no===_.agentInfo.agent_no&&(this.putAgentState(!0,5),_.monitoredAgentNo="",_.earSpeakAgent="",P.reset(),ge.emit(oe.LISTEN_HANGUP,{session_id:A.session_id}),P.updateActionConfigs(Ln));else this.putAgentState(!0),P.reset(),ge.emit(oe.INCOMING_CALL_END,{session_id:A.session_id}),P.updateActionConfigs(Ln)}else if(o===rt.SATISFACTION_EVALUATION)a===0?ge.emit(oe.SATISFACTION_EVALUATION_SUCCESS):(ge.emit(oe.SATISFACTION_EVALUATION_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s));else if(o===rt.CONSULT_THREE_WAY)a!==0?(ge.emit(oe.CONSULT_THREE_WAY_FAILED,s),ge.emit(Ge.FAIL_NOTIFICATION,s)):a===0&&P.updateIsMeeting(!0);else if(o===rt.CONSULT_THREE_WAY_RESULT)A.status==="success"?(P.updateDirection(yn.MEETING),P.updateDisplayText(Ht.MEETING),P.updateActionConfigs(Ow),ge.emit(oe.CONSULT_THREE_WAY_SUCCESS)):(ge.emit(oe.CONSULT_THREE_WAY_FAILED,{conf_name:A.conf_name}),P.updateIsMeeting(!1));else if(o===rt.TRANSFER_INCOMING_CALL)clearTimeout(_.autoStateTimer),A.agent_no===_.agentInfo.agent_no?(P.updateDisplayText(Ht.TRANSFERRING),ge.emit(oe.TRANSFER_PROGRESS),P.updateActionConfigs([]),P.updateTransferIsAnswer(!0)):(_.sessionId=A.session_id,ge.emit(oe.TRANSFER_INCOMING_CALL,{agent_no:A.agent_no,agent_name:A.agent_name,session_id:A.session_id}),P.updateIsCalling(!0),P.updateDirection(yn.TRANSFER),P.updateDisplayText(Ht.TRANSFER_INCOMING_CALL),P.updateActionConfigs(wa),_.enableBrowserAlert&&So.show("📞 转接来电",`坐席 [${A.agent_no}] 正在转接...`,()=>{ge.emit(Ge.NOTIFICATION_CLICK,{agent_no:A.agent_no})},_.browserAlertTime));else if(o===rt.TRANSFER_OFF_HOOK)ge.emit(oe.TRANSFER_OFF_HOOK,{session_id:_.sessionId}),P.updateTransferIsAnswer(!1),P.updateDisplayText(Ht.CALLING),P.updateActionConfigs(Ui,A.direction!==8);else if(o===rt.TRANSFER_FAILED){if(A.status==="failed"){ge.emit(oe.TRANSFER_FAILED,"未知原因"),ge.emit(Ge.FAIL_NOTIFICATION,"转接失败");const d=P.get("direction");d===yn.OUTGOING?P.updateActionConfigs(Vi):d===yn.INCOMING&&P.updateActionConfigs(Ui)}}else o===rt.KICK_OFFLINE?ge.emit(Ge.KICK_OFF):o===rt.CONTINUOUS_NOT_ANSWER?(ge.emit(Ge.FAIL_NOTIFICATION,`已连续 ${A.miss_count} 次未接, 设置忙碌`),this.stateBusyChange()):o===rt.SIGN_OUT?ge.emit(Ge.SIGN_OUT):o===rt.SIGN_IN_SWITCH_DEVICE?ge.emit(Ge.SIGN_IN_SWITCH_DEVICE,A):o===rt.LISTEN_INCOMING_CALL?(clearTimeout(_.autoStateTimer),_.sessionId=A.session_id,P.updateIsCalling(!0),P.updateDirection(yn.INCOMING),this.inCallAutoAnswer(),P.updateDisplayText(Ht.LISTENING),P.updateActionConfigs(wa),ge.emit(oe.LISTEN_INCOMING_CALL,{session_id:A.session_id}),_.enableBrowserAlert&&So.show("📞 监听来电","正在来电...",()=>{ge.emit(Ge.NOTIFICATION_CLICK,{customer_phone:A.customer_phone})},_.browserAlertTime)):o===rt.LISTEN_INCOMING_CALL_OFF_HOOK?(_.monitoredAgentNo=A.monitored_agent_no,_.earSpeakAgent="",P.updateIncomingIsAnswer(!0),ge.emit(oe.LISTEN_INCOMING_CALL_OFF_HOOK,{session_id:_.sessionId,monitored_agent_no:A.monitored_agent_no}),P.updateActionConfigs(kf),P.updateDisplayText(Ht.CALLING)):o===rt.LISTEN_CALL_FAILED?A.status==="failed"&&(ge.emit(oe.LISTEN_CALL_FAILED),_.monitoredAgentNo=""):o===rt.EAR_SPEECH?A.status==="success"?(A.monitored_agent_no===_.agentInfo.agent_no&&(P.updateActionConfigs(Dw),ge.emit(oe.EAR_SPEECH_BE_SUCCESS)),A.monitor_agent_no===_.agentInfo.agent_no&&(P.updateActionConfigs(Nw),ge.emit(oe.EAR_SPEECH_SUCCESS,{monitored_agent_no:A.monitored_agent_no,monitor_agent_no:A.monitor_agent_no}),_.earSpeakAgent=A.monitored_agent_no)):ge.emit(oe.EAR_SPEECH_FAILED):o===rt.STOP_EAR_SPEECH?A.status==="success"?(A.monitored_agent_no===_.agentInfo.agent_no&&P.updateActionConfigs(Ui),A.monitor_agent_no===_.agentInfo.agent_no&&P.updateActionConfigs(kf),_.earSpeakAgent="",ge.emit(oe.STOP_EAR_SPEECH_SUCCESS)):ge.emit(oe.STOP_EAR_SPEECH_FAILED):o===rt.CALL_FORCE_INSERT?A.status==="success"?(A.monitored_agent_no===_.agentInfo.agent_no&&(P.updateActionConfigs(Qw),ge.emit(oe.CALL_FORCE_INSERT_SUCCESS,{monitored_agent_no:A.monitored_agent_no,monitor_agent_no:A.monitor_agent_no})),A.monitor_agent_no===_.agentInfo.agent_no&&(P.updateActionConfigs(Fw),ge.emit(oe.CALL_FORCE_INSERT_SUCCESS_LISTENER,{monitored_agent_no:A.monitored_agent_no,monitor_agent_no:A.monitor_agent_no}))):ge.emit(oe.CALL_FORCE_INSERT_FAILED):o===rt.INTERNAL_CALL_START_CONSULT?A.agent_no===_.agentInfo.agent_no?(P.updateConsultIsAnswer(!0),P.updateActionConfigs(Qf),P.updateDisplayText(Ht.CONSULTING)):(P.updateDisplayText(Ht.OTHER_SIDE_CONSULTING),P.updateActionConfigs([])):o===rt.INTERNAL_CALL_END_CONSULT?(P.updateActionConfigs(Yl),P.updateDisplayText(""),P.updateConsultIsAnswer(!1)):o===rt.CALL_SIP_INCOMING_CALL&&ge.emit(oe.CALL_SIP_INCOMING_CALL)},this.ws.onclose=r=>{ge.emit(Ge.FAIL_NOTIFICATION,"链接已断开,请检查网络"),this.stopHeartbeat();const i=P.get("isNextState");!this.manualClose&&i&&setTimeout(()=>this.initWebSocket(),this.reconnectDelay)},this.ws.onerror=r=>{var i;ge.emit(Ge.FAIL_NOTIFICATION,"连接失败,请检查网络"),(i=this.ws)==null||i.close()}}startHeartbeat(){const e=new Blob([`
164
164
  let timer;
165
165
  self.onmessage = function (e) {
166
166
  if (e.data === 'start') {
@@ -171,7 +171,7 @@ React keys must be passed directly to JSX without using spread:
171
171
  clearInterval(timer);
172
172
  }
173
173
  };
174
- `],{type:"application/javascript"}),n=URL.createObjectURL(e);this.heartbeatWorker=new Worker(n),this.heartbeatWorker.onmessage=()=>{const r=new Date().getTime();this.sendMessage({type:0,msg_id:r}),this.pendingMessages.set(r,performance.now())},this.heartbeatWorker.postMessage("start")}stopHeartbeat(){this.heartbeatWorker&&(this.heartbeatWorker.postMessage("stop"),this.heartbeatWorker.terminate(),this.heartbeatWorker=null)}sendMessage(e){var n;((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN?(this.ws.send(JSON.stringify(e)),e.type!==0&&Uf("%cWebSocket 发送消息:","color: green; font-weight: bold;",e)):console.warn("WebSocket 未连接,消息未发送")}close(){var e;this.manualClose=!0,this.stopHeartbeat(),(e=this.ws)==null||e.close()}reconnect(){this.initWebSocket()}static __internalClose(){ti&&(ti.close(),ti=null)}static __internalSend(e){if(!ti)throw new Error("WebSocket 尚未初始化");ti.sendMessage(e)}}class Uw{constructor(e){this.sipClient=null,this.sipClient=e}roleMute(){const e=P.get("isCalling"),n=_.sessionId;if(!e)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));if(!n)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}))}holdCall(){this.roleMute();const e=P.get("isHold"),{sessionId:n}=_;if(n){if(!P.get("actionConfigs").includes("hold"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿保持"}));if(e)throw new Error(JSON.stringify({code:1,msg:"当前已处于保持状态"}));ln.__internalSend({type:rt.CALL_HOLD,data:{session_id:n}})}}unholdCall(){this.roleMute();const{isHold:e}=P.getState(),{sessionId:n}=_;if(!P.get("actionConfigs").includes("unhold"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿取消保持"}));if(n){if(!e)throw new Error(JSON.stringify({code:1,msg:"当前未处于保持状态"}));ln.__internalSend({type:rt.CALL_UNHOLD,data:{session_id:n}})}}sendDTMF(e){if(P.get("answerDevice")!==1)throw new Error(JSON.stringify({code:1,msg:"当前设备不支持此功能"}));if(!P.get("actionConfigs").includes("dtmf"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿发送按键"}));const{isCalling:n}=P.getState();if(!n)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));this.sipClient.sendDTMF(e)}cancelCall(){if(!P.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));const e=_.sessionId;ge.emit(oe.REJECT,{session_id:e}),ln.__internalSend({type:rt.AGENT_HANGUP,data:{session_id:e}})}async consultCall(e){this.roleMute();const{isCalling:n,outCallIsAnswer:r,consultIsAnswer:i,incomingIsAnswer:o}=P.getState(),A=_.sessionId;if(!P.get("actionConfigs").includes("consult"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用咨询"}));if(i)throw new Error(JSON.stringify({code:1,msg:"当前正在咨询"}));if(!(n||r||o))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));if(!A)throw new Error(JSON.stringify({code:1,msg:"sessionId不存在"}));ln.__internalSend({type:rt.CONSULT_REQUEST,data:{session_id:A,consultation_agent_no:e}})}async answerCall(){if(P.get("answerDevice")!==1)throw new Error(JSON.stringify({code:1,msg:"当前设备不支持此功能"}));await this.sipClient.answerCall()}makeCall(e){if(typeof e!="string"||e.trim()==="")throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));const n={};eu(e)?n.trace_id=e:n.customer_phone=e.replace(/[\s\r\n-]+/g,"");const r=P.get("isCalling"),i=P.get("selectOutNumber")||"";if(r)throw new Error(JSON.stringify({code:1,msg:"正在呼叫中,请勿重复点击"}));P.updateIsCalling(!0),P.updateDirection(yn.OUTGOING),ln.__internalSend({type:rt.OUT_CALL,data:{...n,caller:i.replace(/[\s\r\n-]+/g,"")}})}previewCall(e,n){const r={};eu(e)?r.trace_id=e:r.customer_phone=e.replace(/[\s\r\n-]+/g,"");const i=P.get("isCalling"),o=P.get("selectOutNumber")||"";if(i)throw new Error(JSON.stringify({code:1,msg:"正在呼叫中,请勿重复点击"}));if(typeof e!="string"||e.trim()==="")throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));P.updateIsCalling(!0),P.updateDirection(yn.OUTGOING),ln.__internalSend({type:rt.PREVIEW_OUT_CALL,data:{...r,caller:o,preview_task_id:n}})}async hangup(){if(!P.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));const e=_.sessionId;ln.__internalSend({type:rt.AGENT_HANGUP,data:{session_id:e}})}mute(){this.roleMute();const e=P.get("actionConfigs"),n=P.get("isMuted"),r=_.sessionId;if(n)throw new Error(JSON.stringify({code:1,msg:"当前未处于静音状态"}));if(!e.includes("mute"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用静音"}));ln.__internalSend({type:rt.MUTE,data:{session_id:r}})}unmute(){this.roleMute();const e=P.get("actionConfigs"),n=P.get("isMuted"),r=_.sessionId;if(!n)throw new Error(JSON.stringify({code:1,msg:"当前未处于未静音状态"}));if(!e.includes("unmute"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用静音"}));ln.__internalSend({type:rt.UNMUTE,data:{session_id:r}})}consultTransfer(){this.roleMute();const e=P.get("consultIsAnswer"),n=_.sessionId;if(!P.get("actionConfigs").includes("consult_transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用咨询转移"}));if(!e)throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));ln.__internalSend({type:rt.CONSULT_TRANSFER,data:{session_id:n}})}satisfactionEvaluation(){this.roleMute();const e=_.sessionId;if(!P.get("actionConfigs").includes("satisfaction"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用满意度评价"}));ln.__internalSend({type:rt.SATISFACTION_EVALUATION,data:{session_id:e}})}startConference(){if(this.roleMute(),!P.get("actionConfigs").includes("conference"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用三方会议"}));const e=_.sessionId;if(!P.get("consultIsAnswer"))throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));ln.__internalSend({type:rt.CONSULT_THREE_WAY,data:{session_id:e}})}consultRetrieve(){if(this.roleMute(),!P.get("actionConfigs").includes("consult_retrieve"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿取回通话"}));const e=_.sessionId;if(!P.get("consultIsAnswer"))throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));ln.__internalSend({type:rt.CONSULT_RETURN_CALL,data:{session_id:e}})}async transferAgent(e){if(this.roleMute(),!P.get("actionConfigs").includes("transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿转接"}));const{transferIsAnswer:n}=P.getState(),r=_.sessionId;if(n)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));ln.__internalSend({type:rt.TRANSFER,data:{session_id:r,transfer_type:0,transfer_dest:e}})}async transferOutline(e){if(this.roleMute(),!P.get("actionConfigs").includes("transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿转接"}));if(!e)throw new Error(JSON.stringify({code:1,msg:"号码不能为空"}));if(!/^\d+$/.test(e))throw new Error(JSON.stringify({code:1,msg:"号码格式错误"}));const{transferIsAnswer:n}=P.getState(),r=_.sessionId;if(n)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));if(n)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));ln.__internalSend({type:rt.TRANSFER,data:{session_id:r,transfer_type:2,transfer_dest:e}})}}var or,Yn,un,sn,zi,GA,jA,Ji,PA,LA,Di,D0,N0,YA,F0;const Ts=class Ts{constructor(){fr(this,Di);fr(this,Yn);fr(this,un);fr(this,sn);fr(this,zi);fr(this,GA);fr(this,jA);fr(this,Ji);fr(this,PA);fr(this,LA);fr(this,YA);if(On(this,Yn,null),On(this,un,new OA),On(this,zi,null),On(this,Ji,!1),On(this,PA,()=>{}),On(this,LA,()=>{}),this.initWebRtc=async()=>{if(ut(this,Yn))return;const e=_.agentInfo.sip_account_list.find(n=>n.device_type===1);if(!e)throw new Error(JSON.stringify({code:1,msg:"未找到 sip_account_list"}));{const n=e.sip_register_addr;On(this,Yn,new fw({server:n.split(":")[0],user:e.sip_account,password:e.sip_password,webSocket:`wss://${n}`,callTimeout:3e4},ut(this,YA))),await ut(this,Yn).start()}},On(this,YA,e=>{const{type:n,data:r}=e;ge.emit(n,r)}),!or._creatingInstance)throw new Error("请使用 YSYTAgentSdk.getInstance() 获取实例");clearInterval(ut(this,zi)),On(this,zi,setInterval(async()=>{const e=await ua(this,Di,F0).call(this);I0.updateRttObject(e)},2e3)),So.requestMediaPermissions(),On(this,jA,P.subscribeKey("isNextState",async e=>{if(e){P.get("answerDevice")===1&&await ut(this,Yn).reconnect();let n="";const r=new URL(qo).host;n=qo.includes("https")?`wss://${r}`:`ws://${r}`;const{agent_no:i}=_.agentInfo;ln.getInstance({url:`${n}/ccs-ws/api/v1/ws/call/${i}?Authorization=`,sipClient:ut(this,Yn)}),setTimeout(()=>{ut(this,un)._changeState({data:{state:Rt.BUSY,state_name:"忙碌"},success:()=>{P.updateDisplayText(""),ge.emit(oe.AGENT_STATE,{state:Rt.BUSY,state_name:"忙碌"})}},"d")},10)}else ln.__internalClose(),P.updateDisplayText("离线")})),On(this,GA,P.subscribeKey("answerDevice",async e=>{e===1?_.stateObject.state===Rt.UNREGISTERED&&await ut(this,un)._changeState({data:{..._.stateBeforeChange,state_name:_.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},"qq"):await this.destroyRtc()})),this.on(Ge.KICK_OFF,()=>{this.destroy()}),window.addEventListener("beforeunload",e=>{e.returnValue="",this.destroy()}),window.addEventListener("online",ut(this,PA)),window.addEventListener("offline",ut(this,LA))}static get instance(){return this._instance}static async destroyInstance(){this._instance&&(await this._instance.destroy(),this._instance=null)}static getInstance(e){if(!this._instance){if(!e)throw new Error("首次调用必须传入配置参数");const{url:n,appKey:r,appSecret:i,agentNo:o}=e;qo=n||"https://aicc-api.yescloudy.com",jd=r,Pd=i,Ll=o,or._creatingInstance=!0,this._instance=new or,delete or._creatingInstance}return this._instance}getInit(){return ut(this,Ji)}async init({enableBrowserAlert:e,logBuiltinEnabled:n,browserAlertTime:r}){try{let i="";const o=new URL(qo).host;i=qo.includes("https")?`wss://${o}`:`ws://${o}`;const A=ln.getInstance({url:`${i}/ccs-ws/api/v1/ws/call/${Ll}?Authorization=`,sipClient:null,onOpen:async()=>{_.logBuiltinEnabled=n||!1,_.browserAlertTime=r||5e3,await ut(this,un)._agentLogin(Ll);const{current_answer_device:a,current_state:s,out_display_number:l,out_display_select_switch:u}=_.agentInfo;s===Rt.IDLE?(P.updateActionConfigs(Ln),_.stateObject={state:s,state_name:"空闲"},_.stateBeforeChange=_.stateObject):s===Rt.BUSY?(P.updateActionConfigs(cs),_.stateObject={state:s,state_name:"忙碌"},_.stateBeforeChange=_.stateObject):s===Rt.UNREGISTERED&&(P.updateActionConfigs(cs),_.stateObject={state:s,state_name:"未注册"}),u===1?P.updateSelectOutNumber(l):P.updateSelectOutNumber(""),P.updateAnswerDevice(a),OA.setInitRtcFn(this.initWebRtc),a===1&&(await this.initWebRtc(),A.setSipClient(ut(this,Yn))),On(this,sn,new Uw(ut(this,Yn))),_.enableBrowserAlert=e,e&&So.requestPermission(),ge.emit(Ge.AGENT_INIT_STATUS,!0),On(this,Ji,!0),clearInterval(or._timer),or._timer=null,ua(this,Di,N0).call(this)}})}catch{ge.emit(Ge.AGENT_INIT_STATUS,!1),On(this,Ji,!1)}}on(e,n){return ge.on(e,n),this}off(e,n){ge.off(e,n)}offAll(){ge.clearAllListeners()}async destroyRtc(){var e;await((e=ut(this,Yn))==null?void 0:e.destroy()),On(this,Yn,null)}async destroy(){var e,n;or._instance&&(await this.destroyRtc(),(e=ut(this,GA))==null||e.call(this),(n=ut(this,jA))==null||n.call(this),clearInterval(ut(this,zi)),ln.__internalClose(),ge.emit(Ge.DESTROY),this.offAll(),or._instance=null,P.reset(),P.updateSelectOutNumber(""),clearInterval(or._timer),or._timer=null)}get call_api(){const e=n=>(...r)=>n.apply(this,r);return{answerCall:e(()=>ut(this,sn).answerCall()),makeCall:n=>ut(this,sn).makeCall(n),previewMakeCall:(n,r)=>ut(this,sn).previewCall(n,r),cancelCall:e(()=>ut(this,sn).cancelCall()),hangup:e(()=>ut(this,sn).hangup()),sendDTMF:e(n=>ut(this,sn).sendDTMF(n)),holdCall:e(()=>ut(this,sn).holdCall()),unholdCall:e(()=>ut(this,sn).unholdCall()),consultCall:e(async n=>{try{await ut(this,sn).consultCall(n)}catch(r){throw console.warn(r),r}}),consultRetrieve:e(()=>ut(this,sn).consultRetrieve()),consultTransfer:e(()=>ut(this,sn).consultTransfer()),mute:e(()=>ut(this,sn).mute()),unmute:e(()=>ut(this,sn).unmute()),satisfactionEvaluation:e(()=>ut(this,sn).satisfactionEvaluation()),startConference:e(()=>ut(this,sn).startConference()),transferAgent:e(n=>ut(this,sn).transferAgent(n)),transferOutline:e(n=>ut(this,sn).transferOutline(n)),earSpeakStart:e(n=>ut(this,un).earCall(n)),earSpeakStop:e(n=>ut(this,un).stopEarCall(n)),forceInsert:e(n=>ut(this,un).forceInsert(n)),forceDisconnect:e(n=>ut(this,un).forceDisconnect(n))}}get agent_api(){const e=n=>(...r)=>n.apply(this,r);return{changeDevice:e(n=>ut(this,un).changeDevice(n)),changeState:e(n=>ut(this,un).changeState(n,"c")),getIdleAgentList:e(n=>ut(this,un).getIdleAgentList(n)),getAgentState:e(n=>ut(this,un).getAgentState(n)),setAgentExplicit:e(n=>ut(this,un).setAgentExplicit(n)),checkAgentLogin:n=>ut(this,un).checkAgentLogin(n),getCallRecord:n=>ut(this,un).getCallRecord(n),agentLogout:async(n,r)=>{try{await ut(this,un).logout(n),await this.destroy(),r==null||r({code:0,msg:""})}catch{}},listenAgentCall:n=>ut(this,un).listenCall(n)}}getAgentData(){const{agent_no:e,agent_name:n,answer_devices:r,out_display_data:i,out_display_select_switch:o,current_state:A}=_.agentInfo,{stateObject:a}=_,s={1:"软电话",2:"手机模式",3:"SIP话机"};return{agent_no:e,agent_name:n,init_state:A,default_device:P.get("answerDevice"),out_display_data:i,out_display_select_switch:o,answer_devices:(r||"").split(",").map(l=>({value:Number(l),label:s[Number(l)]})),stateObject:a}}async getRealTimeCustomerInfo(){return P.get("customerObject")}setBrowserAlert(e){if(typeof e!="boolean")throw new Error(JSON.stringify({code:1,msg:"参数类型错误"}));_.logBuiltinEnabled=e||!1}setBrowserAlertTime(e){if(typeof e!="number")throw new Error(JSON.stringify({code:1,msg:"参数类型错误"}));_.browserAlertTime=e||3e3}};Yn=new WeakMap,un=new WeakMap,sn=new WeakMap,zi=new WeakMap,GA=new WeakMap,jA=new WeakMap,Ji=new WeakMap,PA=new WeakMap,LA=new WeakMap,Di=new WeakSet,D0=async function(){const e=P.get("isNextState");try{await Rw(),e||P.updateIsNextState(!0)}catch{ge.emit(Ge.FAIL_NOTIFICATION,"网络断开,请检查网络"),e&&P.updateIsNextState(!1)}},N0=function(){or._timer||(or._timer=setInterval(()=>ua(this,Di,D0).call(this),3e3))},YA=new WeakMap,F0=async function(){return ut(this,Yn)?ut(this,Yn).getNetworkStats():{}},Ts._instance=null,Ts._timer=null;let Tn=Ts;or=Tn;var _n=function(){return _n=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},_n.apply(this,arguments)};function eo(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function Gw(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var jw=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Pw=Gw(function(t){return jw.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),_t="-ms-",mA="-moz-",jt="-webkit-",Q0="comm",js="rule",Ld="decl",Lw="@import",k0="@keyframes",Yw="@layer",U0=Math.abs,Yd=String.fromCharCode,tu=Object.assign;function Hw(t,e){return wn(t,0)^45?(((e<<2^wn(t,0))<<2^wn(t,1))<<2^wn(t,2))<<2^wn(t,3):0}function G0(t){return t.trim()}function ii(t,e){return(t=e.exec(t))?t[0]:t}function It(t,e,n){return t.replace(e,n)}function Za(t,e,n){return t.indexOf(e,n)}function wn(t,e){return t.charCodeAt(e)|0}function Qo(t,e,n){return t.slice(e,n)}function Hr(t){return t.length}function j0(t){return t.length}function dA(t,e){return e.push(t),t}function Kw(t,e){return t.map(e).join("")}function Gf(t,e){return t.filter(function(n){return!ii(n,e)})}var Ps=1,ko=1,P0=0,wr=0,gn=0,Ko="";function Ls(t,e,n,r,i,o,A,a){return{value:t,root:e,parent:n,type:r,props:i,children:o,line:Ps,column:ko,length:A,return:"",siblings:a}}function Ei(t,e){return tu(Ls("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},e)}function co(t){for(;t.root;)t=Ei(t.root,{children:[t]});dA(t,t.siblings)}function Zw(){return gn}function zw(){return gn=wr>0?wn(Ko,--wr):0,ko--,gn===10&&(ko=1,Ps--),gn}function Or(){return gn=wr<P0?wn(Ko,wr++):0,ko++,gn===10&&(ko=1,Ps++),gn}function Xi(){return wn(Ko,wr)}function za(){return wr}function Ys(t,e){return Qo(Ko,t,e)}function nu(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Jw(t){return Ps=ko=1,P0=Hr(Ko=t),wr=0,[]}function Ww(t){return Ko="",t}function Hl(t){return G0(Ys(wr-1,ru(t===91?t+2:t===40?t+1:t)))}function Xw(t){for(;(gn=Xi())&&gn<33;)Or();return nu(t)>2||nu(gn)>3?"":" "}function _w(t,e){for(;--e&&Or()&&!(gn<48||gn>102||gn>57&&gn<65||gn>70&&gn<97););return Ys(t,za()+(e<6&&Xi()==32&&Or()==32))}function ru(t){for(;Or();)switch(gn){case t:return wr;case 34:case 39:t!==34&&t!==39&&ru(gn);break;case 40:t===41&&ru(t);break;case 92:Or();break}return wr}function $w(t,e){for(;Or()&&t+gn!==57;)if(t+gn===84&&Xi()===47)break;return"/*"+Ys(e,wr-1)+"*"+Yd(t===47?t:Or())}function eS(t){for(;!nu(Xi());)Or();return Ys(t,wr)}function tS(t){return Ww(Ja("",null,null,null,[""],t=Jw(t),0,[0],t))}function Ja(t,e,n,r,i,o,A,a,s){for(var l=0,u=0,d=A,g=0,p=0,V=0,v=1,m=1,C=1,w=0,S="",M=i,I=o,f=r,R=S;m;)switch(V=w,w=Or()){case 40:if(V!=108&&wn(R,d-1)==58){Za(R+=It(Hl(w),"&","&\f"),"&\f",U0(l?a[l-1]:0))!=-1&&(C=-1);break}case 34:case 39:case 91:R+=Hl(w);break;case 9:case 10:case 13:case 32:R+=Xw(V);break;case 92:R+=_w(za()-1,7);continue;case 47:switch(Xi()){case 42:case 47:dA(nS($w(Or(),za()),e,n,s),s);break;default:R+="/"}break;case 123*v:a[l++]=Hr(R)*C;case 125*v:case 59:case 0:switch(w){case 0:case 125:m=0;case 59+u:C==-1&&(R=It(R,/\f/g,"")),p>0&&Hr(R)-d&&dA(p>32?Pf(R+";",r,n,d-1,s):Pf(It(R," ","")+";",r,n,d-2,s),s);break;case 59:R+=";";default:if(dA(f=jf(R,e,n,l,u,i,a,S,M=[],I=[],d,o),o),w===123)if(u===0)Ja(R,e,f,f,M,o,d,a,I);else switch(g===99&&wn(R,3)===110?100:g){case 100:case 108:case 109:case 115:Ja(t,f,f,r&&dA(jf(t,f,f,0,0,i,a,S,i,M=[],d,I),I),i,I,d,a,r?M:I);break;default:Ja(R,f,f,f,[""],I,0,a,I)}}l=u=p=0,v=C=1,S=R="",d=A;break;case 58:d=1+Hr(R),p=V;default:if(v<1){if(w==123)--v;else if(w==125&&v++==0&&zw()==125)continue}switch(R+=Yd(w),w*v){case 38:C=u>0?1:(R+="\f",-1);break;case 44:a[l++]=(Hr(R)-1)*C,C=1;break;case 64:Xi()===45&&(R+=Hl(Or())),g=Xi(),u=d=Hr(S=R+=eS(za())),w++;break;case 45:V===45&&Hr(R)==2&&(v=0)}}return o}function jf(t,e,n,r,i,o,A,a,s,l,u,d){for(var g=i-1,p=i===0?o:[""],V=j0(p),v=0,m=0,C=0;v<r;++v)for(var w=0,S=Qo(t,g+1,g=U0(m=A[v])),M=t;w<V;++w)(M=G0(m>0?p[w]+" "+S:It(S,/&\f/g,p[w])))&&(s[C++]=M);return Ls(t,e,n,i===0?js:a,s,l,u,d)}function nS(t,e,n,r){return Ls(t,e,n,Q0,Yd(Zw()),Qo(t,2,-2),0,r)}function Pf(t,e,n,r,i){return Ls(t,e,n,Ld,Qo(t,0,r),Qo(t,r+1,-1),r,i)}function L0(t,e,n){switch(Hw(t,e)){case 5103:return jt+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return jt+t+t;case 4789:return mA+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return jt+t+mA+t+_t+t+t;case 5936:switch(wn(t,e+11)){case 114:return jt+t+_t+It(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return jt+t+_t+It(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return jt+t+_t+It(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return jt+t+_t+t+t;case 6165:return jt+t+_t+"flex-"+t+t;case 5187:return jt+t+It(t,/(\w+).+(:[^]+)/,jt+"box-$1$2"+_t+"flex-$1$2")+t;case 5443:return jt+t+_t+"flex-item-"+It(t,/flex-|-self/g,"")+(ii(t,/flex-|baseline/)?"":_t+"grid-row-"+It(t,/flex-|-self/g,""))+t;case 4675:return jt+t+_t+"flex-line-pack"+It(t,/align-content|flex-|-self/g,"")+t;case 5548:return jt+t+_t+It(t,"shrink","negative")+t;case 5292:return jt+t+_t+It(t,"basis","preferred-size")+t;case 6060:return jt+"box-"+It(t,"-grow","")+jt+t+_t+It(t,"grow","positive")+t;case 4554:return jt+It(t,/([^-])(transform)/g,"$1"+jt+"$2")+t;case 6187:return It(It(It(t,/(zoom-|grab)/,jt+"$1"),/(image-set)/,jt+"$1"),t,"")+t;case 5495:case 3959:return It(t,/(image-set\([^]*)/,jt+"$1$`$1");case 4968:return It(It(t,/(.+:)(flex-)?(.*)/,jt+"box-pack:$3"+_t+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+jt+t+t;case 4200:if(!ii(t,/flex-|baseline/))return _t+"grid-column-align"+Qo(t,e)+t;break;case 2592:case 3360:return _t+It(t,"template-","")+t;case 4384:case 3616:return n&&n.some(function(r,i){return e=i,ii(r.props,/grid-\w+-end/)})?~Za(t+(n=n[e].value),"span",0)?t:_t+It(t,"-start","")+t+_t+"grid-row-span:"+(~Za(n,"span",0)?ii(n,/\d+/):+ii(n,/\d+/)-+ii(t,/\d+/))+";":_t+It(t,"-start","")+t;case 4896:case 4128:return n&&n.some(function(r){return ii(r.props,/grid-\w+-start/)})?t:_t+It(It(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return It(t,/(.+)-inline(.+)/,jt+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Hr(t)-1-e>6)switch(wn(t,e+1)){case 109:if(wn(t,e+4)!==45)break;case 102:return It(t,/(.+:)(.+)-([^]+)/,"$1"+jt+"$2-$3$1"+mA+(wn(t,e+3)==108?"$3":"$2-$3"))+t;case 115:return~Za(t,"stretch",0)?L0(It(t,"stretch","fill-available"),e,n)+t:t}break;case 5152:case 5920:return It(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(r,i,o,A,a,s,l){return _t+i+":"+o+l+(A?_t+i+"-span:"+(a?s:+s-+o)+l:"")+t});case 4949:if(wn(t,e+6)===121)return It(t,":",":"+jt)+t;break;case 6444:switch(wn(t,wn(t,14)===45?18:11)){case 120:return It(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+jt+(wn(t,14)===45?"inline-":"")+"box$3$1"+jt+"$2$3$1"+_t+"$2box$3")+t;case 100:return It(t,":",":"+_t)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return It(t,"scroll-","scroll-snap-")+t}return t}function us(t,e){for(var n="",r=0;r<t.length;r++)n+=e(t[r],r,t,e)||"";return n}function rS(t,e,n,r){switch(t.type){case Yw:if(t.children.length)break;case Lw:case Ld:return t.return=t.return||t.value;case Q0:return"";case k0:return t.return=t.value+"{"+us(t.children,r)+"}";case js:if(!Hr(t.value=t.props.join(",")))return""}return Hr(n=us(t.children,r))?t.return=t.value+"{"+n+"}":""}function iS(t){var e=j0(t);return function(n,r,i,o){for(var A="",a=0;a<e;a++)A+=t[a](n,r,i,o)||"";return A}}function oS(t){return function(e){e.root||(e=e.return)&&t(e)}}function AS(t,e,n,r){if(t.length>-1&&!t.return)switch(t.type){case Ld:t.return=L0(t.value,t.length,n);return;case k0:return us([Ei(t,{value:It(t.value,"@","@"+jt)})],r);case js:if(t.length)return Kw(n=t.props,function(i){switch(ii(i,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":co(Ei(t,{props:[It(i,/:(read-\w+)/,":"+mA+"$1")]})),co(Ei(t,{props:[i]})),tu(t,{props:Gf(n,r)});break;case"::placeholder":co(Ei(t,{props:[It(i,/:(plac\w+)/,":"+jt+"input-$1")]})),co(Ei(t,{props:[It(i,/:(plac\w+)/,":"+mA+"$1")]})),co(Ei(t,{props:[It(i,/:(plac\w+)/,_t+"input-$1")]})),co(Ei(t,{props:[i]})),tu(t,{props:Gf(n,r)});break}return""})}}var aS={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},to=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Y0="active",H0="data-styled-version",Hs="6.1.19",Hd=`/*!sc*/
174
+ `],{type:"application/javascript"}),n=URL.createObjectURL(e);this.heartbeatWorker=new Worker(n),this.heartbeatWorker.onmessage=()=>{const r=new Date().getTime();this.sendMessage({type:0,msg_id:r}),this.pendingMessages.set(r,performance.now())},this.heartbeatWorker.postMessage("start")}stopHeartbeat(){this.heartbeatWorker&&(this.heartbeatWorker.postMessage("stop"),this.heartbeatWorker.terminate(),this.heartbeatWorker=null)}sendMessage(e){var n;((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN?(this.ws.send(JSON.stringify(e)),e.type!==0&&Uf("%cWebSocket 发送消息:","color: green; font-weight: bold;",e)):console.warn("WebSocket 未连接,消息未发送")}close(){var e;this.manualClose=!0,this.stopHeartbeat(),(e=this.ws)==null||e.close()}reconnect(){this.initWebSocket()}static __internalClose(){ti&&(ti.close(),ti=null)}static __internalSend(e){if(!ti)throw new Error("WebSocket 尚未初始化");ti.sendMessage(e)}}class Uw{constructor(e){this.sipClient=null,this.sipClient=e}roleMute(){const e=P.get("isCalling"),n=_.sessionId;if(!e)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));if(!n)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}))}holdCall(){this.roleMute();const e=P.get("isHold"),{sessionId:n}=_;if(n){if(!P.get("actionConfigs").includes("hold"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿保持"}));if(e)throw new Error(JSON.stringify({code:1,msg:"当前已处于保持状态"}));ln.__internalSend({type:rt.CALL_HOLD,data:{session_id:n}})}}unholdCall(){this.roleMute();const{isHold:e}=P.getState(),{sessionId:n}=_;if(!P.get("actionConfigs").includes("unhold"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿取消保持"}));if(n){if(!e)throw new Error(JSON.stringify({code:1,msg:"当前未处于保持状态"}));ln.__internalSend({type:rt.CALL_UNHOLD,data:{session_id:n}})}}sendDTMF(e){if(P.get("answerDevice")!==1)throw new Error(JSON.stringify({code:1,msg:"当前设备不支持此功能"}));if(!P.get("actionConfigs").includes("dtmf"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿发送按键"}));const{isCalling:n}=P.getState();if(!n)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));this.sipClient.sendDTMF(e)}cancelCall(){if(!P.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));const e=_.sessionId;ge.emit(oe.REJECT,{session_id:e}),ln.__internalSend({type:rt.AGENT_HANGUP,data:{session_id:e}})}async consultCall(e){this.roleMute();const{isCalling:n,outCallIsAnswer:r,consultIsAnswer:i,incomingIsAnswer:o}=P.getState(),A=_.sessionId;if(!P.get("actionConfigs").includes("consult"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用咨询"}));if(i)throw new Error(JSON.stringify({code:1,msg:"当前正在咨询"}));if(!(n||r||o))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));if(!A)throw new Error(JSON.stringify({code:1,msg:"sessionId不存在"}));ln.__internalSend({type:rt.CONSULT_REQUEST,data:{session_id:A,consultation_agent_no:e}})}async answerCall(){if(P.get("answerDevice")!==1)throw new Error(JSON.stringify({code:1,msg:"当前设备不支持此功能"}));await this.sipClient.answerCall()}makeCall(e){if(typeof e!="string"||e.trim()==="")throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));const n={};eu(e)?n.trace_id=e:n.customer_phone=e.replace(/[\s\r\n-]+/g,"");const r=P.get("isCalling"),i=P.get("selectOutNumber")||"";if(r)throw new Error(JSON.stringify({code:1,msg:"正在呼叫中,请勿重复点击"}));P.updateIsCalling(!0),P.updateDirection(yn.OUTGOING),ln.__internalSend({type:rt.OUT_CALL,data:{...n,caller:i.replace(/[\s\r\n-]+/g,"")}})}previewCall(e,n){const r={};eu(e)?r.trace_id=e:r.customer_phone=e.replace(/[\s\r\n-]+/g,"");const i=P.get("isCalling"),o=P.get("selectOutNumber")||"";if(i)throw new Error(JSON.stringify({code:1,msg:"正在呼叫中,请勿重复点击"}));if(typeof e!="string"||e.trim()==="")throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));P.updateIsCalling(!0),P.updateDirection(yn.OUTGOING),ln.__internalSend({type:rt.PREVIEW_OUT_CALL,data:{...r,caller:o,preview_task_id:n}})}async hangup(){if(!P.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));const e=_.sessionId;ln.__internalSend({type:rt.AGENT_HANGUP,data:{session_id:e}})}mute(){this.roleMute();const e=P.get("actionConfigs"),n=P.get("isMuted"),r=_.sessionId;if(n)throw new Error(JSON.stringify({code:1,msg:"当前未处于静音状态"}));if(!e.includes("mute"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用静音"}));ln.__internalSend({type:rt.MUTE,data:{session_id:r}})}unmute(){this.roleMute();const e=P.get("actionConfigs"),n=P.get("isMuted"),r=_.sessionId;if(!n)throw new Error(JSON.stringify({code:1,msg:"当前未处于未静音状态"}));if(!e.includes("unmute"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用静音"}));ln.__internalSend({type:rt.UNMUTE,data:{session_id:r}})}consultTransfer(){this.roleMute();const e=P.get("consultIsAnswer"),n=_.sessionId;if(!P.get("actionConfigs").includes("consult_transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用咨询转移"}));if(!e)throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));ln.__internalSend({type:rt.CONSULT_TRANSFER,data:{session_id:n}})}satisfactionEvaluation(){this.roleMute();const e=_.sessionId;if(!P.get("actionConfigs").includes("satisfaction"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用满意度评价"}));ln.__internalSend({type:rt.SATISFACTION_EVALUATION,data:{session_id:e}})}startConference(){if(this.roleMute(),!P.get("actionConfigs").includes("conference"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用三方会议"}));const e=_.sessionId;if(!P.get("consultIsAnswer"))throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));ln.__internalSend({type:rt.CONSULT_THREE_WAY,data:{session_id:e}})}consultRetrieve(){if(this.roleMute(),!P.get("actionConfigs").includes("consult_retrieve"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿取回通话"}));const e=_.sessionId;if(!P.get("consultIsAnswer"))throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));ln.__internalSend({type:rt.CONSULT_RETURN_CALL,data:{session_id:e}})}async transferAgent(e){if(this.roleMute(),!P.get("actionConfigs").includes("transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿转接"}));const{transferIsAnswer:n}=P.getState(),r=_.sessionId;if(n)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));ln.__internalSend({type:rt.TRANSFER,data:{session_id:r,transfer_type:0,transfer_dest:e}})}async transferOutline(e){if(this.roleMute(),!P.get("actionConfigs").includes("transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿转接"}));if(!e)throw new Error(JSON.stringify({code:1,msg:"号码不能为空"}));if(!/^\d+$/.test(e))throw new Error(JSON.stringify({code:1,msg:"号码格式错误"}));const{transferIsAnswer:n}=P.getState(),r=_.sessionId;if(n)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));if(n)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));ln.__internalSend({type:rt.TRANSFER,data:{session_id:r,transfer_type:2,transfer_dest:e}})}}var or,Yn,un,sn,zi,GA,jA,Ji,PA,LA,Di,D0,N0,YA,F0;const Ts=class Ts{constructor(){fr(this,Di);fr(this,Yn);fr(this,un);fr(this,sn);fr(this,zi);fr(this,GA);fr(this,jA);fr(this,Ji);fr(this,PA);fr(this,LA);fr(this,YA);if(On(this,Yn,null),On(this,un,new OA),On(this,zi,null),On(this,Ji,!1),On(this,PA,()=>{}),On(this,LA,()=>{}),this.initWebRtc=async()=>{if(ut(this,Yn))return;const e=_.agentInfo.sip_account_list.find(n=>n.device_type===1);if(!e)throw new Error(JSON.stringify({code:1,msg:"未找到 sip_account_list"}));{const n=e.sip_register_addr;On(this,Yn,new fw({server:n.split(":")[0],user:e.sip_account,password:e.sip_password,webSocket:`wss://${n}`,callTimeout:3e4},ut(this,YA))),await ut(this,Yn).start()}},On(this,YA,e=>{const{type:n,data:r}=e;ge.emit(n,r)}),!or._creatingInstance)throw new Error("请使用 YSYTAgentSdk.getInstance() 获取实例");clearInterval(ut(this,zi)),On(this,zi,setInterval(async()=>{const e=await ua(this,Di,F0).call(this);I0.updateRttObject(e)},2e3)),So.requestMediaPermissions(),On(this,jA,P.subscribeKey("isNextState",async e=>{if(e){P.get("answerDevice")===1&&await ut(this,Yn).reconnect();let n="";const r=new URL(qo).host;n=qo.includes("https")?`wss://${r}`:`ws://${r}`;const{agent_no:i}=_.agentInfo;ln.getInstance({url:`${n}/ccs-ws/api/v1/ws/call/${i}?Authorization=`,sipClient:ut(this,Yn)}),setTimeout(()=>{ut(this,un)._changeState({data:{state:Rt.BUSY,state_name:"忙碌"},success:()=>{P.updateDisplayText(""),ge.emit(oe.AGENT_STATE,{state:Rt.BUSY,state_name:"忙碌"})}},"d")},10)}else ln.__internalClose(),P.updateIsCalling(!1),P.updateOutCallIsAnswer(!1),P.updateIncomingIsAnswer(!1),P.updateIsMuted(!1),P.updateConsultIsAnswer(!1),P.updateIsHold(!1),P.updateCustomerInfo(void 0),P.updateDisplayText("离线")})),On(this,GA,P.subscribeKey("answerDevice",async e=>{e===1?_.stateObject.state===Rt.UNREGISTERED&&await ut(this,un)._changeState({data:{..._.stateBeforeChange,state_name:_.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},"qq"):await this.destroyRtc()})),this.on(Ge.KICK_OFF,()=>{this.destroy()}),window.addEventListener("beforeunload",e=>{e.returnValue="",this.destroy()}),window.addEventListener("online",ut(this,PA)),window.addEventListener("offline",ut(this,LA))}static get instance(){return this._instance}static async destroyInstance(){this._instance&&(await this._instance.destroy(),this._instance=null)}static getInstance(e){if(!this._instance){if(!e)throw new Error("首次调用必须传入配置参数");const{url:n,appKey:r,appSecret:i,agentNo:o}=e;qo=n||"https://aicc-api.yescloudy.com",jd=r,Pd=i,Ll=o,or._creatingInstance=!0,this._instance=new or,delete or._creatingInstance}return this._instance}getInit(){return ut(this,Ji)}async init({enableBrowserAlert:e,logBuiltinEnabled:n,browserAlertTime:r}){try{let i="";const o=new URL(qo).host;i=qo.includes("https")?`wss://${o}`:`ws://${o}`;const A=ln.getInstance({url:`${i}/ccs-ws/api/v1/ws/call/${Ll}?Authorization=`,sipClient:null,onOpen:async()=>{_.logBuiltinEnabled=n||!1,_.browserAlertTime=r||5e3,await ut(this,un)._agentLogin(Ll);const{current_answer_device:a,current_state:s,out_display_number:l,out_display_select_switch:u}=_.agentInfo;s===Rt.IDLE?(P.updateActionConfigs(Ln),_.stateObject={state:s,state_name:"空闲"},_.stateBeforeChange=_.stateObject):s===Rt.BUSY?(P.updateActionConfigs(cs),_.stateObject={state:s,state_name:"忙碌"},_.stateBeforeChange=_.stateObject):s===Rt.UNREGISTERED&&(P.updateActionConfigs(cs),_.stateObject={state:s,state_name:"未注册"}),u===1?P.updateSelectOutNumber(l):P.updateSelectOutNumber(""),P.updateAnswerDevice(a),OA.setInitRtcFn(this.initWebRtc),a===1&&(await this.initWebRtc(),A.setSipClient(ut(this,Yn))),On(this,sn,new Uw(ut(this,Yn))),_.enableBrowserAlert=e,e&&So.requestPermission(),ge.emit(Ge.AGENT_INIT_STATUS,!0),On(this,Ji,!0),clearInterval(or._timer),or._timer=null,ua(this,Di,N0).call(this)}})}catch{ge.emit(Ge.AGENT_INIT_STATUS,!1),On(this,Ji,!1)}}on(e,n){return ge.on(e,n),this}off(e,n){ge.off(e,n)}offAll(){ge.clearAllListeners()}async destroyRtc(){var e;await((e=ut(this,Yn))==null?void 0:e.destroy()),On(this,Yn,null)}async destroy(){var e,n;or._instance&&(await this.destroyRtc(),(e=ut(this,GA))==null||e.call(this),(n=ut(this,jA))==null||n.call(this),clearInterval(ut(this,zi)),ln.__internalClose(),ge.emit(Ge.DESTROY),this.offAll(),or._instance=null,P.reset(),P.updateSelectOutNumber(""),clearInterval(or._timer),or._timer=null)}get call_api(){const e=n=>(...r)=>n.apply(this,r);return{answerCall:e(()=>ut(this,sn).answerCall()),makeCall:n=>ut(this,sn).makeCall(n),previewMakeCall:(n,r)=>ut(this,sn).previewCall(n,r),cancelCall:e(()=>ut(this,sn).cancelCall()),hangup:e(()=>ut(this,sn).hangup()),sendDTMF:e(n=>ut(this,sn).sendDTMF(n)),holdCall:e(()=>ut(this,sn).holdCall()),unholdCall:e(()=>ut(this,sn).unholdCall()),consultCall:e(async n=>{try{await ut(this,sn).consultCall(n)}catch(r){throw console.warn(r),r}}),consultRetrieve:e(()=>ut(this,sn).consultRetrieve()),consultTransfer:e(()=>ut(this,sn).consultTransfer()),mute:e(()=>ut(this,sn).mute()),unmute:e(()=>ut(this,sn).unmute()),satisfactionEvaluation:e(()=>ut(this,sn).satisfactionEvaluation()),startConference:e(()=>ut(this,sn).startConference()),transferAgent:e(n=>ut(this,sn).transferAgent(n)),transferOutline:e(n=>ut(this,sn).transferOutline(n)),earSpeakStart:e(n=>ut(this,un).earCall(n)),earSpeakStop:e(n=>ut(this,un).stopEarCall(n)),forceInsert:e(n=>ut(this,un).forceInsert(n)),forceDisconnect:e(n=>ut(this,un).forceDisconnect(n))}}get agent_api(){const e=n=>(...r)=>n.apply(this,r);return{changeDevice:e(n=>ut(this,un).changeDevice(n)),changeState:e(n=>ut(this,un).changeState(n,"c")),getIdleAgentList:e(n=>ut(this,un).getIdleAgentList(n)),getAgentState:e(n=>ut(this,un).getAgentState(n)),setAgentExplicit:e(n=>ut(this,un).setAgentExplicit(n)),checkAgentLogin:n=>ut(this,un).checkAgentLogin(n),getCallRecord:n=>ut(this,un).getCallRecord(n),agentLogout:async(n,r)=>{try{await ut(this,un).logout(n),await this.destroy(),r==null||r({code:0,msg:""})}catch{}},listenAgentCall:n=>ut(this,un).listenCall(n)}}getAgentData(){const{agent_no:e,agent_name:n,answer_devices:r,out_display_data:i,out_display_select_switch:o,current_state:A}=_.agentInfo,{stateObject:a}=_,s={1:"软电话",2:"手机模式",3:"SIP话机"};return{agent_no:e,agent_name:n,init_state:A,default_device:P.get("answerDevice"),out_display_data:i,out_display_select_switch:o,answer_devices:(r||"").split(",").map(l=>({value:Number(l),label:s[Number(l)]})),stateObject:a}}async getRealTimeCustomerInfo(){return P.get("customerObject")}setBrowserAlert(e){if(typeof e!="boolean")throw new Error(JSON.stringify({code:1,msg:"参数类型错误"}));_.logBuiltinEnabled=e||!1}setBrowserAlertTime(e){if(typeof e!="number")throw new Error(JSON.stringify({code:1,msg:"参数类型错误"}));_.browserAlertTime=e||3e3}};Yn=new WeakMap,un=new WeakMap,sn=new WeakMap,zi=new WeakMap,GA=new WeakMap,jA=new WeakMap,Ji=new WeakMap,PA=new WeakMap,LA=new WeakMap,Di=new WeakSet,D0=async function(){const e=P.get("isNextState");try{await Rw(),e||P.updateIsNextState(!0)}catch{ge.emit(Ge.FAIL_NOTIFICATION,"网络断开,请检查网络"),e&&P.updateIsNextState(!1)}},N0=function(){or._timer||(or._timer=setInterval(()=>ua(this,Di,D0).call(this),3e3))},YA=new WeakMap,F0=async function(){return ut(this,Yn)?ut(this,Yn).getNetworkStats():{}},Ts._instance=null,Ts._timer=null;let Tn=Ts;or=Tn;var _n=function(){return _n=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},_n.apply(this,arguments)};function eo(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function Gw(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var jw=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Pw=Gw(function(t){return jw.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),_t="-ms-",mA="-moz-",jt="-webkit-",Q0="comm",js="rule",Ld="decl",Lw="@import",k0="@keyframes",Yw="@layer",U0=Math.abs,Yd=String.fromCharCode,tu=Object.assign;function Hw(t,e){return wn(t,0)^45?(((e<<2^wn(t,0))<<2^wn(t,1))<<2^wn(t,2))<<2^wn(t,3):0}function G0(t){return t.trim()}function ii(t,e){return(t=e.exec(t))?t[0]:t}function It(t,e,n){return t.replace(e,n)}function Za(t,e,n){return t.indexOf(e,n)}function wn(t,e){return t.charCodeAt(e)|0}function Qo(t,e,n){return t.slice(e,n)}function Hr(t){return t.length}function j0(t){return t.length}function dA(t,e){return e.push(t),t}function Kw(t,e){return t.map(e).join("")}function Gf(t,e){return t.filter(function(n){return!ii(n,e)})}var Ps=1,ko=1,P0=0,wr=0,gn=0,Ko="";function Ls(t,e,n,r,i,o,A,a){return{value:t,root:e,parent:n,type:r,props:i,children:o,line:Ps,column:ko,length:A,return:"",siblings:a}}function Ei(t,e){return tu(Ls("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},e)}function co(t){for(;t.root;)t=Ei(t.root,{children:[t]});dA(t,t.siblings)}function Zw(){return gn}function zw(){return gn=wr>0?wn(Ko,--wr):0,ko--,gn===10&&(ko=1,Ps--),gn}function Or(){return gn=wr<P0?wn(Ko,wr++):0,ko++,gn===10&&(ko=1,Ps++),gn}function Xi(){return wn(Ko,wr)}function za(){return wr}function Ys(t,e){return Qo(Ko,t,e)}function nu(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Jw(t){return Ps=ko=1,P0=Hr(Ko=t),wr=0,[]}function Ww(t){return Ko="",t}function Hl(t){return G0(Ys(wr-1,ru(t===91?t+2:t===40?t+1:t)))}function Xw(t){for(;(gn=Xi())&&gn<33;)Or();return nu(t)>2||nu(gn)>3?"":" "}function _w(t,e){for(;--e&&Or()&&!(gn<48||gn>102||gn>57&&gn<65||gn>70&&gn<97););return Ys(t,za()+(e<6&&Xi()==32&&Or()==32))}function ru(t){for(;Or();)switch(gn){case t:return wr;case 34:case 39:t!==34&&t!==39&&ru(gn);break;case 40:t===41&&ru(t);break;case 92:Or();break}return wr}function $w(t,e){for(;Or()&&t+gn!==57;)if(t+gn===84&&Xi()===47)break;return"/*"+Ys(e,wr-1)+"*"+Yd(t===47?t:Or())}function eS(t){for(;!nu(Xi());)Or();return Ys(t,wr)}function tS(t){return Ww(Ja("",null,null,null,[""],t=Jw(t),0,[0],t))}function Ja(t,e,n,r,i,o,A,a,s){for(var l=0,u=0,d=A,g=0,p=0,V=0,v=1,m=1,C=1,w=0,S="",M=i,I=o,f=r,R=S;m;)switch(V=w,w=Or()){case 40:if(V!=108&&wn(R,d-1)==58){Za(R+=It(Hl(w),"&","&\f"),"&\f",U0(l?a[l-1]:0))!=-1&&(C=-1);break}case 34:case 39:case 91:R+=Hl(w);break;case 9:case 10:case 13:case 32:R+=Xw(V);break;case 92:R+=_w(za()-1,7);continue;case 47:switch(Xi()){case 42:case 47:dA(nS($w(Or(),za()),e,n,s),s);break;default:R+="/"}break;case 123*v:a[l++]=Hr(R)*C;case 125*v:case 59:case 0:switch(w){case 0:case 125:m=0;case 59+u:C==-1&&(R=It(R,/\f/g,"")),p>0&&Hr(R)-d&&dA(p>32?Pf(R+";",r,n,d-1,s):Pf(It(R," ","")+";",r,n,d-2,s),s);break;case 59:R+=";";default:if(dA(f=jf(R,e,n,l,u,i,a,S,M=[],I=[],d,o),o),w===123)if(u===0)Ja(R,e,f,f,M,o,d,a,I);else switch(g===99&&wn(R,3)===110?100:g){case 100:case 108:case 109:case 115:Ja(t,f,f,r&&dA(jf(t,f,f,0,0,i,a,S,i,M=[],d,I),I),i,I,d,a,r?M:I);break;default:Ja(R,f,f,f,[""],I,0,a,I)}}l=u=p=0,v=C=1,S=R="",d=A;break;case 58:d=1+Hr(R),p=V;default:if(v<1){if(w==123)--v;else if(w==125&&v++==0&&zw()==125)continue}switch(R+=Yd(w),w*v){case 38:C=u>0?1:(R+="\f",-1);break;case 44:a[l++]=(Hr(R)-1)*C,C=1;break;case 64:Xi()===45&&(R+=Hl(Or())),g=Xi(),u=d=Hr(S=R+=eS(za())),w++;break;case 45:V===45&&Hr(R)==2&&(v=0)}}return o}function jf(t,e,n,r,i,o,A,a,s,l,u,d){for(var g=i-1,p=i===0?o:[""],V=j0(p),v=0,m=0,C=0;v<r;++v)for(var w=0,S=Qo(t,g+1,g=U0(m=A[v])),M=t;w<V;++w)(M=G0(m>0?p[w]+" "+S:It(S,/&\f/g,p[w])))&&(s[C++]=M);return Ls(t,e,n,i===0?js:a,s,l,u,d)}function nS(t,e,n,r){return Ls(t,e,n,Q0,Yd(Zw()),Qo(t,2,-2),0,r)}function Pf(t,e,n,r,i){return Ls(t,e,n,Ld,Qo(t,0,r),Qo(t,r+1,-1),r,i)}function L0(t,e,n){switch(Hw(t,e)){case 5103:return jt+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return jt+t+t;case 4789:return mA+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return jt+t+mA+t+_t+t+t;case 5936:switch(wn(t,e+11)){case 114:return jt+t+_t+It(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return jt+t+_t+It(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return jt+t+_t+It(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return jt+t+_t+t+t;case 6165:return jt+t+_t+"flex-"+t+t;case 5187:return jt+t+It(t,/(\w+).+(:[^]+)/,jt+"box-$1$2"+_t+"flex-$1$2")+t;case 5443:return jt+t+_t+"flex-item-"+It(t,/flex-|-self/g,"")+(ii(t,/flex-|baseline/)?"":_t+"grid-row-"+It(t,/flex-|-self/g,""))+t;case 4675:return jt+t+_t+"flex-line-pack"+It(t,/align-content|flex-|-self/g,"")+t;case 5548:return jt+t+_t+It(t,"shrink","negative")+t;case 5292:return jt+t+_t+It(t,"basis","preferred-size")+t;case 6060:return jt+"box-"+It(t,"-grow","")+jt+t+_t+It(t,"grow","positive")+t;case 4554:return jt+It(t,/([^-])(transform)/g,"$1"+jt+"$2")+t;case 6187:return It(It(It(t,/(zoom-|grab)/,jt+"$1"),/(image-set)/,jt+"$1"),t,"")+t;case 5495:case 3959:return It(t,/(image-set\([^]*)/,jt+"$1$`$1");case 4968:return It(It(t,/(.+:)(flex-)?(.*)/,jt+"box-pack:$3"+_t+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+jt+t+t;case 4200:if(!ii(t,/flex-|baseline/))return _t+"grid-column-align"+Qo(t,e)+t;break;case 2592:case 3360:return _t+It(t,"template-","")+t;case 4384:case 3616:return n&&n.some(function(r,i){return e=i,ii(r.props,/grid-\w+-end/)})?~Za(t+(n=n[e].value),"span",0)?t:_t+It(t,"-start","")+t+_t+"grid-row-span:"+(~Za(n,"span",0)?ii(n,/\d+/):+ii(n,/\d+/)-+ii(t,/\d+/))+";":_t+It(t,"-start","")+t;case 4896:case 4128:return n&&n.some(function(r){return ii(r.props,/grid-\w+-start/)})?t:_t+It(It(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return It(t,/(.+)-inline(.+)/,jt+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Hr(t)-1-e>6)switch(wn(t,e+1)){case 109:if(wn(t,e+4)!==45)break;case 102:return It(t,/(.+:)(.+)-([^]+)/,"$1"+jt+"$2-$3$1"+mA+(wn(t,e+3)==108?"$3":"$2-$3"))+t;case 115:return~Za(t,"stretch",0)?L0(It(t,"stretch","fill-available"),e,n)+t:t}break;case 5152:case 5920:return It(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(r,i,o,A,a,s,l){return _t+i+":"+o+l+(A?_t+i+"-span:"+(a?s:+s-+o)+l:"")+t});case 4949:if(wn(t,e+6)===121)return It(t,":",":"+jt)+t;break;case 6444:switch(wn(t,wn(t,14)===45?18:11)){case 120:return It(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+jt+(wn(t,14)===45?"inline-":"")+"box$3$1"+jt+"$2$3$1"+_t+"$2box$3")+t;case 100:return It(t,":",":"+_t)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return It(t,"scroll-","scroll-snap-")+t}return t}function us(t,e){for(var n="",r=0;r<t.length;r++)n+=e(t[r],r,t,e)||"";return n}function rS(t,e,n,r){switch(t.type){case Yw:if(t.children.length)break;case Lw:case Ld:return t.return=t.return||t.value;case Q0:return"";case k0:return t.return=t.value+"{"+us(t.children,r)+"}";case js:if(!Hr(t.value=t.props.join(",")))return""}return Hr(n=us(t.children,r))?t.return=t.value+"{"+n+"}":""}function iS(t){var e=j0(t);return function(n,r,i,o){for(var A="",a=0;a<e;a++)A+=t[a](n,r,i,o)||"";return A}}function oS(t){return function(e){e.root||(e=e.return)&&t(e)}}function AS(t,e,n,r){if(t.length>-1&&!t.return)switch(t.type){case Ld:t.return=L0(t.value,t.length,n);return;case k0:return us([Ei(t,{value:It(t.value,"@","@"+jt)})],r);case js:if(t.length)return Kw(n=t.props,function(i){switch(ii(i,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":co(Ei(t,{props:[It(i,/:(read-\w+)/,":"+mA+"$1")]})),co(Ei(t,{props:[i]})),tu(t,{props:Gf(n,r)});break;case"::placeholder":co(Ei(t,{props:[It(i,/:(plac\w+)/,":"+jt+"input-$1")]})),co(Ei(t,{props:[It(i,/:(plac\w+)/,":"+mA+"$1")]})),co(Ei(t,{props:[It(i,/:(plac\w+)/,_t+"input-$1")]})),co(Ei(t,{props:[i]})),tu(t,{props:Gf(n,r)});break}return""})}}var aS={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},to=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Y0="active",H0="data-styled-version",Hs="6.1.19",Hd=`/*!sc*/
175
175
  `,ds=typeof window<"u"&&typeof document<"u",sS=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==""?process.env.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&process.env.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.SC_DISABLE_SPEEDY!==void 0&&process.env.SC_DISABLE_SPEEDY!==""?process.env.SC_DISABLE_SPEEDY!=="false"&&process.env.SC_DISABLE_SPEEDY:process.env.NODE_ENV!=="production"),Lf=/invalid hook call/i,Sa=new Set,lS=function(t,e){if(process.env.NODE_ENV!=="production"){var n=e?' with the id of "'.concat(e,'"'):"",r="The component ".concat(t).concat(n,` has been created dynamically.
176
176
  `)+`You may see this warning because you've called styled inside another component.
177
177
  To resolve this only create new StyledComponents outside of any render method and function component.
@@ -683,7 +683,7 @@ html body {
683
683
  &:hover {
684
684
  opacity: 0.9;
685
685
  }
686
- `;function vO({title:t,content:e,icon:n,onOk:r,onCancel:i}){const o=document.createElement("div");document.body.appendChild(o);const A=dO.createRoot(o),a=()=>{A.unmount(),o.remove()},s=async()=>{r&&await r(),a()},l=()=>{i==null||i(),a()};A.render(ie.jsx(gO,{children:ie.jsxs(fO,{children:[ie.jsxs(hO,{children:[n&&ie.jsx(pO,{children:n}),t]}),ie.jsx(mO,{children:e}),ie.jsxs(VO,{children:[ie.jsx(Ym,{onClick:l,children:"取消"}),ie.jsx(Ym,{primary:!0,onClick:s,children:"确定"})]})]})}))}const CO={1:ie.jsx(Vt,{name:"ruandianhua"}),2:ie.jsx(Vt,{name:"pnhone"}),3:ie.jsx(Vt,{name:"sip-phone"})},qO={call_number:"",answer:"接听",reject:"拒接",hangup:"挂机",dtmf:"DTMF",unhold:"取消保持",hold:"保持",mute:"静音",unmute:"取消静音",satisfaction:"满意度",consult:"咨询",consult_transfer:"咨询转接",consult_retrieve:"取回通话",conference:"三方会议",whisper:"耳语",cancel_whisper:"取消耳语",force_insert:"强插",force_disconnect:"强拆"},EO={空闲:1,离线:0,未注册:4},yO=T.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-Co1x-cuh.js"))),wO=T.lazy(()=>Promise.resolve().then(()=>require("./TransferModel-C7UX-wdd.js"))),hc=rn.div`
686
+ `;function vO({title:t,content:e,icon:n,onOk:r,onCancel:i}){const o=document.createElement("div");document.body.appendChild(o);const A=dO.createRoot(o),a=()=>{A.unmount(),o.remove()},s=async()=>{r&&await r(),a()},l=()=>{i==null||i(),a()};A.render(ie.jsx(gO,{children:ie.jsxs(fO,{children:[ie.jsxs(hO,{children:[n&&ie.jsx(pO,{children:n}),t]}),ie.jsx(mO,{children:e}),ie.jsxs(VO,{children:[ie.jsx(Ym,{onClick:l,children:"取消"}),ie.jsx(Ym,{primary:!0,onClick:s,children:"确定"})]})]})}))}const CO={1:ie.jsx(Vt,{name:"ruandianhua"}),2:ie.jsx(Vt,{name:"pnhone"}),3:ie.jsx(Vt,{name:"sip-phone"})},qO={call_number:"",answer:"接听",reject:"拒接",hangup:"挂机",dtmf:"DTMF",unhold:"取消保持",hold:"保持",mute:"静音",unmute:"取消静音",satisfaction:"满意度",consult:"咨询",consult_transfer:"咨询转接",consult_retrieve:"取回通话",conference:"三方会议",whisper:"耳语",cancel_whisper:"取消耳语",force_insert:"强插",force_disconnect:"强拆"},EO={空闲:1,离线:0,未注册:4},yO=T.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-CYTVQGdR.js"))),wO=T.lazy(()=>Promise.resolve().then(()=>require("./TransferModel-QQzZ-wzs.js"))),hc=rn.div`
687
687
  width: 25px;
688
688
  height: 25px;
689
689
  background: ${({bg:t})=>t};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-xVt94WPB.js");exports.YsytAgentLogout=e.agentLogout;exports.YsytCallForceInsert=e.callForceInsert;exports.YsytCallForceSplit=e.callForceSplit;exports.YsytGetCustomerInfo=e.getCustomerInfo;exports.YsytListenCall=e.listenCall;exports.YsytMakeCall=e.makeCall;exports.YsytPreviewMakeCall=e.previewMakeCall;exports.YsytSetAgentDevice=e.setAgentDevice;exports.YsytSetAgentInitState=e.setAgentInitState;exports.YsytStartEarSpeak=e.startEarSpeak;exports.YsytStopEarSpeak=e.stopEarSpeak;exports.default=e.YsytBarPhone;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-DlZp6-xz.js");exports.YsytAgentLogout=e.agentLogout;exports.YsytCallForceInsert=e.callForceInsert;exports.YsytCallForceSplit=e.callForceSplit;exports.YsytGetCustomerInfo=e.getCustomerInfo;exports.YsytListenCall=e.listenCall;exports.YsytMakeCall=e.makeCall;exports.YsytPreviewMakeCall=e.previewMakeCall;exports.YsytSetAgentDevice=e.setAgentDevice;exports.YsytSetAgentInitState=e.setAgentInitState;exports.YsytStartEarSpeak=e.startEarSpeak;exports.YsytStopEarSpeak=e.stopEarSpeak;exports.default=e.YsytBarPhone;
@@ -1,4 +1,4 @@
1
- import { ak as s, ap as e, aq as l, ah as y, am as Y, ag as o, al as r, aj as n, ai as S, an as i, ao as p, af as C } from "./index-DExsNupU.mjs";
1
+ import { ak as s, ap as e, aq as l, ah as y, am as Y, ag as o, al as r, aj as n, ai as S, an as i, ao as p, af as C } from "./index-BrCg-39l.mjs";
2
2
  export {
3
3
  s as YsytAgentLogout,
4
4
  e as YsytCallForceInsert,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ysyt-react-agent-lib",
3
- "version": "1.2.16",
3
+ "version": "1.2.18",
4
4
  "description": "",
5
5
  "main": "dist/ysyt-react-agent-lib.cjs.js",
6
6
  "module": "dist/ysyt-react-agent-lib.es.js",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "antd": "5.24.0",
31
31
  "styled-components": "^6.1.13",
32
- "ysyt-agent-sdk": "2.0.24"
32
+ "ysyt-agent-sdk": "2.0.26"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.2.0",