ysyt-react-agent-lib 1.0.98 → 1.0.99

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-DUQ5FeiU.js"),s=require("react"),i=require("./index-BbcpIfXG.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-pLvaffe5.js"),s=require("react"),i=require("./index-CINQwnCI.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-z-WTflF-.mjs";
1
+ import { j as e, M as l, E as r, S as i, Y as d } from "./index-CPcFDOQg.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-DuzuSozs.mjs";
3
+ import { M as p, T as j } from "./index-Cb1vkTHo.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-z-WTflF-.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-CPcFDOQg.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-DuzuSozs.mjs";
3
+ import { M as I, T as M } from "./index-Cb1vkTHo.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-DUQ5FeiU.js"),t=require("react"),l=require("./index-BbcpIfXG.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-pLvaffe5.js"),t=require("react"),l=require("./index-CINQwnCI.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,4 +1,4 @@
1
- "use strict";const b=require("react"),a=require("./index-DUQ5FeiU.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-pLvaffe5.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`]:{[`
@@ -10025,7 +10025,7 @@ var we, Vn, fe, wn, pA, se, ot;
10025
10025
  (function(e) {
10026
10026
  e[e.IDLE = 1] = "IDLE", e[e.BUSY = 2] = "BUSY", e[e.RINGING = 3] = "RINGING", e[e.OFFLINE = 0] = "OFFLINE", e[e.UNREGISTERED = 4] = "UNREGISTERED";
10027
10027
  })(we || (we = {})), function(e) {
10028
- e.OUTGOING = "outgoing", e.INCOMING = "incoming", e.CONSULT = "consult", e.MEETING = "meeting", e.TRANSFER = "transfer";
10028
+ e.OUTGOING = "outgoing", e.INCOMING = "incoming", e.CONSULT = "consult", e.MEETING = "meeting", e.TRANSFER = "transfer", e.PREDICT_OUT_CALL = "predict_out_call";
10029
10029
  }(Vn || (Vn = {})), function(e) {
10030
10030
  e[e.OUT_CALL = 100] = "OUT_CALL", e[e.AGENT_STATE = 101] = "AGENT_STATE", e[e.OUT_CALL_INCOMING_CALL = 102] = "OUT_CALL_INCOMING_CALL", e[e.OUT_CALL_RINGING = 103] = "OUT_CALL_RINGING", e[e.OUT_CALL_ANSWER = 104] = "OUT_CALL_ANSWER", e[e.CALL_HOLD = 105] = "CALL_HOLD", e[e.CALL_UNHOLD = 106] = "CALL_UNHOLD", e[e.OUT_CALL_END = 107] = "OUT_CALL_END", e[e.CONSULT_REQUEST = 108] = "CONSULT_REQUEST", e[e.CONSULT_RINGING = 109] = "CONSULT_RINGING", e[e.CONSULT_ANSWER = 110] = "CONSULT_ANSWER", e[e.CONSULT_FAIL = 111] = "CONSULT_FAIL", e[e.MUTE = 112] = "MUTE", e[e.UNMUTE = 113] = "UNMUTE", e[e.CONSULT_CALL_IN = 114] = "CONSULT_CALL_IN", e[e.CONSULT_CALL_IN_SUCCESS = 115] = "CONSULT_CALL_IN_SUCCESS", e[e.CONSULT_RETURN_CALL = 125] = "CONSULT_RETURN_CALL", e[e.CONSULT_RETURN_CALL_SUCCESS = 126] = "CONSULT_RETURN_CALL_SUCCESS", e[e.CONSULT_TRANSFER = 116] = "CONSULT_TRANSFER", e[e.CONSULT_TRANSFER_FAILED = 118] = "CONSULT_TRANSFER_FAILED", e[e.CONSULT_TRANSFER_OFF_HOOK = 117] = "CONSULT_TRANSFER_OFF_HOOK", e[e.INCOMING_CALL = 119] = "INCOMING_CALL", e[e.INCOMING_CALL_OFF_HOOK = 120] = "INCOMING_CALL_OFF_HOOK", e[e.INCOMING_CALL_END = 121] = "INCOMING_CALL_END", e[e.SATISFACTION_EVALUATION = 122] = "SATISFACTION_EVALUATION", e[e.CONSULT_THREE_WAY = 123] = "CONSULT_THREE_WAY", e[e.CONSULT_THREE_WAY_RESULT = 124] = "CONSULT_THREE_WAY_RESULT", e[e.TRANSFER = 127] = "TRANSFER", e[e.TRANSFER_FAILED = 128] = "TRANSFER_FAILED", e[e.TRANSFER_INCOMING_CALL = 129] = "TRANSFER_INCOMING_CALL", e[e.TRANSFER_OFF_HOOK = 130] = "TRANSFER_OFF_HOOK", e[e.AGENT_HANGUP = 131] = "AGENT_HANGUP", e[e.KICK_OFFLINE = 132] = "KICK_OFFLINE", e[e.CONTINUOUS_NOT_ANSWER = 133] = "CONTINUOUS_NOT_ANSWER", e[e.PREVIEW_OUT_CALL = 134] = "PREVIEW_OUT_CALL";
10031
10031
  }(fe || (fe = {})), function(e) {
@@ -12920,22 +12920,23 @@ class Vt {
12920
12920
  const n = (/* @__PURE__ */ new Date()).getTime();
12921
12921
  this.sendMessage({ type: 0, msg_id: n }), this.pendingMessages.set(n, performance.now()), this.startHeartbeat(), this.manualClose = !1;
12922
12922
  }, this.ws.onmessage = async (n) => {
12923
+ var u;
12923
12924
  const r = JSON.parse(n.data), { type: i, data: o, code: a, msg: s, msg_id: l } = r;
12924
12925
  if (i === 0 && l) {
12925
- const u = this.pendingMessages.get(l), V = performance.now() - u;
12926
- lA.latency = parseFloat(V.toFixed(2)), this.pendingMessages.delete(l);
12926
+ const V = this.pendingMessages.get(l), d = performance.now() - V;
12927
+ lA.latency = parseFloat(d.toFixed(2)), this.pendingMessages.delete(l);
12927
12928
  }
12928
12929
  if (i !== 0 && Xh("%cWebSocket 收到消息:", "color: blue; font-weight: bold;", r), i !== fe.OUT_CALL && i !== fe.PREVIEW_OUT_CALL || (a !== 0 ? (z.reset(), vA.emit(pA.OUT_FAILED, s), vA.emit(se.FAIL_NOTIFICATION, s), z.updateActionConfigs(Sn), setTimeout(() => {
12929
12930
  z.updateCustomerInfo(void 0);
12930
12931
  }, 500), this.stateIdleChange()) : a === 0 && (vA.emit(pA.OUT_SUCCESS), clearTimeout(lA.autoStateTimer))), i === fe.AGENT_STATE) {
12931
- const { state: u, state_name: V } = o;
12932
- lA.stateObject = { state: u, state_name: V }, V === "振铃中" && z.updateDisplayText(ot.AGENT_RINGING), u === we.UNREGISTERED && z.updateActionConfigs(HM), vA.emit(pA.AGENT_STATE, { state: u, state_name: V });
12932
+ const { state: V, state_name: d } = o;
12933
+ lA.stateObject = { state: V, state_name: d }, d === "振铃中" && z.updateDisplayText(ot.AGENT_RINGING), V === we.UNREGISTERED && z.updateActionConfigs(HM), vA.emit(pA.AGENT_STATE, { state: V, state_name: d });
12933
12934
  }
12934
12935
  if (i === fe.OUT_CALL_INCOMING_CALL) {
12935
12936
  try {
12936
12937
  await this.getCustomerInfo(o.trace_id || o.customer_phone);
12937
- } catch (u) {
12938
- console.error(u);
12938
+ } catch (V) {
12939
+ console.error(V);
12939
12940
  }
12940
12941
  o.preview_task_id ? vA.emit(pA.PREVIEW_OUT_INCOMING_CALL, { customer_phone: o.customer_phone, session_id: o.session_id, preview_task_id: o.preview_task_id, trace_id: o.trace_id }) : vA.emit(pA.OUT_INCOMING_CALL, { customer_phone: o.customer_phone, session_id: o.session_id, trace_id: o.trace_id }), lA.sessionId = o.session_id, z.updateActionConfigs(JM);
12941
12942
  }
@@ -12945,10 +12946,10 @@ class Vt {
12945
12946
  clearTimeout(lA.autoStateTimer), lA.sessionId = o.session_id;
12946
12947
  try {
12947
12948
  await this.getCustomerInfo(o.trace_id || o.customer_phone);
12948
- } catch (u) {
12949
- console.error(u);
12949
+ } catch (V) {
12950
+ console.error(V);
12950
12951
  }
12951
- z.updateIsCalling(!0), z.updateDirection(Vn.INCOMING), this.inCallAutoAnswer(), z.updateDisplayText(ot.INCOMING_CALL), o.direction === 1 && vA.emit(pA.INCOMING_CALL, { customer_phone: o.customer_phone, trace_id: o.trace_id, session_id: o.session_id }), o.direction === 3 && vA.emit(pA.PREDICT_INCOMING_CALL, { customer_phone: o.customer_phone, trace_id: o.trace_id, session_id: o.session_id }), z.updateActionConfigs(Tc), lA.enableBrowserAlert && ia.show("📞 客户来电", `客户 [${o.customer_phone}] 正在呼入...`, () => {
12952
+ z.updateIsCalling(!0), z.updateDirection(Vn.INCOMING), this.inCallAutoAnswer(), z.updateDisplayText(ot.INCOMING_CALL), o.direction === 1 && vA.emit(pA.INCOMING_CALL, { customer_phone: o.customer_phone, trace_id: o.trace_id, session_id: o.session_id }), o.direction === 3 && (vA.emit(pA.PREDICT_INCOMING_CALL, { customer_phone: o.customer_phone, trace_id: o.trace_id, session_id: o.session_id }), (u = this.sipClient) == null || u.answerCall()), z.updateActionConfigs(Tc), lA.enableBrowserAlert && ia.show("📞 客户来电", `客户 [${o.customer_phone}] 正在呼入...`, () => {
12952
12953
  vA.emit(se.NOTIFICATION_CLICK, { customer_phone: o.customer_phone });
12953
12954
  }, lA.browserAlertTime);
12954
12955
  }
@@ -12956,8 +12957,8 @@ class Vt {
12956
12957
  vA.emit(se.NOTIFICATION_CLICK, { agent_no: o.agent_no });
12957
12958
  }, lA.browserAlertTime))), i === fe.TRANSFER_OFF_HOOK && (vA.emit(pA.TRANSFER_OFF_HOOK, { session_id: lA.sessionId }), z.updateTransferIsAnswer(!1), z.updateDisplayText(ot.CALLING), z.updateActionConfigs(is)), i === fe.TRANSFER_FAILED && o.status === "failed") {
12958
12959
  vA.emit(pA.TRANSFER_FAILED, "未知原因"), vA.emit(se.FAIL_NOTIFICATION, "转接失败");
12959
- const u = z.get("direction");
12960
- u === Vn.OUTGOING ? z.updateActionConfigs(Bi) : u === Vn.INCOMING && z.updateActionConfigs(is);
12960
+ const V = z.get("direction");
12961
+ V === Vn.OUTGOING ? z.updateActionConfigs(Bi) : V === Vn.INCOMING && z.updateActionConfigs(is);
12961
12962
  }
12962
12963
  i === fe.KICK_OFFLINE && vA.emit(se.KICK_OFF), i === fe.CONTINUOUS_NOT_ANSWER && (vA.emit(se.FAIL_NOTIFICATION, `已连续 ${o.miss_count} 次未接, 设置忙碌`), this.stateBusyChange());
12963
12964
  }, this.ws.onclose = () => {
@@ -34535,7 +34536,7 @@ const L6 = {
34535
34536
  空闲: 1,
34536
34537
  离线: 0,
34537
34538
  未注册: 4
34538
- }, P6 = zq(() => import("./ConsultModel-BbHszACf.mjs")), W6 = zq(() => import("./TransferModel-DkVgCnEs.mjs")), vO = (e) => {
34539
+ }, P6 = zq(() => import("./ConsultModel-mhBh-iuF.mjs")), W6 = zq(() => import("./TransferModel-BLNbMubI.mjs")), vO = (e) => {
34539
34540
  var te, me, xA;
34540
34541
  const {
34541
34542
  style: A,
@@ -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-z-WTflF-.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-CPcFDOQg.mjs";
4
4
  const bn = new Ne("antFadeIn", {
5
5
  "0%": {
6
6
  opacity: 0
@@ -152,7 +152,7 @@ React keys must be passed directly to JSX without using spread:
152
152
  `+r+`
153
153
  `);if(this.state===Ve.Connected){if(this.onMessage)try{this.onMessage(r)}catch(i){throw this.logger.error(i.toString()),this.logger.error("Exception thrown by onMessage callback"),i}}else this.logger.warn("Received message while not connected, discarding...")}else this.logger.warn("Received empty message, discarding...")}onWebSocketOpen(A,t){t===this._ws&&this._state===Ve.Connecting&&(this.logger.log(`WebSocket opened ${this.server}`),this.transitionState(Ve.Connected))}transitionLoopDetectedError(A){let t="A state transition loop has been detected.";return t+=` An attempt to transition from ${this._state} to ${A} before the prior transition completed.`,t+=" Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?",this.logger.error(t),new To("Loop detected.")}transitionState(A,t){const n=()=>{throw new Error(`Invalid state transition from ${this._state} to ${A}`)};if(this.transitioningState)throw this.transitionLoopDetectedError(A);switch(this.transitioningState=!0,this._state){case Ve.Connecting:A!==Ve.Connected&&A!==Ve.Disconnecting&&A!==Ve.Disconnected&&n();break;case Ve.Connected:A!==Ve.Disconnecting&&A!==Ve.Disconnected&&n();break;case Ve.Disconnecting:A!==Ve.Connecting&&A!==Ve.Disconnected&&n();break;case Ve.Disconnected:A!==Ve.Connecting&&n();break;default:throw new Error("Unknown state.")}const r=this._state;this._state=A;const i=this.connectResolve,o=this.connectReject;r===Ve.Connecting&&(this.connectPromise=void 0,this.connectResolve=void 0,this.connectReject=void 0);const a=this.disconnectResolve,s=this.disconnectReject;if(r===Ve.Disconnecting&&(this.disconnectPromise=void 0,this.disconnectResolve=void 0,this.disconnectReject=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),this.logger.log(`Transitioned from ${r} to ${this._state}`),this._stateEventEmitter.emit(this._state),A===Ve.Connected&&(this.startSendingKeepAlives(),this.onConnect))try{this.onConnect()}catch(l){throw this.logger.error(l.toString()),this.logger.error("Exception thrown by onConnect callback"),l}if(r===Ve.Connected&&(this.stopSendingKeepAlives(),this.onDisconnect))try{t?this.onDisconnect(t):this.onDisconnect()}catch(l){throw this.logger.error(l.toString()),this.logger.error("Exception thrown by onDisconnect callback"),l}if(r===Ve.Connecting){if(!i)throw new Error("Connect resolve undefined.");if(!o)throw new Error("Connect reject undefined.");A===Ve.Connected?i():o(t||new Error("Connect aborted."))}if(r===Ve.Disconnecting){if(!a)throw new Error("Disconnect resolve undefined.");if(!s)throw new Error("Disconnect reject undefined.");A===Ve.Disconnected?a():s(t||new Error("Disconnect aborted."))}this.transitioningState=!1}clearKeepAliveTimeout(){this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveDebounceTimeout=void 0}sendKeepAlive(){return this.keepAliveDebounceTimeout?Promise.resolve():(this.keepAliveDebounceTimeout=setTimeout(()=>{this.clearKeepAliveTimeout()},1e3*this.configuration.keepAliveDebounce),this.send(`\r
154
154
  \r
155
- `))}startSendingKeepAlives(){this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(()=>{this.sendKeepAlive(),this.startSendingKeepAlives()},(A=>{const t=.8*A;return 1e3*(Math.random()*(A-t)+t)})(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}}Ql.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0};class ji{constructor(A={}){if(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=Rt.Stopped,this._stateEventEmitter=new ga,this.delegate=A.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ji.defaultOptions()),{sipjsId:ni(5)}),{uri:new _n("sip","anonymous."+ni(6),"anonymous.invalid")}),{viaHost:ni(12)+".invalid"}),ji.stripUndefinedProperties(A)),this.options.hackIpInContact)if(typeof this.options.hackIpInContact=="boolean"&&this.options.hackIpInContact){const r=Math.floor(Math.random()*254+1);this.options.viaHost="192.0.2."+r}else this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact);switch(this.loggerFactory=new H1,this.logger=this.loggerFactory.getLogger("sip.UserAgent"),this.loggerFactory.builtinEnabled=this.options.logBuiltinEnabled,this.loggerFactory.connector=this.options.logConnector,this.options.logLevel){case"error":this.loggerFactory.level=St.error;break;case"warn":this.loggerFactory.level=St.warn;break;case"log":this.loggerFactory.level=St.log;break;case"debug":this.loggerFactory.level=St.debug}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(t=>{const n=this.options[t];switch(t){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("· "+t+": "+n);break;case"authorizationPassword":this.logger.log("· "+t+": NOT SHOWN");break;case"transportConstructor":this.logger.log("· "+t+": "+n.name);break;default:this.logger.log("· "+t+": "+JSON.stringify(n))}})),this.options.transportOptions){const t=this.options.transportOptions,n=t.maxReconnectionAttempts,r=t.reconnectionTimeout;n!==void 0&&this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),r!==void 0&&this.logger.warn('The transport option "reconnectionTimeout" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),A.reconnectionDelay===void 0&&r!==void 0&&(this.options.reconnectionDelay=r),A.reconnectionAttempts===void 0&&n!==void 0&&(this.options.reconnectionAttempts=n)}if(A.reconnectionDelay!==void 0&&this.logger.warn('The user agent option "reconnectionDelay" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),A.reconnectionAttempts!==void 0&&this.logger.warn('The user agent option "reconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),this._transport=new this.options.transportConstructor(this.getLogger("sip.Transport"),this.options.transportOptions),this.initTransportCallbacks(),this._contact=this.initContact(),this._instanceId=this.options.instanceId?this.options.instanceId:ji.newUUID(),vt.parse(this._instanceId,"uuid")===-1)throw new Error("Invalid instanceId.");this._userAgentCore=this.initCore()}static makeURI(A){return vt.URIParse(A)}static defaultOptions(){return{allowLegacyNotifications:!1,authorizationHa1:"",authorizationPassword:"",authorizationUsername:"",delegate:{},contactName:"",contactParams:{transport:"ws"},displayName:"",forceRport:!1,gracefulShutdown:!0,hackAllowUnregisteredOptionTags:!1,hackIpInContact:!1,hackViaTcp:!1,instanceId:"",instanceIdAlwaysAdded:!1,logBuiltinEnabled:!0,logConfiguration:!0,logConnector:()=>{},logLevel:"log",noAnswerTimeout:60,preloadedRouteSet:[],reconnectionAttempts:0,reconnectionDelay:4,sendInitialProvisionalResponse:!0,sessionDescriptionHandlerFactory:uM(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:Tn.Unsupported,sipExtensionReplaces:Tn.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:Ql,transportOptions:{},uri:new _n("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/0.21.1",viaHost:""}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.floor(16*Math.random());return(t==="x"?n:n%4+8).toString(16)})}static stripUndefinedProperties(A){return Object.keys(A).reduce((t,n)=>(A[n]!==void 0&&(t[n]=A[n]),t),{})}get configuration(){return this.options}get contact(){return this._contact}get instanceId(){return this._instanceId}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get transport(){return this._transport}get userAgentCore(){return this._userAgentCore}getLogger(A,t){return this.loggerFactory.getLogger(A,t)}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===Rt.Stopped?Promise.reject(new Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}start(){return this.state===Rt.Started?(this.logger.warn("User agent already started"),Promise.resolve()):(this.logger.log(`Starting ${this.configuration.uri}`),this.transitionState(Rt.Started),this.transport.connect())}async stop(){if(this.state===Rt.Stopped)return this.logger.warn("User agent already stopped"),Promise.resolve();if(this.logger.log(`Stopping ${this.configuration.uri}`),!this.options.gracefulShutdown)return this.logger.log("Dispose of transport"),this.transport.dispose().catch(a=>{throw this.logger.error(a.message),a}),this.logger.log("Dispose of core"),this.userAgentCore.dispose(),this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this.transitionState(Rt.Stopped),Promise.resolve();const A=Object.assign({},this._publishers),t=Object.assign({},this._registerers),n=Object.assign({},this._sessions),r=Object.assign({},this._subscriptions),i=this.transport,o=this.userAgentCore;this.logger.log("Dispose of registerers");for(const a in t)t[a]&&await t[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._registerers[a],s});this.logger.log("Dispose of sessions");for(const a in n)n[a]&&await n[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._sessions[a],s});this.logger.log("Dispose of subscriptions");for(const a in r)r[a]&&await r[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._subscriptions[a],s});this.logger.log("Dispose of publishers");for(const a in A)A[a]&&await A[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._publishers[a],s});this.logger.log("Dispose of transport"),await i.dispose().catch(a=>{throw this.logger.error(a.message),a}),this.logger.log("Dispose of core"),o.dispose(),this.transitionState(Rt.Stopped)}_makeInviter(A,t){return new VC(this,A,t)}attemptReconnection(A=1){const t=this.options.reconnectionAttempts,n=this.options.reconnectionDelay;A>t?this.logger.log("Maximum reconnection attempts reached"):(this.logger.log(`Reconnection attempt ${A} of ${t} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${A} of ${t} - succeeded`)}).catch(r=>{this.logger.error(r.message),this.logger.log(`Reconnection attempt ${A} of ${t} - failed`),this.attemptReconnection(++A)})},A===1?0:1e3*n))}initContact(){const A=this.options.contactName!==""?this.options.contactName:ni(8),t=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new _n("sip",A,this.options.viaHost,void 0,t),toString:(n={})=>{const r=n.anonymous||!1,i=n.outbound||!1,o=n.register||!1;let a="<";return a+=r?this.contact.tempGruu||`sip:anonymous@anonymous.invalid;transport=${t.transport?t.transport:"ws"}`:o?this.contact.uri:this.contact.pubGruu||this.contact.uri,i&&(a+=";ob"),a+=">",this.options.instanceIdAlwaysAdded&&(a+=';+sip.instance="<urn:uuid:'+this._instanceId+'>"'),a}}}initCore(){let A=[];A.push("outbound"),this.options.sipExtension100rel===Tn.Supported&&A.push("100rel"),this.options.sipExtensionReplaces===Tn.Supported&&A.push("replaces"),this.options.sipExtensionExtraSupported&&A.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(A=A.filter(i=>j1[i])),A=Array.from(new Set(A));const t=A.slice();(this.contact.pubGruu||this.contact.tempGruu)&&t.push("gruu");const n={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:A,supportedOptionTagsResponse:t,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{const i=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,o=this.options.authorizationPassword?this.options.authorizationPassword:void 0,a=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new L1(this.getLoggerFactory(),a,i,o)},transportAccessor:()=>this.transport},r={onInvite:i=>{var o;const a=new Hu(this,i);if(i.delegate={onCancel:s=>{a._onCancel(s)},onTransportError:s=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},i.trying(),this.options.sipExtensionReplaces!==Tn.Unsupported){const s=i.message.parseHeader("replaces");if(s){const l=s.call_id;if(typeof l!="string")throw new Error("Type of call id is not string");const u=s.replaces_to_tag;if(typeof u!="string")throw new Error("Type of to tag is not string");const V=s.replaces_from_tag;if(typeof V!="string")throw new Error("type of from tag is not string");const d=l+u+V,f=this.userAgentCore.dialogs.get(d);if(!f)return void a.reject({statusCode:481});if(!f.early&&s.early_only===!0)return void a.reject({statusCode:486});const q=this._sessions[l+V]||this._sessions[l+u]||void 0;if(!q)throw new Error("Session does not exist.");a._replacee=q}}if(!((o=this.delegate)===null||o===void 0)&&o.onInvite)return a.autoSendAnInitialProvisionalResponse?void a.progress().then(()=>{var s;if(((s=this.delegate)===null||s===void 0?void 0:s.onInvite)===void 0)throw new Error("onInvite undefined.");this.delegate.onInvite(a)}):void this.delegate.onInvite(a);a.reject({statusCode:486})},onMessage:i=>{if(this.delegate&&this.delegate.onMessage){const o=new cC(i);this.delegate.onMessage(o)}else i.accept()},onNotify:i=>{if(this.delegate&&this.delegate.onNotify){const o=new ju(i);this.delegate.onNotify(o)}else this.options.allowLegacyNotifications?i.accept():i.reject({statusCode:481})},onRefer:i=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(i):i.reject({statusCode:405})},onRegister:i=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(i):i.reject({statusCode:405})},onSubscribe:i=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(i):i.reject({statusCode:405})}};return new cM(n,r)}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=A=>this.onTransportDisconnect(A),this.transport.onMessage=A=>this.onTransportMessage(A)}onTransportConnect(){this.state!==Rt.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(A){this.state!==Rt.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(A),A&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(A){const t=Bs.parseMessage(A,this.getLogger("sip.Parser"));if(!t)return void this.logger.warn("Failed to parse incoming message. Dropping.");if(this.state===Rt.Stopped&&t instanceof Ki)return void this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);const n=()=>{const r=["from","to","call_id","cseq","via"];for(const i of r)if(!t.hasHeader(i))return this.logger.warn(`Missing mandatory header field : ${i}.`),!1;return!0};if(t instanceof Ki){if(!n())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!t.toTag&&t.callId.substr(0,5)===this.options.sipjsId)return void this.userAgentCore.replyStateless(t,{statusCode:482});const r=ha(t.body),i=t.getHeader("content-length");if(i&&r<Number(i))return void this.userAgentCore.replyStateless(t,{statusCode:400})}if(t instanceof Kr){if(!n())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(t.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(t.via.host!==this.options.viaHost||t.via.port!==void 0)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");const r=ha(t.body),i=t.getHeader("content-length");if(i&&r<Number(i))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(t instanceof Ki)this.userAgentCore.receiveIncomingRequestFromTransport(t);else{if(!(t instanceof Kr))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(t)}}transitionState(A,t){const n=()=>{throw new Error(`Invalid state transition from ${this._state} to ${A}`)};switch(this._state){case Rt.Started:A!==Rt.Stopped&&n();break;case Rt.Stopped:A!==Rt.Started&&n();break;default:throw new Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${A}`),this._state=A,this._stateEventEmitter.emit(this._state)}}class mC{constructor(A){this.listeners=[],this.keyListeners={},this.data={...A},this.proxy=new Proxy(this.data,{set:(t,n,r)=>(t[n]!==r&&(t[n]=r,this.notify(),this.notifyKey(n,r)),!0)})}getState(){return this.proxy}setState(A,t=!1){let n=!1;for(const r in A)if(Object.prototype.hasOwnProperty.call(A,r)){const i=this.data[r],o=A[r];(t||i!==o)&&(this.data[r]=o,n=!0,this.notifyKey(r,o))}(n||t)&&this.notify()}subscribe(A){return this.listeners.push(A),()=>{this.listeners=this.listeners.filter(t=>t!==A)}}subscribeKey(A,t){return this.keyListeners[A]||(this.keyListeners[A]=[]),this.keyListeners[A].push(t),()=>{this.keyListeners[A]=this.keyListeners[A].filter(n=>n!==t)}}notify(){const A=this.getState();for(const t of this.listeners)t(A)}notifyKey(A,t){const n=this.keyListeners[A];n&&n.forEach(r=>r(t))}}var ye,ln,fe,En,fA,ae,nt;(function(e){e[e.IDLE=1]="IDLE",e[e.BUSY=2]="BUSY",e[e.RINGING=3]="RINGING",e[e.OFFLINE=0]="OFFLINE",e[e.UNREGISTERED=4]="UNREGISTERED"})(ye||(ye={})),function(e){e.OUTGOING="outgoing",e.INCOMING="incoming",e.CONSULT="consult",e.MEETING="meeting",e.TRANSFER="transfer"}(ln||(ln={})),function(e){e[e.OUT_CALL=100]="OUT_CALL",e[e.AGENT_STATE=101]="AGENT_STATE",e[e.OUT_CALL_INCOMING_CALL=102]="OUT_CALL_INCOMING_CALL",e[e.OUT_CALL_RINGING=103]="OUT_CALL_RINGING",e[e.OUT_CALL_ANSWER=104]="OUT_CALL_ANSWER",e[e.CALL_HOLD=105]="CALL_HOLD",e[e.CALL_UNHOLD=106]="CALL_UNHOLD",e[e.OUT_CALL_END=107]="OUT_CALL_END",e[e.CONSULT_REQUEST=108]="CONSULT_REQUEST",e[e.CONSULT_RINGING=109]="CONSULT_RINGING",e[e.CONSULT_ANSWER=110]="CONSULT_ANSWER",e[e.CONSULT_FAIL=111]="CONSULT_FAIL",e[e.MUTE=112]="MUTE",e[e.UNMUTE=113]="UNMUTE",e[e.CONSULT_CALL_IN=114]="CONSULT_CALL_IN",e[e.CONSULT_CALL_IN_SUCCESS=115]="CONSULT_CALL_IN_SUCCESS",e[e.CONSULT_RETURN_CALL=125]="CONSULT_RETURN_CALL",e[e.CONSULT_RETURN_CALL_SUCCESS=126]="CONSULT_RETURN_CALL_SUCCESS",e[e.CONSULT_TRANSFER=116]="CONSULT_TRANSFER",e[e.CONSULT_TRANSFER_FAILED=118]="CONSULT_TRANSFER_FAILED",e[e.CONSULT_TRANSFER_OFF_HOOK=117]="CONSULT_TRANSFER_OFF_HOOK",e[e.INCOMING_CALL=119]="INCOMING_CALL",e[e.INCOMING_CALL_OFF_HOOK=120]="INCOMING_CALL_OFF_HOOK",e[e.INCOMING_CALL_END=121]="INCOMING_CALL_END",e[e.SATISFACTION_EVALUATION=122]="SATISFACTION_EVALUATION",e[e.CONSULT_THREE_WAY=123]="CONSULT_THREE_WAY",e[e.CONSULT_THREE_WAY_RESULT=124]="CONSULT_THREE_WAY_RESULT",e[e.TRANSFER=127]="TRANSFER",e[e.TRANSFER_FAILED=128]="TRANSFER_FAILED",e[e.TRANSFER_INCOMING_CALL=129]="TRANSFER_INCOMING_CALL",e[e.TRANSFER_OFF_HOOK=130]="TRANSFER_OFF_HOOK",e[e.AGENT_HANGUP=131]="AGENT_HANGUP",e[e.KICK_OFFLINE=132]="KICK_OFFLINE",e[e.CONTINUOUS_NOT_ANSWER=133]="CONTINUOUS_NOT_ANSWER",e[e.PREVIEW_OUT_CALL=134]="PREVIEW_OUT_CALL"}(fe||(fe={})),function(e){e.WEB_RTC_CONNECTING="connecting",e.WEB_RTC_CONNECTED="connected",e.WEB_RTC_DISCONNECTING="disconnecting",e.WEB_RTC_DISCONNECTED="disconnected",e.WEB_RTC_REGISTERED="registered",e.WEB_RTC_UNREGISTERED="unregistered",e.WEB_RTC_TERMINATED="terminated",e.WEB_RTC_REGISTER_FAILED="register_failed",e.WEB_RTC_ANSWER_FAILED="answer_failed",e.WEB_RTC_SEND_DTMF="send_dtmf"}(En||(En={})),function(e){e.CUSTOMER_INFO="customer_info",e.CALL_PROGRESS="call_progress",e.OUT_INCOMING_CALL="out_call_incoming_call",e.PREVIEW_OUT_INCOMING_CALL="preview_out_incoming_call",e.OUT_SUCCESS="out_call_success",e.OUT_FAILED="out_call_failed",e.OUT_RINGING="out_call_ringing",e.OUT_OFF_ANSWER="out_call_answer",e.HOLD_SUCCESS="hold_success",e.HOLD_FAILED="hold_failed",e.UNHOLD_SUCCESS="unhold_success",e.UNHOLD_FAILED="unhold_failed",e.OUT_HANGUP="out_call_hangup",e.CONSULT_RINGING="consult_ringing",e.CONSULT_OFF_HOOK="consult_off_hook",e.CONSULT_FAILED="consult_failed",e.CONSULT_INCOMING="consult_incoming",e.CONSULT_CALL_IN_SUCCESS="consult_call_in_success",e.CONSULT_RETURN_CALL_SUCCESS="consult_return_call_success",e.OTHER_SIDE_CONSULT_HANGUP="other_side_consult_hangup",e.OUR_SIDE_CONSULT_HANGUP="our_side_consult_hangup",e.AGENT_STATE="agent_state",e.MUTE_SUCCESS="mute_success",e.MUTE_FAILED="mute_failed",e.UNMUTE_SUCCESS="unmute_success",e.UNMUTE_FAILED="unmute_failed",e.CONSULT_TRANSFER_SUCCESS="consult_transfer_success",e.CONSULT_TRANSFER_FAILED="consult_transfer_failed",e.CONSULT_TRANSFER_OFF_HOOK="consult_transfer_off_hook",e.INCOMING_CALL="incoming_call",e.PREDICT_INCOMING_CALL="predict_incoming_call",e.INCOMING_CALL_OFF_HOOK="incoming_call_off_hook",e.INCOMING_CALL_END="incoming_call_end",e.SATISFACTION_EVALUATION_SUCCESS="satisfaction_evaluation_success",e.SATISFACTION_EVALUATION_FAILED="satisfaction_evaluation_failed",e.CONSULT_THREE_WAY_SUCCESS="consult_three_way_success",e.CONSULT_THREE_WAY_FAILED="consult_three_way_failed",e.THREE_WAY_OUR_SIDE_HANGUP="three_way_our_side_hangup",e.TRANSFER_FAILED="transfer_failed",e.TRANSFER_PROGRESS="transfer_progress",e.TRANSFER_INCOMING_CALL="transfer_incoming_call",e.TRANSFER_OFF_HOOK="transfer_off_hook",e.TRANSFER_END="transfer_end",e.REJECT="reject"}(fA||(fA={})),function(e){e.EVENT_ALL="event_all",e.NOTIFICATION_CLICK="notification_click",e.UPDATE_ANSWER_DEVICE="update_answer_device",e.PHONE_BAR_OPERATION="phone_bar_operation",e.AGENT_INIT_STATUS="agent_init_status",e.WEBSITE_DELAY="website_delay",e.SELECT_EXTERNAL_NUMBER="select_external_number",e.FAIL_NOTIFICATION="fail_notification",e.KICK_OFF="kick_off",e.DESTROY="destroy",e.NETWORK_OFFLINE="network_offline",e.NETWORK_ONLINE="network_online"}(ae||(ae={})),function(e){e.RINGING="客户振铃",e.AGENT_RINGING="振铃中",e.CALLING="通话中",e.CONSULTING="正在咨询",e.CONSULT_CALL_IN="咨询来电",e.INCOMING_CALL="客户来电",e.MEETING="会议中",e.TRANSFERRING="转接中",e.TRANSFER_INCOMING_CALL="转接来电",e.HOLDING="保持中",e.MUTING="静音中"}(nt||(nt={}));const Fo=function(e){return{all:e=e||new Map,on:function(A,t){var n=e.get(A);n?n.push(t):e.set(A,[t])},off:function(A,t){var n=e.get(A);n&&(t?n.splice(n.indexOf(t)>>>0,1):e.set(A,[]))},emit:function(A,t){var n=e.get(A);n&&n.slice().map(function(r){r(t)}),(n=e.get("*"))&&n.slice().map(function(r){r(A,t)})}}}(),vA={on:(e,A)=>(Fo.on(e,A),vA),off(e,A){Fo.off(e,A)},emit(e,A){Fo.emit(e,A),Fo.emit(ae.EVENT_ALL,{event:e,data:A})},clearAllListeners(){Fo.all.clear()}},lA={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null,autoAnswerTimer:null,logBuiltinEnabled:!1,browserAlertTime:3e3,latency:0},mn={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,transferIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1,selectOutNumber:"",customerObject:void 0,isNextState:!0},X=new class extends mC{updateIsCalling(e){this.setState({isCalling:e})}updateDirection(e){this.setState({direction:e})}updateOutCallIsAnswer(e){this.setState({outCallIsAnswer:e})}updateIsHold(e){var t;if(((t=lA.stateObject)==null?void 0:t.state)===ye.UNREGISTERED)return;const A=this.get("actionConfigs");if(e){const n=[...A.filter(r=>r!=="hold")];n.push("unhold"),this.updateActionConfigs(n)}else{const n=[...A.filter(r=>r!=="unhold")];n.push("hold"),this.updateActionConfigs(n)}this.getState().isHold=e}updateDisplayText(e){this.setState({displayText:e}),vA.emit(fA.CALL_PROGRESS,e)}updateActionConfigs(e){const{show_satisfaction:A}=lA.agentInfo||{},t=this.get("answerDevice"),n=e.filter(r=>(A!==0||r!=="satisfaction")&&(t!==2||r!=="answer"));this.setState({actionConfigs:n}),vA.emit(ae.PHONE_BAR_OPERATION,n)}updateConsultIsAnswer(e){this.setState({consultIsAnswer:e})}updateIsMuted(e){var t;if(((t=lA.stateObject)==null?void 0:t.state)===ye.UNREGISTERED)return;const A=this.get("actionConfigs");if(e){const n=[...A.filter(r=>r!=="mute")];n.push("unmute"),this.updateActionConfigs(n)}else{const n=[...A.filter(r=>r!=="unmute")];n.push("mute"),this.updateActionConfigs(n)}this.setState({isMuted:e})}updateIncomingIsAnswer(e){this.setState({incomingIsAnswer:e})}updateAnswerDevice(e){this.setState({answerDevice:e}),vA.emit(ae.UPDATE_ANSWER_DEVICE,e)}updateIsMeeting(e){this.setState({isMeeting:e})}updateTransferIsAnswer(e){this.setState({transferIsAnswer:e})}updateSelectOutNumber(e){vA.emit(ae.SELECT_EXTERNAL_NUMBER,e),this.setState({selectOutNumber:e})}updateCustomerInfo(e){const A=this.get("displayText");if(e&&A){const{contact_count:t,customer_name:n,phone:r,city:i,province:o,is_vip:a,in_contact_count:s,trace_id:l}=e;vA.emit(fA.CUSTOMER_INFO,{customer_name:n||"未知客户",phone:r,city:i||"未知",province:o||"未知",contact_count:t||0,in_contact_count:s||0,is_vip:a,trace_id:l})}else vA.emit(fA.CUSTOMER_INFO,void 0);this.setState({customerObject:e})}updateIsNextState(e){this.setState({isNextState:e}),e?vA.emit(ae.NETWORK_ONLINE):(lA.stateObject={state:ye.OFFLINE,state_name:"离线"},this.updateActionConfigs([]),vA.emit(fA.AGENT_STATE,lA.stateObject),vA.emit(ae.NETWORK_OFFLINE))}reset(){this.updateIsCalling(mn.isCalling),this.updateDirection(mn.direction),this.updateOutCallIsAnswer(mn.outCallIsAnswer),this.updateIsHold(mn.isHold),this.updateDisplayText(mn.displayText),this.updateActionConfigs(mn.actionConfigs),this.updateConsultIsAnswer(mn.consultIsAnswer),this.updateIsMuted(mn.isMuted),this.updateIncomingIsAnswer(mn.incomingIsAnswer),this.updateIsMeeting(mn.isMeeting),this.updateTransferIsAnswer(mn.transferIsAnswer),this.updateCustomerInfo(void 0)}getCallInfo(){return this.getState()}get(e){return this.getState()[e]}}(mn),xd=new class extends mC{updateRttObject(e){this.setState({rttObject:e}),vA.emit(ae.WEBSITE_DELAY,e)}}({rttObject:{rtt:null,jitter:null,packetsLost:null,packetsReceived:null,packetsSent:null,sendBitrate:null,recvBitrate:null,codec:null}});let VM=class{constructor(A,t){this.config=A,this.eventCallback=t,this.userAgent=null,this.registerer=null,this.activeSession=null,this.callTimeoutTimer=null,this.incomingInvitation=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectTimer=null,this.isOffline=!1,this.isManuallyStopped=!1,this.registerIntervalTimer=null,this.registerInterval=6e4,this.handleNetworkInfoChange=n=>{var r,i;(r=n.rttObject)!=null&&r.rtt&&((((i=n.rttObject)==null?void 0:i.rtt)||0)===0?this.isOffline||(this.isOffline=!0,this.handleOffline()):this.isOffline&&(this.isOffline=!1,this.handleOnline()))},this.handleOffline=()=>{console.warn("[SIPClient] 网络断开,准备销毁 SIP 客户端",new Date().toLocaleString()),this.destroy()},this.handleOnline=()=>{console.warn("[SIPClient] 网络恢复,准备重新启动 SIP 客户端",new Date().toLocaleString()),this.reconnect()},xd.subscribe(this.handleNetworkInfoChange)}async start(){const A=ji.makeURI(`sip:${this.config.user}@${this.config.server}`);if(!A)throw new Error("无效的SIP配置");const t={uri:A,authorizationUsername:this.config.user,authorizationPassword:this.config.password,transportOptions:{server:this.config.webSocket,connectionTimeout:30,keepAliveInterval:0},contactName:this.config.user,contactParams:{transport:"wss"},userAgentString:"SwiftSIP/1.0.74",sessionDescriptionHandlerFactoryOptions:{alwaysAcquireMediaFirst:!0,peerConnectionConfiguration:{iceServers:[]},iceGatheringTimeout:500},logBuiltinEnabled:lA.logBuiltinEnabled};this.userAgent=new ji(t),this.setupEventListeners(),await this.userAgent.start(),await this.register()}setupEventListeners(){this.userAgent&&(this.userAgent.transport.stateChange.addListener(A=>{var n;let t;switch(A){case Ve.Connecting:t=En.WEB_RTC_CONNECTING;break;case Ve.Connected:t=En.WEB_RTC_CONNECTED,this.reconnectAttempts=0,lA.isRtcReconnecting=!1,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);break;case Ve.Disconnecting:t=En.WEB_RTC_DISCONNECTING;break;case Ve.Disconnected:{if(this.isManuallyStopped)return void console.warn("[SIP] 手动断开,不触发重连");t=En.WEB_RTC_DISCONNECTED;const r=X.get("answerDevice");if(!lA.isRtcReconnecting&&this.reconnectAttempts<this.maxReconnectAttempts&&r===1){this.reconnectAttempts++;const i=1e3*this.reconnectAttempts;console.warn(`SIP WebSocket 断开,第 ${this.reconnectAttempts} 次尝试重连,${i}ms 后重试...`),this.reconnectTimer=setTimeout(()=>{this.reconnect()},i)}else this.reconnectAttempts>=this.maxReconnectAttempts&&console.error("SIP 重连失败:已达到最大重试次数");break}default:t="unknown"}(n=this.eventCallback)==null||n.call(this,{type:t})}),this.userAgent.delegate={onInvite:A=>{this.handleIncomingCall(A)}})}async refreshRegister(){if(this.registerer)try{await this.registerer.register(),new Date().toLocaleTimeString()}catch(A){console.error("[SIPClient] REGISTER刷新失败",A)}}async register(){var A,t;if(this.userAgent){this.registerer=new zn(this.userAgent),(A=this.registerer)==null||A.stateChange.addListener(n=>{var i;let r;switch(n){case Ge.Initial:r="initial";break;case Ge.Registered:r=En.WEB_RTC_REGISTERED;break;case Ge.Unregistered:r=En.WEB_RTC_UNREGISTERED;break;case Ge.Terminated:r=En.WEB_RTC_TERMINATED;break;default:r="unknown"}(i=this.eventCallback)==null||i.call(this,{type:r})});try{await this.registerer.register(),this.registerIntervalTimer||(this.registerIntervalTimer=setInterval(()=>{this.refreshRegister()},this.registerInterval))}catch(n){(t=this.eventCallback)==null||t.call(this,{type:En.WEB_RTC_REGISTER_FAILED,data:n})}}}attachRemoteAudio(A){const t=A.sessionDescriptionHandler;if(t){const n=t.peerConnection;if(!n)return;const r=new MediaStream;n.getReceivers().forEach(o=>{o.track&&o.track.kind==="audio"&&r.addTrack(o.track)});let i=document.getElementById("sip-remote-audio");i||(i=document.createElement("audio"),i.id="sip-remote-audio",i.autoplay=!0,i.style.display="none",document.body.appendChild(i)),i.srcObject=r,i.play().catch(o=>{console.error("音频播放失败,需要用户交互触发",o)})}}handleSessionState(A,t,n){A.stateChange.addListener(r=>{switch(r){case cA.Established:clearTimeout(this.callTimeoutTimer),this.activeSession=A,this.attachRemoteAudio(A);break;case cA.Terminating:break;case cA.Terminated:this.activeSession=null,clearTimeout(this.callTimeoutTimer);case cA.Establishing:}})}handleIncomingCall(A){this.incomingInvitation=A,this.handleSessionState(A,!1),X.get("direction")===ln.OUTGOING&&this.answerCall()}async answerCall(){var A;if(!this.incomingInvitation)throw new Error("无来电可接听");lA.autoAnswerTimer&&(clearTimeout(lA.autoAnswerTimer),lA.autoAnswerTimer=null);try{await this.incomingInvitation.accept(),this.activeSession=this.incomingInvitation,this.incomingInvitation=null}catch(t){(A=this.eventCallback)==null||A.call(this,{type:En.WEB_RTC_ANSWER_FAILED,data:{detail:t}})}}async rejectInCall(){var A;if(this.incomingInvitation)try{await this.incomingInvitation.reject(),this.incomingInvitation=null,X.updateDirection(null),X.updateIsCalling(!1),clearTimeout(this.callTimeoutTimer)}catch(t){(A=this.eventCallback)==null||A.call(this,{type:"error",data:{message:"拒接失败",detail:t}})}}sendDTMF(A){var n;if(!this.activeSession)throw new Error("当前没有活跃的通话");const t=this.activeSession.sessionDescriptionHandler;t&&typeof t.sendDtmf=="function"?(t.sendDtmf(A),(n=this.eventCallback)==null||n.call(this,{type:En.WEB_RTC_SEND_DTMF,data:{tone:A}})):console.warn("DTMF发送不支持或未初始化")}async hangup(){if(this.activeSession,this.activeSession){clearTimeout(this.callTimeoutTimer);const A=this.activeSession;if(!A)return;const t=A.state;try{t===cA.Established?await A.bye():t===cA.Establishing&&(A instanceof VC?await A.cancel():A instanceof Hu&&await A.reject()),clearTimeout(this.callTimeoutTimer)}catch(n){console.error("挂断失败",n)}finally{this.activeSession=null}}}async rejectOutCall(){this.activeSession instanceof Hu&&(await this.activeSession.reject(),this.activeSession=null)}async destroy(){if(this.isManuallyStopped=!0,clearTimeout(this.callTimeoutTimer),this.activeSession&&await this.hangup(),this.registerIntervalTimer&&(clearInterval(this.registerIntervalTimer),this.registerIntervalTimer=null),this.registerer){try{await this.registerer.unregister()}catch(A){console.warn("注销失败",A)}this.registerer=null}this.userAgent&&(await this.userAgent.stop(),this.userAgent=null)}async reconnect(){if(!lA.isRtcReconnecting){lA.isRtcReconnecting=!0;try{await this.destroy(),await this.start(),this.isOffline=!1}catch(A){console.error("重连失败",A)}finally{lA.isRtcReconnecting=!1}}}async getNetworkStats(){var A;if(this.activeSession){const t=(A=this.activeSession.sessionDescriptionHandler)==null?void 0:A.peerConnection;if(!t)return null;const n=await t.getStats(),r={};return n.forEach(i=>{i.type==="candidate-pair"&&i.state==="succeeded"&&i.currentRoundTripTime!=null&&(r.rtt=+(1e3*i.currentRoundTripTime).toFixed(2)),i.type==="inbound-rtp"&&i.kind==="audio"&&(r.jitter=+(1e3*i.jitter).toFixed(2),r.packetsLost=i.packetsLost,r.packetsReceived=i.packetsReceived,i.bytesReceived&&i.timestamp&&(r.recvBitrate=+(i.bytesReceived/1024).toFixed(2))),i.type==="outbound-rtp"&&i.kind==="audio"&&(r.packetsSent=i.packetsSent,i.bytesSent&&i.timestamp&&(r.sendBitrate=+(i.bytesSent/1024).toFixed(2))),i.type==="codec"&&i.mimeType&&(r.codec=i.mimeType)}),{...r,rtt:(r==null?void 0:r.rtt)||40}}return{rtt:lA.latency||1}}};/**
155
+ `))}startSendingKeepAlives(){this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(()=>{this.sendKeepAlive(),this.startSendingKeepAlives()},(A=>{const t=.8*A;return 1e3*(Math.random()*(A-t)+t)})(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}}Ql.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0};class ji{constructor(A={}){if(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=Rt.Stopped,this._stateEventEmitter=new ga,this.delegate=A.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ji.defaultOptions()),{sipjsId:ni(5)}),{uri:new _n("sip","anonymous."+ni(6),"anonymous.invalid")}),{viaHost:ni(12)+".invalid"}),ji.stripUndefinedProperties(A)),this.options.hackIpInContact)if(typeof this.options.hackIpInContact=="boolean"&&this.options.hackIpInContact){const r=Math.floor(Math.random()*254+1);this.options.viaHost="192.0.2."+r}else this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact);switch(this.loggerFactory=new H1,this.logger=this.loggerFactory.getLogger("sip.UserAgent"),this.loggerFactory.builtinEnabled=this.options.logBuiltinEnabled,this.loggerFactory.connector=this.options.logConnector,this.options.logLevel){case"error":this.loggerFactory.level=St.error;break;case"warn":this.loggerFactory.level=St.warn;break;case"log":this.loggerFactory.level=St.log;break;case"debug":this.loggerFactory.level=St.debug}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(t=>{const n=this.options[t];switch(t){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("· "+t+": "+n);break;case"authorizationPassword":this.logger.log("· "+t+": NOT SHOWN");break;case"transportConstructor":this.logger.log("· "+t+": "+n.name);break;default:this.logger.log("· "+t+": "+JSON.stringify(n))}})),this.options.transportOptions){const t=this.options.transportOptions,n=t.maxReconnectionAttempts,r=t.reconnectionTimeout;n!==void 0&&this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),r!==void 0&&this.logger.warn('The transport option "reconnectionTimeout" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),A.reconnectionDelay===void 0&&r!==void 0&&(this.options.reconnectionDelay=r),A.reconnectionAttempts===void 0&&n!==void 0&&(this.options.reconnectionAttempts=n)}if(A.reconnectionDelay!==void 0&&this.logger.warn('The user agent option "reconnectionDelay" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),A.reconnectionAttempts!==void 0&&this.logger.warn('The user agent option "reconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),this._transport=new this.options.transportConstructor(this.getLogger("sip.Transport"),this.options.transportOptions),this.initTransportCallbacks(),this._contact=this.initContact(),this._instanceId=this.options.instanceId?this.options.instanceId:ji.newUUID(),vt.parse(this._instanceId,"uuid")===-1)throw new Error("Invalid instanceId.");this._userAgentCore=this.initCore()}static makeURI(A){return vt.URIParse(A)}static defaultOptions(){return{allowLegacyNotifications:!1,authorizationHa1:"",authorizationPassword:"",authorizationUsername:"",delegate:{},contactName:"",contactParams:{transport:"ws"},displayName:"",forceRport:!1,gracefulShutdown:!0,hackAllowUnregisteredOptionTags:!1,hackIpInContact:!1,hackViaTcp:!1,instanceId:"",instanceIdAlwaysAdded:!1,logBuiltinEnabled:!0,logConfiguration:!0,logConnector:()=>{},logLevel:"log",noAnswerTimeout:60,preloadedRouteSet:[],reconnectionAttempts:0,reconnectionDelay:4,sendInitialProvisionalResponse:!0,sessionDescriptionHandlerFactory:uM(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:Tn.Unsupported,sipExtensionReplaces:Tn.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:Ql,transportOptions:{},uri:new _n("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/0.21.1",viaHost:""}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.floor(16*Math.random());return(t==="x"?n:n%4+8).toString(16)})}static stripUndefinedProperties(A){return Object.keys(A).reduce((t,n)=>(A[n]!==void 0&&(t[n]=A[n]),t),{})}get configuration(){return this.options}get contact(){return this._contact}get instanceId(){return this._instanceId}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get transport(){return this._transport}get userAgentCore(){return this._userAgentCore}getLogger(A,t){return this.loggerFactory.getLogger(A,t)}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===Rt.Stopped?Promise.reject(new Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}start(){return this.state===Rt.Started?(this.logger.warn("User agent already started"),Promise.resolve()):(this.logger.log(`Starting ${this.configuration.uri}`),this.transitionState(Rt.Started),this.transport.connect())}async stop(){if(this.state===Rt.Stopped)return this.logger.warn("User agent already stopped"),Promise.resolve();if(this.logger.log(`Stopping ${this.configuration.uri}`),!this.options.gracefulShutdown)return this.logger.log("Dispose of transport"),this.transport.dispose().catch(a=>{throw this.logger.error(a.message),a}),this.logger.log("Dispose of core"),this.userAgentCore.dispose(),this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this.transitionState(Rt.Stopped),Promise.resolve();const A=Object.assign({},this._publishers),t=Object.assign({},this._registerers),n=Object.assign({},this._sessions),r=Object.assign({},this._subscriptions),i=this.transport,o=this.userAgentCore;this.logger.log("Dispose of registerers");for(const a in t)t[a]&&await t[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._registerers[a],s});this.logger.log("Dispose of sessions");for(const a in n)n[a]&&await n[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._sessions[a],s});this.logger.log("Dispose of subscriptions");for(const a in r)r[a]&&await r[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._subscriptions[a],s});this.logger.log("Dispose of publishers");for(const a in A)A[a]&&await A[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._publishers[a],s});this.logger.log("Dispose of transport"),await i.dispose().catch(a=>{throw this.logger.error(a.message),a}),this.logger.log("Dispose of core"),o.dispose(),this.transitionState(Rt.Stopped)}_makeInviter(A,t){return new VC(this,A,t)}attemptReconnection(A=1){const t=this.options.reconnectionAttempts,n=this.options.reconnectionDelay;A>t?this.logger.log("Maximum reconnection attempts reached"):(this.logger.log(`Reconnection attempt ${A} of ${t} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${A} of ${t} - succeeded`)}).catch(r=>{this.logger.error(r.message),this.logger.log(`Reconnection attempt ${A} of ${t} - failed`),this.attemptReconnection(++A)})},A===1?0:1e3*n))}initContact(){const A=this.options.contactName!==""?this.options.contactName:ni(8),t=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new _n("sip",A,this.options.viaHost,void 0,t),toString:(n={})=>{const r=n.anonymous||!1,i=n.outbound||!1,o=n.register||!1;let a="<";return a+=r?this.contact.tempGruu||`sip:anonymous@anonymous.invalid;transport=${t.transport?t.transport:"ws"}`:o?this.contact.uri:this.contact.pubGruu||this.contact.uri,i&&(a+=";ob"),a+=">",this.options.instanceIdAlwaysAdded&&(a+=';+sip.instance="<urn:uuid:'+this._instanceId+'>"'),a}}}initCore(){let A=[];A.push("outbound"),this.options.sipExtension100rel===Tn.Supported&&A.push("100rel"),this.options.sipExtensionReplaces===Tn.Supported&&A.push("replaces"),this.options.sipExtensionExtraSupported&&A.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(A=A.filter(i=>j1[i])),A=Array.from(new Set(A));const t=A.slice();(this.contact.pubGruu||this.contact.tempGruu)&&t.push("gruu");const n={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:A,supportedOptionTagsResponse:t,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{const i=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,o=this.options.authorizationPassword?this.options.authorizationPassword:void 0,a=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new L1(this.getLoggerFactory(),a,i,o)},transportAccessor:()=>this.transport},r={onInvite:i=>{var o;const a=new Hu(this,i);if(i.delegate={onCancel:s=>{a._onCancel(s)},onTransportError:s=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},i.trying(),this.options.sipExtensionReplaces!==Tn.Unsupported){const s=i.message.parseHeader("replaces");if(s){const l=s.call_id;if(typeof l!="string")throw new Error("Type of call id is not string");const u=s.replaces_to_tag;if(typeof u!="string")throw new Error("Type of to tag is not string");const V=s.replaces_from_tag;if(typeof V!="string")throw new Error("type of from tag is not string");const d=l+u+V,f=this.userAgentCore.dialogs.get(d);if(!f)return void a.reject({statusCode:481});if(!f.early&&s.early_only===!0)return void a.reject({statusCode:486});const q=this._sessions[l+V]||this._sessions[l+u]||void 0;if(!q)throw new Error("Session does not exist.");a._replacee=q}}if(!((o=this.delegate)===null||o===void 0)&&o.onInvite)return a.autoSendAnInitialProvisionalResponse?void a.progress().then(()=>{var s;if(((s=this.delegate)===null||s===void 0?void 0:s.onInvite)===void 0)throw new Error("onInvite undefined.");this.delegate.onInvite(a)}):void this.delegate.onInvite(a);a.reject({statusCode:486})},onMessage:i=>{if(this.delegate&&this.delegate.onMessage){const o=new cC(i);this.delegate.onMessage(o)}else i.accept()},onNotify:i=>{if(this.delegate&&this.delegate.onNotify){const o=new ju(i);this.delegate.onNotify(o)}else this.options.allowLegacyNotifications?i.accept():i.reject({statusCode:481})},onRefer:i=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(i):i.reject({statusCode:405})},onRegister:i=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(i):i.reject({statusCode:405})},onSubscribe:i=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(i):i.reject({statusCode:405})}};return new cM(n,r)}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=A=>this.onTransportDisconnect(A),this.transport.onMessage=A=>this.onTransportMessage(A)}onTransportConnect(){this.state!==Rt.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(A){this.state!==Rt.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(A),A&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(A){const t=Bs.parseMessage(A,this.getLogger("sip.Parser"));if(!t)return void this.logger.warn("Failed to parse incoming message. Dropping.");if(this.state===Rt.Stopped&&t instanceof Ki)return void this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);const n=()=>{const r=["from","to","call_id","cseq","via"];for(const i of r)if(!t.hasHeader(i))return this.logger.warn(`Missing mandatory header field : ${i}.`),!1;return!0};if(t instanceof Ki){if(!n())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!t.toTag&&t.callId.substr(0,5)===this.options.sipjsId)return void this.userAgentCore.replyStateless(t,{statusCode:482});const r=ha(t.body),i=t.getHeader("content-length");if(i&&r<Number(i))return void this.userAgentCore.replyStateless(t,{statusCode:400})}if(t instanceof Kr){if(!n())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(t.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(t.via.host!==this.options.viaHost||t.via.port!==void 0)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");const r=ha(t.body),i=t.getHeader("content-length");if(i&&r<Number(i))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(t instanceof Ki)this.userAgentCore.receiveIncomingRequestFromTransport(t);else{if(!(t instanceof Kr))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(t)}}transitionState(A,t){const n=()=>{throw new Error(`Invalid state transition from ${this._state} to ${A}`)};switch(this._state){case Rt.Started:A!==Rt.Stopped&&n();break;case Rt.Stopped:A!==Rt.Started&&n();break;default:throw new Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${A}`),this._state=A,this._stateEventEmitter.emit(this._state)}}class mC{constructor(A){this.listeners=[],this.keyListeners={},this.data={...A},this.proxy=new Proxy(this.data,{set:(t,n,r)=>(t[n]!==r&&(t[n]=r,this.notify(),this.notifyKey(n,r)),!0)})}getState(){return this.proxy}setState(A,t=!1){let n=!1;for(const r in A)if(Object.prototype.hasOwnProperty.call(A,r)){const i=this.data[r],o=A[r];(t||i!==o)&&(this.data[r]=o,n=!0,this.notifyKey(r,o))}(n||t)&&this.notify()}subscribe(A){return this.listeners.push(A),()=>{this.listeners=this.listeners.filter(t=>t!==A)}}subscribeKey(A,t){return this.keyListeners[A]||(this.keyListeners[A]=[]),this.keyListeners[A].push(t),()=>{this.keyListeners[A]=this.keyListeners[A].filter(n=>n!==t)}}notify(){const A=this.getState();for(const t of this.listeners)t(A)}notifyKey(A,t){const n=this.keyListeners[A];n&&n.forEach(r=>r(t))}}var ye,ln,fe,En,fA,ae,nt;(function(e){e[e.IDLE=1]="IDLE",e[e.BUSY=2]="BUSY",e[e.RINGING=3]="RINGING",e[e.OFFLINE=0]="OFFLINE",e[e.UNREGISTERED=4]="UNREGISTERED"})(ye||(ye={})),function(e){e.OUTGOING="outgoing",e.INCOMING="incoming",e.CONSULT="consult",e.MEETING="meeting",e.TRANSFER="transfer",e.PREDICT_OUT_CALL="predict_out_call"}(ln||(ln={})),function(e){e[e.OUT_CALL=100]="OUT_CALL",e[e.AGENT_STATE=101]="AGENT_STATE",e[e.OUT_CALL_INCOMING_CALL=102]="OUT_CALL_INCOMING_CALL",e[e.OUT_CALL_RINGING=103]="OUT_CALL_RINGING",e[e.OUT_CALL_ANSWER=104]="OUT_CALL_ANSWER",e[e.CALL_HOLD=105]="CALL_HOLD",e[e.CALL_UNHOLD=106]="CALL_UNHOLD",e[e.OUT_CALL_END=107]="OUT_CALL_END",e[e.CONSULT_REQUEST=108]="CONSULT_REQUEST",e[e.CONSULT_RINGING=109]="CONSULT_RINGING",e[e.CONSULT_ANSWER=110]="CONSULT_ANSWER",e[e.CONSULT_FAIL=111]="CONSULT_FAIL",e[e.MUTE=112]="MUTE",e[e.UNMUTE=113]="UNMUTE",e[e.CONSULT_CALL_IN=114]="CONSULT_CALL_IN",e[e.CONSULT_CALL_IN_SUCCESS=115]="CONSULT_CALL_IN_SUCCESS",e[e.CONSULT_RETURN_CALL=125]="CONSULT_RETURN_CALL",e[e.CONSULT_RETURN_CALL_SUCCESS=126]="CONSULT_RETURN_CALL_SUCCESS",e[e.CONSULT_TRANSFER=116]="CONSULT_TRANSFER",e[e.CONSULT_TRANSFER_FAILED=118]="CONSULT_TRANSFER_FAILED",e[e.CONSULT_TRANSFER_OFF_HOOK=117]="CONSULT_TRANSFER_OFF_HOOK",e[e.INCOMING_CALL=119]="INCOMING_CALL",e[e.INCOMING_CALL_OFF_HOOK=120]="INCOMING_CALL_OFF_HOOK",e[e.INCOMING_CALL_END=121]="INCOMING_CALL_END",e[e.SATISFACTION_EVALUATION=122]="SATISFACTION_EVALUATION",e[e.CONSULT_THREE_WAY=123]="CONSULT_THREE_WAY",e[e.CONSULT_THREE_WAY_RESULT=124]="CONSULT_THREE_WAY_RESULT",e[e.TRANSFER=127]="TRANSFER",e[e.TRANSFER_FAILED=128]="TRANSFER_FAILED",e[e.TRANSFER_INCOMING_CALL=129]="TRANSFER_INCOMING_CALL",e[e.TRANSFER_OFF_HOOK=130]="TRANSFER_OFF_HOOK",e[e.AGENT_HANGUP=131]="AGENT_HANGUP",e[e.KICK_OFFLINE=132]="KICK_OFFLINE",e[e.CONTINUOUS_NOT_ANSWER=133]="CONTINUOUS_NOT_ANSWER",e[e.PREVIEW_OUT_CALL=134]="PREVIEW_OUT_CALL"}(fe||(fe={})),function(e){e.WEB_RTC_CONNECTING="connecting",e.WEB_RTC_CONNECTED="connected",e.WEB_RTC_DISCONNECTING="disconnecting",e.WEB_RTC_DISCONNECTED="disconnected",e.WEB_RTC_REGISTERED="registered",e.WEB_RTC_UNREGISTERED="unregistered",e.WEB_RTC_TERMINATED="terminated",e.WEB_RTC_REGISTER_FAILED="register_failed",e.WEB_RTC_ANSWER_FAILED="answer_failed",e.WEB_RTC_SEND_DTMF="send_dtmf"}(En||(En={})),function(e){e.CUSTOMER_INFO="customer_info",e.CALL_PROGRESS="call_progress",e.OUT_INCOMING_CALL="out_call_incoming_call",e.PREVIEW_OUT_INCOMING_CALL="preview_out_incoming_call",e.OUT_SUCCESS="out_call_success",e.OUT_FAILED="out_call_failed",e.OUT_RINGING="out_call_ringing",e.OUT_OFF_ANSWER="out_call_answer",e.HOLD_SUCCESS="hold_success",e.HOLD_FAILED="hold_failed",e.UNHOLD_SUCCESS="unhold_success",e.UNHOLD_FAILED="unhold_failed",e.OUT_HANGUP="out_call_hangup",e.CONSULT_RINGING="consult_ringing",e.CONSULT_OFF_HOOK="consult_off_hook",e.CONSULT_FAILED="consult_failed",e.CONSULT_INCOMING="consult_incoming",e.CONSULT_CALL_IN_SUCCESS="consult_call_in_success",e.CONSULT_RETURN_CALL_SUCCESS="consult_return_call_success",e.OTHER_SIDE_CONSULT_HANGUP="other_side_consult_hangup",e.OUR_SIDE_CONSULT_HANGUP="our_side_consult_hangup",e.AGENT_STATE="agent_state",e.MUTE_SUCCESS="mute_success",e.MUTE_FAILED="mute_failed",e.UNMUTE_SUCCESS="unmute_success",e.UNMUTE_FAILED="unmute_failed",e.CONSULT_TRANSFER_SUCCESS="consult_transfer_success",e.CONSULT_TRANSFER_FAILED="consult_transfer_failed",e.CONSULT_TRANSFER_OFF_HOOK="consult_transfer_off_hook",e.INCOMING_CALL="incoming_call",e.PREDICT_INCOMING_CALL="predict_incoming_call",e.INCOMING_CALL_OFF_HOOK="incoming_call_off_hook",e.INCOMING_CALL_END="incoming_call_end",e.SATISFACTION_EVALUATION_SUCCESS="satisfaction_evaluation_success",e.SATISFACTION_EVALUATION_FAILED="satisfaction_evaluation_failed",e.CONSULT_THREE_WAY_SUCCESS="consult_three_way_success",e.CONSULT_THREE_WAY_FAILED="consult_three_way_failed",e.THREE_WAY_OUR_SIDE_HANGUP="three_way_our_side_hangup",e.TRANSFER_FAILED="transfer_failed",e.TRANSFER_PROGRESS="transfer_progress",e.TRANSFER_INCOMING_CALL="transfer_incoming_call",e.TRANSFER_OFF_HOOK="transfer_off_hook",e.TRANSFER_END="transfer_end",e.REJECT="reject"}(fA||(fA={})),function(e){e.EVENT_ALL="event_all",e.NOTIFICATION_CLICK="notification_click",e.UPDATE_ANSWER_DEVICE="update_answer_device",e.PHONE_BAR_OPERATION="phone_bar_operation",e.AGENT_INIT_STATUS="agent_init_status",e.WEBSITE_DELAY="website_delay",e.SELECT_EXTERNAL_NUMBER="select_external_number",e.FAIL_NOTIFICATION="fail_notification",e.KICK_OFF="kick_off",e.DESTROY="destroy",e.NETWORK_OFFLINE="network_offline",e.NETWORK_ONLINE="network_online"}(ae||(ae={})),function(e){e.RINGING="客户振铃",e.AGENT_RINGING="振铃中",e.CALLING="通话中",e.CONSULTING="正在咨询",e.CONSULT_CALL_IN="咨询来电",e.INCOMING_CALL="客户来电",e.MEETING="会议中",e.TRANSFERRING="转接中",e.TRANSFER_INCOMING_CALL="转接来电",e.HOLDING="保持中",e.MUTING="静音中"}(nt||(nt={}));const Fo=function(e){return{all:e=e||new Map,on:function(A,t){var n=e.get(A);n?n.push(t):e.set(A,[t])},off:function(A,t){var n=e.get(A);n&&(t?n.splice(n.indexOf(t)>>>0,1):e.set(A,[]))},emit:function(A,t){var n=e.get(A);n&&n.slice().map(function(r){r(t)}),(n=e.get("*"))&&n.slice().map(function(r){r(A,t)})}}}(),vA={on:(e,A)=>(Fo.on(e,A),vA),off(e,A){Fo.off(e,A)},emit(e,A){Fo.emit(e,A),Fo.emit(ae.EVENT_ALL,{event:e,data:A})},clearAllListeners(){Fo.all.clear()}},lA={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null,autoAnswerTimer:null,logBuiltinEnabled:!1,browserAlertTime:3e3,latency:0},mn={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,transferIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1,selectOutNumber:"",customerObject:void 0,isNextState:!0},X=new class extends mC{updateIsCalling(e){this.setState({isCalling:e})}updateDirection(e){this.setState({direction:e})}updateOutCallIsAnswer(e){this.setState({outCallIsAnswer:e})}updateIsHold(e){var t;if(((t=lA.stateObject)==null?void 0:t.state)===ye.UNREGISTERED)return;const A=this.get("actionConfigs");if(e){const n=[...A.filter(r=>r!=="hold")];n.push("unhold"),this.updateActionConfigs(n)}else{const n=[...A.filter(r=>r!=="unhold")];n.push("hold"),this.updateActionConfigs(n)}this.getState().isHold=e}updateDisplayText(e){this.setState({displayText:e}),vA.emit(fA.CALL_PROGRESS,e)}updateActionConfigs(e){const{show_satisfaction:A}=lA.agentInfo||{},t=this.get("answerDevice"),n=e.filter(r=>(A!==0||r!=="satisfaction")&&(t!==2||r!=="answer"));this.setState({actionConfigs:n}),vA.emit(ae.PHONE_BAR_OPERATION,n)}updateConsultIsAnswer(e){this.setState({consultIsAnswer:e})}updateIsMuted(e){var t;if(((t=lA.stateObject)==null?void 0:t.state)===ye.UNREGISTERED)return;const A=this.get("actionConfigs");if(e){const n=[...A.filter(r=>r!=="mute")];n.push("unmute"),this.updateActionConfigs(n)}else{const n=[...A.filter(r=>r!=="unmute")];n.push("mute"),this.updateActionConfigs(n)}this.setState({isMuted:e})}updateIncomingIsAnswer(e){this.setState({incomingIsAnswer:e})}updateAnswerDevice(e){this.setState({answerDevice:e}),vA.emit(ae.UPDATE_ANSWER_DEVICE,e)}updateIsMeeting(e){this.setState({isMeeting:e})}updateTransferIsAnswer(e){this.setState({transferIsAnswer:e})}updateSelectOutNumber(e){vA.emit(ae.SELECT_EXTERNAL_NUMBER,e),this.setState({selectOutNumber:e})}updateCustomerInfo(e){const A=this.get("displayText");if(e&&A){const{contact_count:t,customer_name:n,phone:r,city:i,province:o,is_vip:a,in_contact_count:s,trace_id:l}=e;vA.emit(fA.CUSTOMER_INFO,{customer_name:n||"未知客户",phone:r,city:i||"未知",province:o||"未知",contact_count:t||0,in_contact_count:s||0,is_vip:a,trace_id:l})}else vA.emit(fA.CUSTOMER_INFO,void 0);this.setState({customerObject:e})}updateIsNextState(e){this.setState({isNextState:e}),e?vA.emit(ae.NETWORK_ONLINE):(lA.stateObject={state:ye.OFFLINE,state_name:"离线"},this.updateActionConfigs([]),vA.emit(fA.AGENT_STATE,lA.stateObject),vA.emit(ae.NETWORK_OFFLINE))}reset(){this.updateIsCalling(mn.isCalling),this.updateDirection(mn.direction),this.updateOutCallIsAnswer(mn.outCallIsAnswer),this.updateIsHold(mn.isHold),this.updateDisplayText(mn.displayText),this.updateActionConfigs(mn.actionConfigs),this.updateConsultIsAnswer(mn.consultIsAnswer),this.updateIsMuted(mn.isMuted),this.updateIncomingIsAnswer(mn.incomingIsAnswer),this.updateIsMeeting(mn.isMeeting),this.updateTransferIsAnswer(mn.transferIsAnswer),this.updateCustomerInfo(void 0)}getCallInfo(){return this.getState()}get(e){return this.getState()[e]}}(mn),xd=new class extends mC{updateRttObject(e){this.setState({rttObject:e}),vA.emit(ae.WEBSITE_DELAY,e)}}({rttObject:{rtt:null,jitter:null,packetsLost:null,packetsReceived:null,packetsSent:null,sendBitrate:null,recvBitrate:null,codec:null}});let VM=class{constructor(A,t){this.config=A,this.eventCallback=t,this.userAgent=null,this.registerer=null,this.activeSession=null,this.callTimeoutTimer=null,this.incomingInvitation=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectTimer=null,this.isOffline=!1,this.isManuallyStopped=!1,this.registerIntervalTimer=null,this.registerInterval=6e4,this.handleNetworkInfoChange=n=>{var r,i;(r=n.rttObject)!=null&&r.rtt&&((((i=n.rttObject)==null?void 0:i.rtt)||0)===0?this.isOffline||(this.isOffline=!0,this.handleOffline()):this.isOffline&&(this.isOffline=!1,this.handleOnline()))},this.handleOffline=()=>{console.warn("[SIPClient] 网络断开,准备销毁 SIP 客户端",new Date().toLocaleString()),this.destroy()},this.handleOnline=()=>{console.warn("[SIPClient] 网络恢复,准备重新启动 SIP 客户端",new Date().toLocaleString()),this.reconnect()},xd.subscribe(this.handleNetworkInfoChange)}async start(){const A=ji.makeURI(`sip:${this.config.user}@${this.config.server}`);if(!A)throw new Error("无效的SIP配置");const t={uri:A,authorizationUsername:this.config.user,authorizationPassword:this.config.password,transportOptions:{server:this.config.webSocket,connectionTimeout:30,keepAliveInterval:0},contactName:this.config.user,contactParams:{transport:"wss"},userAgentString:"SwiftSIP/1.0.74",sessionDescriptionHandlerFactoryOptions:{alwaysAcquireMediaFirst:!0,peerConnectionConfiguration:{iceServers:[]},iceGatheringTimeout:500},logBuiltinEnabled:lA.logBuiltinEnabled};this.userAgent=new ji(t),this.setupEventListeners(),await this.userAgent.start(),await this.register()}setupEventListeners(){this.userAgent&&(this.userAgent.transport.stateChange.addListener(A=>{var n;let t;switch(A){case Ve.Connecting:t=En.WEB_RTC_CONNECTING;break;case Ve.Connected:t=En.WEB_RTC_CONNECTED,this.reconnectAttempts=0,lA.isRtcReconnecting=!1,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);break;case Ve.Disconnecting:t=En.WEB_RTC_DISCONNECTING;break;case Ve.Disconnected:{if(this.isManuallyStopped)return void console.warn("[SIP] 手动断开,不触发重连");t=En.WEB_RTC_DISCONNECTED;const r=X.get("answerDevice");if(!lA.isRtcReconnecting&&this.reconnectAttempts<this.maxReconnectAttempts&&r===1){this.reconnectAttempts++;const i=1e3*this.reconnectAttempts;console.warn(`SIP WebSocket 断开,第 ${this.reconnectAttempts} 次尝试重连,${i}ms 后重试...`),this.reconnectTimer=setTimeout(()=>{this.reconnect()},i)}else this.reconnectAttempts>=this.maxReconnectAttempts&&console.error("SIP 重连失败:已达到最大重试次数");break}default:t="unknown"}(n=this.eventCallback)==null||n.call(this,{type:t})}),this.userAgent.delegate={onInvite:A=>{this.handleIncomingCall(A)}})}async refreshRegister(){if(this.registerer)try{await this.registerer.register(),new Date().toLocaleTimeString()}catch(A){console.error("[SIPClient] REGISTER刷新失败",A)}}async register(){var A,t;if(this.userAgent){this.registerer=new zn(this.userAgent),(A=this.registerer)==null||A.stateChange.addListener(n=>{var i;let r;switch(n){case Ge.Initial:r="initial";break;case Ge.Registered:r=En.WEB_RTC_REGISTERED;break;case Ge.Unregistered:r=En.WEB_RTC_UNREGISTERED;break;case Ge.Terminated:r=En.WEB_RTC_TERMINATED;break;default:r="unknown"}(i=this.eventCallback)==null||i.call(this,{type:r})});try{await this.registerer.register(),this.registerIntervalTimer||(this.registerIntervalTimer=setInterval(()=>{this.refreshRegister()},this.registerInterval))}catch(n){(t=this.eventCallback)==null||t.call(this,{type:En.WEB_RTC_REGISTER_FAILED,data:n})}}}attachRemoteAudio(A){const t=A.sessionDescriptionHandler;if(t){const n=t.peerConnection;if(!n)return;const r=new MediaStream;n.getReceivers().forEach(o=>{o.track&&o.track.kind==="audio"&&r.addTrack(o.track)});let i=document.getElementById("sip-remote-audio");i||(i=document.createElement("audio"),i.id="sip-remote-audio",i.autoplay=!0,i.style.display="none",document.body.appendChild(i)),i.srcObject=r,i.play().catch(o=>{console.error("音频播放失败,需要用户交互触发",o)})}}handleSessionState(A,t,n){A.stateChange.addListener(r=>{switch(r){case cA.Established:clearTimeout(this.callTimeoutTimer),this.activeSession=A,this.attachRemoteAudio(A);break;case cA.Terminating:break;case cA.Terminated:this.activeSession=null,clearTimeout(this.callTimeoutTimer);case cA.Establishing:}})}handleIncomingCall(A){this.incomingInvitation=A,this.handleSessionState(A,!1),X.get("direction")===ln.OUTGOING&&this.answerCall()}async answerCall(){var A;if(!this.incomingInvitation)throw new Error("无来电可接听");lA.autoAnswerTimer&&(clearTimeout(lA.autoAnswerTimer),lA.autoAnswerTimer=null);try{await this.incomingInvitation.accept(),this.activeSession=this.incomingInvitation,this.incomingInvitation=null}catch(t){(A=this.eventCallback)==null||A.call(this,{type:En.WEB_RTC_ANSWER_FAILED,data:{detail:t}})}}async rejectInCall(){var A;if(this.incomingInvitation)try{await this.incomingInvitation.reject(),this.incomingInvitation=null,X.updateDirection(null),X.updateIsCalling(!1),clearTimeout(this.callTimeoutTimer)}catch(t){(A=this.eventCallback)==null||A.call(this,{type:"error",data:{message:"拒接失败",detail:t}})}}sendDTMF(A){var n;if(!this.activeSession)throw new Error("当前没有活跃的通话");const t=this.activeSession.sessionDescriptionHandler;t&&typeof t.sendDtmf=="function"?(t.sendDtmf(A),(n=this.eventCallback)==null||n.call(this,{type:En.WEB_RTC_SEND_DTMF,data:{tone:A}})):console.warn("DTMF发送不支持或未初始化")}async hangup(){if(this.activeSession,this.activeSession){clearTimeout(this.callTimeoutTimer);const A=this.activeSession;if(!A)return;const t=A.state;try{t===cA.Established?await A.bye():t===cA.Establishing&&(A instanceof VC?await A.cancel():A instanceof Hu&&await A.reject()),clearTimeout(this.callTimeoutTimer)}catch(n){console.error("挂断失败",n)}finally{this.activeSession=null}}}async rejectOutCall(){this.activeSession instanceof Hu&&(await this.activeSession.reject(),this.activeSession=null)}async destroy(){if(this.isManuallyStopped=!0,clearTimeout(this.callTimeoutTimer),this.activeSession&&await this.hangup(),this.registerIntervalTimer&&(clearInterval(this.registerIntervalTimer),this.registerIntervalTimer=null),this.registerer){try{await this.registerer.unregister()}catch(A){console.warn("注销失败",A)}this.registerer=null}this.userAgent&&(await this.userAgent.stop(),this.userAgent=null)}async reconnect(){if(!lA.isRtcReconnecting){lA.isRtcReconnecting=!0;try{await this.destroy(),await this.start(),this.isOffline=!1}catch(A){console.error("重连失败",A)}finally{lA.isRtcReconnecting=!1}}}async getNetworkStats(){var A;if(this.activeSession){const t=(A=this.activeSession.sessionDescriptionHandler)==null?void 0:A.peerConnection;if(!t)return null;const n=await t.getStats(),r={};return n.forEach(i=>{i.type==="candidate-pair"&&i.state==="succeeded"&&i.currentRoundTripTime!=null&&(r.rtt=+(1e3*i.currentRoundTripTime).toFixed(2)),i.type==="inbound-rtp"&&i.kind==="audio"&&(r.jitter=+(1e3*i.jitter).toFixed(2),r.packetsLost=i.packetsLost,r.packetsReceived=i.packetsReceived,i.bytesReceived&&i.timestamp&&(r.recvBitrate=+(i.bytesReceived/1024).toFixed(2))),i.type==="outbound-rtp"&&i.kind==="audio"&&(r.packetsSent=i.packetsSent,i.bytesSent&&i.timestamp&&(r.sendBitrate=+(i.bytesSent/1024).toFixed(2))),i.type==="codec"&&i.mimeType&&(r.codec=i.mimeType)}),{...r,rtt:(r==null?void 0:r.rtt)||40}}return{rtt:lA.latency||1}}};/**
156
156
  * @license
157
157
  * Copyright 2019 Google LLC
158
158
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1053,7 +1053,7 @@ React keys must be passed directly to JSX without using spread:
1053
1053
  `:""}
1054
1054
  </div>
1055
1055
  </my-popover>
1056
- `;Ai(r,this.rttHTML)}}class $o{static requestPermission(){"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}static async requestMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(t=>t.kind==="audioinput"&&t.label!=="")?null:await navigator.mediaDevices.getUserMedia({audio:!0})}catch(A){return console.warn("获取音频权限失败:",A),null}}static show(A,t,n,r){if("Notification"in window&&Notification.permission==="granted"){const i=new Notification(A,{body:t,tag:`xy-global-notification${new Date().getTime()}`,renotify:!0});i.onclick=()=>{window.focus(),i.close(),n==null||n()},setTimeout(()=>i.close(),1e3*(r||3))}}static async checkMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(A=>A.kind==="audioinput"&&A.label!=="")}catch(A){return console.warn("无法检查设备权限:",A),!1}}}const $M=console.log,jh=(...e)=>{lA.logBuiltinEnabled&&$M(...e)};let sr=null;class ct{constructor(A){this.url=A,this.ws=null,this.heartbeatWorker=null,this.reconnectDelay=3e3,this.manualClose=!1,this.apiClient=new Gd,this.sipClient=null,this.pendingMessages=new Map,this.initWebSocket()}static getInstance({url:A,sipClient:t}){if(!sr){if(!A)throw new Error("WebSocket 尚未初始化");sr=new ct(A),sr.sipClient=t}return sr}stateIdleChange(){const{state:A}=lA.stateObject;A!==ye.IDLE&&this.apiClient._changeState({data:{...lA.stateBeforeChange,state_name:lA.stateBeforeChange.state===ye.IDLE?"空闲":"忙碌"}})}inCallAutoAnswer(){const{soft_device_auto_answer:A,auto_answer_time:t}=lA.agentInfo,n=A===1,r=X.get("direction");if(n&&r===ln.INCOMING){const i=Number(t)||0;i>0&&(lA.autoAnswerTimer=setTimeout(()=>{var o;(o=this.sipClient)==null||o.answerCall(),lA.autoAnswerTimer=null},1e3*i))}}async getCustomerInfo(A){try{await this.apiClient._getInCallCrmDetail({data:{phone:A},success:t=>{X.updateCustomerInfo(t.data||{phone:t.data.phone,is_vip:0,customer_name:"未知客户",city:"未知",province:"未知",contact_count:0,in_contact_count:0,trace_id:t.data.trace_id})}})}catch{}}putAgentState(A){if(!A)return;lA.sessionId="";const{post_call_process_time:t}=lA.agentInfo,n=t||0;if(lA.autoStateTimer&&(clearTimeout(lA.autoStateTimer),lA.autoStateTimer=null),X.updateCustomerInfo(void 0),n>0){const{state:r}=lA.stateObject;if(r===ye.IDLE)return;this.apiClient._changeState({data:{state:ye.BUSY,state_name:"整理"}}),lA.autoStateTimer=setTimeout(()=>{lA.autoStateTimer=null,this.stateIdleChange()},1e3*n)}else this.stateIdleChange()}stateBusyChange(){lA.sessionId="",clearTimeout(lA.autoStateTimer),X.updateCustomerInfo(void 0),this.apiClient._changeState({data:{state:ye.BUSY,state_name:"忙碌"}})}initWebSocket(){var t;if(((t=this.ws)==null?void 0:t.readyState)===1)return;const A=RC(Ud,kd);this.ws=new WebSocket(this.url+A),this.ws.onopen=()=>{const n=new Date().getTime();this.sendMessage({type:0,msg_id:n}),this.pendingMessages.set(n,performance.now()),this.startHeartbeat(),this.manualClose=!1},this.ws.onmessage=async n=>{const r=JSON.parse(n.data),{type:i,data:o,code:a,msg:s,msg_id:l}=r;if(i===0&&l){const u=this.pendingMessages.get(l),V=performance.now()-u;lA.latency=parseFloat(V.toFixed(2)),this.pendingMessages.delete(l)}if(i!==0&&jh("%cWebSocket 收到消息:","color: blue; font-weight: bold;",r),i!==fe.OUT_CALL&&i!==fe.PREVIEW_OUT_CALL||(a!==0?(X.reset(),vA.emit(fA.OUT_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s),X.updateActionConfigs(In),setTimeout(()=>{X.updateCustomerInfo(void 0)},500),this.stateIdleChange()):a===0&&(vA.emit(fA.OUT_SUCCESS),clearTimeout(lA.autoStateTimer))),i===fe.AGENT_STATE){const{state:u,state_name:V}=o;lA.stateObject={state:u,state_name:V},V==="振铃中"&&X.updateDisplayText(nt.AGENT_RINGING),u===ye.UNREGISTERED&&X.updateActionConfigs(BM),vA.emit(fA.AGENT_STATE,{state:u,state_name:V})}if(i===fe.OUT_CALL_INCOMING_CALL){try{await this.getCustomerInfo(o.trace_id||o.customer_phone)}catch(u){console.error(u)}o.preview_task_id?vA.emit(fA.PREVIEW_OUT_INCOMING_CALL,{customer_phone:o.customer_phone,session_id:o.session_id,preview_task_id:o.preview_task_id,trace_id:o.trace_id}):vA.emit(fA.OUT_INCOMING_CALL,{customer_phone:o.customer_phone,session_id:o.session_id,trace_id:o.trace_id}),lA.sessionId=o.session_id,X.updateActionConfigs(QM)}if(i===fe.OUT_CALL_END&&(X.updateDisplayText(""),o.device_type===1&&o.agent_no===lA.agentInfo.agent_no?(this.putAgentState(!0),X.reset(),vA.emit(fA.OUT_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(In)):o.device_type===2&&o.agent_no===lA.agentInfo.agent_no?(X.reset(),vA.emit(fA.OUR_SIDE_CONSULT_HANGUP,{session_id:o.session_id}),this.putAgentState(!0),X.updateActionConfigs(In)):o.device_type===2&&o.agent_no!==lA.agentInfo.agent_no?(X.updateDisplayText(nt.CALLING),vA.emit(fA.OTHER_SIDE_CONSULT_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(yi)):o.device_type===3&&o.agent_no===lA.agentInfo.agent_no?(this.putAgentState(!0),X.reset(),vA.emit(fA.THREE_WAY_OUR_SIDE_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(In)):o.device_type===4&&o.agent_no===lA.agentInfo.agent_no&&(this.putAgentState(!0),X.reset(),vA.emit(fA.TRANSFER_END,{session_id:o.session_id}),X.updateActionConfigs(In))),i===fe.OUT_CALL_RINGING&&o.type===1&&(vA.emit(fA.OUT_RINGING,{session_id:lA.sessionId,type:o.type}),X.updateDisplayText(nt.RINGING)),i===fe.OUT_CALL_ANSWER&&(clearTimeout(lA.autoStateTimer),X.updateIsCalling(!0),vA.emit(fA.OUT_OFF_ANSWER,{session_id:lA.sessionId}),X.updateOutCallIsAnswer(!0),X.updateDisplayText(nt.CALLING),X.updateActionConfigs(yi)),i===fe.CONSULT_RINGING&&(vA.emit(fA.CONSULT_RINGING,{session_id:o.session_id}),X.updateDisplayText(nt.AGENT_RINGING),X.updateActionConfigs([]),clearTimeout(lA.autoStateTimer)),i===fe.CONSULT_ANSWER&&(vA.emit(fA.CONSULT_OFF_HOOK,{session_id:o.session_id}),X.updateConsultIsAnswer(!0),X.updateDisplayText(nt.CONSULTING),X.updateActionConfigs(bM)),i===fe.CONSULT_FAIL&&(vA.emit(fA.CONSULT_FAILED,{custom_reason:o.custom_reason}),X.updateDisplayText(nt.CALLING),X.updateActionConfigs(yi)),i===fe.CONSULT_CALL_IN&&(vA.emit(fA.CONSULT_INCOMING,{agent_no:o.agent_no,agent_mane:o.agent_name,session_id:o.session_id}),lA.sessionId=o.session_id,X.updateIsCalling(!0),X.updateDirection(ln.CONSULT),X.updateDisplayText(nt.CONSULT_CALL_IN),X.updateActionConfigs(Oc),lA.enableBrowserAlert&&$o.show("📞 咨询来电",`坐席 [${o.agent_name}] 正在咨询...`,()=>{vA.emit(ae.NOTIFICATION_CLICK,{agent_mane:o.agent_name,agent_no:o.agent_no})},lA.browserAlertTime)),i===fe.CONSULT_CALL_IN_SUCCESS&&(vA.emit(fA.CONSULT_CALL_IN_SUCCESS,{session_id:o.session_id}),X.updateConsultIsAnswer(!0),X.updateDisplayText(nt.CALLING),X.updateActionConfigs(RM)),i===fe.CONSULT_RETURN_CALL_SUCCESS&&(o.status==="success"?(X.updateConsultIsAnswer(!1),vA.emit(fA.CONSULT_RETURN_CALL_SUCCESS),X.updateDisplayText(nt.CALLING),vA.emit(fA.OTHER_SIDE_CONSULT_HANGUP),X.updateActionConfigs(yi)):vA.emit(ae.FAIL_NOTIFICATION,"媒体失败")),i===fe.MUTE&&(a===0?(X.updateIsMuted(!0),vA.emit(fA.MUTE_SUCCESS),X.updateDisplayText(nt.MUTING)):(vA.emit(fA.MUTE_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.UNMUTE&&(a===0?(X.updateIsMuted(!1),vA.emit(fA.UNMUTE_SUCCESS),X.updateDisplayText(nt.CALLING)):(vA.emit(fA.UNMUTE_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CALL_HOLD&&(a===0?(X.updateIsHold(!0),X.updateDisplayText(nt.HOLDING),vA.emit(fA.HOLD_SUCCESS)):(vA.emit(fA.HOLD_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CALL_UNHOLD&&(a===0?(X.updateDisplayText(nt.CALLING),X.updateIsHold(!1),vA.emit(fA.UNHOLD_SUCCESS)):(vA.emit(fA.UNHOLD_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CONSULT_TRANSFER&&(a===0?vA.emit(fA.CONSULT_TRANSFER_SUCCESS):(vA.emit(fA.CONSULT_TRANSFER_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CONSULT_TRANSFER_FAILED&&vA.emit(fA.CONSULT_TRANSFER_FAILED,o.status),i===fe.CONSULT_TRANSFER_OFF_HOOK&&(X.updateDirection(ln.INCOMING),X.updateDisplayText(nt.CALLING),vA.emit(fA.CONSULT_TRANSFER_OFF_HOOK),X.updateActionConfigs(ns),X.updateIncomingIsAnswer(!0),X.updateConsultIsAnswer(!1)),i===fe.INCOMING_CALL){clearTimeout(lA.autoStateTimer),lA.sessionId=o.session_id;try{await this.getCustomerInfo(o.trace_id||o.customer_phone)}catch(u){console.error(u)}X.updateIsCalling(!0),X.updateDirection(ln.INCOMING),this.inCallAutoAnswer(),X.updateDisplayText(nt.INCOMING_CALL),o.direction===1&&vA.emit(fA.INCOMING_CALL,{customer_phone:o.customer_phone,trace_id:o.trace_id,session_id:o.session_id}),o.direction===3&&vA.emit(fA.PREDICT_INCOMING_CALL,{customer_phone:o.customer_phone,trace_id:o.trace_id,session_id:o.session_id}),X.updateActionConfigs(Oc),lA.enableBrowserAlert&&$o.show("📞 客户来电",`客户 [${o.customer_phone}] 正在呼入...`,()=>{vA.emit(ae.NOTIFICATION_CLICK,{customer_phone:o.customer_phone})},lA.browserAlertTime)}if(i===fe.INCOMING_CALL_OFF_HOOK&&(X.updateIncomingIsAnswer(!0),vA.emit(fA.INCOMING_CALL_OFF_HOOK,{session_id:lA.sessionId}),X.updateActionConfigs(ns),X.updateDisplayText(nt.CALLING)),i===fe.INCOMING_CALL_END&&(X.updateDisplayText(""),o.device_type===1&&o.agent_no===lA.agentInfo.agent_no?(this.putAgentState(!0),X.reset(),vA.emit(fA.INCOMING_CALL_END,{session_id:o.session_id}),X.updateActionConfigs(In)):o.device_type===2&&o.agent_no===lA.agentInfo.agent_no?(X.reset(),vA.emit(fA.OUR_SIDE_CONSULT_HANGUP,{session_id:o.session_id}),this.putAgentState(!0),X.updateActionConfigs(In)):o.device_type===2&&o.agent_no!==lA.agentInfo.agent_no?(X.updateDisplayText(nt.CALLING),vA.emit(fA.OTHER_SIDE_CONSULT_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(yi)):o.device_type===3&&o.agent_no===lA.agentInfo.agent_no?(this.putAgentState(!0),X.reset(),vA.emit(fA.THREE_WAY_OUR_SIDE_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(In)):o.device_type===4&&o.agent_no===lA.agentInfo.agent_no&&(this.putAgentState(!0),X.reset(),vA.emit(fA.TRANSFER_END,{session_id:o.session_id}),X.updateActionConfigs(In))),i===fe.SATISFACTION_EVALUATION&&(a===0?vA.emit(fA.SATISFACTION_EVALUATION_SUCCESS):(vA.emit(fA.SATISFACTION_EVALUATION_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CONSULT_THREE_WAY&&(a!==0?(vA.emit(fA.CONSULT_THREE_WAY_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s)):a===0&&X.updateIsMeeting(!0)),i===fe.CONSULT_THREE_WAY_RESULT&&(o.status==="success"?(X.updateDirection(ln.MEETING),X.updateDisplayText(nt.MEETING),X.updateActionConfigs(xM),vA.emit(fA.CONSULT_THREE_WAY_SUCCESS)):(vA.emit(fA.CONSULT_THREE_WAY_FAILED,{conf_name:o.conf_name}),X.updateIsMeeting(!1))),i===fe.TRANSFER_INCOMING_CALL&&(clearTimeout(lA.autoStateTimer),o.agent_no===lA.agentInfo.agent_no?(X.updateDisplayText(nt.TRANSFERRING),vA.emit(fA.TRANSFER_PROGRESS),X.updateActionConfigs([]),X.updateTransferIsAnswer(!0)):(lA.sessionId=o.session_id,vA.emit(fA.TRANSFER_INCOMING_CALL,{agent_no:o.agent_no,agent_name:o.agent_name,session_id:o.session_id}),X.updateIsCalling(!0),X.updateDirection(ln.TRANSFER),X.updateDisplayText(nt.TRANSFER_INCOMING_CALL),X.updateActionConfigs(Oc),lA.enableBrowserAlert&&$o.show("📞 转接来电",`坐席 [${o.agent_no}] 正在转接...`,()=>{vA.emit(ae.NOTIFICATION_CLICK,{agent_no:o.agent_no})},lA.browserAlertTime))),i===fe.TRANSFER_OFF_HOOK&&(vA.emit(fA.TRANSFER_OFF_HOOK,{session_id:lA.sessionId}),X.updateTransferIsAnswer(!1),X.updateDisplayText(nt.CALLING),X.updateActionConfigs(ns)),i===fe.TRANSFER_FAILED&&o.status==="failed"){vA.emit(fA.TRANSFER_FAILED,"未知原因"),vA.emit(ae.FAIL_NOTIFICATION,"转接失败");const u=X.get("direction");u===ln.OUTGOING?X.updateActionConfigs(yi):u===ln.INCOMING&&X.updateActionConfigs(ns)}i===fe.KICK_OFFLINE&&vA.emit(ae.KICK_OFF),i===fe.CONTINUOUS_NOT_ANSWER&&(vA.emit(ae.FAIL_NOTIFICATION,`已连续 ${o.miss_count} 次未接, 设置忙碌`),this.stateBusyChange())},this.ws.onclose=()=>{this.stopHeartbeat(),this.manualClose||setTimeout(()=>this.initWebSocket(),this.reconnectDelay)},this.ws.onerror=()=>{var n;(n=this.ws)==null||n.close()}}startHeartbeat(){const A=new Blob([`
1056
+ `;Ai(r,this.rttHTML)}}class $o{static requestPermission(){"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}static async requestMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(t=>t.kind==="audioinput"&&t.label!=="")?null:await navigator.mediaDevices.getUserMedia({audio:!0})}catch(A){return console.warn("获取音频权限失败:",A),null}}static show(A,t,n,r){if("Notification"in window&&Notification.permission==="granted"){const i=new Notification(A,{body:t,tag:`xy-global-notification${new Date().getTime()}`,renotify:!0});i.onclick=()=>{window.focus(),i.close(),n==null||n()},setTimeout(()=>i.close(),1e3*(r||3))}}static async checkMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(A=>A.kind==="audioinput"&&A.label!=="")}catch(A){return console.warn("无法检查设备权限:",A),!1}}}const $M=console.log,jh=(...e)=>{lA.logBuiltinEnabled&&$M(...e)};let sr=null;class ct{constructor(A){this.url=A,this.ws=null,this.heartbeatWorker=null,this.reconnectDelay=3e3,this.manualClose=!1,this.apiClient=new Gd,this.sipClient=null,this.pendingMessages=new Map,this.initWebSocket()}static getInstance({url:A,sipClient:t}){if(!sr){if(!A)throw new Error("WebSocket 尚未初始化");sr=new ct(A),sr.sipClient=t}return sr}stateIdleChange(){const{state:A}=lA.stateObject;A!==ye.IDLE&&this.apiClient._changeState({data:{...lA.stateBeforeChange,state_name:lA.stateBeforeChange.state===ye.IDLE?"空闲":"忙碌"}})}inCallAutoAnswer(){const{soft_device_auto_answer:A,auto_answer_time:t}=lA.agentInfo,n=A===1,r=X.get("direction");if(n&&r===ln.INCOMING){const i=Number(t)||0;i>0&&(lA.autoAnswerTimer=setTimeout(()=>{var o;(o=this.sipClient)==null||o.answerCall(),lA.autoAnswerTimer=null},1e3*i))}}async getCustomerInfo(A){try{await this.apiClient._getInCallCrmDetail({data:{phone:A},success:t=>{X.updateCustomerInfo(t.data||{phone:t.data.phone,is_vip:0,customer_name:"未知客户",city:"未知",province:"未知",contact_count:0,in_contact_count:0,trace_id:t.data.trace_id})}})}catch{}}putAgentState(A){if(!A)return;lA.sessionId="";const{post_call_process_time:t}=lA.agentInfo,n=t||0;if(lA.autoStateTimer&&(clearTimeout(lA.autoStateTimer),lA.autoStateTimer=null),X.updateCustomerInfo(void 0),n>0){const{state:r}=lA.stateObject;if(r===ye.IDLE)return;this.apiClient._changeState({data:{state:ye.BUSY,state_name:"整理"}}),lA.autoStateTimer=setTimeout(()=>{lA.autoStateTimer=null,this.stateIdleChange()},1e3*n)}else this.stateIdleChange()}stateBusyChange(){lA.sessionId="",clearTimeout(lA.autoStateTimer),X.updateCustomerInfo(void 0),this.apiClient._changeState({data:{state:ye.BUSY,state_name:"忙碌"}})}initWebSocket(){var t;if(((t=this.ws)==null?void 0:t.readyState)===1)return;const A=RC(Ud,kd);this.ws=new WebSocket(this.url+A),this.ws.onopen=()=>{const n=new Date().getTime();this.sendMessage({type:0,msg_id:n}),this.pendingMessages.set(n,performance.now()),this.startHeartbeat(),this.manualClose=!1},this.ws.onmessage=async n=>{var u;const r=JSON.parse(n.data),{type:i,data:o,code:a,msg:s,msg_id:l}=r;if(i===0&&l){const V=this.pendingMessages.get(l),d=performance.now()-V;lA.latency=parseFloat(d.toFixed(2)),this.pendingMessages.delete(l)}if(i!==0&&jh("%cWebSocket 收到消息:","color: blue; font-weight: bold;",r),i!==fe.OUT_CALL&&i!==fe.PREVIEW_OUT_CALL||(a!==0?(X.reset(),vA.emit(fA.OUT_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s),X.updateActionConfigs(In),setTimeout(()=>{X.updateCustomerInfo(void 0)},500),this.stateIdleChange()):a===0&&(vA.emit(fA.OUT_SUCCESS),clearTimeout(lA.autoStateTimer))),i===fe.AGENT_STATE){const{state:V,state_name:d}=o;lA.stateObject={state:V,state_name:d},d==="振铃中"&&X.updateDisplayText(nt.AGENT_RINGING),V===ye.UNREGISTERED&&X.updateActionConfigs(BM),vA.emit(fA.AGENT_STATE,{state:V,state_name:d})}if(i===fe.OUT_CALL_INCOMING_CALL){try{await this.getCustomerInfo(o.trace_id||o.customer_phone)}catch(V){console.error(V)}o.preview_task_id?vA.emit(fA.PREVIEW_OUT_INCOMING_CALL,{customer_phone:o.customer_phone,session_id:o.session_id,preview_task_id:o.preview_task_id,trace_id:o.trace_id}):vA.emit(fA.OUT_INCOMING_CALL,{customer_phone:o.customer_phone,session_id:o.session_id,trace_id:o.trace_id}),lA.sessionId=o.session_id,X.updateActionConfigs(QM)}if(i===fe.OUT_CALL_END&&(X.updateDisplayText(""),o.device_type===1&&o.agent_no===lA.agentInfo.agent_no?(this.putAgentState(!0),X.reset(),vA.emit(fA.OUT_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(In)):o.device_type===2&&o.agent_no===lA.agentInfo.agent_no?(X.reset(),vA.emit(fA.OUR_SIDE_CONSULT_HANGUP,{session_id:o.session_id}),this.putAgentState(!0),X.updateActionConfigs(In)):o.device_type===2&&o.agent_no!==lA.agentInfo.agent_no?(X.updateDisplayText(nt.CALLING),vA.emit(fA.OTHER_SIDE_CONSULT_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(yi)):o.device_type===3&&o.agent_no===lA.agentInfo.agent_no?(this.putAgentState(!0),X.reset(),vA.emit(fA.THREE_WAY_OUR_SIDE_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(In)):o.device_type===4&&o.agent_no===lA.agentInfo.agent_no&&(this.putAgentState(!0),X.reset(),vA.emit(fA.TRANSFER_END,{session_id:o.session_id}),X.updateActionConfigs(In))),i===fe.OUT_CALL_RINGING&&o.type===1&&(vA.emit(fA.OUT_RINGING,{session_id:lA.sessionId,type:o.type}),X.updateDisplayText(nt.RINGING)),i===fe.OUT_CALL_ANSWER&&(clearTimeout(lA.autoStateTimer),X.updateIsCalling(!0),vA.emit(fA.OUT_OFF_ANSWER,{session_id:lA.sessionId}),X.updateOutCallIsAnswer(!0),X.updateDisplayText(nt.CALLING),X.updateActionConfigs(yi)),i===fe.CONSULT_RINGING&&(vA.emit(fA.CONSULT_RINGING,{session_id:o.session_id}),X.updateDisplayText(nt.AGENT_RINGING),X.updateActionConfigs([]),clearTimeout(lA.autoStateTimer)),i===fe.CONSULT_ANSWER&&(vA.emit(fA.CONSULT_OFF_HOOK,{session_id:o.session_id}),X.updateConsultIsAnswer(!0),X.updateDisplayText(nt.CONSULTING),X.updateActionConfigs(bM)),i===fe.CONSULT_FAIL&&(vA.emit(fA.CONSULT_FAILED,{custom_reason:o.custom_reason}),X.updateDisplayText(nt.CALLING),X.updateActionConfigs(yi)),i===fe.CONSULT_CALL_IN&&(vA.emit(fA.CONSULT_INCOMING,{agent_no:o.agent_no,agent_mane:o.agent_name,session_id:o.session_id}),lA.sessionId=o.session_id,X.updateIsCalling(!0),X.updateDirection(ln.CONSULT),X.updateDisplayText(nt.CONSULT_CALL_IN),X.updateActionConfigs(Oc),lA.enableBrowserAlert&&$o.show("📞 咨询来电",`坐席 [${o.agent_name}] 正在咨询...`,()=>{vA.emit(ae.NOTIFICATION_CLICK,{agent_mane:o.agent_name,agent_no:o.agent_no})},lA.browserAlertTime)),i===fe.CONSULT_CALL_IN_SUCCESS&&(vA.emit(fA.CONSULT_CALL_IN_SUCCESS,{session_id:o.session_id}),X.updateConsultIsAnswer(!0),X.updateDisplayText(nt.CALLING),X.updateActionConfigs(RM)),i===fe.CONSULT_RETURN_CALL_SUCCESS&&(o.status==="success"?(X.updateConsultIsAnswer(!1),vA.emit(fA.CONSULT_RETURN_CALL_SUCCESS),X.updateDisplayText(nt.CALLING),vA.emit(fA.OTHER_SIDE_CONSULT_HANGUP),X.updateActionConfigs(yi)):vA.emit(ae.FAIL_NOTIFICATION,"媒体失败")),i===fe.MUTE&&(a===0?(X.updateIsMuted(!0),vA.emit(fA.MUTE_SUCCESS),X.updateDisplayText(nt.MUTING)):(vA.emit(fA.MUTE_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.UNMUTE&&(a===0?(X.updateIsMuted(!1),vA.emit(fA.UNMUTE_SUCCESS),X.updateDisplayText(nt.CALLING)):(vA.emit(fA.UNMUTE_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CALL_HOLD&&(a===0?(X.updateIsHold(!0),X.updateDisplayText(nt.HOLDING),vA.emit(fA.HOLD_SUCCESS)):(vA.emit(fA.HOLD_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CALL_UNHOLD&&(a===0?(X.updateDisplayText(nt.CALLING),X.updateIsHold(!1),vA.emit(fA.UNHOLD_SUCCESS)):(vA.emit(fA.UNHOLD_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CONSULT_TRANSFER&&(a===0?vA.emit(fA.CONSULT_TRANSFER_SUCCESS):(vA.emit(fA.CONSULT_TRANSFER_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CONSULT_TRANSFER_FAILED&&vA.emit(fA.CONSULT_TRANSFER_FAILED,o.status),i===fe.CONSULT_TRANSFER_OFF_HOOK&&(X.updateDirection(ln.INCOMING),X.updateDisplayText(nt.CALLING),vA.emit(fA.CONSULT_TRANSFER_OFF_HOOK),X.updateActionConfigs(ns),X.updateIncomingIsAnswer(!0),X.updateConsultIsAnswer(!1)),i===fe.INCOMING_CALL){clearTimeout(lA.autoStateTimer),lA.sessionId=o.session_id;try{await this.getCustomerInfo(o.trace_id||o.customer_phone)}catch(V){console.error(V)}X.updateIsCalling(!0),X.updateDirection(ln.INCOMING),this.inCallAutoAnswer(),X.updateDisplayText(nt.INCOMING_CALL),o.direction===1&&vA.emit(fA.INCOMING_CALL,{customer_phone:o.customer_phone,trace_id:o.trace_id,session_id:o.session_id}),o.direction===3&&(vA.emit(fA.PREDICT_INCOMING_CALL,{customer_phone:o.customer_phone,trace_id:o.trace_id,session_id:o.session_id}),(u=this.sipClient)==null||u.answerCall()),X.updateActionConfigs(Oc),lA.enableBrowserAlert&&$o.show("📞 客户来电",`客户 [${o.customer_phone}] 正在呼入...`,()=>{vA.emit(ae.NOTIFICATION_CLICK,{customer_phone:o.customer_phone})},lA.browserAlertTime)}if(i===fe.INCOMING_CALL_OFF_HOOK&&(X.updateIncomingIsAnswer(!0),vA.emit(fA.INCOMING_CALL_OFF_HOOK,{session_id:lA.sessionId}),X.updateActionConfigs(ns),X.updateDisplayText(nt.CALLING)),i===fe.INCOMING_CALL_END&&(X.updateDisplayText(""),o.device_type===1&&o.agent_no===lA.agentInfo.agent_no?(this.putAgentState(!0),X.reset(),vA.emit(fA.INCOMING_CALL_END,{session_id:o.session_id}),X.updateActionConfigs(In)):o.device_type===2&&o.agent_no===lA.agentInfo.agent_no?(X.reset(),vA.emit(fA.OUR_SIDE_CONSULT_HANGUP,{session_id:o.session_id}),this.putAgentState(!0),X.updateActionConfigs(In)):o.device_type===2&&o.agent_no!==lA.agentInfo.agent_no?(X.updateDisplayText(nt.CALLING),vA.emit(fA.OTHER_SIDE_CONSULT_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(yi)):o.device_type===3&&o.agent_no===lA.agentInfo.agent_no?(this.putAgentState(!0),X.reset(),vA.emit(fA.THREE_WAY_OUR_SIDE_HANGUP,{session_id:o.session_id}),X.updateActionConfigs(In)):o.device_type===4&&o.agent_no===lA.agentInfo.agent_no&&(this.putAgentState(!0),X.reset(),vA.emit(fA.TRANSFER_END,{session_id:o.session_id}),X.updateActionConfigs(In))),i===fe.SATISFACTION_EVALUATION&&(a===0?vA.emit(fA.SATISFACTION_EVALUATION_SUCCESS):(vA.emit(fA.SATISFACTION_EVALUATION_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s))),i===fe.CONSULT_THREE_WAY&&(a!==0?(vA.emit(fA.CONSULT_THREE_WAY_FAILED,s),vA.emit(ae.FAIL_NOTIFICATION,s)):a===0&&X.updateIsMeeting(!0)),i===fe.CONSULT_THREE_WAY_RESULT&&(o.status==="success"?(X.updateDirection(ln.MEETING),X.updateDisplayText(nt.MEETING),X.updateActionConfigs(xM),vA.emit(fA.CONSULT_THREE_WAY_SUCCESS)):(vA.emit(fA.CONSULT_THREE_WAY_FAILED,{conf_name:o.conf_name}),X.updateIsMeeting(!1))),i===fe.TRANSFER_INCOMING_CALL&&(clearTimeout(lA.autoStateTimer),o.agent_no===lA.agentInfo.agent_no?(X.updateDisplayText(nt.TRANSFERRING),vA.emit(fA.TRANSFER_PROGRESS),X.updateActionConfigs([]),X.updateTransferIsAnswer(!0)):(lA.sessionId=o.session_id,vA.emit(fA.TRANSFER_INCOMING_CALL,{agent_no:o.agent_no,agent_name:o.agent_name,session_id:o.session_id}),X.updateIsCalling(!0),X.updateDirection(ln.TRANSFER),X.updateDisplayText(nt.TRANSFER_INCOMING_CALL),X.updateActionConfigs(Oc),lA.enableBrowserAlert&&$o.show("📞 转接来电",`坐席 [${o.agent_no}] 正在转接...`,()=>{vA.emit(ae.NOTIFICATION_CLICK,{agent_no:o.agent_no})},lA.browserAlertTime))),i===fe.TRANSFER_OFF_HOOK&&(vA.emit(fA.TRANSFER_OFF_HOOK,{session_id:lA.sessionId}),X.updateTransferIsAnswer(!1),X.updateDisplayText(nt.CALLING),X.updateActionConfigs(ns)),i===fe.TRANSFER_FAILED&&o.status==="failed"){vA.emit(fA.TRANSFER_FAILED,"未知原因"),vA.emit(ae.FAIL_NOTIFICATION,"转接失败");const V=X.get("direction");V===ln.OUTGOING?X.updateActionConfigs(yi):V===ln.INCOMING&&X.updateActionConfigs(ns)}i===fe.KICK_OFFLINE&&vA.emit(ae.KICK_OFF),i===fe.CONTINUOUS_NOT_ANSWER&&(vA.emit(ae.FAIL_NOTIFICATION,`已连续 ${o.miss_count} 次未接, 设置忙碌`),this.stateBusyChange())},this.ws.onclose=()=>{this.stopHeartbeat(),this.manualClose||setTimeout(()=>this.initWebSocket(),this.reconnectDelay)},this.ws.onerror=()=>{var n;(n=this.ws)==null||n.close()}}startHeartbeat(){const A=new Blob([`
1057
1057
  let timer;
1058
1058
  self.onmessage = function (e) {
1059
1059
  if (e.data === 'start') {
@@ -1556,4 +1556,4 @@ html body {
1556
1556
  &:hover {
1557
1557
  opacity: 0.9;
1558
1558
  }
1559
- `;function w6({title:e,content:A,icon:t,onOk:n,onCancel:r}){const i=document.createElement("div");document.body.appendChild(i);const o=m6.createRoot(i),a=()=>{o.unmount(),i.remove()},s=async()=>{n&&await n(),a()},l=()=>{r==null||r(),a()};o.render(VA.jsx(C6,{children:VA.jsxs(v6,{children:[VA.jsxs(E6,{children:[t&&VA.jsx(I6,{children:t}),e]}),VA.jsx(y6,{children:A}),VA.jsxs(M6,{children:[VA.jsx(Nq,{onClick:l,children:"取消"}),VA.jsx(Nq,{primary:!0,onClick:s,children:"确定"})]})]})}))}const S6={1:VA.jsx(Re,{name:"ruandianhua"}),2:VA.jsx(Re,{name:"pnhone"}),3:VA.jsx(Re,{name:"sip-phone"})},B6={call_number:"",answer:"接听",reject:"拒接",hangup:"挂机",dtmf:"DTMF",unhold:"取消保持",hold:"保持",mute:"静音",unmute:"取消静音",satisfaction:"满意度",consult:"咨询",consult_transfer:"咨询转接",consult_retrieve:"取回通话",conference:"三方会议"},Q6={空闲:1,离线:0,未注册:4},b6=R.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-kwRPdfkT.js"))),R6=R.lazy(()=>Promise.resolve().then(()=>require("./TransferModel-D8fAx92d.js"))),x6=e=>{var ee,qe,RA;const{style:A,logBuiltinEnabled:t,browserAlertTime:n,enableBrowserAlert:r,agentNo:i,appKey:o,appSecret:a,url:s,onCallBack:l,ringingCardShow:u=!0,onLoginCancel:V,isCheckLogin:d,...f}=e,{height:q,busy:C,idle:p,unavailable:m,selectOutNumberColor:y}=A||{},M=R.useRef(),B=R.useRef(),[w,g]=R.useState(new Audio(f6)),[Q,v]=R.useState(new Audio(p6)),[E,h]=R.useState(),[I,b]=R.useState(),[S,x]=R.useState(!1),[D,F]=R.useState(new Date().getTime()),[O,Y]=R.useState(),[K,j]=R.useState(),[Z,G]=R.useState([]),[z,L]=R.useState([]),[P,J]=R.useState(""),[_,W]=R.useState(!1),[tA,rA]=R.useState([]),[oA,AA]=R.useState(""),[hA,H]=R.useState(""),[aA,iA]=R.useState(!1),[IA,MA]=R.useState(!1),[qA,DA]=R.useState(),[OA,UA]=R.useState(new Date().getTime()),[yA,dA]=R.useState(!0),QA=N=>{switch(N){case ye.IDLE:return p||"#1D92E9";case ye.BUSY:return C||"#F5212D";case ye.UNREGISTERED:return m||"#faad14";case ye.OFFLINE:return m||"#8c8c8c";default:return"#1D92E9"}};R.useEffect(()=>((async()=>(x(!0),M.current=Bn.getInstance({agentNo:i,appKey:o,appSecret:a,url:s}),NA(),M.current.on(ae.PHONE_BAR_OPERATION,N=>{G(N)}),d?await M.current.agent_api.checkAgentLogin({data:{agent_no:i},success:async N=>{N.data.is_login?w6({title:"当前账号已登录!",icon:VA.jsx(Re,{name:"wing",size:20}),content:"是否继续登录",onOk:async()=>{await M.current.init({...f,logBuiltinEnabled:t,browserAlertTime:n,enableBrowserAlert:r}),B.current=M.current.getAgentData()},onCancel:()=>{V==null||V()}}):(await M.current.init({...f,logBuiltinEnabled:t,browserAlertTime:n,enableBrowserAlert:r}),B.current=M.current.getAgentData())}}):(await M.current.init({...f,logBuiltinEnabled:t,browserAlertTime:n,enableBrowserAlert:r}),B.current=M.current.getAgentData()),F(new Date().getTime()),x(!1)))(),()=>{var N;(N=M.current)==null||N.destroy()}),[]);const NA=()=>{var N,gA;(N=M.current)==null||N.on(ae.EVENT_ALL,({event:uA,data:EA})=>{switch(uA){case fA.OUT_SUCCESS:case fA.CONSULT_RINGING:{$A(w),DA("out");return}case fA.OUT_INCOMING_CALL:{l==null||l(fA.OUT_INCOMING_CALL,{customer_phone:EA.customer_phone,session_id:EA.session_id});return}case fA.PREVIEW_OUT_INCOMING_CALL:{l==null||l(fA.PREVIEW_OUT_INCOMING_CALL,{customer_phone:EA.customer_phone,session_id:EA.session_id,preview_task_id:EA.preview_task_id});return}case fA.OUT_OFF_ANSWER:case fA.OUT_FAILED:case fA.CONSULT_FAILED:case fA.OUT_RINGING:case fA.CONSULT_OFF_HOOK:{PA(w);return}case fA.CONSULT_INCOMING:case fA.TRANSFER_INCOMING_CALL:case fA.PREDICT_INCOMING_CALL:case fA.INCOMING_CALL:{DA("in"),(uA===fA.CONSULT_INCOMING||uA===fA.TRANSFER_INCOMING_CALL)&&(l==null||l(uA,{agent_no:EA.agent_no,agent_name:EA.agent_name,session_id:EA.session_id})),uA===fA.INCOMING_CALL&&(l==null||l(fA.INCOMING_CALL,{customer_phone:EA.customer_phone,session_id:EA.session_id})),uA===fA.PREDICT_INCOMING_CALL&&(l==null||l(fA.PREDICT_INCOMING_CALL,{customer_phone:EA.customer_phone,session_id:EA.session_id})),$A(Q);return}case fA.TRANSFER_OFF_HOOK:case fA.CONSULT_CALL_IN_SUCCESS:case fA.INCOMING_CALL_OFF_HOOK:{l==null||l(uA,{session_id:EA.session_id}),PA(Q);return}case fA.OUT_HANGUP:case fA.TRANSFER_END:case fA.THREE_WAY_OUR_SIDE_HANGUP:case fA.OUR_SIDE_CONSULT_HANGUP:case fA.INCOMING_CALL_END:{l==null||l(uA,{session_id:EA.session_id}),PA(Q),PA(w),DA(void 0),iA(!1),MA(!1);return}case fA.REJECT:l==null||l(uA,{session_id:EA.session_id});return;default:return null}}),(gA=M.current)==null||gA.on(fA.AGENT_STATE,uA=>{j(uA.state_name),F(new Date().getTime())}).on(fA.CALL_PROGRESS,uA=>{J(uA)}).on(ae.WEBSITE_DELAY,uA=>{h(uA)}).on(fA.CUSTOMER_INFO,uA=>{b(uA),uA&&dA(!0)}).on(ae.AGENT_INIT_STATUS,uA=>{if(uA){const{default_device:EA,init_state:T,out_display_select_switch:sA,out_display_data:pA}=M.current.getAgentData();W(sA===1),sA===1&&rA((pA||"").split("#")),Y(EA),j(T===1?"空闲":"忙碌"),ce()}}).on(ae.SELECT_EXTERNAL_NUMBER,uA=>{AA(uA)}).on(ae.FAIL_NOTIFICATION,uA=>{_e.error(uA)}).on(ae.KICK_OFF,()=>{l?l==null||l(ae.KICK_OFF):_e.warning("您的座席账号已在别处登录,请重新登录。如非您本人操作,请及时修改密码。"),j("")}).on(ae.DESTROY,()=>{l==null||l(ae.DESTROY),_e.success("已离线")}).on(ae.NETWORK_OFFLINE,()=>{_e.warning("网络已断开,请检查网络设置。")}).on(ae.NETWORK_ONLINE,()=>{_e.success("网络已恢复")})};R.useEffect(()=>{var N;(N=M.current)==null||N.setBrowserAlertTime(n||3)},[n]),R.useEffect(()=>{var N;(N=M.current)==null||N.setBrowserAlert(r||!1)},[r]);const $A=N=>{N.currentTime=0,N.loop=!0,N.play()},PA=N=>{N.pause()},ZA=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.agent_api.changeDevice({data:{device:N},success:()=>{Y(N),_e.success("切换设备成功")}}))}catch{}},GA=async(N,gA)=>{var uA;try{await((uA=M.current)==null?void 0:uA.agent_api.changeState({data:{state:N,state_name:gA},success:()=>{j(gA),_e.success("切换状态成功")}}))}catch{}},WA=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.agent_api.setAgentExplicit({data:{number:N},success:()=>{_e.success(`切换[${N}]外显号码成功`)}}))}catch{}},ce=async()=>{var N;try{await((N=M.current)==null?void 0:N.agent_api.getAgentState({success:gA=>{L(gA.data)}}))}catch{}},_A=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.call_api.makeCall(N))}catch(uA){const{msg:EA}=JSON.parse(uA.message);_e.warning(EA)}},xA=async()=>{var N;try{await((N=M.current)==null?void 0:N.call_api.answerCall())}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},SA=async()=>{var N;try{(N=M.current)==null||N.call_api.cancelCall()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},ie=async()=>{var N;try{await((N=M.current)==null?void 0:N.call_api.hangup())}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},se=async()=>{var N;try{(N=M.current)==null||N.call_api.holdCall()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},me=()=>{var N;(N=M.current)==null||N.call_api.unholdCall()},xe=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.call_api.consultCall(N))}catch(uA){const{msg:EA}=JSON.parse(uA.message);_e.warning(EA)}},ze=async()=>{var N;try{(N=M.current)==null||N.call_api.consultRetrieve()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},We=async()=>{var N;try{(N=M.current)==null||N.call_api.consultTransfer()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},et=()=>{var N;try{(N=M.current)==null||N.call_api.mute()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},Xe=()=>{var N;try{(N=M.current)==null||N.call_api.unmute()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},Le=()=>{var N;try{(N=M.current)==null||N.call_api.satisfactionEvaluation()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},Be=()=>{var N;try{(N=M.current)==null||N.call_api.startConference()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},pe=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.call_api.transferAgent(N))}catch(uA){const{msg:EA}=JSON.parse(uA.message);_e.warning(EA)}},KA=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.call_api.transferOutline(N))}catch(uA){const{msg:EA}=JSON.parse(uA.message);_e.warning(EA)}},zA=VA.jsx(V6,{onPressEnter:N=>{N&&_A(N)}},OA),BA=R.useMemo(()=>[{name:"call_number",icon:VA.jsx(na,{trigger:"click",rootClassName:"call-number-popover",destroyTooltipOnHide:!0,onOpenChange:gA=>{UA(new Date().getTime())},content:zA,children:VA.jsx("span",{children:VA.jsx(Re,{name:"boda",color:"#48D866",size:25})})})},{name:"answer",icon:VA.jsx(Re,{name:"jieting",onClick:xA,size:25})},{name:"reject",icon:VA.jsx(Re,{name:"jujie",color:"red",onClick:SA,size:25})},{name:"hangup",icon:VA.jsx(Re,{name:"guaji",color:"red",onClick:ie,size:25})},{name:"hold",icon:VA.jsx(Re,{name:"baochi",color:"#1D92E9",onClick:se,size:25})},{name:"unhold",icon:VA.jsx(Re,{name:"quxiaobaochi",color:"#1D92E9",onClick:me,size:25})},{name:"mute",icon:VA.jsx(Re,{name:"mk",onClick:et,color:"#1D92E9",size:25})},{name:"unmute",icon:VA.jsx(Re,{name:"guanbimk",onClick:Xe,color:"#1D92E9",size:25})},{name:"satisfaction",icon:VA.jsx(Re,{name:"manyidu",onClick:Le,size:25})},{name:"consult",icon:VA.jsx(Re,{name:"zixun",onClick:()=>{iA(!0)},size:25})},{name:"consult_transfer",icon:VA.jsx(Re,{name:"zhuanjie",onClick:We,size:25})},{name:"transfer",icon:VA.jsx(Re,{size:25,name:"zhuanjie",onClick:()=>{MA(!0)}})},{name:"consult_retrieve",icon:VA.jsx(Re,{name:"fanhui",color:"#ffc53d",size:25,onClick:ze})},{name:"conference",icon:VA.jsx(Re,{name:"huiyi",onClick:Be,size:25})}].filter(({name:gA})=>Z.includes(gA)),[Z]);return VA.jsx(VA.Fragment,{children:VA.jsxs(nr,{prefixCls:"ysyt",theme:{components:{Select:{selectorBg:"none"}}},children:[K?VA.jsx(lc,{spinning:S,children:VA.jsxs(iS,{height:q,children:[VA.jsx(oS,{children:VA.jsx(vi,{variant:"underlined",value:O,onChange:N=>{ZA(N)},options:(((ee=B.current)==null?void 0:ee.answer_devices)||[]).map(N=>({...N,label:VA.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[S6[N.value],VA.jsx("span",{style:{marginLeft:5},children:N.label})]})})),style:{width:140}})}),VA.jsxs(aS,{background:QA(Q6[K]??2),children:[VA.jsxs("div",{className:"ysyt-strip",children:[VA.jsx("div",{children:P?VA.jsx("span",{className:"ysyt-strip-state-name",children:P}):VA.jsx(zv,{trigger:["click"],menu:{items:z.map(N=>({label:VA.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[N.state===1?VA.jsx(Re,{name:"kongxian",color:"#7cb305",size:16}):VA.jsx(Re,{name:"manglu",color:"#f5222d",size:16}),VA.jsx("span",{style:{marginLeft:10},children:N.state_name})]}),key:N.state_name,onClick:()=>{GA(N.state,N.state_name)}}))},children:VA.jsxs("div",{style:{color:"#fff",cursor:"pointer",display:"flex",alignItems:"center"},children:[K==="空闲"?VA.jsx(Re,{name:"kongxian",color:"#fff",size:20}):VA.jsx(VA.Fragment,{children:K==="未注册"?VA.jsx(Re,{name:"unregistered",size:20}):VA.jsx(Re,{name:"manglu2",size:20})}),VA.jsx("span",{style:{margin:"0 10px"},children:K}),VA.jsx(Re,{name:"xia",color:"#fff"})]})})}),VA.jsx("div",{className:"ysyt-strip-time",children:VA.jsx(h6,{},D)}),u&&I&&VA.jsx("div",{className:"ysyt-strip-call-card",onClick:()=>dA(!yA),children:yA?VA.jsx(Re,{name:"unopen",color:"#fff"}):VA.jsx(Re,{name:"open",color:"#fff"})})]}),VA.jsx("div",{className:"ysyt-action",children:BA.map(({name:N,icon:gA})=>VA.jsx(Za,{title:B6[N],children:gA},N))}),_&&VA.jsx(pS,{children:VA.jsx("div",{children:VA.jsx(na,{trigger:"click",title:"外显号码池",onOpenChange:N=>{N||H("")},content:VA.jsxs(qS,{children:[VA.jsx("div",{children:VA.jsx(zr,{value:hA,placeholder:"请输入外显号码",onChange:N=>H(N.target.value)})}),VA.jsx("div",{className:"ysyt-number-content",children:VA.jsx(Oa.Group,{value:oA,onChange:N=>{WA(N.target.value)},options:tA.filter(N=>N.includes(hA)).map(N=>({label:VA.jsx(mS,{style:{color:oA===N?"#1D92E9":""},children:N},N),value:N}))})})]}),children:VA.jsxs("div",{style:{fontSize:14,cursor:"pointer",color:y||"#333",display:"flex",alignItems:"center"},children:[VA.jsx(Re,{name:"external",color:y||"#333"}),VA.jsx("span",{style:{margin:"0 5px"},children:"外显号码"}),VA.jsx(Re,{name:"xia",color:y||"#333"})]})})})})]}),VA.jsx(dS,{children:E&&E.rtt&&VA.jsx("div",{children:VA.jsx(na,{content:VA.jsxs("div",{children:[VA.jsxs("div",{children:["延迟: ",E.rtt,"ms"]}),E.jitter&&VA.jsxs("div",{children:["抖动: ",E.jitter,"ms"]}),VA.jsxs("div",{children:["丢包: ",E.packetsLost||0]}),E.packetsReceived?VA.jsxs("div",{children:["接收: ",E.packetsReceived]}):null,E.packetsSent?VA.jsxs("div",{children:["发送: ",E.packetsSent]}):null,E.sendBitrate?VA.jsxs("div",{children:["发送码率: ",E.sendBitrate,"KB/s"]}):null,E.recvBitrate?VA.jsxs("div",{children:["接收码率: ",E.recvBitrate,"KB/s"]}):null]}),placement:"bottomLeft",children:VA.jsxs("div",{style:{padding:"0 10px"},children:[E.rtt>=250?VA.jsx(Re,{name:"wifi1"}):"",E.rtt>=121&&E.rtt<250?VA.jsx(Re,{name:"wifi2"}):"",E.rtt<=120?VA.jsx(Re,{name:"wifi3"}):""]})})})}),u&&VA.jsxs(fS,{height:q,show:!!I&&yA,children:[VA.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[VA.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[(I==null?void 0:I.is_vip)===1&&VA.jsx(Re,{name:"vip"}),VA.jsx("span",{style:{marginLeft:5},children:I==null?void 0:I.customer_name})]}),VA.jsx("b",{children:I==null?void 0:I.phone})]}),VA.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[VA.jsxs("span",{children:[I==null?void 0:I.province,"-",I==null?void 0:I.city]}),qA&&VA.jsxs("span",{children:[qA==="out"?"呼出次数:":"呼入次数:",VA.jsx("span",{style:{color:"#1D92E9"},children:qA==="out"?I==null?void 0:I.contact_count:I==null?void 0:I.in_contact_count})]})]})]})]})}):VA.jsx(VA.Fragment,{}),VA.jsx(R.Suspense,{children:aA&&((qe=M.current)==null?void 0:qe.agent_api)&&VA.jsx(b6,{open:aA,queryFetch:M.current.agent_api.getIdleAgentList,onCallBack:N=>{iA(!1),N&&xe(N)}})}),VA.jsx(R.Suspense,{children:IA&&((RA=M.current)==null?void 0:RA.agent_api)&&VA.jsx(R6,{open:IA,queryFetch:M.current.agent_api.getIdleAgentList,onCallBack:(N,gA)=>{MA(!1),N&&(gA===0?pe(N):gA===1&&KA(N))}})})]})})},D6=e=>{var A;return(A=Bn.getInstance())==null?void 0:A.call_api.makeCall(e)},T6=()=>{var e;return(e=Bn.getInstance())==null?void 0:e.getRealTimeCustomerInfo()},F6=async e=>{var A,t;if(e!==ye.IDLE&&e!==ye.BUSY)throw new Error("Invalid agent state");try{await((t=(A=Bn.getInstance())==null?void 0:A.agent_api)==null?void 0:t.changeState({data:{state:e,state_name:e===ye.IDLE?"空闲":"忙碌"}}))}catch(n){console.error(n)}},O6=async e=>{var A,t;try{await((t=(A=Bn.getInstance())==null?void 0:A.agent_api)==null?void 0:t.changeDevice({data:{device:e}}))}catch(n){console.error(n)}},U6=async(e=!1,A)=>{var t,n;try{await((n=(t=Bn.getInstance())==null?void 0:t.agent_api)==null?void 0:n.agentLogout({data:{offline_answer:e},success:()=>{A==null||A()}}))}catch(r){console.log(r)}},k6=async(e,A)=>{var t;(t=Bn.getInstance())==null||t.call_api.previewMakeCall(e,A)};exports.Button=fi;exports.CONTAINER_MAX_OFFSET=Ag;exports.CSSMotion=qi;exports.ConfigContext=Ue;exports.ConfigProvider=nr;exports.ContextIsolator=ma;exports.DisabledContextProvider=Ym;exports.Empty=gr;exports.FastColor=Ke;exports.Input=zr;exports.KeyCode=re;exports.Keyframe=Oe;exports.ModelBody=VS;exports.Portal=Ac;exports.Radio=Oa;exports.RefIcon=oc;exports.RefIcon$1=Cg;exports.RefIcon$2=Ua;exports.RefIcon$3=mg;exports.RefIcon$4=vg;exports.Space=ic;exports.Spin=lc;exports.Wave=Zl;exports.YsytBarPhone=x6;exports.YsytIconSvg=Re;exports._extends=FA;exports._objectSpread2=k;exports._slicedToArray=$;exports._toConsumableArray=wA;exports._typeof=Ae;exports.agentLogout=U6;exports.canUseDom=Ut;exports.classNames=nA;exports.clearFix=Ys;exports.contains=Wq;exports.convertLegacyProps=ix;exports.devUseWarning=st;exports.genFocusStyle=Ns;exports.genPresetColor=Tm;exports.genStyleHooks=Qt;exports.genSubStyleComponent=Dm;exports.getConfirmLocale=Ky;exports.getCustomerInfo=T6;exports.getReactRender=rg;exports.getTransitionName=Jl;exports.globalConfig=bd;exports.initMotion=Gl;exports.initZoomMotion=ba;exports.isPresetColor=jv;exports.isPresetStatusColor=DF;exports.jsxRuntimeExports=VA;exports.localeValues=Vi;exports.makeCall=D6;exports.merge=Je;exports.omit=_t;exports.pickAttrs=jr;exports.previewMakeCall=k6;exports.replaceElement=b0;exports.resetComponent=Lt;exports.setAgentDevice=O6;exports.setAgentInitState=F6;exports.unit=mA;exports.useCSSVarCls=Kn;exports.useComponentConfig=tr;exports.useComposeRef=Jr;exports.useEvent=rt;exports.useId=Kl;exports.useLocale=yl;exports.useSafeState=ao;exports.useToken=gn;exports.useZIndex=xa;exports.warnContext=eC;exports.warning=Nr;exports.withPureRenderTheme=yv;exports.zIndexContext=Ra;
1559
+ `;function w6({title:e,content:A,icon:t,onOk:n,onCancel:r}){const i=document.createElement("div");document.body.appendChild(i);const o=m6.createRoot(i),a=()=>{o.unmount(),i.remove()},s=async()=>{n&&await n(),a()},l=()=>{r==null||r(),a()};o.render(VA.jsx(C6,{children:VA.jsxs(v6,{children:[VA.jsxs(E6,{children:[t&&VA.jsx(I6,{children:t}),e]}),VA.jsx(y6,{children:A}),VA.jsxs(M6,{children:[VA.jsx(Nq,{onClick:l,children:"取消"}),VA.jsx(Nq,{primary:!0,onClick:s,children:"确定"})]})]})}))}const S6={1:VA.jsx(Re,{name:"ruandianhua"}),2:VA.jsx(Re,{name:"pnhone"}),3:VA.jsx(Re,{name:"sip-phone"})},B6={call_number:"",answer:"接听",reject:"拒接",hangup:"挂机",dtmf:"DTMF",unhold:"取消保持",hold:"保持",mute:"静音",unmute:"取消静音",satisfaction:"满意度",consult:"咨询",consult_transfer:"咨询转接",consult_retrieve:"取回通话",conference:"三方会议"},Q6={空闲:1,离线:0,未注册:4},b6=R.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-B0Fw7yDi.js"))),R6=R.lazy(()=>Promise.resolve().then(()=>require("./TransferModel-szAlOaWK.js"))),x6=e=>{var ee,qe,RA;const{style:A,logBuiltinEnabled:t,browserAlertTime:n,enableBrowserAlert:r,agentNo:i,appKey:o,appSecret:a,url:s,onCallBack:l,ringingCardShow:u=!0,onLoginCancel:V,isCheckLogin:d,...f}=e,{height:q,busy:C,idle:p,unavailable:m,selectOutNumberColor:y}=A||{},M=R.useRef(),B=R.useRef(),[w,g]=R.useState(new Audio(f6)),[Q,v]=R.useState(new Audio(p6)),[E,h]=R.useState(),[I,b]=R.useState(),[S,x]=R.useState(!1),[D,F]=R.useState(new Date().getTime()),[O,Y]=R.useState(),[K,j]=R.useState(),[Z,G]=R.useState([]),[z,L]=R.useState([]),[P,J]=R.useState(""),[_,W]=R.useState(!1),[tA,rA]=R.useState([]),[oA,AA]=R.useState(""),[hA,H]=R.useState(""),[aA,iA]=R.useState(!1),[IA,MA]=R.useState(!1),[qA,DA]=R.useState(),[OA,UA]=R.useState(new Date().getTime()),[yA,dA]=R.useState(!0),QA=N=>{switch(N){case ye.IDLE:return p||"#1D92E9";case ye.BUSY:return C||"#F5212D";case ye.UNREGISTERED:return m||"#faad14";case ye.OFFLINE:return m||"#8c8c8c";default:return"#1D92E9"}};R.useEffect(()=>((async()=>(x(!0),M.current=Bn.getInstance({agentNo:i,appKey:o,appSecret:a,url:s}),NA(),M.current.on(ae.PHONE_BAR_OPERATION,N=>{G(N)}),d?await M.current.agent_api.checkAgentLogin({data:{agent_no:i},success:async N=>{N.data.is_login?w6({title:"当前账号已登录!",icon:VA.jsx(Re,{name:"wing",size:20}),content:"是否继续登录",onOk:async()=>{await M.current.init({...f,logBuiltinEnabled:t,browserAlertTime:n,enableBrowserAlert:r}),B.current=M.current.getAgentData()},onCancel:()=>{V==null||V()}}):(await M.current.init({...f,logBuiltinEnabled:t,browserAlertTime:n,enableBrowserAlert:r}),B.current=M.current.getAgentData())}}):(await M.current.init({...f,logBuiltinEnabled:t,browserAlertTime:n,enableBrowserAlert:r}),B.current=M.current.getAgentData()),F(new Date().getTime()),x(!1)))(),()=>{var N;(N=M.current)==null||N.destroy()}),[]);const NA=()=>{var N,gA;(N=M.current)==null||N.on(ae.EVENT_ALL,({event:uA,data:EA})=>{switch(uA){case fA.OUT_SUCCESS:case fA.CONSULT_RINGING:{$A(w),DA("out");return}case fA.OUT_INCOMING_CALL:{l==null||l(fA.OUT_INCOMING_CALL,{customer_phone:EA.customer_phone,session_id:EA.session_id});return}case fA.PREVIEW_OUT_INCOMING_CALL:{l==null||l(fA.PREVIEW_OUT_INCOMING_CALL,{customer_phone:EA.customer_phone,session_id:EA.session_id,preview_task_id:EA.preview_task_id});return}case fA.OUT_OFF_ANSWER:case fA.OUT_FAILED:case fA.CONSULT_FAILED:case fA.OUT_RINGING:case fA.CONSULT_OFF_HOOK:{PA(w);return}case fA.CONSULT_INCOMING:case fA.TRANSFER_INCOMING_CALL:case fA.PREDICT_INCOMING_CALL:case fA.INCOMING_CALL:{DA("in"),(uA===fA.CONSULT_INCOMING||uA===fA.TRANSFER_INCOMING_CALL)&&(l==null||l(uA,{agent_no:EA.agent_no,agent_name:EA.agent_name,session_id:EA.session_id})),uA===fA.INCOMING_CALL&&(l==null||l(fA.INCOMING_CALL,{customer_phone:EA.customer_phone,session_id:EA.session_id})),uA===fA.PREDICT_INCOMING_CALL&&(l==null||l(fA.PREDICT_INCOMING_CALL,{customer_phone:EA.customer_phone,session_id:EA.session_id})),$A(Q);return}case fA.TRANSFER_OFF_HOOK:case fA.CONSULT_CALL_IN_SUCCESS:case fA.INCOMING_CALL_OFF_HOOK:{l==null||l(uA,{session_id:EA.session_id}),PA(Q);return}case fA.OUT_HANGUP:case fA.TRANSFER_END:case fA.THREE_WAY_OUR_SIDE_HANGUP:case fA.OUR_SIDE_CONSULT_HANGUP:case fA.INCOMING_CALL_END:{l==null||l(uA,{session_id:EA.session_id}),PA(Q),PA(w),DA(void 0),iA(!1),MA(!1);return}case fA.REJECT:l==null||l(uA,{session_id:EA.session_id});return;default:return null}}),(gA=M.current)==null||gA.on(fA.AGENT_STATE,uA=>{j(uA.state_name),F(new Date().getTime())}).on(fA.CALL_PROGRESS,uA=>{J(uA)}).on(ae.WEBSITE_DELAY,uA=>{h(uA)}).on(fA.CUSTOMER_INFO,uA=>{b(uA),uA&&dA(!0)}).on(ae.AGENT_INIT_STATUS,uA=>{if(uA){const{default_device:EA,init_state:T,out_display_select_switch:sA,out_display_data:pA}=M.current.getAgentData();W(sA===1),sA===1&&rA((pA||"").split("#")),Y(EA),j(T===1?"空闲":"忙碌"),ce()}}).on(ae.SELECT_EXTERNAL_NUMBER,uA=>{AA(uA)}).on(ae.FAIL_NOTIFICATION,uA=>{_e.error(uA)}).on(ae.KICK_OFF,()=>{l?l==null||l(ae.KICK_OFF):_e.warning("您的座席账号已在别处登录,请重新登录。如非您本人操作,请及时修改密码。"),j("")}).on(ae.DESTROY,()=>{l==null||l(ae.DESTROY),_e.success("已离线")}).on(ae.NETWORK_OFFLINE,()=>{_e.warning("网络已断开,请检查网络设置。")}).on(ae.NETWORK_ONLINE,()=>{_e.success("网络已恢复")})};R.useEffect(()=>{var N;(N=M.current)==null||N.setBrowserAlertTime(n||3)},[n]),R.useEffect(()=>{var N;(N=M.current)==null||N.setBrowserAlert(r||!1)},[r]);const $A=N=>{N.currentTime=0,N.loop=!0,N.play()},PA=N=>{N.pause()},ZA=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.agent_api.changeDevice({data:{device:N},success:()=>{Y(N),_e.success("切换设备成功")}}))}catch{}},GA=async(N,gA)=>{var uA;try{await((uA=M.current)==null?void 0:uA.agent_api.changeState({data:{state:N,state_name:gA},success:()=>{j(gA),_e.success("切换状态成功")}}))}catch{}},WA=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.agent_api.setAgentExplicit({data:{number:N},success:()=>{_e.success(`切换[${N}]外显号码成功`)}}))}catch{}},ce=async()=>{var N;try{await((N=M.current)==null?void 0:N.agent_api.getAgentState({success:gA=>{L(gA.data)}}))}catch{}},_A=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.call_api.makeCall(N))}catch(uA){const{msg:EA}=JSON.parse(uA.message);_e.warning(EA)}},xA=async()=>{var N;try{await((N=M.current)==null?void 0:N.call_api.answerCall())}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},SA=async()=>{var N;try{(N=M.current)==null||N.call_api.cancelCall()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},ie=async()=>{var N;try{await((N=M.current)==null?void 0:N.call_api.hangup())}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},se=async()=>{var N;try{(N=M.current)==null||N.call_api.holdCall()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},me=()=>{var N;(N=M.current)==null||N.call_api.unholdCall()},xe=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.call_api.consultCall(N))}catch(uA){const{msg:EA}=JSON.parse(uA.message);_e.warning(EA)}},ze=async()=>{var N;try{(N=M.current)==null||N.call_api.consultRetrieve()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},We=async()=>{var N;try{(N=M.current)==null||N.call_api.consultTransfer()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},et=()=>{var N;try{(N=M.current)==null||N.call_api.mute()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},Xe=()=>{var N;try{(N=M.current)==null||N.call_api.unmute()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},Le=()=>{var N;try{(N=M.current)==null||N.call_api.satisfactionEvaluation()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},Be=()=>{var N;try{(N=M.current)==null||N.call_api.startConference()}catch(gA){const{msg:uA}=JSON.parse(gA.message);_e.warning(uA)}},pe=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.call_api.transferAgent(N))}catch(uA){const{msg:EA}=JSON.parse(uA.message);_e.warning(EA)}},KA=async N=>{var gA;try{await((gA=M.current)==null?void 0:gA.call_api.transferOutline(N))}catch(uA){const{msg:EA}=JSON.parse(uA.message);_e.warning(EA)}},zA=VA.jsx(V6,{onPressEnter:N=>{N&&_A(N)}},OA),BA=R.useMemo(()=>[{name:"call_number",icon:VA.jsx(na,{trigger:"click",rootClassName:"call-number-popover",destroyTooltipOnHide:!0,onOpenChange:gA=>{UA(new Date().getTime())},content:zA,children:VA.jsx("span",{children:VA.jsx(Re,{name:"boda",color:"#48D866",size:25})})})},{name:"answer",icon:VA.jsx(Re,{name:"jieting",onClick:xA,size:25})},{name:"reject",icon:VA.jsx(Re,{name:"jujie",color:"red",onClick:SA,size:25})},{name:"hangup",icon:VA.jsx(Re,{name:"guaji",color:"red",onClick:ie,size:25})},{name:"hold",icon:VA.jsx(Re,{name:"baochi",color:"#1D92E9",onClick:se,size:25})},{name:"unhold",icon:VA.jsx(Re,{name:"quxiaobaochi",color:"#1D92E9",onClick:me,size:25})},{name:"mute",icon:VA.jsx(Re,{name:"mk",onClick:et,color:"#1D92E9",size:25})},{name:"unmute",icon:VA.jsx(Re,{name:"guanbimk",onClick:Xe,color:"#1D92E9",size:25})},{name:"satisfaction",icon:VA.jsx(Re,{name:"manyidu",onClick:Le,size:25})},{name:"consult",icon:VA.jsx(Re,{name:"zixun",onClick:()=>{iA(!0)},size:25})},{name:"consult_transfer",icon:VA.jsx(Re,{name:"zhuanjie",onClick:We,size:25})},{name:"transfer",icon:VA.jsx(Re,{size:25,name:"zhuanjie",onClick:()=>{MA(!0)}})},{name:"consult_retrieve",icon:VA.jsx(Re,{name:"fanhui",color:"#ffc53d",size:25,onClick:ze})},{name:"conference",icon:VA.jsx(Re,{name:"huiyi",onClick:Be,size:25})}].filter(({name:gA})=>Z.includes(gA)),[Z]);return VA.jsx(VA.Fragment,{children:VA.jsxs(nr,{prefixCls:"ysyt",theme:{components:{Select:{selectorBg:"none"}}},children:[K?VA.jsx(lc,{spinning:S,children:VA.jsxs(iS,{height:q,children:[VA.jsx(oS,{children:VA.jsx(vi,{variant:"underlined",value:O,onChange:N=>{ZA(N)},options:(((ee=B.current)==null?void 0:ee.answer_devices)||[]).map(N=>({...N,label:VA.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[S6[N.value],VA.jsx("span",{style:{marginLeft:5},children:N.label})]})})),style:{width:140}})}),VA.jsxs(aS,{background:QA(Q6[K]??2),children:[VA.jsxs("div",{className:"ysyt-strip",children:[VA.jsx("div",{children:P?VA.jsx("span",{className:"ysyt-strip-state-name",children:P}):VA.jsx(zv,{trigger:["click"],menu:{items:z.map(N=>({label:VA.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[N.state===1?VA.jsx(Re,{name:"kongxian",color:"#7cb305",size:16}):VA.jsx(Re,{name:"manglu",color:"#f5222d",size:16}),VA.jsx("span",{style:{marginLeft:10},children:N.state_name})]}),key:N.state_name,onClick:()=>{GA(N.state,N.state_name)}}))},children:VA.jsxs("div",{style:{color:"#fff",cursor:"pointer",display:"flex",alignItems:"center"},children:[K==="空闲"?VA.jsx(Re,{name:"kongxian",color:"#fff",size:20}):VA.jsx(VA.Fragment,{children:K==="未注册"?VA.jsx(Re,{name:"unregistered",size:20}):VA.jsx(Re,{name:"manglu2",size:20})}),VA.jsx("span",{style:{margin:"0 10px"},children:K}),VA.jsx(Re,{name:"xia",color:"#fff"})]})})}),VA.jsx("div",{className:"ysyt-strip-time",children:VA.jsx(h6,{},D)}),u&&I&&VA.jsx("div",{className:"ysyt-strip-call-card",onClick:()=>dA(!yA),children:yA?VA.jsx(Re,{name:"unopen",color:"#fff"}):VA.jsx(Re,{name:"open",color:"#fff"})})]}),VA.jsx("div",{className:"ysyt-action",children:BA.map(({name:N,icon:gA})=>VA.jsx(Za,{title:B6[N],children:gA},N))}),_&&VA.jsx(pS,{children:VA.jsx("div",{children:VA.jsx(na,{trigger:"click",title:"外显号码池",onOpenChange:N=>{N||H("")},content:VA.jsxs(qS,{children:[VA.jsx("div",{children:VA.jsx(zr,{value:hA,placeholder:"请输入外显号码",onChange:N=>H(N.target.value)})}),VA.jsx("div",{className:"ysyt-number-content",children:VA.jsx(Oa.Group,{value:oA,onChange:N=>{WA(N.target.value)},options:tA.filter(N=>N.includes(hA)).map(N=>({label:VA.jsx(mS,{style:{color:oA===N?"#1D92E9":""},children:N},N),value:N}))})})]}),children:VA.jsxs("div",{style:{fontSize:14,cursor:"pointer",color:y||"#333",display:"flex",alignItems:"center"},children:[VA.jsx(Re,{name:"external",color:y||"#333"}),VA.jsx("span",{style:{margin:"0 5px"},children:"外显号码"}),VA.jsx(Re,{name:"xia",color:y||"#333"})]})})})})]}),VA.jsx(dS,{children:E&&E.rtt&&VA.jsx("div",{children:VA.jsx(na,{content:VA.jsxs("div",{children:[VA.jsxs("div",{children:["延迟: ",E.rtt,"ms"]}),E.jitter&&VA.jsxs("div",{children:["抖动: ",E.jitter,"ms"]}),VA.jsxs("div",{children:["丢包: ",E.packetsLost||0]}),E.packetsReceived?VA.jsxs("div",{children:["接收: ",E.packetsReceived]}):null,E.packetsSent?VA.jsxs("div",{children:["发送: ",E.packetsSent]}):null,E.sendBitrate?VA.jsxs("div",{children:["发送码率: ",E.sendBitrate,"KB/s"]}):null,E.recvBitrate?VA.jsxs("div",{children:["接收码率: ",E.recvBitrate,"KB/s"]}):null]}),placement:"bottomLeft",children:VA.jsxs("div",{style:{padding:"0 10px"},children:[E.rtt>=250?VA.jsx(Re,{name:"wifi1"}):"",E.rtt>=121&&E.rtt<250?VA.jsx(Re,{name:"wifi2"}):"",E.rtt<=120?VA.jsx(Re,{name:"wifi3"}):""]})})})}),u&&VA.jsxs(fS,{height:q,show:!!I&&yA,children:[VA.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[VA.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[(I==null?void 0:I.is_vip)===1&&VA.jsx(Re,{name:"vip"}),VA.jsx("span",{style:{marginLeft:5},children:I==null?void 0:I.customer_name})]}),VA.jsx("b",{children:I==null?void 0:I.phone})]}),VA.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[VA.jsxs("span",{children:[I==null?void 0:I.province,"-",I==null?void 0:I.city]}),qA&&VA.jsxs("span",{children:[qA==="out"?"呼出次数:":"呼入次数:",VA.jsx("span",{style:{color:"#1D92E9"},children:qA==="out"?I==null?void 0:I.contact_count:I==null?void 0:I.in_contact_count})]})]})]})]})}):VA.jsx(VA.Fragment,{}),VA.jsx(R.Suspense,{children:aA&&((qe=M.current)==null?void 0:qe.agent_api)&&VA.jsx(b6,{open:aA,queryFetch:M.current.agent_api.getIdleAgentList,onCallBack:N=>{iA(!1),N&&xe(N)}})}),VA.jsx(R.Suspense,{children:IA&&((RA=M.current)==null?void 0:RA.agent_api)&&VA.jsx(R6,{open:IA,queryFetch:M.current.agent_api.getIdleAgentList,onCallBack:(N,gA)=>{MA(!1),N&&(gA===0?pe(N):gA===1&&KA(N))}})})]})})},D6=e=>{var A;return(A=Bn.getInstance())==null?void 0:A.call_api.makeCall(e)},T6=()=>{var e;return(e=Bn.getInstance())==null?void 0:e.getRealTimeCustomerInfo()},F6=async e=>{var A,t;if(e!==ye.IDLE&&e!==ye.BUSY)throw new Error("Invalid agent state");try{await((t=(A=Bn.getInstance())==null?void 0:A.agent_api)==null?void 0:t.changeState({data:{state:e,state_name:e===ye.IDLE?"空闲":"忙碌"}}))}catch(n){console.error(n)}},O6=async e=>{var A,t;try{await((t=(A=Bn.getInstance())==null?void 0:A.agent_api)==null?void 0:t.changeDevice({data:{device:e}}))}catch(n){console.error(n)}},U6=async(e=!1,A)=>{var t,n;try{await((n=(t=Bn.getInstance())==null?void 0:t.agent_api)==null?void 0:n.agentLogout({data:{offline_answer:e},success:()=>{A==null||A()}}))}catch(r){console.log(r)}},k6=async(e,A)=>{var t;(t=Bn.getInstance())==null||t.call_api.previewMakeCall(e,A)};exports.Button=fi;exports.CONTAINER_MAX_OFFSET=Ag;exports.CSSMotion=qi;exports.ConfigContext=Ue;exports.ConfigProvider=nr;exports.ContextIsolator=ma;exports.DisabledContextProvider=Ym;exports.Empty=gr;exports.FastColor=Ke;exports.Input=zr;exports.KeyCode=re;exports.Keyframe=Oe;exports.ModelBody=VS;exports.Portal=Ac;exports.Radio=Oa;exports.RefIcon=oc;exports.RefIcon$1=Cg;exports.RefIcon$2=Ua;exports.RefIcon$3=mg;exports.RefIcon$4=vg;exports.Space=ic;exports.Spin=lc;exports.Wave=Zl;exports.YsytBarPhone=x6;exports.YsytIconSvg=Re;exports._extends=FA;exports._objectSpread2=k;exports._slicedToArray=$;exports._toConsumableArray=wA;exports._typeof=Ae;exports.agentLogout=U6;exports.canUseDom=Ut;exports.classNames=nA;exports.clearFix=Ys;exports.contains=Wq;exports.convertLegacyProps=ix;exports.devUseWarning=st;exports.genFocusStyle=Ns;exports.genPresetColor=Tm;exports.genStyleHooks=Qt;exports.genSubStyleComponent=Dm;exports.getConfirmLocale=Ky;exports.getCustomerInfo=T6;exports.getReactRender=rg;exports.getTransitionName=Jl;exports.globalConfig=bd;exports.initMotion=Gl;exports.initZoomMotion=ba;exports.isPresetColor=jv;exports.isPresetStatusColor=DF;exports.jsxRuntimeExports=VA;exports.localeValues=Vi;exports.makeCall=D6;exports.merge=Je;exports.omit=_t;exports.pickAttrs=jr;exports.previewMakeCall=k6;exports.replaceElement=b0;exports.resetComponent=Lt;exports.setAgentDevice=O6;exports.setAgentInitState=F6;exports.unit=mA;exports.useCSSVarCls=Kn;exports.useComponentConfig=tr;exports.useComposeRef=Jr;exports.useEvent=rt;exports.useId=Kl;exports.useLocale=yl;exports.useSafeState=ao;exports.useToken=gn;exports.useZIndex=xa;exports.warnContext=eC;exports.warning=Nr;exports.withPureRenderTheme=yv;exports.zIndexContext=Ra;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-DUQ5FeiU.js");exports.YsytAgentLogout=e.agentLogout;exports.YsytGetCustomerInfo=e.getCustomerInfo;exports.YsytMakeCall=e.makeCall;exports.YsytPreviewMakeCall=e.previewMakeCall;exports.YsytSetAgentDevice=e.setAgentDevice;exports.YsytSetAgentInitState=e.setAgentInitState;exports.default=e.YsytBarPhone;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-pLvaffe5.js");exports.YsytAgentLogout=e.agentLogout;exports.YsytGetCustomerInfo=e.getCustomerInfo;exports.YsytMakeCall=e.makeCall;exports.YsytPreviewMakeCall=e.previewMakeCall;exports.YsytSetAgentDevice=e.setAgentDevice;exports.YsytSetAgentInitState=e.setAgentInitState;exports.default=e.YsytBarPhone;
@@ -1,4 +1,4 @@
1
- import { ak as e, ah as s, ag as l, al as o, aj as y, ai as Y, af as g } from "./index-z-WTflF-.mjs";
1
+ import { ak as e, ah as s, ag as l, al as o, aj as y, ai as Y, af as g } from "./index-CPcFDOQg.mjs";
2
2
  export {
3
3
  e as YsytAgentLogout,
4
4
  s as YsytGetCustomerInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ysyt-react-agent-lib",
3
- "version": "1.0.98",
3
+ "version": "1.0.99",
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": "1.0.156"
32
+ "ysyt-agent-sdk": "1.0.157"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.2.0",