joytalk 0.0.23 → 0.0.24

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.
@@ -24,3 +24,4 @@ export declare const fetchFaqList: (params: {
24
24
  }) => Promise<RequestResponse<FaqListResponse>>;
25
25
  export declare const fetchUserInfo: () => Promise<RequestResponse<UserInfo>>;
26
26
  export declare const fetchHistoryMessages: (params: HistoryMessagesParams) => Promise<RequestResponse<HistoryMessagesResponse>>;
27
+ export declare const fetchAnonymousLogin: (params: any) => Promise<RequestResponse<any>>;
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function ot(e,t){return function(){return e.apply(t,arguments)}}const{toString:Dt}=Object.prototype,{getPrototypeOf:De}=Object,{iterator:Ee,toStringTag:it}=Symbol,Se=(e=>t=>{const n=Dt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>Se(t)===e),Te=e=>t=>typeof t===e,{isArray:Q}=Array,Y=Te("undefined");function ne(e){return e!==null&&!Y(e)&&e.constructor!==null&&!Y(e.constructor)&&_(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const at=P("ArrayBuffer");function It(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&at(e.buffer),t}const Lt=Te("string"),_=Te("function"),ct=Te("number"),re=e=>e!==null&&typeof e=="object",Ft=e=>e===!0||e===!1,ue=e=>{if(Se(e)!=="object")return!1;const t=De(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(it in e)&&!(Ee in e)},Pt=e=>{if(!re(e)||ne(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xt=P("Date"),Bt=P("File"),kt=P("Blob"),Ht=P("FileList"),jt=e=>re(e)&&_(e.pipe),vt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_(e.append)&&((t=Se(e))==="formdata"||t==="object"&&_(e.toString)&&e.toString()==="[object FormData]"))},Mt=P("URLSearchParams"),[qt,$t,Gt,zt]=["ReadableStream","Request","Response","Headers"].map(P),Jt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function se(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),Q(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(ne(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function lt(e,t){if(ne(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const G=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ut=e=>!Y(e)&&e!==G;function Ce(){const{caseless:e,skipUndefined:t}=ut(this)&&this||{},n={},r=(s,o)=>{const i=e&&lt(n,o)||o;ue(n[i])&&ue(s)?n[i]=Ce(n[i],s):ue(s)?n[i]=Ce({},s):Q(s)?n[i]=s.slice():(!t||!Y(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&se(arguments[s],r);return n}const Wt=(e,t,n,{allOwnKeys:r}={})=>(se(t,(s,o)=>{n&&_(s)?e[o]=ot(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&De(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(Q(e))return e;let t=e.length;if(!ct(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&De(Uint8Array)),en=(e,t)=>{const r=(e&&e[Ee]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},tn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},nn=P("HTMLFormElement"),rn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Me=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),sn=P("RegExp"),ft=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};se(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},on=e=>{ft(e,(t,n)=>{if(_(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(_(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},an=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Q(e)?r(e):r(String(e).split(t)),n},cn=()=>{},ln=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function un(e){return!!(e&&_(e.append)&&e[it]==="FormData"&&e[Ee])}const fn=e=>{const t=new Array(10),n=(r,s)=>{if(re(r)){if(t.indexOf(r)>=0)return;if(ne(r))return r;if(!("toJSON"in r)){t[s]=r;const o=Q(r)?[]:{};return se(r,(i,c)=>{const d=n(i,s+1);!Y(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)},dn=P("AsyncFunction"),hn=e=>e&&(re(e)||_(e))&&_(e.then)&&_(e.catch),dt=((e,t)=>e?setImmediate:t?((n,r)=>(G.addEventListener("message",({source:s,data:o})=>{s===G&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),G.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",_(G.postMessage)),pn=typeof queueMicrotask<"u"?queueMicrotask.bind(G):typeof process<"u"&&process.nextTick||dt,mn=e=>e!=null&&_(e[Ee]),a={isArray:Q,isArrayBuffer:at,isBuffer:ne,isFormData:vt,isArrayBufferView:It,isString:Lt,isNumber:ct,isBoolean:Ft,isObject:re,isPlainObject:ue,isEmptyObject:Pt,isReadableStream:qt,isRequest:$t,isResponse:Gt,isHeaders:zt,isUndefined:Y,isDate:xt,isFile:Bt,isBlob:kt,isRegExp:sn,isFunction:_,isStream:jt,isURLSearchParams:Mt,isTypedArray:Zt,isFileList:Ht,forEach:se,merge:Ce,extend:Wt,trim:Jt,stripBOM:Vt,inherits:Kt,toFlatObject:Xt,kindOf:Se,kindOfTest:P,endsWith:Yt,toArray:Qt,forEachEntry:en,matchAll:tn,isHTMLForm:nn,hasOwnProperty:Me,hasOwnProp:Me,reduceDescriptors:ft,freezeMethods:on,toObjectSet:an,toCamelCase:rn,noop:cn,toFiniteNumber:ln,findKey:lt,global:G,isContextDefined:ut,isSpecCompliantForm:un,toJSONObject:fn,isAsyncFn:dn,isThenable:hn,setImmediate:dt,asap:pn,isIterable:mn};function E(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(E,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const ht=E.prototype,pt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{pt[e]={value:e}});Object.defineProperties(E,pt);Object.defineProperty(ht,"isAxiosError",{value:!0});E.from=(e,t,n,r,s,o)=>{const i=Object.create(ht);a.toFlatObject(e,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return E.call(i,c,d,n,r,s),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",o&&Object.assign(i,o),i};const En=null;function ge(e){return a.isPlainObject(e)||a.isArray(e)}function mt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function qe(e,t,n){return e?e.concat(t).map(function(s,o){return s=mt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Sn(e){return a.isArray(e)&&!e.some(ge)}const Tn=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function we(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!a.isUndefined(p[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!d&&a.isBlob(f))throw new E("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,m,p){let w=f;if(f&&!p&&typeof f=="object"){if(a.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Sn(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(w=a.toArray(f)))return m=mt(m),w.forEach(function(R,U){!(a.isUndefined(R)||R===null)&&t.append(i===!0?qe([m],U,o):i===null?m:m+"[]",u(R))}),!1}return ge(f)?!0:(t.append(qe(p,m,o),u(f)),!1)}const h=[],S=Object.assign(Tn,{defaultVisitor:l,convertValue:u,isVisitable:ge});function b(f,m){if(!a.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));h.push(f),a.forEach(f,function(w,I){(!(a.isUndefined(w)||w===null)&&s.call(t,w,a.isString(I)?I.trim():I,m,S))===!0&&b(w,m?m.concat(I):[I])}),h.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return b(e),t}function $e(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ie(e,t){this._pairs=[],e&&we(e,this,t)}const Et=Ie.prototype;Et.append=function(t,n){this._pairs.push([t,n])};Et.toString=function(t){const n=t?function(r){return t.call(this,r,$e)}:$e;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function wn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function St(e,t,n){if(!t)return e;const r=n&&n.encode||wn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new Ie(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Ge{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Rn=typeof URLSearchParams<"u"?URLSearchParams:Ie,yn=typeof FormData<"u"?FormData:null,An=typeof Blob<"u"?Blob:null,bn={isBrowser:!0,classes:{URLSearchParams:Rn,FormData:yn,Blob:An},protocols:["http","https","file","blob","url","data"]},Le=typeof window<"u"&&typeof document<"u",Ue=typeof navigator=="object"&&navigator||void 0,Nn=Le&&(!Ue||["ReactNative","NativeScript","NS"].indexOf(Ue.product)<0),On=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Cn=Le&&window.location.href||"http://localhost",gn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Le,hasStandardBrowserEnv:Nn,hasStandardBrowserWebWorkerEnv:On,navigator:Ue,origin:Cn},Symbol.toStringTag,{value:"Module"})),C={...gn,...bn};function Un(e,t){return we(e,new C.classes.URLSearchParams,{visitor:function(n,r,s,o){return C.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function _n(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Dn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function wt(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Dn(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(_n(r),s,n,0)}),n}return null}function In(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:Tt,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(wt(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Un(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return we(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),In(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?E.from(c,E.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{oe.headers[e]={}});const Ln=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Fn=e=>{const t={};let n,r,s;return e&&e.split(`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function ot(e,t){return function(){return e.apply(t,arguments)}}const{toString:Dt}=Object.prototype,{getPrototypeOf:De}=Object,{iterator:Ee,toStringTag:it}=Symbol,Se=(e=>t=>{const n=Dt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),x=e=>(e=e.toLowerCase(),t=>Se(t)===e),Te=e=>t=>typeof t===e,{isArray:Q}=Array,Y=Te("undefined");function ne(e){return e!==null&&!Y(e)&&e.constructor!==null&&!Y(e.constructor)&&_(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const at=x("ArrayBuffer");function It(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&at(e.buffer),t}const Lt=Te("string"),_=Te("function"),ct=Te("number"),re=e=>e!==null&&typeof e=="object",Ft=e=>e===!0||e===!1,ue=e=>{if(Se(e)!=="object")return!1;const t=De(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(it in e)&&!(Ee in e)},Pt=e=>{if(!re(e)||ne(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xt=x("Date"),Bt=x("File"),kt=x("Blob"),Ht=x("FileList"),vt=e=>re(e)&&_(e.pipe),jt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_(e.append)&&((t=Se(e))==="formdata"||t==="object"&&_(e.toString)&&e.toString()==="[object FormData]"))},Mt=x("URLSearchParams"),[$t,qt,Gt,zt]=["ReadableStream","Request","Response","Headers"].map(x),Jt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function se(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),Q(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(ne(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function lt(e,t){if(ne(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const G=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ut=e=>!Y(e)&&e!==G;function Ce(){const{caseless:e,skipUndefined:t}=ut(this)&&this||{},n={},r=(s,o)=>{const i=e&&lt(n,o)||o;ue(n[i])&&ue(s)?n[i]=Ce(n[i],s):ue(s)?n[i]=Ce({},s):Q(s)?n[i]=s.slice():(!t||!Y(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&se(arguments[s],r);return n}const Wt=(e,t,n,{allOwnKeys:r}={})=>(se(t,(s,o)=>{n&&_(s)?e[o]=ot(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&De(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(Q(e))return e;let t=e.length;if(!ct(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&De(Uint8Array)),en=(e,t)=>{const r=(e&&e[Ee]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},tn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},nn=x("HTMLFormElement"),rn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Me=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),sn=x("RegExp"),ft=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};se(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},on=e=>{ft(e,(t,n)=>{if(_(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(_(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},an=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Q(e)?r(e):r(String(e).split(t)),n},cn=()=>{},ln=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function un(e){return!!(e&&_(e.append)&&e[it]==="FormData"&&e[Ee])}const fn=e=>{const t=new Array(10),n=(r,s)=>{if(re(r)){if(t.indexOf(r)>=0)return;if(ne(r))return r;if(!("toJSON"in r)){t[s]=r;const o=Q(r)?[]:{};return se(r,(i,c)=>{const d=n(i,s+1);!Y(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)},dn=x("AsyncFunction"),hn=e=>e&&(re(e)||_(e))&&_(e.then)&&_(e.catch),dt=((e,t)=>e?setImmediate:t?((n,r)=>(G.addEventListener("message",({source:s,data:o})=>{s===G&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),G.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",_(G.postMessage)),pn=typeof queueMicrotask<"u"?queueMicrotask.bind(G):typeof process<"u"&&process.nextTick||dt,mn=e=>e!=null&&_(e[Ee]),a={isArray:Q,isArrayBuffer:at,isBuffer:ne,isFormData:jt,isArrayBufferView:It,isString:Lt,isNumber:ct,isBoolean:Ft,isObject:re,isPlainObject:ue,isEmptyObject:Pt,isReadableStream:$t,isRequest:qt,isResponse:Gt,isHeaders:zt,isUndefined:Y,isDate:xt,isFile:Bt,isBlob:kt,isRegExp:sn,isFunction:_,isStream:vt,isURLSearchParams:Mt,isTypedArray:Zt,isFileList:Ht,forEach:se,merge:Ce,extend:Wt,trim:Jt,stripBOM:Vt,inherits:Kt,toFlatObject:Xt,kindOf:Se,kindOfTest:x,endsWith:Yt,toArray:Qt,forEachEntry:en,matchAll:tn,isHTMLForm:nn,hasOwnProperty:Me,hasOwnProp:Me,reduceDescriptors:ft,freezeMethods:on,toObjectSet:an,toCamelCase:rn,noop:cn,toFiniteNumber:ln,findKey:lt,global:G,isContextDefined:ut,isSpecCompliantForm:un,toJSONObject:fn,isAsyncFn:dn,isThenable:hn,setImmediate:dt,asap:pn,isIterable:mn};function E(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(E,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const ht=E.prototype,pt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{pt[e]={value:e}});Object.defineProperties(E,pt);Object.defineProperty(ht,"isAxiosError",{value:!0});E.from=(e,t,n,r,s,o)=>{const i=Object.create(ht);a.toFlatObject(e,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return E.call(i,c,d,n,r,s),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",o&&Object.assign(i,o),i};const En=null;function ge(e){return a.isPlainObject(e)||a.isArray(e)}function mt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function $e(e,t,n){return e?e.concat(t).map(function(s,o){return s=mt(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Sn(e){return a.isArray(e)&&!e.some(ge)}const Tn=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function we(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!a.isUndefined(p[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!d&&a.isBlob(f))throw new E("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,m,p){let w=f;if(f&&!p&&typeof f=="object"){if(a.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Sn(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(w=a.toArray(f)))return m=mt(m),w.forEach(function(R,U){!(a.isUndefined(R)||R===null)&&t.append(i===!0?$e([m],U,o):i===null?m:m+"[]",u(R))}),!1}return ge(f)?!0:(t.append($e(p,m,o),u(f)),!1)}const h=[],S=Object.assign(Tn,{defaultVisitor:l,convertValue:u,isVisitable:ge});function b(f,m){if(!a.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));h.push(f),a.forEach(f,function(w,I){(!(a.isUndefined(w)||w===null)&&s.call(t,w,a.isString(I)?I.trim():I,m,S))===!0&&b(w,m?m.concat(I):[I])}),h.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return b(e),t}function qe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ie(e,t){this._pairs=[],e&&we(e,this,t)}const Et=Ie.prototype;Et.append=function(t,n){this._pairs.push([t,n])};Et.toString=function(t){const n=t?function(r){return t.call(this,r,qe)}:qe;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function wn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function St(e,t,n){if(!t)return e;const r=n&&n.encode||wn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new Ie(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Ge{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Rn=typeof URLSearchParams<"u"?URLSearchParams:Ie,yn=typeof FormData<"u"?FormData:null,An=typeof Blob<"u"?Blob:null,bn={isBrowser:!0,classes:{URLSearchParams:Rn,FormData:yn,Blob:An},protocols:["http","https","file","blob","url","data"]},Le=typeof window<"u"&&typeof document<"u",Ue=typeof navigator=="object"&&navigator||void 0,Nn=Le&&(!Ue||["ReactNative","NativeScript","NS"].indexOf(Ue.product)<0),On=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Cn=Le&&window.location.href||"http://localhost",gn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Le,hasStandardBrowserEnv:Nn,hasStandardBrowserWebWorkerEnv:On,navigator:Ue,origin:Cn},Symbol.toStringTag,{value:"Module"})),C={...gn,...bn};function Un(e,t){return we(e,new C.classes.URLSearchParams,{visitor:function(n,r,s,o){return C.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function _n(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Dn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function wt(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Dn(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(_n(r),s,n,0)}),n}return null}function In(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:Tt,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(wt(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Un(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return we(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),In(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?E.from(c,E.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{oe.headers[e]={}});const Ln=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Fn=e=>{const t={};let n,r,s;return e&&e.split(`
2
2
  `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Ln[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ze=Symbol("internals");function te(e){return e&&String(e).trim().toLowerCase()}function fe(e){return e===!1||e==null?e:a.isArray(e)?e.map(fe):String(e)}function Pn(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const xn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function be(e,t,n,r,s){if(a.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function Bn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function kn(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let D=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,u){const l=te(d);if(!l)throw new Error("header name must be a non-empty string");const h=a.findKey(s,l);(!h||s[h]===void 0||u===!0||u===void 0&&s[h]!==!1)&&(s[h||d]=fe(c))}const i=(c,d)=>a.forEach(c,(u,l)=>o(u,l,d));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!xn(t))i(Fn(t),n);else if(a.isObject(t)&&a.isIterable(t)){let c={},d,u;for(const l of t){if(!a.isArray(l))throw TypeError("Object iterator must return a key-value pair");c[u=l[0]]=(d=c[u])?a.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}i(c,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=te(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Pn(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=te(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||be(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=te(i),i){const c=a.findKey(r,i);c&&(!n||be(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||be(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=fe(s),delete n[o];return}const c=t?Bn(o):String(o).trim();c!==o&&delete n[o],n[c]=fe(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ze]=this[ze]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=te(i);r[c]||(kn(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(D.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(D);function Ne(e,t){const n=this||oe,r=t||n,s=D.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function Rt(e){return!!(e&&e.__CANCEL__)}function Z(e,t,n){E.call(this,e??"canceled",E.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(Z,E,{__CANCEL__:!0});function yt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new E("Request failed with status code "+n.status,[E.ERR_BAD_REQUEST,E.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Hn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=r[o];i||(i=u),n[s]=d,r[s]=u;let h=o,S=0;for(;h!==s;)S+=n[h++],h=h%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const b=l&&u-l;return b?Math.round(S*1e3/b):void 0}}function vn(e,t){let n=0,r=1e3/t,s,o;const i=(u,l=Date.now())=>{n=l,s=null,o&&(clearTimeout(o),o=null),e(...u)};return[(...u)=>{const l=Date.now(),h=l-n;h>=r?i(u,l):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-h)))},()=>s&&i(s)]}const he=(e,t,n=3)=>{let r=0;const s=jn(50,250);return vn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),l=i<=c;r=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},n)},Je=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},We=e=>(...t)=>a.asap(()=>e(...t)),Mn=C.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,C.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(C.origin),C.navigator&&/(msie|trident)/i.test(C.navigator.userAgent)):()=>!0,qn=C.hasStandardBrowserEnv?{write(e,t,n,r,s,o,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&c.push(`path=${r}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function $n(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Gn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function At(e,t,n){let r=!$n(t);return e&&(r||n==!1)?Gn(e,t):t}const Ve=e=>e instanceof D?{...e}:e;function W(e,t){t=t||{};const n={};function r(u,l,h,S){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:S},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,h,S){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,h,S)}else return r(u,l,h,S)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,h){if(h in t)return r(u,l);if(h in e)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l,h)=>s(Ve(u),Ve(l),h,!0)};return a.forEach(Object.keys({...e,...t}),function(l){const h=d[l]||s,S=h(e[l],t[l],l);a.isUndefined(S)&&h!==c||(n[l]=S)}),n}const bt=e=>{const t=W({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;if(t.headers=i=D.from(i),t.url=St(At(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(n)){if(C.hasStandardBrowserEnv||C.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,h])=>{u.includes(l.toLowerCase())&&i.set(l,h)})}}if(C.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Mn(t.url))){const d=s&&o&&qn.read(o);d&&i.set(s,d)}return t},zn=typeof XMLHttpRequest<"u",Jn=zn&&function(e){return new Promise(function(n,r){const s=bt(e);let o=s.data;const i=D.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,l,h,S,b,f;function m(){b&&b(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const R=D.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),F={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:R,config:e,request:p};yt(function(L){n(L),m()},function(L){r(L),m()},F),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new E("Request aborted",E.ECONNABORTED,e,p)),p=null)},p.onerror=function(U){const F=U&&U.message?U.message:"Network Error",q=new E(F,E.ERR_NETWORK,e,p);q.event=U||null,r(q),p=null},p.ontimeout=function(){let U=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const F=s.transitional||Tt;s.timeoutErrorMessage&&(U=s.timeoutErrorMessage),r(new E(U,F.clarifyTimeoutError?E.ETIMEDOUT:E.ECONNABORTED,e,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&a.forEach(i.toJSON(),function(U,F){p.setRequestHeader(F,U)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),u&&([S,f]=he(u,!0),p.addEventListener("progress",S)),d&&p.upload&&([h,b]=he(d),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",b)),(s.cancelToken||s.signal)&&(l=R=>{p&&(r(!R||R.type?new Z(null,e,p):R),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const I=Hn(s.url);if(I&&C.protocols.indexOf(I)===-1){r(new E("Unsupported protocol "+I+":",E.ERR_BAD_REQUEST,e));return}p.send(o||null)})},Wn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const l=u instanceof Error?u:this.reason;r.abort(l instanceof E?l:new Z(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,o(new E(`timeout ${t} of ms exceeded`,E.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},Vn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},Kn=async function*(e,t){for await(const n of Xn(e))yield*Vn(n,t)},Xn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Ke=(e,t,n,r)=>{const s=Kn(e,t);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){c(),d.close();return}let h=l.byteLength;if(n){let S=o+=h;n(S)}d.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},Xe=64*1024,{isFunction:le}=a,Yn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:Ye,TextEncoder:Qe}=a.global,Ze=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Qn=e=>{e=a.merge.call({skipUndefined:!0},Yn,e);const{fetch:t,Request:n,Response:r}=e,s=t?le(t):typeof fetch=="function",o=le(n),i=le(r);if(!s)return!1;const c=s&&le(Ye),d=s&&(typeof Qe=="function"?(f=>m=>f.encode(m))(new Qe):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=o&&c&&Ze(()=>{let f=!1;const m=new n(C.origin,{body:new Ye,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),l=i&&c&&Ze(()=>a.isReadableStream(new r("").body)),h={stream:l&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(m,p)=>{let w=m&&m[f];if(w)return w.call(m);throw new E(`Response type '${f}' is not supported`,E.ERR_NOT_SUPPORT,p)})});const S=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new n(C.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await d(f)).byteLength},b=async(f,m)=>{const p=a.toFiniteNumber(f.getContentLength());return p??S(m)};return async f=>{let{url:m,method:p,data:w,signal:I,cancelToken:R,timeout:U,onDownloadProgress:F,onUploadProgress:q,responseType:L,headers:ye,withCredentials:ie="same-origin",fetchOptions:xe}=bt(f),Be=t||fetch;L=L?(L+"").toLowerCase():"text";let ae=Wn([I,R&&R.toAbortSignal()],U),ee=null;const $=ae&&ae.unsubscribe&&(()=>{ae.unsubscribe()});let ke;try{if(q&&u&&p!=="get"&&p!=="head"&&(ke=await b(ye,w))!==0){let v=new n(m,{method:"POST",body:w,duplex:"half"}),K;if(a.isFormData(w)&&(K=v.headers.get("content-type"))&&ye.setContentType(K),v.body){const[Ae,ce]=Je(ke,he(We(q)));w=Ke(v.body,Xe,Ae,ce)}}a.isString(ie)||(ie=ie?"include":"omit");const x=o&&"credentials"in n.prototype,He={...xe,signal:ae,method:p.toUpperCase(),headers:ye.normalize().toJSON(),body:w,duplex:"half",credentials:x?ie:void 0};ee=o&&new n(m,He);let j=await(o?Be(ee,xe):Be(m,He));const je=l&&(L==="stream"||L==="response");if(l&&(F||je&&$)){const v={};["status","statusText","headers"].forEach(ve=>{v[ve]=j[ve]});const K=a.toFiniteNumber(j.headers.get("content-length")),[Ae,ce]=F&&Je(K,he(We(F),!0))||[];j=new r(Ke(j.body,Xe,Ae,()=>{ce&&ce(),$&&$()}),v)}L=L||"text";let _t=await h[a.findKey(h,L)||"text"](j,f);return!je&&$&&$(),await new Promise((v,K)=>{yt(v,K,{data:_t,headers:D.from(j.headers),status:j.status,statusText:j.statusText,config:f,request:ee})})}catch(x){throw $&&$(),x&&x.name==="TypeError"&&/Load failed|fetch/i.test(x.message)?Object.assign(new E("Network Error",E.ERR_NETWORK,f,ee),{cause:x.cause||x}):E.from(x,x&&x.code,f,ee)}}},Zn=new Map,Nt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,o=[r,s,n];let i=o.length,c=i,d,u,l=Zn;for(;c--;)d=o[c],u=l.get(d),u===void 0&&l.set(d,u=c?new Map:Qn(t)),l=u;return u};Nt();const Fe={http:En,xhr:Jn,fetch:{get:Nt}};a.forEach(Fe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const et=e=>`- ${e}`,er=e=>a.isFunction(e)||e===null||e===!1;function tr(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const o={};for(let i=0;i<n;i++){r=e[i];let c;if(s=r,!er(r)&&(s=Fe[(c=String(r)).toLowerCase()],s===void 0))throw new E(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ze]=this[ze]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=te(i);r[c]||(kn(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors(D.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});a.freezeMethods(D);function Ne(e,t){const n=this||oe,r=t||n,s=D.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function Rt(e){return!!(e&&e.__CANCEL__)}function Z(e,t,n){E.call(this,e??"canceled",E.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(Z,E,{__CANCEL__:!0});function yt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new E("Request failed with status code "+n.status,[E.ERR_BAD_REQUEST,E.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Hn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function vn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=r[o];i||(i=u),n[s]=d,r[s]=u;let h=o,S=0;for(;h!==s;)S+=n[h++],h=h%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const b=l&&u-l;return b?Math.round(S*1e3/b):void 0}}function jn(e,t){let n=0,r=1e3/t,s,o;const i=(u,l=Date.now())=>{n=l,s=null,o&&(clearTimeout(o),o=null),e(...u)};return[(...u)=>{const l=Date.now(),h=l-n;h>=r?i(u,l):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-h)))},()=>s&&i(s)]}const he=(e,t,n=3)=>{let r=0;const s=vn(50,250);return jn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),l=i<=c;r=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},n)},Je=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},We=e=>(...t)=>a.asap(()=>e(...t)),Mn=C.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,C.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(C.origin),C.navigator&&/(msie|trident)/i.test(C.navigator.userAgent)):()=>!0,$n=C.hasStandardBrowserEnv?{write(e,t,n,r,s,o,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&c.push(`path=${r}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function qn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Gn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function At(e,t,n){let r=!qn(t);return e&&(r||n==!1)?Gn(e,t):t}const Ve=e=>e instanceof D?{...e}:e;function W(e,t){t=t||{};const n={};function r(u,l,h,S){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:S},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,h,S){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,h,S)}else return r(u,l,h,S)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,h){if(h in t)return r(u,l);if(h in e)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l,h)=>s(Ve(u),Ve(l),h,!0)};return a.forEach(Object.keys({...e,...t}),function(l){const h=d[l]||s,S=h(e[l],t[l],l);a.isUndefined(S)&&h!==c||(n[l]=S)}),n}const bt=e=>{const t=W({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;if(t.headers=i=D.from(i),t.url=St(At(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(n)){if(C.hasStandardBrowserEnv||C.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,h])=>{u.includes(l.toLowerCase())&&i.set(l,h)})}}if(C.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Mn(t.url))){const d=s&&o&&$n.read(o);d&&i.set(s,d)}return t},zn=typeof XMLHttpRequest<"u",Jn=zn&&function(e){return new Promise(function(n,r){const s=bt(e);let o=s.data;const i=D.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,l,h,S,b,f;function m(){b&&b(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const R=D.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),P={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:R,config:e,request:p};yt(function(L){n(L),m()},function(L){r(L),m()},P),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new E("Request aborted",E.ECONNABORTED,e,p)),p=null)},p.onerror=function(U){const P=U&&U.message?U.message:"Network Error",$=new E(P,E.ERR_NETWORK,e,p);$.event=U||null,r($),p=null},p.ontimeout=function(){let U=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const P=s.transitional||Tt;s.timeoutErrorMessage&&(U=s.timeoutErrorMessage),r(new E(U,P.clarifyTimeoutError?E.ETIMEDOUT:E.ECONNABORTED,e,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&a.forEach(i.toJSON(),function(U,P){p.setRequestHeader(P,U)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),u&&([S,f]=he(u,!0),p.addEventListener("progress",S)),d&&p.upload&&([h,b]=he(d),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",b)),(s.cancelToken||s.signal)&&(l=R=>{p&&(r(!R||R.type?new Z(null,e,p):R),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const I=Hn(s.url);if(I&&C.protocols.indexOf(I)===-1){r(new E("Unsupported protocol "+I+":",E.ERR_BAD_REQUEST,e));return}p.send(o||null)})},Wn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const l=u instanceof Error?u:this.reason;r.abort(l instanceof E?l:new Z(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,o(new E(`timeout ${t} of ms exceeded`,E.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},Vn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},Kn=async function*(e,t){for await(const n of Xn(e))yield*Vn(n,t)},Xn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Ke=(e,t,n,r)=>{const s=Kn(e,t);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){c(),d.close();return}let h=l.byteLength;if(n){let S=o+=h;n(S)}d.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},Xe=64*1024,{isFunction:le}=a,Yn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:Ye,TextEncoder:Qe}=a.global,Ze=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Qn=e=>{e=a.merge.call({skipUndefined:!0},Yn,e);const{fetch:t,Request:n,Response:r}=e,s=t?le(t):typeof fetch=="function",o=le(n),i=le(r);if(!s)return!1;const c=s&&le(Ye),d=s&&(typeof Qe=="function"?(f=>m=>f.encode(m))(new Qe):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=o&&c&&Ze(()=>{let f=!1;const m=new n(C.origin,{body:new Ye,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),l=i&&c&&Ze(()=>a.isReadableStream(new r("").body)),h={stream:l&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(m,p)=>{let w=m&&m[f];if(w)return w.call(m);throw new E(`Response type '${f}' is not supported`,E.ERR_NOT_SUPPORT,p)})});const S=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new n(C.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await d(f)).byteLength},b=async(f,m)=>{const p=a.toFiniteNumber(f.getContentLength());return p??S(m)};return async f=>{let{url:m,method:p,data:w,signal:I,cancelToken:R,timeout:U,onDownloadProgress:P,onUploadProgress:$,responseType:L,headers:ye,withCredentials:ie="same-origin",fetchOptions:xe}=bt(f),Be=t||fetch;L=L?(L+"").toLowerCase():"text";let ae=Wn([I,R&&R.toAbortSignal()],U),ee=null;const q=ae&&ae.unsubscribe&&(()=>{ae.unsubscribe()});let ke;try{if($&&u&&p!=="get"&&p!=="head"&&(ke=await b(ye,w))!==0){let M=new n(m,{method:"POST",body:w,duplex:"half"}),K;if(a.isFormData(w)&&(K=M.headers.get("content-type"))&&ye.setContentType(K),M.body){const[Ae,ce]=Je(ke,he(We($)));w=Ke(M.body,Xe,Ae,ce)}}a.isString(ie)||(ie=ie?"include":"omit");const B=o&&"credentials"in n.prototype,He={...xe,signal:ae,method:p.toUpperCase(),headers:ye.normalize().toJSON(),body:w,duplex:"half",credentials:B?ie:void 0};ee=o&&new n(m,He);let j=await(o?Be(ee,xe):Be(m,He));const ve=l&&(L==="stream"||L==="response");if(l&&(P||ve&&q)){const M={};["status","statusText","headers"].forEach(je=>{M[je]=j[je]});const K=a.toFiniteNumber(j.headers.get("content-length")),[Ae,ce]=P&&Je(K,he(We(P),!0))||[];j=new r(Ke(j.body,Xe,Ae,()=>{ce&&ce(),q&&q()}),M)}L=L||"text";let _t=await h[a.findKey(h,L)||"text"](j,f);return!ve&&q&&q(),await new Promise((M,K)=>{yt(M,K,{data:_t,headers:D.from(j.headers),status:j.status,statusText:j.statusText,config:f,request:ee})})}catch(B){throw q&&q(),B&&B.name==="TypeError"&&/Load failed|fetch/i.test(B.message)?Object.assign(new E("Network Error",E.ERR_NETWORK,f,ee),{cause:B.cause||B}):E.from(B,B&&B.code,f,ee)}}},Zn=new Map,Nt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,o=[r,s,n];let i=o.length,c=i,d,u,l=Zn;for(;c--;)d=o[c],u=l.get(d),u===void 0&&l.set(d,u=c?new Map:Qn(t)),l=u;return u};Nt();const Fe={http:En,xhr:Jn,fetch:{get:Nt}};a.forEach(Fe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const et=e=>`- ${e}`,er=e=>a.isFunction(e)||e===null||e===!1;function tr(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const o={};for(let i=0;i<n;i++){r=e[i];let c;if(s=r,!er(r)&&(s=Fe[(c=String(r)).toLowerCase()],s===void 0))throw new E(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
4
4
  `+i.map(et).join(`
5
- `):" "+et(i[0]):"as no adapter specified";throw new E("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Ot={getAdapter:tr,adapters:Fe};function Oe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Z(null,e)}function tt(e){return Oe(e),e.headers=D.from(e.headers),e.data=Ne.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ot.getAdapter(e.adapter||oe.adapter,e)(e).then(function(r){return Oe(e),r.data=Ne.call(e,e.transformResponse,r),r.headers=D.from(r.headers),r},function(r){return Rt(r)||(Oe(e),r&&r.response&&(r.response.data=Ne.call(e,e.transformResponse,r.response),r.response.headers=D.from(r.response.headers))),Promise.reject(r)})}const Ct="1.13.2",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const nt={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+Ct+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new E(s(i," has been removed"+(n?" in "+n:"")),E.ERR_DEPRECATED);return n&&!nt[i]&&(nt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};Re.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function nr(e,t,n){if(typeof e!="object")throw new E("options must be an object",E.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new E("option "+o+" must be "+d,E.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new E("Unknown option "+o,E.ERR_BAD_OPTION)}}const de={assertOptions:nr,validators:Re},B=de.validators;let z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ge,response:new Ge}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=W(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&de.assertOptions(r,{silentJSONParsing:B.transitional(B.boolean),forcedJSONParsing:B.transitional(B.boolean),clarifyTimeoutError:B.transitional(B.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:de.assertOptions(s,{encode:B.function,serialize:B.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),de.assertOptions(n,{baseUrl:B.spelling("baseURL"),withXsrfToken:B.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),n.headers=D.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,h=0,S;if(!d){const f=[tt.bind(this),void 0];for(f.unshift(...c),f.push(...u),S=f.length,l=Promise.resolve(n);h<S;)l=l.then(f[h++],f[h++]);return l}S=c.length;let b=n;for(;h<S;){const f=c[h++],m=c[h++];try{b=f(b)}catch(p){m.call(this,p);break}}try{l=tt.call(this,b)}catch(f){return Promise.reject(f)}for(h=0,S=u.length;h<S;)l=l.then(u[h++],u[h++]);return l}getUri(t){t=W(this.defaults,t);const n=At(t.baseURL,t.url,t.allowAbsoluteUrls);return St(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){z.prototype[t]=function(n,r){return this.request(W(r||{},{method:t,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(W(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}z.prototype[t]=n(),z.prototype[t+"Form"]=n(!0)});let rr=class gt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new Z(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new gt(function(s){t=s}),cancel:t}}};function sr(e){return function(n){return e.apply(null,n)}}function or(e){return a.isObject(e)&&e.isAxiosError===!0}const _e={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(_e).forEach(([e,t])=>{_e[t]=e});function Ut(e){const t=new z(e),n=ot(z.prototype.request,t);return a.extend(n,z.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Ut(W(e,s))},n}const T=Ut(oe);T.Axios=z;T.CanceledError=Z;T.CancelToken=rr;T.isCancel=Rt;T.VERSION=Ct;T.toFormData=we;T.AxiosError=E;T.Cancel=T.CanceledError;T.all=function(t){return Promise.all(t)};T.spread=sr;T.isAxiosError=or;T.mergeConfig=W;T.AxiosHeaders=D;T.formToJSON=e=>wt(a.isHTMLForm(e)?new FormData(e):e);T.getAdapter=Ot.getAdapter;T.HttpStatusCode=_e;T.default=T;const{Axios:Cr,AxiosError:gr,CanceledError:Ur,isCancel:_r,CancelToken:Dr,VERSION:Ir,all:Lr,Cancel:Fr,isAxiosError:Pr,spread:xr,toFormData:Br,AxiosHeaders:kr,HttpStatusCode:Hr,formToJSON:jr,getAdapter:vr,mergeConfig:Mr}=T,A={UNINITIALIZED:{code:10001,msg:"未初始化"},DISCONNECTED:{code:10002,msg:"未连接"},NO_CUSTOMER_SERVICE:{code:10003,msg:"未分配客服"},MESSAGE_SEND_FAIL:{code:10004,msg:"消息发送失败"},DATA_PARSING_ERROR:{code:10005,msg:"数据解析异常"},FILE_NOT_EXIST:{code:10006,msg:"文件不存在"},FILE_PARSING_ERROR:{code:10007,msg:"文件解析异常"},AUTH_INFO_ERROR:{code:10008,msg:"授权信息错误"},FILE_UPLOAD_FAIL:{code:10009,msg:"文件上传失败"},PARAMETER_ERROR:{code:10010,msg:"参数异常"},EMPTY_DATA:{code:10011,msg:"数据为空"}},ir="/api/customer-service/customer/v1/CustomerService/TestLineLatency",ar="/api/customer-service/customer/v1/CustomerService/ListLines",cr="/pub/logo.png",rt={development:{BASE_API_URL:"http://dev-joytalk-api.halaladmin.vip",OBS_URL:"http://dev-joytalk-img.halaladmin.vip"},prodtest:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"},production:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"}},M={api:"",download:"",ws:""};let X=null;function lr(e){const t=`${e.replace(/\/$/,"")}${ir}`;return T.get(t,{timeout:1e4}).then(n=>n.data?.code!==200?Promise.reject(new Error("TestLineLatency failed")):e)}function ur(e){const t=`${e.replace(/\/$/,"")}${cr}`;return T.get(t,{timeout:1e4}).then(()=>e).catch(()=>Promise.reject(new Error("Download latency test failed")))}function fr(e){return e?.length?Promise.any(e.map(t=>lr(t))):Promise.reject(new Error("No urls to test"))}function dr(e){return e?.length?Promise.any(e.map(t=>ur(t))):Promise.reject(new Error("No download urls to test"))}async function Pe(e,t){if(M.api&&M.download)return;if(X)return X;const n=rt[t].BASE_API_URL||"",r=rt[t].OBS_URL||"";n||(X=Promise.reject(new Error("环境配置错误")),await X),X=(async()=>{const s=await T.get(`${n.replace(/\/$/,"")}${ar}`,{headers:{Authorization:`Bearer ${e}`},timeout:15e3});if(s.data?.code!==200||!s.data?.data)throw new Error(s.data?.message||"ListLines failed or empty data");const o=(s.data.data.api??[]).map(h=>h.url).filter(Boolean),i=(s.data.data.download??[]).map(h=>h.url).filter(Boolean),c=n,d=r,[u,l]=await Promise.all([o.length?fr(o).catch(()=>c):Promise.resolve(c),i.length?dr(i).catch(()=>c):Promise.resolve(d)]);M.api=u,M.download=l,M.ws=u.replace(/http/g,"ws")})(),await X}const V=T.create({timeout:6e5});V.interceptors.request.use(async e=>{const t=new J,n=t.config.token;return n?(e.headers.Authorization=`Bearer ${n}`,await Pe(n,t.config.env),e.baseURL=M.api,e):Promise.reject(A.UNINITIALIZED)},e=>Promise.reject(e));V.interceptors.response.use(e=>e.data?.code!==200?Promise.reject(e):Promise.resolve(e.data),e=>Promise.reject(e));function pe(){return M.download}function hr(){return M.ws}const pr=e=>V.post("/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",e),mr=async e=>{const t=await pe();return T.post(`${t}`,e,{headers:{"Content-Type":"multipart/form-data"}})},Er=e=>V.post("/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",e),Sr=e=>V.get("/api/open-auth/faq/v1/FaqService/GetFaqList",{params:e}),Tr=()=>V.get("/api/open-auth/user/v1/UserService/GetUserInfo"),wr=e=>V.post("/api/open-auth/user/v1/UserService/GetUserHistoryMessages",e);var k=(e=>(e.SEND="1",e.WITHDRAW="2",e.EDIT="3",e.SYSTEM_NOTICE="4",e.TRANSFER="5",e.INBOUND="6",e.REPLY="7",e.UNBIND="8",e))(k||{}),H=(e=>(e.TEXT="1",e.IMAGE="2",e.VIDEO="3",e.FILE="4",e.FAQ="5",e))(H||{}),g=(e=>(e[e.CONNECT_SUCCESS=200]="CONNECT_SUCCESS",e[e.CONNECT_FAILED=40001]="CONNECT_FAILED",e[e.TRANSFER_CUSTOMER_SUCCESS=201]="TRANSFER_CUSTOMER_SUCCESS",e[e.TRANSFER_TO_CUSTOMER_SUCCESS=202]="TRANSFER_TO_CUSTOMER_SUCCESS",e[e.TRANSFER_USER_SUCCESS=203]="TRANSFER_USER_SUCCESS",e[e.TRANSFER_FAIL=50001]="TRANSFER_FAIL",e[e.MATCH_FAIL=50002]="MATCH_FAIL",e[e.MATCH_INFO=50005]="MATCH_INFO",e[e.MATCH_SUCCESS=50006]="MATCH_SUCCESS",e[e.RETRACT=204]="RETRACT",e[e.RETRACT_FAIL=50003]="RETRACT_FAIL",e[e.EDIT=205]="EDIT",e[e.EDIT_FAIL=50004]="EDIT_FAIL",e[e.COMMON_FAIL=5e4]="COMMON_FAIL",e[e.SEND_SUCCESS=206]="SEND_SUCCESS",e[e.SEND_CALLBACK=207]="SEND_CALLBACK",e[e.CHANGE_CHAT_STATUS=208]="CHANGE_CHAT_STATUS",e[e.REPLY_FAIL=50008]="REPLY_FAIL",e[e.REPLY_SUCCESS=209]="REPLY_SUCCESS",e[e.UNBIND_SUCCESS=60006]="UNBIND_SUCCESS",e[e.REMATCH=60001]="REMATCH",e))(g||{}),me=(e=>(e.CUSTOMER="1",e.USER="2",e.ANONYMOUS="3",e))(me||{}),y=(e=>(e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.ERROR="error",e.MESSAGE="message",e.STATUS_CHANGE="status_change",e.HEARTBEAT_TIMEOUT="heartbeat_timeout",e))(y||{}),N=(e=>(e.DISCONNECTED="disconnected",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ERROR="error",e))(N||{}),O=(e=>(e.UNMATCHED="1",e.MATCHING="2",e.MATCHED="3",e.UNBIND="4",e))(O||{});class Rr{events=new Map;on(t,n){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n)}off(t,n){const r=this.events.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1)}}emit(t,n){const r=this.events.get(t);r&&r.forEach(s=>{try{s(n)}catch(o){console.error(`事件回调执行错误 [${t}]:`,o)}})}removeAllListeners(t){t?this.events.delete(t):this.events.clear()}once(t,n){const r=s=>{n(s),this.off(t,r)};this.on(t,r)}}async function yr(e,t){return await Pe(e,t),`${await hr()}/api/ws?Authorization=${e}`}function Ar(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function br(e){return typeof e=="object"&&e!==null&&"data"in e&&"msgType"in e&&"toUid"in e&&"chatType"in e&&"code"in e}function st(e){const t=pe()+"/";return e.contentType!==H.TEXT&&(e.content=JSON.parse(e.content),e.content?.fileUrl?.startsWith("http")||(e.content.fileUrl=t+e.content.fileUrl),e.content?.thumbnailUrl?.startsWith("http")||(e.content.thumbnailUrl=t+e.content.thumbnailUrl)),e.replyType&&e.replyType!==H.TEXT&&typeof e.replyContent=="string"&&(e.replyContent=JSON.parse(e.replyContent),e.replyContent?.fileUrl?.startsWith("http")||(e.replyContent.fileUrl=t+e.replyContent.fileUrl),e.replyContent?.thumbnailUrl?.startsWith("http")||(e.replyContent.thumbnailUrl=t+e.replyContent.thumbnailUrl)),e}class J extends Rr{config={token:"",autoReconnect:!0,reconnectInterval:3e3,maxReconnectAttempts:5,responseTimeout:1e4,env:"production"};ws=null;status=N.DISCONNECTED;reconnectTimer=null;reconnectAttempts=0;heartbeatTimeoutTimer=null;lastHeartbeatTime=0;consultationTypeId="";sessionData=null;userInfo=null;static instance=null;matchStatus=O.UNMATCHED;constructor(){if(super(),J.instance)return J.instance;J.instance=this}init(t){if(!t.token)return Promise.reject(A.PARAMETER_ERROR);Pe(t.token,t.env||"production"),this.config=Object.assign(this.config,t)}connect(t){return this.consultationTypeId=t,new Promise(async(n,r)=>{if(!this.config.token)return r(A.UNINITIALIZED);if(this.status===N.CONNECTED)return n();if(this.status!==N.CONNECTING){this.setStatus(N.CONNECTING);try{const s=await yr(this.config.token,this.config.env);this.ws=new WebSocket(s),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus(N.CONNECTED),this.emit(y.CONNECTED),n()},this.ws.onmessage=o=>{try{this.handleMessage(o.data)}catch(i){throw console.error("解析消息失败:",i),A.DATA_PARSING_ERROR}},this.ws.onerror=o=>{console.error("连接错误:",o),this.setStatus(N.ERROR),this.emit(y.ERROR,o),r(o)},this.ws.onclose=()=>{this.setStatus(N.DISCONNECTED),this.emit(y.DISCONNECTED),this.config.autoReconnect&&this.reconnectAttempts<this.config.maxReconnectAttempts&&this.scheduleReconnect()}}catch(s){this.setStatus(N.ERROR),this.emit(y.ERROR,s),r(s)}}})}disconnect(){this.config.autoReconnect=!1,this.sessionData=null,this.matchStatus=O.UNMATCHED,this.clearReconnectTimer(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus(N.DISCONNECTED)}async sendMessage(t,n,r=k.SEND){const s={msgType:r,data:t,toUid:this.sessionData?.cid,chatType:n,editId:void 0};if(this.status!==N.CONNECTED||!this.ws)if(this.ws&&this.status===N.DISCONNECTED){console.log("连接断开,尝试重新连接");try{await this.connect(this.consultationTypeId)}catch(o){throw console.error("重连失败:",o),A.DISCONNECTED}}else throw console.error(A.DISCONNECTED),A.DISCONNECTED;try{if(!this.ws)throw A.DISCONNECTED;return r===k.SEND?new Promise((o,i)=>{const c=Ar();s.ext=c;const d=setTimeout(()=>{this.off(c,u),i(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout),u=l=>{clearTimeout(d),o({messageId:l,data:t})};this.once(c,u),this.ws.send(JSON.stringify(s))}):(this.ws.send(JSON.stringify(s)),{data:t})}catch(o){throw console.error("发送消息失败:",o),A.MESSAGE_SEND_FAIL}}async checkMatchStatus(){if(this.matchStatus===O.UNBIND&&(await this.sendMessage(this.consultationTypeId,void 0,k.INBOUND),await new Promise((t,n)=>{const r=setTimeout(()=>{clearTimeout(r),n(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout);this.once(y.MESSAGE,s=>{s.code===g.REMATCH&&(clearTimeout(r),t(!0))})})),this.matchStatus!==O.MATCHED)throw console.error(A.NO_CUSTOMER_SERVICE),A.NO_CUSTOMER_SERVICE}async sendText(t){return await this.checkMatchStatus(),this.sendMessage(t,H.TEXT)}async sendFile({file:t,thumbnailFile:n,chatType:r}){try{await this.checkMatchStatus();const[s,o]=await Promise.all([this.handleUploadFile(t),n?this.handleUploadFile(n):Promise.resolve(void 0)]),i={fileName:t.name,fileUrl:s,thumbnailUrl:o,fileSize:t.size},{messageId:c}=await this.sendMessage(JSON.stringify(i),r),d=pe();return{messageId:c,content:{fileName:t.name,fileUrl:`${d}/${s}`,thumbnailUrl:o?`${d}/${o}`:void 0,fileSize:t.size}}}catch(s){throw console.error("上传文件失败:",s),s}}getStatus(){return this.status}isConnected(){return this.status===N.CONNECTED}handleMessage(t){if(t==="ping"){this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.sendHeartbeat();return}if(t=JSON.parse(t),!!br(t))try{const n=t.data?JSON.parse(t.data):t.data;switch(t.data=n,t.code){case g.CONNECT_SUCCESS:if(this.matchStatus===O.MATCHED||this.matchStatus===O.MATCHING)return;this.matchStatus=O.MATCHING,this.sendMessage(this.consultationTypeId,void 0,k.INBOUND);break;case g.MATCH_INFO:case g.MATCH_SUCCESS:if(this.matchStatus===O.MATCHED)return;this.sessionData=t.data,this.matchStatus===O.UNBIND?(this.matchStatus=O.MATCHED,this.emit(y.MESSAGE,{...t,code:g.REMATCH})):(this.matchStatus=O.MATCHED,this.getFaqList(),this.emit(y.MESSAGE,t));break;case g.TRANSFER_USER_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;const r=t.data;this.sessionData={...this.sessionData,cid:r.cid,customerAvatar:r.customerAvatar,customerName:r.customerName,groupId:r.groupId,sessionId:r.sessionId},this.emit(y.MESSAGE,t);break;case g.SEND_SUCCESS:case g.EDIT:case g.REPLY_SUCCESS:const s=t.data;if(s.sessionId!==this.sessionData?.sessionId)return;st(s),this.emit(y.MESSAGE,t);break;case g.SEND_CALLBACK:const o=t.ext,c=t.data.messageId;this.emit(o,c);break;case g.UNBIND_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;this.matchStatus=O.UNBIND,this.sessionData=null,this.emit(y.MESSAGE,t);break;default:this.emit(y.MESSAGE,t);break}}catch(n){console.error("解析消息失败:",n)}}setStatus(t){this.status!==t&&(this.status=t,this.emit(y.STATUS_CHANGE,t))}scheduleReconnect(){this.clearReconnectTimer(),this.reconnectAttempts++,this.setStatus(N.RECONNECTING),this.reconnectTimer=setTimeout(()=>{this.connect(this.consultationTypeId).catch(t=>{console.error("重连失败:",t)})},this.config.reconnectInterval)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}sendHeartbeat(){if(!(this.status!==N.CONNECTED||!this.ws))try{this.ws.send("pong"),this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer=setTimeout(()=>{Date.now()-this.lastHeartbeatTime>=this.config.responseTimeout&&(this.emit(y.HEARTBEAT_TIMEOUT),console.warn("心跳超时,尝试重连"),this.ws&&this.ws.close())},this.config.responseTimeout)}catch(t){console.error("发送心跳失败:",t)}}async getHistoryMessages({lastMsgId:t,size:n=50}){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const r=await wr({sessionId:this.sessionData?.sessionId,lastMsgId:t,size:n}),s=r.data.list.map(o=>st(o));return{hasMore:r.data.hasMore,list:s}}async getConsultationList(t){return(await Er({entranceId:t})).data}handleUploadFile(t){return new Promise(async(n,r)=>{const s=t.name.split(".").pop(),o=await pr({ext:s||""}),{accessKeyId:i,signature:c,policy:d,key:u}=o.data,l=new FormData;l.append("key",u),l.append("AccessKeyId",i),l.append("signature",c),l.append("policy",d),l.append("file",t);const h=await mr(l);h.status===204?n(`${u}`):r(h.data)})}getVideoThumbnail=t=>new Promise((n,r)=>{const s=document.createElement("video"),o=document.createElement("canvas"),i=o.getContext("2d");if(!i){r(new Error("无法创建 canvas 上下文"));return}const c=URL.createObjectURL(t);s.preload="metadata",s.src=c,s.muted=!0,s.playsInline=!0,s.addEventListener("loadeddata",()=>{o.width=s.videoWidth,o.height=s.videoHeight,s.currentTime=0}),s.addEventListener("seeked",()=>{try{i.drawImage(s,0,0,o.width,o.height),o.toBlob(d=>{if(URL.revokeObjectURL(c),s.remove(),!d){r(A.FILE_PARSING_ERROR);return}const u=t.name.replace(/\.[^/.]+$/,"")+"_thumb.jpg",l=new File([d],u,{type:"image/jpeg",lastModified:Date.now()});n(l)},"image/jpeg",.6)}catch(d){URL.revokeObjectURL(c),s.remove(),r(d)}}),s.addEventListener("error",()=>{URL.revokeObjectURL(c),s.remove(),r(A.FILE_PARSING_ERROR)}),s.load()});async getFaqList(){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const t=await Sr({id:this.sessionData?.cid});if(!t.data?.topic?.length)return;const n={guideText:t.data.guideText,list:t.data.topic.map(r=>({...r,question:r.question}))};setTimeout(()=>{const r={code:g.SEND_SUCCESS,data:{content:n,contentType:H.FAQ,sendUserType:me.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:k.SEND},msgType:k.SEND,chatType:H.FAQ};this.emit(y.MESSAGE,r)},t.data.showDelaySeconds*1e3)}sendFaq(t){const n={code:g.SEND_SUCCESS,data:{sendUserType:me.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:k.SEND,contentType:H.FAQ,content:{}},msgType:k.SEND,chatType:H.FAQ};if(t.isMulti)n.data.content={list:t.item},this.emit(y.MESSAGE,n);else{const r=t.item?.[0]||t,s=pe();r.imageUrl=r.imageUrl?.map(o=>o?.startsWith("http")?o:`${s}/${o}`),n.data.content={answer:r},this.emit(y.MESSAGE,n)}}async getUserInfo(){if(this.userInfo)return this.userInfo;const t=await Tr();return this.userInfo=t.data,this.userInfo}}exports.ChatType=H;exports.ConnectionStatus=N;exports.EventType=y;exports.JoyTalk=J;exports.MatchStatus=O;exports.MessageCode=g;exports.MessageType=k;exports.SendUserType=me;exports.default=J;
5
+ `):" "+et(i[0]):"as no adapter specified";throw new E("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Ot={getAdapter:tr,adapters:Fe};function Oe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Z(null,e)}function tt(e){return Oe(e),e.headers=D.from(e.headers),e.data=Ne.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ot.getAdapter(e.adapter||oe.adapter,e)(e).then(function(r){return Oe(e),r.data=Ne.call(e,e.transformResponse,r),r.headers=D.from(r.headers),r},function(r){return Rt(r)||(Oe(e),r&&r.response&&(r.response.data=Ne.call(e,e.transformResponse,r.response),r.response.headers=D.from(r.response.headers))),Promise.reject(r)})}const Ct="1.13.2",Re={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Re[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const nt={};Re.transitional=function(t,n,r){function s(o,i){return"[Axios v"+Ct+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new E(s(i," has been removed"+(n?" in "+n:"")),E.ERR_DEPRECATED);return n&&!nt[i]&&(nt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};Re.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function nr(e,t,n){if(typeof e!="object")throw new E("options must be an object",E.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new E("option "+o+" must be "+d,E.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new E("Unknown option "+o,E.ERR_BAD_OPTION)}}const de={assertOptions:nr,validators:Re},k=de.validators;let z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ge,response:new Ge}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
+ `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=W(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&de.assertOptions(r,{silentJSONParsing:k.transitional(k.boolean),forcedJSONParsing:k.transitional(k.boolean),clarifyTimeoutError:k.transitional(k.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:de.assertOptions(s,{encode:k.function,serialize:k.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),de.assertOptions(n,{baseUrl:k.spelling("baseURL"),withXsrfToken:k.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),n.headers=D.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,h=0,S;if(!d){const f=[tt.bind(this),void 0];for(f.unshift(...c),f.push(...u),S=f.length,l=Promise.resolve(n);h<S;)l=l.then(f[h++],f[h++]);return l}S=c.length;let b=n;for(;h<S;){const f=c[h++],m=c[h++];try{b=f(b)}catch(p){m.call(this,p);break}}try{l=tt.call(this,b)}catch(f){return Promise.reject(f)}for(h=0,S=u.length;h<S;)l=l.then(u[h++],u[h++]);return l}getUri(t){t=W(this.defaults,t);const n=At(t.baseURL,t.url,t.allowAbsoluteUrls);return St(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){z.prototype[t]=function(n,r){return this.request(W(r||{},{method:t,url:n,data:(r||{}).data}))}});a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(W(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}z.prototype[t]=n(),z.prototype[t+"Form"]=n(!0)});let rr=class gt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new Z(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new gt(function(s){t=s}),cancel:t}}};function sr(e){return function(n){return e.apply(null,n)}}function or(e){return a.isObject(e)&&e.isAxiosError===!0}const _e={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(_e).forEach(([e,t])=>{_e[t]=e});function Ut(e){const t=new z(e),n=ot(z.prototype.request,t);return a.extend(n,z.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Ut(W(e,s))},n}const T=Ut(oe);T.Axios=z;T.CanceledError=Z;T.CancelToken=rr;T.isCancel=Rt;T.VERSION=Ct;T.toFormData=we;T.AxiosError=E;T.Cancel=T.CanceledError;T.all=function(t){return Promise.all(t)};T.spread=sr;T.isAxiosError=or;T.mergeConfig=W;T.AxiosHeaders=D;T.formToJSON=e=>wt(a.isHTMLForm(e)?new FormData(e):e);T.getAdapter=Ot.getAdapter;T.HttpStatusCode=_e;T.default=T;const{Axios:Ur,AxiosError:_r,CanceledError:Dr,isCancel:Ir,CancelToken:Lr,VERSION:Fr,all:Pr,Cancel:xr,isAxiosError:Br,spread:kr,toFormData:Hr,AxiosHeaders:vr,HttpStatusCode:jr,formToJSON:Mr,getAdapter:$r,mergeConfig:qr}=T,A={UNINITIALIZED:{code:10001,msg:"未初始化"},DISCONNECTED:{code:10002,msg:"未连接"},NO_CUSTOMER_SERVICE:{code:10003,msg:"未分配客服"},MESSAGE_SEND_FAIL:{code:10004,msg:"消息发送失败"},DATA_PARSING_ERROR:{code:10005,msg:"数据解析异常"},FILE_NOT_EXIST:{code:10006,msg:"文件不存在"},FILE_PARSING_ERROR:{code:10007,msg:"文件解析异常"},AUTH_INFO_ERROR:{code:10008,msg:"授权信息错误"},FILE_UPLOAD_FAIL:{code:10009,msg:"文件上传失败"},PARAMETER_ERROR:{code:10010,msg:"参数异常"},EMPTY_DATA:{code:10011,msg:"数据为空"}},ir="/api/customer-service/customer/v1/CustomerService/TestLineLatency",ar="/api/customer-service/customer/v1/CustomerService/ListLines",cr="/pub/logo.png",rt={development:{BASE_API_URL:"http://dev-joytalk-api.halaladmin.vip",OBS_URL:"http://dev-joytalk-img.halaladmin.vip"},prodtest:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"},production:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"}},F={api:"",download:"",ws:""};let X=null;function lr(e){const t=`${e.replace(/\/$/,"")}${ir}`;return T.get(t,{timeout:1e4}).then(n=>n.data?.code!==200?Promise.reject(new Error("TestLineLatency failed")):e)}function ur(e){const t=`${e.replace(/\/$/,"")}${cr}`;return T.get(t,{timeout:1e4}).then(()=>e).catch(()=>Promise.reject(new Error("Download latency test failed")))}function fr(e){return e?.length?Promise.any(e.map(t=>lr(t))):Promise.reject(new Error("No urls to test"))}function dr(e){return e?.length?Promise.any(e.map(t=>ur(t))):Promise.reject(new Error("No download urls to test"))}async function Pe(e,t){if(F.api&&F.download)return;if(X)return X;const n=rt[t].BASE_API_URL||"",r=rt[t].OBS_URL||"";F.api=n,F.download=r,F.ws=n.replace(/http/g,"ws"),n||(X=Promise.reject(new Error("环境配置错误")),await X),X=(async()=>{const s=await T.get(`${n.replace(/\/$/,"")}${ar}`,{headers:{Authorization:`Bearer ${e}`},timeout:15e3});if(s.data?.code!==200||!s.data?.data)return Promise.reject(s.data);const o=(s.data.data.api??[]).map(h=>h.url).filter(Boolean),i=(s.data.data.download??[]).map(h=>h.url).filter(Boolean),c=n,d=r,[u,l]=await Promise.all([o.length?fr(o).catch(()=>c):Promise.resolve(c),i.length?dr(i).catch(()=>c):Promise.resolve(d)]);F.api=u,F.download=l,F.ws=u.replace(/http/g,"ws")})(),await X}const V=T.create({timeout:6e5});V.interceptors.request.use(async e=>{const t=new J,n=t.config.token;return n?(e.headers.Authorization=`Bearer ${n}`,await Pe(n,t.config.env),e.baseURL=F.api,e):Promise.reject(A.UNINITIALIZED)},e=>Promise.reject(e));V.interceptors.response.use(e=>e.data?.code!==200?Promise.reject(e):Promise.resolve(e.data),e=>Promise.reject(e));function hr(){return F.api}function pe(){return F.download}function pr(){return F.ws}const mr=e=>V.post("/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",e),Er=async e=>{const t=pe();return T.post(`${t}`,e,{headers:{"Content-Type":"multipart/form-data"}})},Sr=e=>V.post("/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",e),Tr=e=>V.get("/api/open-auth/faq/v1/FaqService/GetFaqList",{params:e}),wr=()=>V.get("/api/open-auth/user/v1/UserService/GetUserInfo"),Rr=e=>V.post("/api/open-auth/user/v1/UserService/GetUserHistoryMessages",e),yr=e=>{const t=hr();return T.post(`${t}/api/open-auth/openAuth/v1/OpenAuthService/AnonymousAuth`,e)};var H=(e=>(e.SEND="1",e.WITHDRAW="2",e.EDIT="3",e.SYSTEM_NOTICE="4",e.TRANSFER="5",e.INBOUND="6",e.REPLY="7",e.UNBIND="8",e))(H||{}),v=(e=>(e.TEXT="1",e.IMAGE="2",e.VIDEO="3",e.FILE="4",e.FAQ="5",e))(v||{}),g=(e=>(e[e.CONNECT_SUCCESS=200]="CONNECT_SUCCESS",e[e.CONNECT_FAILED=40001]="CONNECT_FAILED",e[e.TRANSFER_CUSTOMER_SUCCESS=201]="TRANSFER_CUSTOMER_SUCCESS",e[e.TRANSFER_TO_CUSTOMER_SUCCESS=202]="TRANSFER_TO_CUSTOMER_SUCCESS",e[e.TRANSFER_USER_SUCCESS=203]="TRANSFER_USER_SUCCESS",e[e.TRANSFER_FAIL=50001]="TRANSFER_FAIL",e[e.MATCH_FAIL=50002]="MATCH_FAIL",e[e.MATCH_INFO=50005]="MATCH_INFO",e[e.MATCH_SUCCESS=50006]="MATCH_SUCCESS",e[e.RETRACT=204]="RETRACT",e[e.RETRACT_FAIL=50003]="RETRACT_FAIL",e[e.EDIT=205]="EDIT",e[e.EDIT_FAIL=50004]="EDIT_FAIL",e[e.COMMON_FAIL=5e4]="COMMON_FAIL",e[e.SEND_SUCCESS=206]="SEND_SUCCESS",e[e.SEND_CALLBACK=207]="SEND_CALLBACK",e[e.CHANGE_CHAT_STATUS=208]="CHANGE_CHAT_STATUS",e[e.REPLY_FAIL=50008]="REPLY_FAIL",e[e.REPLY_SUCCESS=209]="REPLY_SUCCESS",e[e.UNBIND_SUCCESS=60006]="UNBIND_SUCCESS",e[e.REMATCH=60001]="REMATCH",e))(g||{}),me=(e=>(e.CUSTOMER="1",e.USER="2",e.ANONYMOUS="3",e))(me||{}),y=(e=>(e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.ERROR="error",e.MESSAGE="message",e.STATUS_CHANGE="status_change",e.HEARTBEAT_TIMEOUT="heartbeat_timeout",e))(y||{}),N=(e=>(e.DISCONNECTED="disconnected",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ERROR="error",e))(N||{}),O=(e=>(e.UNMATCHED="1",e.MATCHING="2",e.MATCHED="3",e.UNBIND="4",e))(O||{});class Ar{events=new Map;on(t,n){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n)}off(t,n){const r=this.events.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1)}}emit(t,n){const r=this.events.get(t);r&&r.forEach(s=>{try{s(n)}catch(o){console.error(`事件回调执行错误 [${t}]:`,o)}})}removeAllListeners(t){t?this.events.delete(t):this.events.clear()}once(t,n){const r=s=>{n(s),this.off(t,r)};this.on(t,r)}}async function br(e,t){return await Pe(e,t),`${await pr()}/api/ws?Authorization=${e}`}function Nr(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function Or(e){return typeof e=="object"&&e!==null&&"data"in e&&"msgType"in e&&"toUid"in e&&"chatType"in e&&"code"in e}function st(e){const t=pe()+"/";return e.contentType!==v.TEXT&&(e.content=JSON.parse(e.content),e.content?.fileUrl?.startsWith("http")||(e.content.fileUrl=t+e.content.fileUrl),e.content?.thumbnailUrl?.startsWith("http")||(e.content.thumbnailUrl=t+e.content.thumbnailUrl)),e.replyType&&e.replyType!==v.TEXT&&typeof e.replyContent=="string"&&(e.replyContent=JSON.parse(e.replyContent),e.replyContent?.fileUrl?.startsWith("http")||(e.replyContent.fileUrl=t+e.replyContent.fileUrl),e.replyContent?.thumbnailUrl?.startsWith("http")||(e.replyContent.thumbnailUrl=t+e.replyContent.thumbnailUrl)),e}class J extends Ar{config={token:"",autoReconnect:!0,reconnectInterval:3e3,maxReconnectAttempts:5,responseTimeout:1e4,env:"production"};ws=null;status=N.DISCONNECTED;reconnectTimer=null;reconnectAttempts=0;heartbeatTimeoutTimer=null;lastHeartbeatTime=0;consultationTypeId="";sessionData=null;userInfo=null;static instance=null;matchStatus=O.UNMATCHED;constructor(){if(super(),J.instance)return J.instance;J.instance=this}init(t){if(!t.token)return Promise.reject(A.PARAMETER_ERROR);Pe(t.token,t.env||"production"),this.config=Object.assign(this.config,t)}connect(t){return this.consultationTypeId=t,new Promise(async(n,r)=>{if(!this.config.token)return r(A.UNINITIALIZED);if(this.status===N.CONNECTED)return n();if(this.status!==N.CONNECTING){this.setStatus(N.CONNECTING);try{const s=await br(this.config.token,this.config.env);this.ws=new WebSocket(s),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus(N.CONNECTED),this.emit(y.CONNECTED),n()},this.ws.onmessage=o=>{try{this.handleMessage(o.data)}catch(i){throw console.error("解析消息失败:",i),A.DATA_PARSING_ERROR}},this.ws.onerror=o=>{console.error("连接错误:",o),this.setStatus(N.ERROR),this.emit(y.ERROR,o),r(o)},this.ws.onclose=()=>{this.setStatus(N.DISCONNECTED),this.emit(y.DISCONNECTED),this.config.autoReconnect&&this.reconnectAttempts<this.config.maxReconnectAttempts&&this.scheduleReconnect()}}catch(s){this.setStatus(N.ERROR),this.emit(y.ERROR,s),r(s)}}})}disconnect(){this.config.autoReconnect=!1,this.sessionData=null,this.matchStatus=O.UNMATCHED,this.clearReconnectTimer(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus(N.DISCONNECTED)}async sendMessage(t,n,r=H.SEND){const s={msgType:r,data:t,toUid:this.sessionData?.cid,chatType:n,editId:void 0};if(this.status!==N.CONNECTED||!this.ws)if(this.ws&&this.status===N.DISCONNECTED){console.log("连接断开,尝试重新连接");try{await this.connect(this.consultationTypeId)}catch(o){throw console.error("重连失败:",o),A.DISCONNECTED}}else throw console.error(A.DISCONNECTED),A.DISCONNECTED;try{if(!this.ws)throw A.DISCONNECTED;return r===H.SEND?new Promise((o,i)=>{const c=Nr();s.ext=c;const d=setTimeout(()=>{this.off(c,u),i(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout),u=l=>{clearTimeout(d),o({messageId:l,data:t})};this.once(c,u),this.ws.send(JSON.stringify(s))}):(this.ws.send(JSON.stringify(s)),{data:t})}catch(o){throw console.error("发送消息失败:",o),A.MESSAGE_SEND_FAIL}}async checkMatchStatus(){if(this.matchStatus===O.UNBIND&&(await this.sendMessage(this.consultationTypeId,void 0,H.INBOUND),await new Promise((t,n)=>{const r=setTimeout(()=>{clearTimeout(r),n(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout);this.once(y.MESSAGE,s=>{s.code===g.REMATCH&&(clearTimeout(r),t(!0))})})),this.matchStatus!==O.MATCHED)throw console.error(A.NO_CUSTOMER_SERVICE),A.NO_CUSTOMER_SERVICE}async sendText(t){return await this.checkMatchStatus(),this.sendMessage(t,v.TEXT)}async sendFile({file:t,thumbnailFile:n,chatType:r}){try{await this.checkMatchStatus();const[s,o]=await Promise.all([this.handleUploadFile(t),n?this.handleUploadFile(n):Promise.resolve(void 0)]),i={fileName:t.name,fileUrl:s,thumbnailUrl:o,fileSize:t.size},{messageId:c}=await this.sendMessage(JSON.stringify(i),r),d=pe();return{messageId:c,content:{fileName:t.name,fileUrl:`${d}/${s}`,thumbnailUrl:o?`${d}/${o}`:void 0,fileSize:t.size}}}catch(s){throw console.error("上传文件失败:",s),s}}getStatus(){return this.status}isConnected(){return this.status===N.CONNECTED}handleMessage(t){if(t==="ping"){this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.sendHeartbeat();return}if(t=JSON.parse(t),!!Or(t))try{const n=t.data?JSON.parse(t.data):t.data;switch(t.data=n,t.code){case g.CONNECT_SUCCESS:if(this.matchStatus===O.MATCHED||this.matchStatus===O.MATCHING)return;this.matchStatus=O.MATCHING,this.sendMessage(this.consultationTypeId,void 0,H.INBOUND);break;case g.MATCH_INFO:case g.MATCH_SUCCESS:if(this.matchStatus===O.MATCHED)return;this.sessionData=t.data,this.matchStatus===O.UNBIND?(this.matchStatus=O.MATCHED,this.emit(y.MESSAGE,{...t,code:g.REMATCH})):(this.matchStatus=O.MATCHED,this.getFaqList(),this.emit(y.MESSAGE,t));break;case g.TRANSFER_USER_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;const r=t.data;this.sessionData={...this.sessionData,cid:r.cid,customerAvatar:r.customerAvatar,customerName:r.customerName,groupId:r.groupId,sessionId:r.sessionId},this.emit(y.MESSAGE,t);break;case g.SEND_SUCCESS:case g.EDIT:case g.REPLY_SUCCESS:const s=t.data;if(s.sessionId!==this.sessionData?.sessionId)return;st(s),this.emit(y.MESSAGE,t);break;case g.SEND_CALLBACK:const o=t.ext,c=t.data.messageId;this.emit(o,c);break;case g.UNBIND_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;this.matchStatus=O.UNBIND,this.sessionData=null,this.emit(y.MESSAGE,t);break;default:this.emit(y.MESSAGE,t);break}}catch(n){console.error("解析消息失败:",n)}}setStatus(t){this.status!==t&&(this.status=t,this.emit(y.STATUS_CHANGE,t))}scheduleReconnect(){this.clearReconnectTimer(),this.reconnectAttempts++,this.setStatus(N.RECONNECTING),this.reconnectTimer=setTimeout(()=>{this.connect(this.consultationTypeId).catch(t=>{console.error("重连失败:",t)})},this.config.reconnectInterval)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}sendHeartbeat(){if(!(this.status!==N.CONNECTED||!this.ws))try{this.ws.send("pong"),this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer=setTimeout(()=>{Date.now()-this.lastHeartbeatTime>=this.config.responseTimeout&&(this.emit(y.HEARTBEAT_TIMEOUT),console.warn("心跳超时,尝试重连"),this.ws&&this.ws.close())},this.config.responseTimeout)}catch(t){console.error("发送心跳失败:",t)}}async getHistoryMessages({lastMsgId:t,size:n=50}){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const r=await Rr({sessionId:this.sessionData?.sessionId,lastMsgId:t,size:n}),s=r.data.list.map(o=>st(o));return{hasMore:r.data.hasMore,list:s}}async getConsultationList(t){return(await Sr({entranceId:t})).data}handleUploadFile(t){return new Promise(async(n,r)=>{const s=t.name.split(".").pop(),o=await mr({ext:s||""}),{accessKeyId:i,signature:c,policy:d,key:u}=o.data,l=new FormData;l.append("key",u),l.append("AccessKeyId",i),l.append("signature",c),l.append("policy",d),l.append("file",t);const h=await Er(l);h.status===204?n(`${u}`):r(h.data)})}getVideoThumbnail=t=>new Promise((n,r)=>{const s=document.createElement("video"),o=document.createElement("canvas"),i=o.getContext("2d");if(!i){r(new Error("无法创建 canvas 上下文"));return}const c=URL.createObjectURL(t);s.preload="metadata",s.src=c,s.muted=!0,s.playsInline=!0,s.addEventListener("loadeddata",()=>{o.width=s.videoWidth,o.height=s.videoHeight,s.currentTime=0}),s.addEventListener("seeked",()=>{try{i.drawImage(s,0,0,o.width,o.height),o.toBlob(d=>{if(URL.revokeObjectURL(c),s.remove(),!d){r(A.FILE_PARSING_ERROR);return}const u=t.name.replace(/\.[^/.]+$/,"")+"_thumb.jpg",l=new File([d],u,{type:"image/jpeg",lastModified:Date.now()});n(l)},"image/jpeg",.6)}catch(d){URL.revokeObjectURL(c),s.remove(),r(d)}}),s.addEventListener("error",()=>{URL.revokeObjectURL(c),s.remove(),r(A.FILE_PARSING_ERROR)}),s.load()});async getFaqList(){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const t=await Tr({id:this.sessionData?.cid});if(!t.data?.topic?.length)return;const n={guideText:t.data.guideText,list:t.data.topic.map(r=>({...r,question:r.question}))};setTimeout(()=>{const r={code:g.SEND_SUCCESS,data:{content:n,contentType:v.FAQ,sendUserType:me.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:H.SEND},msgType:H.SEND,chatType:v.FAQ};this.emit(y.MESSAGE,r)},t.data.showDelaySeconds*1e3)}sendFaq(t){const n={code:g.SEND_SUCCESS,data:{sendUserType:me.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:H.SEND,contentType:v.FAQ,content:{}},msgType:H.SEND,chatType:v.FAQ};if(t.isMulti)n.data.content={list:t.item},this.emit(y.MESSAGE,n);else{const r=t.item?.[0]||t,s=pe();r.imageUrl=r.imageUrl?.map(o=>o?.startsWith("http")?o:`${s}/${o}`),n.data.content={answer:r},this.emit(y.MESSAGE,n)}}async getUserInfo(){if(this.userInfo)return this.userInfo;const t=await wr();return this.userInfo=t.data,this.userInfo}async anonymousLogin(t,n){return(await yr({appKey:t,entranceId:n,userSource:"H5"})).data}}exports.ChatType=v;exports.ConnectionStatus=N;exports.EventType=y;exports.JoyTalk=J;exports.MatchStatus=O;exports.MessageCode=g;exports.MessageType=H;exports.SendUserType=me;exports.default=J;
package/dist/index.es.js CHANGED
@@ -6,11 +6,11 @@ function ot(e, t) {
6
6
  const { toString: Dt } = Object.prototype, { getPrototypeOf: De } = Object, { iterator: me, toStringTag: it } = Symbol, Ee = /* @__PURE__ */ ((e) => (t) => {
7
7
  const n = Dt.call(t);
8
8
  return e[n] || (e[n] = n.slice(8, -1).toLowerCase());
9
- })(/* @__PURE__ */ Object.create(null)), P = (e) => (e = e.toLowerCase(), (t) => Ee(t) === e), Se = (e) => (t) => typeof t === e, { isArray: Y } = Array, X = Se("undefined");
9
+ })(/* @__PURE__ */ Object.create(null)), x = (e) => (e = e.toLowerCase(), (t) => Ee(t) === e), Se = (e) => (t) => typeof t === e, { isArray: Y } = Array, X = Se("undefined");
10
10
  function ne(e) {
11
11
  return e !== null && !X(e) && e.constructor !== null && !X(e.constructor) && _(e.constructor.isBuffer) && e.constructor.isBuffer(e);
12
12
  }
13
- const at = P("ArrayBuffer");
13
+ const at = x("ArrayBuffer");
14
14
  function It(e) {
15
15
  let t;
16
16
  return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && at(e.buffer), t;
@@ -28,11 +28,11 @@ const Lt = Se("string"), _ = Se("function"), ct = Se("number"), re = (e) => e !=
28
28
  } catch {
29
29
  return !1;
30
30
  }
31
- }, xt = P("Date"), Bt = P("File"), kt = P("Blob"), Ht = P("FileList"), jt = (e) => re(e) && _(e.pipe), vt = (e) => {
31
+ }, xt = x("Date"), Bt = x("File"), kt = x("Blob"), Ht = x("FileList"), jt = (e) => re(e) && _(e.pipe), vt = (e) => {
32
32
  let t;
33
33
  return e && (typeof FormData == "function" && e instanceof FormData || _(e.append) && ((t = Ee(e)) === "formdata" || // detect form-data instance
34
34
  t === "object" && _(e.toString) && e.toString() === "[object FormData]"));
35
- }, Mt = P("URLSearchParams"), [qt, $t, Gt, zt] = ["ReadableStream", "Request", "Response", "Headers"].map(P), Jt = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
35
+ }, Mt = x("URLSearchParams"), [$t, qt, Gt, zt] = ["ReadableStream", "Request", "Response", "Headers"].map(x), Jt = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
36
36
  function se(e, t, { allOwnKeys: n = !1 } = {}) {
37
37
  if (e === null || typeof e > "u")
38
38
  return;
@@ -112,12 +112,12 @@ const Wt = (e, t, n, { allOwnKeys: r } = {}) => (se(t, (s, o) => {
112
112
  for (; (n = e.exec(t)) !== null; )
113
113
  r.push(n);
114
114
  return r;
115
- }, nn = P("HTMLFormElement"), rn = (e) => e.toLowerCase().replace(
115
+ }, nn = x("HTMLFormElement"), rn = (e) => e.toLowerCase().replace(
116
116
  /[-_\s]([a-z\d])(\w*)/g,
117
117
  function(n, r, s) {
118
118
  return r.toUpperCase() + s;
119
119
  }
120
- ), Me = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), sn = P("RegExp"), ft = (e, t) => {
120
+ ), Me = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), sn = x("RegExp"), ft = (e, t) => {
121
121
  const n = Object.getOwnPropertyDescriptors(e), r = {};
122
122
  se(n, (s, o) => {
123
123
  let i;
@@ -169,7 +169,7 @@ const fn = (e) => {
169
169
  return r;
170
170
  };
171
171
  return n(e, 0);
172
- }, dn = P("AsyncFunction"), hn = (e) => e && (re(e) || _(e)) && _(e.then) && _(e.catch), dt = ((e, t) => e ? setImmediate : t ? ((n, r) => (G.addEventListener("message", ({ source: s, data: o }) => {
172
+ }, dn = x("AsyncFunction"), hn = (e) => e && (re(e) || _(e)) && _(e.then) && _(e.catch), dt = ((e, t) => e ? setImmediate : t ? ((n, r) => (G.addEventListener("message", ({ source: s, data: o }) => {
173
173
  s === G && o === n && r.length && r.shift()();
174
174
  }, !1), (s) => {
175
175
  r.push(s), G.postMessage(n, "*");
@@ -188,8 +188,8 @@ const fn = (e) => {
188
188
  isObject: re,
189
189
  isPlainObject: ue,
190
190
  isEmptyObject: Pt,
191
- isReadableStream: qt,
192
- isRequest: $t,
191
+ isReadableStream: $t,
192
+ isRequest: qt,
193
193
  isResponse: Gt,
194
194
  isHeaders: zt,
195
195
  isUndefined: X,
@@ -210,7 +210,7 @@ const fn = (e) => {
210
210
  inherits: Kt,
211
211
  toFlatObject: Xt,
212
212
  kindOf: Ee,
213
- kindOfTest: P,
213
+ kindOfTest: x,
214
214
  endsWith: Yt,
215
215
  toArray: Qt,
216
216
  forEachEntry: en,
@@ -295,7 +295,7 @@ function Ce(e) {
295
295
  function mt(e) {
296
296
  return a.endsWith(e, "[]") ? e.slice(0, -2) : e;
297
297
  }
298
- function qe(e, t, n) {
298
+ function $e(e, t, n) {
299
299
  return e ? e.concat(t).map(function(s, o) {
300
300
  return s = mt(s), !n && o ? "[" + s + "]" : s;
301
301
  }).join(n ? "." : "") : t;
@@ -338,12 +338,12 @@ function Te(e, t, n) {
338
338
  return m = mt(m), w.forEach(function(R, g) {
339
339
  !(a.isUndefined(R) || R === null) && t.append(
340
340
  // eslint-disable-next-line no-nested-ternary
341
- i === !0 ? qe([m], g, o) : i === null ? m : m + "[]",
341
+ i === !0 ? $e([m], g, o) : i === null ? m : m + "[]",
342
342
  u(R)
343
343
  );
344
344
  }), !1;
345
345
  }
346
- return Ce(f) ? !0 : (t.append(qe(p, m, o), u(f)), !1);
346
+ return Ce(f) ? !0 : (t.append($e(p, m, o), u(f)), !1);
347
347
  }
348
348
  const h = [], S = Object.assign(Tn, {
349
349
  defaultVisitor: l,
@@ -369,7 +369,7 @@ function Te(e, t, n) {
369
369
  throw new TypeError("data must be an object");
370
370
  return b(e), t;
371
371
  }
372
- function $e(e) {
372
+ function qe(e) {
373
373
  const t = {
374
374
  "!": "%21",
375
375
  "'": "%27",
@@ -392,8 +392,8 @@ Et.append = function(t, n) {
392
392
  };
393
393
  Et.toString = function(t) {
394
394
  const n = t ? function(r) {
395
- return t.call(this, r, $e);
396
- } : $e;
395
+ return t.call(this, r, qe);
396
+ } : qe;
397
397
  return this._pairs.map(function(s) {
398
398
  return n(s[0]) + "=" + n(s[1]);
399
399
  }, "").join("&");
@@ -896,7 +896,7 @@ const he = (e, t, n = 3) => {
896
896
  }, We = (e) => (...t) => a.asap(() => e(...t)), Mn = N.hasStandardBrowserEnv ? /* @__PURE__ */ ((e, t) => (n) => (n = new URL(n, N.origin), e.protocol === n.protocol && e.host === n.host && (t || e.port === n.port)))(
897
897
  new URL(N.origin),
898
898
  N.navigator && /(msie|trident)/i.test(N.navigator.userAgent)
899
- ) : () => !0, qn = N.hasStandardBrowserEnv ? (
899
+ ) : () => !0, $n = N.hasStandardBrowserEnv ? (
900
900
  // Standard browser envs support document.cookie
901
901
  {
902
902
  write(e, t, n, r, s, o, i) {
@@ -925,14 +925,14 @@ const he = (e, t, n = 3) => {
925
925
  }
926
926
  }
927
927
  );
928
- function $n(e) {
928
+ function qn(e) {
929
929
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);
930
930
  }
931
931
  function Gn(e, t) {
932
932
  return t ? e.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : e;
933
933
  }
934
934
  function At(e, t, n) {
935
- let r = !$n(t);
935
+ let r = !qn(t);
936
936
  return e && (r || n == !1) ? Gn(e, t) : t;
937
937
  }
938
938
  const Ve = (e) => e instanceof D ? { ...e } : e;
@@ -1017,7 +1017,7 @@ const bt = (e) => {
1017
1017
  }
1018
1018
  }
1019
1019
  if (N.hasStandardBrowserEnv && (r && a.isFunction(r) && (r = r(t)), r || r !== !1 && Mn(t.url))) {
1020
- const d = s && o && qn.read(o);
1020
+ const d = s && o && $n.read(o);
1021
1021
  d && i.set(s, d);
1022
1022
  }
1023
1023
  return t;
@@ -1037,7 +1037,7 @@ const bt = (e) => {
1037
1037
  return;
1038
1038
  const R = D.from(
1039
1039
  "getAllResponseHeaders" in p && p.getAllResponseHeaders()
1040
- ), F = {
1040
+ ), P = {
1041
1041
  data: !c || c === "text" || c === "json" ? p.responseText : p.response,
1042
1042
  status: p.status,
1043
1043
  statusText: p.statusText,
@@ -1049,26 +1049,26 @@ const bt = (e) => {
1049
1049
  n(L), m();
1050
1050
  }, function(L) {
1051
1051
  r(L), m();
1052
- }, F), p = null;
1052
+ }, P), p = null;
1053
1053
  }
1054
1054
  "onloadend" in p ? p.onloadend = w : p.onreadystatechange = function() {
1055
1055
  !p || p.readyState !== 4 || p.status === 0 && !(p.responseURL && p.responseURL.indexOf("file:") === 0) || setTimeout(w);
1056
1056
  }, p.onabort = function() {
1057
1057
  p && (r(new E("Request aborted", E.ECONNABORTED, e, p)), p = null);
1058
1058
  }, p.onerror = function(g) {
1059
- const F = g && g.message ? g.message : "Network Error", q = new E(F, E.ERR_NETWORK, e, p);
1060
- q.event = g || null, r(q), p = null;
1059
+ const P = g && g.message ? g.message : "Network Error", $ = new E(P, E.ERR_NETWORK, e, p);
1060
+ $.event = g || null, r($), p = null;
1061
1061
  }, p.ontimeout = function() {
1062
1062
  let g = s.timeout ? "timeout of " + s.timeout + "ms exceeded" : "timeout exceeded";
1063
- const F = s.transitional || Tt;
1063
+ const P = s.transitional || Tt;
1064
1064
  s.timeoutErrorMessage && (g = s.timeoutErrorMessage), r(new E(
1065
1065
  g,
1066
- F.clarifyTimeoutError ? E.ETIMEDOUT : E.ECONNABORTED,
1066
+ P.clarifyTimeoutError ? E.ETIMEDOUT : E.ECONNABORTED,
1067
1067
  e,
1068
1068
  p
1069
1069
  )), p = null;
1070
- }, o === void 0 && i.setContentType(null), "setRequestHeader" in p && a.forEach(i.toJSON(), function(g, F) {
1071
- p.setRequestHeader(F, g);
1070
+ }, o === void 0 && i.setContentType(null), "setRequestHeader" in p && a.forEach(i.toJSON(), function(g, P) {
1071
+ p.setRequestHeader(P, g);
1072
1072
  }), a.isUndefined(s.withCredentials) || (p.withCredentials = !!s.withCredentials), c && c !== "json" && (p.responseType = s.responseType), u && ([S, f] = he(u, !0), p.addEventListener("progress", S)), d && p.upload && ([h, b] = he(d), p.upload.addEventListener("progress", h), p.upload.addEventListener("loadend", b)), (s.cancelToken || s.signal) && (l = (R) => {
1073
1073
  p && (r(!R || R.type ? new Q(null, e, p) : R), p.abort(), p = null);
1074
1074
  }, s.cancelToken && s.cancelToken.subscribe(l), s.signal && (s.signal.aborted ? l() : s.signal.addEventListener("abort", l)));
@@ -1225,8 +1225,8 @@ const bt = (e) => {
1225
1225
  signal: I,
1226
1226
  cancelToken: R,
1227
1227
  timeout: g,
1228
- onDownloadProgress: F,
1229
- onUploadProgress: q,
1228
+ onDownloadProgress: P,
1229
+ onUploadProgress: $,
1230
1230
  responseType: L,
1231
1231
  headers: Re,
1232
1232
  withCredentials: ie = "same-origin",
@@ -1234,73 +1234,73 @@ const bt = (e) => {
1234
1234
  } = bt(f), Be = t || fetch;
1235
1235
  L = L ? (L + "").toLowerCase() : "text";
1236
1236
  let ae = Wn([I, R && R.toAbortSignal()], g), Z = null;
1237
- const $ = ae && ae.unsubscribe && (() => {
1237
+ const q = ae && ae.unsubscribe && (() => {
1238
1238
  ae.unsubscribe();
1239
1239
  });
1240
1240
  let ke;
1241
1241
  try {
1242
- if (q && u && p !== "get" && p !== "head" && (ke = await b(Re, w)) !== 0) {
1243
- let j = new n(m, {
1242
+ if ($ && u && p !== "get" && p !== "head" && (ke = await b(Re, w)) !== 0) {
1243
+ let v = new n(m, {
1244
1244
  method: "POST",
1245
1245
  body: w,
1246
1246
  duplex: "half"
1247
1247
  }), V;
1248
- if (a.isFormData(w) && (V = j.headers.get("content-type")) && Re.setContentType(V), j.body) {
1248
+ if (a.isFormData(w) && (V = v.headers.get("content-type")) && Re.setContentType(V), v.body) {
1249
1249
  const [ye, ce] = Je(
1250
1250
  ke,
1251
- he(We(q))
1251
+ he(We($))
1252
1252
  );
1253
- w = Ke(j.body, Xe, ye, ce);
1253
+ w = Ke(v.body, Xe, ye, ce);
1254
1254
  }
1255
1255
  }
1256
1256
  a.isString(ie) || (ie = ie ? "include" : "omit");
1257
- const x = o && "credentials" in n.prototype, He = {
1257
+ const B = o && "credentials" in n.prototype, He = {
1258
1258
  ...xe,
1259
1259
  signal: ae,
1260
1260
  method: p.toUpperCase(),
1261
1261
  headers: Re.normalize().toJSON(),
1262
1262
  body: w,
1263
1263
  duplex: "half",
1264
- credentials: x ? ie : void 0
1264
+ credentials: B ? ie : void 0
1265
1265
  };
1266
1266
  Z = o && new n(m, He);
1267
- let H = await (o ? Be(Z, xe) : Be(m, He));
1267
+ let j = await (o ? Be(Z, xe) : Be(m, He));
1268
1268
  const je = l && (L === "stream" || L === "response");
1269
- if (l && (F || je && $)) {
1270
- const j = {};
1269
+ if (l && (P || je && q)) {
1270
+ const v = {};
1271
1271
  ["status", "statusText", "headers"].forEach((ve) => {
1272
- j[ve] = H[ve];
1272
+ v[ve] = j[ve];
1273
1273
  });
1274
- const V = a.toFiniteNumber(H.headers.get("content-length")), [ye, ce] = F && Je(
1274
+ const V = a.toFiniteNumber(j.headers.get("content-length")), [ye, ce] = P && Je(
1275
1275
  V,
1276
- he(We(F), !0)
1276
+ he(We(P), !0)
1277
1277
  ) || [];
1278
- H = new r(
1279
- Ke(H.body, Xe, ye, () => {
1280
- ce && ce(), $ && $();
1278
+ j = new r(
1279
+ Ke(j.body, Xe, ye, () => {
1280
+ ce && ce(), q && q();
1281
1281
  }),
1282
- j
1282
+ v
1283
1283
  );
1284
1284
  }
1285
1285
  L = L || "text";
1286
- let _t = await h[a.findKey(h, L) || "text"](H, f);
1287
- return !je && $ && $(), await new Promise((j, V) => {
1288
- yt(j, V, {
1286
+ let _t = await h[a.findKey(h, L) || "text"](j, f);
1287
+ return !je && q && q(), await new Promise((v, V) => {
1288
+ yt(v, V, {
1289
1289
  data: _t,
1290
- headers: D.from(H.headers),
1291
- status: H.status,
1292
- statusText: H.statusText,
1290
+ headers: D.from(j.headers),
1291
+ status: j.status,
1292
+ statusText: j.statusText,
1293
1293
  config: f,
1294
1294
  request: Z
1295
1295
  });
1296
1296
  });
1297
- } catch (x) {
1298
- throw $ && $(), x && x.name === "TypeError" && /Load failed|fetch/i.test(x.message) ? Object.assign(
1297
+ } catch (B) {
1298
+ throw q && q(), B && B.name === "TypeError" && /Load failed|fetch/i.test(B.message) ? Object.assign(
1299
1299
  new E("Network Error", E.ERR_NETWORK, f, Z),
1300
1300
  {
1301
- cause: x.cause || x
1301
+ cause: B.cause || B
1302
1302
  }
1303
- ) : E.from(x, x && x.code, f, Z);
1303
+ ) : E.from(B, B && B.code, f, Z);
1304
1304
  }
1305
1305
  };
1306
1306
  }, Zn = /* @__PURE__ */ new Map(), Nt = (e) => {
@@ -1443,7 +1443,7 @@ function nr(e, t, n) {
1443
1443
  const de = {
1444
1444
  assertOptions: nr,
1445
1445
  validators: we
1446
- }, B = de.validators;
1446
+ }, k = de.validators;
1447
1447
  let z = class {
1448
1448
  constructor(t) {
1449
1449
  this.defaults = t || {}, this.interceptors = {
@@ -1480,17 +1480,17 @@ let z = class {
1480
1480
  typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = J(this.defaults, n);
1481
1481
  const { transitional: r, paramsSerializer: s, headers: o } = n;
1482
1482
  r !== void 0 && de.assertOptions(r, {
1483
- silentJSONParsing: B.transitional(B.boolean),
1484
- forcedJSONParsing: B.transitional(B.boolean),
1485
- clarifyTimeoutError: B.transitional(B.boolean)
1483
+ silentJSONParsing: k.transitional(k.boolean),
1484
+ forcedJSONParsing: k.transitional(k.boolean),
1485
+ clarifyTimeoutError: k.transitional(k.boolean)
1486
1486
  }, !1), s != null && (a.isFunction(s) ? n.paramsSerializer = {
1487
1487
  serialize: s
1488
1488
  } : de.assertOptions(s, {
1489
- encode: B.function,
1490
- serialize: B.function
1489
+ encode: k.function,
1490
+ serialize: k.function
1491
1491
  }, !0)), n.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? n.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : n.allowAbsoluteUrls = !0), de.assertOptions(n, {
1492
- baseUrl: B.spelling("baseURL"),
1493
- withXsrfToken: B.spelling("withXSRFToken")
1492
+ baseUrl: k.spelling("baseURL"),
1493
+ withXsrfToken: k.spelling("withXSRFToken")
1494
1494
  }, !0), n.method = (n.method || this.defaults.method || "get").toLowerCase();
1495
1495
  let i = o && a.merge(
1496
1496
  o.common,
@@ -1750,22 +1750,22 @@ T.getAdapter = Ot.getAdapter;
1750
1750
  T.HttpStatusCode = Ue;
1751
1751
  T.default = T;
1752
1752
  const {
1753
- Axios: Cr,
1754
- AxiosError: gr,
1755
- CanceledError: Ur,
1756
- isCancel: _r,
1757
- CancelToken: Dr,
1758
- VERSION: Ir,
1759
- all: Lr,
1760
- Cancel: Fr,
1761
- isAxiosError: Pr,
1762
- spread: xr,
1763
- toFormData: Br,
1764
- AxiosHeaders: kr,
1765
- HttpStatusCode: Hr,
1766
- formToJSON: jr,
1767
- getAdapter: vr,
1768
- mergeConfig: Mr
1753
+ Axios: Ur,
1754
+ AxiosError: _r,
1755
+ CanceledError: Dr,
1756
+ isCancel: Ir,
1757
+ CancelToken: Lr,
1758
+ VERSION: Fr,
1759
+ all: Pr,
1760
+ Cancel: xr,
1761
+ isAxiosError: Br,
1762
+ spread: kr,
1763
+ toFormData: Hr,
1764
+ AxiosHeaders: jr,
1765
+ HttpStatusCode: vr,
1766
+ formToJSON: Mr,
1767
+ getAdapter: $r,
1768
+ mergeConfig: qr
1769
1769
  } = T, y = {
1770
1770
  /** 未初始化 */
1771
1771
  UNINITIALIZED: {
@@ -1835,7 +1835,7 @@ const {
1835
1835
  BASE_API_URL: "https://fat-joytalk-api.halaladmin.vip",
1836
1836
  OBS_URL: "https://fat-joytalk-img.halaladmin.vip"
1837
1837
  }
1838
- }, v = {
1838
+ }, F = {
1839
1839
  api: "",
1840
1840
  download: "",
1841
1841
  ws: ""
@@ -1860,23 +1860,21 @@ function dr(e) {
1860
1860
  return e?.length ? Promise.any(e.map((t) => ur(t))) : Promise.reject(new Error("No download urls to test"));
1861
1861
  }
1862
1862
  async function Pe(e, t) {
1863
- if (v.api && v.download) return;
1863
+ if (F.api && F.download) return;
1864
1864
  if (K) return K;
1865
1865
  const n = rt[t].BASE_API_URL || "", r = rt[t].OBS_URL || "";
1866
- n || (K = Promise.reject(new Error("环境配置错误")), await K), K = (async () => {
1866
+ F.api = n, F.download = r, F.ws = n.replace(/http/g, "ws"), n || (K = Promise.reject(new Error("环境配置错误")), await K), K = (async () => {
1867
1867
  const s = await T.get(`${n.replace(/\/$/, "")}${ar}`, {
1868
1868
  headers: { Authorization: `Bearer ${e}` },
1869
1869
  timeout: 15e3
1870
1870
  });
1871
1871
  if (s.data?.code !== 200 || !s.data?.data)
1872
- throw new Error(
1873
- s.data?.message || "ListLines failed or empty data"
1874
- );
1872
+ return Promise.reject(s.data);
1875
1873
  const o = (s.data.data.api ?? []).map((h) => h.url).filter(Boolean), i = (s.data.data.download ?? []).map((h) => h.url).filter(Boolean), c = n, d = r, [u, l] = await Promise.all([
1876
1874
  o.length ? fr(o).catch(() => c) : Promise.resolve(c),
1877
1875
  i.length ? dr(i).catch(() => c) : Promise.resolve(d)
1878
1876
  ]);
1879
- v.api = u, v.download = l, v.ws = u.replace(/http/g, "ws");
1877
+ F.api = u, F.download = l, F.ws = u.replace(/http/g, "ws");
1880
1878
  })(), await K;
1881
1879
  }
1882
1880
  const W = T.create({
@@ -1885,7 +1883,7 @@ const W = T.create({
1885
1883
  W.interceptors.request.use(
1886
1884
  async (e) => {
1887
1885
  const t = new te(), n = t.config.token;
1888
- return n ? (e.headers.Authorization = `Bearer ${n}`, await Pe(n, t.config.env), e.baseURL = v.api, e) : Promise.reject(y.UNINITIALIZED);
1886
+ return n ? (e.headers.Authorization = `Bearer ${n}`, await Pe(n, t.config.env), e.baseURL = F.api, e) : Promise.reject(y.UNINITIALIZED);
1889
1887
  },
1890
1888
  (e) => Promise.reject(e)
1891
1889
  );
@@ -1893,38 +1891,47 @@ W.interceptors.response.use(
1893
1891
  (e) => e.data?.code !== 200 ? Promise.reject(e) : Promise.resolve(e.data),
1894
1892
  (e) => Promise.reject(e)
1895
1893
  );
1894
+ function hr() {
1895
+ return F.api;
1896
+ }
1896
1897
  function pe() {
1897
- return v.download;
1898
+ return F.download;
1898
1899
  }
1899
- function hr() {
1900
- return v.ws;
1900
+ function pr() {
1901
+ return F.ws;
1901
1902
  }
1902
- const pr = (e) => W.post(
1903
+ const mr = (e) => W.post(
1903
1904
  "/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",
1904
1905
  e
1905
- ), mr = async (e) => {
1906
- const t = await pe();
1906
+ ), Er = async (e) => {
1907
+ const t = pe();
1907
1908
  return T.post(`${t}`, e, {
1908
1909
  headers: {
1909
1910
  "Content-Type": "multipart/form-data"
1910
1911
  }
1911
1912
  });
1912
- }, Er = (e) => W.post(
1913
+ }, Sr = (e) => W.post(
1913
1914
  "/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",
1914
1915
  e
1915
- ), Sr = (e) => W.get(
1916
+ ), Tr = (e) => W.get(
1916
1917
  "/api/open-auth/faq/v1/FaqService/GetFaqList",
1917
1918
  {
1918
1919
  params: e
1919
1920
  }
1920
- ), Tr = () => W.get(
1921
+ ), wr = () => W.get(
1921
1922
  "/api/open-auth/user/v1/UserService/GetUserInfo"
1922
- ), wr = (e) => W.post(
1923
+ ), Rr = (e) => W.post(
1923
1924
  "/api/open-auth/user/v1/UserService/GetUserHistoryMessages",
1924
1925
  e
1925
- );
1926
- var k = /* @__PURE__ */ ((e) => (e.SEND = "1", e.WITHDRAW = "2", e.EDIT = "3", e.SYSTEM_NOTICE = "4", e.TRANSFER = "5", e.INBOUND = "6", e.REPLY = "7", e.UNBIND = "8", e))(k || {}), M = /* @__PURE__ */ ((e) => (e.TEXT = "1", e.IMAGE = "2", e.VIDEO = "3", e.FILE = "4", e.FAQ = "5", e))(M || {}), U = /* @__PURE__ */ ((e) => (e[e.CONNECT_SUCCESS = 200] = "CONNECT_SUCCESS", e[e.CONNECT_FAILED = 40001] = "CONNECT_FAILED", e[e.TRANSFER_CUSTOMER_SUCCESS = 201] = "TRANSFER_CUSTOMER_SUCCESS", e[e.TRANSFER_TO_CUSTOMER_SUCCESS = 202] = "TRANSFER_TO_CUSTOMER_SUCCESS", e[e.TRANSFER_USER_SUCCESS = 203] = "TRANSFER_USER_SUCCESS", e[e.TRANSFER_FAIL = 50001] = "TRANSFER_FAIL", e[e.MATCH_FAIL = 50002] = "MATCH_FAIL", e[e.MATCH_INFO = 50005] = "MATCH_INFO", e[e.MATCH_SUCCESS = 50006] = "MATCH_SUCCESS", e[e.RETRACT = 204] = "RETRACT", e[e.RETRACT_FAIL = 50003] = "RETRACT_FAIL", e[e.EDIT = 205] = "EDIT", e[e.EDIT_FAIL = 50004] = "EDIT_FAIL", e[e.COMMON_FAIL = 5e4] = "COMMON_FAIL", e[e.SEND_SUCCESS = 206] = "SEND_SUCCESS", e[e.SEND_CALLBACK = 207] = "SEND_CALLBACK", e[e.CHANGE_CHAT_STATUS = 208] = "CHANGE_CHAT_STATUS", e[e.REPLY_FAIL = 50008] = "REPLY_FAIL", e[e.REPLY_SUCCESS = 209] = "REPLY_SUCCESS", e[e.UNBIND_SUCCESS = 60006] = "UNBIND_SUCCESS", e[e.REMATCH = 60001] = "REMATCH", e))(U || {}), _e = /* @__PURE__ */ ((e) => (e.CUSTOMER = "1", e.USER = "2", e.ANONYMOUS = "3", e))(_e || {}), A = /* @__PURE__ */ ((e) => (e.CONNECTED = "connected", e.DISCONNECTED = "disconnected", e.ERROR = "error", e.MESSAGE = "message", e.STATUS_CHANGE = "status_change", e.HEARTBEAT_TIMEOUT = "heartbeat_timeout", e))(A || {}), O = /* @__PURE__ */ ((e) => (e.DISCONNECTED = "disconnected", e.CONNECTING = "connecting", e.CONNECTED = "connected", e.RECONNECTING = "reconnecting", e.ERROR = "error", e))(O || {}), C = /* @__PURE__ */ ((e) => (e.UNMATCHED = "1", e.MATCHING = "2", e.MATCHED = "3", e.UNBIND = "4", e))(C || {});
1927
- class Rr {
1926
+ ), yr = (e) => {
1927
+ const t = hr();
1928
+ return T.post(
1929
+ `${t}/api/open-auth/openAuth/v1/OpenAuthService/AnonymousAuth`,
1930
+ e
1931
+ );
1932
+ };
1933
+ var H = /* @__PURE__ */ ((e) => (e.SEND = "1", e.WITHDRAW = "2", e.EDIT = "3", e.SYSTEM_NOTICE = "4", e.TRANSFER = "5", e.INBOUND = "6", e.REPLY = "7", e.UNBIND = "8", e))(H || {}), M = /* @__PURE__ */ ((e) => (e.TEXT = "1", e.IMAGE = "2", e.VIDEO = "3", e.FILE = "4", e.FAQ = "5", e))(M || {}), U = /* @__PURE__ */ ((e) => (e[e.CONNECT_SUCCESS = 200] = "CONNECT_SUCCESS", e[e.CONNECT_FAILED = 40001] = "CONNECT_FAILED", e[e.TRANSFER_CUSTOMER_SUCCESS = 201] = "TRANSFER_CUSTOMER_SUCCESS", e[e.TRANSFER_TO_CUSTOMER_SUCCESS = 202] = "TRANSFER_TO_CUSTOMER_SUCCESS", e[e.TRANSFER_USER_SUCCESS = 203] = "TRANSFER_USER_SUCCESS", e[e.TRANSFER_FAIL = 50001] = "TRANSFER_FAIL", e[e.MATCH_FAIL = 50002] = "MATCH_FAIL", e[e.MATCH_INFO = 50005] = "MATCH_INFO", e[e.MATCH_SUCCESS = 50006] = "MATCH_SUCCESS", e[e.RETRACT = 204] = "RETRACT", e[e.RETRACT_FAIL = 50003] = "RETRACT_FAIL", e[e.EDIT = 205] = "EDIT", e[e.EDIT_FAIL = 50004] = "EDIT_FAIL", e[e.COMMON_FAIL = 5e4] = "COMMON_FAIL", e[e.SEND_SUCCESS = 206] = "SEND_SUCCESS", e[e.SEND_CALLBACK = 207] = "SEND_CALLBACK", e[e.CHANGE_CHAT_STATUS = 208] = "CHANGE_CHAT_STATUS", e[e.REPLY_FAIL = 50008] = "REPLY_FAIL", e[e.REPLY_SUCCESS = 209] = "REPLY_SUCCESS", e[e.UNBIND_SUCCESS = 60006] = "UNBIND_SUCCESS", e[e.REMATCH = 60001] = "REMATCH", e))(U || {}), _e = /* @__PURE__ */ ((e) => (e.CUSTOMER = "1", e.USER = "2", e.ANONYMOUS = "3", e))(_e || {}), A = /* @__PURE__ */ ((e) => (e.CONNECTED = "connected", e.DISCONNECTED = "disconnected", e.ERROR = "error", e.MESSAGE = "message", e.STATUS_CHANGE = "status_change", e.HEARTBEAT_TIMEOUT = "heartbeat_timeout", e))(A || {}), O = /* @__PURE__ */ ((e) => (e.DISCONNECTED = "disconnected", e.CONNECTING = "connecting", e.CONNECTED = "connected", e.RECONNECTING = "reconnecting", e.ERROR = "error", e))(O || {}), C = /* @__PURE__ */ ((e) => (e.UNMATCHED = "1", e.MATCHING = "2", e.MATCHED = "3", e.UNBIND = "4", e))(C || {});
1934
+ class Ar {
1928
1935
  events = /* @__PURE__ */ new Map();
1929
1936
  /**
1930
1937
  * 监听事件
@@ -1980,13 +1987,13 @@ class Rr {
1980
1987
  this.on(t, r);
1981
1988
  }
1982
1989
  }
1983
- async function yr(e, t) {
1984
- return await Pe(e, t), `${await hr()}/api/ws?Authorization=${e}`;
1990
+ async function br(e, t) {
1991
+ return await Pe(e, t), `${await pr()}/api/ws?Authorization=${e}`;
1985
1992
  }
1986
- function Ar() {
1993
+ function Nr() {
1987
1994
  return Date.now().toString(36) + Math.random().toString(36).slice(2);
1988
1995
  }
1989
- function br(e) {
1996
+ function Or(e) {
1990
1997
  return typeof e == "object" && e !== null && "data" in e && "msgType" in e && "toUid" in e && "chatType" in e && "code" in e;
1991
1998
  }
1992
1999
  function st(e) {
@@ -1995,7 +2002,7 @@ function st(e) {
1995
2002
  e.replyContent
1996
2003
  ), e.replyContent?.fileUrl?.startsWith("http") || (e.replyContent.fileUrl = t + e.replyContent.fileUrl), e.replyContent?.thumbnailUrl?.startsWith("http") || (e.replyContent.thumbnailUrl = t + e.replyContent.thumbnailUrl)), e;
1997
2004
  }
1998
- class te extends Rr {
2005
+ class te extends Ar {
1999
2006
  config = {
2000
2007
  token: "",
2001
2008
  autoReconnect: !0,
@@ -2042,7 +2049,7 @@ class te extends Rr {
2042
2049
  if (this.status !== O.CONNECTING) {
2043
2050
  this.setStatus(O.CONNECTING);
2044
2051
  try {
2045
- const s = await yr(
2052
+ const s = await br(
2046
2053
  this.config.token,
2047
2054
  this.config.env
2048
2055
  );
@@ -2079,7 +2086,7 @@ class te extends Rr {
2079
2086
  * @param msgType - 消息类型
2080
2087
  * @returns Promise<{ messageId?: string; data?: Message }>
2081
2088
  */
2082
- async sendMessage(t, n, r = k.SEND) {
2089
+ async sendMessage(t, n, r = H.SEND) {
2083
2090
  const s = {
2084
2091
  msgType: r,
2085
2092
  data: t,
@@ -2100,8 +2107,8 @@ class te extends Rr {
2100
2107
  try {
2101
2108
  if (!this.ws)
2102
2109
  throw y.DISCONNECTED;
2103
- return r === k.SEND ? new Promise((o, i) => {
2104
- const c = Ar();
2110
+ return r === H.SEND ? new Promise((o, i) => {
2111
+ const c = Nr();
2105
2112
  s.ext = c;
2106
2113
  const d = setTimeout(() => {
2107
2114
  this.off(c, u), i(y.MESSAGE_SEND_FAIL);
@@ -2122,7 +2129,7 @@ class te extends Rr {
2122
2129
  if (this.matchStatus === C.UNBIND && (await this.sendMessage(
2123
2130
  this.consultationTypeId,
2124
2131
  void 0,
2125
- k.INBOUND
2132
+ H.INBOUND
2126
2133
  ), await new Promise((t, n) => {
2127
2134
  const r = setTimeout(() => {
2128
2135
  clearTimeout(r), n(y.MESSAGE_SEND_FAIL);
@@ -2203,7 +2210,7 @@ class te extends Rr {
2203
2210
  this.lastHeartbeatTime = Date.now(), this.heartbeatTimeoutTimer && (clearTimeout(this.heartbeatTimeoutTimer), this.heartbeatTimeoutTimer = null), this.sendHeartbeat();
2204
2211
  return;
2205
2212
  }
2206
- if (t = JSON.parse(t), !!br(t))
2213
+ if (t = JSON.parse(t), !!Or(t))
2207
2214
  try {
2208
2215
  const n = t.data ? JSON.parse(t.data) : t.data;
2209
2216
  switch (t.data = n, t.code) {
@@ -2214,7 +2221,7 @@ class te extends Rr {
2214
2221
  this.matchStatus = C.MATCHING, this.sendMessage(
2215
2222
  this.consultationTypeId,
2216
2223
  void 0,
2217
- k.INBOUND
2224
+ H.INBOUND
2218
2225
  );
2219
2226
  break;
2220
2227
  // 匹配成功
@@ -2317,7 +2324,7 @@ class te extends Rr {
2317
2324
  }) {
2318
2325
  if (this.matchStatus !== C.MATCHED)
2319
2326
  return Promise.reject(y.NO_CUSTOMER_SERVICE);
2320
- const r = await wr({
2327
+ const r = await Rr({
2321
2328
  sessionId: this.sessionData?.sessionId,
2322
2329
  lastMsgId: t,
2323
2330
  size: n
@@ -2332,13 +2339,13 @@ class te extends Rr {
2332
2339
  * @returns Promise<ConsultationList>
2333
2340
  */
2334
2341
  async getConsultationList(t) {
2335
- return (await Er({ entranceId: t })).data;
2342
+ return (await Sr({ entranceId: t })).data;
2336
2343
  }
2337
2344
  handleUploadFile(t) {
2338
2345
  return new Promise(async (n, r) => {
2339
- const s = t.name.split(".").pop(), o = await pr({ ext: s || "" }), { accessKeyId: i, signature: c, policy: d, key: u } = o.data, l = new FormData();
2346
+ const s = t.name.split(".").pop(), o = await mr({ ext: s || "" }), { accessKeyId: i, signature: c, policy: d, key: u } = o.data, l = new FormData();
2340
2347
  l.append("key", u), l.append("AccessKeyId", i), l.append("signature", c), l.append("policy", d), l.append("file", t);
2341
- const h = await mr(l);
2348
+ const h = await Er(l);
2342
2349
  h.status === 204 ? n(`${u}`) : r(h.data);
2343
2350
  });
2344
2351
  }
@@ -2384,7 +2391,7 @@ class te extends Rr {
2384
2391
  async getFaqList() {
2385
2392
  if (this.matchStatus !== C.MATCHED)
2386
2393
  return Promise.reject(y.NO_CUSTOMER_SERVICE);
2387
- const t = await Sr({ id: this.sessionData?.cid });
2394
+ const t = await Tr({ id: this.sessionData?.cid });
2388
2395
  if (!t.data?.topic?.length)
2389
2396
  return;
2390
2397
  const n = {
@@ -2404,9 +2411,9 @@ class te extends Rr {
2404
2411
  customerServiceAvatar: this.sessionData?.customerAvatar,
2405
2412
  customerServiceName: this.sessionData?.customerName,
2406
2413
  createTime: Date.now(),
2407
- msgType: k.SEND
2414
+ msgType: H.SEND
2408
2415
  },
2409
- msgType: k.SEND,
2416
+ msgType: H.SEND,
2410
2417
  chatType: M.FAQ
2411
2418
  };
2412
2419
  this.emit(A.MESSAGE, r);
@@ -2420,11 +2427,11 @@ class te extends Rr {
2420
2427
  customerServiceAvatar: this.sessionData?.customerAvatar,
2421
2428
  customerServiceName: this.sessionData?.customerName,
2422
2429
  createTime: Date.now(),
2423
- msgType: k.SEND,
2430
+ msgType: H.SEND,
2424
2431
  contentType: M.FAQ,
2425
2432
  content: {}
2426
2433
  },
2427
- msgType: k.SEND,
2434
+ msgType: H.SEND,
2428
2435
  chatType: M.FAQ
2429
2436
  };
2430
2437
  if (t.isMulti)
@@ -2441,9 +2448,16 @@ class te extends Rr {
2441
2448
  async getUserInfo() {
2442
2449
  if (this.userInfo)
2443
2450
  return this.userInfo;
2444
- const t = await Tr();
2451
+ const t = await wr();
2445
2452
  return this.userInfo = t.data, this.userInfo;
2446
2453
  }
2454
+ async anonymousLogin(t, n) {
2455
+ return (await yr({
2456
+ appKey: t,
2457
+ entranceId: n,
2458
+ userSource: "H5"
2459
+ })).data;
2460
+ }
2447
2461
  }
2448
2462
  export {
2449
2463
  M as ChatType,
@@ -2452,7 +2466,7 @@ export {
2452
2466
  te as JoyTalk,
2453
2467
  C as MatchStatus,
2454
2468
  U as MessageCode,
2455
- k as MessageType,
2469
+ H as MessageType,
2456
2470
  _e as SendUserType,
2457
2471
  te as default
2458
2472
  };
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
- (function(U,X){typeof exports=="object"&&typeof module<"u"?X(exports):typeof define=="function"&&define.amd?define(["exports"],X):(U=typeof globalThis<"u"?globalThis:U||self,X(U.JoyTalk={}))})(this,(function(U){"use strict";function X(e,t){return function(){return e.apply(t,arguments)}}const{toString:Dt}=Object.prototype,{getPrototypeOf:be}=Object,{iterator:ce,toStringTag:ke}=Symbol,le=(e=>t=>{const n=Dt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>le(t)===e),ue=e=>t=>typeof t===e,{isArray:Y}=Array,Q=ue("undefined");function ne(e){return e!==null&&!Q(e)&&e.constructor!==null&&!Q(e.constructor)&&_(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const He=P("ArrayBuffer");function It(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&He(e.buffer),t}const Lt=ue("string"),_=ue("function"),je=ue("number"),re=e=>e!==null&&typeof e=="object",Ft=e=>e===!0||e===!1,fe=e=>{if(le(e)!=="object")return!1;const t=be(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ke in e)&&!(ce in e)},Pt=e=>{if(!re(e)||ne(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xt=P("Date"),Bt=P("File"),kt=P("Blob"),Ht=P("FileList"),jt=e=>re(e)&&_(e.pipe),vt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_(e.append)&&((t=le(e))==="formdata"||t==="object"&&_(e.toString)&&e.toString()==="[object FormData]"))},Mt=P("URLSearchParams"),[$t,qt,Gt,zt]=["ReadableStream","Request","Response","Headers"].map(P),Jt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function se(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),Y(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(ne(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function ve(e,t){if(ne(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Me=e=>!Q(e)&&e!==q;function Ne(){const{caseless:e,skipUndefined:t}=Me(this)&&this||{},n={},r=(s,o)=>{const i=e&&ve(n,o)||o;fe(n[i])&&fe(s)?n[i]=Ne(n[i],s):fe(s)?n[i]=Ne({},s):Y(s)?n[i]=s.slice():(!t||!Q(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&se(arguments[s],r);return n}const Wt=(e,t,n,{allOwnKeys:r}={})=>(se(t,(s,o)=>{n&&_(s)?e[o]=X(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&be(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(Y(e))return e;let t=e.length;if(!je(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&be(Uint8Array)),en=(e,t)=>{const r=(e&&e[ce]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},tn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},nn=P("HTMLFormElement"),rn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),$e=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),sn=P("RegExp"),qe=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};se(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},on=e=>{qe(e,(t,n)=>{if(_(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(_(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},an=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Y(e)?r(e):r(String(e).split(t)),n},cn=()=>{},ln=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function un(e){return!!(e&&_(e.append)&&e[ke]==="FormData"&&e[ce])}const fn=e=>{const t=new Array(10),n=(r,s)=>{if(re(r)){if(t.indexOf(r)>=0)return;if(ne(r))return r;if(!("toJSON"in r)){t[s]=r;const o=Y(r)?[]:{};return se(r,(i,c)=>{const d=n(i,s+1);!Q(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)},dn=P("AsyncFunction"),hn=e=>e&&(re(e)||_(e))&&_(e.then)&&_(e.catch),Ge=((e,t)=>e?setImmediate:t?((n,r)=>(q.addEventListener("message",({source:s,data:o})=>{s===q&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),q.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",_(q.postMessage)),pn=typeof queueMicrotask<"u"?queueMicrotask.bind(q):typeof process<"u"&&process.nextTick||Ge,a={isArray:Y,isArrayBuffer:He,isBuffer:ne,isFormData:vt,isArrayBufferView:It,isString:Lt,isNumber:je,isBoolean:Ft,isObject:re,isPlainObject:fe,isEmptyObject:Pt,isReadableStream:$t,isRequest:qt,isResponse:Gt,isHeaders:zt,isUndefined:Q,isDate:xt,isFile:Bt,isBlob:kt,isRegExp:sn,isFunction:_,isStream:jt,isURLSearchParams:Mt,isTypedArray:Zt,isFileList:Ht,forEach:se,merge:Ne,extend:Wt,trim:Jt,stripBOM:Vt,inherits:Kt,toFlatObject:Xt,kindOf:le,kindOfTest:P,endsWith:Yt,toArray:Qt,forEachEntry:en,matchAll:tn,isHTMLForm:nn,hasOwnProperty:$e,hasOwnProp:$e,reduceDescriptors:qe,freezeMethods:on,toObjectSet:an,toCamelCase:rn,noop:cn,toFiniteNumber:ln,findKey:ve,global:q,isContextDefined:Me,isSpecCompliantForm:un,toJSONObject:fn,isAsyncFn:dn,isThenable:hn,setImmediate:Ge,asap:pn,isIterable:e=>e!=null&&_(e[ce])};function E(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(E,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const ze=E.prototype,Je={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Je[e]={value:e}}),Object.defineProperties(E,Je),Object.defineProperty(ze,"isAxiosError",{value:!0}),E.from=(e,t,n,r,s,o)=>{const i=Object.create(ze);a.toFlatObject(e,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return E.call(i,c,d,n,r,s),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",o&&Object.assign(i,o),i};const mn=null;function Oe(e){return a.isPlainObject(e)||a.isArray(e)}function We(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ve(e,t,n){return e?e.concat(t).map(function(s,o){return s=We(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function En(e){return a.isArray(e)&&!e.some(Oe)}const Sn=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function de(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!a.isUndefined(p[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!d&&a.isBlob(f))throw new E("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,m,p){let w=f;if(f&&!p&&typeof f=="object"){if(a.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&En(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(w=a.toArray(f)))return m=We(m),w.forEach(function(y,I){!(a.isUndefined(y)||y===null)&&t.append(i===!0?Ve([m],I,o):i===null?m:m+"[]",u(y))}),!1}return Oe(f)?!0:(t.append(Ve(p,m,o),u(f)),!1)}const h=[],S=Object.assign(Sn,{defaultVisitor:l,convertValue:u,isVisitable:Oe});function C(f,m){if(!a.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));h.push(f),a.forEach(f,function(w,L){(!(a.isUndefined(w)||w===null)&&s.call(t,w,a.isString(L)?L.trim():L,m,S))===!0&&C(w,m?m.concat(L):[L])}),h.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return C(e),t}function Ke(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ce(e,t){this._pairs=[],e&&de(e,this,t)}const Xe=Ce.prototype;Xe.append=function(t,n){this._pairs.push([t,n])},Xe.toString=function(t){const n=t?function(r){return t.call(this,r,Ke)}:Ke;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Tn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ye(e,t,n){if(!t)return e;const r=n&&n.encode||Tn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new Ce(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Qe{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},wn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ce,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ge=typeof window<"u"&&typeof document<"u",Ue=typeof navigator=="object"&&navigator||void 0,Rn=ge&&(!Ue||["ReactNative","NativeScript","NS"].indexOf(Ue.product)<0),yn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",An=ge&&window.location.href||"http://localhost",b={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ge,hasStandardBrowserEnv:Rn,hasStandardBrowserWebWorkerEnv:yn,navigator:Ue,origin:An},Symbol.toStringTag,{value:"Module"})),...wn};function bn(e,t){return de(e,new b.classes.URLSearchParams,{visitor:function(n,r,s,o){return b.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function Nn(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function On(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function et(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=On(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(Nn(r),s,n,0)}),n}return null}function Cn(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:Ze,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(et(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return bn(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return de(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Cn(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?E.from(c,E.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:b.classes.FormData,Blob:b.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{oe.headers[e]={}});const gn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Un=e=>{const t={};let n,r,s;return e&&e.split(`
1
+ (function(U,X){typeof exports=="object"&&typeof module<"u"?X(exports):typeof define=="function"&&define.amd?define(["exports"],X):(U=typeof globalThis<"u"?globalThis:U||self,X(U.JoyTalk={}))})(this,(function(U){"use strict";function X(e,t){return function(){return e.apply(t,arguments)}}const{toString:Dt}=Object.prototype,{getPrototypeOf:be}=Object,{iterator:ce,toStringTag:ke}=Symbol,le=(e=>t=>{const n=Dt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),x=e=>(e=e.toLowerCase(),t=>le(t)===e),ue=e=>t=>typeof t===e,{isArray:Y}=Array,Q=ue("undefined");function ne(e){return e!==null&&!Q(e)&&e.constructor!==null&&!Q(e.constructor)&&_(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const He=x("ArrayBuffer");function It(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&He(e.buffer),t}const Lt=ue("string"),_=ue("function"),je=ue("number"),re=e=>e!==null&&typeof e=="object",Ft=e=>e===!0||e===!1,fe=e=>{if(le(e)!=="object")return!1;const t=be(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ke in e)&&!(ce in e)},Pt=e=>{if(!re(e)||ne(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xt=x("Date"),Bt=x("File"),kt=x("Blob"),Ht=x("FileList"),jt=e=>re(e)&&_(e.pipe),vt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_(e.append)&&((t=le(e))==="formdata"||t==="object"&&_(e.toString)&&e.toString()==="[object FormData]"))},Mt=x("URLSearchParams"),[$t,qt,Gt,zt]=["ReadableStream","Request","Response","Headers"].map(x),Jt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function se(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),Y(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(ne(e))return;const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function ve(e,t){if(ne(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Me=e=>!Q(e)&&e!==q;function Ne(){const{caseless:e,skipUndefined:t}=Me(this)&&this||{},n={},r=(s,o)=>{const i=e&&ve(n,o)||o;fe(n[i])&&fe(s)?n[i]=Ne(n[i],s):fe(s)?n[i]=Ne({},s):Y(s)?n[i]=s.slice():(!t||!Q(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&se(arguments[s],r);return n}const Wt=(e,t,n,{allOwnKeys:r}={})=>(se(t,(s,o)=>{n&&_(s)?e[o]=X(s,n):e[o]=s},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&be(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Qt=e=>{if(!e)return null;if(Y(e))return e;let t=e.length;if(!je(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&be(Uint8Array)),en=(e,t)=>{const r=(e&&e[ce]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},tn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},nn=x("HTMLFormElement"),rn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),$e=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),sn=x("RegExp"),qe=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};se(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},on=e=>{qe(e,(t,n)=>{if(_(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(_(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},an=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Y(e)?r(e):r(String(e).split(t)),n},cn=()=>{},ln=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function un(e){return!!(e&&_(e.append)&&e[ke]==="FormData"&&e[ce])}const fn=e=>{const t=new Array(10),n=(r,s)=>{if(re(r)){if(t.indexOf(r)>=0)return;if(ne(r))return r;if(!("toJSON"in r)){t[s]=r;const o=Y(r)?[]:{};return se(r,(i,c)=>{const d=n(i,s+1);!Q(d)&&(o[c]=d)}),t[s]=void 0,o}}return r};return n(e,0)},dn=x("AsyncFunction"),hn=e=>e&&(re(e)||_(e))&&_(e.then)&&_(e.catch),Ge=((e,t)=>e?setImmediate:t?((n,r)=>(q.addEventListener("message",({source:s,data:o})=>{s===q&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),q.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",_(q.postMessage)),pn=typeof queueMicrotask<"u"?queueMicrotask.bind(q):typeof process<"u"&&process.nextTick||Ge,a={isArray:Y,isArrayBuffer:He,isBuffer:ne,isFormData:vt,isArrayBufferView:It,isString:Lt,isNumber:je,isBoolean:Ft,isObject:re,isPlainObject:fe,isEmptyObject:Pt,isReadableStream:$t,isRequest:qt,isResponse:Gt,isHeaders:zt,isUndefined:Q,isDate:xt,isFile:Bt,isBlob:kt,isRegExp:sn,isFunction:_,isStream:jt,isURLSearchParams:Mt,isTypedArray:Zt,isFileList:Ht,forEach:se,merge:Ne,extend:Wt,trim:Jt,stripBOM:Vt,inherits:Kt,toFlatObject:Xt,kindOf:le,kindOfTest:x,endsWith:Yt,toArray:Qt,forEachEntry:en,matchAll:tn,isHTMLForm:nn,hasOwnProperty:$e,hasOwnProp:$e,reduceDescriptors:qe,freezeMethods:on,toObjectSet:an,toCamelCase:rn,noop:cn,toFiniteNumber:ln,findKey:ve,global:q,isContextDefined:Me,isSpecCompliantForm:un,toJSONObject:fn,isAsyncFn:dn,isThenable:hn,setImmediate:Ge,asap:pn,isIterable:e=>e!=null&&_(e[ce])};function E(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(E,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const ze=E.prototype,Je={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Je[e]={value:e}}),Object.defineProperties(E,Je),Object.defineProperty(ze,"isAxiosError",{value:!0}),E.from=(e,t,n,r,s,o)=>{const i=Object.create(ze);a.toFlatObject(e,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return E.call(i,c,d,n,r,s),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",o&&Object.assign(i,o),i};const mn=null;function Oe(e){return a.isPlainObject(e)||a.isArray(e)}function We(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ve(e,t,n){return e?e.concat(t).map(function(s,o){return s=We(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function En(e){return a.isArray(e)&&!e.some(Oe)}const Sn=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function de(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!a.isUndefined(p[m])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!d&&a.isBlob(f))throw new E("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,m,p){let w=f;if(f&&!p&&typeof f=="object"){if(a.endsWith(m,"{}"))m=r?m:m.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&En(f)||(a.isFileList(f)||a.endsWith(m,"[]"))&&(w=a.toArray(f)))return m=We(m),w.forEach(function(y,I){!(a.isUndefined(y)||y===null)&&t.append(i===!0?Ve([m],I,o):i===null?m:m+"[]",u(y))}),!1}return Oe(f)?!0:(t.append(Ve(p,m,o),u(f)),!1)}const h=[],T=Object.assign(Sn,{defaultVisitor:l,convertValue:u,isVisitable:Oe});function C(f,m){if(!a.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+m.join("."));h.push(f),a.forEach(f,function(w,F){(!(a.isUndefined(w)||w===null)&&s.call(t,w,a.isString(F)?F.trim():F,m,T))===!0&&C(w,m?m.concat(F):[F])}),h.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return C(e),t}function Ke(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ce(e,t){this._pairs=[],e&&de(e,this,t)}const Xe=Ce.prototype;Xe.append=function(t,n){this._pairs.push([t,n])},Xe.toString=function(t){const n=t?function(r){return t.call(this,r,Ke)}:Ke;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Tn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ye(e,t,n){if(!t)return e;const r=n&&n.encode||Tn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new Ce(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Qe{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},wn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ce,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ge=typeof window<"u"&&typeof document<"u",Ue=typeof navigator=="object"&&navigator||void 0,Rn=ge&&(!Ue||["ReactNative","NativeScript","NS"].indexOf(Ue.product)<0),yn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",An=ge&&window.location.href||"http://localhost",b={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ge,hasStandardBrowserEnv:Rn,hasStandardBrowserWebWorkerEnv:yn,navigator:Ue,origin:An},Symbol.toStringTag,{value:"Module"})),...wn};function bn(e,t){return de(e,new b.classes.URLSearchParams,{visitor:function(n,r,s,o){return b.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function Nn(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function On(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function et(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=On(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(Nn(r),s,n,0)}),n}return null}function Cn(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:Ze,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(et(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return bn(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return de(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Cn(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?E.from(c,E.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:b.classes.FormData,Blob:b.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{oe.headers[e]={}});const gn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Un=e=>{const t={};let n,r,s;return e&&e.split(`
2
2
  `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&gn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},tt=Symbol("internals");function ie(e){return e&&String(e).trim().toLowerCase()}function he(e){return e===!1||e==null?e:a.isArray(e)?e.map(he):String(e)}function _n(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Dn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function _e(e,t,n,r,s){if(a.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function In(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Ln(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let D=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,d,u){const l=ie(d);if(!l)throw new Error("header name must be a non-empty string");const h=a.findKey(s,l);(!h||s[h]===void 0||u===!0||u===void 0&&s[h]!==!1)&&(s[h||d]=he(c))}const i=(c,d)=>a.forEach(c,(u,l)=>o(u,l,d));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!Dn(t))i(Un(t),n);else if(a.isObject(t)&&a.isIterable(t)){let c={},d,u;for(const l of t){if(!a.isArray(l))throw TypeError("Object iterator must return a key-value pair");c[u=l[0]]=(d=c[u])?a.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}i(c,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=ie(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return _n(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=ie(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||_e(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=ie(i),i){const c=a.findKey(r,i);c&&(!n||_e(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||_e(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=he(s),delete n[o];return}const c=t?In(o):String(o).trim();c!==o&&delete n[o],n[c]=he(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[tt]=this[tt]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=ie(i);r[c]||(Ln(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(D.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),a.freezeMethods(D);function De(e,t){const n=this||oe,r=t||n,s=D.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function nt(e){return!!(e&&e.__CANCEL__)}function Z(e,t,n){E.call(this,e??"canceled",E.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(Z,E,{__CANCEL__:!0});function rt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new E("Request failed with status code "+n.status,[E.ERR_BAD_REQUEST,E.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Pn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=r[o];i||(i=u),n[s]=d,r[s]=u;let h=o,S=0;for(;h!==s;)S+=n[h++],h=h%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const C=l&&u-l;return C?Math.round(S*1e3/C):void 0}}function xn(e,t){let n=0,r=1e3/t,s,o;const i=(u,l=Date.now())=>{n=l,s=null,o&&(clearTimeout(o),o=null),e(...u)};return[(...u)=>{const l=Date.now(),h=l-n;h>=r?i(u,l):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-h)))},()=>s&&i(s)]}const pe=(e,t,n=3)=>{let r=0;const s=Pn(50,250);return xn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),l=i<=c;r=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},n)},st=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ot=e=>(...t)=>a.asap(()=>e(...t)),Bn=b.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,b.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(b.origin),b.navigator&&/(msie|trident)/i.test(b.navigator.userAgent)):()=>!0,kn=b.hasStandardBrowserEnv?{write(e,t,n,r,s,o,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&c.push(`path=${r}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Hn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function jn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function it(e,t,n){let r=!Hn(t);return e&&(r||n==!1)?jn(e,t):t}const at=e=>e instanceof D?{...e}:e;function G(e,t){t=t||{};const n={};function r(u,l,h,S){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:S},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,h,S){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,h,S)}else return r(u,l,h,S)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,h){if(h in t)return r(u,l);if(h in e)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l,h)=>s(at(u),at(l),h,!0)};return a.forEach(Object.keys({...e,...t}),function(l){const h=d[l]||s,S=h(e[l],t[l],l);a.isUndefined(S)&&h!==c||(n[l]=S)}),n}const ct=e=>{const t=G({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;if(t.headers=i=D.from(i),t.url=Ye(it(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(n)){if(b.hasStandardBrowserEnv||b.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,h])=>{u.includes(l.toLowerCase())&&i.set(l,h)})}}if(b.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Bn(t.url))){const d=s&&o&&kn.read(o);d&&i.set(s,d)}return t},vn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const s=ct(e);let o=s.data;const i=D.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,l,h,S,C,f;function m(){C&&C(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const y=D.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:y,config:e,request:p};rt(function(F){n(F),m()},function(F){r(F),m()},x),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new E("Request aborted",E.ECONNABORTED,e,p)),p=null)},p.onerror=function(I){const x=I&&I.message?I.message:"Network Error",V=new E(x,E.ERR_NETWORK,e,p);V.event=I||null,r(V),p=null},p.ontimeout=function(){let I=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const x=s.transitional||Ze;s.timeoutErrorMessage&&(I=s.timeoutErrorMessage),r(new E(I,x.clarifyTimeoutError?E.ETIMEDOUT:E.ECONNABORTED,e,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&a.forEach(i.toJSON(),function(I,x){p.setRequestHeader(x,I)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),u&&([S,f]=pe(u,!0),p.addEventListener("progress",S)),d&&p.upload&&([h,C]=pe(d),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",C)),(s.cancelToken||s.signal)&&(l=y=>{p&&(r(!y||y.type?new Z(null,e,p):y),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const L=Fn(s.url);if(L&&b.protocols.indexOf(L)===-1){r(new E("Unsupported protocol "+L+":",E.ERR_BAD_REQUEST,e));return}p.send(o||null)})},Mn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const l=u instanceof Error?u:this.reason;r.abort(l instanceof E?l:new Z(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,o(new E(`timeout ${t} of ms exceeded`,E.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},$n=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},qn=async function*(e,t){for await(const n of Gn(e))yield*$n(n,t)},Gn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},lt=(e,t,n,r)=>{const s=qn(e,t);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){c(),d.close();return}let h=l.byteLength;if(n){let S=o+=h;n(S)}d.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},ut=64*1024,{isFunction:me}=a,zn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:ft,TextEncoder:dt}=a.global,ht=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Jn=e=>{e=a.merge.call({skipUndefined:!0},zn,e);const{fetch:t,Request:n,Response:r}=e,s=t?me(t):typeof fetch=="function",o=me(n),i=me(r);if(!s)return!1;const c=s&&me(ft),d=s&&(typeof dt=="function"?(f=>m=>f.encode(m))(new dt):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=o&&c&&ht(()=>{let f=!1;const m=new n(b.origin,{body:new ft,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),l=i&&c&&ht(()=>a.isReadableStream(new r("").body)),h={stream:l&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(m,p)=>{let w=m&&m[f];if(w)return w.call(m);throw new E(`Response type '${f}' is not supported`,E.ERR_NOT_SUPPORT,p)})});const S=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new n(b.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await d(f)).byteLength},C=async(f,m)=>{const p=a.toFiniteNumber(f.getContentLength());return p??S(m)};return async f=>{let{url:m,method:p,data:w,signal:L,cancelToken:y,timeout:I,onDownloadProgress:x,onUploadProgress:V,responseType:F,headers:xe,withCredentials:Re="same-origin",fetchOptions:bt}=ct(f),Nt=t||fetch;F=F?(F+"").toLowerCase():"text";let ye=Mn([L,y&&y.toAbortSignal()],I),ae=null;const K=ye&&ye.unsubscribe&&(()=>{ye.unsubscribe()});let Ot;try{if(V&&u&&p!=="get"&&p!=="head"&&(Ot=await C(xe,w))!==0){let $=new n(m,{method:"POST",body:w,duplex:"half"}),te;if(a.isFormData(w)&&(te=$.headers.get("content-type"))&&xe.setContentType(te),$.body){const[Be,Ae]=st(Ot,pe(ot(V)));w=lt($.body,ut,Be,Ae)}}a.isString(Re)||(Re=Re?"include":"omit");const H=o&&"credentials"in n.prototype,Ct={...bt,signal:ye,method:p.toUpperCase(),headers:xe.normalize().toJSON(),body:w,duplex:"half",credentials:H?Re:void 0};ae=o&&new n(m,Ct);let M=await(o?Nt(ae,bt):Nt(m,Ct));const gt=l&&(F==="stream"||F==="response");if(l&&(x||gt&&K)){const $={};["status","statusText","headers"].forEach(Ut=>{$[Ut]=M[Ut]});const te=a.toFiniteNumber(M.headers.get("content-length")),[Be,Ae]=x&&st(te,pe(ot(x),!0))||[];M=new r(lt(M.body,ut,Be,()=>{Ae&&Ae(),K&&K()}),$)}F=F||"text";let Tr=await h[a.findKey(h,F)||"text"](M,f);return!gt&&K&&K(),await new Promise(($,te)=>{rt($,te,{data:Tr,headers:D.from(M.headers),status:M.status,statusText:M.statusText,config:f,request:ae})})}catch(H){throw K&&K(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new E("Network Error",E.ERR_NETWORK,f,ae),{cause:H.cause||H}):E.from(H,H&&H.code,f,ae)}}},Wn=new Map,pt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,o=[r,s,n];let i=o.length,c=i,d,u,l=Wn;for(;c--;)d=o[c],u=l.get(d),u===void 0&&l.set(d,u=c?new Map:Jn(t)),l=u;return u};pt();const Ie={http:mn,xhr:vn,fetch:{get:pt}};a.forEach(Ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const mt=e=>`- ${e}`,Vn=e=>a.isFunction(e)||e===null||e===!1;function Kn(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const o={};for(let i=0;i<n;i++){r=e[i];let c;if(s=r,!Vn(r)&&(s=Ie[(c=String(r)).toLowerCase()],s===void 0))throw new E(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[tt]=this[tt]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=ie(i);r[c]||(Ln(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(D.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),a.freezeMethods(D);function De(e,t){const n=this||oe,r=t||n,s=D.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function nt(e){return!!(e&&e.__CANCEL__)}function Z(e,t,n){E.call(this,e??"canceled",E.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(Z,E,{__CANCEL__:!0});function rt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new E("Request failed with status code "+n.status,[E.ERR_BAD_REQUEST,E.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Fn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Pn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=r[o];i||(i=u),n[s]=d,r[s]=u;let h=o,T=0;for(;h!==s;)T+=n[h++],h=h%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const C=l&&u-l;return C?Math.round(T*1e3/C):void 0}}function xn(e,t){let n=0,r=1e3/t,s,o;const i=(u,l=Date.now())=>{n=l,s=null,o&&(clearTimeout(o),o=null),e(...u)};return[(...u)=>{const l=Date.now(),h=l-n;h>=r?i(u,l):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-h)))},()=>s&&i(s)]}const pe=(e,t,n=3)=>{let r=0;const s=Pn(50,250);return xn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,u=s(d),l=i<=c;r=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&l?(c-i)/u:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},n)},st=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ot=e=>(...t)=>a.asap(()=>e(...t)),Bn=b.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,b.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(b.origin),b.navigator&&/(msie|trident)/i.test(b.navigator.userAgent)):()=>!0,kn=b.hasStandardBrowserEnv?{write(e,t,n,r,s,o,i){if(typeof document>"u")return;const c=[`${e}=${encodeURIComponent(t)}`];a.isNumber(n)&&c.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&c.push(`path=${r}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Hn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function jn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function it(e,t,n){let r=!Hn(t);return e&&(r||n==!1)?jn(e,t):t}const at=e=>e instanceof D?{...e}:e;function G(e,t){t=t||{};const n={};function r(u,l,h,T){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:T},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,h,T){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,h,T)}else return r(u,l,h,T)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,h){if(h in t)return r(u,l);if(h in e)return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l,h)=>s(at(u),at(l),h,!0)};return a.forEach(Object.keys({...e,...t}),function(l){const h=d[l]||s,T=h(e[l],t[l],l);a.isUndefined(T)&&h!==c||(n[l]=T)}),n}const ct=e=>{const t=G({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;if(t.headers=i=D.from(i),t.url=Ye(it(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(n)){if(b.hasStandardBrowserEnv||b.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(n.getHeaders)){const d=n.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,h])=>{u.includes(l.toLowerCase())&&i.set(l,h)})}}if(b.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Bn(t.url))){const d=s&&o&&kn.read(o);d&&i.set(s,d)}return t},vn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const s=ct(e);let o=s.data;const i=D.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:u}=s,l,h,T,C,f;function m(){C&&C(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function w(){if(!p)return;const y=D.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),B={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:y,config:e,request:p};rt(function(P){n(P),m()},function(P){r(P),m()},B),p=null}"onloadend"in p?p.onloadend=w:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(w)},p.onabort=function(){p&&(r(new E("Request aborted",E.ECONNABORTED,e,p)),p=null)},p.onerror=function(I){const B=I&&I.message?I.message:"Network Error",V=new E(B,E.ERR_NETWORK,e,p);V.event=I||null,r(V),p=null},p.ontimeout=function(){let I=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const B=s.transitional||Ze;s.timeoutErrorMessage&&(I=s.timeoutErrorMessage),r(new E(I,B.clarifyTimeoutError?E.ETIMEDOUT:E.ECONNABORTED,e,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&a.forEach(i.toJSON(),function(I,B){p.setRequestHeader(B,I)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),u&&([T,f]=pe(u,!0),p.addEventListener("progress",T)),d&&p.upload&&([h,C]=pe(d),p.upload.addEventListener("progress",h),p.upload.addEventListener("loadend",C)),(s.cancelToken||s.signal)&&(l=y=>{p&&(r(!y||y.type?new Z(null,e,p):y),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const F=Fn(s.url);if(F&&b.protocols.indexOf(F)===-1){r(new E("Unsupported protocol "+F+":",E.ERR_BAD_REQUEST,e));return}p.send(o||null)})},Mn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,c();const l=u instanceof Error?u:this.reason;r.abort(l instanceof E?l:new Z(l instanceof Error?l.message:l))}};let i=t&&setTimeout(()=>{i=null,o(new E(`timeout ${t} of ms exceeded`,E.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},$n=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},qn=async function*(e,t){for await(const n of Gn(e))yield*$n(n,t)},Gn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},lt=(e,t,n,r)=>{const s=qn(e,t);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){c(),d.close();return}let h=l.byteLength;if(n){let T=o+=h;n(T)}d.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},ut=64*1024,{isFunction:me}=a,zn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:ft,TextEncoder:dt}=a.global,ht=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Jn=e=>{e=a.merge.call({skipUndefined:!0},zn,e);const{fetch:t,Request:n,Response:r}=e,s=t?me(t):typeof fetch=="function",o=me(n),i=me(r);if(!s)return!1;const c=s&&me(ft),d=s&&(typeof dt=="function"?(f=>m=>f.encode(m))(new dt):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=o&&c&&ht(()=>{let f=!1;const m=new n(b.origin,{body:new ft,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!m}),l=i&&c&&ht(()=>a.isReadableStream(new r("").body)),h={stream:l&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(m,p)=>{let w=m&&m[f];if(w)return w.call(m);throw new E(`Response type '${f}' is not supported`,E.ERR_NOT_SUPPORT,p)})});const T=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new n(b.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await d(f)).byteLength},C=async(f,m)=>{const p=a.toFiniteNumber(f.getContentLength());return p??T(m)};return async f=>{let{url:m,method:p,data:w,signal:F,cancelToken:y,timeout:I,onDownloadProgress:B,onUploadProgress:V,responseType:P,headers:xe,withCredentials:Re="same-origin",fetchOptions:bt}=ct(f),Nt=t||fetch;P=P?(P+"").toLowerCase():"text";let ye=Mn([F,y&&y.toAbortSignal()],I),ae=null;const K=ye&&ye.unsubscribe&&(()=>{ye.unsubscribe()});let Ot;try{if(V&&u&&p!=="get"&&p!=="head"&&(Ot=await C(xe,w))!==0){let $=new n(m,{method:"POST",body:w,duplex:"half"}),te;if(a.isFormData(w)&&(te=$.headers.get("content-type"))&&xe.setContentType(te),$.body){const[Be,Ae]=st(Ot,pe(ot(V)));w=lt($.body,ut,Be,Ae)}}a.isString(Re)||(Re=Re?"include":"omit");const j=o&&"credentials"in n.prototype,Ct={...bt,signal:ye,method:p.toUpperCase(),headers:xe.normalize().toJSON(),body:w,duplex:"half",credentials:j?Re:void 0};ae=o&&new n(m,Ct);let M=await(o?Nt(ae,bt):Nt(m,Ct));const gt=l&&(P==="stream"||P==="response");if(l&&(B||gt&&K)){const $={};["status","statusText","headers"].forEach(Ut=>{$[Ut]=M[Ut]});const te=a.toFiniteNumber(M.headers.get("content-length")),[Be,Ae]=B&&st(te,pe(ot(B),!0))||[];M=new r(lt(M.body,ut,Be,()=>{Ae&&Ae(),K&&K()}),$)}P=P||"text";let Rr=await h[a.findKey(h,P)||"text"](M,f);return!gt&&K&&K(),await new Promise(($,te)=>{rt($,te,{data:Rr,headers:D.from(M.headers),status:M.status,statusText:M.statusText,config:f,request:ae})})}catch(j){throw K&&K(),j&&j.name==="TypeError"&&/Load failed|fetch/i.test(j.message)?Object.assign(new E("Network Error",E.ERR_NETWORK,f,ae),{cause:j.cause||j}):E.from(j,j&&j.code,f,ae)}}},Wn=new Map,pt=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,o=[r,s,n];let i=o.length,c=i,d,u,l=Wn;for(;c--;)d=o[c],u=l.get(d),u===void 0&&l.set(d,u=c?new Map:Jn(t)),l=u;return u};pt();const Ie={http:mn,xhr:vn,fetch:{get:pt}};a.forEach(Ie,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const mt=e=>`- ${e}`,Vn=e=>a.isFunction(e)||e===null||e===!1;function Kn(e,t){e=a.isArray(e)?e:[e];const{length:n}=e;let r,s;const o={};for(let i=0;i<n;i++){r=e[i];let c;if(s=r,!Vn(r)&&(s=Ie[(c=String(r)).toLowerCase()],s===void 0))throw new E(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(t))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let c=n?i.length>1?`since :
4
4
  `+i.map(mt).join(`
5
- `):" "+mt(i[0]):"as no adapter specified";throw new E("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Et={getAdapter:Kn,adapters:Ie};function Le(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Z(null,e)}function St(e){return Le(e),e.headers=D.from(e.headers),e.data=De.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Et.getAdapter(e.adapter||oe.adapter,e)(e).then(function(r){return Le(e),r.data=De.call(e,e.transformResponse,r),r.headers=D.from(r.headers),r},function(r){return nt(r)||(Le(e),r&&r.response&&(r.response.data=De.call(e,e.transformResponse,r.response),r.response.headers=D.from(r.response.headers))),Promise.reject(r)})}const Tt="1.13.2",Ee={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ee[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const wt={};Ee.transitional=function(t,n,r){function s(o,i){return"[Axios v"+Tt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new E(s(i," has been removed"+(n?" in "+n:"")),E.ERR_DEPRECATED);return n&&!wt[i]&&(wt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}},Ee.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Xn(e,t,n){if(typeof e!="object")throw new E("options must be an object",E.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new E("option "+o+" must be "+d,E.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new E("Unknown option "+o,E.ERR_BAD_OPTION)}}const Se={assertOptions:Xn,validators:Ee},B=Se.validators;let z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Qe,response:new Qe}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=G(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Se.assertOptions(r,{silentJSONParsing:B.transitional(B.boolean),forcedJSONParsing:B.transitional(B.boolean),clarifyTimeoutError:B.transitional(B.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:Se.assertOptions(s,{encode:B.function,serialize:B.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Se.assertOptions(n,{baseUrl:B.spelling("baseURL"),withXsrfToken:B.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),n.headers=D.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,h=0,S;if(!d){const f=[St.bind(this),void 0];for(f.unshift(...c),f.push(...u),S=f.length,l=Promise.resolve(n);h<S;)l=l.then(f[h++],f[h++]);return l}S=c.length;let C=n;for(;h<S;){const f=c[h++],m=c[h++];try{C=f(C)}catch(p){m.call(this,p);break}}try{l=St.call(this,C)}catch(f){return Promise.reject(f)}for(h=0,S=u.length;h<S;)l=l.then(u[h++],u[h++]);return l}getUri(t){t=G(this.defaults,t);const n=it(t.baseURL,t.url,t.allowAbsoluteUrls);return Ye(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){z.prototype[t]=function(n,r){return this.request(G(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(G(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}z.prototype[t]=n(),z.prototype[t+"Form"]=n(!0)});let Yn=class _t{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new Z(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new _t(function(s){t=s}),cancel:t}}};function Qn(e){return function(n){return e.apply(null,n)}}function Zn(e){return a.isObject(e)&&e.isAxiosError===!0}const Fe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Fe).forEach(([e,t])=>{Fe[t]=e});function Rt(e){const t=new z(e),n=X(z.prototype.request,t);return a.extend(n,z.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Rt(G(e,s))},n}const T=Rt(oe);T.Axios=z,T.CanceledError=Z,T.CancelToken=Yn,T.isCancel=nt,T.VERSION=Tt,T.toFormData=de,T.AxiosError=E,T.Cancel=T.CanceledError,T.all=function(t){return Promise.all(t)},T.spread=Qn,T.isAxiosError=Zn,T.mergeConfig=G,T.AxiosHeaders=D,T.formToJSON=e=>et(a.isHTMLForm(e)?new FormData(e):e),T.getAdapter=Et.getAdapter,T.HttpStatusCode=Fe,T.default=T;const{Axios:Or,AxiosError:Cr,CanceledError:gr,isCancel:Ur,CancelToken:_r,VERSION:Dr,all:Ir,Cancel:Lr,isAxiosError:Fr,spread:Pr,toFormData:xr,AxiosHeaders:Br,HttpStatusCode:kr,formToJSON:Hr,getAdapter:jr,mergeConfig:vr}=T,A={UNINITIALIZED:{code:10001,msg:"未初始化"},DISCONNECTED:{code:10002,msg:"未连接"},NO_CUSTOMER_SERVICE:{code:10003,msg:"未分配客服"},MESSAGE_SEND_FAIL:{code:10004,msg:"消息发送失败"},DATA_PARSING_ERROR:{code:10005,msg:"数据解析异常"},FILE_NOT_EXIST:{code:10006,msg:"文件不存在"},FILE_PARSING_ERROR:{code:10007,msg:"文件解析异常"},AUTH_INFO_ERROR:{code:10008,msg:"授权信息错误"},FILE_UPLOAD_FAIL:{code:10009,msg:"文件上传失败"},PARAMETER_ERROR:{code:10010,msg:"参数异常"},EMPTY_DATA:{code:10011,msg:"数据为空"}},er="/api/customer-service/customer/v1/CustomerService/TestLineLatency",tr="/api/customer-service/customer/v1/CustomerService/ListLines",nr="/pub/logo.png",yt={development:{BASE_API_URL:"http://dev-joytalk-api.halaladmin.vip",OBS_URL:"http://dev-joytalk-img.halaladmin.vip"},prodtest:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"},production:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"}},v={api:"",download:"",ws:""};let ee=null;function rr(e){const t=`${e.replace(/\/$/,"")}${er}`;return T.get(t,{timeout:1e4}).then(n=>n.data?.code!==200?Promise.reject(new Error("TestLineLatency failed")):e)}function sr(e){const t=`${e.replace(/\/$/,"")}${nr}`;return T.get(t,{timeout:1e4}).then(()=>e).catch(()=>Promise.reject(new Error("Download latency test failed")))}function or(e){return e?.length?Promise.any(e.map(t=>rr(t))):Promise.reject(new Error("No urls to test"))}function ir(e){return e?.length?Promise.any(e.map(t=>sr(t))):Promise.reject(new Error("No download urls to test"))}async function Pe(e,t){if(v.api&&v.download)return;if(ee)return ee;const n=yt[t].BASE_API_URL||"",r=yt[t].OBS_URL||"";n||(ee=Promise.reject(new Error("环境配置错误")),await ee),ee=(async()=>{const s=await T.get(`${n.replace(/\/$/,"")}${tr}`,{headers:{Authorization:`Bearer ${e}`},timeout:15e3});if(s.data?.code!==200||!s.data?.data)throw new Error(s.data?.message||"ListLines failed or empty data");const o=(s.data.data.api??[]).map(h=>h.url).filter(Boolean),i=(s.data.data.download??[]).map(h=>h.url).filter(Boolean),c=n,d=r,[u,l]=await Promise.all([o.length?or(o).catch(()=>c):Promise.resolve(c),i.length?ir(i).catch(()=>c):Promise.resolve(d)]);v.api=u,v.download=l,v.ws=u.replace(/http/g,"ws")})(),await ee}const J=T.create({timeout:6e5});J.interceptors.request.use(async e=>{const t=new W,n=t.config.token;return n?(e.headers.Authorization=`Bearer ${n}`,await Pe(n,t.config.env),e.baseURL=v.api,e):Promise.reject(A.UNINITIALIZED)},e=>Promise.reject(e)),J.interceptors.response.use(e=>e.data?.code!==200?Promise.reject(e):Promise.resolve(e.data),e=>Promise.reject(e));function Te(){return v.download}function ar(){return v.ws}const cr=e=>J.post("/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",e),lr=async e=>{const t=await Te();return T.post(`${t}`,e,{headers:{"Content-Type":"multipart/form-data"}})},ur=e=>J.post("/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",e),fr=e=>J.get("/api/open-auth/faq/v1/FaqService/GetFaqList",{params:e}),dr=()=>J.get("/api/open-auth/user/v1/UserService/GetUserInfo"),hr=e=>J.post("/api/open-auth/user/v1/UserService/GetUserHistoryMessages",e);var k=(e=>(e.SEND="1",e.WITHDRAW="2",e.EDIT="3",e.SYSTEM_NOTICE="4",e.TRANSFER="5",e.INBOUND="6",e.REPLY="7",e.UNBIND="8",e))(k||{}),j=(e=>(e.TEXT="1",e.IMAGE="2",e.VIDEO="3",e.FILE="4",e.FAQ="5",e))(j||{}),g=(e=>(e[e.CONNECT_SUCCESS=200]="CONNECT_SUCCESS",e[e.CONNECT_FAILED=40001]="CONNECT_FAILED",e[e.TRANSFER_CUSTOMER_SUCCESS=201]="TRANSFER_CUSTOMER_SUCCESS",e[e.TRANSFER_TO_CUSTOMER_SUCCESS=202]="TRANSFER_TO_CUSTOMER_SUCCESS",e[e.TRANSFER_USER_SUCCESS=203]="TRANSFER_USER_SUCCESS",e[e.TRANSFER_FAIL=50001]="TRANSFER_FAIL",e[e.MATCH_FAIL=50002]="MATCH_FAIL",e[e.MATCH_INFO=50005]="MATCH_INFO",e[e.MATCH_SUCCESS=50006]="MATCH_SUCCESS",e[e.RETRACT=204]="RETRACT",e[e.RETRACT_FAIL=50003]="RETRACT_FAIL",e[e.EDIT=205]="EDIT",e[e.EDIT_FAIL=50004]="EDIT_FAIL",e[e.COMMON_FAIL=5e4]="COMMON_FAIL",e[e.SEND_SUCCESS=206]="SEND_SUCCESS",e[e.SEND_CALLBACK=207]="SEND_CALLBACK",e[e.CHANGE_CHAT_STATUS=208]="CHANGE_CHAT_STATUS",e[e.REPLY_FAIL=50008]="REPLY_FAIL",e[e.REPLY_SUCCESS=209]="REPLY_SUCCESS",e[e.UNBIND_SUCCESS=60006]="UNBIND_SUCCESS",e[e.REMATCH=60001]="REMATCH",e))(g||{}),we=(e=>(e.CUSTOMER="1",e.USER="2",e.ANONYMOUS="3",e))(we||{}),R=(e=>(e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.ERROR="error",e.MESSAGE="message",e.STATUS_CHANGE="status_change",e.HEARTBEAT_TIMEOUT="heartbeat_timeout",e))(R||{}),N=(e=>(e.DISCONNECTED="disconnected",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ERROR="error",e))(N||{}),O=(e=>(e.UNMATCHED="1",e.MATCHING="2",e.MATCHED="3",e.UNBIND="4",e))(O||{});class pr{events=new Map;on(t,n){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n)}off(t,n){const r=this.events.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1)}}emit(t,n){const r=this.events.get(t);r&&r.forEach(s=>{try{s(n)}catch(o){console.error(`事件回调执行错误 [${t}]:`,o)}})}removeAllListeners(t){t?this.events.delete(t):this.events.clear()}once(t,n){const r=s=>{n(s),this.off(t,r)};this.on(t,r)}}async function mr(e,t){return await Pe(e,t),`${await ar()}/api/ws?Authorization=${e}`}function Er(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function Sr(e){return typeof e=="object"&&e!==null&&"data"in e&&"msgType"in e&&"toUid"in e&&"chatType"in e&&"code"in e}function At(e){const t=Te()+"/";return e.contentType!==j.TEXT&&(e.content=JSON.parse(e.content),e.content?.fileUrl?.startsWith("http")||(e.content.fileUrl=t+e.content.fileUrl),e.content?.thumbnailUrl?.startsWith("http")||(e.content.thumbnailUrl=t+e.content.thumbnailUrl)),e.replyType&&e.replyType!==j.TEXT&&typeof e.replyContent=="string"&&(e.replyContent=JSON.parse(e.replyContent),e.replyContent?.fileUrl?.startsWith("http")||(e.replyContent.fileUrl=t+e.replyContent.fileUrl),e.replyContent?.thumbnailUrl?.startsWith("http")||(e.replyContent.thumbnailUrl=t+e.replyContent.thumbnailUrl)),e}class W extends pr{config={token:"",autoReconnect:!0,reconnectInterval:3e3,maxReconnectAttempts:5,responseTimeout:1e4,env:"production"};ws=null;status=N.DISCONNECTED;reconnectTimer=null;reconnectAttempts=0;heartbeatTimeoutTimer=null;lastHeartbeatTime=0;consultationTypeId="";sessionData=null;userInfo=null;static instance=null;matchStatus=O.UNMATCHED;constructor(){if(super(),W.instance)return W.instance;W.instance=this}init(t){if(!t.token)return Promise.reject(A.PARAMETER_ERROR);Pe(t.token,t.env||"production"),this.config=Object.assign(this.config,t)}connect(t){return this.consultationTypeId=t,new Promise(async(n,r)=>{if(!this.config.token)return r(A.UNINITIALIZED);if(this.status===N.CONNECTED)return n();if(this.status!==N.CONNECTING){this.setStatus(N.CONNECTING);try{const s=await mr(this.config.token,this.config.env);this.ws=new WebSocket(s),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus(N.CONNECTED),this.emit(R.CONNECTED),n()},this.ws.onmessage=o=>{try{this.handleMessage(o.data)}catch(i){throw console.error("解析消息失败:",i),A.DATA_PARSING_ERROR}},this.ws.onerror=o=>{console.error("连接错误:",o),this.setStatus(N.ERROR),this.emit(R.ERROR,o),r(o)},this.ws.onclose=()=>{this.setStatus(N.DISCONNECTED),this.emit(R.DISCONNECTED),this.config.autoReconnect&&this.reconnectAttempts<this.config.maxReconnectAttempts&&this.scheduleReconnect()}}catch(s){this.setStatus(N.ERROR),this.emit(R.ERROR,s),r(s)}}})}disconnect(){this.config.autoReconnect=!1,this.sessionData=null,this.matchStatus=O.UNMATCHED,this.clearReconnectTimer(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus(N.DISCONNECTED)}async sendMessage(t,n,r=k.SEND){const s={msgType:r,data:t,toUid:this.sessionData?.cid,chatType:n,editId:void 0};if(this.status!==N.CONNECTED||!this.ws)if(this.ws&&this.status===N.DISCONNECTED){console.log("连接断开,尝试重新连接");try{await this.connect(this.consultationTypeId)}catch(o){throw console.error("重连失败:",o),A.DISCONNECTED}}else throw console.error(A.DISCONNECTED),A.DISCONNECTED;try{if(!this.ws)throw A.DISCONNECTED;return r===k.SEND?new Promise((o,i)=>{const c=Er();s.ext=c;const d=setTimeout(()=>{this.off(c,u),i(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout),u=l=>{clearTimeout(d),o({messageId:l,data:t})};this.once(c,u),this.ws.send(JSON.stringify(s))}):(this.ws.send(JSON.stringify(s)),{data:t})}catch(o){throw console.error("发送消息失败:",o),A.MESSAGE_SEND_FAIL}}async checkMatchStatus(){if(this.matchStatus===O.UNBIND&&(await this.sendMessage(this.consultationTypeId,void 0,k.INBOUND),await new Promise((t,n)=>{const r=setTimeout(()=>{clearTimeout(r),n(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout);this.once(R.MESSAGE,s=>{s.code===g.REMATCH&&(clearTimeout(r),t(!0))})})),this.matchStatus!==O.MATCHED)throw console.error(A.NO_CUSTOMER_SERVICE),A.NO_CUSTOMER_SERVICE}async sendText(t){return await this.checkMatchStatus(),this.sendMessage(t,j.TEXT)}async sendFile({file:t,thumbnailFile:n,chatType:r}){try{await this.checkMatchStatus();const[s,o]=await Promise.all([this.handleUploadFile(t),n?this.handleUploadFile(n):Promise.resolve(void 0)]),i={fileName:t.name,fileUrl:s,thumbnailUrl:o,fileSize:t.size},{messageId:c}=await this.sendMessage(JSON.stringify(i),r),d=Te();return{messageId:c,content:{fileName:t.name,fileUrl:`${d}/${s}`,thumbnailUrl:o?`${d}/${o}`:void 0,fileSize:t.size}}}catch(s){throw console.error("上传文件失败:",s),s}}getStatus(){return this.status}isConnected(){return this.status===N.CONNECTED}handleMessage(t){if(t==="ping"){this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.sendHeartbeat();return}if(t=JSON.parse(t),!!Sr(t))try{const n=t.data?JSON.parse(t.data):t.data;switch(t.data=n,t.code){case g.CONNECT_SUCCESS:if(this.matchStatus===O.MATCHED||this.matchStatus===O.MATCHING)return;this.matchStatus=O.MATCHING,this.sendMessage(this.consultationTypeId,void 0,k.INBOUND);break;case g.MATCH_INFO:case g.MATCH_SUCCESS:if(this.matchStatus===O.MATCHED)return;this.sessionData=t.data,this.matchStatus===O.UNBIND?(this.matchStatus=O.MATCHED,this.emit(R.MESSAGE,{...t,code:g.REMATCH})):(this.matchStatus=O.MATCHED,this.getFaqList(),this.emit(R.MESSAGE,t));break;case g.TRANSFER_USER_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;const r=t.data;this.sessionData={...this.sessionData,cid:r.cid,customerAvatar:r.customerAvatar,customerName:r.customerName,groupId:r.groupId,sessionId:r.sessionId},this.emit(R.MESSAGE,t);break;case g.SEND_SUCCESS:case g.EDIT:case g.REPLY_SUCCESS:const s=t.data;if(s.sessionId!==this.sessionData?.sessionId)return;At(s),this.emit(R.MESSAGE,t);break;case g.SEND_CALLBACK:const o=t.ext,c=t.data.messageId;this.emit(o,c);break;case g.UNBIND_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;this.matchStatus=O.UNBIND,this.sessionData=null,this.emit(R.MESSAGE,t);break;default:this.emit(R.MESSAGE,t);break}}catch(n){console.error("解析消息失败:",n)}}setStatus(t){this.status!==t&&(this.status=t,this.emit(R.STATUS_CHANGE,t))}scheduleReconnect(){this.clearReconnectTimer(),this.reconnectAttempts++,this.setStatus(N.RECONNECTING),this.reconnectTimer=setTimeout(()=>{this.connect(this.consultationTypeId).catch(t=>{console.error("重连失败:",t)})},this.config.reconnectInterval)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}sendHeartbeat(){if(!(this.status!==N.CONNECTED||!this.ws))try{this.ws.send("pong"),this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer=setTimeout(()=>{Date.now()-this.lastHeartbeatTime>=this.config.responseTimeout&&(this.emit(R.HEARTBEAT_TIMEOUT),console.warn("心跳超时,尝试重连"),this.ws&&this.ws.close())},this.config.responseTimeout)}catch(t){console.error("发送心跳失败:",t)}}async getHistoryMessages({lastMsgId:t,size:n=50}){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const r=await hr({sessionId:this.sessionData?.sessionId,lastMsgId:t,size:n}),s=r.data.list.map(o=>At(o));return{hasMore:r.data.hasMore,list:s}}async getConsultationList(t){return(await ur({entranceId:t})).data}handleUploadFile(t){return new Promise(async(n,r)=>{const s=t.name.split(".").pop(),o=await cr({ext:s||""}),{accessKeyId:i,signature:c,policy:d,key:u}=o.data,l=new FormData;l.append("key",u),l.append("AccessKeyId",i),l.append("signature",c),l.append("policy",d),l.append("file",t);const h=await lr(l);h.status===204?n(`${u}`):r(h.data)})}getVideoThumbnail=t=>new Promise((n,r)=>{const s=document.createElement("video"),o=document.createElement("canvas"),i=o.getContext("2d");if(!i){r(new Error("无法创建 canvas 上下文"));return}const c=URL.createObjectURL(t);s.preload="metadata",s.src=c,s.muted=!0,s.playsInline=!0,s.addEventListener("loadeddata",()=>{o.width=s.videoWidth,o.height=s.videoHeight,s.currentTime=0}),s.addEventListener("seeked",()=>{try{i.drawImage(s,0,0,o.width,o.height),o.toBlob(d=>{if(URL.revokeObjectURL(c),s.remove(),!d){r(A.FILE_PARSING_ERROR);return}const u=t.name.replace(/\.[^/.]+$/,"")+"_thumb.jpg",l=new File([d],u,{type:"image/jpeg",lastModified:Date.now()});n(l)},"image/jpeg",.6)}catch(d){URL.revokeObjectURL(c),s.remove(),r(d)}}),s.addEventListener("error",()=>{URL.revokeObjectURL(c),s.remove(),r(A.FILE_PARSING_ERROR)}),s.load()});async getFaqList(){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const t=await fr({id:this.sessionData?.cid});if(!t.data?.topic?.length)return;const n={guideText:t.data.guideText,list:t.data.topic.map(r=>({...r,question:r.question}))};setTimeout(()=>{const r={code:g.SEND_SUCCESS,data:{content:n,contentType:j.FAQ,sendUserType:we.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:k.SEND},msgType:k.SEND,chatType:j.FAQ};this.emit(R.MESSAGE,r)},t.data.showDelaySeconds*1e3)}sendFaq(t){const n={code:g.SEND_SUCCESS,data:{sendUserType:we.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:k.SEND,contentType:j.FAQ,content:{}},msgType:k.SEND,chatType:j.FAQ};if(t.isMulti)n.data.content={list:t.item},this.emit(R.MESSAGE,n);else{const r=t.item?.[0]||t,s=Te();r.imageUrl=r.imageUrl?.map(o=>o?.startsWith("http")?o:`${s}/${o}`),n.data.content={answer:r},this.emit(R.MESSAGE,n)}}async getUserInfo(){if(this.userInfo)return this.userInfo;const t=await dr();return this.userInfo=t.data,this.userInfo}}U.ChatType=j,U.ConnectionStatus=N,U.EventType=R,U.JoyTalk=W,U.MatchStatus=O,U.MessageCode=g,U.MessageType=k,U.SendUserType=we,U.default=W,Object.defineProperties(U,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
5
+ `):" "+mt(i[0]):"as no adapter specified";throw new E("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Et={getAdapter:Kn,adapters:Ie};function Le(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Z(null,e)}function St(e){return Le(e),e.headers=D.from(e.headers),e.data=De.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Et.getAdapter(e.adapter||oe.adapter,e)(e).then(function(r){return Le(e),r.data=De.call(e,e.transformResponse,r),r.headers=D.from(r.headers),r},function(r){return nt(r)||(Le(e),r&&r.response&&(r.response.data=De.call(e,e.transformResponse,r.response),r.response.headers=D.from(r.response.headers))),Promise.reject(r)})}const Tt="1.13.2",Ee={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ee[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const wt={};Ee.transitional=function(t,n,r){function s(o,i){return"[Axios v"+Tt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new E(s(i," has been removed"+(n?" in "+n:"")),E.ERR_DEPRECATED);return n&&!wt[i]&&(wt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}},Ee.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Xn(e,t,n){if(typeof e!="object")throw new E("options must be an object",E.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],d=c===void 0||i(c,o,e);if(d!==!0)throw new E("option "+o+" must be "+d,E.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new E("Unknown option "+o,E.ERR_BAD_OPTION)}}const Se={assertOptions:Xn,validators:Ee},k=Se.validators;let z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Qe,response:new Qe}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
+ `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=G(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Se.assertOptions(r,{silentJSONParsing:k.transitional(k.boolean),forcedJSONParsing:k.transitional(k.boolean),clarifyTimeoutError:k.transitional(k.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:Se.assertOptions(s,{encode:k.function,serialize:k.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Se.assertOptions(n,{baseUrl:k.spelling("baseURL"),withXsrfToken:k.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),n.headers=D.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,h=0,T;if(!d){const f=[St.bind(this),void 0];for(f.unshift(...c),f.push(...u),T=f.length,l=Promise.resolve(n);h<T;)l=l.then(f[h++],f[h++]);return l}T=c.length;let C=n;for(;h<T;){const f=c[h++],m=c[h++];try{C=f(C)}catch(p){m.call(this,p);break}}try{l=St.call(this,C)}catch(f){return Promise.reject(f)}for(h=0,T=u.length;h<T;)l=l.then(u[h++],u[h++]);return l}getUri(t){t=G(this.defaults,t);const n=it(t.baseURL,t.url,t.allowAbsoluteUrls);return Ye(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){z.prototype[t]=function(n,r){return this.request(G(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(G(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}z.prototype[t]=n(),z.prototype[t+"Form"]=n(!0)});let Yn=class _t{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new Z(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new _t(function(s){t=s}),cancel:t}}};function Qn(e){return function(n){return e.apply(null,n)}}function Zn(e){return a.isObject(e)&&e.isAxiosError===!0}const Fe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Fe).forEach(([e,t])=>{Fe[t]=e});function Rt(e){const t=new z(e),n=X(z.prototype.request,t);return a.extend(n,z.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Rt(G(e,s))},n}const S=Rt(oe);S.Axios=z,S.CanceledError=Z,S.CancelToken=Yn,S.isCancel=nt,S.VERSION=Tt,S.toFormData=de,S.AxiosError=E,S.Cancel=S.CanceledError,S.all=function(t){return Promise.all(t)},S.spread=Qn,S.isAxiosError=Zn,S.mergeConfig=G,S.AxiosHeaders=D,S.formToJSON=e=>et(a.isHTMLForm(e)?new FormData(e):e),S.getAdapter=Et.getAdapter,S.HttpStatusCode=Fe,S.default=S;const{Axios:gr,AxiosError:Ur,CanceledError:_r,isCancel:Dr,CancelToken:Ir,VERSION:Lr,all:Fr,Cancel:Pr,isAxiosError:xr,spread:Br,toFormData:kr,AxiosHeaders:Hr,HttpStatusCode:jr,formToJSON:vr,getAdapter:Mr,mergeConfig:$r}=S,A={UNINITIALIZED:{code:10001,msg:"未初始化"},DISCONNECTED:{code:10002,msg:"未连接"},NO_CUSTOMER_SERVICE:{code:10003,msg:"未分配客服"},MESSAGE_SEND_FAIL:{code:10004,msg:"消息发送失败"},DATA_PARSING_ERROR:{code:10005,msg:"数据解析异常"},FILE_NOT_EXIST:{code:10006,msg:"文件不存在"},FILE_PARSING_ERROR:{code:10007,msg:"文件解析异常"},AUTH_INFO_ERROR:{code:10008,msg:"授权信息错误"},FILE_UPLOAD_FAIL:{code:10009,msg:"文件上传失败"},PARAMETER_ERROR:{code:10010,msg:"参数异常"},EMPTY_DATA:{code:10011,msg:"数据为空"}},er="/api/customer-service/customer/v1/CustomerService/TestLineLatency",tr="/api/customer-service/customer/v1/CustomerService/ListLines",nr="/pub/logo.png",yt={development:{BASE_API_URL:"http://dev-joytalk-api.halaladmin.vip",OBS_URL:"http://dev-joytalk-img.halaladmin.vip"},prodtest:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"},production:{BASE_API_URL:"https://fat-joytalk-api.halaladmin.vip",OBS_URL:"https://fat-joytalk-img.halaladmin.vip"}},L={api:"",download:"",ws:""};let ee=null;function rr(e){const t=`${e.replace(/\/$/,"")}${er}`;return S.get(t,{timeout:1e4}).then(n=>n.data?.code!==200?Promise.reject(new Error("TestLineLatency failed")):e)}function sr(e){const t=`${e.replace(/\/$/,"")}${nr}`;return S.get(t,{timeout:1e4}).then(()=>e).catch(()=>Promise.reject(new Error("Download latency test failed")))}function or(e){return e?.length?Promise.any(e.map(t=>rr(t))):Promise.reject(new Error("No urls to test"))}function ir(e){return e?.length?Promise.any(e.map(t=>sr(t))):Promise.reject(new Error("No download urls to test"))}async function Pe(e,t){if(L.api&&L.download)return;if(ee)return ee;const n=yt[t].BASE_API_URL||"",r=yt[t].OBS_URL||"";L.api=n,L.download=r,L.ws=n.replace(/http/g,"ws"),n||(ee=Promise.reject(new Error("环境配置错误")),await ee),ee=(async()=>{const s=await S.get(`${n.replace(/\/$/,"")}${tr}`,{headers:{Authorization:`Bearer ${e}`},timeout:15e3});if(s.data?.code!==200||!s.data?.data)return Promise.reject(s.data);const o=(s.data.data.api??[]).map(h=>h.url).filter(Boolean),i=(s.data.data.download??[]).map(h=>h.url).filter(Boolean),c=n,d=r,[u,l]=await Promise.all([o.length?or(o).catch(()=>c):Promise.resolve(c),i.length?ir(i).catch(()=>c):Promise.resolve(d)]);L.api=u,L.download=l,L.ws=u.replace(/http/g,"ws")})(),await ee}const J=S.create({timeout:6e5});J.interceptors.request.use(async e=>{const t=new W,n=t.config.token;return n?(e.headers.Authorization=`Bearer ${n}`,await Pe(n,t.config.env),e.baseURL=L.api,e):Promise.reject(A.UNINITIALIZED)},e=>Promise.reject(e)),J.interceptors.response.use(e=>e.data?.code!==200?Promise.reject(e):Promise.resolve(e.data),e=>Promise.reject(e));function ar(){return L.api}function Te(){return L.download}function cr(){return L.ws}const lr=e=>J.post("/api/open-auth/obs/v1/ObsService/GetObsAuthInfo",e),ur=async e=>{const t=Te();return S.post(`${t}`,e,{headers:{"Content-Type":"multipart/form-data"}})},fr=e=>J.post("/api/open-auth/open_consultation/v1/OpenConsultationService/GetConsultationList",e),dr=e=>J.get("/api/open-auth/faq/v1/FaqService/GetFaqList",{params:e}),hr=()=>J.get("/api/open-auth/user/v1/UserService/GetUserInfo"),pr=e=>J.post("/api/open-auth/user/v1/UserService/GetUserHistoryMessages",e),mr=e=>{const t=ar();return S.post(`${t}/api/open-auth/openAuth/v1/OpenAuthService/AnonymousAuth`,e)};var H=(e=>(e.SEND="1",e.WITHDRAW="2",e.EDIT="3",e.SYSTEM_NOTICE="4",e.TRANSFER="5",e.INBOUND="6",e.REPLY="7",e.UNBIND="8",e))(H||{}),v=(e=>(e.TEXT="1",e.IMAGE="2",e.VIDEO="3",e.FILE="4",e.FAQ="5",e))(v||{}),g=(e=>(e[e.CONNECT_SUCCESS=200]="CONNECT_SUCCESS",e[e.CONNECT_FAILED=40001]="CONNECT_FAILED",e[e.TRANSFER_CUSTOMER_SUCCESS=201]="TRANSFER_CUSTOMER_SUCCESS",e[e.TRANSFER_TO_CUSTOMER_SUCCESS=202]="TRANSFER_TO_CUSTOMER_SUCCESS",e[e.TRANSFER_USER_SUCCESS=203]="TRANSFER_USER_SUCCESS",e[e.TRANSFER_FAIL=50001]="TRANSFER_FAIL",e[e.MATCH_FAIL=50002]="MATCH_FAIL",e[e.MATCH_INFO=50005]="MATCH_INFO",e[e.MATCH_SUCCESS=50006]="MATCH_SUCCESS",e[e.RETRACT=204]="RETRACT",e[e.RETRACT_FAIL=50003]="RETRACT_FAIL",e[e.EDIT=205]="EDIT",e[e.EDIT_FAIL=50004]="EDIT_FAIL",e[e.COMMON_FAIL=5e4]="COMMON_FAIL",e[e.SEND_SUCCESS=206]="SEND_SUCCESS",e[e.SEND_CALLBACK=207]="SEND_CALLBACK",e[e.CHANGE_CHAT_STATUS=208]="CHANGE_CHAT_STATUS",e[e.REPLY_FAIL=50008]="REPLY_FAIL",e[e.REPLY_SUCCESS=209]="REPLY_SUCCESS",e[e.UNBIND_SUCCESS=60006]="UNBIND_SUCCESS",e[e.REMATCH=60001]="REMATCH",e))(g||{}),we=(e=>(e.CUSTOMER="1",e.USER="2",e.ANONYMOUS="3",e))(we||{}),R=(e=>(e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.ERROR="error",e.MESSAGE="message",e.STATUS_CHANGE="status_change",e.HEARTBEAT_TIMEOUT="heartbeat_timeout",e))(R||{}),N=(e=>(e.DISCONNECTED="disconnected",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ERROR="error",e))(N||{}),O=(e=>(e.UNMATCHED="1",e.MATCHING="2",e.MATCHED="3",e.UNBIND="4",e))(O||{});class Er{events=new Map;on(t,n){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n)}off(t,n){const r=this.events.get(t);if(r){const s=r.indexOf(n);s>-1&&r.splice(s,1)}}emit(t,n){const r=this.events.get(t);r&&r.forEach(s=>{try{s(n)}catch(o){console.error(`事件回调执行错误 [${t}]:`,o)}})}removeAllListeners(t){t?this.events.delete(t):this.events.clear()}once(t,n){const r=s=>{n(s),this.off(t,r)};this.on(t,r)}}async function Sr(e,t){return await Pe(e,t),`${await cr()}/api/ws?Authorization=${e}`}function Tr(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function wr(e){return typeof e=="object"&&e!==null&&"data"in e&&"msgType"in e&&"toUid"in e&&"chatType"in e&&"code"in e}function At(e){const t=Te()+"/";return e.contentType!==v.TEXT&&(e.content=JSON.parse(e.content),e.content?.fileUrl?.startsWith("http")||(e.content.fileUrl=t+e.content.fileUrl),e.content?.thumbnailUrl?.startsWith("http")||(e.content.thumbnailUrl=t+e.content.thumbnailUrl)),e.replyType&&e.replyType!==v.TEXT&&typeof e.replyContent=="string"&&(e.replyContent=JSON.parse(e.replyContent),e.replyContent?.fileUrl?.startsWith("http")||(e.replyContent.fileUrl=t+e.replyContent.fileUrl),e.replyContent?.thumbnailUrl?.startsWith("http")||(e.replyContent.thumbnailUrl=t+e.replyContent.thumbnailUrl)),e}class W extends Er{config={token:"",autoReconnect:!0,reconnectInterval:3e3,maxReconnectAttempts:5,responseTimeout:1e4,env:"production"};ws=null;status=N.DISCONNECTED;reconnectTimer=null;reconnectAttempts=0;heartbeatTimeoutTimer=null;lastHeartbeatTime=0;consultationTypeId="";sessionData=null;userInfo=null;static instance=null;matchStatus=O.UNMATCHED;constructor(){if(super(),W.instance)return W.instance;W.instance=this}init(t){if(!t.token)return Promise.reject(A.PARAMETER_ERROR);Pe(t.token,t.env||"production"),this.config=Object.assign(this.config,t)}connect(t){return this.consultationTypeId=t,new Promise(async(n,r)=>{if(!this.config.token)return r(A.UNINITIALIZED);if(this.status===N.CONNECTED)return n();if(this.status!==N.CONNECTING){this.setStatus(N.CONNECTING);try{const s=await Sr(this.config.token,this.config.env);this.ws=new WebSocket(s),this.ws.onopen=()=>{this.reconnectAttempts=0,this.setStatus(N.CONNECTED),this.emit(R.CONNECTED),n()},this.ws.onmessage=o=>{try{this.handleMessage(o.data)}catch(i){throw console.error("解析消息失败:",i),A.DATA_PARSING_ERROR}},this.ws.onerror=o=>{console.error("连接错误:",o),this.setStatus(N.ERROR),this.emit(R.ERROR,o),r(o)},this.ws.onclose=()=>{this.setStatus(N.DISCONNECTED),this.emit(R.DISCONNECTED),this.config.autoReconnect&&this.reconnectAttempts<this.config.maxReconnectAttempts&&this.scheduleReconnect()}}catch(s){this.setStatus(N.ERROR),this.emit(R.ERROR,s),r(s)}}})}disconnect(){this.config.autoReconnect=!1,this.sessionData=null,this.matchStatus=O.UNMATCHED,this.clearReconnectTimer(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.setStatus(N.DISCONNECTED)}async sendMessage(t,n,r=H.SEND){const s={msgType:r,data:t,toUid:this.sessionData?.cid,chatType:n,editId:void 0};if(this.status!==N.CONNECTED||!this.ws)if(this.ws&&this.status===N.DISCONNECTED){console.log("连接断开,尝试重新连接");try{await this.connect(this.consultationTypeId)}catch(o){throw console.error("重连失败:",o),A.DISCONNECTED}}else throw console.error(A.DISCONNECTED),A.DISCONNECTED;try{if(!this.ws)throw A.DISCONNECTED;return r===H.SEND?new Promise((o,i)=>{const c=Tr();s.ext=c;const d=setTimeout(()=>{this.off(c,u),i(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout),u=l=>{clearTimeout(d),o({messageId:l,data:t})};this.once(c,u),this.ws.send(JSON.stringify(s))}):(this.ws.send(JSON.stringify(s)),{data:t})}catch(o){throw console.error("发送消息失败:",o),A.MESSAGE_SEND_FAIL}}async checkMatchStatus(){if(this.matchStatus===O.UNBIND&&(await this.sendMessage(this.consultationTypeId,void 0,H.INBOUND),await new Promise((t,n)=>{const r=setTimeout(()=>{clearTimeout(r),n(A.MESSAGE_SEND_FAIL)},this.config.responseTimeout);this.once(R.MESSAGE,s=>{s.code===g.REMATCH&&(clearTimeout(r),t(!0))})})),this.matchStatus!==O.MATCHED)throw console.error(A.NO_CUSTOMER_SERVICE),A.NO_CUSTOMER_SERVICE}async sendText(t){return await this.checkMatchStatus(),this.sendMessage(t,v.TEXT)}async sendFile({file:t,thumbnailFile:n,chatType:r}){try{await this.checkMatchStatus();const[s,o]=await Promise.all([this.handleUploadFile(t),n?this.handleUploadFile(n):Promise.resolve(void 0)]),i={fileName:t.name,fileUrl:s,thumbnailUrl:o,fileSize:t.size},{messageId:c}=await this.sendMessage(JSON.stringify(i),r),d=Te();return{messageId:c,content:{fileName:t.name,fileUrl:`${d}/${s}`,thumbnailUrl:o?`${d}/${o}`:void 0,fileSize:t.size}}}catch(s){throw console.error("上传文件失败:",s),s}}getStatus(){return this.status}isConnected(){return this.status===N.CONNECTED}handleMessage(t){if(t==="ping"){this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.sendHeartbeat();return}if(t=JSON.parse(t),!!wr(t))try{const n=t.data?JSON.parse(t.data):t.data;switch(t.data=n,t.code){case g.CONNECT_SUCCESS:if(this.matchStatus===O.MATCHED||this.matchStatus===O.MATCHING)return;this.matchStatus=O.MATCHING,this.sendMessage(this.consultationTypeId,void 0,H.INBOUND);break;case g.MATCH_INFO:case g.MATCH_SUCCESS:if(this.matchStatus===O.MATCHED)return;this.sessionData=t.data,this.matchStatus===O.UNBIND?(this.matchStatus=O.MATCHED,this.emit(R.MESSAGE,{...t,code:g.REMATCH})):(this.matchStatus=O.MATCHED,this.getFaqList(),this.emit(R.MESSAGE,t));break;case g.TRANSFER_USER_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;const r=t.data;this.sessionData={...this.sessionData,cid:r.cid,customerAvatar:r.customerAvatar,customerName:r.customerName,groupId:r.groupId,sessionId:r.sessionId},this.emit(R.MESSAGE,t);break;case g.SEND_SUCCESS:case g.EDIT:case g.REPLY_SUCCESS:const s=t.data;if(s.sessionId!==this.sessionData?.sessionId)return;At(s),this.emit(R.MESSAGE,t);break;case g.SEND_CALLBACK:const o=t.ext,c=t.data.messageId;this.emit(o,c);break;case g.UNBIND_SUCCESS:if(n.sessionId!==this.sessionData?.sessionId)return;this.matchStatus=O.UNBIND,this.sessionData=null,this.emit(R.MESSAGE,t);break;default:this.emit(R.MESSAGE,t);break}}catch(n){console.error("解析消息失败:",n)}}setStatus(t){this.status!==t&&(this.status=t,this.emit(R.STATUS_CHANGE,t))}scheduleReconnect(){this.clearReconnectTimer(),this.reconnectAttempts++,this.setStatus(N.RECONNECTING),this.reconnectTimer=setTimeout(()=>{this.connect(this.consultationTypeId).catch(t=>{console.error("重连失败:",t)})},this.config.reconnectInterval)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}sendHeartbeat(){if(!(this.status!==N.CONNECTED||!this.ws))try{this.ws.send("pong"),this.lastHeartbeatTime=Date.now(),this.heartbeatTimeoutTimer=setTimeout(()=>{Date.now()-this.lastHeartbeatTime>=this.config.responseTimeout&&(this.emit(R.HEARTBEAT_TIMEOUT),console.warn("心跳超时,尝试重连"),this.ws&&this.ws.close())},this.config.responseTimeout)}catch(t){console.error("发送心跳失败:",t)}}async getHistoryMessages({lastMsgId:t,size:n=50}){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const r=await pr({sessionId:this.sessionData?.sessionId,lastMsgId:t,size:n}),s=r.data.list.map(o=>At(o));return{hasMore:r.data.hasMore,list:s}}async getConsultationList(t){return(await fr({entranceId:t})).data}handleUploadFile(t){return new Promise(async(n,r)=>{const s=t.name.split(".").pop(),o=await lr({ext:s||""}),{accessKeyId:i,signature:c,policy:d,key:u}=o.data,l=new FormData;l.append("key",u),l.append("AccessKeyId",i),l.append("signature",c),l.append("policy",d),l.append("file",t);const h=await ur(l);h.status===204?n(`${u}`):r(h.data)})}getVideoThumbnail=t=>new Promise((n,r)=>{const s=document.createElement("video"),o=document.createElement("canvas"),i=o.getContext("2d");if(!i){r(new Error("无法创建 canvas 上下文"));return}const c=URL.createObjectURL(t);s.preload="metadata",s.src=c,s.muted=!0,s.playsInline=!0,s.addEventListener("loadeddata",()=>{o.width=s.videoWidth,o.height=s.videoHeight,s.currentTime=0}),s.addEventListener("seeked",()=>{try{i.drawImage(s,0,0,o.width,o.height),o.toBlob(d=>{if(URL.revokeObjectURL(c),s.remove(),!d){r(A.FILE_PARSING_ERROR);return}const u=t.name.replace(/\.[^/.]+$/,"")+"_thumb.jpg",l=new File([d],u,{type:"image/jpeg",lastModified:Date.now()});n(l)},"image/jpeg",.6)}catch(d){URL.revokeObjectURL(c),s.remove(),r(d)}}),s.addEventListener("error",()=>{URL.revokeObjectURL(c),s.remove(),r(A.FILE_PARSING_ERROR)}),s.load()});async getFaqList(){if(this.matchStatus!==O.MATCHED)return Promise.reject(A.NO_CUSTOMER_SERVICE);const t=await dr({id:this.sessionData?.cid});if(!t.data?.topic?.length)return;const n={guideText:t.data.guideText,list:t.data.topic.map(r=>({...r,question:r.question}))};setTimeout(()=>{const r={code:g.SEND_SUCCESS,data:{content:n,contentType:v.FAQ,sendUserType:we.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:H.SEND},msgType:H.SEND,chatType:v.FAQ};this.emit(R.MESSAGE,r)},t.data.showDelaySeconds*1e3)}sendFaq(t){const n={code:g.SEND_SUCCESS,data:{sendUserType:we.CUSTOMER,customerServiceAvatar:this.sessionData?.customerAvatar,customerServiceName:this.sessionData?.customerName,createTime:Date.now(),msgType:H.SEND,contentType:v.FAQ,content:{}},msgType:H.SEND,chatType:v.FAQ};if(t.isMulti)n.data.content={list:t.item},this.emit(R.MESSAGE,n);else{const r=t.item?.[0]||t,s=Te();r.imageUrl=r.imageUrl?.map(o=>o?.startsWith("http")?o:`${s}/${o}`),n.data.content={answer:r},this.emit(R.MESSAGE,n)}}async getUserInfo(){if(this.userInfo)return this.userInfo;const t=await hr();return this.userInfo=t.data,this.userInfo}async anonymousLogin(t,n){return(await mr({appKey:t,entranceId:n,userSource:"H5"})).data}}U.ChatType=v,U.ConnectionStatus=N,U.EventType=R,U.JoyTalk=W,U.MatchStatus=O,U.MessageCode=g,U.MessageType=H,U.SendUserType=we,U.default=W,Object.defineProperties(U,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -132,4 +132,5 @@ export default class JoyTalk extends EventEmitter {
132
132
  private getFaqList;
133
133
  sendFaq(faqItem: FaqItem): void;
134
134
  getUserInfo(): Promise<UserInfo>;
135
+ anonymousLogin(appKey: string, entranceId: string): Promise<any>;
135
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joytalk",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "JoyTalk SDK - 用于集成客服功能的 JavaScript SDK",
5
5
  "type": "module",
6
6
  "scripts": {