ysyt-react-agent-lib 1.2.44 → 1.2.46

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,6 +1,6 @@
1
- import { j as e, M as l, E as r, S as i, Y as d } from "./index-BPoDHym7.mjs";
1
+ import { j as e, M as l, E as r, S as i, Y as d } from "./index-DLugzJjU.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-CVaJHqrq.mjs";
3
+ import { M as p, T as j } from "./index-lr_E7MVo.mjs";
4
4
  const E = m(({ open: t, onCallBack: a, queryFetch: o }) => {
5
5
  const [n, c] = g([]);
6
6
  return x(() => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BffC-kL-.js"),s=require("react"),i=require("./index-C5zbL-su.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-B2ssxfsE.js"),s=require("react"),i=require("./index-DhX6Tx7f.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BffC-kL-.js"),t=require("react"),l=require("./index-C5zbL-su.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-B2ssxfsE.js"),t=require("react"),l=require("./index-DhX6Tx7f.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,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-BPoDHym7.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-DLugzJjU.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-CVaJHqrq.mjs";
3
+ import { M as I, T as M } from "./index-lr_E7MVo.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(() => {
@@ -152,7 +152,7 @@ React keys must be passed directly to JSX without using spread:
152
152
  `+i+`
153
153
  `);if(this.state===dt.Connected){if(this.onMessage)try{this.onMessage(i)}catch(o){throw this.logger.error(o.toString()),this.logger.error("Exception thrown by onMessage callback"),o}}else this.logger.warn("Received message while not connected, discarding...")}else this.logger.warn("Received empty message, discarding...")}onWebSocketOpen(e,n){n===this._ws&&this._state===dt.Connecting&&(this.logger.log(`WebSocket opened ${this.server}`),this.transitionState(dt.Connected))}transitionLoopDetectedError(e){let n="A state transition loop has been detected.";return n+=` An attempt to transition from ${this._state} to ${e} before the prior transition completed.`,n+=" Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?",this.logger.error(n),new ca("Loop detected.")}transitionState(e,n){const r=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};if(this.transitioningState)throw this.transitionLoopDetectedError(e);switch(this.transitioningState=!0,this._state){case dt.Connecting:e!==dt.Connected&&e!==dt.Disconnecting&&e!==dt.Disconnected&&r();break;case dt.Connected:e!==dt.Disconnecting&&e!==dt.Disconnected&&r();break;case dt.Disconnecting:e!==dt.Connecting&&e!==dt.Disconnected&&r();break;case dt.Disconnected:e!==dt.Connecting&&r();break;default:throw new Error("Unknown state.")}const i=this._state;this._state=e;const o=this.connectResolve,a=this.connectReject;i===dt.Connecting&&(this.connectPromise=void 0,this.connectResolve=void 0,this.connectReject=void 0);const s=this.disconnectResolve,A=this.disconnectReject;if(i===dt.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 ${i} to ${this._state}`),this._stateEventEmitter.emit(this._state),e===dt.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(i===dt.Connected&&(this.stopSendingKeepAlives(),this.onDisconnect))try{n?this.onDisconnect(n):this.onDisconnect()}catch(l){throw this.logger.error(l.toString()),this.logger.error("Exception thrown by onDisconnect callback"),l}if(i===dt.Connecting){if(!o)throw new Error("Connect resolve undefined.");if(!a)throw new Error("Connect reject undefined.");e===dt.Connected?o():a(n||new Error("Connect aborted."))}if(i===dt.Disconnecting){if(!s)throw new Error("Disconnect resolve undefined.");if(!A)throw new Error("Disconnect reject undefined.");e===dt.Disconnected?s():A(n||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()},(e=>{const n=.8*e;return 1e3*(Math.random()*(e-n)+n)})(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}};N0.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0};let jg=class _s{constructor(e={}){if(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=Bn.Stopped,this._stateEventEmitter=new ja,this.delegate=e.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},_s.defaultOptions()),{sipjsId:Yi(5)}),{uri:new Di("sip","anonymous."+Yi(6),"anonymous.invalid")}),{viaHost:Yi(12)+".invalid"}),_s.stripUndefinedProperties(e)),this.options.hackIpInContact)if(typeof this.options.hackIpInContact=="boolean"&&this.options.hackIpInContact){const i=Math.floor(Math.random()*254+1);this.options.viaHost="192.0.2."+i}else this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact);switch(this.loggerFactory=new nw,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=Mn.error;break;case"warn":this.loggerFactory.level=Mn.warn;break;case"log":this.loggerFactory.level=Mn.log;break;case"debug":this.loggerFactory.level=Mn.debug}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(n=>{const r=this.options[n];switch(n){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("· "+n+": "+r);break;case"authorizationPassword":this.logger.log("· "+n+": NOT SHOWN");break;case"transportConstructor":this.logger.log("· "+n+": "+r.name);break;default:this.logger.log("· "+n+": "+JSON.stringify(r))}})),this.options.transportOptions){const n=this.options.transportOptions,r=n.maxReconnectionAttempts,i=n.reconnectionTimeout;r!==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.'),i!==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.'),e.reconnectionDelay===void 0&&i!==void 0&&(this.options.reconnectionDelay=i),e.reconnectionAttempts===void 0&&r!==void 0&&(this.options.reconnectionAttempts=r)}if(e.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.'),e.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:_s.newUUID(),En.parse(this._instanceId,"uuid")===-1)throw new Error("Invalid instanceId.");this._userAgentCore=this.initCore()}static makeURI(e){return En.URIParse(e)}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:Ew(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:Br.Unsupported,sipExtensionReplaces:Br.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:N0,transportOptions:{},uri:new Di("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/0.21.1",viaHost:""}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const n=Math.floor(16*Math.random());return(e==="x"?n:n%4+8).toString(16)})}static stripUndefinedProperties(e){return Object.keys(e).reduce((n,r)=>(e[r]!==void 0&&(n[r]=e[r]),n),{})}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(e,n){return this.loggerFactory.getLogger(e,n)}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===Bn.Stopped?Promise.reject(new Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}start(){return this.state===Bn.Started?(this.logger.warn("User agent already started"),Promise.resolve()):(this.logger.log(`Starting ${this.configuration.uri}`),this.transitionState(Bn.Started),this.transport.connect())}async stop(){if(this.state===Bn.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(s=>{throw this.logger.error(s.message),s}),this.logger.log("Dispose of core"),this.userAgentCore.dispose(),this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this.transitionState(Bn.Stopped),Promise.resolve();const e=Object.assign({},this._publishers),n=Object.assign({},this._registerers),r=Object.assign({},this._sessions),i=Object.assign({},this._subscriptions),o=this.transport,a=this.userAgentCore;this.logger.log("Dispose of registerers");for(const s in n)n[s]&&await n[s].dispose().catch(A=>{throw this.logger.error(A.message),delete this._registerers[s],A});this.logger.log("Dispose of sessions");for(const s in r)r[s]&&await r[s].dispose().catch(A=>{throw this.logger.error(A.message),delete this._sessions[s],A});this.logger.log("Dispose of subscriptions");for(const s in i)i[s]&&await i[s].dispose().catch(A=>{throw this.logger.error(A.message),delete this._subscriptions[s],A});this.logger.log("Dispose of publishers");for(const s in e)e[s]&&await e[s].dispose().catch(A=>{throw this.logger.error(A.message),delete this._publishers[s],A});this.logger.log("Dispose of transport"),await o.dispose().catch(s=>{throw this.logger.error(s.message),s}),this.logger.log("Dispose of core"),a.dispose(),this.transitionState(Bn.Stopped)}_makeInviter(e,n){return new b0(this,e,n)}attemptReconnection(e=1){const n=this.options.reconnectionAttempts,r=this.options.reconnectionDelay;e>n?this.logger.log("Maximum reconnection attempts reached"):(this.logger.log(`Reconnection attempt ${e} of ${n} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${e} of ${n} - succeeded`)}).catch(i=>{this.logger.error(i.message),this.logger.log(`Reconnection attempt ${e} of ${n} - failed`),this.attemptReconnection(++e)})},e===1?0:1e3*r))}initContact(){const e=this.options.contactName!==""?this.options.contactName:Yi(8),n=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new Di("sip",e,this.options.viaHost,void 0,n),toString:(r={})=>{const i=r.anonymous||!1,o=r.outbound||!1,a=r.register||!1;let s="<";return s+=i?this.contact.tempGruu||`sip:anonymous@anonymous.invalid;transport=${n.transport?n.transport:"ws"}`:a?this.contact.uri:this.contact.pubGruu||this.contact.uri,o&&(s+=";ob"),s+=">",this.options.instanceIdAlwaysAdded&&(s+=';+sip.instance="<urn:uuid:'+this._instanceId+'>"'),s}}}initCore(){let e=[];e.push("outbound"),this.options.sipExtension100rel===Br.Supported&&e.push("100rel"),this.options.sipExtensionReplaces===Br.Supported&&e.push("replaces"),this.options.sipExtensionExtraSupported&&e.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(e=e.filter(o=>ew[o])),e=Array.from(new Set(e));const n=e.slice();(this.contact.pubGruu||this.contact.tempGruu)&&n.push("gruu");const r={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:e,supportedOptionTagsResponse:n,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{const o=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,a=this.options.authorizationPassword?this.options.authorizationPassword:void 0,s=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new tw(this.getLoggerFactory(),s,o,a)},transportAccessor:()=>this.transport},i={onInvite:o=>{var a;const s=new eu(this,o);if(o.delegate={onCancel:A=>{s._onCancel(A)},onTransportError:A=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},o.trying(),this.options.sipExtensionReplaces!==Br.Unsupported){const A=o.message.parseHeader("replaces");if(A){const l=A.call_id;if(typeof l!="string")throw new Error("Type of call id is not string");const u=A.replaces_to_tag;if(typeof u!="string")throw new Error("Type of to tag is not string");const d=A.replaces_from_tag;if(typeof d!="string")throw new Error("type of from tag is not string");const f=l+u+d,p=this.userAgentCore.dialogs.get(f);if(!p)return void s.reject({statusCode:481});if(!p.early&&A.early_only===!0)return void s.reject({statusCode:486});const m=this._sessions[l+d]||this._sessions[l+u]||void 0;if(!m)throw new Error("Session does not exist.");s._replacee=m}}if(!((a=this.delegate)===null||a===void 0)&&a.onInvite)return s.autoSendAnInitialProvisionalResponse?void s.progress().then(()=>{var A;if(((A=this.delegate)===null||A===void 0?void 0:A.onInvite)===void 0)throw new Error("onInvite undefined.");this.delegate.onInvite(s)}):void this.delegate.onInvite(s);s.reject({statusCode:486})},onMessage:o=>{if(this.delegate&&this.delegate.onMessage){const a=new y0(o);this.delegate.onMessage(a)}else o.accept()},onNotify:o=>{if(this.delegate&&this.delegate.onNotify){const a=new $c(o);this.delegate.onNotify(a)}else this.options.allowLegacyNotifications?o.accept():o.reject({statusCode:481})},onRefer:o=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(o):o.reject({statusCode:405})},onRegister:o=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(o):o.reject({statusCode:405})},onSubscribe:o=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(o):o.reject({statusCode:405})}};return new yw(r,i)}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=e=>this.onTransportDisconnect(e),this.transport.onMessage=e=>this.onTransportMessage(e)}onTransportConnect(){this.state!==Bn.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(e){this.state!==Bn.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(e),e&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(e){const n=Js.parseMessage(e,this.getLogger("sip.Parser"));if(!n)return void this.logger.warn("Failed to parse incoming message. Dropping.");if(this.state===Bn.Stopped&&n instanceof Fo)return void this.logger.warn(`Received ${n.method} request while stopped. Dropping.`);const r=()=>{const i=["from","to","call_id","cseq","via"];for(const o of i)if(!n.hasHeader(o))return this.logger.warn(`Missing mandatory header field : ${o}.`),!1;return!0};if(n instanceof Fo){if(!r())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!n.toTag&&n.callId.substr(0,5)===this.options.sipjsId)return void this.userAgentCore.replyStateless(n,{statusCode:482});const i=Qa(n.body),o=n.getHeader("content-length");if(o&&i<Number(o))return void this.userAgentCore.replyStateless(n,{statusCode:400})}if(n instanceof ki){if(!r())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(n.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(n.via.host!==this.options.viaHost||n.via.port!==void 0)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");const i=Qa(n.body),o=n.getHeader("content-length");if(o&&i<Number(o))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(n instanceof Fo)this.userAgentCore.receiveIncomingRequestFromTransport(n);else{if(!(n instanceof ki))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(n)}}transitionState(e,n){const r=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case Bn.Started:e!==Bn.Stopped&&r();break;case Bn.Stopped:e!==Bn.Started&&r();break;default:throw new Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${e}`),this._state=e,this._stateEventEmitter.emit(this._state)}},B0=class{constructor(e){this.listeners=[],this.keyListeners={},this.data={...e},this.proxy=new Proxy(this.data,{set:(n,r,i)=>(n[r]!==i&&(n[r]=i,this.notify(),this.notifyKey(r,i)),!0)})}getState(){return this.proxy}setState(e,n=!1){let r=!1;for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)){const o=this.data[i],a=e[i];(n||o!==a)&&(this.data[i]=a,r=!0,this.notifyKey(i,a))}(r||n)&&this.notify()}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(n=>n!==e)}}subscribeKey(e,n){return this.keyListeners[e]||(this.keyListeners[e]=[]),this.keyListeners[e].push(n),()=>{this.keyListeners[e]=this.keyListeners[e].filter(r=>r!==n)}}notify(){const e=this.getState();for(const n of this.listeners)n(e)}notifyKey(e,n){const r=this.keyListeners[e];r&&r.forEach(i=>i(n))}};var Mt,Rn,rt,lr,ie,He,Gt;(function(t){t[t.IDLE=1]="IDLE",t[t.BUSY=2]="BUSY",t[t.RINGING=3]="RINGING",t[t.OFFLINE=0]="OFFLINE",t[t.UNREGISTERED=4]="UNREGISTERED"})(Mt||(Mt={})),function(t){t.OUTGOING="outgoing",t.INCOMING="incoming",t.CONSULT="consult",t.MEETING="meeting",t.TRANSFER="transfer",t.PREDICT_OUT_CALL="predict_out_call"}(Rn||(Rn={})),function(t){t[t.OUT_CALL=100]="OUT_CALL",t[t.AGENT_STATE=101]="AGENT_STATE",t[t.OUT_CALL_INCOMING_CALL=102]="OUT_CALL_INCOMING_CALL",t[t.OUT_CALL_RINGING=103]="OUT_CALL_RINGING",t[t.OUT_CALL_ANSWER=104]="OUT_CALL_ANSWER",t[t.CALL_HOLD=105]="CALL_HOLD",t[t.CALL_UNHOLD=106]="CALL_UNHOLD",t[t.OUT_CALL_END=107]="OUT_CALL_END",t[t.CONSULT_REQUEST=108]="CONSULT_REQUEST",t[t.CONSULT_RINGING=109]="CONSULT_RINGING",t[t.CONSULT_ANSWER=110]="CONSULT_ANSWER",t[t.CONSULT_FAIL=111]="CONSULT_FAIL",t[t.MUTE=112]="MUTE",t[t.UNMUTE=113]="UNMUTE",t[t.CONSULT_CALL_IN=114]="CONSULT_CALL_IN",t[t.CONSULT_CALL_IN_SUCCESS=115]="CONSULT_CALL_IN_SUCCESS",t[t.CONSULT_RETURN_CALL=125]="CONSULT_RETURN_CALL",t[t.CONSULT_RETURN_CALL_SUCCESS=126]="CONSULT_RETURN_CALL_SUCCESS",t[t.CONSULT_TRANSFER=116]="CONSULT_TRANSFER",t[t.CONSULT_TRANSFER_FAILED=118]="CONSULT_TRANSFER_FAILED",t[t.CONSULT_TRANSFER_OFF_HOOK=117]="CONSULT_TRANSFER_OFF_HOOK",t[t.INCOMING_CALL=119]="INCOMING_CALL",t[t.INCOMING_CALL_OFF_HOOK=120]="INCOMING_CALL_OFF_HOOK",t[t.INCOMING_CALL_END=121]="INCOMING_CALL_END",t[t.SATISFACTION_EVALUATION=122]="SATISFACTION_EVALUATION",t[t.CONSULT_THREE_WAY=123]="CONSULT_THREE_WAY",t[t.CONSULT_THREE_WAY_RESULT=124]="CONSULT_THREE_WAY_RESULT",t[t.TRANSFER=127]="TRANSFER",t[t.TRANSFER_FAILED=128]="TRANSFER_FAILED",t[t.TRANSFER_INCOMING_CALL=129]="TRANSFER_INCOMING_CALL",t[t.TRANSFER_OFF_HOOK=130]="TRANSFER_OFF_HOOK",t[t.AGENT_HANGUP=131]="AGENT_HANGUP",t[t.KICK_OFFLINE=132]="KICK_OFFLINE",t[t.CONTINUOUS_NOT_ANSWER=133]="CONTINUOUS_NOT_ANSWER",t[t.PREVIEW_OUT_CALL=134]="PREVIEW_OUT_CALL",t[t.SIGN_OUT=135]="SIGN_OUT",t[t.SIGN_IN_SWITCH_DEVICE=136]="SIGN_IN_SWITCH_DEVICE",t[t.LISTEN_CALL_FAILED=137]="LISTEN_CALL_FAILED",t[t.LISTEN_INCOMING_CALL=138]="LISTEN_INCOMING_CALL",t[t.LISTEN_INCOMING_CALL_OFF_HOOK=139]="LISTEN_INCOMING_CALL_OFF_HOOK",t[t.EAR_SPEECH=140]="EAR_SPEECH",t[t.STOP_EAR_SPEECH=141]="STOP_EAR_SPEECH",t[t.CALL_FORCE_INSERT=142]="CALL_FORCE_INSERT",t[t.INTERNAL_CALL_START_CONSULT=145]="INTERNAL_CALL_START_CONSULT",t[t.INTERNAL_CALL_END_CONSULT=146]="INTERNAL_CALL_END_CONSULT",t[t.CALL_SIP_INCOMING_CALL=147]="CALL_SIP_INCOMING_CALL",t[t.CALL_REAL_TIME_TRANSCRIPT=148]="CALL_REAL_TIME_TRANSCRIPT"}(rt||(rt={})),function(t){t.WEB_RTC_CONNECTING="connecting",t.WEB_RTC_CONNECTED="connected",t.WEB_RTC_DISCONNECTING="disconnecting",t.WEB_RTC_DISCONNECTED="disconnected",t.WEB_RTC_REGISTERED="registered",t.WEB_RTC_UNREGISTERED="unregistered",t.WEB_RTC_TERMINATED="terminated",t.WEB_RTC_REGISTER_FAILED="register_failed",t.WEB_RTC_ANSWER_FAILED="answer_failed",t.WEB_RTC_SEND_DTMF="send_dtmf"}(lr||(lr={})),function(t){t.CUSTOMER_INFO="customer_info",t.CALL_PROGRESS="call_progress",t.OUT_INCOMING_CALL="out_call_incoming_call",t.INTERNAL_OUT_INCOMING_CALL="internal_out_incoming_call",t.PREVIEW_OUT_INCOMING_CALL="preview_out_incoming_call",t.OUT_SUCCESS="out_call_success",t.OUT_FAILED="out_call_failed",t.OUT_RINGING="out_call_ringing",t.OUT_OFF_ANSWER="out_call_answer",t.INTERNAL_OUT_OFF_ANSWER="internal_out_call_answer",t.HOLD_SUCCESS="hold_success",t.HOLD_FAILED="hold_failed",t.UNHOLD_SUCCESS="unhold_success",t.UNHOLD_FAILED="unhold_failed",t.OUT_HANGUP="out_call_hangup",t.CONSULT_RINGING="consult_ringing",t.CONSULT_OFF_HOOK="consult_off_hook",t.CONSULT_FAILED="consult_failed",t.CONSULT_INCOMING="consult_incoming",t.CONSULT_CALL_IN_SUCCESS="consult_call_in_success",t.CONSULT_RETURN_CALL_SUCCESS="consult_return_call_success",t.OTHER_SIDE_CONSULT_HANGUP="other_side_consult_hangup",t.OUR_SIDE_CONSULT_HANGUP="our_side_consult_hangup",t.AGENT_STATE="agent_state",t.MUTE_SUCCESS="mute_success",t.MUTE_FAILED="mute_failed",t.UNMUTE_SUCCESS="unmute_success",t.UNMUTE_FAILED="unmute_failed",t.CONSULT_TRANSFER_SUCCESS="consult_transfer_success",t.CONSULT_TRANSFER_FAILED="consult_transfer_failed",t.CONSULT_TRANSFER_OFF_HOOK="consult_transfer_off_hook",t.INCOMING_CALL="incoming_call",t.INCOMING_CALL_IN="incoming_call_in",t.PREDICT_INCOMING_CALL="predict_incoming_call",t.DUAL_CALL_INCOMING_CALL="dual_call_incoming_call",t.INCOMING_CALL_OFF_HOOK="incoming_call_off_hook",t.INCOMING_CALL_IN_OFF_HOOK="incoming_call_in_off_hook",t.INCOMING_CALL_END="incoming_call_end",t.SATISFACTION_EVALUATION_SUCCESS="satisfaction_evaluation_success",t.SATISFACTION_EVALUATION_FAILED="satisfaction_evaluation_failed",t.CONSULT_THREE_WAY_SUCCESS="consult_three_way_success",t.CONSULT_THREE_WAY_FAILED="consult_three_way_failed",t.THREE_WAY_OUR_SIDE_HANGUP="three_way_our_side_hangup",t.TRANSFER_FAILED="transfer_failed",t.TRANSFER_PROGRESS="transfer_progress",t.TRANSFER_INCOMING_CALL="transfer_incoming_call",t.TRANSFER_OFF_HOOK="transfer_off_hook",t.TRANSFER_END="transfer_end",t.REJECT="reject",t.LISTEN_CALL_FAILED="listen_call_failed",t.LISTEN_INCOMING_CALL="listen_incoming_call",t.LISTEN_INCOMING_CALL_OFF_HOOK="listen_incoming_call_off_hook",t.LISTEN_HANGUP="listen_hangup",t.EAR_SPEECH_SUCCESS="ear_speech_success",t.EAR_SPEECH_BE_SUCCESS="ear_speech_be_success",t.EAR_SPEECH_FAILED="ear_speech_failed",t.STOP_EAR_SPEECH_SUCCESS="stop_ear_speech_success",t.STOP_EAR_SPEECH_FAILED="stop_ear_speech_failed",t.CALL_FORCE_INSERT_SUCCESS="call_force_insert_success",t.CALL_FORCE_INSERT_SUCCESS_LISTENER="call_force_insert_success_listener",t.CALL_FORCE_INSERT_FAILED="call_force_insert_failed",t.CALL_SIP_INCOMING_CALL="call_sip_incoming_call",t.REAL_TIME_TRANSCRIPTION="real_time_transcription"}(ie||(ie={})),function(t){t.EVENT_ALL="event_all",t.NOTIFICATION_CLICK="notification_click",t.UPDATE_ANSWER_DEVICE="update_answer_device",t.PHONE_BAR_OPERATION="phone_bar_operation",t.AGENT_INIT_STATUS="agent_init_status",t.WEBSITE_DELAY="website_delay",t.SELECT_EXTERNAL_NUMBER="select_external_number",t.FAIL_NOTIFICATION="fail_notification",t.KICK_OFF="kick_off",t.DESTROY="destroy",t.NETWORK_OFFLINE="network_offline",t.NETWORK_ONLINE="network_online",t.SIGN_OUT="sign_out",t.SIGN_IN_SWITCH_DEVICE="sign_in_switch_device"}(He||(He={})),function(t){t.RINGING="客户振铃",t.AGENT_RINGING="振铃中",t.CALLING="通话中",t.CONSULTING="正在咨询",t.CONSULT_CALL_IN="咨询来电",t.INCOMING_CALL="客户来电",t.MEETING="会议中",t.TRANSFERRING="转接中",t.TRANSFER_INCOMING_CALL="转接来电",t.HOLDING="保持中",t.MUTING="静音中",t.LISTENING="监听来电",t.LINKING="正在链接",t.OTHER_SIDE_CONSULTING="对方正咨询"}(Gt||(Gt={}));const ua={all:Ci=Ci||new Map,on:function(t,e){var n=Ci.get(t);n?n.push(e):Ci.set(t,[e])},off:function(t,e){var n=Ci.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):Ci.set(t,[]))},emit:function(t,e){var n=Ci.get(t);n&&n.slice().map(function(r){r(e)}),(n=Ci.get("*"))&&n.slice().map(function(r){r(t,e)})}};var Ci;const ue={on:(t,e)=>(ua.on(t,e),ue),off(t,e){ua.off(t,e)},emit(t,e){ua.emit(t,e),ua.emit(He.EVENT_ALL,{event:t,data:e})},clearAllListeners(){ua.all.clear()}},Z={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null,autoAnswerTimer:null,logBuiltinEnabled:!1,browserAlertTime:3e3,latency:0,monitoredAgentNo:"",earSpeakAgent:"",stateObject:{state:Mt.BUSY,state_name:"忙碌"},isAgentHangup:!1},yr={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,isSipConnected:!1},H=new class extends B0{updateIsCalling(t){this.setState({isCalling:t})}updateDirection(t){this.setState({direction:t})}updateOutCallIsAnswer(t){this.setState({outCallIsAnswer:t})}updateIsHold(t){var n;if(((n=Z.stateObject)==null?void 0:n.state)===Mt.UNREGISTERED)return;const e=this.get("actionConfigs");if(t){const r=[...e.filter(i=>i!=="hold")];r.push("unhold"),this.updateActionConfigs(r)}else{const r=[...e.filter(i=>i!=="unhold")];r.push("hold"),this.updateActionConfigs(r)}this.setState({isHold:t})}updateDisplayText(t){this.setState({displayText:t}),ue.emit(ie.CALL_PROGRESS,t)}updateActionConfigs(t,e=!0){const{show_satisfaction:n}=Z.agentInfo||{},r=this.get("answerDevice"),i=t.filter(o=>(n!==0||o!=="satisfaction"||!e)&&(r!==2&&r!==3||o!=="answer"));this.setState({actionConfigs:i}),ue.emit(He.PHONE_BAR_OPERATION,i)}updateConsultIsAnswer(t){this.setState({consultIsAnswer:t})}updateIsMuted(t){var n;if(((n=Z.stateObject)==null?void 0:n.state)===Mt.UNREGISTERED)return;const e=this.get("actionConfigs");if(t){const r=[...e.filter(i=>i!=="mute")];r.push("unmute"),this.updateActionConfigs(r)}else{const r=[...e.filter(i=>i!=="unmute")];r.push("mute"),this.updateActionConfigs(r)}this.setState({isMuted:t})}updateIncomingIsAnswer(t){this.setState({incomingIsAnswer:t})}updateAnswerDevice(t){this.setState({answerDevice:t}),ue.emit(He.UPDATE_ANSWER_DEVICE,t)}updateIsMeeting(t){this.setState({isMeeting:t})}updateTransferIsAnswer(t){this.setState({transferIsAnswer:t})}updateSelectOutNumber(t){ue.emit(He.SELECT_EXTERNAL_NUMBER,t),this.setState({selectOutNumber:t})}updateCustomerInfo(t){const e=this.get("displayText");if(t&&e){const{contact_count:n,customer_name:r,phone:i,city:o,province:a,is_vip:s,in_contact_count:A,trace_id:l,contact_count_month:u,in_contact_count_month:d,type:f,session_id:p}=t;ue.emit(ie.CUSTOMER_INFO,{customer_name:r||"未知客户",phone:i,city:o||"未知",province:a||"未知",contact_count:n||0,in_contact_count:A||0,is_vip:s,trace_id:l,contact_count_month:u||0,in_contact_count_month:d||0,type:f,session_id:p})}else ue.emit(ie.CUSTOMER_INFO,void 0);this.setState({customerObject:t})}updateIsNextState(t){this.setState({isNextState:t}),t?ue.emit(He.NETWORK_ONLINE):(Z.stateObject={state:Mt.OFFLINE,state_name:"离线"},this.updateActionConfigs([]),ue.emit(ie.AGENT_STATE,Z.stateObject),ue.emit(He.NETWORK_OFFLINE))}updateIsSipConnected(t){this.setState({isSipConnected:t})}reset(){this.updateAnswerDevice(1),this.updateIsCalling(yr.isCalling),this.updateDirection(yr.direction),this.updateOutCallIsAnswer(yr.outCallIsAnswer),this.updateIsHold(yr.isHold),this.updateDisplayText(yr.displayText),this.updateActionConfigs(yr.actionConfigs),this.updateConsultIsAnswer(yr.consultIsAnswer),this.updateIsMuted(yr.isMuted),this.updateIncomingIsAnswer(yr.incomingIsAnswer),this.updateIsMeeting(yr.isMeeting),this.updateTransferIsAnswer(yr.transferIsAnswer),this.updateCustomerInfo(void 0)}getCallInfo(){return this.getState()}get(t){return this.getState()[t]}}(yr),F0=new class extends B0{updateRttObject(t){this.setState({rttObject:t}),ue.emit(He.WEBSITE_DELAY,t)}}({rttObject:{rtt:null,jitter:null,packetsLost:null,packetsReceived:null,packetsSent:null,sendBitrate:null,recvBitrate:null,codec:null}});let Qg=class extends Error{constructor(n,r,i){const o=`${n.status||n.status===0?n.status:""} ${n.statusText||""}`.trim();super(`Request failed with ${o?`status code ${o}`:"an unknown error"}: ${r.method} ${r.url}`);vr(this,"response");vr(this,"request");vr(this,"options");this.name="HTTPError",this.response=n,this.request=r,this.options=i}};class Lg extends Error{constructor(n){super(`Request timed out: ${n.method} ${n.url}`);vr(this,"request");this.name="TimeoutError",this.request=n}}const Ug=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(n&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return t&&!e})(),bw=typeof globalThis.AbortController=="function",Sw=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ww=typeof globalThis.ReadableStream=="function",Iw=typeof globalThis.FormData=="function",k0=["get","post","put","patch","head","delete"],xw={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Hg=2147483647,Rw=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,P0=Symbol("stop"),Ow={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Mw={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},Tw=(t,e)=>{const n=(i=>{if(!i)return 0;if(i instanceof FormData){let o=0;for(const[a,s]of i)o+=Rw,o+=new TextEncoder().encode(`Content-Disposition: form-data; name="${a}"`).length,o+=typeof s=="string"?new TextEncoder().encode(s).length:s.size;return o}if(i instanceof Blob)return i.size;if(i instanceof ArrayBuffer)return i.byteLength;if(typeof i=="string")return new TextEncoder().encode(i).length;if(i instanceof URLSearchParams)return new TextEncoder().encode(i.toString()).length;if("byteLength"in i)return i.byteLength;if(typeof i=="object"&&i!==null)try{const o=JSON.stringify(i);return new TextEncoder().encode(o).length}catch{return 0}return 0})(t.body);let r=0;return new Request(t,{duplex:"half",body:new ReadableStream({async start(i){const o=t.body instanceof ReadableStream?t.body.getReader():new Response("").body.getReader();await async function a(){const{done:s,value:A}=await o.read();if(s)return e&&e({percent:1,transferredBytes:r,totalBytes:Math.max(n,r)},new Uint8Array),void i.close();r+=A.byteLength;let l=n===0?0:r/n;(n<r||l===1)&&(l=.99),e&&e({percent:Number(l.toFixed(2)),transferredBytes:r,totalBytes:n},A),i.enqueue(A),await a()}()}})})},ma=t=>t!==null&&typeof t=="object",Rs=(...t)=>{for(const e of t)if((!ma(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return Kd({},...t)},j0=(t={},e={})=>{const n=new globalThis.Headers(t),r=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[o,a]of i.entries())r&&a==="undefined"||a===void 0?n.delete(o):n.set(o,a);return n};function Os(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:Kd(t[n]??[],e[n]??[])}const Q0=(t={},e={})=>({beforeRequest:Os(t,e,"beforeRequest"),beforeRetry:Os(t,e,"beforeRetry"),afterResponse:Os(t,e,"afterResponse"),beforeError:Os(t,e,"beforeError")}),Kd=(...t)=>{let e={},n={},r={};for(const i of t)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(ma(i)){for(let[o,a]of Object.entries(i))ma(a)&&o in e&&(a=Kd(e[o],a)),e={...e,[o]:a};ma(i.hooks)&&(r=Q0(r,i.hooks),e.hooks=r),ma(i.headers)&&(n=j0(n,i.headers),e.headers=n)}return e},Nw=t=>k0.includes(t)?t.toUpperCase():t,Gg={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3},Dw=(t={})=>{if(typeof t=="number")return{...Gg,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Gg,...t}};class gA{constructor(e,n={}){vr(this,"request");vr(this,"abortController");vr(this,"_retryCount",0);vr(this,"_input");vr(this,"_options");var r,i;if(this._input=e,this._options={...n,headers:j0(this._input.headers,n.headers),hooks:Q0({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:Nw(n.method??this._input.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:Dw(n.retry),throwHttpErrors:n.throwHttpErrors!==!1,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(bw&&Sw){const o=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=o?AbortSignal.any([o,this.abortController.signal]):this.abortController.signal}if(Ug&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((i=(r=this._options).stringifyJson)==null?void 0:i.call(r,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const o="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,o);!(Iw&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Ug)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Tw(this.request,this._options.onUploadProgress))}}static create(e,n){const r=new gA(e,n),i=async()=>{if(typeof r._options.timeout=="number"&&r._options.timeout>Hg)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let a=await r._fetch();for(const s of r._options.hooks.afterResponse){const A=await s(r.request,r._options,r._decorateResponse(a.clone()));A instanceof globalThis.Response&&(a=A)}if(r._decorateResponse(a),!a.ok&&r._options.throwHttpErrors){let s=new Qg(a,r.request,r._options);for(const A of r._options.hooks.beforeError)s=await A(s);throw s}if(r._options.onDownloadProgress){if(typeof r._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!ww)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((s,A)=>{const l=Number(s.headers.get("content-length"))||0;let u=0;return s.status===204?(A&&A({percent:1,totalBytes:l,transferredBytes:u},new Uint8Array),new Response(null,{status:s.status,statusText:s.statusText,headers:s.headers})):new Response(new ReadableStream({async start(d){const f=s.body.getReader();A&&A({percent:0,transferredBytes:0,totalBytes:l},new Uint8Array),await async function p(){const{done:m,value:C}=await f.read();m?d.close():(A&&(u+=C.byteLength,A({percent:l===0?0:u/l,transferredBytes:u,totalBytes:l},C)),d.enqueue(C),await p())}()}}),{status:s.status,statusText:s.statusText,headers:s.headers})})(a.clone(),r._options.onDownloadProgress)}return a},o=(r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(i):i()).finally(async()=>{var a;r.request.bodyUsed||await((a=r.request.body)==null?void 0:a.cancel())});for(const[a,s]of Object.entries(xw))o[a]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||s);const A=await o;if(a==="json"){if(A.status===204||(await A.clone().arrayBuffer()).byteLength===0)return"";if(n.parseJson)return n.parseJson(await A.text())}return A[a]()};return o}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount>this._options.retry.limit||e instanceof Lg)throw e;if(e instanceof Qg){if(!this._options.retry.statusCodes.includes(e.response.status))throw e;const r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this._options.retry.afterStatusCodes.includes(e.response.status)){let i=1e3*Number(r);Number.isNaN(i)?i=Date.parse(r)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());const o=this._options.retry.maxRetryAfter??i;return i<o?i:o}if(e.response.status===413)throw e}const n=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,n)}_decorateResponse(e){return this._options.parseJson&&(e.json=async()=>this._options.parseJson(await e.text())),e}async _retry(e){try{return await e()}catch(n){const r=Math.min(this._calculateRetryDelay(n),Hg);if(this._retryCount<1)throw n;await async function(i,{signal:o}){return new Promise((a,s)=>{function A(){clearTimeout(l),s(o.reason)}o&&(o.throwIfAborted(),o.addEventListener("abort",A,{once:!0}));const l=setTimeout(()=>{o==null||o.removeEventListener("abort",A),a()},i)})}(r,{signal:this._options.signal});for(const i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:n,retryCount:this._retryCount})===P0)return;return this._retry(e)}}async _fetch(){for(const r of this._options.hooks.beforeRequest){const i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}const e=((r,i)=>{const o={};for(const a in i)a in Mw||a in Ow||a in r||(o[a]=i[a]);return o})(this.request,this._options),n=this.request;return this.request=n.clone(),this._options.timeout===!1?this._options.fetch(n,e):async function(r,i,o,a){return new Promise((s,A)=>{const l=setTimeout(()=>{o&&o.abort(),A(new Lg(r))},a.timeout);a.fetch(r,i).then(s).catch(A).then(()=>{clearTimeout(l)})})}(n,e,this.abortController,this._options)}}/*! MIT License © Sindre Sorhus */const ru=t=>{const e=(n,r)=>gA.create(n,Rs(t,r));for(const n of k0)e[n]=(r,i)=>gA.create(r,Rs(t,i,{method:n}));return e.create=n=>ru(Rs(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),ru(Rs(t,n))),e.stop=P0,e};var zl,Bw=ru(),Fw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},L0={exports:{}};/**
155
+ `))}startSendingKeepAlives(){this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(()=>{this.sendKeepAlive(),this.startSendingKeepAlives()},(e=>{const n=.8*e;return 1e3*(Math.random()*(e-n)+n)})(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}};N0.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0};let jg=class _s{constructor(e={}){if(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=Bn.Stopped,this._stateEventEmitter=new ja,this.delegate=e.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},_s.defaultOptions()),{sipjsId:Yi(5)}),{uri:new Di("sip","anonymous."+Yi(6),"anonymous.invalid")}),{viaHost:Yi(12)+".invalid"}),_s.stripUndefinedProperties(e)),this.options.hackIpInContact)if(typeof this.options.hackIpInContact=="boolean"&&this.options.hackIpInContact){const i=Math.floor(Math.random()*254+1);this.options.viaHost="192.0.2."+i}else this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact);switch(this.loggerFactory=new nw,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=Mn.error;break;case"warn":this.loggerFactory.level=Mn.warn;break;case"log":this.loggerFactory.level=Mn.log;break;case"debug":this.loggerFactory.level=Mn.debug}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(n=>{const r=this.options[n];switch(n){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("· "+n+": "+r);break;case"authorizationPassword":this.logger.log("· "+n+": NOT SHOWN");break;case"transportConstructor":this.logger.log("· "+n+": "+r.name);break;default:this.logger.log("· "+n+": "+JSON.stringify(r))}})),this.options.transportOptions){const n=this.options.transportOptions,r=n.maxReconnectionAttempts,i=n.reconnectionTimeout;r!==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.'),i!==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.'),e.reconnectionDelay===void 0&&i!==void 0&&(this.options.reconnectionDelay=i),e.reconnectionAttempts===void 0&&r!==void 0&&(this.options.reconnectionAttempts=r)}if(e.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.'),e.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:_s.newUUID(),En.parse(this._instanceId,"uuid")===-1)throw new Error("Invalid instanceId.");this._userAgentCore=this.initCore()}static makeURI(e){return En.URIParse(e)}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:Ew(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:Br.Unsupported,sipExtensionReplaces:Br.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:N0,transportOptions:{},uri:new Di("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/0.21.1",viaHost:""}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const n=Math.floor(16*Math.random());return(e==="x"?n:n%4+8).toString(16)})}static stripUndefinedProperties(e){return Object.keys(e).reduce((n,r)=>(e[r]!==void 0&&(n[r]=e[r]),n),{})}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(e,n){return this.loggerFactory.getLogger(e,n)}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===Bn.Stopped?Promise.reject(new Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}start(){return this.state===Bn.Started?(this.logger.warn("User agent already started"),Promise.resolve()):(this.logger.log(`Starting ${this.configuration.uri}`),this.transitionState(Bn.Started),this.transport.connect())}async stop(){if(this.state===Bn.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(s=>{throw this.logger.error(s.message),s}),this.logger.log("Dispose of core"),this.userAgentCore.dispose(),this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this.transitionState(Bn.Stopped),Promise.resolve();const e=Object.assign({},this._publishers),n=Object.assign({},this._registerers),r=Object.assign({},this._sessions),i=Object.assign({},this._subscriptions),o=this.transport,a=this.userAgentCore;this.logger.log("Dispose of registerers");for(const s in n)n[s]&&await n[s].dispose().catch(A=>{throw this.logger.error(A.message),delete this._registerers[s],A});this.logger.log("Dispose of sessions");for(const s in r)r[s]&&await r[s].dispose().catch(A=>{throw this.logger.error(A.message),delete this._sessions[s],A});this.logger.log("Dispose of subscriptions");for(const s in i)i[s]&&await i[s].dispose().catch(A=>{throw this.logger.error(A.message),delete this._subscriptions[s],A});this.logger.log("Dispose of publishers");for(const s in e)e[s]&&await e[s].dispose().catch(A=>{throw this.logger.error(A.message),delete this._publishers[s],A});this.logger.log("Dispose of transport"),await o.dispose().catch(s=>{throw this.logger.error(s.message),s}),this.logger.log("Dispose of core"),a.dispose(),this.transitionState(Bn.Stopped)}_makeInviter(e,n){return new b0(this,e,n)}attemptReconnection(e=1){const n=this.options.reconnectionAttempts,r=this.options.reconnectionDelay;e>n?this.logger.log("Maximum reconnection attempts reached"):(this.logger.log(`Reconnection attempt ${e} of ${n} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${e} of ${n} - succeeded`)}).catch(i=>{this.logger.error(i.message),this.logger.log(`Reconnection attempt ${e} of ${n} - failed`),this.attemptReconnection(++e)})},e===1?0:1e3*r))}initContact(){const e=this.options.contactName!==""?this.options.contactName:Yi(8),n=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new Di("sip",e,this.options.viaHost,void 0,n),toString:(r={})=>{const i=r.anonymous||!1,o=r.outbound||!1,a=r.register||!1;let s="<";return s+=i?this.contact.tempGruu||`sip:anonymous@anonymous.invalid;transport=${n.transport?n.transport:"ws"}`:a?this.contact.uri:this.contact.pubGruu||this.contact.uri,o&&(s+=";ob"),s+=">",this.options.instanceIdAlwaysAdded&&(s+=';+sip.instance="<urn:uuid:'+this._instanceId+'>"'),s}}}initCore(){let e=[];e.push("outbound"),this.options.sipExtension100rel===Br.Supported&&e.push("100rel"),this.options.sipExtensionReplaces===Br.Supported&&e.push("replaces"),this.options.sipExtensionExtraSupported&&e.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(e=e.filter(o=>ew[o])),e=Array.from(new Set(e));const n=e.slice();(this.contact.pubGruu||this.contact.tempGruu)&&n.push("gruu");const r={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:e,supportedOptionTagsResponse:n,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{const o=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,a=this.options.authorizationPassword?this.options.authorizationPassword:void 0,s=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new tw(this.getLoggerFactory(),s,o,a)},transportAccessor:()=>this.transport},i={onInvite:o=>{var a;const s=new eu(this,o);if(o.delegate={onCancel:A=>{s._onCancel(A)},onTransportError:A=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},o.trying(),this.options.sipExtensionReplaces!==Br.Unsupported){const A=o.message.parseHeader("replaces");if(A){const l=A.call_id;if(typeof l!="string")throw new Error("Type of call id is not string");const u=A.replaces_to_tag;if(typeof u!="string")throw new Error("Type of to tag is not string");const d=A.replaces_from_tag;if(typeof d!="string")throw new Error("type of from tag is not string");const f=l+u+d,p=this.userAgentCore.dialogs.get(f);if(!p)return void s.reject({statusCode:481});if(!p.early&&A.early_only===!0)return void s.reject({statusCode:486});const m=this._sessions[l+d]||this._sessions[l+u]||void 0;if(!m)throw new Error("Session does not exist.");s._replacee=m}}if(!((a=this.delegate)===null||a===void 0)&&a.onInvite)return s.autoSendAnInitialProvisionalResponse?void s.progress().then(()=>{var A;if(((A=this.delegate)===null||A===void 0?void 0:A.onInvite)===void 0)throw new Error("onInvite undefined.");this.delegate.onInvite(s)}):void this.delegate.onInvite(s);s.reject({statusCode:486})},onMessage:o=>{if(this.delegate&&this.delegate.onMessage){const a=new y0(o);this.delegate.onMessage(a)}else o.accept()},onNotify:o=>{if(this.delegate&&this.delegate.onNotify){const a=new $c(o);this.delegate.onNotify(a)}else this.options.allowLegacyNotifications?o.accept():o.reject({statusCode:481})},onRefer:o=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(o):o.reject({statusCode:405})},onRegister:o=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(o):o.reject({statusCode:405})},onSubscribe:o=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(o):o.reject({statusCode:405})}};return new yw(r,i)}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=e=>this.onTransportDisconnect(e),this.transport.onMessage=e=>this.onTransportMessage(e)}onTransportConnect(){this.state!==Bn.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(e){this.state!==Bn.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(e),e&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(e){const n=Js.parseMessage(e,this.getLogger("sip.Parser"));if(!n)return void this.logger.warn("Failed to parse incoming message. Dropping.");if(this.state===Bn.Stopped&&n instanceof Fo)return void this.logger.warn(`Received ${n.method} request while stopped. Dropping.`);const r=()=>{const i=["from","to","call_id","cseq","via"];for(const o of i)if(!n.hasHeader(o))return this.logger.warn(`Missing mandatory header field : ${o}.`),!1;return!0};if(n instanceof Fo){if(!r())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!n.toTag&&n.callId.substr(0,5)===this.options.sipjsId)return void this.userAgentCore.replyStateless(n,{statusCode:482});const i=Qa(n.body),o=n.getHeader("content-length");if(o&&i<Number(o))return void this.userAgentCore.replyStateless(n,{statusCode:400})}if(n instanceof ki){if(!r())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(n.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(n.via.host!==this.options.viaHost||n.via.port!==void 0)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");const i=Qa(n.body),o=n.getHeader("content-length");if(o&&i<Number(o))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(n instanceof Fo)this.userAgentCore.receiveIncomingRequestFromTransport(n);else{if(!(n instanceof ki))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(n)}}transitionState(e,n){const r=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case Bn.Started:e!==Bn.Stopped&&r();break;case Bn.Stopped:e!==Bn.Started&&r();break;default:throw new Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${e}`),this._state=e,this._stateEventEmitter.emit(this._state)}},B0=class{constructor(e){this.listeners=[],this.keyListeners={},this.data={...e},this.proxy=new Proxy(this.data,{set:(n,r,i)=>(n[r]!==i&&(n[r]=i,this.notify(),this.notifyKey(r,i)),!0)})}getState(){return this.proxy}setState(e,n=!1){let r=!1;for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)){const o=this.data[i],a=e[i];(n||o!==a)&&(this.data[i]=a,r=!0,this.notifyKey(i,a))}(r||n)&&this.notify()}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(n=>n!==e)}}subscribeKey(e,n){return this.keyListeners[e]||(this.keyListeners[e]=[]),this.keyListeners[e].push(n),()=>{this.keyListeners[e]=this.keyListeners[e].filter(r=>r!==n)}}notify(){const e=this.getState();for(const n of this.listeners)n(e)}notifyKey(e,n){const r=this.keyListeners[e];r&&r.forEach(i=>i(n))}};var Mt,Rn,rt,lr,ie,He,Gt;(function(t){t[t.IDLE=1]="IDLE",t[t.BUSY=2]="BUSY",t[t.RINGING=3]="RINGING",t[t.OFFLINE=0]="OFFLINE",t[t.UNREGISTERED=4]="UNREGISTERED"})(Mt||(Mt={})),function(t){t.OUTGOING="outgoing",t.INCOMING="incoming",t.CONSULT="consult",t.MEETING="meeting",t.TRANSFER="transfer",t.PREDICT_OUT_CALL="predict_out_call"}(Rn||(Rn={})),function(t){t[t.OUT_CALL=100]="OUT_CALL",t[t.AGENT_STATE=101]="AGENT_STATE",t[t.OUT_CALL_INCOMING_CALL=102]="OUT_CALL_INCOMING_CALL",t[t.OUT_CALL_RINGING=103]="OUT_CALL_RINGING",t[t.OUT_CALL_ANSWER=104]="OUT_CALL_ANSWER",t[t.CALL_HOLD=105]="CALL_HOLD",t[t.CALL_UNHOLD=106]="CALL_UNHOLD",t[t.OUT_CALL_END=107]="OUT_CALL_END",t[t.CONSULT_REQUEST=108]="CONSULT_REQUEST",t[t.CONSULT_RINGING=109]="CONSULT_RINGING",t[t.CONSULT_ANSWER=110]="CONSULT_ANSWER",t[t.CONSULT_FAIL=111]="CONSULT_FAIL",t[t.MUTE=112]="MUTE",t[t.UNMUTE=113]="UNMUTE",t[t.CONSULT_CALL_IN=114]="CONSULT_CALL_IN",t[t.CONSULT_CALL_IN_SUCCESS=115]="CONSULT_CALL_IN_SUCCESS",t[t.CONSULT_RETURN_CALL=125]="CONSULT_RETURN_CALL",t[t.CONSULT_RETURN_CALL_SUCCESS=126]="CONSULT_RETURN_CALL_SUCCESS",t[t.CONSULT_TRANSFER=116]="CONSULT_TRANSFER",t[t.CONSULT_TRANSFER_FAILED=118]="CONSULT_TRANSFER_FAILED",t[t.CONSULT_TRANSFER_OFF_HOOK=117]="CONSULT_TRANSFER_OFF_HOOK",t[t.INCOMING_CALL=119]="INCOMING_CALL",t[t.INCOMING_CALL_OFF_HOOK=120]="INCOMING_CALL_OFF_HOOK",t[t.INCOMING_CALL_END=121]="INCOMING_CALL_END",t[t.SATISFACTION_EVALUATION=122]="SATISFACTION_EVALUATION",t[t.CONSULT_THREE_WAY=123]="CONSULT_THREE_WAY",t[t.CONSULT_THREE_WAY_RESULT=124]="CONSULT_THREE_WAY_RESULT",t[t.TRANSFER=127]="TRANSFER",t[t.TRANSFER_FAILED=128]="TRANSFER_FAILED",t[t.TRANSFER_INCOMING_CALL=129]="TRANSFER_INCOMING_CALL",t[t.TRANSFER_OFF_HOOK=130]="TRANSFER_OFF_HOOK",t[t.AGENT_HANGUP=131]="AGENT_HANGUP",t[t.KICK_OFFLINE=132]="KICK_OFFLINE",t[t.CONTINUOUS_NOT_ANSWER=133]="CONTINUOUS_NOT_ANSWER",t[t.PREVIEW_OUT_CALL=134]="PREVIEW_OUT_CALL",t[t.SIGN_OUT=135]="SIGN_OUT",t[t.SIGN_IN_SWITCH_DEVICE=136]="SIGN_IN_SWITCH_DEVICE",t[t.LISTEN_CALL_FAILED=137]="LISTEN_CALL_FAILED",t[t.LISTEN_INCOMING_CALL=138]="LISTEN_INCOMING_CALL",t[t.LISTEN_INCOMING_CALL_OFF_HOOK=139]="LISTEN_INCOMING_CALL_OFF_HOOK",t[t.EAR_SPEECH=140]="EAR_SPEECH",t[t.STOP_EAR_SPEECH=141]="STOP_EAR_SPEECH",t[t.CALL_FORCE_INSERT=142]="CALL_FORCE_INSERT",t[t.INTERNAL_CALL_START_CONSULT=145]="INTERNAL_CALL_START_CONSULT",t[t.INTERNAL_CALL_END_CONSULT=146]="INTERNAL_CALL_END_CONSULT",t[t.CALL_SIP_INCOMING_CALL=147]="CALL_SIP_INCOMING_CALL",t[t.CALL_REAL_TIME_TRANSCRIPT=148]="CALL_REAL_TIME_TRANSCRIPT"}(rt||(rt={})),function(t){t.WEB_RTC_CONNECTING="connecting",t.WEB_RTC_CONNECTED="connected",t.WEB_RTC_DISCONNECTING="disconnecting",t.WEB_RTC_DISCONNECTED="disconnected",t.WEB_RTC_REGISTERED="registered",t.WEB_RTC_UNREGISTERED="unregistered",t.WEB_RTC_TERMINATED="terminated",t.WEB_RTC_REGISTER_FAILED="register_failed",t.WEB_RTC_ANSWER_FAILED="answer_failed",t.WEB_RTC_SEND_DTMF="send_dtmf"}(lr||(lr={})),function(t){t.CUSTOMER_INFO="customer_info",t.CALL_PROGRESS="call_progress",t.OUT_INCOMING_CALL="out_call_incoming_call",t.INTERNAL_OUT_INCOMING_CALL="internal_out_incoming_call",t.PREVIEW_OUT_INCOMING_CALL="preview_out_incoming_call",t.OUT_SUCCESS="out_call_success",t.OUT_FAILED="out_call_failed",t.OUT_RINGING="out_call_ringing",t.OUT_OFF_ANSWER="out_call_answer",t.INTERNAL_OUT_OFF_ANSWER="internal_out_call_answer",t.HOLD_SUCCESS="hold_success",t.HOLD_FAILED="hold_failed",t.UNHOLD_SUCCESS="unhold_success",t.UNHOLD_FAILED="unhold_failed",t.OUT_HANGUP="out_call_hangup",t.CONSULT_RINGING="consult_ringing",t.CONSULT_OFF_HOOK="consult_off_hook",t.CONSULT_FAILED="consult_failed",t.CONSULT_INCOMING="consult_incoming",t.CONSULT_CALL_IN_SUCCESS="consult_call_in_success",t.CONSULT_RETURN_CALL_SUCCESS="consult_return_call_success",t.OTHER_SIDE_CONSULT_HANGUP="other_side_consult_hangup",t.OUR_SIDE_CONSULT_HANGUP="our_side_consult_hangup",t.AGENT_STATE="agent_state",t.MUTE_SUCCESS="mute_success",t.MUTE_FAILED="mute_failed",t.UNMUTE_SUCCESS="unmute_success",t.UNMUTE_FAILED="unmute_failed",t.CONSULT_TRANSFER_SUCCESS="consult_transfer_success",t.CONSULT_TRANSFER_FAILED="consult_transfer_failed",t.CONSULT_TRANSFER_OFF_HOOK="consult_transfer_off_hook",t.INCOMING_CALL="incoming_call",t.INCOMING_CALL_IN="incoming_call_in",t.PREDICT_INCOMING_CALL="predict_incoming_call",t.DUAL_CALL_INCOMING_CALL="dual_call_incoming_call",t.INCOMING_CALL_OFF_HOOK="incoming_call_off_hook",t.INCOMING_CALL_IN_OFF_HOOK="incoming_call_in_off_hook",t.INCOMING_CALL_END="incoming_call_end",t.SATISFACTION_EVALUATION_SUCCESS="satisfaction_evaluation_success",t.SATISFACTION_EVALUATION_FAILED="satisfaction_evaluation_failed",t.CONSULT_THREE_WAY_SUCCESS="consult_three_way_success",t.CONSULT_THREE_WAY_FAILED="consult_three_way_failed",t.THREE_WAY_OUR_SIDE_HANGUP="three_way_our_side_hangup",t.TRANSFER_FAILED="transfer_failed",t.TRANSFER_PROGRESS="transfer_progress",t.TRANSFER_INCOMING_CALL="transfer_incoming_call",t.TRANSFER_OFF_HOOK="transfer_off_hook",t.TRANSFER_END="transfer_end",t.REJECT="reject",t.LISTEN_CALL_FAILED="listen_call_failed",t.LISTEN_INCOMING_CALL="listen_incoming_call",t.LISTEN_INCOMING_CALL_OFF_HOOK="listen_incoming_call_off_hook",t.LISTEN_HANGUP="listen_hangup",t.EAR_SPEECH_SUCCESS="ear_speech_success",t.EAR_SPEECH_BE_SUCCESS="ear_speech_be_success",t.EAR_SPEECH_FAILED="ear_speech_failed",t.STOP_EAR_SPEECH_SUCCESS="stop_ear_speech_success",t.STOP_EAR_SPEECH_FAILED="stop_ear_speech_failed",t.CALL_FORCE_INSERT_SUCCESS="call_force_insert_success",t.CALL_FORCE_INSERT_SUCCESS_LISTENER="call_force_insert_success_listener",t.CALL_FORCE_INSERT_FAILED="call_force_insert_failed",t.CALL_SIP_INCOMING_CALL="call_sip_incoming_call",t.REAL_TIME_TRANSCRIPTION="real_time_transcription"}(ie||(ie={})),function(t){t.EVENT_ALL="event_all",t.NOTIFICATION_CLICK="notification_click",t.UPDATE_ANSWER_DEVICE="update_answer_device",t.PHONE_BAR_OPERATION="phone_bar_operation",t.AGENT_INIT_STATUS="agent_init_status",t.WEBSITE_DELAY="website_delay",t.SELECT_EXTERNAL_NUMBER="select_external_number",t.FAIL_NOTIFICATION="fail_notification",t.KICK_OFF="kick_off",t.DESTROY="destroy",t.NETWORK_OFFLINE="network_offline",t.NETWORK_ONLINE="network_online",t.SIGN_OUT="sign_out",t.SIGN_IN_SWITCH_DEVICE="sign_in_switch_device"}(He||(He={})),function(t){t.RINGING="客户振铃",t.AGENT_RINGING="振铃中",t.CALLING="通话中",t.CONSULTING="正在咨询",t.CONSULT_CALL_IN="咨询来电",t.INCOMING_CALL="客户来电",t.MEETING="会议中",t.TRANSFERRING="转接中",t.TRANSFER_INCOMING_CALL="转接来电",t.HOLDING="保持中",t.MUTING="静音中",t.LISTENING="监听来电",t.LINKING="正在链接",t.OTHER_SIDE_CONSULTING="对方正咨询"}(Gt||(Gt={}));const ua={all:Ci=Ci||new Map,on:function(t,e){var n=Ci.get(t);n?n.push(e):Ci.set(t,[e])},off:function(t,e){var n=Ci.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):Ci.set(t,[]))},emit:function(t,e){var n=Ci.get(t);n&&n.slice().map(function(r){r(e)}),(n=Ci.get("*"))&&n.slice().map(function(r){r(t,e)})}};var Ci;const ue={on:(t,e)=>(ua.on(t,e),ue),off(t,e){ua.off(t,e)},emit(t,e){ua.emit(t,e),ua.emit(He.EVENT_ALL,{event:t,data:e})},clearAllListeners(){ua.all.clear()}},Z={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null,autoAnswerTimer:null,logBuiltinEnabled:!1,browserAlertTime:3e3,latency:0,monitoredAgentNo:"",earSpeakAgent:"",stateObject:{state:Mt.BUSY,state_name:"忙碌"},isAgentHangup:!1},yr={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,isSipConnected:!1},H=new class extends B0{updateIsCalling(t){this.setState({isCalling:t})}updateDirection(t){this.setState({direction:t})}updateOutCallIsAnswer(t){this.setState({outCallIsAnswer:t})}updateIsHold(t){var n;if(((n=Z.stateObject)==null?void 0:n.state)===Mt.UNREGISTERED)return;const e=this.get("actionConfigs");if(t){const r=[...e.filter(i=>i!=="hold")];r.push("unhold"),this.updateActionConfigs(r)}else{const r=[...e.filter(i=>i!=="unhold")];r.push("hold"),this.updateActionConfigs(r)}this.setState({isHold:t})}updateDisplayText(t){this.setState({displayText:t}),ue.emit(ie.CALL_PROGRESS,t)}updateActionConfigs(t,e=!0){const{show_satisfaction:n}=Z.agentInfo||{},r=this.get("answerDevice"),i=t.filter(o=>(n!==0||o!=="satisfaction"||!e)&&(r!==2&&r!==3||o!=="answer"));this.setState({actionConfigs:i}),ue.emit(He.PHONE_BAR_OPERATION,i)}updateConsultIsAnswer(t){this.setState({consultIsAnswer:t})}updateIsMuted(t){var n;if(((n=Z.stateObject)==null?void 0:n.state)===Mt.UNREGISTERED)return;const e=this.get("actionConfigs");if(t){const r=[...e.filter(i=>i!=="mute")];r.push("unmute"),this.updateActionConfigs(r)}else{const r=[...e.filter(i=>i!=="unmute")];r.push("mute"),this.updateActionConfigs(r)}this.setState({isMuted:t})}updateIncomingIsAnswer(t){this.setState({incomingIsAnswer:t})}updateAnswerDevice(t){this.setState({answerDevice:t}),ue.emit(He.UPDATE_ANSWER_DEVICE,t)}updateIsMeeting(t){this.setState({isMeeting:t})}updateTransferIsAnswer(t){this.setState({transferIsAnswer:t})}updateSelectOutNumber(t){ue.emit(He.SELECT_EXTERNAL_NUMBER,t),this.setState({selectOutNumber:t})}updateCustomerInfo(t){const e=this.get("displayText");if(t&&e){const{contact_count:n,customer_name:r,phone:i,city:o,province:a,is_vip:s,in_contact_count:A,trace_id:l,contact_count_month:u,in_contact_count_month:d,type:f,session_id:p}=t;ue.emit(ie.CUSTOMER_INFO,{customer_name:r||"未知客户",phone:i,city:o||"未知",province:a||"未知",contact_count:n||0,in_contact_count:A||0,is_vip:s,trace_id:l,contact_count_month:u||0,in_contact_count_month:d||0,type:f,session_id:p})}else ue.emit(ie.CUSTOMER_INFO,void 0);this.setState({customerObject:t})}updateIsNextState(t){this.setState({isNextState:t}),t?ue.emit(He.NETWORK_ONLINE):(Z.stateObject={state:Mt.OFFLINE,state_name:"离线"},this.updateActionConfigs([]),ue.emit(ie.AGENT_STATE,Z.stateObject),ue.emit(He.NETWORK_OFFLINE))}updateIsSipConnected(t){this.setState({isSipConnected:t})}reset(){this.updateIsCalling(yr.isCalling),this.updateDirection(yr.direction),this.updateOutCallIsAnswer(yr.outCallIsAnswer),this.updateIsHold(yr.isHold),this.updateDisplayText(yr.displayText),this.updateActionConfigs(yr.actionConfigs),this.updateConsultIsAnswer(yr.consultIsAnswer),this.updateIsMuted(yr.isMuted),this.updateIncomingIsAnswer(yr.incomingIsAnswer),this.updateIsMeeting(yr.isMeeting),this.updateTransferIsAnswer(yr.transferIsAnswer),this.updateCustomerInfo(void 0)}getCallInfo(){return this.getState()}get(t){return this.getState()[t]}}(yr),F0=new class extends B0{updateRttObject(t){this.setState({rttObject:t}),ue.emit(He.WEBSITE_DELAY,t)}}({rttObject:{rtt:null,jitter:null,packetsLost:null,packetsReceived:null,packetsSent:null,sendBitrate:null,recvBitrate:null,codec:null}});let Qg=class extends Error{constructor(n,r,i){const o=`${n.status||n.status===0?n.status:""} ${n.statusText||""}`.trim();super(`Request failed with ${o?`status code ${o}`:"an unknown error"}: ${r.method} ${r.url}`);vr(this,"response");vr(this,"request");vr(this,"options");this.name="HTTPError",this.response=n,this.request=r,this.options=i}};class Lg extends Error{constructor(n){super(`Request timed out: ${n.method} ${n.url}`);vr(this,"request");this.name="TimeoutError",this.request=n}}const Ug=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(n&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return t&&!e})(),bw=typeof globalThis.AbortController=="function",Sw=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ww=typeof globalThis.ReadableStream=="function",Iw=typeof globalThis.FormData=="function",k0=["get","post","put","patch","head","delete"],xw={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Hg=2147483647,Rw=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,P0=Symbol("stop"),Ow={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Mw={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},Tw=(t,e)=>{const n=(i=>{if(!i)return 0;if(i instanceof FormData){let o=0;for(const[a,s]of i)o+=Rw,o+=new TextEncoder().encode(`Content-Disposition: form-data; name="${a}"`).length,o+=typeof s=="string"?new TextEncoder().encode(s).length:s.size;return o}if(i instanceof Blob)return i.size;if(i instanceof ArrayBuffer)return i.byteLength;if(typeof i=="string")return new TextEncoder().encode(i).length;if(i instanceof URLSearchParams)return new TextEncoder().encode(i.toString()).length;if("byteLength"in i)return i.byteLength;if(typeof i=="object"&&i!==null)try{const o=JSON.stringify(i);return new TextEncoder().encode(o).length}catch{return 0}return 0})(t.body);let r=0;return new Request(t,{duplex:"half",body:new ReadableStream({async start(i){const o=t.body instanceof ReadableStream?t.body.getReader():new Response("").body.getReader();await async function a(){const{done:s,value:A}=await o.read();if(s)return e&&e({percent:1,transferredBytes:r,totalBytes:Math.max(n,r)},new Uint8Array),void i.close();r+=A.byteLength;let l=n===0?0:r/n;(n<r||l===1)&&(l=.99),e&&e({percent:Number(l.toFixed(2)),transferredBytes:r,totalBytes:n},A),i.enqueue(A),await a()}()}})})},ma=t=>t!==null&&typeof t=="object",Rs=(...t)=>{for(const e of t)if((!ma(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return Kd({},...t)},j0=(t={},e={})=>{const n=new globalThis.Headers(t),r=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[o,a]of i.entries())r&&a==="undefined"||a===void 0?n.delete(o):n.set(o,a);return n};function Os(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:Kd(t[n]??[],e[n]??[])}const Q0=(t={},e={})=>({beforeRequest:Os(t,e,"beforeRequest"),beforeRetry:Os(t,e,"beforeRetry"),afterResponse:Os(t,e,"afterResponse"),beforeError:Os(t,e,"beforeError")}),Kd=(...t)=>{let e={},n={},r={};for(const i of t)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(ma(i)){for(let[o,a]of Object.entries(i))ma(a)&&o in e&&(a=Kd(e[o],a)),e={...e,[o]:a};ma(i.hooks)&&(r=Q0(r,i.hooks),e.hooks=r),ma(i.headers)&&(n=j0(n,i.headers),e.headers=n)}return e},Nw=t=>k0.includes(t)?t.toUpperCase():t,Gg={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3},Dw=(t={})=>{if(typeof t=="number")return{...Gg,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Gg,...t}};class gA{constructor(e,n={}){vr(this,"request");vr(this,"abortController");vr(this,"_retryCount",0);vr(this,"_input");vr(this,"_options");var r,i;if(this._input=e,this._options={...n,headers:j0(this._input.headers,n.headers),hooks:Q0({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:Nw(n.method??this._input.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:Dw(n.retry),throwHttpErrors:n.throwHttpErrors!==!1,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(bw&&Sw){const o=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=o?AbortSignal.any([o,this.abortController.signal]):this.abortController.signal}if(Ug&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((i=(r=this._options).stringifyJson)==null?void 0:i.call(r,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const o="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,o);!(Iw&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Ug)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Tw(this.request,this._options.onUploadProgress))}}static create(e,n){const r=new gA(e,n),i=async()=>{if(typeof r._options.timeout=="number"&&r._options.timeout>Hg)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let a=await r._fetch();for(const s of r._options.hooks.afterResponse){const A=await s(r.request,r._options,r._decorateResponse(a.clone()));A instanceof globalThis.Response&&(a=A)}if(r._decorateResponse(a),!a.ok&&r._options.throwHttpErrors){let s=new Qg(a,r.request,r._options);for(const A of r._options.hooks.beforeError)s=await A(s);throw s}if(r._options.onDownloadProgress){if(typeof r._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!ww)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((s,A)=>{const l=Number(s.headers.get("content-length"))||0;let u=0;return s.status===204?(A&&A({percent:1,totalBytes:l,transferredBytes:u},new Uint8Array),new Response(null,{status:s.status,statusText:s.statusText,headers:s.headers})):new Response(new ReadableStream({async start(d){const f=s.body.getReader();A&&A({percent:0,transferredBytes:0,totalBytes:l},new Uint8Array),await async function p(){const{done:m,value:C}=await f.read();m?d.close():(A&&(u+=C.byteLength,A({percent:l===0?0:u/l,transferredBytes:u,totalBytes:l},C)),d.enqueue(C),await p())}()}}),{status:s.status,statusText:s.statusText,headers:s.headers})})(a.clone(),r._options.onDownloadProgress)}return a},o=(r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(i):i()).finally(async()=>{var a;r.request.bodyUsed||await((a=r.request.body)==null?void 0:a.cancel())});for(const[a,s]of Object.entries(xw))o[a]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||s);const A=await o;if(a==="json"){if(A.status===204||(await A.clone().arrayBuffer()).byteLength===0)return"";if(n.parseJson)return n.parseJson(await A.text())}return A[a]()};return o}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount>this._options.retry.limit||e instanceof Lg)throw e;if(e instanceof Qg){if(!this._options.retry.statusCodes.includes(e.response.status))throw e;const r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this._options.retry.afterStatusCodes.includes(e.response.status)){let i=1e3*Number(r);Number.isNaN(i)?i=Date.parse(r)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());const o=this._options.retry.maxRetryAfter??i;return i<o?i:o}if(e.response.status===413)throw e}const n=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,n)}_decorateResponse(e){return this._options.parseJson&&(e.json=async()=>this._options.parseJson(await e.text())),e}async _retry(e){try{return await e()}catch(n){const r=Math.min(this._calculateRetryDelay(n),Hg);if(this._retryCount<1)throw n;await async function(i,{signal:o}){return new Promise((a,s)=>{function A(){clearTimeout(l),s(o.reason)}o&&(o.throwIfAborted(),o.addEventListener("abort",A,{once:!0}));const l=setTimeout(()=>{o==null||o.removeEventListener("abort",A),a()},i)})}(r,{signal:this._options.signal});for(const i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:n,retryCount:this._retryCount})===P0)return;return this._retry(e)}}async _fetch(){for(const r of this._options.hooks.beforeRequest){const i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}const e=((r,i)=>{const o={};for(const a in i)a in Mw||a in Ow||a in r||(o[a]=i[a]);return o})(this.request,this._options),n=this.request;return this.request=n.clone(),this._options.timeout===!1?this._options.fetch(n,e):async function(r,i,o,a){return new Promise((s,A)=>{const l=setTimeout(()=>{o&&o.abort(),A(new Lg(r))},a.timeout);a.fetch(r,i).then(s).catch(A).then(()=>{clearTimeout(l)})})}(n,e,this.abortController,this._options)}}/*! MIT License © Sindre Sorhus */const ru=t=>{const e=(n,r)=>gA.create(n,Rs(t,r));for(const n of k0)e[n]=(r,i)=>gA.create(r,Rs(t,i,{method:n}));return e.create=n=>ru(Rs(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),ru(Rs(t,n))),e.stop=P0,e};var zl,Bw=ru(),Fw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},L0={exports:{}};/**
156
156
  * [js-md5]{@link https://github.com/emn178/js-md5}
157
157
  *
158
158
  * @namespace md5
@@ -160,7 +160,7 @@ React keys must be passed directly to JSX without using spread:
160
160
  * @author Chen, Yi-Cyuan [emn178@gmail.com]
161
161
  * @copyright Chen, Yi-Cyuan 2014-2023
162
162
  * @license MIT
163
- */zl=L0,function(){var t="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_MD5_NO_WINDOW&&(e=!1);var r=!e&&typeof self=="object",i=!n.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;i?n=Fw:r&&(n=self);var o,a=!n.JS_MD5_NO_COMMON_JS&&zl.exports,s=!n.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",A="0123456789abcdef".split(""),l=[128,32768,8388608,-2147483648],u=[0,8,16,24],d=["hex","array","digest","buffer","arrayBuffer","base64"],f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),p=[];if(s){var m=new ArrayBuffer(68);o=new Uint8Array(m),p=new Uint32Array(m)}var C=Array.isArray;!n.JS_MD5_NO_NODE_JS&&C||(C=function(E){return Object.prototype.toString.call(E)==="[object Array]"});var v=ArrayBuffer.isView;!s||!n.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&v||(v=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});var y=function(E){var b=typeof E;if(b==="string")return[E,!0];if(b!=="object"||E===null)throw new Error(t);if(s&&E.constructor===ArrayBuffer)return[new Uint8Array(E),!1];if(!C(E)&&!v(E))throw new Error(t);return[E,!1]},w=function(E){return function(b){return new x(!0).update(b)[E]()}},I=function(E){var b,h=Ng,S=Ng.Buffer;return b=S.from&&!n.JS_MD5_NO_BUFFER_FROM?S.from:function(T){return new S(T)},function(T){if(typeof T=="string")return h.createHash("md5").update(T,"utf8").digest("hex");if(T==null)throw new Error(t);return T.constructor===ArrayBuffer&&(T=new Uint8Array(T)),C(T)||v(T)||T.constructor===S?h.createHash("md5").update(b(T)).digest("hex"):E(T)}},O=function(E){return function(b,h){return new g(b,!0).update(h)[E]()}};function x(E){if(E)p[0]=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0,this.blocks=p,this.buffer8=o;else if(s){var b=new ArrayBuffer(68);this.buffer8=new Uint8Array(b),this.blocks=new Uint32Array(b)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function g(E,b){var h,S=y(E);if(E=S[0],S[1]){var T,R=[],D=E.length,B=0;for(h=0;h<D;++h)(T=E.charCodeAt(h))<128?R[B++]=T:T<2048?(R[B++]=192|T>>>6,R[B++]=128|63&T):T<55296||T>=57344?(R[B++]=224|T>>>12,R[B++]=128|T>>>6&63,R[B++]=128|63&T):(T=65536+((1023&T)<<10|1023&E.charCodeAt(++h)),R[B++]=240|T>>>18,R[B++]=128|T>>>12&63,R[B++]=128|T>>>6&63,R[B++]=128|63&T);E=R}E.length>64&&(E=new x(!0).update(E).array());var k=[],P=[];for(h=0;h<64;++h){var G=E[h]||0;k[h]=92^G,P[h]=54^G}x.call(this,b),this.update(P),this.oKeyPad=k,this.inner=!0,this.sharedMemory=b}x.prototype.update=function(E){if(this.finalized)throw new Error("finalize already called");var b=y(E);E=b[0];for(var h,S,T=b[1],R=0,D=E.length,B=this.blocks,k=this.buffer8;R<D;){if(this.hashed&&(this.hashed=!1,B[0]=B[16],B[16]=B[1]=B[2]=B[3]=B[4]=B[5]=B[6]=B[7]=B[8]=B[9]=B[10]=B[11]=B[12]=B[13]=B[14]=B[15]=0),T)if(s)for(S=this.start;R<D&&S<64;++R)(h=E.charCodeAt(R))<128?k[S++]=h:h<2048?(k[S++]=192|h>>>6,k[S++]=128|63&h):h<55296||h>=57344?(k[S++]=224|h>>>12,k[S++]=128|h>>>6&63,k[S++]=128|63&h):(h=65536+((1023&h)<<10|1023&E.charCodeAt(++R)),k[S++]=240|h>>>18,k[S++]=128|h>>>12&63,k[S++]=128|h>>>6&63,k[S++]=128|63&h);else for(S=this.start;R<D&&S<64;++R)(h=E.charCodeAt(R))<128?B[S>>>2]|=h<<u[3&S++]:h<2048?(B[S>>>2]|=(192|h>>>6)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]):h<55296||h>=57344?(B[S>>>2]|=(224|h>>>12)<<u[3&S++],B[S>>>2]|=(128|h>>>6&63)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]):(h=65536+((1023&h)<<10|1023&E.charCodeAt(++R)),B[S>>>2]|=(240|h>>>18)<<u[3&S++],B[S>>>2]|=(128|h>>>12&63)<<u[3&S++],B[S>>>2]|=(128|h>>>6&63)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]);else if(s)for(S=this.start;R<D&&S<64;++R)k[S++]=E[R];else for(S=this.start;R<D&&S<64;++R)B[S>>>2]|=E[R]<<u[3&S++];this.lastByteIndex=S,this.bytes+=S-this.start,S>=64?(this.start=S-64,this.hash(),this.hashed=!0):this.start=S}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},x.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var E=this.blocks,b=this.lastByteIndex;E[b>>>2]|=l[3&b],b>=56&&(this.hashed||this.hash(),E[0]=E[16],E[16]=E[1]=E[2]=E[3]=E[4]=E[5]=E[6]=E[7]=E[8]=E[9]=E[10]=E[11]=E[12]=E[13]=E[14]=E[15]=0),E[14]=this.bytes<<3,E[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},x.prototype.hash=function(){var E,b,h,S,T,R,D=this.blocks;this.first?b=((b=((E=((E=D[0]-680876937)<<7|E>>>25)-271733879|0)^(h=((h=(-271733879^(S=((S=(-1732584194^2004318071&E)+D[1]-117830708)<<12|S>>>20)+E|0)&(-271733879^E))+D[2]-1126478375)<<17|h>>>15)+S|0)&(S^E))+D[3]-1316259209)<<22|b>>>10)+h|0:(E=this.h0,b=this.h1,h=this.h2,b=((b+=((E=((E+=((S=this.h3)^b&(h^S))+D[0]-680876936)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[1]-389564586)<<12|S>>>20)+E|0)&(E^b))+D[2]+606105819)<<17|h>>>15)+S|0)&(S^E))+D[3]-1044525330)<<22|b>>>10)+h|0),b=((b+=((E=((E+=(S^b&(h^S))+D[4]-176418897)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[5]+1200080426)<<12|S>>>20)+E|0)&(E^b))+D[6]-1473231341)<<17|h>>>15)+S|0)&(S^E))+D[7]-45705983)<<22|b>>>10)+h|0,b=((b+=((E=((E+=(S^b&(h^S))+D[8]+1770035416)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[9]-1958414417)<<12|S>>>20)+E|0)&(E^b))+D[10]-42063)<<17|h>>>15)+S|0)&(S^E))+D[11]-1990404162)<<22|b>>>10)+h|0,b=((b+=((E=((E+=(S^b&(h^S))+D[12]+1804603682)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[13]-40341101)<<12|S>>>20)+E|0)&(E^b))+D[14]-1502002290)<<17|h>>>15)+S|0)&(S^E))+D[15]+1236535329)<<22|b>>>10)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[1]-165796510)<<5|E>>>27)+b|0)^b))+D[6]-1069501632)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[11]+643717713)<<14|h>>>18)+S|0)^S))+D[0]-373897302)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[5]-701558691)<<5|E>>>27)+b|0)^b))+D[10]+38016083)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[15]-660478335)<<14|h>>>18)+S|0)^S))+D[4]-405537848)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[9]+568446438)<<5|E>>>27)+b|0)^b))+D[14]-1019803690)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[3]-187363961)<<14|h>>>18)+S|0)^S))+D[8]+1163531501)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[13]-1444681467)<<5|E>>>27)+b|0)^b))+D[2]-51403784)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[7]+1735328473)<<14|h>>>18)+S|0)^S))+D[12]-1926607734)<<20|b>>>12)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[5]-378558)<<4|E>>>28)+b|0))+D[8]-2022574463)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[11]+1839030562)<<16|h>>>16)+S|0))+D[14]-35309556)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[1]-1530992060)<<4|E>>>28)+b|0))+D[4]+1272893353)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[7]-155497632)<<16|h>>>16)+S|0))+D[10]-1094730640)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[13]+681279174)<<4|E>>>28)+b|0))+D[0]-358537222)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[3]-722521979)<<16|h>>>16)+S|0))+D[6]+76029189)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[9]-640364487)<<4|E>>>28)+b|0))+D[12]-421815835)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[15]+530742520)<<16|h>>>16)+S|0))+D[2]-995338651)<<23|b>>>9)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[0]-198630844)<<6|E>>>26)+b|0)|~h))+D[7]+1126891415)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[14]-1416354905)<<15|h>>>17)+S|0)|~E))+D[5]-57434055)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[12]+1700485571)<<6|E>>>26)+b|0)|~h))+D[3]-1894986606)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[10]-1051523)<<15|h>>>17)+S|0)|~E))+D[1]-2054922799)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[8]+1873313359)<<6|E>>>26)+b|0)|~h))+D[15]-30611744)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[6]-1560198380)<<15|h>>>17)+S|0)|~E))+D[13]+1309151649)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[4]-145523070)<<6|E>>>26)+b|0)|~h))+D[11]-1120210379)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[2]+718787259)<<15|h>>>17)+S|0)|~E))+D[9]-343485551)<<21|b>>>11)+h|0,this.first?(this.h0=E+1732584193|0,this.h1=b-271733879|0,this.h2=h-1732584194|0,this.h3=S+271733878|0,this.first=!1):(this.h0=this.h0+E|0,this.h1=this.h1+b|0,this.h2=this.h2+h|0,this.h3=this.h3+S|0)},x.prototype.hex=function(){this.finalize();var E=this.h0,b=this.h1,h=this.h2,S=this.h3;return A[E>>>4&15]+A[15&E]+A[E>>>12&15]+A[E>>>8&15]+A[E>>>20&15]+A[E>>>16&15]+A[E>>>28&15]+A[E>>>24&15]+A[b>>>4&15]+A[15&b]+A[b>>>12&15]+A[b>>>8&15]+A[b>>>20&15]+A[b>>>16&15]+A[b>>>28&15]+A[b>>>24&15]+A[h>>>4&15]+A[15&h]+A[h>>>12&15]+A[h>>>8&15]+A[h>>>20&15]+A[h>>>16&15]+A[h>>>28&15]+A[h>>>24&15]+A[S>>>4&15]+A[15&S]+A[S>>>12&15]+A[S>>>8&15]+A[S>>>20&15]+A[S>>>16&15]+A[S>>>28&15]+A[S>>>24&15]},x.prototype.toString=x.prototype.hex,x.prototype.digest=function(){this.finalize();var E=this.h0,b=this.h1,h=this.h2,S=this.h3;return[255&E,E>>>8&255,E>>>16&255,E>>>24&255,255&b,b>>>8&255,b>>>16&255,b>>>24&255,255&h,h>>>8&255,h>>>16&255,h>>>24&255,255&S,S>>>8&255,S>>>16&255,S>>>24&255]},x.prototype.array=x.prototype.digest,x.prototype.arrayBuffer=function(){this.finalize();var E=new ArrayBuffer(16),b=new Uint32Array(E);return b[0]=this.h0,b[1]=this.h1,b[2]=this.h2,b[3]=this.h3,E},x.prototype.buffer=x.prototype.arrayBuffer,x.prototype.base64=function(){for(var E,b,h,S="",T=this.array(),R=0;R<15;)E=T[R++],b=T[R++],h=T[R++],S+=f[E>>>2]+f[63&(E<<4|b>>>4)]+f[63&(b<<2|h>>>6)]+f[63&h];return E=T[R],S+=f[E>>>2]+f[E<<4&63]+"=="},g.prototype=new x,g.prototype.finalize=function(){if(x.prototype.finalize.call(this),this.inner){this.inner=!1;var E=this.array();x.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(E),x.prototype.finalize.call(this)}};var M=function(){var E=w("hex");i&&(E=I(E)),E.create=function(){return new x},E.update=function(S){return E.create().update(S)};for(var b=0;b<d.length;++b){var h=d[b];E[h]=w(h)}return E}();M.md5=M,M.md5.hmac=function(){var E=O("hex");E.create=function(S){return new g(S)},E.update=function(S,T){return E.create(S).update(T)};for(var b=0;b<d.length;++b){var h=d[b];E[h]=O(h)}return E}(),a?zl.exports=M:n.md5=M}();var kw=L0.exports;const U0=(t,e)=>{const n=Date.now(),r=`${t}:${n}:${kw.md5(`${e}${n}`)}`,i=new TextEncoder().encode(r);return btoa(String.fromCharCode(...i))},iu=t=>{if(/^\d+$/.test(t)||!t||typeof t!="string"||t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return!1;try{const e=atob(t);return btoa(e)===t}catch{return!1}},Wi="/v1/aicc/bmserver",Tr="/v1/aicc/ccs";let wi="",zd="",Yd="",Yl="";function H0(t){const e=U0(zd,Yd);return Bw.create({prefixUrl:`${wi}`,timeout:!1,headers:{Authorization:e,...t},hooks:{afterResponse:[async(n,r,i)=>{if(i.url.indexOf("heartbeat")!==-1)return i;const o=await i.clone().json();if(o.code!==0)throw new Error(JSON.stringify(o)||"请求失败");return i.json=async()=>o,i}]}})}async function yn(t,e,n){const r=H0(n),i="api/"+t.replace(/^\/+/,"");return r.post(i,{json:e}).json()}const qg=(t,e)=>yn(`${Tr}/state/change?h=${e}`,t,{h:e}),Pw=()=>async function(t,e){const n=H0(),r=t.replace(/^\/+/,"");return n.post(r,{json:e}).json()}("/heartbeat",{});class rn{static log(e,n={}){const{level:r="info",module:i="",timestamp:o=!0}=n;if(Z.logBuiltinEnabled){const A=i?`[${i}]`:"",l=o?`[${new Date().toLocaleString()}]`:"";switch(r){case"debug":break;case"warn":console.warn(`${l}${A} ${e}`);break;case"error":console.error(`${l}${A} ${e}`)}}const a=Z.agentInfo.agent_no;if(a){const A=JSON.stringify({level:r,module:i,content:e,timestamp:new Date().toISOString()});(s={agent_no:a,content:A},yn("/v1/aicc/ccs/softphone/log",s)).catch(()=>{})}var s}static debug(e,n){this.log(e,{level:"debug",module:n})}static info(e,n){this.log(e,{level:"info",module:n})}static warn(e,n){this.log(e,{level:"warn",module:n})}static error(e,n){this.log(e,{level:"error",module:n})}static errorObj(e,n){const r=JSON.stringify({message:e.message,stack:e.stack,name:e.name});this.log(r,{level:"error",module:n})}}class jw{constructor(e,n){this.config=e,this.eventCallback=n,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.registerInterval=6e4,this.handleNetworkInfoChange=r=>{var i,o;if((i=r.rttObject)!=null&&i.rtt){const a=(o=r.rttObject)==null?void 0:o.rtt,s=a!=null&&a>0;s||this.isOffline?s&&this.isOffline&&(this.isOffline=!1,this.handleOnline()):(this.isOffline=!0,this.handleOffline())}},this.handleOffline=()=>{rn.warn("网络断开,准备销毁 SIP 客户端","sip-client.ts 75 handleOffline"),ue.emit(He.FAIL_NOTIFICATION,"网络断开,准备销毁 SIP 客户端"),this.destroy()},this.handleOnline=()=>{rn.warn("网络恢复,准备重新启动 SIP 客户端","sip-client.ts 82 handleOnline"),this.reconnect()},this.sleep=r=>new Promise(i=>setTimeout(i,r)),F0.subscribe(this.handleNetworkInfoChange)}async start(){const e=jg.makeURI(`sip:${this.config.user}@${this.config.server}`);if(!e)throw new Error("无效的SIP配置");const n={uri:e,authorizationUsername:this.config.user,authorizationPassword:this.config.password,sendInitialProvisionalResponse:!1,transportOptions:{server:this.config.webSocket,connectionTimeout:10,keepAliveInterval:20,keepAliveDebounce:10},contactName:this.config.user,contactParams:{transport:"wss"},userAgentString:"SwiftSIP/2.0.21",sessionDescriptionHandlerFactoryOptions:{alwaysAcquireMediaFirst:!0,peerConnectionConfiguration:{iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceCandidatePoolSize:0,iceTransportPolicy:"all",rtcpMuxPolicy:"require",bundlePolicy:"balanced",certificates:void 0,peerIdentity:void 0},iceGatheringTimeout:1e3},logBuiltinEnabled:Z.logBuiltinEnabled};this.userAgent=new jg(n),this.setupEventListeners(),await this.userAgent.start(),await this.register()}setupEventListeners(){this.userAgent&&(this.userAgent.transport.stateChange.addListener(e=>{var r;let n;switch(e){case dt.Connecting:n=lr.WEB_RTC_CONNECTING;break;case dt.Connected:n=lr.WEB_RTC_CONNECTED,this.reconnectAttempts=0,Z.isRtcReconnecting=!1,H.updateIsSipConnected(!0),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);break;case dt.Disconnecting:n=lr.WEB_RTC_DISCONNECTING,H.updateIsSipConnected(!1);break;case dt.Disconnected:{if(H.updateIsSipConnected(!1),this.isManuallyStopped)return rn.warn("手动断开,不触发重连","sip-client.ts 204"),void console.warn("[SIP] 手动断开,不触发重连");ue.emit(He.FAIL_NOTIFICATION,"软电话链接失败"),n=lr.WEB_RTC_DISCONNECTED;const i=H.get("answerDevice");if(!Z.isRtcReconnecting&&this.reconnectAttempts<this.maxReconnectAttempts&&i===1){this.reconnectAttempts++;const o=1e3*this.reconnectAttempts;rn.warn(`SIP WebSocket 断开,第 ${this.reconnectAttempts} 次尝试重连,${o}ms 后重试...`,"sip-client.ts 219"),this.reconnectTimer=setTimeout(()=>{this.reconnect()},o)}else this.reconnectAttempts>=this.maxReconnectAttempts&&(rn.warn(`SIP 重连失败:已达到最大重试次数; reconnectAttempts: ${this.reconnectAttempts}; maxReconnectAttempts: ${this.maxReconnectAttempts}`,"sip-client.ts 228"),console.error("SIP 重连失败:已达到最大重试次数"),ue.emit(He.FAIL_NOTIFICATION,"SIP 重连失败:已达到最大重试次数"));break}default:H.updateIsSipConnected(!1),n="unknown"}(r=this.eventCallback)==null||r.call(this,{type:n})}),this.userAgent.delegate={onInvite:e=>{this.handleIncomingCall(e)}})}async refreshRegister(){if(this.registerer)try{await this.registerer.register(),new Date().toLocaleTimeString()}catch(e){console.error("[SIPClient] REGISTER刷新失败",e)}}async register(){var e,n;if(this.userAgent){this.registerer=new tu(this.userAgent,{expires:120,refreshFrequency:80}),(e=this.registerer)==null||e.stateChange.addListener(r=>{var o;let i;switch(r){case Qt.Initial:H.updateDisplayText(Gt.LINKING),i="initial";break;case Qt.Registered:H.updateDisplayText(""),i=lr.WEB_RTC_REGISTERED;break;case Qt.Unregistered:i=lr.WEB_RTC_UNREGISTERED;break;case Qt.Terminated:rn.warn(`注册流程已终止,无法再注册(如 UA 停止,或网络不可达);regStatus: ${lr.WEB_RTC_TERMINATED}`,"sip-client.ts 299"),i=lr.WEB_RTC_TERMINATED;break;default:i="unknown"}(o=this.eventCallback)==null||o.call(this,{type:i})});try{await this.registerer.register()}catch(r){(n=this.eventCallback)==null||n.call(this,{type:lr.WEB_RTC_REGISTER_FAILED,data:r})}}}attachRemoteAudio(e){const n=e.sessionDescriptionHandler;if(n){const r=n.peerConnection;if(!r)return;const i=new MediaStream;r.getReceivers().forEach(a=>{a.track&&a.track.kind==="audio"&&i.addTrack(a.track)});let o=document.getElementById("sip-remote-audio");o||(o=document.createElement("audio"),o.id="sip-remote-audio",o.autoplay=!0,o.style.display="none",document.body.appendChild(o)),o.srcObject=i,o.play().catch(a=>{console.error("音频播放失败,需要用户交互触发",a)})}}handleSessionState(e,n,r){e.stateChange.addListener(i=>{switch(i){case he.Established:clearTimeout(this.callTimeoutTimer),this.activeSession=e,this.attachRemoteAudio(e);break;case he.Terminating:break;case he.Terminated:this.activeSession=null,clearTimeout(this.callTimeoutTimer);case he.Establishing:}})}handleIncomingCall(e){this.incomingInvitation=e,this.handleSessionState(e,!1),e.progress({statusCode:180,reasonPhrase:"Ringing"}).catch(n=>console.error("发送 180 失败",n)),H.get("direction")}async answerCall(){var e;if(!this.incomingInvitation)throw new Error("无来电可接听");Z.autoAnswerTimer&&(clearTimeout(Z.autoAnswerTimer),Z.autoAnswerTimer=null);try{await this.incomingInvitation.accept(),this.activeSession=this.incomingInvitation,this.incomingInvitation=null}catch(n){(e=this.eventCallback)==null||e.call(this,{type:lr.WEB_RTC_ANSWER_FAILED,data:{detail:n}})}}async rejectInCall(){var e;if(this.incomingInvitation)try{await this.incomingInvitation.reject(),this.incomingInvitation=null,H.updateDirection(null),H.updateIsCalling(!1),clearTimeout(this.callTimeoutTimer)}catch(n){(e=this.eventCallback)==null||e.call(this,{type:"error",data:{message:"拒接失败",detail:n}})}}sendDTMF(e){var r;if(!this.activeSession)throw new Error("当前没有活跃的通话");const n=this.activeSession.sessionDescriptionHandler;n&&typeof n.sendDtmf=="function"?(n.sendDtmf(e),(r=this.eventCallback)==null||r.call(this,{type:lr.WEB_RTC_SEND_DTMF,data:{tone:e}})):(console.warn("DTMF发送不支持或未初始化"),rn.warn("DTMF发送不支持或未初始化","sip-client.ts 490 sendDTMF"))}async hangup(){if(this.activeSession,this.activeSession){clearTimeout(this.callTimeoutTimer);const e=this.activeSession;if(!e)return;const n=e.state;try{n===he.Established?await e.bye():n===he.Establishing&&(e instanceof b0?await e.cancel():e instanceof eu&&await e.reject()),clearTimeout(this.callTimeoutTimer)}catch(r){rn.error("挂断失败","sip-client.ts 522 hangup"),console.error("挂断失败",r)}finally{this.activeSession=null}}}async rejectOutCall(){this.activeSession instanceof eu&&(await this.activeSession.reject(),this.activeSession=null)}async destroy(){if(this.isManuallyStopped=!0,clearTimeout(this.callTimeoutTimer),this.activeSession&&await this.hangup(),this.registerer){try{await this.registerer.unregister()}catch(e){console.warn("注销失败",e)}this.registerer=null}this.userAgent&&(await this.userAgent.stop(),this.userAgent=null)}async reconnect(){if(!Z.isRtcReconnecting){Z.isRtcReconnecting=!0;try{this.isManuallyStopped=!1,await this.destroy(),await this.start(),this.isOffline=!1,this.reconnectAttempts=0}catch(e){console.error("重连失败",e),Z.isRtcReconnecting=!1}finally{Z.isRtcReconnecting=!1}}}async getNetworkStats(){var e;if(this.activeSession){const n=(e=this.activeSession.sessionDescriptionHandler)==null?void 0:e.peerConnection;if(!n)return null;const r=await n.getStats(),i={};return r.forEach(o=>{o.type==="candidate-pair"&&o.state==="succeeded"&&o.currentRoundTripTime!=null&&(i.rtt=+(1e3*o.currentRoundTripTime).toFixed(2)),o.type==="inbound-rtp"&&o.kind==="audio"&&(i.jitter=+(1e3*o.jitter).toFixed(2),i.packetsLost=o.packetsLost,i.packetsReceived=o.packetsReceived,o.bytesReceived&&o.timestamp&&(i.recvBitrate=+(o.bytesReceived/1024).toFixed(2))),o.type==="outbound-rtp"&&o.kind==="audio"&&(i.packetsSent=o.packetsSent,o.bytesSent&&o.timestamp&&(i.sendBitrate=+(o.bytesSent/1024).toFixed(2))),o.type==="codec"&&o.mimeType&&(i.codec=o.mimeType)}),{...i,rtt:(i==null?void 0:i.rtt)||40}}return{rtt:Z.latency||1}}}class No{static requestPermission(){"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}static async requestMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(n=>n.kind==="audioinput"&&n.label!=="")?null:await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){return console.warn("获取音频权限失败:",e),null}}static show(e,n,r,i){if("Notification"in window&&Notification.permission==="granted"){const o=new Notification(e,{body:n,tag:`xy-global-notification${new Date().getTime()}`,renotify:!0});o.onclick=()=>{window.focus(),o.close(),r==null||r()},setTimeout(()=>o.close(),1e3*(i||3))}}static async checkMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(e=>e.kind==="audioinput"&&e.label!=="")}catch(e){return console.warn("无法检查设备权限:",e),!1}}}const Qw=[],zn=["call_number"],hA=["call_number"],Lw=["hangup"],yi=["hold","hangup","mute","transfer","consult","satisfaction","dtmf"],Wl=["hold","hangup","mute","transfer","consult"],Vg=["consult_transfer","conference","consult_retrieve"],Uw=["hangup"],Hw=["hangup"],Ms=["answer","reject"],qi=["hangup","consult","transfer","hold","mute","satisfaction","dtmf"],Zg=["hangup","whisper","force_insert","force_disconnect"],Gw=["hangup"],qw=["hangup","cancel_whisper","force_insert"],Vw=["hangup"],Zw=["hangup"];class La{constructor(){this.roleData={agentInfo:()=>{var e;if(!((e=Z.agentInfo)!=null&&e.agent_no))throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:e=>{if(!e.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:e=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:n}=Z.agentInfo;if(!n.split(",").map(r=>Number(r)).includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(e,n)=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!n)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(e===2&&(n==="通话中"||n==="整理"))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:e=>{const{out_display_select_switch:n,out_display_data:r}=Z.agentInfo;if(n!==1)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(r||"").split("#").includes(e))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}},this.changeDevice=async e=>{try{if(H.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:n,success:r}=e,{device:i}=n;i===1&&await La.initRtcFn(),this.roleData.changeDevice(i);const{agent_no:o}=Z.agentInfo;await(s=>yn(`${Tr}/device/change`,s))({agent_no:o,answer_device:i}),H.updateAnswerDevice(i);const a=H.get("actionConfigs");H.updateActionConfigs(a),i===2&&Z.stateObject.state===Mt.UNREGISTERED&&await this._changeState({data:{...Z.stateBeforeChange,state_name:Z.stateBeforeChange.state===Mt.IDLE?"空闲":"忙碌"}},"q"),r==null||r({code:0,msg:"请求成功"})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}formatDate(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}static setInitRtcFn(e){this.initRtcFn=e}async _agentLogin(e){try{const r=await(n={agent_no:e},yn(`${Tr}/agent/login`,n));Z.agentInfo=r.data}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}var n}async _changeState(e,n){try{Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:a}=r,{agent_no:s}=Z.agentInfo;await qg({agent_no:s,state_name:a,state:o},n),o===Mt.IDLE?H.updateActionConfigs(zn):o===Mt.BUSY&&H.updateActionConfigs(hA),Z.stateObject={state:o,state_name:a},i==null||i({code:0,msg:"请求成功"})}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async _getInCallCrmDetail(e){var n;try{const{phone:r}=e.data,i={};iu(r)?i.trace_id=r:i.phone=r.replace(/[\s\r\n-]+/g,"");const o=await(a=>yn(`${Wi}/crm/popups`,a))({...i});(n=e.success)==null||n.call(e,o)}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async changeState(e,n){try{if(H.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:a}=r;this.roleData.changeState(o,a);const{agent_no:s}=Z.agentInfo;await qg({agent_no:s,state_name:a,state:o},n),(Z.stateObject.state===Mt.IDLE||Z.stateObject.state===Mt.BUSY&&a!=="整理")&&(Z.stateBeforeChange=Z.stateObject),o===Mt.IDLE?H.updateActionConfigs(zn):o===Mt.BUSY&&H.updateActionConfigs(hA),Z.stateObject={state:o,state_name:a},i==null||i({code:0,msg:"请求成功"})}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getIdleAgentList(e){var r;const{agent_no:n}=Z.agentInfo;try{this.roleData.agentInfo();const i=await(o=>yn(`${Tr}/agent/free`,o))({agent_no:n});(r=e.success)==null||r.call(e,i)}catch(i){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(i.message).msg),i}}async getAgentState(e){var n;try{const r=await yn(`${Wi}/agent/statecfg/list`,{}),i=(r.data||[]).filter(o=>o.enable===0).filter(o=>o.state!==0&&o.state!==3).filter(o=>o.state_name!=="通话中"&&o.state_name!=="整理"&&o.state_name!=="未注册"&&o.state_name!=="离线接听").map(o=>({state:o.state,state_name:o.state_name})).reverse();(n=e.success)==null||n.call(e,{...r,data:i})}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async setAgentExplicit(e){var n;try{this.roleData.agentInfo(),this.roleData.requestInfo(e),this.roleData.setAgentExplicit(e.data.number);const{agent_id:r}=Z.agentInfo;await(i=>yn(`${Wi}/agent/update`,i))({agent_id:r,out_display_number:e.data.number}),H.updateSelectOutNumber(e.data.number),(n=e.success)==null||n.call(e,{code:0,msg:"请求成功"})}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async checkAgentLogin(e){var n;try{this.roleData.requestInfo(e);const{agent_no:r}=e.data;if(!r)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const i=await(o=>yn(`${Tr}/agent/islogin`,o))({agent_no:r});(n=e.success)==null||n.call(e,i)}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getCallRecord(e){try{this.roleData.agentInfo();const{success:n}=e,r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59),a=[this.formatDate(i),this.formatDate(o)],{agent_no:s}=Z.agentInfo,A=await(f=>yn(`${Wi}/agent/recordpage`,f))({start_time:a[0],end_time:a[1],page_no:1,page_size:10,agent_no_list:[s]}),{code:l,msg:u,data:d}=A;n==null||n({code:l,msg:u,data:d})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async logout(e){this.roleData.agentInfo();try{const{agent_no:n}=Z.agentInfo,{data:r,success:i}=e;await(o=>yn(`${Tr}/agent/logout`,o))({...r,agent_no:n}),i==null||i({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async listenCall(e){try{const{agent_no:n}=Z.agentInfo,{data:r,success:i}=e;if(this.roleData.agentInfo(),this.roleData.requestInfo(e),!r.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(o=>yn(`${Tr}/call/monitor`,o))({...r,monitor_agent_no:n}),Z.monitoredAgentNo=r.monitored_agent_no,i==null||i({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async earCall(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Tr}/call/whisper`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async stopEarCall(e){try{const{agentInfo:n,earSpeakAgent:r}=Z;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;await(a=>yn(`${Tr}/call/stopwhisper`,a))({monitor_agent_no:i,monitored_agent_no:r}),o==null||o({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceInsert(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Tr}/call/bargein`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceDisconnect(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Tr}/call/intercept`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}const Kw=console.log,Kg=(...t)=>{Z.logBuiltinEnabled&&Kw(...t)};let ri=null;class An{constructor(e,n){this.url=e,this.onOpenCallback=n,this.ws=null,this.heartbeatWorker=null,this.reconnectDelay=3e3,this.manualClose=!1,this.apiClient=new La,this.sipClient=null,this.pendingMessages=new Map,this.initWebSocket()}static getInstance({url:e,sipClient:n,onOpen:r}){if(!ri){if(!e)throw new Error("WebSocket 尚未初始化");ri=new An(e,r),ri.sipClient=n}return ri}setSipClient(e){this.sipClient=e}stateIdleChange(e){const{state:n}=Z.stateObject;n!==Mt.IDLE&&this.apiClient._changeState({data:{...Z.stateBeforeChange,state_name:Z.stateBeforeChange.state===Mt.IDLE?"空闲":"忙碌"}},e)}inCallAutoAnswer(){const{soft_device_auto_answer:e,auto_answer_time:n}=Z.agentInfo,r=e===1,i=H.get("direction");if(r&&i===Rn.INCOMING){const o=Number(n)||0;o>0&&(Z.autoAnswerTimer=setTimeout(()=>{var a;(a=this.sipClient)==null||a.answerCall(),Z.autoAnswerTimer=null},o>0?1e3*o-500:0))}}async getCustomerInfo(e,n){try{await this.apiClient._getInCallCrmDetail({data:{phone:e},success:r=>{const{phone:i,trace_id:o,...a}=r.data,s={...a,type:n,session_id:Z.sessionId,phone:r.data.phone,trace_id:r.data.trace_id};H.updateCustomerInfo(s)}})}catch{}}putAgentState(e,n){if(!e)return;if(n===5)return void this.stateIdleChange("device_type5");Z.sessionId="";const{post_call_process_time:r}=Z.agentInfo,i=r||0;if(Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),H.updateCustomerInfo(void 0),i>0){const{state:o}=Z.stateObject;if(o===Mt.IDLE)return;this.apiClient._changeState({data:{state:Mt.BUSY,state_name:"整理"}},"ez"),Z.autoStateTimer=setTimeout(()=>{Z.autoStateTimer=null,this.stateIdleChange(`delay${i}`)},1e3*i)}else this.stateIdleChange("delay0")}stateBusyChange(){Z.sessionId="",clearTimeout(Z.autoStateTimer),H.updateCustomerInfo(void 0),this.apiClient._changeState({data:{state:Mt.BUSY,state_name:"忙碌"}},"dm")}initWebSocket(){var n;if(((n=this.ws)==null?void 0:n.readyState)===1||!H.get("isNextState")||this.manualClose)return;const e=U0(zd,Yd);this.ws=new WebSocket(this.url+e),this.ws.onopen=()=>{const r=new Date().getTime();this.sendMessage({type:0,msg_id:r}),this.pendingMessages.set(r,performance.now()),this.startHeartbeat(),this.manualClose=!1,this.onOpenCallback&&this.onOpenCallback()},this.ws.onmessage=async r=>{var u,d,f,p;const i=JSON.parse(r.data),{type:o,data:a,code:s,msg:A,msg_id:l}=i;if(o===0&&l){const m=this.pendingMessages.get(l),C=performance.now()-m;Z.latency=parseFloat(C.toFixed(2)),this.pendingMessages.delete(l)}if(o!==0&&Kg("%cWebSocket 收到消息:","color: blue; font-weight: bold;",i),o!==rt.OUT_CALL&&o!==rt.PREVIEW_OUT_CALL||(Z.isAgentHangup=!1,s!==0?(H.reset(),ue.emit(ie.OUT_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A),H.updateActionConfigs(zn),setTimeout(()=>{H.updateCustomerInfo(void 0)},500),this.stateIdleChange("h")):s===0&&(H.updateDirection(Rn.OUTGOING),ue.emit(ie.OUT_SUCCESS),Z.sessionId=a.session_id,H.updateIsCalling(!0),clearTimeout(Z.autoStateTimer))),o===rt.AGENT_STATE){const{state:m,state_name:C}=a;Z.stateObject={state:m,state_name:C},(u=Z.stateBeforeChange)!=null&&u.state||Z.stateObject.state!==Mt.IDLE&&(Z.stateObject.state!==Mt.BUSY||C==="整理")||(Z.stateBeforeChange=Z.stateObject),C==="振铃中"&&H.updateDisplayText(Gt.AGENT_RINGING);const v=H.get("isCalling");m!==Mt.UNREGISTERED||v||H.updateActionConfigs(Qw),m!==Mt.IDLE||v||H.updateActionConfigs(zn),ue.emit(ie.AGENT_STATE,{state:m,state_name:C})}else if(o===rt.OUT_CALL_INCOMING_CALL)Z.isAgentHangup=!1,H.updateIsCalling(!0),a.preview_task_id?((d=this.sipClient)==null||d.answerCall(),this.getCustomerInfo(a.trace_id||a.customer_phone,"preview_out_incoming_call"),ue.emit(ie.PREVIEW_OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,preview_task_id:a.preview_task_id,trace_id:a.trace_id})):a.direction===0?((f=this.sipClient)==null||f.answerCall(),this.getCustomerInfo(a.trace_id||a.customer_phone,"out_call_incoming_call"),ue.emit(ie.OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,trace_id:a.trace_id})):a.direction===8&&((p=this.sipClient)==null||p.answerCall(),this.getCustomerInfo(a.trace_id||a.customer_phone,"internal_out_incoming_call"),ue.emit(ie.INTERNAL_OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,trace_id:a.trace_id})),Z.sessionId=a.session_id,H.updateActionConfigs(Lw,a.direction!==8);else if(o===rt.OUT_CALL_END){if(Z.sessionId!==a.session_id)return;if(H.updateDisplayText(""),a.device_type===1&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.OUT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),H.updateActionConfigs(zn),this.putAgentState(!0);else if(a.device_type===2&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.OUR_SIDE_CONSULT_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn),this.putAgentState(!0);else if(a.device_type===2&&a.agent_no!==Z.agentInfo.agent_no)H.get("isCalling")&&(H.updateDisplayText(Gt.CALLING),ue.emit(ie.OTHER_SIDE_CONSULT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),H.updateActionConfigs(yi));else if(a.device_type===3&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.THREE_WAY_OUR_SIDE_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn),this.putAgentState(!0);else if(a.device_type===4&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.TRANSFER_END,{session_id:a.session_id}),H.updateActionConfigs(zn),this.putAgentState(!0);else if(a.device_type===4&&a.agent_no!==Z.agentInfo.agent_no){ue.emit(ie.TRANSFER_FAILED,"未知原因"),ue.emit(He.FAIL_NOTIFICATION,"转接失败");const m=H.get("direction");m===Rn.OUTGOING?H.updateActionConfigs(yi):m===Rn.INCOMING&&H.updateActionConfigs(qi)}else a.device_type===5&&a.agent_no===Z.agentInfo.agent_no&&(Z.monitoredAgentNo="",Z.earSpeakAgent="",H.reset(),ue.emit(ie.LISTEN_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn),this.putAgentState(!0,5))}else if(o===rt.OUT_CALL_RINGING)H.get("displayText")===Gt.AGENT_RINGING&&(Z.isAgentHangup=!1,ue.emit(ie.OUT_RINGING,{session_id:Z.sessionId,type:a.type}),H.updateDisplayText(Gt.RINGING));else if(o===rt.OUT_CALL_ANSWER)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),H.updateIsCalling(!0),H.updateOutCallIsAnswer(!0),H.updateDisplayText(Gt.CALLING),a.direction===8?(ue.emit(ie.INTERNAL_OUT_OFF_ANSWER,{session_id:Z.sessionId}),H.updateActionConfigs(Wl)):(ue.emit(ie.OUT_OFF_ANSWER,{session_id:Z.sessionId}),H.updateActionConfigs(yi));else if(o===rt.CONSULT_RINGING)Z.isAgentHangup=!1,ue.emit(ie.CONSULT_RINGING,{session_id:a.session_id}),H.updateDisplayText(Gt.AGENT_RINGING),H.updateActionConfigs([]),clearTimeout(Z.autoStateTimer);else if(o===rt.CONSULT_ANSWER)Z.isAgentHangup=!1,ue.emit(ie.CONSULT_OFF_HOOK,{session_id:a.session_id}),H.updateConsultIsAnswer(!0),H.updateDisplayText(Gt.CONSULTING),H.updateActionConfigs(Vg);else if(o===rt.CONSULT_FAIL)ue.emit(ie.CONSULT_FAILED,{custom_reason:a.custom_reason}),H.updateDisplayText(Gt.CALLING),H.updateActionConfigs(yi);else if(o===rt.CONSULT_CALL_IN)Z.isAgentHangup=!1,ue.emit(ie.CONSULT_INCOMING,{agent_no:a.agent_no,agent_mane:a.agent_name,session_id:a.session_id}),Z.sessionId=a.session_id,H.updateIsCalling(!0),H.updateDirection(Rn.CONSULT),H.updateDisplayText(Gt.CONSULT_CALL_IN),H.updateActionConfigs(Ms),Z.enableBrowserAlert&&No.show("📞 咨询来电",`坐席 [${a.agent_name}] 正在咨询...`,()=>{ue.emit(He.NOTIFICATION_CLICK,{agent_mane:a.agent_name,agent_no:a.agent_no})},Z.browserAlertTime);else if(o===rt.CONSULT_CALL_IN_SUCCESS)ue.emit(ie.CONSULT_CALL_IN_SUCCESS,{session_id:a.session_id}),H.updateConsultIsAnswer(!0),H.updateDisplayText(Gt.CALLING),H.updateActionConfigs(Uw);else if(o===rt.CONSULT_RETURN_CALL_SUCCESS)a.status==="success"?(H.updateConsultIsAnswer(!1),ue.emit(ie.CONSULT_RETURN_CALL_SUCCESS),H.updateDisplayText(Gt.CALLING),ue.emit(ie.OTHER_SIDE_CONSULT_HANGUP),H.updateActionConfigs(yi)):ue.emit(He.FAIL_NOTIFICATION,"媒体失败");else if(o===rt.MUTE)s===0?(H.updateIsMuted(!0),ue.emit(ie.MUTE_SUCCESS),H.updateDisplayText(Gt.MUTING)):(ue.emit(ie.MUTE_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.UNMUTE)s===0?(H.updateIsMuted(!1),ue.emit(ie.UNMUTE_SUCCESS),H.updateDisplayText(Gt.CALLING)):(ue.emit(ie.UNMUTE_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CALL_HOLD)s===0?(H.updateIsHold(!0),H.updateDisplayText(Gt.HOLDING),ue.emit(ie.HOLD_SUCCESS)):(ue.emit(ie.HOLD_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CALL_UNHOLD)s===0?(H.updateDisplayText(Gt.CALLING),H.updateIsHold(!1),ue.emit(ie.UNHOLD_SUCCESS)):(ue.emit(ie.UNHOLD_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CONSULT_TRANSFER)Z.isAgentHangup=!1,s===0?ue.emit(ie.CONSULT_TRANSFER_SUCCESS):(ue.emit(ie.CONSULT_TRANSFER_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CONSULT_TRANSFER_FAILED)ue.emit(ie.CONSULT_TRANSFER_FAILED,a.status);else if(o===rt.CONSULT_TRANSFER_OFF_HOOK)H.updateDirection(Rn.INCOMING),H.updateDisplayText(Gt.CALLING),ue.emit(ie.CONSULT_TRANSFER_OFF_HOOK),H.updateActionConfigs(qi),H.updateIncomingIsAnswer(!0),H.updateConsultIsAnswer(!1);else if(o===rt.INCOMING_CALL)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),Z.sessionId=a.session_id,H.updateIsCalling(!0),H.updateDirection(Rn.INCOMING),H.updateDisplayText(Gt.INCOMING_CALL),this.inCallAutoAnswer(),a.direction!==1&&a.direction!==4&&a.direction!==7||(this.getCustomerInfo(a.trace_id||a.customer_phone,"incoming_call"),ue.emit(ie.INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===8&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"incoming_call_in"),ue.emit(ie.INCOMING_CALL_IN,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===3&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"predict_incoming_call"),ue.emit(ie.PREDICT_INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===6&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"dual_call_incoming_call"),ue.emit(ie.DUAL_CALL_INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),H.updateActionConfigs(Ms),Z.enableBrowserAlert&&No.show("📞 客户来电",`客户 [${a.customer_phone}] 正在呼入...`,()=>{ue.emit(He.NOTIFICATION_CLICK,{customer_phone:a.customer_phone})},Z.browserAlertTime);else if(o===rt.INCOMING_CALL_OFF_HOOK)H.updateIncomingIsAnswer(!0),a.direction===8?(H.updateActionConfigs(Wl),ue.emit(ie.INCOMING_CALL_IN_OFF_HOOK,{session_id:Z.sessionId})):(H.updateActionConfigs(qi),ue.emit(ie.INCOMING_CALL_OFF_HOOK,{session_id:Z.sessionId})),H.updateDisplayText(Gt.CALLING);else if(o===rt.INCOMING_CALL_END){if(Z.sessionId!==a.session_id)return;if(H.updateDisplayText(""),a.device_type!==1&&a.device_type!==7||a.agent_no!==Z.agentInfo.agent_no)if(a.device_type===2&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.OUR_SIDE_CONSULT_HANGUP,{session_id:a.session_id}),this.putAgentState(!0),H.updateActionConfigs(zn);else if(a.device_type===2&&a.agent_no!==Z.agentInfo.agent_no)H.updateDisplayText(Gt.CALLING),ue.emit(ie.OTHER_SIDE_CONSULT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),H.updateActionConfigs(yi);else if(a.device_type===3&&a.agent_no===Z.agentInfo.agent_no)this.putAgentState(!0),H.reset(),ue.emit(ie.THREE_WAY_OUR_SIDE_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn);else if(a.device_type===4&&a.agent_no===Z.agentInfo.agent_no)this.putAgentState(!0),H.reset(),ue.emit(ie.TRANSFER_END,{session_id:a.session_id}),H.updateActionConfigs(zn);else if(a.device_type===4&&a.agent_no!==Z.agentInfo.agent_no){ue.emit(ie.TRANSFER_FAILED,"未知原因"),ue.emit(He.FAIL_NOTIFICATION,"转接失败");const m=H.get("direction");m===Rn.OUTGOING?H.updateActionConfigs(yi):m===Rn.INCOMING&&H.updateActionConfigs(qi)}else a.device_type===5&&a.agent_no===Z.agentInfo.agent_no&&(this.putAgentState(!0,5),Z.monitoredAgentNo="",Z.earSpeakAgent="",H.reset(),ue.emit(ie.LISTEN_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn));else this.putAgentState(!0),H.reset(),ue.emit(ie.INCOMING_CALL_END,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),H.updateActionConfigs(zn)}else if(o===rt.SATISFACTION_EVALUATION)s===0?ue.emit(ie.SATISFACTION_EVALUATION_SUCCESS):(ue.emit(ie.SATISFACTION_EVALUATION_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CONSULT_THREE_WAY)s!==0?(ue.emit(ie.CONSULT_THREE_WAY_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A)):s===0&&H.updateIsMeeting(!0);else if(o===rt.CONSULT_THREE_WAY_RESULT)a.status==="success"?(H.updateDirection(Rn.MEETING),H.updateDisplayText(Gt.MEETING),H.updateActionConfigs(Hw),ue.emit(ie.CONSULT_THREE_WAY_SUCCESS)):(ue.emit(ie.CONSULT_THREE_WAY_FAILED,{conf_name:a.conf_name}),H.updateIsMeeting(!1));else if(o===rt.TRANSFER_INCOMING_CALL)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),a.agent_no===Z.agentInfo.agent_no?(H.updateDisplayText(Gt.TRANSFERRING),ue.emit(ie.TRANSFER_PROGRESS),H.updateActionConfigs([]),H.updateTransferIsAnswer(!0)):(Z.sessionId=a.session_id,ue.emit(ie.TRANSFER_INCOMING_CALL,{agent_no:a.agent_no,agent_name:a.agent_name,session_id:a.session_id}),H.updateIsCalling(!0),H.updateDirection(Rn.TRANSFER),H.updateDisplayText(Gt.TRANSFER_INCOMING_CALL),H.updateActionConfigs(Ms),Z.enableBrowserAlert&&No.show("📞 转接来电",`坐席 [${a.agent_no}] 正在转接...`,()=>{ue.emit(He.NOTIFICATION_CLICK,{agent_no:a.agent_no})},Z.browserAlertTime));else if(o===rt.TRANSFER_OFF_HOOK)ue.emit(ie.TRANSFER_OFF_HOOK,{session_id:Z.sessionId}),H.updateTransferIsAnswer(!1),H.updateDisplayText(Gt.CALLING),H.updateActionConfigs(qi,a.direction!==8);else if(o===rt.TRANSFER_FAILED){if(a.status==="failed"){ue.emit(ie.TRANSFER_FAILED,"未知原因"),ue.emit(He.FAIL_NOTIFICATION,"转接失败");const m=H.get("direction");m===Rn.OUTGOING?H.updateActionConfigs(yi):m===Rn.INCOMING&&H.updateActionConfigs(qi)}}else o===rt.KICK_OFFLINE?ue.emit(He.KICK_OFF):o===rt.CONTINUOUS_NOT_ANSWER?(ue.emit(He.FAIL_NOTIFICATION,`已连续 ${a.miss_count} 次未接, 设置忙碌`),this.stateBusyChange()):o===rt.SIGN_OUT?ue.emit(He.SIGN_OUT):o===rt.SIGN_IN_SWITCH_DEVICE?ue.emit(He.SIGN_IN_SWITCH_DEVICE,a):o===rt.LISTEN_INCOMING_CALL?(clearTimeout(Z.autoStateTimer),Z.sessionId=a.session_id,H.updateIsCalling(!0),H.updateDirection(Rn.INCOMING),this.inCallAutoAnswer(),H.updateDisplayText(Gt.LISTENING),H.updateActionConfigs(Ms),ue.emit(ie.LISTEN_INCOMING_CALL,{session_id:a.session_id}),Z.enableBrowserAlert&&No.show("📞 监听来电","正在来电...",()=>{ue.emit(He.NOTIFICATION_CLICK,{customer_phone:a.customer_phone})},Z.browserAlertTime)):o===rt.LISTEN_INCOMING_CALL_OFF_HOOK?(Z.monitoredAgentNo=a.monitored_agent_no,Z.earSpeakAgent="",H.updateIncomingIsAnswer(!0),ue.emit(ie.LISTEN_INCOMING_CALL_OFF_HOOK,{session_id:Z.sessionId,monitored_agent_no:a.monitored_agent_no}),H.updateActionConfigs(Zg),H.updateDisplayText(Gt.CALLING)):o===rt.LISTEN_CALL_FAILED?a.status==="failed"&&(ue.emit(ie.LISTEN_CALL_FAILED),Z.monitoredAgentNo=""):o===rt.EAR_SPEECH?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&(H.updateActionConfigs(Gw),ue.emit(ie.EAR_SPEECH_BE_SUCCESS)),a.monitor_agent_no===Z.agentInfo.agent_no&&(H.updateActionConfigs(qw),ue.emit(ie.EAR_SPEECH_SUCCESS,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no}),Z.earSpeakAgent=a.monitored_agent_no)):ue.emit(ie.EAR_SPEECH_FAILED):o===rt.STOP_EAR_SPEECH?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&H.updateActionConfigs(qi),a.monitor_agent_no===Z.agentInfo.agent_no&&H.updateActionConfigs(Zg),Z.earSpeakAgent="",ue.emit(ie.STOP_EAR_SPEECH_SUCCESS)):ue.emit(ie.STOP_EAR_SPEECH_FAILED):o===rt.CALL_FORCE_INSERT?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&(H.updateActionConfigs(Zw),ue.emit(ie.CALL_FORCE_INSERT_SUCCESS,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no})),a.monitor_agent_no===Z.agentInfo.agent_no&&(H.updateActionConfigs(Vw),ue.emit(ie.CALL_FORCE_INSERT_SUCCESS_LISTENER,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no}))):ue.emit(ie.CALL_FORCE_INSERT_FAILED):o===rt.INTERNAL_CALL_START_CONSULT?a.agent_no===Z.agentInfo.agent_no?(H.updateConsultIsAnswer(!0),H.updateActionConfigs(Vg),H.updateDisplayText(Gt.CONSULTING)):(H.updateDisplayText(Gt.OTHER_SIDE_CONSULTING),H.updateActionConfigs([])):o===rt.INTERNAL_CALL_END_CONSULT?(H.updateActionConfigs(Wl),H.updateDisplayText(""),H.updateConsultIsAnswer(!1)):o===rt.CALL_SIP_INCOMING_CALL?ue.emit(ie.CALL_SIP_INCOMING_CALL):o===rt.CALL_REAL_TIME_TRANSCRIPT&&ue.emit(ie.REAL_TIME_TRANSCRIPTION,a)},this.ws.onclose=r=>{ue.emit(He.FAIL_NOTIFICATION,"链接已断开,请检查网络"),this.stopHeartbeat();const i=H.get("isNextState");!this.manualClose&&i&&setTimeout(()=>this.initWebSocket(),this.reconnectDelay)},this.ws.onerror=r=>{var i;ue.emit(He.FAIL_NOTIFICATION,"连接失败,请检查网络"),(i=this.ws)==null||i.close()}}startHeartbeat(){const e=new Blob([`
163
+ */zl=L0,function(){var t="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_MD5_NO_WINDOW&&(e=!1);var r=!e&&typeof self=="object",i=!n.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;i?n=Fw:r&&(n=self);var o,a=!n.JS_MD5_NO_COMMON_JS&&zl.exports,s=!n.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",A="0123456789abcdef".split(""),l=[128,32768,8388608,-2147483648],u=[0,8,16,24],d=["hex","array","digest","buffer","arrayBuffer","base64"],f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),p=[];if(s){var m=new ArrayBuffer(68);o=new Uint8Array(m),p=new Uint32Array(m)}var C=Array.isArray;!n.JS_MD5_NO_NODE_JS&&C||(C=function(E){return Object.prototype.toString.call(E)==="[object Array]"});var v=ArrayBuffer.isView;!s||!n.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&v||(v=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});var y=function(E){var b=typeof E;if(b==="string")return[E,!0];if(b!=="object"||E===null)throw new Error(t);if(s&&E.constructor===ArrayBuffer)return[new Uint8Array(E),!1];if(!C(E)&&!v(E))throw new Error(t);return[E,!1]},w=function(E){return function(b){return new x(!0).update(b)[E]()}},I=function(E){var b,h=Ng,S=Ng.Buffer;return b=S.from&&!n.JS_MD5_NO_BUFFER_FROM?S.from:function(T){return new S(T)},function(T){if(typeof T=="string")return h.createHash("md5").update(T,"utf8").digest("hex");if(T==null)throw new Error(t);return T.constructor===ArrayBuffer&&(T=new Uint8Array(T)),C(T)||v(T)||T.constructor===S?h.createHash("md5").update(b(T)).digest("hex"):E(T)}},O=function(E){return function(b,h){return new g(b,!0).update(h)[E]()}};function x(E){if(E)p[0]=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0,this.blocks=p,this.buffer8=o;else if(s){var b=new ArrayBuffer(68);this.buffer8=new Uint8Array(b),this.blocks=new Uint32Array(b)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function g(E,b){var h,S=y(E);if(E=S[0],S[1]){var T,R=[],D=E.length,B=0;for(h=0;h<D;++h)(T=E.charCodeAt(h))<128?R[B++]=T:T<2048?(R[B++]=192|T>>>6,R[B++]=128|63&T):T<55296||T>=57344?(R[B++]=224|T>>>12,R[B++]=128|T>>>6&63,R[B++]=128|63&T):(T=65536+((1023&T)<<10|1023&E.charCodeAt(++h)),R[B++]=240|T>>>18,R[B++]=128|T>>>12&63,R[B++]=128|T>>>6&63,R[B++]=128|63&T);E=R}E.length>64&&(E=new x(!0).update(E).array());var k=[],P=[];for(h=0;h<64;++h){var G=E[h]||0;k[h]=92^G,P[h]=54^G}x.call(this,b),this.update(P),this.oKeyPad=k,this.inner=!0,this.sharedMemory=b}x.prototype.update=function(E){if(this.finalized)throw new Error("finalize already called");var b=y(E);E=b[0];for(var h,S,T=b[1],R=0,D=E.length,B=this.blocks,k=this.buffer8;R<D;){if(this.hashed&&(this.hashed=!1,B[0]=B[16],B[16]=B[1]=B[2]=B[3]=B[4]=B[5]=B[6]=B[7]=B[8]=B[9]=B[10]=B[11]=B[12]=B[13]=B[14]=B[15]=0),T)if(s)for(S=this.start;R<D&&S<64;++R)(h=E.charCodeAt(R))<128?k[S++]=h:h<2048?(k[S++]=192|h>>>6,k[S++]=128|63&h):h<55296||h>=57344?(k[S++]=224|h>>>12,k[S++]=128|h>>>6&63,k[S++]=128|63&h):(h=65536+((1023&h)<<10|1023&E.charCodeAt(++R)),k[S++]=240|h>>>18,k[S++]=128|h>>>12&63,k[S++]=128|h>>>6&63,k[S++]=128|63&h);else for(S=this.start;R<D&&S<64;++R)(h=E.charCodeAt(R))<128?B[S>>>2]|=h<<u[3&S++]:h<2048?(B[S>>>2]|=(192|h>>>6)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]):h<55296||h>=57344?(B[S>>>2]|=(224|h>>>12)<<u[3&S++],B[S>>>2]|=(128|h>>>6&63)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]):(h=65536+((1023&h)<<10|1023&E.charCodeAt(++R)),B[S>>>2]|=(240|h>>>18)<<u[3&S++],B[S>>>2]|=(128|h>>>12&63)<<u[3&S++],B[S>>>2]|=(128|h>>>6&63)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]);else if(s)for(S=this.start;R<D&&S<64;++R)k[S++]=E[R];else for(S=this.start;R<D&&S<64;++R)B[S>>>2]|=E[R]<<u[3&S++];this.lastByteIndex=S,this.bytes+=S-this.start,S>=64?(this.start=S-64,this.hash(),this.hashed=!0):this.start=S}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},x.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var E=this.blocks,b=this.lastByteIndex;E[b>>>2]|=l[3&b],b>=56&&(this.hashed||this.hash(),E[0]=E[16],E[16]=E[1]=E[2]=E[3]=E[4]=E[5]=E[6]=E[7]=E[8]=E[9]=E[10]=E[11]=E[12]=E[13]=E[14]=E[15]=0),E[14]=this.bytes<<3,E[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},x.prototype.hash=function(){var E,b,h,S,T,R,D=this.blocks;this.first?b=((b=((E=((E=D[0]-680876937)<<7|E>>>25)-271733879|0)^(h=((h=(-271733879^(S=((S=(-1732584194^2004318071&E)+D[1]-117830708)<<12|S>>>20)+E|0)&(-271733879^E))+D[2]-1126478375)<<17|h>>>15)+S|0)&(S^E))+D[3]-1316259209)<<22|b>>>10)+h|0:(E=this.h0,b=this.h1,h=this.h2,b=((b+=((E=((E+=((S=this.h3)^b&(h^S))+D[0]-680876936)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[1]-389564586)<<12|S>>>20)+E|0)&(E^b))+D[2]+606105819)<<17|h>>>15)+S|0)&(S^E))+D[3]-1044525330)<<22|b>>>10)+h|0),b=((b+=((E=((E+=(S^b&(h^S))+D[4]-176418897)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[5]+1200080426)<<12|S>>>20)+E|0)&(E^b))+D[6]-1473231341)<<17|h>>>15)+S|0)&(S^E))+D[7]-45705983)<<22|b>>>10)+h|0,b=((b+=((E=((E+=(S^b&(h^S))+D[8]+1770035416)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[9]-1958414417)<<12|S>>>20)+E|0)&(E^b))+D[10]-42063)<<17|h>>>15)+S|0)&(S^E))+D[11]-1990404162)<<22|b>>>10)+h|0,b=((b+=((E=((E+=(S^b&(h^S))+D[12]+1804603682)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[13]-40341101)<<12|S>>>20)+E|0)&(E^b))+D[14]-1502002290)<<17|h>>>15)+S|0)&(S^E))+D[15]+1236535329)<<22|b>>>10)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[1]-165796510)<<5|E>>>27)+b|0)^b))+D[6]-1069501632)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[11]+643717713)<<14|h>>>18)+S|0)^S))+D[0]-373897302)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[5]-701558691)<<5|E>>>27)+b|0)^b))+D[10]+38016083)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[15]-660478335)<<14|h>>>18)+S|0)^S))+D[4]-405537848)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[9]+568446438)<<5|E>>>27)+b|0)^b))+D[14]-1019803690)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[3]-187363961)<<14|h>>>18)+S|0)^S))+D[8]+1163531501)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[13]-1444681467)<<5|E>>>27)+b|0)^b))+D[2]-51403784)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[7]+1735328473)<<14|h>>>18)+S|0)^S))+D[12]-1926607734)<<20|b>>>12)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[5]-378558)<<4|E>>>28)+b|0))+D[8]-2022574463)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[11]+1839030562)<<16|h>>>16)+S|0))+D[14]-35309556)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[1]-1530992060)<<4|E>>>28)+b|0))+D[4]+1272893353)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[7]-155497632)<<16|h>>>16)+S|0))+D[10]-1094730640)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[13]+681279174)<<4|E>>>28)+b|0))+D[0]-358537222)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[3]-722521979)<<16|h>>>16)+S|0))+D[6]+76029189)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[9]-640364487)<<4|E>>>28)+b|0))+D[12]-421815835)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[15]+530742520)<<16|h>>>16)+S|0))+D[2]-995338651)<<23|b>>>9)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[0]-198630844)<<6|E>>>26)+b|0)|~h))+D[7]+1126891415)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[14]-1416354905)<<15|h>>>17)+S|0)|~E))+D[5]-57434055)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[12]+1700485571)<<6|E>>>26)+b|0)|~h))+D[3]-1894986606)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[10]-1051523)<<15|h>>>17)+S|0)|~E))+D[1]-2054922799)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[8]+1873313359)<<6|E>>>26)+b|0)|~h))+D[15]-30611744)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[6]-1560198380)<<15|h>>>17)+S|0)|~E))+D[13]+1309151649)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[4]-145523070)<<6|E>>>26)+b|0)|~h))+D[11]-1120210379)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[2]+718787259)<<15|h>>>17)+S|0)|~E))+D[9]-343485551)<<21|b>>>11)+h|0,this.first?(this.h0=E+1732584193|0,this.h1=b-271733879|0,this.h2=h-1732584194|0,this.h3=S+271733878|0,this.first=!1):(this.h0=this.h0+E|0,this.h1=this.h1+b|0,this.h2=this.h2+h|0,this.h3=this.h3+S|0)},x.prototype.hex=function(){this.finalize();var E=this.h0,b=this.h1,h=this.h2,S=this.h3;return A[E>>>4&15]+A[15&E]+A[E>>>12&15]+A[E>>>8&15]+A[E>>>20&15]+A[E>>>16&15]+A[E>>>28&15]+A[E>>>24&15]+A[b>>>4&15]+A[15&b]+A[b>>>12&15]+A[b>>>8&15]+A[b>>>20&15]+A[b>>>16&15]+A[b>>>28&15]+A[b>>>24&15]+A[h>>>4&15]+A[15&h]+A[h>>>12&15]+A[h>>>8&15]+A[h>>>20&15]+A[h>>>16&15]+A[h>>>28&15]+A[h>>>24&15]+A[S>>>4&15]+A[15&S]+A[S>>>12&15]+A[S>>>8&15]+A[S>>>20&15]+A[S>>>16&15]+A[S>>>28&15]+A[S>>>24&15]},x.prototype.toString=x.prototype.hex,x.prototype.digest=function(){this.finalize();var E=this.h0,b=this.h1,h=this.h2,S=this.h3;return[255&E,E>>>8&255,E>>>16&255,E>>>24&255,255&b,b>>>8&255,b>>>16&255,b>>>24&255,255&h,h>>>8&255,h>>>16&255,h>>>24&255,255&S,S>>>8&255,S>>>16&255,S>>>24&255]},x.prototype.array=x.prototype.digest,x.prototype.arrayBuffer=function(){this.finalize();var E=new ArrayBuffer(16),b=new Uint32Array(E);return b[0]=this.h0,b[1]=this.h1,b[2]=this.h2,b[3]=this.h3,E},x.prototype.buffer=x.prototype.arrayBuffer,x.prototype.base64=function(){for(var E,b,h,S="",T=this.array(),R=0;R<15;)E=T[R++],b=T[R++],h=T[R++],S+=f[E>>>2]+f[63&(E<<4|b>>>4)]+f[63&(b<<2|h>>>6)]+f[63&h];return E=T[R],S+=f[E>>>2]+f[E<<4&63]+"=="},g.prototype=new x,g.prototype.finalize=function(){if(x.prototype.finalize.call(this),this.inner){this.inner=!1;var E=this.array();x.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(E),x.prototype.finalize.call(this)}};var M=function(){var E=w("hex");i&&(E=I(E)),E.create=function(){return new x},E.update=function(S){return E.create().update(S)};for(var b=0;b<d.length;++b){var h=d[b];E[h]=w(h)}return E}();M.md5=M,M.md5.hmac=function(){var E=O("hex");E.create=function(S){return new g(S)},E.update=function(S,T){return E.create(S).update(T)};for(var b=0;b<d.length;++b){var h=d[b];E[h]=O(h)}return E}(),a?zl.exports=M:n.md5=M}();var kw=L0.exports;const U0=(t,e)=>{const n=Date.now(),r=`${t}:${n}:${kw.md5(`${e}${n}`)}`,i=new TextEncoder().encode(r);return btoa(String.fromCharCode(...i))},iu=t=>{if(/^\d+$/.test(t)||!t||typeof t!="string"||t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return!1;try{const e=atob(t);return btoa(e)===t}catch{return!1}},Wi="/v1/aicc/bmserver",Tr="/v1/aicc/ccs";let wi="",zd="",Yd="",Yl="";function H0(t){const e=U0(zd,Yd);return Bw.create({prefixUrl:`${wi}`,timeout:!1,headers:{Authorization:e,...t},hooks:{afterResponse:[async(n,r,i)=>{if(i.url.indexOf("heartbeat")!==-1)return i;const o=await i.clone().json();if(o.code!==0)throw new Error(JSON.stringify(o)||"请求失败");return i.json=async()=>o,i}]}})}async function yn(t,e,n){const r=H0(n),i="api/"+t.replace(/^\/+/,"");return r.post(i,{json:e}).json()}const qg=(t,e)=>yn(`${Tr}/state/change?h=${e}`,t,{h:e}),Pw=()=>async function(t,e){const n=H0(),r=t.replace(/^\/+/,"");return n.post(r,{json:e}).json()}("/heartbeat",{});class rn{static log(e,n={}){const{level:r="info",module:i="",timestamp:o=!0}=n;if(Z.logBuiltinEnabled){const A=i?`[${i}]`:"",l=o?`[${new Date().toLocaleString()}]`:"";switch(r){case"debug":break;case"warn":console.warn(`${l}${A} ${e}`);break;case"error":console.error(`${l}${A} ${e}`)}}const a=Z.agentInfo.agent_no;if(a){const A=JSON.stringify({level:r,module:i,content:e,timestamp:new Date().toISOString()});(s={agent_no:a,content:A},yn("/v1/aicc/ccs/softphone/log",s)).catch(()=>{})}var s}static debug(e,n){this.log(e,{level:"debug",module:n})}static info(e,n){this.log(e,{level:"info",module:n})}static warn(e,n){this.log(e,{level:"warn",module:n})}static error(e,n){this.log(e,{level:"error",module:n})}static errorObj(e,n){const r=JSON.stringify({message:e.message,stack:e.stack,name:e.name});this.log(r,{level:"error",module:n})}}class jw{constructor(e,n){this.config=e,this.eventCallback=n,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.registerInterval=6e4,this.handleNetworkInfoChange=r=>{var i,o;if((i=r.rttObject)!=null&&i.rtt){const a=(o=r.rttObject)==null?void 0:o.rtt,s=a!=null&&a>0;s||this.isOffline?s&&this.isOffline&&(this.isOffline=!1,this.handleOnline()):(this.isOffline=!0,this.handleOffline())}},this.handleOffline=()=>{rn.warn("网络断开,准备销毁 SIP 客户端","sip-client.ts 75 handleOffline"),ue.emit(He.FAIL_NOTIFICATION,"网络断开,准备销毁 SIP 客户端"),this.destroy()},this.handleOnline=()=>{rn.warn("网络恢复,准备重新启动 SIP 客户端","sip-client.ts 82 handleOnline"),this.reconnect()},this.sleep=r=>new Promise(i=>setTimeout(i,r)),F0.subscribe(this.handleNetworkInfoChange)}async start(){const e=jg.makeURI(`sip:${this.config.user}@${this.config.server}`);if(!e)throw new Error("无效的SIP配置");const n={uri:e,authorizationUsername:this.config.user,authorizationPassword:this.config.password,sendInitialProvisionalResponse:!1,transportOptions:{server:this.config.webSocket,connectionTimeout:10,keepAliveInterval:20,keepAliveDebounce:10},contactName:this.config.user,contactParams:{transport:"wss"},userAgentString:"SwiftSIP/2.0.21",sessionDescriptionHandlerFactoryOptions:{alwaysAcquireMediaFirst:!0,peerConnectionConfiguration:{iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceCandidatePoolSize:0,iceTransportPolicy:"all",rtcpMuxPolicy:"require",bundlePolicy:"balanced",certificates:void 0,peerIdentity:void 0},iceGatheringTimeout:1e3},logBuiltinEnabled:Z.logBuiltinEnabled};this.userAgent=new jg(n),this.setupEventListeners(),await this.userAgent.start(),await this.register()}setupEventListeners(){this.userAgent&&(this.userAgent.transport.stateChange.addListener(e=>{var r;let n;switch(e){case dt.Connecting:n=lr.WEB_RTC_CONNECTING;break;case dt.Connected:n=lr.WEB_RTC_CONNECTED,this.reconnectAttempts=0,Z.isRtcReconnecting=!1,H.updateIsSipConnected(!0),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);break;case dt.Disconnecting:n=lr.WEB_RTC_DISCONNECTING,H.updateIsSipConnected(!1);break;case dt.Disconnected:{if(H.updateIsSipConnected(!1),this.isManuallyStopped)return rn.warn("手动断开,不触发重连","sip-client.ts 204"),void console.warn("[SIP] 手动断开,不触发重连");ue.emit(He.FAIL_NOTIFICATION,"软电话链接失败"),n=lr.WEB_RTC_DISCONNECTED;const i=H.get("answerDevice");if(!Z.isRtcReconnecting&&this.reconnectAttempts<this.maxReconnectAttempts&&i===1){this.reconnectAttempts++;const o=1e3*this.reconnectAttempts;rn.warn(`SIP WebSocket 断开,第 ${this.reconnectAttempts} 次尝试重连,${o}ms 后重试...`,"sip-client.ts 219"),this.reconnectTimer=setTimeout(()=>{this.reconnect()},o)}else this.reconnectAttempts>=this.maxReconnectAttempts&&(rn.warn(`SIP 重连失败:已达到最大重试次数; reconnectAttempts: ${this.reconnectAttempts}; maxReconnectAttempts: ${this.maxReconnectAttempts}`,"sip-client.ts 228"),console.error("SIP 重连失败:已达到最大重试次数"),ue.emit(He.FAIL_NOTIFICATION,"SIP 重连失败:已达到最大重试次数"));break}default:H.updateIsSipConnected(!1),n="unknown"}(r=this.eventCallback)==null||r.call(this,{type:n})}),this.userAgent.delegate={onInvite:e=>{this.handleIncomingCall(e)}})}async refreshRegister(){if(this.registerer)try{await this.registerer.register(),new Date().toLocaleTimeString()}catch(e){console.error("[SIPClient] REGISTER刷新失败",e)}}async register(){var e,n;if(this.userAgent){this.registerer=new tu(this.userAgent,{expires:120,refreshFrequency:80}),(e=this.registerer)==null||e.stateChange.addListener(r=>{var o;let i;switch(r){case Qt.Initial:H.updateDisplayText(Gt.LINKING),i="initial";break;case Qt.Registered:H.updateDisplayText(""),i=lr.WEB_RTC_REGISTERED;break;case Qt.Unregistered:i=lr.WEB_RTC_UNREGISTERED;break;case Qt.Terminated:rn.warn(`注册流程已终止,无法再注册(如 UA 停止,或网络不可达);regStatus: ${lr.WEB_RTC_TERMINATED}`,"sip-client.ts 299"),i=lr.WEB_RTC_TERMINATED;break;default:i="unknown"}(o=this.eventCallback)==null||o.call(this,{type:i})});try{await this.registerer.register()}catch(r){(n=this.eventCallback)==null||n.call(this,{type:lr.WEB_RTC_REGISTER_FAILED,data:r})}}}attachRemoteAudio(e){const n=e.sessionDescriptionHandler;if(n){const r=n.peerConnection;if(!r)return;const i=new MediaStream;r.getReceivers().forEach(a=>{a.track&&a.track.kind==="audio"&&i.addTrack(a.track)});let o=document.getElementById("sip-remote-audio");o||(o=document.createElement("audio"),o.id="sip-remote-audio",o.autoplay=!0,o.style.display="none",document.body.appendChild(o)),o.srcObject=i,o.play().catch(a=>{console.error("音频播放失败,需要用户交互触发",a)})}}handleSessionState(e,n,r){e.stateChange.addListener(i=>{switch(i){case he.Established:clearTimeout(this.callTimeoutTimer),this.activeSession=e,this.attachRemoteAudio(e);break;case he.Terminating:break;case he.Terminated:this.activeSession=null,clearTimeout(this.callTimeoutTimer);case he.Establishing:}})}handleIncomingCall(e){this.incomingInvitation=e,this.handleSessionState(e,!1),e.progress({statusCode:180,reasonPhrase:"Ringing"}).catch(n=>console.error("发送 180 失败",n)),H.get("direction")}async answerCall(){var e;if(!this.incomingInvitation)throw new Error("无来电可接听");Z.autoAnswerTimer&&(clearTimeout(Z.autoAnswerTimer),Z.autoAnswerTimer=null);try{await this.incomingInvitation.accept(),this.activeSession=this.incomingInvitation,this.incomingInvitation=null}catch(n){(e=this.eventCallback)==null||e.call(this,{type:lr.WEB_RTC_ANSWER_FAILED,data:{detail:n}})}}async rejectInCall(){var e;if(this.incomingInvitation)try{await this.incomingInvitation.reject(),this.incomingInvitation=null,H.updateDirection(null),H.updateIsCalling(!1),clearTimeout(this.callTimeoutTimer)}catch(n){(e=this.eventCallback)==null||e.call(this,{type:"error",data:{message:"拒接失败",detail:n}})}}sendDTMF(e){var r;if(!this.activeSession)throw new Error("当前没有活跃的通话");const n=this.activeSession.sessionDescriptionHandler;n&&typeof n.sendDtmf=="function"?(n.sendDtmf(e),(r=this.eventCallback)==null||r.call(this,{type:lr.WEB_RTC_SEND_DTMF,data:{tone:e}})):(console.warn("DTMF发送不支持或未初始化"),rn.warn("DTMF发送不支持或未初始化","sip-client.ts 490 sendDTMF"))}async hangup(){if(this.activeSession,this.activeSession){clearTimeout(this.callTimeoutTimer);const e=this.activeSession;if(!e)return;const n=e.state;try{n===he.Established?await e.bye():n===he.Establishing&&(e instanceof b0?await e.cancel():e instanceof eu&&await e.reject()),clearTimeout(this.callTimeoutTimer)}catch(r){rn.error("挂断失败","sip-client.ts 522 hangup"),console.error("挂断失败",r)}finally{this.activeSession=null}}}async rejectOutCall(){this.activeSession instanceof eu&&(await this.activeSession.reject(),this.activeSession=null)}async destroy(){if(this.isManuallyStopped=!0,clearTimeout(this.callTimeoutTimer),this.activeSession&&await this.hangup(),this.registerer){try{await this.registerer.unregister()}catch(e){console.warn("注销失败",e)}this.registerer=null}this.userAgent&&(await this.userAgent.stop(),this.userAgent=null)}async reconnect(){if(!Z.isRtcReconnecting){Z.isRtcReconnecting=!0;try{this.isManuallyStopped=!1,await this.destroy(),await this.start(),this.isOffline=!1,this.reconnectAttempts=0}catch(e){console.error("重连失败",e),Z.isRtcReconnecting=!1}finally{Z.isRtcReconnecting=!1}}}async getNetworkStats(){var e;if(this.activeSession){const n=(e=this.activeSession.sessionDescriptionHandler)==null?void 0:e.peerConnection;if(!n)return null;const r=await n.getStats(),i={};return r.forEach(o=>{o.type==="candidate-pair"&&o.state==="succeeded"&&o.currentRoundTripTime!=null&&(i.rtt=+(1e3*o.currentRoundTripTime).toFixed(2)),o.type==="inbound-rtp"&&o.kind==="audio"&&(i.jitter=+(1e3*o.jitter).toFixed(2),i.packetsLost=o.packetsLost,i.packetsReceived=o.packetsReceived,o.bytesReceived&&o.timestamp&&(i.recvBitrate=+(o.bytesReceived/1024).toFixed(2))),o.type==="outbound-rtp"&&o.kind==="audio"&&(i.packetsSent=o.packetsSent,o.bytesSent&&o.timestamp&&(i.sendBitrate=+(o.bytesSent/1024).toFixed(2))),o.type==="codec"&&o.mimeType&&(i.codec=o.mimeType)}),{...i,rtt:(i==null?void 0:i.rtt)||40}}return{rtt:Z.latency||1}}}class No{static requestPermission(){"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}static async requestMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(n=>n.kind==="audioinput"&&n.label!=="")?null:await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){return console.warn("获取音频权限失败:",e),null}}static show(e,n,r,i){if("Notification"in window&&Notification.permission==="granted"){const o=new Notification(e,{body:n,tag:`xy-global-notification${new Date().getTime()}`,renotify:!0});o.onclick=()=>{window.focus(),o.close(),r==null||r()},setTimeout(()=>o.close(),1e3*(i||3))}}static async checkMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(e=>e.kind==="audioinput"&&e.label!=="")}catch(e){return console.warn("无法检查设备权限:",e),!1}}}const Qw=[],zn=["call_number"],hA=["call_number"],Lw=["hangup"],yi=["hold","hangup","mute","transfer","consult","satisfaction","dtmf"],Wl=["hold","hangup","mute","transfer","consult"],Vg=["consult_transfer","conference","consult_retrieve"],Uw=["hangup"],Hw=["hangup"],Ms=["answer","reject"],qi=["hangup","consult","transfer","hold","mute","satisfaction","dtmf"],Zg=["hangup","whisper","force_insert","force_disconnect"],Gw=["hangup"],qw=["hangup","cancel_whisper","force_insert"],Vw=["hangup"],Zw=["hangup"];class La{constructor(){this.roleData={agentInfo:()=>{var e;if(!((e=Z.agentInfo)!=null&&e.agent_no))throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:e=>{if(!e.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:e=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:n}=Z.agentInfo;if(!n.split(",").map(r=>Number(r)).includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(e,n)=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!n)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(e===2&&(n==="通话中"||n==="整理"))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:e=>{const{out_display_select_switch:n,out_display_data:r}=Z.agentInfo;if(n!==1)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(r||"").split("#").includes(e))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}},this.changeDevice=async e=>{try{if(H.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:n,success:r}=e,{device:i}=n;i===1&&await La.initRtcFn(),this.roleData.changeDevice(i);const{agent_no:o}=Z.agentInfo;await(s=>yn(`${Tr}/device/change`,s))({agent_no:o,answer_device:i}),H.updateAnswerDevice(i);const a=H.get("actionConfigs");H.updateActionConfigs(a),i===2&&Z.stateObject.state===Mt.UNREGISTERED&&await this._changeState({data:{...Z.stateBeforeChange,state_name:Z.stateBeforeChange.state===Mt.IDLE?"空闲":"忙碌"}},"q"),r==null||r({code:0,msg:"请求成功"})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}formatDate(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}static setInitRtcFn(e){this.initRtcFn=e}async _agentLogin(e){try{const r=await(n={agent_no:e},yn(`${Tr}/agent/login`,n));Z.agentInfo=r.data}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}var n}async _changeState(e,n){try{Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:a}=r,{agent_no:s}=Z.agentInfo;await qg({agent_no:s,state_name:a,state:o},n),o===Mt.IDLE?H.updateActionConfigs(zn):o===Mt.BUSY&&H.updateActionConfigs(hA),Z.stateObject={state:o,state_name:a},i==null||i({code:0,msg:"请求成功"})}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async _getInCallCrmDetail(e){var n;try{const{phone:r}=e.data,i={};iu(r)?i.trace_id=r:i.phone=r.replace(/[\s\r\n-]+/g,"");const o=await(a=>yn(`${Wi}/crm/popups`,a))({...i});(n=e.success)==null||n.call(e,o)}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async changeState(e,n){try{if(H.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:a}=r;this.roleData.changeState(o,a);const{agent_no:s}=Z.agentInfo;await qg({agent_no:s,state_name:a,state:o},n),(Z.stateObject.state===Mt.IDLE||Z.stateObject.state===Mt.BUSY&&a!=="整理")&&(Z.stateBeforeChange=Z.stateObject),o===Mt.IDLE?H.updateActionConfigs(zn):o===Mt.BUSY&&H.updateActionConfigs(hA),Z.stateObject={state:o,state_name:a},i==null||i({code:0,msg:"请求成功"})}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getIdleAgentList(e){var r;const{agent_no:n}=Z.agentInfo;try{this.roleData.agentInfo();const i=await(o=>yn(`${Tr}/agent/free`,o))({agent_no:n});(r=e.success)==null||r.call(e,i)}catch(i){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(i.message).msg),i}}async getAgentState(e){var n;try{const r=await yn(`${Wi}/agent/statecfg/list`,{}),i=(r.data||[]).filter(o=>o.enable===0).filter(o=>o.state!==0&&o.state!==3).filter(o=>o.state_name!=="通话中"&&o.state_name!=="整理"&&o.state_name!=="未注册"&&o.state_name!=="离线接听").map(o=>({state:o.state,state_name:o.state_name})).reverse();(n=e.success)==null||n.call(e,{...r,data:i})}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async setAgentExplicit(e){var n;try{this.roleData.agentInfo(),this.roleData.requestInfo(e),this.roleData.setAgentExplicit(e.data.number);const{agent_id:r}=Z.agentInfo;await(i=>yn(`${Wi}/agent/update`,i))({agent_id:r,out_display_number:e.data.number}),H.updateSelectOutNumber(e.data.number),(n=e.success)==null||n.call(e,{code:0,msg:"请求成功"})}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async checkAgentLogin(e){var n;try{this.roleData.requestInfo(e);const{agent_no:r}=e.data;if(!r)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const i=await(o=>yn(`${Tr}/agent/islogin`,o))({agent_no:r});(n=e.success)==null||n.call(e,i)}catch(r){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getCallRecord(e){try{this.roleData.agentInfo();const{success:n}=e,r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59),a=[this.formatDate(i),this.formatDate(o)],{agent_no:s}=Z.agentInfo,A=await(f=>yn(`${Wi}/agent/recordpage`,f))({start_time:a[0],end_time:a[1],page_no:1,page_size:10,agent_no_list:[s]}),{code:l,msg:u,data:d}=A;n==null||n({code:l,msg:u,data:d})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async logout(e){this.roleData.agentInfo();try{const{agent_no:n}=Z.agentInfo,{data:r,success:i}=e;await(o=>yn(`${Tr}/agent/logout`,o))({...r,agent_no:n}),i==null||i({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async listenCall(e){try{const{agent_no:n}=Z.agentInfo,{data:r,success:i}=e;if(this.roleData.agentInfo(),this.roleData.requestInfo(e),!r.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(o=>yn(`${Tr}/call/monitor`,o))({...r,monitor_agent_no:n}),Z.monitoredAgentNo=r.monitored_agent_no,i==null||i({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async earCall(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Tr}/call/whisper`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async stopEarCall(e){try{const{agentInfo:n,earSpeakAgent:r}=Z;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;await(a=>yn(`${Tr}/call/stopwhisper`,a))({monitor_agent_no:i,monitored_agent_no:r}),o==null||o({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceInsert(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Tr}/call/bargein`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceDisconnect(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Tr}/call/intercept`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw ue.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}const Kw=console.log,Kg=(...t)=>{Z.logBuiltinEnabled&&Kw(...t)};let ri=null;class An{constructor(e,n){this.url=e,this.onOpenCallback=n,this.ws=null,this.heartbeatWorker=null,this.reconnectDelay=3e3,this.manualClose=!1,this.apiClient=new La,this.sipClient=null,this.pendingMessages=new Map,this.initWebSocket()}static getInstance({url:e,sipClient:n,onOpen:r}){if(!ri){if(!e)throw new Error("WebSocket 尚未初始化");ri=new An(e,r),ri.sipClient=n}return ri}setSipClient(e){this.sipClient=e}stateIdleChange(e){const{state:n}=Z.stateObject;n!==Mt.IDLE&&this.apiClient._changeState({data:{...Z.stateBeforeChange,state_name:Z.stateBeforeChange.state===Mt.IDLE?"空闲":"忙碌"}},e)}inCallAutoAnswer(){const{soft_device_auto_answer:e,auto_answer_time:n}=Z.agentInfo,r=e===1,i=H.get("direction");if(r&&i===Rn.INCOMING){const o=Number(n)||0;o>0&&(Z.autoAnswerTimer=setTimeout(()=>{var a;(a=this.sipClient)==null||a.answerCall(),Z.autoAnswerTimer=null},o>0?1e3*o-500:0))}}async getCustomerInfo(e,n){try{await this.apiClient._getInCallCrmDetail({data:{phone:e},success:r=>{const{phone:i,trace_id:o,...a}=r.data,s={...a,type:n,session_id:Z.sessionId,phone:r.data.phone,trace_id:r.data.trace_id};H.updateCustomerInfo(s)}})}catch{}}putAgentState(e,n){if(!e)return;if(n===5)return void this.stateIdleChange("device_type5");if(H.get("answerDevice")!==1)return;Z.sessionId="";const{post_call_process_time:r}=Z.agentInfo,i=r||0;if(Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),H.updateCustomerInfo(void 0),i>0){const{state:o}=Z.stateObject;if(o===Mt.IDLE)return;this.apiClient._changeState({data:{state:Mt.BUSY,state_name:"整理"}},"ez"),Z.autoStateTimer=setTimeout(()=>{Z.autoStateTimer=null,this.stateIdleChange(`delay${i}`)},1e3*i)}else this.stateIdleChange("delay0")}stateBusyChange(){Z.sessionId="",clearTimeout(Z.autoStateTimer),H.updateCustomerInfo(void 0),this.apiClient._changeState({data:{state:Mt.BUSY,state_name:"忙碌"}},"dm")}initWebSocket(){var n;if(((n=this.ws)==null?void 0:n.readyState)===1||!H.get("isNextState")||this.manualClose)return;const e=U0(zd,Yd);this.ws=new WebSocket(this.url+e),this.ws.onopen=()=>{const r=new Date().getTime();this.sendMessage({type:0,msg_id:r}),this.pendingMessages.set(r,performance.now()),this.startHeartbeat(),this.manualClose=!1,this.onOpenCallback&&this.onOpenCallback()},this.ws.onmessage=async r=>{var u,d,f,p;const i=JSON.parse(r.data),{type:o,data:a,code:s,msg:A,msg_id:l}=i;if(o===0&&l){const m=this.pendingMessages.get(l),C=performance.now()-m;Z.latency=parseFloat(C.toFixed(2)),this.pendingMessages.delete(l)}if(o!==0&&Kg("%cWebSocket 收到消息:","color: blue; font-weight: bold;",i),o!==rt.OUT_CALL&&o!==rt.PREVIEW_OUT_CALL||(Z.isAgentHangup=!1,s!==0?(H.reset(),ue.emit(ie.OUT_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A),H.updateActionConfigs(zn),setTimeout(()=>{H.updateCustomerInfo(void 0)},500),this.stateIdleChange("h")):s===0&&(H.updateDirection(Rn.OUTGOING),ue.emit(ie.OUT_SUCCESS),Z.sessionId=a.session_id,H.updateIsCalling(!0),clearTimeout(Z.autoStateTimer))),o===rt.AGENT_STATE){const{state:m,state_name:C}=a;Z.stateObject={state:m,state_name:C},(u=Z.stateBeforeChange)!=null&&u.state||Z.stateObject.state!==Mt.IDLE&&(Z.stateObject.state!==Mt.BUSY||C==="整理")||(Z.stateBeforeChange=Z.stateObject),C==="振铃中"&&H.updateDisplayText(Gt.AGENT_RINGING);const v=H.get("isCalling");m!==Mt.UNREGISTERED||v||H.updateActionConfigs(Qw),m!==Mt.IDLE||v||H.updateActionConfigs(zn),ue.emit(ie.AGENT_STATE,{state:m,state_name:C})}else if(o===rt.OUT_CALL_INCOMING_CALL)Z.isAgentHangup=!1,H.updateIsCalling(!0),a.preview_task_id?((d=this.sipClient)==null||d.answerCall(),this.getCustomerInfo(a.trace_id||a.customer_phone,"preview_out_incoming_call"),ue.emit(ie.PREVIEW_OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,preview_task_id:a.preview_task_id,trace_id:a.trace_id})):a.direction===0?((f=this.sipClient)==null||f.answerCall(),this.getCustomerInfo(a.trace_id||a.customer_phone,"out_call_incoming_call"),ue.emit(ie.OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,trace_id:a.trace_id})):a.direction===8&&((p=this.sipClient)==null||p.answerCall(),this.getCustomerInfo(a.trace_id||a.customer_phone,"internal_out_incoming_call"),ue.emit(ie.INTERNAL_OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,trace_id:a.trace_id})),Z.sessionId=a.session_id,H.updateActionConfigs(Lw,a.direction!==8);else if(o===rt.OUT_CALL_END){if(Z.sessionId!==a.session_id)return;if(H.updateDisplayText(""),a.device_type===1&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.OUT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),H.updateActionConfigs(zn),this.putAgentState(!0);else if(a.device_type===2&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.OUR_SIDE_CONSULT_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn),this.putAgentState(!0);else if(a.device_type===2&&a.agent_no!==Z.agentInfo.agent_no)H.get("isCalling")&&(H.updateDisplayText(Gt.CALLING),ue.emit(ie.OTHER_SIDE_CONSULT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),H.updateActionConfigs(yi));else if(a.device_type===3&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.THREE_WAY_OUR_SIDE_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn),this.putAgentState(!0);else if(a.device_type===4&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.TRANSFER_END,{session_id:a.session_id}),H.updateActionConfigs(zn),this.putAgentState(!0);else if(a.device_type===4&&a.agent_no!==Z.agentInfo.agent_no){ue.emit(ie.TRANSFER_FAILED,"未知原因"),ue.emit(He.FAIL_NOTIFICATION,"转接失败");const m=H.get("direction");m===Rn.OUTGOING?H.updateActionConfigs(yi):m===Rn.INCOMING&&H.updateActionConfigs(qi)}else a.device_type===5&&a.agent_no===Z.agentInfo.agent_no&&(Z.monitoredAgentNo="",Z.earSpeakAgent="",H.reset(),ue.emit(ie.LISTEN_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn),this.putAgentState(!0,5))}else if(o===rt.OUT_CALL_RINGING)H.get("displayText")===Gt.AGENT_RINGING&&(Z.isAgentHangup=!1,ue.emit(ie.OUT_RINGING,{session_id:Z.sessionId,type:a.type}),H.updateDisplayText(Gt.RINGING));else if(o===rt.OUT_CALL_ANSWER)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),H.updateIsCalling(!0),H.updateOutCallIsAnswer(!0),H.updateDisplayText(Gt.CALLING),a.direction===8?(ue.emit(ie.INTERNAL_OUT_OFF_ANSWER,{session_id:Z.sessionId}),H.updateActionConfigs(Wl)):(ue.emit(ie.OUT_OFF_ANSWER,{session_id:Z.sessionId}),H.updateActionConfigs(yi));else if(o===rt.CONSULT_RINGING)Z.isAgentHangup=!1,ue.emit(ie.CONSULT_RINGING,{session_id:a.session_id}),H.updateDisplayText(Gt.AGENT_RINGING),H.updateActionConfigs([]),clearTimeout(Z.autoStateTimer);else if(o===rt.CONSULT_ANSWER)Z.isAgentHangup=!1,ue.emit(ie.CONSULT_OFF_HOOK,{session_id:a.session_id}),H.updateConsultIsAnswer(!0),H.updateDisplayText(Gt.CONSULTING),H.updateActionConfigs(Vg);else if(o===rt.CONSULT_FAIL)ue.emit(ie.CONSULT_FAILED,{custom_reason:a.custom_reason}),H.updateDisplayText(Gt.CALLING),H.updateActionConfigs(yi);else if(o===rt.CONSULT_CALL_IN)Z.isAgentHangup=!1,ue.emit(ie.CONSULT_INCOMING,{agent_no:a.agent_no,agent_mane:a.agent_name,session_id:a.session_id}),Z.sessionId=a.session_id,H.updateIsCalling(!0),H.updateDirection(Rn.CONSULT),H.updateDisplayText(Gt.CONSULT_CALL_IN),H.updateActionConfigs(Ms),Z.enableBrowserAlert&&No.show("📞 咨询来电",`坐席 [${a.agent_name}] 正在咨询...`,()=>{ue.emit(He.NOTIFICATION_CLICK,{agent_mane:a.agent_name,agent_no:a.agent_no})},Z.browserAlertTime);else if(o===rt.CONSULT_CALL_IN_SUCCESS)ue.emit(ie.CONSULT_CALL_IN_SUCCESS,{session_id:a.session_id}),H.updateConsultIsAnswer(!0),H.updateDisplayText(Gt.CALLING),H.updateActionConfigs(Uw);else if(o===rt.CONSULT_RETURN_CALL_SUCCESS)a.status==="success"?(H.updateConsultIsAnswer(!1),ue.emit(ie.CONSULT_RETURN_CALL_SUCCESS),H.updateDisplayText(Gt.CALLING),ue.emit(ie.OTHER_SIDE_CONSULT_HANGUP),H.updateActionConfigs(yi)):ue.emit(He.FAIL_NOTIFICATION,"媒体失败");else if(o===rt.MUTE)s===0?(H.updateIsMuted(!0),ue.emit(ie.MUTE_SUCCESS),H.updateDisplayText(Gt.MUTING)):(ue.emit(ie.MUTE_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.UNMUTE)s===0?(H.updateIsMuted(!1),ue.emit(ie.UNMUTE_SUCCESS),H.updateDisplayText(Gt.CALLING)):(ue.emit(ie.UNMUTE_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CALL_HOLD)s===0?(H.updateIsHold(!0),H.updateDisplayText(Gt.HOLDING),ue.emit(ie.HOLD_SUCCESS)):(ue.emit(ie.HOLD_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CALL_UNHOLD)s===0?(H.updateDisplayText(Gt.CALLING),H.updateIsHold(!1),ue.emit(ie.UNHOLD_SUCCESS)):(ue.emit(ie.UNHOLD_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CONSULT_TRANSFER)Z.isAgentHangup=!1,s===0?ue.emit(ie.CONSULT_TRANSFER_SUCCESS):(ue.emit(ie.CONSULT_TRANSFER_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CONSULT_TRANSFER_FAILED)ue.emit(ie.CONSULT_TRANSFER_FAILED,a.status);else if(o===rt.CONSULT_TRANSFER_OFF_HOOK)H.updateDirection(Rn.INCOMING),H.updateDisplayText(Gt.CALLING),ue.emit(ie.CONSULT_TRANSFER_OFF_HOOK),H.updateActionConfigs(qi),H.updateIncomingIsAnswer(!0),H.updateConsultIsAnswer(!1);else if(o===rt.INCOMING_CALL)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),Z.sessionId=a.session_id,H.updateIsCalling(!0),H.updateDirection(Rn.INCOMING),H.updateDisplayText(Gt.INCOMING_CALL),this.inCallAutoAnswer(),a.direction!==1&&a.direction!==4&&a.direction!==7||(this.getCustomerInfo(a.trace_id||a.customer_phone,"incoming_call"),ue.emit(ie.INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===8&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"incoming_call_in"),ue.emit(ie.INCOMING_CALL_IN,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===3&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"predict_incoming_call"),ue.emit(ie.PREDICT_INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===6&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"dual_call_incoming_call"),ue.emit(ie.DUAL_CALL_INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),H.updateActionConfigs(Ms),Z.enableBrowserAlert&&No.show("📞 客户来电",`客户 [${a.customer_phone}] 正在呼入...`,()=>{ue.emit(He.NOTIFICATION_CLICK,{customer_phone:a.customer_phone})},Z.browserAlertTime);else if(o===rt.INCOMING_CALL_OFF_HOOK)H.updateIncomingIsAnswer(!0),a.direction===8?(H.updateActionConfigs(Wl),ue.emit(ie.INCOMING_CALL_IN_OFF_HOOK,{session_id:Z.sessionId})):(H.updateActionConfigs(qi),ue.emit(ie.INCOMING_CALL_OFF_HOOK,{session_id:Z.sessionId})),H.updateDisplayText(Gt.CALLING);else if(o===rt.INCOMING_CALL_END){if(Z.sessionId!==a.session_id)return;if(H.updateDisplayText(""),a.device_type!==1&&a.device_type!==7||a.agent_no!==Z.agentInfo.agent_no)if(a.device_type===2&&a.agent_no===Z.agentInfo.agent_no)H.reset(),ue.emit(ie.OUR_SIDE_CONSULT_HANGUP,{session_id:a.session_id}),this.putAgentState(!0),H.updateActionConfigs(zn);else if(a.device_type===2&&a.agent_no!==Z.agentInfo.agent_no)H.updateDisplayText(Gt.CALLING),ue.emit(ie.OTHER_SIDE_CONSULT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),H.updateActionConfigs(yi);else if(a.device_type===3&&a.agent_no===Z.agentInfo.agent_no)this.putAgentState(!0),H.reset(),ue.emit(ie.THREE_WAY_OUR_SIDE_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn);else if(a.device_type===4&&a.agent_no===Z.agentInfo.agent_no)this.putAgentState(!0),H.reset(),ue.emit(ie.TRANSFER_END,{session_id:a.session_id}),H.updateActionConfigs(zn);else if(a.device_type===4&&a.agent_no!==Z.agentInfo.agent_no){ue.emit(ie.TRANSFER_FAILED,"未知原因"),ue.emit(He.FAIL_NOTIFICATION,"转接失败");const m=H.get("direction");m===Rn.OUTGOING?H.updateActionConfigs(yi):m===Rn.INCOMING&&H.updateActionConfigs(qi)}else a.device_type===5&&a.agent_no===Z.agentInfo.agent_no&&(this.putAgentState(!0,5),Z.monitoredAgentNo="",Z.earSpeakAgent="",H.reset(),ue.emit(ie.LISTEN_HANGUP,{session_id:a.session_id}),H.updateActionConfigs(zn));else this.putAgentState(!0),H.reset(),ue.emit(ie.INCOMING_CALL_END,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),H.updateActionConfigs(zn)}else if(o===rt.SATISFACTION_EVALUATION)s===0?ue.emit(ie.SATISFACTION_EVALUATION_SUCCESS):(ue.emit(ie.SATISFACTION_EVALUATION_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A));else if(o===rt.CONSULT_THREE_WAY)s!==0?(ue.emit(ie.CONSULT_THREE_WAY_FAILED,A),ue.emit(He.FAIL_NOTIFICATION,A)):s===0&&H.updateIsMeeting(!0);else if(o===rt.CONSULT_THREE_WAY_RESULT)a.status==="success"?(H.updateDirection(Rn.MEETING),H.updateDisplayText(Gt.MEETING),H.updateActionConfigs(Hw),ue.emit(ie.CONSULT_THREE_WAY_SUCCESS)):(ue.emit(ie.CONSULT_THREE_WAY_FAILED,{conf_name:a.conf_name}),H.updateIsMeeting(!1));else if(o===rt.TRANSFER_INCOMING_CALL)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),a.agent_no===Z.agentInfo.agent_no?(H.updateDisplayText(Gt.TRANSFERRING),ue.emit(ie.TRANSFER_PROGRESS),H.updateActionConfigs([]),H.updateTransferIsAnswer(!0)):(Z.sessionId=a.session_id,ue.emit(ie.TRANSFER_INCOMING_CALL,{agent_no:a.agent_no,agent_name:a.agent_name,session_id:a.session_id}),H.updateIsCalling(!0),H.updateDirection(Rn.TRANSFER),H.updateDisplayText(Gt.TRANSFER_INCOMING_CALL),H.updateActionConfigs(Ms),Z.enableBrowserAlert&&No.show("📞 转接来电",`坐席 [${a.agent_no}] 正在转接...`,()=>{ue.emit(He.NOTIFICATION_CLICK,{agent_no:a.agent_no})},Z.browserAlertTime));else if(o===rt.TRANSFER_OFF_HOOK)ue.emit(ie.TRANSFER_OFF_HOOK,{session_id:Z.sessionId}),H.updateTransferIsAnswer(!1),H.updateDisplayText(Gt.CALLING),H.updateActionConfigs(qi,a.direction!==8);else if(o===rt.TRANSFER_FAILED){if(a.status==="failed"){ue.emit(ie.TRANSFER_FAILED,"未知原因"),ue.emit(He.FAIL_NOTIFICATION,"转接失败");const m=H.get("direction");m===Rn.OUTGOING?H.updateActionConfigs(yi):m===Rn.INCOMING&&H.updateActionConfigs(qi)}}else o===rt.KICK_OFFLINE?ue.emit(He.KICK_OFF):o===rt.CONTINUOUS_NOT_ANSWER?(ue.emit(He.FAIL_NOTIFICATION,`已连续 ${a.miss_count} 次未接, 设置忙碌`),this.stateBusyChange()):o===rt.SIGN_OUT?ue.emit(He.SIGN_OUT):o===rt.SIGN_IN_SWITCH_DEVICE?ue.emit(He.SIGN_IN_SWITCH_DEVICE,a):o===rt.LISTEN_INCOMING_CALL?(clearTimeout(Z.autoStateTimer),Z.sessionId=a.session_id,H.updateIsCalling(!0),H.updateDirection(Rn.INCOMING),this.inCallAutoAnswer(),H.updateDisplayText(Gt.LISTENING),H.updateActionConfigs(Ms),ue.emit(ie.LISTEN_INCOMING_CALL,{session_id:a.session_id}),Z.enableBrowserAlert&&No.show("📞 监听来电","正在来电...",()=>{ue.emit(He.NOTIFICATION_CLICK,{customer_phone:a.customer_phone})},Z.browserAlertTime)):o===rt.LISTEN_INCOMING_CALL_OFF_HOOK?(Z.monitoredAgentNo=a.monitored_agent_no,Z.earSpeakAgent="",H.updateIncomingIsAnswer(!0),ue.emit(ie.LISTEN_INCOMING_CALL_OFF_HOOK,{session_id:Z.sessionId,monitored_agent_no:a.monitored_agent_no}),H.updateActionConfigs(Zg),H.updateDisplayText(Gt.CALLING)):o===rt.LISTEN_CALL_FAILED?a.status==="failed"&&(ue.emit(ie.LISTEN_CALL_FAILED),Z.monitoredAgentNo=""):o===rt.EAR_SPEECH?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&(H.updateActionConfigs(Gw),ue.emit(ie.EAR_SPEECH_BE_SUCCESS)),a.monitor_agent_no===Z.agentInfo.agent_no&&(H.updateActionConfigs(qw),ue.emit(ie.EAR_SPEECH_SUCCESS,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no}),Z.earSpeakAgent=a.monitored_agent_no)):ue.emit(ie.EAR_SPEECH_FAILED):o===rt.STOP_EAR_SPEECH?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&H.updateActionConfigs(qi),a.monitor_agent_no===Z.agentInfo.agent_no&&H.updateActionConfigs(Zg),Z.earSpeakAgent="",ue.emit(ie.STOP_EAR_SPEECH_SUCCESS)):ue.emit(ie.STOP_EAR_SPEECH_FAILED):o===rt.CALL_FORCE_INSERT?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&(H.updateActionConfigs(Zw),ue.emit(ie.CALL_FORCE_INSERT_SUCCESS,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no})),a.monitor_agent_no===Z.agentInfo.agent_no&&(H.updateActionConfigs(Vw),ue.emit(ie.CALL_FORCE_INSERT_SUCCESS_LISTENER,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no}))):ue.emit(ie.CALL_FORCE_INSERT_FAILED):o===rt.INTERNAL_CALL_START_CONSULT?a.agent_no===Z.agentInfo.agent_no?(H.updateConsultIsAnswer(!0),H.updateActionConfigs(Vg),H.updateDisplayText(Gt.CONSULTING)):(H.updateDisplayText(Gt.OTHER_SIDE_CONSULTING),H.updateActionConfigs([])):o===rt.INTERNAL_CALL_END_CONSULT?(H.updateActionConfigs(Wl),H.updateDisplayText(""),H.updateConsultIsAnswer(!1)):o===rt.CALL_SIP_INCOMING_CALL?ue.emit(ie.CALL_SIP_INCOMING_CALL):o===rt.CALL_REAL_TIME_TRANSCRIPT&&ue.emit(ie.REAL_TIME_TRANSCRIPTION,a)},this.ws.onclose=r=>{ue.emit(He.FAIL_NOTIFICATION,"链接已断开,请检查网络"),this.stopHeartbeat();const i=H.get("isNextState");!this.manualClose&&i&&setTimeout(()=>this.initWebSocket(),this.reconnectDelay)},this.ws.onerror=r=>{var i;ue.emit(He.FAIL_NOTIFICATION,"连接失败,请检查网络"),(i=this.ws)==null||i.close()}}startHeartbeat(){const e=new Blob([`
164
164
  let timer;
165
165
  self.onmessage = function (e) {
166
166
  if (e.data === 'start') {
@@ -759,7 +759,7 @@ html body {
759
759
  &:hover {
760
760
  opacity: 0.9;
761
761
  }
762
- `;function MN({title:t,content:e,icon:n,onOk:r,onCancel:i}){const o=document.createElement("div");document.body.appendChild(o);const a=bN.createRoot(o),s=()=>{a.unmount(),o.remove()},A=async()=>{r&&await r(),s()},l=()=>{i==null||i(),s()};a.render(X.jsx(SN,{children:X.jsxs(wN,{children:[X.jsxs(IN,{children:[n&&X.jsx(xN,{children:n}),t]}),X.jsx(RN,{children:e}),X.jsxs(ON,{children:[X.jsx($m,{onClick:l,children:"取消"}),X.jsx($m,{primary:!0,onClick:A,children:"确定"})]})]})}))}class TN{constructor(){vr(this,"listeners",new Map);vr(this,"allHandlers",new Set)}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{var r;(r=this.listeners.get(e))==null||r.delete(n)}}onAll(e){return this.allHandlers.add(e),()=>{this.allHandlers.delete(e)}}emit(e,n){var r;(r=this.listeners.get(e))==null||r.forEach(i=>i(n)),this.allHandlers.forEach(i=>i(e,n))}clear(){this.listeners.clear(),this.allHandlers.clear()}}const Lf=new TN,NN=(t,e)=>Lf.on(t,e),DN=t=>Lf.onAll(t),BN={1:X.jsx(vt,{name:"ruandianhua"}),2:X.jsx(vt,{name:"pnhone"}),3:X.jsx(vt,{name:"sip-phone"})},FN={call_number:"",answer:"接听",reject:"拒接",hangup:"挂机",dtmf:"DTMF",unhold:"取消保持",hold:"保持",mute:"静音",unmute:"取消静音",satisfaction:"满意度",consult:"咨询",consult_transfer:"咨询转接",consult_retrieve:"取回通话",conference:"三方会议",whisper:"耳语",cancel_whisper:"取消耳语",force_insert:"强插",force_disconnect:"强拆",transfer:"转接"},kN={空闲:1,离线:0,未注册:4},PN=N.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-C2ooLq_a.js"))),jN=N.lazy(()=>Promise.resolve().then(()=>require("./TransferModel-d06jBnEL.js")));$t.div`
762
+ `;function MN({title:t,content:e,icon:n,onOk:r,onCancel:i}){const o=document.createElement("div");document.body.appendChild(o);const a=bN.createRoot(o),s=()=>{a.unmount(),o.remove()},A=async()=>{r&&await r(),s()},l=()=>{i==null||i(),s()};a.render(X.jsx(SN,{children:X.jsxs(wN,{children:[X.jsxs(IN,{children:[n&&X.jsx(xN,{children:n}),t]}),X.jsx(RN,{children:e}),X.jsxs(ON,{children:[X.jsx($m,{onClick:l,children:"取消"}),X.jsx($m,{primary:!0,onClick:A,children:"确定"})]})]})}))}class TN{constructor(){vr(this,"listeners",new Map);vr(this,"allHandlers",new Set)}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{var r;(r=this.listeners.get(e))==null||r.delete(n)}}onAll(e){return this.allHandlers.add(e),()=>{this.allHandlers.delete(e)}}emit(e,n){var r;(r=this.listeners.get(e))==null||r.forEach(i=>i(n)),this.allHandlers.forEach(i=>i(e,n))}clear(){this.listeners.clear(),this.allHandlers.clear()}}const Lf=new TN,NN=(t,e)=>Lf.on(t,e),DN=t=>Lf.onAll(t),BN={1:X.jsx(vt,{name:"ruandianhua"}),2:X.jsx(vt,{name:"pnhone"}),3:X.jsx(vt,{name:"sip-phone"})},FN={call_number:"",answer:"接听",reject:"拒接",hangup:"挂机",dtmf:"DTMF",unhold:"取消保持",hold:"保持",mute:"静音",unmute:"取消静音",satisfaction:"满意度",consult:"咨询",consult_transfer:"咨询转接",consult_retrieve:"取回通话",conference:"三方会议",whisper:"耳语",cancel_whisper:"取消耳语",force_insert:"强插",force_disconnect:"强拆",transfer:"转接"},kN={空闲:1,离线:0,未注册:4},PN=N.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-D0153E_l.js"))),jN=N.lazy(()=>Promise.resolve().then(()=>require("./TransferModel-CD7u0VF9.js")));$t.div`
763
763
  width: 25px;
764
764
  height: 25px;
765
765
  background: ${({bg:t})=>t};
@@ -10104,7 +10104,7 @@ const ue = { on: (t, e) => (va.on(t, e), ue), off(t, e) {
10104
10104
  this.setState({ isSipConnected: t });
10105
10105
  }
10106
10106
  reset() {
10107
- this.updateAnswerDevice(1), this.updateIsCalling(wr.isCalling), this.updateDirection(wr.direction), this.updateOutCallIsAnswer(wr.outCallIsAnswer), this.updateIsHold(wr.isHold), this.updateDisplayText(wr.displayText), this.updateActionConfigs(wr.actionConfigs), this.updateConsultIsAnswer(wr.consultIsAnswer), this.updateIsMuted(wr.isMuted), this.updateIncomingIsAnswer(wr.incomingIsAnswer), this.updateIsMeeting(wr.isMeeting), this.updateTransferIsAnswer(wr.transferIsAnswer), this.updateCustomerInfo(void 0);
10107
+ this.updateIsCalling(wr.isCalling), this.updateDirection(wr.direction), this.updateOutCallIsAnswer(wr.outCallIsAnswer), this.updateIsHold(wr.isHold), this.updateDisplayText(wr.displayText), this.updateActionConfigs(wr.actionConfigs), this.updateConsultIsAnswer(wr.consultIsAnswer), this.updateIsMuted(wr.isMuted), this.updateIncomingIsAnswer(wr.incomingIsAnswer), this.updateIsMeeting(wr.isMeeting), this.updateTransferIsAnswer(wr.transferIsAnswer), this.updateCustomerInfo(void 0);
10108
10108
  }
10109
10109
  getCallInfo() {
10110
10110
  return this.getState();
@@ -11038,6 +11038,7 @@ class un {
11038
11038
  putAgentState(e, n) {
11039
11039
  if (!e) return;
11040
11040
  if (n === 5) return void this.stateIdleChange("device_type5");
11041
+ if (U.get("answerDevice") !== 1) return;
11041
11042
  V.sessionId = "";
11042
11043
  const { post_call_process_time: r } = V.agentInfo, i = r || 0;
11043
11044
  if (V.autoStateTimer && (clearTimeout(V.autoStateTimer), V.autoStateTimer = null), U.updateCustomerInfo(void 0), i > 0) {
@@ -33093,7 +33094,7 @@ const Vf = new YN(), eD = (t, e) => Vf.on(t, e), tD = (t) => Vf.onAll(t), WN = {
33093
33094
  空闲: 1,
33094
33095
  离线: 0,
33095
33096
  未注册: 4
33096
- }, XN = av(() => import("./ConsultModel-8visKIPm.mjs")), $N = av(() => import("./TransferModel-DXSOz23k.mjs"));
33097
+ }, XN = av(() => import("./ConsultModel-Bx8la95A.mjs")), $N = av(() => import("./TransferModel-ZcSoEwCg.mjs"));
33097
33098
  tn.div`
33098
33099
  width: 25px;
33099
33100
  height: 25px;
@@ -1,4 +1,4 @@
1
- "use strict";const b=require("react"),a=require("./index-BffC-kL-.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-B2ssxfsE.js");function st(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const s=st(b),it=new a.Keyframe("antFadeIn",{"0%":{opacity:0},"100%":{opacity:1}}),ct=new a.Keyframe("antFadeOut",{"0%":{opacity:1},"100%":{opacity:0}}),dt=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const{antCls:o}=e,n=`${o}-fade`,r=t?"&":"";return[a.initMotion(n,it,ct,e.motionDurationMid,t),{[`
2
2
  ${r}${n}-enter,
3
3
  ${r}${n}-appear
4
4
  `]:{opacity:0,animationTimingFunction:"linear"},[`${r}${n}-leave`]:{animationTimingFunction:"linear"}}]},ut=e=>{const{paddingXXS:t,lineWidth:o,tagPaddingHorizontal:n,componentCls:r,calc:l}=e,i=l(n).sub(o).equal(),u=l(t).sub(o).equal();return{[r]:Object.assign(Object.assign({},a.resetComponent(e)),{display:"inline-block",height:"auto",marginInlineEnd:e.marginXS,paddingInline:i,fontSize:e.tagFontSize,lineHeight:e.tagLineHeight,whiteSpace:"nowrap",background:e.defaultBg,border:`${a.unit(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,opacity:1,transition:`all ${e.motionDurationMid}`,textAlign:"start",position:"relative",[`&${r}-rtl`]:{direction:"rtl"},"&, a, a:hover":{color:e.defaultColor},[`${r}-close-icon`]:{marginInlineStart:u,fontSize:e.tagIconSize,color:e.colorTextDescription,cursor:"pointer",transition:`all ${e.motionDurationMid}`,"&:hover":{color:e.colorTextHeading}},[`&${r}-has-color`]:{borderColor:"transparent",[`&, a, a:hover, ${e.iconCls}-close, ${e.iconCls}-close:hover`]:{color:e.colorTextLightSolid}},"&-checkable":{backgroundColor:"transparent",borderColor:"transparent",cursor:"pointer",[`&:not(${r}-checkable-checked):hover`]:{color:e.colorPrimary,backgroundColor:e.colorFillSecondary},"&:active, &-checked":{color:e.colorTextLightSolid},"&-checked":{backgroundColor:e.colorPrimary,"&:hover":{backgroundColor:e.colorPrimaryHover}},"&:active":{backgroundColor:e.colorPrimaryActive}},"&-hidden":{display:"none"},[`> ${e.iconCls} + span, > span + ${e.iconCls}`]:{marginInlineStart:i}}),[`${r}-borderless`]:{borderColor:"transparent",background:e.tagBorderlessBg}}},Ce=e=>{const{lineWidth:t,fontSizeIcon:o,calc:n}=e,r=e.fontSizeSM;return a.merge(e,{tagFontSize:r,tagLineHeight:a.unit(n(e.lineHeightSM).mul(r).equal()),tagIconSize:n(o).sub(n(t).mul(2)).equal(),tagPaddingHorizontal:8,tagBorderlessBg:e.defaultBg})},pe=e=>({defaultBg:new a.FastColor(e.colorFillQuaternary).onBackground(e.colorBgContainer).toHexString(),defaultColor:e.colorText}),Re=a.genStyleHooks("Tag",e=>{const t=Ce(e);return ut(t)},pe);function oe(e){if(e)return{closable:e.closable,closeIcon:e.closeIcon}}function $e(e){const{closable:t,closeIcon:o}=e||{};return b.useMemo(()=>{if(!t&&(t===!1||o===!1||o===null))return!1;if(t===void 0&&o===void 0)return null;let n={closeIcon:typeof o!="boolean"&&o!==null?o:void 0};return t&&typeof t=="object"&&(n=Object.assign(Object.assign({},n),t)),n},[t,o])}function xe(){const e={};for(var t=arguments.length,o=new Array(t),n=0;n<t;n++)o[n]=arguments[n];return o.forEach(r=>{r&&Object.keys(r).forEach(l=>{r[l]!==void 0&&(e[l]=r[l])})}),e}const mt={};function Be(e,t){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mt;const n=$e(e),r=$e(t),l=typeof n!="boolean"?!!(n!=null&&n.disabled):!1,i=b.useMemo(()=>Object.assign({closeIcon:b.createElement(a.RefIcon,null)},o),[o]),u=b.useMemo(()=>n===!1?!1:n?xe(i,r,n):r===!1?!1:r?xe(i,r):i.closable?i:!1,[n,r,i]);return b.useMemo(()=>{if(u===!1)return[!1,null,l];const{closeIconRender:c}=i,{closeIcon:g}=u;let d=g;if(d!=null){c&&(d=c(g));const m=a.pickAttrs(u,!0);Object.keys(m).length&&(d=b.isValidElement(d)?b.cloneElement(d,m):b.createElement("span",Object.assign({},m),d))}return[!0,d,l]},[u,i])}var ft=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]]);return o};const gt=s.forwardRef((e,t)=>{const{prefixCls:o,style:n,className:r,checked:l,onChange:i,onClick:u}=e,c=ft(e,["prefixCls","style","className","checked","onChange","onClick"]),{getPrefixCls:g,tag:d}=s.useContext(a.ConfigContext),m=y=>{i==null||i(!l),u==null||u(y)},f=g("tag",o),[v,x,C]=Re(f),p=a.classNames(f,`${f}-checkable`,{[`${f}-checkable-checked`]:l},d==null?void 0:d.className,r,x,C);return v(s.createElement("span",Object.assign({},c,{ref:t,style:Object.assign(Object.assign({},n),d==null?void 0:d.style),className:p,onClick:m})))}),Ct=e=>a.genPresetColor(e,(t,o)=>{let{textColor:n,lightBorderColor:r,lightColor:l,darkColor:i}=o;return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:n,background:l,borderColor:r,"&-inverse":{color:e.colorTextLightSolid,background:i,borderColor:i},[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}}),pt=a.genSubStyleComponent(["Tag","preset"],e=>{const t=Ce(e);return Ct(t)},pe);function bt(e){return typeof e!="string"?e:e.charAt(0).toUpperCase()+e.slice(1)}const ne=(e,t,o)=>{const n=bt(o);return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:e[`color${o}`],background:e[`color${n}Bg`],borderColor:e[`color${n}Border`],[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}},vt=a.genSubStyleComponent(["Tag","status"],e=>{const t=Ce(e);return[ne(t,"success","Success"),ne(t,"processing","Info"),ne(t,"error","Error"),ne(t,"warning","Warning")]},pe);var ht=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]]);return o};const yt=s.forwardRef((e,t)=>{const{prefixCls:o,className:n,rootClassName:r,style:l,children:i,icon:u,color:c,onClose:g,bordered:d=!0,visible:m}=e,f=ht(e,["prefixCls","className","rootClassName","style","children","icon","color","onClose","bordered","visible"]),{getPrefixCls:v,direction:x,tag:C}=s.useContext(a.ConfigContext),[p,y]=s.useState(!0),h=a.omit(f,["closeIcon","closable"]);process.env.NODE_ENV!=="production"&&a.devUseWarning("Tag").deprecated(!("visible"in e),"visible","visible && <Tag />"),s.useEffect(()=>{m!==void 0&&y(m)},[m]);const S=a.isPresetColor(c),N=a.isPresetStatusColor(c),E=S||N,O=Object.assign(Object.assign({backgroundColor:c&&!E?c:void 0},C==null?void 0:C.style),l),$=v("tag",o),[P,j,H]=Re($),B=a.classNames($,C==null?void 0:C.className,{[`${$}-${c}`]:E,[`${$}-has-color`]:c&&!E,[`${$}-hidden`]:!p,[`${$}-rtl`]:x==="rtl",[`${$}-borderless`]:!d},n,r,j,H),_=I=>{I.stopPropagation(),g==null||g(I),!I.defaultPrevented&&y(!1)},[,V]=Be(oe(e),oe(C),{closable:!1,closeIconRender:I=>{const X=s.createElement("span",{className:`${$}-close-icon`,onClick:_},I);return a.replaceElement(I,X,M=>({onClick:q=>{var R;(R=M==null?void 0:M.onClick)===null||R===void 0||R.call(M,q),_(q)},className:a.classNames(M==null?void 0:M.className,`${$}-close-icon`)}))}}),A=typeof f.onClick=="function"||i&&i.type==="a",z=u||null,W=z?s.createElement(s.Fragment,null,z,i&&s.createElement("span",null,i)):i,L=s.createElement("span",Object.assign({},h,{ref:t,className:B,style:O}),W,V,S&&s.createElement(pt,{key:"preset",prefixCls:$}),N&&s.createElement(vt,{key:"status",prefixCls:$}));return P(A?s.createElement(a.Wave,{component:"Tag"},L):L)}),be=yt;process.env.NODE_ENV!=="production"&&(be.displayName="Tag");be.CheckableTag=gt;function ie(e){return!!(e!=null&&e.then)}const _e=e=>{const{type:t,children:o,prefixCls:n,buttonProps:r,close:l,autoFocus:i,emitEvent:u,isSilent:c,quitOnNullishReturnValue:g,actionFn:d}=e,m=s.useRef(!1),f=s.useRef(null),[v,x]=a.useSafeState(!1),C=function(){l==null||l.apply(void 0,arguments)};s.useEffect(()=>{let h=null;return i&&(h=setTimeout(()=>{var S;(S=f.current)===null||S===void 0||S.focus({preventScroll:!0})})),()=>{h&&clearTimeout(h)}},[]);const p=h=>{ie(h)&&(x(!0),h.then(function(){x(!1,!0),C.apply(void 0,arguments),m.current=!1},S=>{if(x(!1,!0),m.current=!1,!(c!=null&&c()))return Promise.reject(S)}))},y=h=>{if(m.current)return;if(m.current=!0,!d){C();return}let S;if(u){if(S=d(h),g&&!ie(S)){m.current=!1,C(h);return}}else if(d.length)S=d(l),m.current=!1;else if(S=d(),!ie(S)){C();return}p(S)};return s.createElement(a.Button,Object.assign({},a.convertLegacyProps(t),{onClick:y,loading:v,prefixCls:n},r,{ref:f}),o)},ee=b.createContext({}),{Provider:He}=ee,Se=()=>{const{autoFocusButton:e,cancelButtonProps:t,cancelTextLocale:o,isSilent:n,mergedOkCancel:r,rootPrefixCls:l,close:i,onCancel:u,onConfirm:c}=b.useContext(ee);return r?b.createElement(_e,{isSilent:n,actionFn:u,close:function(){i==null||i.apply(void 0,arguments),c==null||c(!1)},autoFocus:e==="cancel",buttonProps:t,prefixCls:`${l}-btn`},o):null},Oe=()=>{const{autoFocusButton:e,close:t,isSilent:o,okButtonProps:n,rootPrefixCls:r,okTextLocale:l,okType:i,onConfirm:u,onOk:c}=b.useContext(ee);return b.createElement(_e,{isSilent:o,type:i||"primary",actionFn:c,close:function(){t==null||t.apply(void 0,arguments),u==null||u(!0)},autoFocus:e==="ok",buttonProps:n,prefixCls:`${r}-btn`},l)};var ze=s.createContext({});function Ne(e,t,o){var n=t;return!n&&o&&(n="".concat(e,"-").concat(o)),n}function Ee(e,t){var o=e["page".concat(t?"Y":"X","Offset")],n="scroll".concat(t?"Top":"Left");if(typeof o!="number"){var r=e.document;o=r.documentElement[n],typeof o!="number"&&(o=r.body[n])}return o}function $t(e){var t=e.getBoundingClientRect(),o={left:t.left,top:t.top},n=e.ownerDocument,r=n.defaultView||n.parentWindow;return o.left+=Ee(r),o.top+=Ee(r,!0),o}const xt=s.memo(function(e){var t=e.children;return t},function(e,t){var o=t.shouldUpdate;return!o});var St={width:0,height:0,overflow:"hidden",outline:"none"},Ot={outline:"none"},ve=b.forwardRef(function(e,t){var o=e.prefixCls,n=e.className,r=e.style,l=e.title,i=e.ariaId,u=e.footer,c=e.closable,g=e.closeIcon,d=e.onClose,m=e.children,f=e.bodyStyle,v=e.bodyProps,x=e.modalRender,C=e.onMouseDown,p=e.onMouseUp,y=e.holderRef,h=e.visible,S=e.forceRender,N=e.width,E=e.height,O=e.classNames,$=e.styles,P=b.useContext(ze),j=P.panel,H=a.useComposeRef(y,j),B=b.useRef(),_=b.useRef();b.useImperativeHandle(t,function(){return{focus:function(){var R;(R=B.current)===null||R===void 0||R.focus({preventScroll:!0})},changeActive:function(R){var Y=document,G=Y.activeElement;R&&G===_.current?B.current.focus({preventScroll:!0}):!R&&G===B.current&&_.current.focus({preventScroll:!0})}}});var V={};N!==void 0&&(V.width=N),E!==void 0&&(V.height=E);var A=u?b.createElement("div",{className:a.classNames("".concat(o,"-footer"),O==null?void 0:O.footer),style:a._objectSpread2({},$==null?void 0:$.footer)},u):null,z=l?b.createElement("div",{className:a.classNames("".concat(o,"-header"),O==null?void 0:O.header),style:a._objectSpread2({},$==null?void 0:$.header)},b.createElement("div",{className:"".concat(o,"-title"),id:i},l)):null,W=b.useMemo(function(){return a._typeof(c)==="object"&&c!==null?c:c?{closeIcon:g??b.createElement("span",{className:"".concat(o,"-close-x")})}:{}},[c,g,o]),L=a.pickAttrs(W,!0),I=a._typeof(c)==="object"&&c.disabled,X=c?b.createElement("button",a._extends({type:"button",onClick:d,"aria-label":"Close"},L,{className:"".concat(o,"-close"),disabled:I}),W.closeIcon):null,M=b.createElement("div",{className:a.classNames("".concat(o,"-content"),O==null?void 0:O.content),style:$==null?void 0:$.content},X,z,b.createElement("div",a._extends({className:a.classNames("".concat(o,"-body"),O==null?void 0:O.body),style:a._objectSpread2(a._objectSpread2({},f),$==null?void 0:$.body)},v),m),A);return b.createElement("div",{key:"dialog-element",role:"dialog","aria-labelledby":l?i:null,"aria-modal":"true",ref:H,style:a._objectSpread2(a._objectSpread2({},r),V),className:a.classNames(o,n),onMouseDown:C,onMouseUp:p},b.createElement("div",{ref:B,tabIndex:0,style:Ot},b.createElement(xt,{shouldUpdate:h||S},x?x(M):M)),b.createElement("div",{tabIndex:0,ref:_,style:St}))});process.env.NODE_ENV!=="production"&&(ve.displayName="Panel");var Ae=s.forwardRef(function(e,t){var o=e.prefixCls,n=e.title,r=e.style,l=e.className,i=e.visible,u=e.forceRender,c=e.destroyOnClose,g=e.motionName,d=e.ariaId,m=e.onVisibleChanged,f=e.mousePosition,v=b.useRef(),x=s.useState(),C=a._slicedToArray(x,2),p=C[0],y=C[1],h={};p&&(h.transformOrigin=p);function S(){var N=$t(v.current);y(f&&(f.x||f.y)?"".concat(f.x-N.left,"px ").concat(f.y-N.top,"px"):"")}return s.createElement(a.CSSMotion,{visible:i,onVisibleChanged:m,onAppearPrepare:S,onEnterPrepare:S,forceRender:u,motionName:g,removeOnLeave:c,ref:v},function(N,E){var O=N.className,$=N.style;return s.createElement(ve,a._extends({},e,{ref:t,title:n,ariaId:d,prefixCls:o,holderRef:E,style:a._objectSpread2(a._objectSpread2(a._objectSpread2({},$),r),h),className:a.classNames(l,O)}))})});Ae.displayName="Content";var Nt=function(t){var o=t.prefixCls,n=t.style,r=t.visible,l=t.maskProps,i=t.motionName,u=t.className;return s.createElement(a.CSSMotion,{key:"mask",visible:r,motionName:i,leavedClassName:"".concat(o,"-mask-hidden")},function(c,g){var d=c.className,m=c.style;return s.createElement("div",a._extends({ref:g,style:a._objectSpread2(a._objectSpread2({},m),n),className:a.classNames("".concat(o,"-mask"),d,u)},l))})},Et=function(t){var o=t.prefixCls,n=o===void 0?"rc-dialog":o,r=t.zIndex,l=t.visible,i=l===void 0?!1:l,u=t.keyboard,c=u===void 0?!0:u,g=t.focusTriggerAfterClose,d=g===void 0?!0:g,m=t.wrapStyle,f=t.wrapClassName,v=t.wrapProps,x=t.onClose,C=t.afterOpenChange,p=t.afterClose,y=t.transitionName,h=t.animation,S=t.closable,N=S===void 0?!0:S,E=t.mask,O=E===void 0?!0:E,$=t.maskTransitionName,P=t.maskAnimation,j=t.maskClosable,H=j===void 0?!0:j,B=t.maskStyle,_=t.maskProps,V=t.rootClassName,A=t.classNames,z=t.styles;process.env.NODE_ENV!=="production"&&(["wrapStyle","bodyStyle","maskStyle"].forEach(function(w){a.warning(!(w in t),"".concat(w," is deprecated, please use styles instead."))}),"wrapClassName"in t&&a.warning(!1,"wrapClassName is deprecated, please use classNames instead."));var W=b.useRef(),L=b.useRef(),I=b.useRef(),X=s.useState(i),M=a._slicedToArray(X,2),q=M[0],R=M[1],Y=a.useId();function G(){a.contains(L.current,document.activeElement)||(W.current=document.activeElement)}function le(){if(!a.contains(L.current,document.activeElement)){var w;(w=I.current)===null||w===void 0||w.focus()}}function k(w){if(w)le();else{if(R(!1),O&&W.current&&d){try{W.current.focus({preventScroll:!0})}catch{}W.current=null}q&&(p==null||p())}C==null||C(w)}function T(w){x==null||x(w)}var D=b.useRef(!1),J=b.useRef(),ot=function(){clearTimeout(J.current),D.current=!0},at=function(){J.current=setTimeout(function(){D.current=!1})},ye=null;H&&(ye=function(se){D.current?D.current=!1:L.current===se.target&&T(se)});function rt(w){if(c&&w.keyCode===a.KeyCode.ESC){w.stopPropagation(),T(w);return}i&&w.keyCode===a.KeyCode.TAB&&I.current.changeActive(!w.shiftKey)}b.useEffect(function(){i&&(R(!0),G())},[i]),b.useEffect(function(){return function(){clearTimeout(J.current)}},[]);var lt=a._objectSpread2(a._objectSpread2(a._objectSpread2({zIndex:r},m),z==null?void 0:z.wrapper),{},{display:q?null:"none"});return s.createElement("div",a._extends({className:a.classNames("".concat(n,"-root"),V)},a.pickAttrs(t,{data:!0})),s.createElement(Nt,{prefixCls:n,visible:O&&i,motionName:Ne(n,$,P),style:a._objectSpread2(a._objectSpread2({zIndex:r},B),z==null?void 0:z.mask),maskProps:_,className:A==null?void 0:A.mask}),s.createElement("div",a._extends({tabIndex:-1,onKeyDown:rt,className:a.classNames("".concat(n,"-wrap"),f,A==null?void 0:A.wrapper),ref:L,onClick:ye,style:lt},v),s.createElement(Ae,a._extends({},t,{onMouseDown:ot,onMouseUp:at,ref:I,closable:N,ariaId:Y,prefixCls:n,visible:i&&q,onClose:T,onVisibleChanged:k,motionName:Ne(n,y,h)}))))},Le=function(t){var o=t.visible,n=t.getContainer,r=t.forceRender,l=t.destroyOnClose,i=l===void 0?!1:l,u=t.afterClose,c=t.panelRef,g=s.useState(o),d=a._slicedToArray(g,2),m=d[0],f=d[1],v=s.useMemo(function(){return{panel:c}},[c]);return s.useEffect(function(){o&&f(!0)},[o]),!r&&i&&!m?null:s.createElement(ze.Provider,{value:v},s.createElement(a.Portal,{open:o||r||m,autoDestroy:!1,getContainer:n,autoLock:o||m},s.createElement(Et,a._extends({},t,{destroyOnClose:i,afterClose:function(){u==null||u(),f(!1)}}))))};Le.displayName="Dialog";const wt=()=>a.canUseDom()&&window.document.documentElement,ae=e=>{const{prefixCls:t,className:o,style:n,size:r,shape:l}=e,i=a.classNames({[`${t}-lg`]:r==="large",[`${t}-sm`]:r==="small"}),u=a.classNames({[`${t}-circle`]:l==="circle",[`${t}-square`]:l==="square",[`${t}-round`]:l==="round"}),c=s.useMemo(()=>typeof r=="number"?{width:r,height:r,lineHeight:`${r}px`}:{},[r]);return s.createElement("span",{className:a.classNames(t,i,u,o),style:Object.assign(Object.assign({},c),n)})},jt=new a.Keyframe("ant-skeleton-loading",{"0%":{backgroundPosition:"100% 50%"},"100%":{backgroundPosition:"0 50%"}}),re=e=>({height:e,lineHeight:a.unit(e)}),Q=e=>Object.assign({width:e},re(e)),Pt=e=>({background:e.skeletonLoadingBackground,backgroundSize:"400% 100%",animationName:jt,animationDuration:e.skeletonLoadingMotionDuration,animationTimingFunction:"ease",animationIterationCount:"infinite"}),ce=(e,t)=>Object.assign({width:t(e).mul(5).equal(),minWidth:t(e).mul(5).equal()},re(e)),It=e=>{const{skeletonAvatarCls:t,gradientFromColor:o,controlHeight:n,controlHeightLG:r,controlHeightSM:l}=e;return{[t]:Object.assign({display:"inline-block",verticalAlign:"top",background:o},Q(n)),[`${t}${t}-circle`]:{borderRadius:"50%"},[`${t}${t}-lg`]:Object.assign({},Q(r)),[`${t}${t}-sm`]:Object.assign({},Q(l))}},Tt=e=>{const{controlHeight:t,borderRadiusSM:o,skeletonInputCls:n,controlHeightLG:r,controlHeightSM:l,gradientFromColor:i,calc:u}=e;return{[n]:Object.assign({display:"inline-block",verticalAlign:"top",background:i,borderRadius:o},ce(t,u)),[`${n}-lg`]:Object.assign({},ce(r,u)),[`${n}-sm`]:Object.assign({},ce(l,u))}},we=e=>Object.assign({width:e},re(e)),Mt=e=>{const{skeletonImageCls:t,imageSizeBase:o,gradientFromColor:n,borderRadiusSM:r,calc:l}=e;return{[t]:Object.assign(Object.assign({display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",background:n,borderRadius:r},we(l(o).mul(2).equal())),{[`${t}-path`]:{fill:"#bfbfbf"},[`${t}-svg`]:Object.assign(Object.assign({},we(o)),{maxWidth:l(o).mul(4).equal(),maxHeight:l(o).mul(4).equal()}),[`${t}-svg${t}-svg-circle`]:{borderRadius:"50%"}}),[`${t}${t}-circle`]:{borderRadius:"50%"}}},de=(e,t,o)=>{const{skeletonButtonCls:n}=e;return{[`${o}${n}-circle`]:{width:t,minWidth:t,borderRadius:"50%"},[`${o}${n}-round`]:{borderRadius:t}}},ue=(e,t)=>Object.assign({width:t(e).mul(2).equal(),minWidth:t(e).mul(2).equal()},re(e)),Rt=e=>{const{borderRadiusSM:t,skeletonButtonCls:o,controlHeight:n,controlHeightLG:r,controlHeightSM:l,gradientFromColor:i,calc:u}=e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({[o]:Object.assign({display:"inline-block",verticalAlign:"top",background:i,borderRadius:t,width:u(n).mul(2).equal(),minWidth:u(n).mul(2).equal()},ue(n,u))},de(e,n,o)),{[`${o}-lg`]:Object.assign({},ue(r,u))}),de(e,r,`${o}-lg`)),{[`${o}-sm`]:Object.assign({},ue(l,u))}),de(e,l,`${o}-sm`))},Bt=e=>{const{componentCls:t,skeletonAvatarCls:o,skeletonTitleCls:n,skeletonParagraphCls:r,skeletonButtonCls:l,skeletonInputCls:i,skeletonImageCls:u,controlHeight:c,controlHeightLG:g,controlHeightSM:d,gradientFromColor:m,padding:f,marginSM:v,borderRadius:x,titleHeight:C,blockRadius:p,paragraphLiHeight:y,controlHeightXS:h,paragraphMarginTop:S}=e;return{[t]:{display:"table",width:"100%",[`${t}-header`]:{display:"table-cell",paddingInlineEnd:f,verticalAlign:"top",[o]:Object.assign({display:"inline-block",verticalAlign:"top",background:m},Q(c)),[`${o}-circle`]:{borderRadius:"50%"},[`${o}-lg`]:Object.assign({},Q(g)),[`${o}-sm`]:Object.assign({},Q(d))},[`${t}-content`]:{display:"table-cell",width:"100%",verticalAlign:"top",[n]:{width:"100%",height:C,background:m,borderRadius:p,[`+ ${r}`]:{marginBlockStart:d}},[r]:{padding:0,"> li":{width:"100%",height:y,listStyle:"none",background:m,borderRadius:p,"+ li":{marginBlockStart:h}}},[`${r}> li:last-child:not(:first-child):not(:nth-child(2))`]:{width:"61%"}},[`&-round ${t}-content`]:{[`${n}, ${r} > li`]:{borderRadius:x}}},[`${t}-with-avatar ${t}-content`]:{[n]:{marginBlockStart:v,[`+ ${r}`]:{marginBlockStart:S}}},[`${t}${t}-element`]:Object.assign(Object.assign(Object.assign(Object.assign({display:"inline-block",width:"auto"},Rt(e)),It(e)),Tt(e)),Mt(e)),[`${t}${t}-block`]:{width:"100%",[l]:{width:"100%"},[i]:{width:"100%"}},[`${t}${t}-active`]:{[`
@@ -1,6 +1,6 @@
1
1
  import * as r from "react";
2
2
  import $, { useContext as re, useRef as Z, useMemo as Lt, useEffect as De } from "react";
3
- import { i as Dt, K as Ne, g as se, F as kt, m as fe, u as N, r as nt, b as Pe, p as je, C as q, c as O, d as Ie, e as At, o as ge, f as Ce, h as _t, k as Vt, l as Wt, W as qt, n as Gt, B as Te, q as ot, s as Xt, _ as R, t as ke, v as Y, w as Me, x as at, y as Ae, z as Ut, A as _e, D as Ve, P as Kt, G as Qt, H as K, J as Zt, L as Yt, N as Re, O as Jt, Q as lt, T as en, U as tn, V as rt, X as nn, Z as on, $ as an, a0 as ue, a1 as ln, a2 as st, a3 as rn, a4 as sn, a5 as cn, a6 as dn, a7 as un, a8 as mn, a9 as fn, aa as gn, ab as Cn, ac as it, ad as pn, ae as vn } from "./index-BPoDHym7.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-DLugzJjU.mjs";
4
4
  const bn = new Ne("antFadeIn", {
5
5
  "0%": {
6
6
  opacity: 0
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-BffC-kL-.js");exports.YsytAgentLogout=e.agentLogout;exports.YsytCallForceInsert=e.callForceInsert;exports.YsytCallForceSplit=e.callForceSplit;exports.YsytGetCustomerInfo=e.getCustomerInfo;exports.YsytListenCall=e.listenCall;exports.YsytMakeCall=e.makeCall;exports.YsytPreviewMakeCall=e.previewMakeCall;exports.YsytSetAgentDevice=e.setAgentDevice;exports.YsytSetAgentInitState=e.setAgentInitState;exports.YsytStartEarSpeak=e.startEarSpeak;exports.YsytStopEarSpeak=e.stopEarSpeak;exports.default=e.YsytBarPhone;exports.subscribeAllEvents=e.subscribeAllEvents;exports.subscribeEvent=e.subscribeEvent;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-B2ssxfsE.js");exports.YsytAgentLogout=e.agentLogout;exports.YsytCallForceInsert=e.callForceInsert;exports.YsytCallForceSplit=e.callForceSplit;exports.YsytGetCustomerInfo=e.getCustomerInfo;exports.YsytListenCall=e.listenCall;exports.YsytMakeCall=e.makeCall;exports.YsytPreviewMakeCall=e.previewMakeCall;exports.YsytSetAgentDevice=e.setAgentDevice;exports.YsytSetAgentInitState=e.setAgentInitState;exports.YsytStartEarSpeak=e.startEarSpeak;exports.YsytStopEarSpeak=e.stopEarSpeak;exports.default=e.YsytBarPhone;exports.subscribeAllEvents=e.subscribeAllEvents;exports.subscribeEvent=e.subscribeEvent;
@@ -1,4 +1,4 @@
1
- import { ak as t, ap as e, aq as l, ah as r, am as y, ag as Y, al as n, aj as o, ai as i, an as S, ao as p, af as C, as as c, ar as g } from "./index-BPoDHym7.mjs";
1
+ import { ak as t, ap as e, aq as l, ah as r, am as y, ag as Y, al as n, aj as o, ai as i, an as S, ao as p, af as C, as as c, ar as g } from "./index-DLugzJjU.mjs";
2
2
  export {
3
3
  t as YsytAgentLogout,
4
4
  e as YsytCallForceInsert,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ysyt-react-agent-lib",
3
- "version": "1.2.44",
3
+ "version": "1.2.46",
4
4
  "description": "",
5
5
  "main": "dist/ysyt-react-agent-lib.cjs.js",
6
6
  "module": "dist/ysyt-react-agent-lib.es.js",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "antd": "5.24.0",
31
31
  "styled-components": "^6.1.13",
32
- "ysyt-agent-sdk": "2.0.54"
32
+ "ysyt-agent-sdk": "2.0.56"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.2.0",