bw-frontend-sdk 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){return function(){return e.apply(t,arguments)}}const{toString:t}=Object.prototype,{getPrototypeOf:r}=Object,{iterator:n,toStringTag:i}=Symbol,o=(s=Object.create(null),e=>{const r=t.call(e);return s[r]||(s[r]=r.slice(8,-1).toLowerCase())});var s;const a=e=>(e=e.toLowerCase(),t=>o(t)===e),c=e=>t=>typeof t===e,{isArray:u}=Array,l=c("undefined");function h(e){return null!==e&&!l(e)&&null!==e.constructor&&!l(e.constructor)&&p(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const d=a("ArrayBuffer");const g=c("string"),p=c("function"),f=c("number"),m=e=>null!==e&&"object"==typeof e,w=e=>{if("object"!==o(e))return!1;const t=r(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||i in e||n in e)},y=a("Date"),b=a("File"),v=a("Blob"),T=a("FileList"),S=a("URLSearchParams"),[k,E,P,R]=["ReadableStream","Request","Response","Headers"].map(a);function I(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),u(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(h(e))return;const i=r?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let s;for(n=0;n<o;n++)s=i[n],t.call(null,e[s],s,e)}}function C(e,t){if(h(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,A=e=>!l(e)&&e!==O;const D=(x="undefined"!=typeof Uint8Array&&r(Uint8Array),e=>x&&e instanceof x);var x;const N=a("HTMLFormElement"),L=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),_=a("RegExp"),U=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};I(r,(r,i)=>{let o;!1!==(o=t(r,i,e))&&(n[i]=o||r)}),Object.defineProperties(e,n)};const F=a("AsyncFunction"),j=(B="function"==typeof setImmediate,M=p(O.postMessage),B?setImmediate:M?(z=`axios@${Math.random()}`,K=[],O.addEventListener("message",({source:e,data:t})=>{e===O&&t===z&&K.length&&K.shift()()},!1),e=>{K.push(e),O.postMessage(z,"*")}):e=>setTimeout(e));var B,M,z,K;const H="undefined"!=typeof queueMicrotask?queueMicrotask.bind(O):"undefined"!=typeof process&&process.nextTick||j;var V={isArray:u,isArrayBuffer:d,isBuffer:h,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||p(e.append)&&("formdata"===(t=o(e))||"object"===t&&p(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&d(e.buffer),t},isString:g,isNumber:f,isBoolean:e=>!0===e||!1===e,isObject:m,isPlainObject:w,isEmptyObject:e=>{if(!m(e)||h(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:k,isRequest:E,isResponse:P,isHeaders:R,isUndefined:l,isDate:y,isFile:b,isBlob:v,isRegExp:_,isFunction:p,isStream:e=>m(e)&&p(e.pipe),isURLSearchParams:S,isTypedArray:D,isFileList:T,forEach:I,merge:function e(){const{caseless:t}=A(this)&&this||{},r={},n=(n,i)=>{const o=t&&C(r,i)||i;w(r[o])&&w(n)?r[o]=e(r[o],n):w(n)?r[o]=e({},n):u(n)?r[o]=n.slice():r[o]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&I(arguments[e],n);return r},extend:(t,r,n,{allOwnKeys:i}={})=>(I(r,(r,i)=>{n&&p(r)?t[i]=e(r,n):t[i]=r},{allOwnKeys:i}),t),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,n,i)=>{let o,s,a;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],i&&!i(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&r(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:o,kindOfTest:a,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(u(e))return e;let t=e.length;if(!f(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[n]).call(e);let i;for(;(i=r.next())&&!i.done;){const r=i.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:N,hasOwnProperty:L,hasOwnProp:L,reduceDescriptors:U,freezeMethods:e=>{U(e,(t,r)=>{if(p(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];p(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))})},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach(e=>{r[e]=!0})};return u(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:C,global:O,isContextDefined:A,isSpecCompliantForm:function(e){return!!(e&&p(e.append)&&"FormData"===e[i]&&e[n])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(m(e)){if(t.indexOf(e)>=0)return;if(h(e))return e;if(!("toJSON"in e)){t[n]=e;const i=u(e)?[]:{};return I(e,(e,t)=>{const o=r(e,n+1);!l(o)&&(i[t]=o)}),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:F,isThenable:e=>e&&(m(e)||p(e))&&p(e.then)&&p(e.catch),setImmediate:j,asap:H,isIterable:e=>null!=e&&p(e[n])};function Q(e,t,r,n,i){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),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}V.inherits(Q,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:V.toJSONObject(this.config),code:this.code,status:this.status}}});const $=Q.prototype,q={};["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=>{q[e]={value:e}}),Object.defineProperties(Q,q),Object.defineProperty($,"isAxiosError",{value:!0}),Q.from=(e,t,r,n,i,o)=>{const s=Object.create($);return V.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e),Q.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};function J(e){return V.isPlainObject(e)||V.isArray(e)}function W(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function X(e,t,r){return e?e.concat(t).map(function(e,t){return e=W(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}const Y=V.toFlatObject(V,{},null,function(e){return/^is[A-Z]/.test(e)});function G(e,t,r){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=V.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!V.isUndefined(t[e])})).metaTokens,i=r.visitor||u,o=r.dots,s=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(V.isDate(e))return e.toISOString();if(V.isBoolean(e))return e.toString();if(!a&&V.isBlob(e))throw new Q("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(e)||V.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,r,i){let a=e;if(e&&!i&&"object"==typeof e)if(V.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(V.isArray(e)&&function(e){return V.isArray(e)&&!e.some(J)}(e)||(V.isFileList(e)||V.endsWith(r,"[]"))&&(a=V.toArray(e)))return r=W(r),a.forEach(function(e,n){!V.isUndefined(e)&&null!==e&&t.append(!0===s?X([r],n,o):null===s?r:r+"[]",c(e))}),!1;return!!J(e)||(t.append(X(i,r,o),c(e)),!1)}const l=[],h=Object.assign(Y,{defaultVisitor:u,convertValue:c,isVisitable:J});if(!V.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!V.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),V.forEach(r,function(r,o){!0===(!(V.isUndefined(r)||null===r)&&i.call(t,r,V.isString(o)?o.trim():o,n,h))&&e(r,n?n.concat(o):[o])}),l.pop()}}(e),t}function Z(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ee(e,t){this._pairs=[],e&&G(e,this,t)}const te=ee.prototype;function re(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ne(e,t,r){if(!t)return e;const n=r&&r.encode||re;V.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let o;if(o=i?i(t,r):V.isURLSearchParams(t)?t.toString():new ee(t,r).toString(n),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}te.append=function(e,t){this._pairs.push([e,t])},te.toString=function(e){const t=e?function(t){return e.call(this,t,Z)}:Z;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ie=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){V.forEach(this.handlers,function(t){null!==t&&e(t)})}},oe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},se={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ee,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ae="undefined"!=typeof window&&"undefined"!=typeof document,ce="object"==typeof navigator&&navigator||void 0,ue=ae&&(!ce||["ReactNative","NativeScript","NS"].indexOf(ce.product)<0),le="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,he=ae&&window.location.href||"http://localhost";var de={...Object.freeze({__proto__:null,hasBrowserEnv:ae,hasStandardBrowserWebWorkerEnv:le,hasStandardBrowserEnv:ue,navigator:ce,origin:he}),...se};function ge(e){function t(e,r,n,i){let o=e[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=e.length;if(o=!o&&V.isArray(n)?n.length:o,a)return V.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r,!s;n[o]&&V.isObject(n[o])||(n[o]=[]);return t(e,r,n[o],i)&&V.isArray(n[o])&&(n[o]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}(n[o])),!s}if(V.isFormData(e)&&V.isFunction(e.entries)){const r={};return V.forEachEntry(e,(e,n)=>{t(function(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,r,0)}),r}return null}const pe={transitional:oe,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=V.isObject(e);i&&V.isHTMLForm(e)&&(e=new FormData(e));if(V.isFormData(e))return n?JSON.stringify(ge(e)):e;if(V.isArrayBuffer(e)||V.isBuffer(e)||V.isStream(e)||V.isFile(e)||V.isBlob(e)||V.isReadableStream(e))return e;if(V.isArrayBufferView(e))return e.buffer;if(V.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return G(e,new de.classes.URLSearchParams,{visitor:function(e,t,r,n){return de.isNode&&V.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=V.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return G(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||pe.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(V.isResponse(e)||V.isReadableStream(e))return e;if(e&&V.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw Q.from(e,Q.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:de.classes.FormData,Blob:de.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{pe.headers[e]={}});var fe=pe;const me=V.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"]);const we=Symbol("internals");function ye(e){return e&&String(e).trim().toLowerCase()}function be(e){return!1===e||null==e?e:V.isArray(e)?e.map(be):String(e)}function ve(e,t,r,n,i){return V.isFunction(n)?n.call(this,t,r):(i&&(t=r),V.isString(t)?V.isString(n)?-1!==t.indexOf(n):V.isRegExp(n)?n.test(t):void 0:void 0)}class Te{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=ye(t);if(!i)throw new Error("header name must be a non-empty string");const o=V.findKey(n,i);(!o||void 0===n[o]||!0===r||void 0===r&&!1!==n[o])&&(n[o||t]=be(e))}const o=(e,t)=>V.forEach(e,(e,r)=>i(e,r,t));if(V.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(V.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&me[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t})(e),t);else if(V.isObject(e)&&V.isIterable(e)){let r,n,i={};for(const t of e){if(!V.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[n=t[0]]=(r=i[n])?V.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,r);return this}get(e,t){if(e=ye(e)){const r=V.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(V.isFunction(t))return t.call(this,e,r);if(V.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ye(e)){const r=V.findKey(this,e);return!(!r||void 0===this[r]||t&&!ve(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=ye(e)){const i=V.findKey(r,e);!i||t&&!ve(0,r[i],i,t)||(delete r[i],n=!0)}}return V.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!ve(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return V.forEach(this,(n,i)=>{const o=V.findKey(r,i);if(o)return t[o]=be(n),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}(i):String(i).trim();s!==i&&delete t[i],t[s]=be(n),r[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return V.forEach(this,(r,n)=>{null!=r&&!1!==r&&(t[n]=e&&V.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){const t=(this[we]=this[we]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=ye(e);t[n]||(!function(e,t){const r=V.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})})}(r,e),t[n]=!0)}return V.isArray(e)?e.forEach(n):n(e),this}}Te.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Te.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}}),V.freezeMethods(Te);var Se=Te;function ke(e,t){const r=this||fe,n=t||r,i=Se.from(n.headers);let o=n.data;return V.forEach(e,function(e){o=e.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Ee(e){return!(!e||!e.__CANCEL__)}function Pe(e,t,r){Q.call(this,null==e?"canceled":e,Q.ERR_CANCELED,t,r),this.name="CanceledError"}function Re(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new Q("Request failed with status code "+r.status,[Q.ERR_BAD_REQUEST,Q.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}V.inherits(Pe,Q,{__CANCEL__:!0});const Ie=(e,t,r=3)=>{let n=0;const i=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=n[s];i||(i=c),r[o]=a,n[o]=c;let l=s,h=0;for(;l!==o;)h+=r[l++],l%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const d=u&&c-u;return d?Math.round(1e3*h/d):void 0}}(50,250);return function(e,t){let r,n,i=0,o=1e3/t;const s=(t,o=Date.now())=>{i=o,r=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=o?s(e,t):(r=e,n||(n=setTimeout(()=>{n=null,s(r)},o-a)))},()=>r&&s(r)]}(r=>{const o=r.loaded,s=r.lengthComputable?r.total:void 0,a=o-n,c=i(a);n=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&o<=s?(s-o)/c:void 0,event:r,lengthComputable:null!=s,[t?"download":"upload"]:!0})},r)},Ce=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Oe=e=>(...t)=>V.asap(()=>e(...t));var Ae=de.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,de.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(de.origin),de.navigator&&/(msie|trident)/i.test(de.navigator.userAgent)):()=>!0,De=de.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];V.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),V.isString(n)&&s.push("path="+n),V.isString(i)&&s.push("domain="+i),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function xe(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Ne=e=>e instanceof Se?{...e}:e;function Le(e,t){t=t||{};const r={};function n(e,t,r,n){return V.isPlainObject(e)&&V.isPlainObject(t)?V.merge.call({caseless:n},e,t):V.isPlainObject(t)?V.merge({},t):V.isArray(t)?t.slice():t}function i(e,t,r,i){return V.isUndefined(t)?V.isUndefined(e)?void 0:n(void 0,e,0,i):n(e,t,0,i)}function o(e,t){if(!V.isUndefined(t))return n(void 0,t)}function s(e,t){return V.isUndefined(t)?V.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,i,o){return o in t?n(r,i):o in e?n(void 0,r):void 0}const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,r)=>i(Ne(e),Ne(t),0,!0)};return V.forEach(Object.keys({...e,...t}),function(n){const o=c[n]||i,s=o(e[n],t[n],n);V.isUndefined(s)&&o!==a||(r[n]=s)}),r}var _e=e=>{const t=Le({},e);let r,{data:n,withXSRFToken:i,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=Se.from(a),t.url=ne(xe(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),V.isFormData(n))if(de.hasStandardBrowserEnv||de.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(r=a.getContentType())){const[e,...t]=r?r.split(";").map(e=>e.trim()).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(de.hasStandardBrowserEnv&&(i&&V.isFunction(i)&&(i=i(t)),i||!1!==i&&Ae(t.url))){const e=o&&s&&De.read(s);e&&a.set(o,e)}return t};var Ue="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){const n=_e(e);let i=n.data;const o=Se.from(n.headers).normalize();let s,a,c,u,l,{responseType:h,onUploadProgress:d,onDownloadProgress:g}=n;function p(){u&&u(),l&&l(),n.cancelToken&&n.cancelToken.unsubscribe(s),n.signal&&n.signal.removeEventListener("abort",s)}let f=new XMLHttpRequest;function m(){if(!f)return;const n=Se.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());Re(function(e){t(e),p()},function(e){r(e),p()},{data:h&&"text"!==h&&"json"!==h?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:n,config:e,request:f}),f=null}f.open(n.method.toUpperCase(),n.url,!0),f.timeout=n.timeout,"onloadend"in f?f.onloadend=m:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(m)},f.onabort=function(){f&&(r(new Q("Request aborted",Q.ECONNABORTED,e,f)),f=null)},f.onerror=function(){r(new Q("Network Error",Q.ERR_NETWORK,e,f)),f=null},f.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||oe;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new Q(t,i.clarifyTimeoutError?Q.ETIMEDOUT:Q.ECONNABORTED,e,f)),f=null},void 0===i&&o.setContentType(null),"setRequestHeader"in f&&V.forEach(o.toJSON(),function(e,t){f.setRequestHeader(t,e)}),V.isUndefined(n.withCredentials)||(f.withCredentials=!!n.withCredentials),h&&"json"!==h&&(f.responseType=n.responseType),g&&([c,l]=Ie(g,!0),f.addEventListener("progress",c)),d&&f.upload&&([a,u]=Ie(d),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",u)),(n.cancelToken||n.signal)&&(s=t=>{f&&(r(!t||t.type?new Pe(null,e,f):t),f.abort(),f=null)},n.cancelToken&&n.cancelToken.subscribe(s),n.signal&&(n.signal.aborted?s():n.signal.addEventListener("abort",s)));const w=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);w&&-1===de.protocols.indexOf(w)?r(new Q("Unsupported protocol "+w+":",Q.ERR_BAD_REQUEST,e)):f.send(i||null)})};var Fe=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const i=function(e){if(!r){r=!0,s();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Q?t:new Pe(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new Q(`timeout ${t} of ms exceeded`,Q.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));const{signal:a}=n;return a.unsubscribe=()=>V.asap(s),a}};const je=function*(e,t){let r=e.byteLength;if(!t||r<t)return void(yield e);let n,i=0;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},Be=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},Me=(e,t,r,n)=>{const i=async function*(e,t){for await(const r of Be(e))yield*je(r,t)}(e,t);let o,s=0,a=e=>{o||(o=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await i.next();if(t)return a(),void e.close();let o=n.byteLength;if(r){let e=s+=o;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},ze="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Ke=ze&&"function"==typeof ReadableStream,He=ze&&("function"==typeof TextEncoder?(Ve=new TextEncoder,e=>Ve.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Ve;const Qe=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},$e=Ke&&Qe(()=>{let e=!1;const t=new Request(de.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),qe=Ke&&Qe(()=>V.isReadableStream(new Response("").body)),Je={stream:qe&&(e=>e.body)};var We;ze&&(We=new Response,["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Je[e]&&(Je[e]=V.isFunction(We[e])?t=>t[e]():(t,r)=>{throw new Q(`Response type '${e}' is not supported`,Q.ERR_NOT_SUPPORT,r)})}));const Xe=async(e,t)=>{const r=V.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(V.isBlob(e))return e.size;if(V.isSpecCompliantForm(e)){const t=new Request(de.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return V.isArrayBufferView(e)||V.isArrayBuffer(e)?e.byteLength:(V.isURLSearchParams(e)&&(e+=""),V.isString(e)?(await He(e)).byteLength:void 0)})(t):r};const Ye={http:null,xhr:Ue,fetch:ze&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:l,withCredentials:h="same-origin",fetchOptions:d}=_e(e);u=u?(u+"").toLowerCase():"text";let g,p=Fe([i,o&&o.toAbortSignal()],s);const f=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let m;try{if(c&&$e&&"get"!==r&&"head"!==r&&0!==(m=await Xe(l,n))){let e,r=new Request(t,{method:"POST",body:n,duplex:"half"});if(V.isFormData(n)&&(e=r.headers.get("content-type"))&&l.setContentType(e),r.body){const[e,t]=Ce(m,Ie(Oe(c)));n=Me(r.body,65536,e,t)}}V.isString(h)||(h=h?"include":"omit");const i="credentials"in Request.prototype;g=new Request(t,{...d,signal:p,method:r.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",credentials:i?h:void 0});let o=await fetch(g,d);const s=qe&&("stream"===u||"response"===u);if(qe&&(a||s&&f)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=o[t]});const t=V.toFiniteNumber(o.headers.get("content-length")),[r,n]=a&&Ce(t,Ie(Oe(a),!0))||[];o=new Response(Me(o.body,65536,r,()=>{n&&n(),f&&f()}),e)}u=u||"text";let w=await Je[V.findKey(Je,u)||"text"](o,e);return!s&&f&&f(),await new Promise((t,r)=>{Re(t,r,{data:w,headers:Se.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:g})})}catch(t){if(f&&f(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Q("Network Error",Q.ERR_NETWORK,e,g),{cause:t.cause||t});throw Q.from(t,t&&t.code,e,g)}})};V.forEach(Ye,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Ge=e=>`- ${e}`,Ze=e=>V.isFunction(e)||null===e||!1===e;var et=e=>{e=V.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){let t;if(r=e[o],n=r,!Ze(r)&&(n=Ye[(t=String(r)).toLowerCase()],void 0===n))throw new Q(`Unknown adapter '${t}'`);if(n)break;i[t||"#"+o]=n}if(!n){const e=Object.entries(i).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Q("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Ge).join("\n"):" "+Ge(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function tt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Pe(null,e)}function rt(e){tt(e),e.headers=Se.from(e.headers),e.data=ke.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return et(e.adapter||fe.adapter)(e).then(function(t){return tt(e),t.data=ke.call(e,e.transformResponse,t),t.headers=Se.from(t.headers),t},function(t){return Ee(t)||(tt(e),t&&t.response&&(t.response.data=ke.call(e,e.transformResponse,t.response),t.response.headers=Se.from(t.response.headers))),Promise.reject(t)})}const nt="1.11.0",it={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{it[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const ot={};it.transitional=function(e,t,r){function n(e,t){return"[Axios v"+nt+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,o)=>{if(!1===e)throw new Q(n(i," has been removed"+(t?" in "+t:"")),Q.ERR_DEPRECATED);return t&&!ot[i]&&(ot[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,o)}},it.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var st={assertOptions:function(e,t,r){if("object"!=typeof e)throw new Q("options must be an object",Q.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const t=e[o],r=void 0===t||s(t,o,e);if(!0!==r)throw new Q("option "+o+" must be "+r,Q.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new Q("Unknown option "+o,Q.ERR_BAD_OPTION)}},validators:it};const at=st.validators;class ct{constructor(e){this.defaults=e||{},this.interceptors={request:new ie,response:new ie}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Le(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;void 0!==r&&st.assertOptions(r,{silentJSONParsing:at.transitional(at.boolean),forcedJSONParsing:at.transitional(at.boolean),clarifyTimeoutError:at.transitional(at.boolean)},!1),null!=n&&(V.isFunction(n)?t.paramsSerializer={serialize:n}:st.assertOptions(n,{encode:at.function,serialize:at.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),st.assertOptions(t,{baseUrl:at.spelling("baseURL"),withXsrfToken:at.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&V.merge(i.common,i[t.method]);i&&V.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=Se.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const c=[];let u;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,h=0;if(!a){const e=[rt.bind(this),void 0];for(e.unshift(...s),e.push(...c),l=e.length,u=Promise.resolve(t);h<l;)u=u.then(e[h++],e[h++]);return u}l=s.length;let d=t;for(h=0;h<l;){const e=s[h++],t=s[h++];try{d=e(d)}catch(e){t.call(this,e);break}}try{u=rt.call(this,d)}catch(e){return Promise.reject(e)}for(h=0,l=c.length;h<l;)u=u.then(c[h++],c[h++]);return u}getUri(e){return ne(xe((e=Le(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}V.forEach(["delete","get","head","options"],function(e){ct.prototype[e]=function(t,r){return this.request(Le(r||{},{method:e,url:t,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(e){function t(t){return function(r,n,i){return this.request(Le(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ct.prototype[e]=t(),ct.prototype[e+"Form"]=t(!0)});var ut=ct;class lt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e(function(e,n,i){r.reason||(r.reason=new Pe(e,n,i),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new lt(function(t){e=t}),cancel:e}}}var ht=lt;const dt={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};Object.entries(dt).forEach(([e,t])=>{dt[t]=e});var gt=dt;const pt=function t(r){const n=new ut(r),i=e(ut.prototype.request,n);return V.extend(i,ut.prototype,n,{allOwnKeys:!0}),V.extend(i,n,null,{allOwnKeys:!0}),i.create=function(e){return t(Le(r,e))},i}(fe);pt.Axios=ut,pt.CanceledError=Pe,pt.CancelToken=ht,pt.isCancel=Ee,pt.VERSION=nt,pt.toFormData=G,pt.AxiosError=Q,pt.Cancel=pt.CanceledError,pt.all=function(e){return Promise.all(e)},pt.spread=function(e){return function(t){return e.apply(null,t)}},pt.isAxiosError=function(e){return V.isObject(e)&&!0===e.isAxiosError},pt.mergeConfig=Le,pt.AxiosHeaders=Se,pt.formToJSON=e=>ge(V.isHTMLForm(e)?new FormData(e):e),pt.getAdapter=et,pt.HttpStatusCode=gt,pt.default=pt;const ft=pt.create({timeout:1e4,headers:{"Content-Type":"application/json"}});ft.interceptors.request.use(e=>e,e=>Promise.reject(e)),ft.interceptors.response.use(e=>e,e=>Promise.reject(e));let mt=null;try{const e=require("./ua-parser");mt=e.UAParser||e.default||e}catch(e){"undefined"!=typeof window&&(mt=window.UAParser)}const wt="undefined"!=typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>Date.now();function yt(e,t,r="0"){const n=String(e);if(n.length<t){let e=n;for(let i=0;i<t-n.length;i+=1)e=r+e;return e}return n}function bt(){const e=new Date,t=parseInt(`${e.getFullYear()}${yt(e.getMonth()+1,2)}${yt(e.getDate(),2)}`,10).toString(16),r=parseInt(`${yt(e.getHours(),2)}${yt(e.getMinutes(),2)}${yt(e.getSeconds(),2)}${yt(e.getMilliseconds(),3)}`,10).toString(16);let n=t+r.length+r;for(;n.length<32;)n+=Math.floor(16*Math.random()).toString(16);return`${n.slice(0,8)}-${n.slice(8,16)}-${n.slice(16)}`}let vt=0;function Tt(){const e=Date.now().toString(36).slice(-8).padStart(8,"0");vt=(vt+1)%46656;const t=Math.floor(36*Math.random());return e+(vt.toString(36).padStart(2,"0")+t.toString(36)).padStart(4,"0").slice(-4)}const St=()=>(()=>{if("undefined"!=typeof WeixinJSBridge)return!0;var e=navigator.userAgent.toLowerCase();return!(-1===e.indexOf("micromessenger")&&"micromessenger"!=e.match(/MicroMessenger/i))})()?"WECHAT":(()=>{const e=navigator.userAgent.toLowerCase();return!(-1===e.indexOf("alipay")&&"alipay"!=e.match(/Alipay/i))})()?"ALIPAY":"OTHER",kt=e=>{const t=e.indexOf("#");if(-1===t)return"";return e.slice(t+1).replace(/^\//,"").split("?")[0]},Et=(e,t)=>["HONGSHUN"].includes(t)&&"chargeMoney"===e&&window.location.href.indexOf("showMoney=false")>-1?"EQUITY":{login:"LOGIN",buyPkgListNew:"BUY_LIST",cardDetailInfo:"CARD_DETAIL",flowSettle:"SETTLEMENT",chargeMoney:"WALLET",payOrderDetail:"ORDER_DETAIL"}[e]||e,Pt=()=>(()=>{const e=navigator.userAgent.toLowerCase();return/android|adr/.test(e)?"Android":/iphone|ipad|ipod|ios/.test(e)?"iOS":"其他"})();class Rt{constructor(e){this.config=e,this.isReporting=!1}async report(e,t){this.config.getConfig().debugSwitch&&console.log("report----------",e,t);try{const r=this.formatReportData(e,t);this.config.getConfig().customReport?await this.config.getConfig().customReport(e,r):await this.defaultReport(e,r)}catch(t){console.error("上报失败:",t),this.config.getConfig().debugSwitch&&console.error("上报失败详情:",{type:e,error:t.message,stack:t.stack})}}getDeviceInfo(){return{screen:{width:screen.width,height:screen.height,availWidth:screen.availWidth,availHeight:screen.availHeight,colorDepth:screen.colorDepth,pixelDepth:screen.pixelDepth},viewport:{width:window.innerWidth,height:window.innerHeight},connection:navigator.connection?{effectiveType:navigator.connection.effectiveType,downlink:navigator.connection.downlink,rtt:navigator.connection.rtt}:null,memory:navigator.memory?{usedJSHeapSize:navigator.memory.usedJSHeapSize,totalJSHeapSize:navigator.memory.totalJSHeapSize,jsHeapSizeLimit:navigator.memory.jsHeapSizeLimit}:null}}formatReportData(e,t){const r={sessionId:this.config.getConfig().sessionId||"",channel:St(),uiVer:this.config.getConfig().uiVersion,osType:Pt(),screenWidth:screen.width,screenHeight:screen.height,windowInnerWidth:window.innerWidth,windowInnerHeight:window.innerHeight,netType:navigator.connection?navigator.connection.effectiveType:"",tags:{customerId:this.config.getConfig().customerId,deviceId:this.config.getConfig().deviceId,deviceNo:this.config.getConfig().deviceNo,userId:this.config.getConfig().userId}},n=Array.isArray(t)?t:[t];return n.forEach(e=>{const t=Object.assign({},r.tags||{},e&&e.tags||{});Object.assign(e,r),Object.keys(t).length>0&&(e.tags=t)}),n}async defaultReport(e,t){const r=this.config.getReportUrl(),n=this.config.getThirdPartyConfig();r&&await this.reportToBackend(r,t),n&&Object.keys(n).length>0&&await this.reportToThirdParty(n,t)}async reportToBackend(e,t){if(!navigator.sendBeacon||this.isObjectOverSizeLimit(t,60))return this.config.getConfig().debugSwitch&&console.warn("浏览器不支持 sendBeacon,使用 axios"),await this.reportViaAxios(e,t);{const r=new FormData;r.append("events",JSON.stringify(t));const n=navigator.sendBeacon(e,r);if(this.config.getConfig().debugSwitch&&console.log("上报数据:",e,t),!n)return await this.reportViaAxios(e,FormData)}}async reportViaAxios(e,t){try{return(await ft.post(e,t)).data}catch(e){console.error("后端上报失败:",e)}}async reportToThirdParty(e,t){const r=[];e.baidu&&window._hmt&&r.push(this.reportToBaidu(e.baidu,t)),e.umeng&&window._um&&r.push(this.reportToUmeng(e.umeng,t)),e.sensors&&window.sensors&&r.push(this.reportToSensors(e.sensors,t)),e.tencent&&window.MTA&&r.push(this.reportToTencent(e.tencent,t)),e.custom&&r.push(this.reportToCustom(e.custom,t));try{await Promise.allSettled(r)}catch(e){console.error("第三方上报失败:",e)}}async reportToBaidu(e,t){window._hmt&&window._hmt.push(["_trackEvent",t.type,JSON.stringify(t.data)])}async reportToUmeng(e,t){window._um&&window._um.push(["track",t.type,t.data])}async reportToSensors(e,t){window.sensors&&window.sensors.track(t.type,t.data[0]||{})}async reportToTencent(e,t){window.MTA&&window.MTA.Event.stat(t.type,t.data[0]||{})}async reportToCustom(e,t){"function"==typeof e.report&&await e.report(t)}isObjectOverSizeLimit(e,t){const r=JSON.stringify(e);return(new TextEncoder).encode(r).length/1024>t}}class It{constructor(e){this.config=e,this.reporter=new Rt(e),this.errorQueue=[],this.isInitialized=!1,this.reportTimer=null,this.errorCache=new Map,this.errorCacheTimeout=5e3,this.maxCacheSize=100,this.errorFingerprint=this.createErrorFingerprint.bind(this),this.errorTimeout=null,this.resourceErrorTimeout=null,this.lastResourceError=null}createErrorFingerprint(e,t){const r=e?.message||e?.toString()||e,n=e?.stack||t.stack;return`${t.type||"unknown"}:${r}:${window.location.href}:${n?n.split("\n")[0]:""}`}isDuplicateError(e,t){const r=this.errorFingerprint(e,t),n=Date.now();if(this.cleanupErrorCache(n),this.errorCache.has(r)){if(n-this.errorCache.get(r)<this.errorCacheTimeout)return!0}if(this.errorCache.set(r,n),this.errorCache.size>this.maxCacheSize){const e=this.errorCache.keys().next().value;this.errorCache.delete(e)}return!1}cleanupErrorCache(e){for(const[t,r]of this.errorCache.entries())e-r>this.errorCacheTimeout&&this.errorCache.delete(t)}init(){if(this.isInitialized)return;const e=this.config.getConfig();(e.enableErrorTracking||e.enableResourceError)&&this.setupErrorListener(),e.enableUnhandledRejection&&this.setupUnhandledRejectionListener(),e.reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushErrorQueue()},e))}setupErrorListener(){window.addEventListener("error",e=>{e.target&&e.target!==window?this.handleResourceError(e):this.handleJavaScriptError(e)},!0)}handleJavaScriptError(e){this.errorTimeout&&clearTimeout(this.errorTimeout),this.errorTimeout=setTimeout(()=>{this.handleError(e.error||e.message,{type:"javascript",filename:e.filename,lineno:e.lineno,colno:e.colno,stack:e.error?.stack})},100)}handleResourceError(e){const t=`${e.target.tagName}:${e.target.src||e.target.href}`;this.lastResourceError!==t?(this.lastResourceError=t,this.resourceErrorTimeout&&clearTimeout(this.resourceErrorTimeout),this.resourceErrorTimeout=setTimeout(()=>{this.handleError(`Resource load failed: ${e.target.src||e.target.href}`,{type:"resource",tagName:e.target.tagName,src:e.target.src,href:e.target.href}),setTimeout(()=>{this.lastResourceError=null},2e3)},100)):this.config.getConfig().debugSwitch&&console.log("忽略重复的资源加载错误:",t)}setupUnhandledRejectionListener(){let e=null,t=null;window.addEventListener("unhandledrejection",r=>{const n=`${r.reason?.message||r.reason}:${r.reason?.stack||""}`;t!==n?(t=n,e&&clearTimeout(e),e=setTimeout(()=>{this.handleError(r.reason,{type:"unhandledrejection",stack:r.reason?.stack}),setTimeout(()=>{t=null},1e3)},100)):this.config.getConfig().debugSwitch&&console.log("忽略重复的 Promise 拒绝:",r.reason)})}handleError(e,t={}){if(this.isDuplicateError(e,t))return void(this.config.getConfig().debugSwitch&&console.log("忽略重复错误:",e?.message||e));const r=this.parseStack(e),n={message:e?.message||e?.toString()||e,stack:e?.stack||t.stack,type:t.type||"unknown",timestamp:Date.now(),url:window.location.href,userAgent:navigator.userAgent,fileName:r.fileName,lineNumber:r.lineNumber,columnNumber:r.columnNumber,functionName:r.functionName,stackFrames:r.stackFrames,...t};this.errorQueue.push(n),this.config.getConfig().debugSwitch&&console.log("errorInfo-----",n),0===this.config.getConfig().reportInterval?this.reporter.report("error",[n]):this.errorQueue.length>=this.config.getConfig().maxQueueSize&&this.flushErrorQueue()}parseStack(e){const t=e?.stack||"",r=e?.message||e?.toString()||"",n={errMessage:r,errStack:t,fileName:"",lineNumber:"",columnNumber:"",functionName:"",stackFrames:[]};if(!t)return n;try{const e=/^\s*at\s+([^(]+?)\s+\((.+?):(\d+):(\d+)\)$/,i=/^\s*at\s+(.+?):(\d+):(\d+)$/,o=/^\s*([^@]*)@(.+?):(\d+):(\d+)$/;let s=t;if(r&&t.startsWith(r))s=t.substring(r.length).replace(/^\n+/,"");else if(t.includes("\n")){const e=t.split("\n");!e[0]||e[0].trim().startsWith("at")||e[0].includes("@")||(s=e.slice(1).join("\n"))}const a=s.split("\n").filter(e=>e.trim()),c=[];for(const t of a){let r=null,n=t.match(e);n?r={functionName:n[1].trim(),fileName:n[2],lineNumber:parseInt(n[3]),columnNumber:parseInt(n[4])}:(n=t.match(i),n?r={functionName:"",fileName:n[1],lineNumber:parseInt(n[2]),columnNumber:parseInt(n[3])}:(n=t.match(o),n&&(r={functionName:n[1].trim(),fileName:n[2],lineNumber:parseInt(n[3]),columnNumber:parseInt(n[4])}))),r&&c.push(r)}if(c.length>0){const e=c[0];n.fileName=e.fileName,n.lineNumber=e.lineNumber,n.columnNumber=e.columnNumber,n.functionName=e.functionName}n.stackFrames=c}catch(e){this.config?.getConfig()?.debugSwitch&&console.warn("解析堆栈失败:",e)}return n}reportError(e,t={}){this.handleError(e,t)}flushErrorQueue(){this.errorQueue.length>0&&(this.reporter.report("error",[...this.errorQueue]),this.errorQueue=[])}destroy(){this.config.getConfig().reportInterval>0&&this.flushErrorQueue(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.isInitialized=!1}}class Ct{constructor(e){this.config=e,this.reporter=new Rt(e),this.eventQueue=[],this.isInitialized=!1,this.clickListener=null,this.pageViewListener=null,this.reportTimer=null,this.originalPushState=null,this.originalReplaceState=null,this.pageHistory=[],this.currentPage=null,this.currentPageStartTime=Date.now(),this.previousPage=null,this.previousPageStayTime=0}init(){if(this.isInitialized)return;const e=this.config.getConfig();this.currentPage={url:window.location.href,title:document.title,enterTime:Date.now(),referrer:document.referrer},this.currentPageStartTime=Date.now(),e.enableClickTracking&&this.setupClickTracking(),e.enablePageViewTracking&&this.setupPageViewTracking(),window.addEventListener("beforeunload",()=>{this.handlePageUnload()}),document.addEventListener("visibilitychange",()=>{}),this.config.getConfig().reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0}handlePageUnload(){if(this.currentPage){const e=Date.now()-this.currentPageStartTime;this.previousPage={...this.currentPage,stayTime:e,leaveTime:Date.now()},this.previousPageStayTime=e}}setupClickTracking(){this.clickListener=e=>{const t=e.target,r={type:"click",timestamp:Date.now(),url:window.location.href,element:{tagName:t.tagName,className:t.className,id:t.id,text:t.textContent?.substring(0,50)},position:{x:e.clientX,y:e.clientY}};this.handleEvent("click",r)},document.addEventListener("click",this.clickListener,!0)}setupPageViewTracking(){const e=this.config.getConfig().pageViewTracking||{};let t=window.location.href,r=Date.now();const n=e.debounce||100;this.pageViewListener=()=>{const e=window.location.href,i=Date.now();e===t&&i-r<n&&this.config.getConfig().debugSwitch?console.log("忽略重复的页面浏览事件:",e):(this.handlePageChange(e,i),t=e,r=i,this.handleEvent("pageview",{uuid:Tt(),timestamp:i,pageKey:Et(kt(e),this.config.getConfig().uiVersion),pageUri:kt(e),eventType:"VIEW"}))},!1!==e.listenPopstate&&window.addEventListener("popstate",this.pageViewListener),!1!==e.listenHistoryAPI&&(this.originalPushState=history.pushState,this.originalReplaceState=history.replaceState,history.pushState=function(...e){this.originalPushState.apply(history,e),setTimeout(()=>{this.pageViewListener()},0)}.bind(this),history.replaceState=function(...e){this.originalReplaceState.apply(history,e),setTimeout(()=>{this.pageViewListener()},0)}.bind(this)),e.vueRouterMode&&(this.config.getConfig().debugSwitch&&console.log("Vue Router 模式:页面浏览追踪已优化"),this.pageViewListener())}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushEventQueue()},e))}handlePageChange(e,t){if(this.currentPage){const r=t-this.currentPageStartTime;this.previousPage={...this.currentPage,stayTime:r,leaveTime:t},this.previousPageStayTime=r,this.pageHistory.push({...this.previousPage}),this.pageHistory.length>20&&this.pageHistory.shift(),this.config.getConfig().debugSwitch&&console.log(`页面切换: ${this.currentPage.url} → ${e},停留时间: ${r}ms`)}this.currentPage={url:e,title:document.title,enterTime:t,referrer:document.referrer},this.currentPageStartTime=t}getPreviousPageInfo(){return{previousPage:this.previousPage?{url:this.previousPage.url,title:this.previousPage.title,stayTime:this.previousPageStayTime}:null,previousPageStayTime:this.previousPageStayTime}}getCurrentPageStayTime(){return this.currentPageStartTime?Date.now()-this.currentPageStartTime:0}handleEvent(e,t){const r=this.getPreviousPageInfo(),n={...t,refer:kt(r?.previousPage?.url),duration:r?.previousPageStayTime};this.eventQueue.push(n),this.config.getConfig().debugSwitch&&console.log("eventInfo----",n),0===this.config.getConfig().reportInterval?this.reporter.report("event",[n]):this.eventQueue.length>=this.config.getConfig().maxQueueSize&&this.flushEventQueue()}reportEvent(e,t={}){const r={uuid:Tt(),timestamp:Date.now(),actionKey:e,pageKey:Et(kt(window.location.href),this.config.getConfig().uiVersion),pageUri:kt(window.location.href),eventType:"CLICK",tags:t};this.handleEvent(e,r)}flushEventQueue(){this.eventQueue.length>0&&(this.reporter.report("event",[...this.eventQueue]),this.eventQueue=[])}destroy(){this.flushEventQueue(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.clickListener&&(document.removeEventListener("click",this.clickListener,!0),this.clickListener=null),this.pageViewListener&&(window.removeEventListener("popstate",this.pageViewListener),this.pageViewListener=null),this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),this.originalReplaceState&&(history.replaceState=this.originalReplaceState,this.originalReplaceState=null),this.isInitialized=!1}}class Ot{constructor(e){this.config=e,this.reporter=new Rt(e),this.isInitialized=!1,this.pageStartTime=Date.now(),this.performanceQueue=[],this.thirdPartySDKs={},this.reportTimer=null,this.currentRoute=null,this.routeStartTime=Date.now(),this.routeHistory=[],this.vueRouter=null,this.metrics={fcp:0,lcp:0,fid:0,cls:0,ttfb:0,domLoad:0,windowLoad:0,resourceLoad:[],apiRequests:[],pageStayTime:0}}init(){if(this.isInitialized)return;const e=this.config.getConfig();e.enablePerformanceTracking&&this.setupPerformanceMonitoring(),e.enableResourceTracking&&this.setupResourceMonitoring(),e.enableInteractionTracking&&this.setupInteractionMonitoring(),this.initThirdPartySDKs(),e.reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushPerformanceQueue()},e))}setupVueRouterMonitoring(e){e&&!this.vueRouter&&(this.vueRouter=e,this.currentRoute=e.currentRoute.value,e.beforeEach((e,t,r)=>{t.name&&this.handleRouteLeave(t,e),r()}),e.afterEach((e,t)=>{this.handleRouteEnter(e,t)}),e.beforeResolve((e,t,r)=>{t.name&&this.calculateRouteStayTime(t),r()}),this.config?.config?.debugSwitch&&console.log("Vue Router 监控已设置"))}handleRouteLeave(e,t){const r=Date.now()-this.routeStartTime;this.recordRouteStayTime(e,r),this.currentRoute=e,this.routeStartTime=Date.now()}handleRouteEnter(e,t){this.routeStartTime=Date.now(),this.currentRoute=e,this.recordRouteEnter(e,t)}recordRouteStayTime(e,t){const r={name:e.name||"unknown",path:e.path,fullPath:e.fullPath,stayTime:t,enterTime:this.routeStartTime,leaveTime:Date.now(),params:e.params,query:e.query,meta:e.meta};this.routeHistory.push(r),this.metrics.pageStayTime=t,this.reportRouteStayTime(r),this.config?.config?.debugSwitch&&console.log("路由数据",r)}recordRouteEnter(e,t){e.name,e.path,e.fullPath,Date.now(),e.params,e.query,e.meta,t&&(t.name,t.path),this.config?.config?.debugSwitch&&console.log(`进入路由: ${e.name||e.path}`)}calculateRouteStayTime(e){if(!this.routeStartTime)return 0;return Date.now()-this.routeStartTime}reportRouteStayTime(e){const t={type:"route_stay_time",timestamp:Date.now(),route:e,user:this.config.getUser(),device:this.getDeviceInfo()};this.reporter.report("route_performance",[t])}getCurrentRoute(){return this.currentRoute}getRouteHistory(){return[...this.routeHistory]}getCurrentPageStayTime(){return this.routeStartTime?Date.now()-this.routeStartTime:0}getRoutePerformanceStats(){const e={totalRoutes:this.routeHistory.length,averageStayTime:0,routesByPath:new Map,totalStayTime:0};return this.routeHistory.length>0&&(this.routeHistory.forEach(t=>{e.totalStayTime+=t.stayTime,e.routesByPath.has(t.path)||e.routesByPath.set(t.path,{count:0,totalStayTime:0,averageStayTime:0});const r=e.routesByPath.get(t.path);r.count++,r.totalStayTime+=t.stayTime,r.averageStayTime=r.totalStayTime/r.count}),e.averageStayTime=e.totalStayTime/e.totalRoutes),e}setupPerformanceMonitoring(){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{this.captureDOMLoadTime()}):this.captureDOMLoadTime(),window.addEventListener("load",()=>{this.captureWindowLoadTime(),this.captureWebVitals(),this.reportPerformanceMetrics()})}setupResourceMonitoring(){if("undefined"!=typeof window&&"PerformanceObserver"in window){const e=new PerformanceObserver(e=>{for(const t of e.getEntries())"resource"===t.entryType&&this.handleResourceLoad(t)});try{e.observe({entryTypes:["resource"]})}catch(e){this.setupResourceFallback()}}}setupInteractionMonitoring(){let e=0,t=0;const r=n=>{0===e&&(e=wt(),t=e-this.metrics.fcp,this.metrics.fid=t,document.removeEventListener("click",r,!0),document.removeEventListener("keydown",r,!0),document.removeEventListener("touchstart",r,!0))};document.addEventListener("click",r,!0),document.addEventListener("keydown",r,!0),document.addEventListener("touchstart",r,!0)}captureDOMLoadTime(){this.metrics.domLoad=wt()}captureWindowLoadTime(){this.metrics.windowLoad=wt()}captureWebVitals(){if("undefined"!=typeof window&&"PerformanceObserver"in window)try{new PerformanceObserver(e=>{for(const t of e.getEntries())"first-contentful-paint"===t.name&&(this.metrics.fcp=t.startTime,this.config?.config?.debugSwitch&&console.log("FCP:",t.startTime))}).observe({type:"paint",buffered:!0})}catch(e){console.warn("FCP监控失败:",e)}if("undefined"!=typeof window&&"PerformanceObserver"in window)try{new PerformanceObserver(e=>{for(const t of e.getEntries())this.metrics.lcp=t.startTime}).observe({entryTypes:["largest-contentful-paint"]})}catch(e){console.warn("LCP监控失败:",e)}if("undefined"!=typeof window&&"PerformanceObserver"in window)try{let e=0;new PerformanceObserver(t=>{for(const r of t.getEntries())r.hadRecentInput||(e+=r.value);this.metrics.cls=e}).observe({entryTypes:["layout-shift"]})}catch(e){console.warn("CLS监控失败:",e)}}handleResourceLoad(e){const t={name:e.name,type:e.initiatorType,duration:e.duration,size:e.transferSize,timestamp:Date.now()};this.metrics.resourceLoad.push(t),e.duration>3e3&&this.reportSlowResource(t)}handlePageHidden(){this.calculatePageStayTime()}handlePageVisible(){this.pageStartTime=Date.now()}calculatePageStayTime(){const e=Date.now()-this.pageStartTime;this.reportPageStayTime(e)}reportPerformanceMetrics(){const e={type:"performance",timestamp:Date.now(),url:window.location.href,userAgent:navigator.userAgent,metrics:this.metrics,user:this.config.getUser(),device:this.getDeviceInfo()};this.performanceQueue.push(e),this.config.getConfig().debugSwitch&&console.log("Performance Data:",e),0===this.config.getConfig().reportInterval?this.reporter.report("performance",[e]):this.performanceQueue.length>=this.config.getConfig().maxQueueSize&&this.flushPerformanceQueue()}reportSlowResource(e){this.reporter.report("slow_resource",[e])}reportSlowApi(e){this.reporter.report("slow_api",[e])}reportPageStayTime(e){const t={type:"page_stay",url:window.location.href,stayTime:e,timestamp:Date.now()};this.reporter.report("page_stay",[t])}getDeviceInfo(){return{screen:{width:screen.width,height:screen.height,availWidth:screen.availWidth,availHeight:screen.availHeight,colorDepth:screen.colorDepth,pixelDepth:screen.pixelDepth},viewport:{width:window.innerWidth,height:window.innerHeight},connection:navigator.connection?{effectiveType:navigator.connection.effectiveType,downlink:navigator.connection.downlink,rtt:navigator.connection.rtt}:null,memory:navigator.memory?{usedJSHeapSize:navigator.memory.usedJSHeapSize,totalJSHeapSize:navigator.memory.totalJSHeapSize,jsHeapSizeLimit:navigator.memory.jsHeapSizeLimit}:null}}initThirdPartySDKs(){const e=this.config.getThirdPartyConfig();e.baidu&&window._hmt&&(this.thirdPartySDKs.baidu=window._hmt),e.umeng&&window._um&&(this.thirdPartySDKs.umeng=window._um),e.sensors&&window.sensors&&(this.thirdPartySDKs.sensors=window.sensors),e.tencent&&window.MTA&&(this.thirdPartySDKs.tencent=window.MTA)}flushPerformanceQueue(){this.performanceQueue.length>0&&(this.reporter.report("performance",[...this.performanceQueue]),this.performanceQueue=[])}reportPerformance(e={}){const t={type:"custom_performance",timestamp:Date.now(),url:window.location.href,metrics:e,user:this.config.getUser()};this.reporter.report("performance",[t])}getCurrentMetrics(){return{...this.metrics}}destroy(){this.config.getConfig().reportInterval>0&&this.flushPerformanceQueue(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.isInitialized=!1}}class At{constructor(e){this.config=e,this.reporter=new Rt(e),this.isInitialized=!1,this.behaviorQueue=[],this.sessionId=this.generateSessionId(),this.pageStartTime=Date.now(),this.scrollDepth=0,this.mouseMovements=[],this.keyStrokes=[],this.formInteractions=[],this.timeTracker=null,this.reportTimer=null,this.originalPushState=null,this.originalReplaceState=null,this.behaviors={pageViews:[],clicks:[],scrolls:[],formSubmissions:[],navigation:[],timeOnPage:0}}init(){if(this.isInitialized)return;const e=this.config.getConfig();e.enableUserInteractionTracking&&this.setupUserInteractionTracking(),e.enableFormTracking&&this.setupFormTracking(),e.enableScrollTracking&&this.setupScrollTracking(),e.enableMouseTracking&&this.setupMouseTracking(),e.enableKeyboardTracking&&this.setupKeyboardTracking(),this.setupTimeTracking(),e.reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushBehaviorQueue()},e))}setupUserInteractionTracking(){document.addEventListener("click",e=>{this.trackClick(e)},!0),document.addEventListener("dblclick",e=>{this.trackDoubleClick(e)},!0),document.addEventListener("contextmenu",e=>{this.trackRightClick(e)},!0),"ontouchstart"in window&&document.addEventListener("touchstart",e=>{this.trackTouch(e)},!0)}setupFormTracking(){document.addEventListener("submit",e=>{this.trackFormSubmission(e)},!0),document.addEventListener("change",e=>{"INPUT"!==e.target.tagName&&"SELECT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName||this.trackFormFieldChange(e)},!0),document.addEventListener("focus",e=>{"INPUT"!==e.target.tagName&&"SELECT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName||this.trackFormFieldFocus(e)},!0),document.addEventListener("blur",e=>{"INPUT"!==e.target.tagName&&"SELECT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName||this.trackFormFieldBlur(e)},!0)}setupScrollTracking(){let e;document.addEventListener("scroll",()=>{clearTimeout(e),e=setTimeout(()=>{const e=window.pageYOffset||document.documentElement.scrollTop,t=document.documentElement.scrollHeight,r=document.documentElement.clientHeight,n=Math.round(e/(t-r)*100);n>this.scrollDepth&&(this.scrollDepth=n,this.trackScroll(n,e))},100)},{passive:!0})}setupMouseTracking(){let e,t=[];document.addEventListener("mousemove",r=>{clearTimeout(e),t.push({x:r.clientX,y:r.clientY,timestamp:Date.now()}),t.length>100&&t.shift(),e=setTimeout(()=>{t.length>10&&(this.trackMouseMovement(t),t=[])},1e3)},{passive:!0})}setupKeyboardTracking(){document.addEventListener("keydown",e=>{"password"!==e.target.type&&this.trackKeyStroke(e)},!0)}setupTimeTracking(){this.timeTracker&&clearInterval(this.timeTracker),this.timeTracker=setInterval(()=>{this.behaviors.timeOnPage+=1},1e3),window.addEventListener("beforeunload",()=>{this.reportTimeOnPage()})}trackReferrer(){const e=document.referrer;if(e){const t={type:"referrer",url:e,domain:this.extractDomain(e),timestamp:Date.now()};this.config.getConfig().debugSwitch&&console.log("referrerData----",t),this.behaviors.navigation.push(t),this.reportBehavior("referrer",t)}}trackPageView(){const e={type:"pageview",url:window.location.href,title:document.title,timestamp:Date.now(),sessionId:this.sessionId,referrer:document.referrer};this.behaviors.pageViews.push(e),this.reportBehavior("pageview",e),this.pageStartTime=Date.now(),this.scrollDepth=0}trackClick(e){const t={type:"click",element:{tagName:e.target.tagName,className:e.target.className,id:e.target.id,text:e.target.textContent?.substring(0,50),href:e.target.href},position:{x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY},timestamp:Date.now(),sessionId:this.sessionId};this.behaviors.clicks.push(t),this.reportBehavior("click",t)}trackDoubleClick(e){const t={type:"doubleclick",element:{tagName:e.target.tagName,className:e.target.className,id:e.target.id},position:{x:e.clientX,y:e.clientY},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("doubleclick",t)}trackRightClick(e){const t={type:"rightclick",element:{tagName:e.target.tagName,className:e.target.className,id:e.target.id},position:{x:e.clientX,y:e.clientY},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("rightclick",t)}trackTouch(e){const t={type:"touch",touches:Array.from(e.touches).map(e=>({x:e.clientX,y:e.clientY,identifier:e.identifier})),timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("touch",t)}trackFormSubmission(e){const t={type:"form_submission",form:{action:e.target.action,method:e.target.method,id:e.target.id,className:e.target.className},fields:this.getFormFields(e.target),timestamp:Date.now(),sessionId:this.sessionId};this.behaviors.formSubmissions.push(t),this.reportBehavior("form_submission",t)}trackFormFieldChange(e){const t={type:"form_field_change",field:{name:e.target.name,type:e.target.type,value:"password"===e.target.type?"***":e.target.value,id:e.target.id},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("form_field_change",t)}trackFormFieldFocus(e){const t={type:"form_field_focus",field:{name:e.target.name,type:e.target.type,id:e.target.id},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("form_field_focus",t)}trackFormFieldBlur(e){const t={type:"form_field_blur",field:{name:e.target.name,type:e.target.type,id:e.target.id},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("form_field_blur",t)}trackScroll(e,t){const r={type:"scroll",depth:e,scrollTop:t,timestamp:Date.now(),sessionId:this.sessionId};this.config.getConfig().debugSwitch&&console.log("scrollData---",r),this.reportBehavior("scroll",r)}trackMouseMovement(e){const t={type:"mouse_movement",movements:e,timestamp:Date.now(),sessionId:this.sessionId};this.config.getConfig().debugSwitch&&console.log("mouse_movement---",t),this.reportBehavior("mouse_movement",t)}trackKeyStroke(e){const t={type:"keystroke",key:e.key,code:e.code,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,timestamp:Date.now(),sessionId:this.sessionId};this.config.getConfig().debugSwitch&&console.log("keystroke---",t),this.reportBehavior("keystroke",t)}reportBehavior(e,t){const r={type:e,data:t,user:this.config.getUser(),config:{appId:this.config.getConfig().appId,appVersion:this.config.getConfig().appVersion}};this.behaviorQueue.push(r),0===this.config.getConfig().reportInterval?this.reporter.report("behavior",[r]):this.behaviorQueue.length>=this.config.getConfig().maxQueueSize&&this.flushBehaviorQueue()}reportCustomBehavior(e,t={}){const r={type:"custom_behavior",eventName:e,...t,timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("custom_behavior",r)}flushBehaviorQueue(){this.behaviorQueue.length>0&&(this.reporter.report("behavior",[...this.behaviorQueue]),this.behaviorQueue=[])}getFormFields(e){const t=[],r=e.elements;for(let e=0;e<r.length;e++){const n=r[e];n.name&&t.push({name:n.name,type:n.type,value:"password"===n.type?"***":n.value})}return t}extractDomain(e){try{return new URL(e).hostname}catch(t){return e}}generateSessionId(){return"session_"+Date.now()+"_"+Math.random().toString(36).substr(2,9)}getCurrentBehaviors(){return{...this.behaviors}}getSessionId(){return this.sessionId}destroy(){this.config.getConfig().reportInterval>0&&this.flushBehaviorQueue(),this.reportTimeOnPage(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.timeTracker&&(clearInterval(this.timeTracker),this.timeTracker=null),this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),this.originalReplaceState&&(history.replaceState=this.originalReplaceState,this.originalReplaceState=null),this.isInitialized=!1}}class Dt{constructor(e,t=null){this.config=e,this.reporter=new Rt(e),this.eventTracker=t,this.isInitialized=!1,this.observer=null,this.trackedElements=new Map,this.exposureQueue=[],this.reportTimer=null,this.scrollTimer=null,this.useFallback=!1,this.lastReportTime=new Map,this.debounceTime=500,this.defaultOptions={threshold:.5,rootMargin:"0px",scrollThrottle:100}}init(){if(this.isInitialized)return;this.isIntersectionObserverSupported()?(this.createObserver(),this.useFallback=!1,this.config.getConfig().debugSwitch&&console.log("曝光追踪器初始化完成(使用 Intersection Observer API)")):(this.setupFallbackTracking(),this.useFallback=!0,this.config.getConfig().debugSwitch&&console.warn("浏览器不支持 Intersection Observer,使用降级方案(滚动事件追踪)"));const e=this.config.getConfig();e.reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0,e.debugSwitch&&console.log("曝光追踪器初始化完成")}isIntersectionObserverSupported(){return"undefined"!=typeof window&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype}createObserver(){const e={root:null,rootMargin:this.defaultOptions.rootMargin,threshold:[0,.5,1]};this.observer=new IntersectionObserver(e=>{e.forEach(e=>{this.handleIntersection(e)})},e)}handleIntersection(e){console.log("entry-------",e);const t=e.target,r=this.getElementId(t),n=this.getElementConfig(t),i=n.threshold||this.defaultOptions.threshold,o=e.intersectionRatio,s=o>=i;if(this.config.getConfig().debugSwitch&&console.log(`元素 ${r} 可见性检查:`,{visibleRatio:(100*o).toFixed(2)+"%",threshold:(100*i).toFixed(2)+"%",isThresholdMet:s}),s){this.trackedElements.has(r)||this.trackedElements.set(r,{element:t,config:n});const e=this.trackedElements.get(r),i=Date.now(),s=i-(this.lastReportTime.get(r)||0);s>=this.debounceTime?(this.lastReportTime.set(r,i),this.triggerExposure(t,r,e,o,0),this.config.getConfig().debugSwitch&&console.log(`元素 ${r} 进入可视区域,可见比例: ${(100*o).toFixed(2)}%,立即触发曝光`)):this.config.getConfig().debugSwitch&&console.log(`元素 ${r} 跳过上报(去重),距离上次上报 ${s}ms,需要间隔 ${this.debounceTime}ms`)}}triggerExposure(e,t,r,n,i){const o=this.extractProductInfo(e,r.config);let s={};this.eventTracker&&"function"==typeof this.eventTracker.getPreviousPageInfo&&(s=this.eventTracker.getPreviousPageInfo());const a=this.getElementConfig(e),c={uuid:Tt(),timestamp:Date.now(),pageKey:Et(kt(window.location.href),this.config.getConfig().uiVersion),pageUri:kt(window.location.href),eventType:"EXPOSE",actionKey:"",refer:kt(s?.previousPage?.url),duration:s?.previousPageStayTime,viewParam:{...o},tags:{...a}};this.exposureQueue.push(c),this.config.getConfig().debugSwitch&&console.log("商品曝光事件:",c);0===this.config.getConfig().reportInterval?Promise.resolve().then(()=>{this.reporter.report("exposure",this.getReportData([c])).catch(e=>{console.error("曝光上报失败:",e),this.config.getConfig().debugSwitch&&console.error("曝光上报失败详情:",e)})}):this.exposureQueue.length>=this.config.getConfig().maxQueueSize&&this.flushExposureQueue()}setupFallbackTracking(){this.observer={observe:e=>{const t=this.getElementId(e);this.trackedElements.has(t)},unobserve:e=>{const t=this.getElementId(e);this.trackedElements.delete(t)},disconnect:()=>{this.trackedElements.clear(),this.removeScrollListener()}},this.addScrollListener(),setTimeout(()=>{this.checkAllElementsVisibility()},100)}addScrollListener(){if(this.scrollHandler)return;let e=0;const t=this.defaultOptions.scrollThrottle;this.scrollHandler=()=>{const r=Date.now();r-e>=t&&(e=r,this.checkAllElementsVisibility())},window.addEventListener("scroll",this.scrollHandler,{passive:!0}),window.addEventListener("touchmove",this.scrollHandler,{passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0})}removeScrollListener(){this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler),window.removeEventListener("touchmove",this.scrollHandler),window.removeEventListener("resize",this.scrollHandler),this.scrollHandler=null)}checkAllElementsVisibility(){if(!this.useFallback)return;const e=window.innerHeight,t=window.innerWidth;this.trackedElements.forEach((r,n)=>{const i=r.element;if(!i||!document.contains(i))return void this.trackedElements.delete(n);const o=r.config.threshold||this.defaultOptions.threshold,s=this.calculateVisibleRatio(i,0,e,0,t);if(s>=o){const e=Date.now(),t=e-(this.lastReportTime.get(n)||0);t>=this.debounceTime?(this.lastReportTime.set(n,e),this.triggerExposure(i,n,r,s,0),this.config.getConfig().debugSwitch&&console.log(`元素 ${n} 进入可视区域,可见比例: ${(100*s).toFixed(2)}%,立即触发曝光`)):this.config.getConfig().debugSwitch&&console.log(`元素 ${n} 跳过上报(去重),距离上次上报 ${t}ms,需要间隔 ${this.debounceTime}ms`)}})}calculateVisibleRatio(e,t,r,n,i){const o=e.getBoundingClientRect();if(o.bottom<t||o.top>r||o.right<n||o.left>i)return 0;const s=Math.max(o.top,t),a=Math.min(o.bottom,r),c=Math.max(o.left,n),u=Math.min(o.right,i),l=Math.max(0,u-c)*Math.max(0,a-s),h=o.width*o.height;return 0===h?0:l/h}trackProduct(e,t={}){if(!this.isInitialized)return void console.warn("曝光追踪器未初始化");if(!e||"object"!=typeof e||!e.nodeType)return void console.warn("无效的元素,无法追踪");const r=this.getElementId(e),n={...t};this.trackedElements.has(r)&&this.untrackProduct(e),e.setAttribute("data-exposure-tracked","true"),e.setAttribute("data-exposure-config",JSON.stringify(n)),this.trackedElements.set(r,{element:e,config:n}),this.observer&&this.observer.observe(e),this.useFallback&&setTimeout(()=>{this.checkAllElementsVisibility()},0),this.config.getConfig().debugSwitch&&console.log(`开始追踪商品元素: ${r}`,n)}trackProducts(e,t={}){if(!this.isInitialized||!this.observer)return void console.warn("曝光追踪器未初始化");let r=[];if("string"==typeof e)r=Array.from(document.querySelectorAll(e));else{if(!Array.isArray(e))return void console.warn("无效的选择器或元素列表");r=e}r.forEach((e,r)=>{const n=Array.isArray(t)?t[r]||{}:t;this.trackProduct(e,n)}),this.config.getConfig().debugSwitch&&console.log(`批量追踪了 ${r.length} 个商品元素`)}untrackProduct(e){if(!this.observer)return;const t=this.getElementId(e);this.observer.unobserve&&this.observer.unobserve(e),this.trackedElements.delete(t),this.lastReportTime.delete(t),e&&e.removeAttribute&&(e.removeAttribute("data-exposure-tracked"),e.removeAttribute("data-exposure-config")),this.config.getConfig().debugSwitch&&console.log(`取消追踪商品元素: ${t}`)}untrackAll(){this.observer&&(this.useFallback||this.trackedElements.forEach((e,t)=>{e.element&&this.observer.unobserve&&this.observer.unobserve(e.element)}),this.trackedElements.clear(),this.config.getConfig().debugSwitch&&console.log("已取消追踪所有商品元素"))}getElementId(e){if(e.getAttribute("data-exposure-id"))return e.getAttribute("data-exposure-id");if(e._exposureUniqueId)return e._exposureUniqueId;if(e.id)return`id_${e.id}`;if(e.getAttribute("data-product-id"))return`product_${e.getAttribute("data-product-id")}`;const t=Tt();return e._exposureUniqueId=t,t}getElementConfig(e){const t=e.getAttribute("data-exposure-config");if(t)try{return JSON.parse(t)}catch(e){return{}}return{}}extractProductInfo(e,t={}){const r={productId:t.productId||e.getAttribute("data-product-id")||null,productName:t.productName||e.getAttribute("data-product-name")||null,productPrice:t.productPrice||e.getAttribute("data-product-price")||null,productCategory:t.productCategory||e.getAttribute("data-product-category")||null,productImage:t.productImage||e.getAttribute("data-product-image")||null};return Object.keys(r).forEach(e=>{null===r[e]&&delete r[e]}),r}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushExposureQueue()},e))}getReportData(e){if(e.length>0){const r=e[0];return r.tags&&(r.tags.exposeContent=(t=e.map(e=>e.viewParam?.productId).filter(Boolean),Array.from(new Set(t)))),delete r.viewParam,r}var t;return null}flushExposureQueue(){if(this.exposureQueue.length>0){const e=[...this.exposureQueue];this.exposureQueue=[],Promise.resolve().then(()=>{this.reporter.report("exposure",this.getReportData(e)).catch(e=>{console.error("批量曝光上报失败:",e),this.config.getConfig().debugSwitch&&console.error("批量曝光上报失败详情:",e)})})}}reportExposure(e={}){let t={};this.eventTracker&&"function"==typeof this.eventTracker.getPreviousPageInfo&&(t=this.eventTracker.getPreviousPageInfo());const r={uuid:Tt(),timestamp:Date.now(),pageKey:Et(kt(window.location.href),this.config.getConfig().uiVersion),pageUri:kt(window.location.href),eventType:"EXPOSE",actionKey:"",refer:kt(t?.previousPage?.url),duration:t?.previousPageStayTime,viewParam:{...e},tags:{...config}};Promise.resolve().then(()=>{this.reporter.report("exposure",this.getReportData(r)).catch(e=>{console.error("手动曝光上报失败:",e),this.config.getConfig().debugSwitch&&console.error("手动曝光上报失败详情:",e)})})}getTrackedElements(){return Array.from(this.trackedElements.keys())}getExposureQueue(){return[...this.exposureQueue]}destroy(){this.flushExposureQueue(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.untrackAll(),this.observer&&(this.observer.disconnect&&this.observer.disconnect(),this.observer=null),this.removeScrollListener(),this.trackedElements.clear(),this.exposureQueue=[],this.lastReportTime.clear(),this.useFallback=!1,this.isInitialized=!1,this.config.getConfig().debugSwitch&&console.log("曝光追踪器已销毁")}}class xt{constructor(e){this.config=e,this.integratedSDKs={},this.isInitialized=!1}init(){if(this.isInitialized)return;const e=this.config.getThirdPartyConfig();e.baidu&&e.baidu.enabled&&this.initBaiduAnalytics(e.baidu),e.umeng&&e.umeng.enabled&&this.initUmengAnalytics(e.umeng),e.sensors&&e.sensors.enabled&&this.initSensorsAnalytics(e.sensors),e.tencent&&e.tencent.enabled&&this.initTencentAnalytics(e.tencent),e.google&&e.google.enabled&&this.initGoogleAnalytics(e.google),e.custom&&e.custom.enabled&&this.initCustomAnalytics(e.custom),this.isInitialized=!0}initBaiduAnalytics(e){try{window._hmt?(this.integratedSDKs.baidu={name:"baidu",instance:window._hmt,config:e},e.siteId&&window._hmt.push(["_setAccount",e.siteId]),!1!==e.autoPageview&&window._hmt.push(["_trackPageview"]),console.log("百度统计集成成功")):console.warn("百度统计未加载,请检查脚本是否正确引入")}catch(e){console.error("百度统计集成失败:",e)}}initUmengAnalytics(e){try{window._um?(this.integratedSDKs.umeng={name:"umeng",instance:window._um,config:e},e.siteId&&window._um.push(["setAccount",e.siteId]),!1!==e.autoPageview&&window._um.push(["trackPageview"]),console.log("友盟统计集成成功")):console.warn("友盟统计未加载,请检查脚本是否正确引入")}catch(e){console.error("友盟统计集成失败:",e)}}initSensorsAnalytics(e){try{window.sensors?(this.integratedSDKs.sensors={name:"sensors",instance:window.sensors,config:e},e.serverUrl&&window.sensors.setServerUrl(e.serverUrl),e.siteId&&window.sensors.setSiteId(e.siteId),!1!==e.autoPageview&&window.sensors.trackPageview(),console.log("神策数据集成成功")):console.warn("神策数据未加载,请检查脚本是否正确引入")}catch(e){console.error("神策数据集成失败:",e)}}initTencentAnalytics(e){try{window.MTA?(this.integratedSDKs.tencent={name:"tencent",instance:window.MTA,config:e},e.appId&&window.MTA.setAppId(e.appId),!1!==e.autoPageview&&window.MTA.trackPageview(),console.log("腾讯云分析集成成功")):console.warn("腾讯云分析未加载,请检查脚本是否正确引入")}catch(e){console.error("腾讯云分析集成失败:",e)}}initGoogleAnalytics(e){try{window.gtag?(this.integratedSDKs.google={name:"google",instance:window.gtag,config:e},e.measurementId&&window.gtag("config",e.measurementId,{page_title:document.title,page_location:window.location.href}),console.log("Google Analytics集成成功")):console.warn("Google Analytics未加载,请检查脚本是否正确引入")}catch(e){console.error("Google Analytics集成失败:",e)}}initCustomAnalytics(e){try{if("function"==typeof e.init){const t=e.init(e);this.integratedSDKs.custom={name:"custom",instance:t,config:e},console.log("自定义第三方集成成功")}else console.warn("自定义第三方配置缺少init函数")}catch(e){console.error("自定义第三方集成失败:",e)}}reportEvent(e,t={}){Object.values(this.integratedSDKs).forEach(r=>{try{this.reportToSDK(r,e,t)}catch(e){console.error(`上报事件到${r.name}失败:`,e)}})}reportPageView(e={}){Object.values(this.integratedSDKs).forEach(t=>{try{this.reportPageViewToSDK(t,e)}catch(e){console.error(`上报页面浏览到${t.name}失败:`,e)}})}reportUser(e={}){Object.values(this.integratedSDKs).forEach(t=>{try{this.reportUserToSDK(t,e)}catch(e){console.error(`上报用户信息到${t.name}失败:`,e)}})}reportPerformance(e={}){Object.values(this.integratedSDKs).forEach(t=>{try{this.reportPerformanceToSDK(t,e)}catch(e){console.error(`上报性能指标到${t.name}失败:`,e)}})}reportToSDK(e,t,r){switch(e.name){case"baidu":e.instance&&e.instance.push&&e.instance.push(["_trackEvent",t,JSON.stringify(r)]);break;case"umeng":e.instance&&e.instance.push&&e.instance.push(["track",t,r]);break;case"sensors":e.instance&&e.instance.track&&e.instance.track(t,r);break;case"tencent":e.instance&&e.instance.Event&&e.instance.Event.stat&&e.instance.Event.stat(t,r);break;case"google":e.instance&&"function"==typeof e.instance&&e.instance("event",t,r);break;case"custom":e.instance&&"function"==typeof e.instance.track&&e.instance.track(t,r);break;default:console.warn(`未知的SDK类型: ${e.name}`)}}reportPageViewToSDK(e,t){switch(e.name){case"baidu":e.instance&&e.instance.push&&e.instance.push(["_trackPageview",t.url||window.location.href]);break;case"umeng":e.instance&&e.instance.push&&e.instance.push(["trackPageview",t.url||window.location.href]);break;case"sensors":e.instance&&e.instance.trackPageview&&e.instance.trackPageview(t);break;case"tencent":e.instance&&e.instance.trackPageview&&e.instance.trackPageview(t.url||window.location.href);break;case"google":e.instance&&"function"==typeof e.instance&&e.instance("config",e.config.measurementId,{page_title:t.title||document.title,page_location:t.url||window.location.href});break;case"custom":e.instance&&"function"==typeof e.instance.trackPageview&&e.instance.trackPageview(t);break;default:console.warn(`未知的SDK类型: ${e.name}`)}}reportUserToSDK(e,t){switch(e.name){case"baidu":e.instance&&e.instance.push&&(e.instance.push(["_setUserTag","userId",t.userId]),e.instance.push(["_setUserTag","userType",t.userType]));break;case"umeng":e.instance&&e.instance.push&&(e.instance.push(["setUserTag","userId",t.userId]),e.instance.push(["setUserTag","userType",t.userType]));break;case"sensors":e.instance&&e.instance.setProfile&&e.instance.setProfile(t);break;case"tencent":e.instance&&e.instance.setUserInfo&&e.instance.setUserInfo(t);break;case"google":e.instance&&"function"==typeof e.instance&&e.instance("set","user_id",t.userId);break;case"custom":e.instance&&"function"==typeof e.instance.setUser&&e.instance.setUser(t);break;default:console.warn(`未知的SDK类型: ${e.name}`)}}reportPerformanceToSDK(e,t){switch(e.name){case"baidu":e.instance&&e.instance.push&&e.instance.push(["_trackEvent","performance",JSON.stringify(t)]);break;case"umeng":e.instance&&e.instance.push&&e.instance.push(["track","performance",t]);break;case"sensors":e.instance&&e.instance.track&&e.instance.track("performance",t);break;case"tencent":e.instance&&e.instance.Event&&e.instance.Event.stat&&e.instance.Event.stat("performance",t);break;case"google":e.instance&&"function"==typeof e.instance&&e.instance("event","performance",t);break;case"custom":e.instance&&"function"==typeof e.instance.trackPerformance&&e.instance.trackPerformance(t);break;default:console.warn(`未知的SDK类型: ${e.name}`)}}isSDKIntegrated(e){return!!this.integratedSDKs[e]}getIntegratedSDKs(){return Object.keys(this.integratedSDKs)}getSDKInstance(e){return this.integratedSDKs[e]?.instance||null}destroy(){Object.values(this.integratedSDKs).forEach(e=>{try{e.instance&&"function"==typeof e.instance.destroy&&e.instance.destroy()}catch(t){console.error(`销毁${e.name}失败:`,t)}}),this.integratedSDKs={},this.isInitialized=!1}}class Nt{constructor(e={}){this.config={appId:e.appId||"",appVersion:e.appVersion||"1.0.0",environment:e.environment||"production",debugSwitch:!0===e.debugSwitch,customerId:e.customerId||"",userId:e.userId||"",deviceNo:e.deviceNo||"",deviceId:e.userId||"",uiVersion:e.uiVersion||"",sessionId:bt(),reportUrl:e.reportUrl||"",reportInterval:e.reportInterval||5e3,maxQueueSize:e.maxQueueSize||100,enableErrorTracking:!1!==e.enableErrorTracking,enableUnhandledRejection:!1!==e.enableUnhandledRejection,enableResourceError:!1!==e.enableResourceError,enableEventTracking:!1!==e.enableEventTracking,enableClickTracking:!1!==e.enableClickTracking,enablePageViewTracking:!1!==e.enablePageViewTracking,enablePerformanceTracking:!1!==e.enablePerformanceTracking,enableResourceTracking:!1!==e.enableResourceTracking,enableApiTracking:!1!==e.enableApiTracking,enableInteractionTracking:!1!==e.enableInteractionTracking,enableUserInteractionTracking:!1!==e.enableUserInteractionTracking,enableFormTracking:!1!==e.enableFormTracking,enableScrollTracking:!1!==e.enableScrollTracking,enableMouseTracking:!1!==e.enableMouseTracking,enableKeyboardTracking:!1!==e.enableKeyboardTracking,thirdPartyConfig:e.thirdPartyConfig||{},user:e.user||null,customReport:e.customReport||null},this.user=null}updateConfig(e){this.config={...this.config,...e}}setUser(e){this.user=e}getConfig(){return this.config}getUser(){return this.user}getReportUrl(){return this.config.reportUrl}getThirdPartyConfig(){return this.config.thirdPartyConfig}isErrorTrackingEnabled(){return this.config.enableErrorTracking}isEventTrackingEnabled(){return this.config.enableEventTracking}}"undefined"==typeof window||window?.axios||(window.axios=ft);class Lt{constructor(e={}){this.config=new Nt(e),this.errorTracker=new It(this.config),this.eventTracker=new Ct(this.config),this.performanceTracker=new Ot(this.config),this.userBehaviorTracker=new At(this.config),this.exposureTracker=new Dt(this.config,this.eventTracker),this.thirdPartyIntegrator=new xt(this.config),this.init()}init(){this.eventTracker.init(),this.exposureTracker.init(),this.thirdPartyIntegrator.init(),console.log("Frontend SDK 初始化完成")}reportError(e,t={}){this.errorTracker.reportError(e,t)}reportEvent(e,t={}){this.eventTracker.reportEvent(e,t)}getPreviousPageInfo(){return this.eventTracker.getPreviousPageInfo()}getCurrentPageStayTime(){return this.eventTracker.getCurrentPageStayTime()}getPageHistory(){return this.eventTracker.pageHistory||[]}reportPerformance(e={}){this.performanceTracker.reportPerformance(e)}reportBehavior(e,t={}){this.userBehaviorTracker.reportCustomBehavior(e,t)}setUser(e){this.config.setUser(e),this.thirdPartyIntegrator.reportUser(e)}setConfig(e){this.config.updateConfig(e)}getPerformanceMetrics(){return this.performanceTracker.getCurrentMetrics()}getBehaviorData(){return this.userBehaviorTracker.getCurrentBehaviors()}getSessionId(){return this.userBehaviorTracker.getSessionId()}isThirdPartySDKIntegrated(e){return this.thirdPartyIntegrator.isSDKIntegrated(e)}getIntegratedThirdPartySDKs(){return this.thirdPartyIntegrator.getIntegratedSDKs()}setupVueRouterMonitoring(e){e?(this.performanceTracker.setupVueRouterMonitoring(e),console.log("Vue Router 监控已设置")):console.warn("Vue Router 实例未提供")}getCurrentRoute(){return this.performanceTracker.getCurrentRoute()}getRouteHistory(){return this.performanceTracker.getRouteHistory()}getCurrentRouteStayTime(){return this.performanceTracker.getCurrentPageStayTime()}getRoutePerformanceStats(){return this.performanceTracker.getRoutePerformanceStats()}trackProduct(e,t={}){return this.exposureTracker.trackProduct(e,t)}trackProducts(e,t={}){return this.exposureTracker.trackProducts(e,t)}untrackProduct(e){return this.exposureTracker.untrackProduct(e)}untrackAllProducts(){return this.exposureTracker.untrackAll()}reportExposure(e={}){return this.exposureTracker.reportExposure(e)}getTrackedProducts(){return this.exposureTracker.getTrackedElements()}getExposureQueue(){return this.exposureTracker.getExposureQueue()}flushExposureQueue(){return this.exposureTracker.flushExposureQueue()}destroy(){this.errorTracker.destroy(),this.eventTracker.destroy(),this.performanceTracker.destroy(),this.userBehaviorTracker.destroy(),this.exposureTracker.destroy(),this.thirdPartyIntegrator.destroy(),console.log("Frontend SDK 已销毁")}}export{Lt as default,wt as performanceNow};
|
|
1
|
+
function e(e,t){return function(){return e.apply(t,arguments)}}const{toString:t}=Object.prototype,{getPrototypeOf:r}=Object,{iterator:n,toStringTag:i}=Symbol,o=(s=Object.create(null),e=>{const r=t.call(e);return s[r]||(s[r]=r.slice(8,-1).toLowerCase())});var s;const a=e=>(e=e.toLowerCase(),t=>o(t)===e),c=e=>t=>typeof t===e,{isArray:u}=Array,l=c("undefined");function h(e){return null!==e&&!l(e)&&null!==e.constructor&&!l(e.constructor)&&p(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const d=a("ArrayBuffer");const g=c("string"),p=c("function"),f=c("number"),m=e=>null!==e&&"object"==typeof e,w=e=>{if("object"!==o(e))return!1;const t=r(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||i in e||n in e)},y=a("Date"),b=a("File"),v=a("Blob"),T=a("FileList"),S=a("URLSearchParams"),[k,E,P,R]=["ReadableStream","Request","Response","Headers"].map(a);function I(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),u(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(h(e))return;const i=r?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let s;for(n=0;n<o;n++)s=i[n],t.call(null,e[s],s,e)}}function C(e,t){if(h(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,A=e=>!l(e)&&e!==O;const D=(x="undefined"!=typeof Uint8Array&&r(Uint8Array),e=>x&&e instanceof x);var x;const N=a("HTMLFormElement"),L=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),_=a("RegExp"),U=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};I(r,(r,i)=>{let o;!1!==(o=t(r,i,e))&&(n[i]=o||r)}),Object.defineProperties(e,n)};const F=a("AsyncFunction"),j=(B="function"==typeof setImmediate,M=p(O.postMessage),B?setImmediate:M?(z=`axios@${Math.random()}`,K=[],O.addEventListener("message",({source:e,data:t})=>{e===O&&t===z&&K.length&&K.shift()()},!1),e=>{K.push(e),O.postMessage(z,"*")}):e=>setTimeout(e));var B,M,z,K;const H="undefined"!=typeof queueMicrotask?queueMicrotask.bind(O):"undefined"!=typeof process&&process.nextTick||j;var V={isArray:u,isArrayBuffer:d,isBuffer:h,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||p(e.append)&&("formdata"===(t=o(e))||"object"===t&&p(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&d(e.buffer),t},isString:g,isNumber:f,isBoolean:e=>!0===e||!1===e,isObject:m,isPlainObject:w,isEmptyObject:e=>{if(!m(e)||h(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:k,isRequest:E,isResponse:P,isHeaders:R,isUndefined:l,isDate:y,isFile:b,isBlob:v,isRegExp:_,isFunction:p,isStream:e=>m(e)&&p(e.pipe),isURLSearchParams:S,isTypedArray:D,isFileList:T,forEach:I,merge:function e(){const{caseless:t}=A(this)&&this||{},r={},n=(n,i)=>{const o=t&&C(r,i)||i;w(r[o])&&w(n)?r[o]=e(r[o],n):w(n)?r[o]=e({},n):u(n)?r[o]=n.slice():r[o]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&I(arguments[e],n);return r},extend:(t,r,n,{allOwnKeys:i}={})=>(I(r,(r,i)=>{n&&p(r)?t[i]=e(r,n):t[i]=r},{allOwnKeys:i}),t),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,n,i)=>{let o,s,a;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],i&&!i(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&r(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:o,kindOfTest:a,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(u(e))return e;let t=e.length;if(!f(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[n]).call(e);let i;for(;(i=r.next())&&!i.done;){const r=i.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:N,hasOwnProperty:L,hasOwnProp:L,reduceDescriptors:U,freezeMethods:e=>{U(e,(t,r)=>{if(p(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];p(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))})},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach(e=>{r[e]=!0})};return u(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:C,global:O,isContextDefined:A,isSpecCompliantForm:function(e){return!!(e&&p(e.append)&&"FormData"===e[i]&&e[n])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(m(e)){if(t.indexOf(e)>=0)return;if(h(e))return e;if(!("toJSON"in e)){t[n]=e;const i=u(e)?[]:{};return I(e,(e,t)=>{const o=r(e,n+1);!l(o)&&(i[t]=o)}),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:F,isThenable:e=>e&&(m(e)||p(e))&&p(e.then)&&p(e.catch),setImmediate:j,asap:H,isIterable:e=>null!=e&&p(e[n])};function Q(e,t,r,n,i){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),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}V.inherits(Q,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:V.toJSONObject(this.config),code:this.code,status:this.status}}});const $=Q.prototype,q={};["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=>{q[e]={value:e}}),Object.defineProperties(Q,q),Object.defineProperty($,"isAxiosError",{value:!0}),Q.from=(e,t,r,n,i,o)=>{const s=Object.create($);return V.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e),Q.call(s,e.message,t,r,n,i),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};function J(e){return V.isPlainObject(e)||V.isArray(e)}function W(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function X(e,t,r){return e?e.concat(t).map(function(e,t){return e=W(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}const Y=V.toFlatObject(V,{},null,function(e){return/^is[A-Z]/.test(e)});function G(e,t,r){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=V.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!V.isUndefined(t[e])})).metaTokens,i=r.visitor||u,o=r.dots,s=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(V.isDate(e))return e.toISOString();if(V.isBoolean(e))return e.toString();if(!a&&V.isBlob(e))throw new Q("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(e)||V.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,r,i){let a=e;if(e&&!i&&"object"==typeof e)if(V.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(V.isArray(e)&&function(e){return V.isArray(e)&&!e.some(J)}(e)||(V.isFileList(e)||V.endsWith(r,"[]"))&&(a=V.toArray(e)))return r=W(r),a.forEach(function(e,n){!V.isUndefined(e)&&null!==e&&t.append(!0===s?X([r],n,o):null===s?r:r+"[]",c(e))}),!1;return!!J(e)||(t.append(X(i,r,o),c(e)),!1)}const l=[],h=Object.assign(Y,{defaultVisitor:u,convertValue:c,isVisitable:J});if(!V.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!V.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),V.forEach(r,function(r,o){!0===(!(V.isUndefined(r)||null===r)&&i.call(t,r,V.isString(o)?o.trim():o,n,h))&&e(r,n?n.concat(o):[o])}),l.pop()}}(e),t}function Z(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ee(e,t){this._pairs=[],e&&G(e,this,t)}const te=ee.prototype;function re(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ne(e,t,r){if(!t)return e;const n=r&&r.encode||re;V.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let o;if(o=i?i(t,r):V.isURLSearchParams(t)?t.toString():new ee(t,r).toString(n),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}te.append=function(e,t){this._pairs.push([e,t])},te.toString=function(e){const t=e?function(t){return e.call(this,t,Z)}:Z;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ie=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){V.forEach(this.handlers,function(t){null!==t&&e(t)})}},oe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},se={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ee,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ae="undefined"!=typeof window&&"undefined"!=typeof document,ce="object"==typeof navigator&&navigator||void 0,ue=ae&&(!ce||["ReactNative","NativeScript","NS"].indexOf(ce.product)<0),le="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,he=ae&&window.location.href||"http://localhost";var de={...Object.freeze({__proto__:null,hasBrowserEnv:ae,hasStandardBrowserWebWorkerEnv:le,hasStandardBrowserEnv:ue,navigator:ce,origin:he}),...se};function ge(e){function t(e,r,n,i){let o=e[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=e.length;if(o=!o&&V.isArray(n)?n.length:o,a)return V.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r,!s;n[o]&&V.isObject(n[o])||(n[o]=[]);return t(e,r,n[o],i)&&V.isArray(n[o])&&(n[o]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}(n[o])),!s}if(V.isFormData(e)&&V.isFunction(e.entries)){const r={};return V.forEachEntry(e,(e,n)=>{t(function(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,r,0)}),r}return null}const pe={transitional:oe,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=V.isObject(e);i&&V.isHTMLForm(e)&&(e=new FormData(e));if(V.isFormData(e))return n?JSON.stringify(ge(e)):e;if(V.isArrayBuffer(e)||V.isBuffer(e)||V.isStream(e)||V.isFile(e)||V.isBlob(e)||V.isReadableStream(e))return e;if(V.isArrayBufferView(e))return e.buffer;if(V.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return G(e,new de.classes.URLSearchParams,{visitor:function(e,t,r,n){return de.isNode&&V.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=V.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return G(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||pe.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(V.isResponse(e)||V.isReadableStream(e))return e;if(e&&V.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw Q.from(e,Q.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:de.classes.FormData,Blob:de.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{pe.headers[e]={}});var fe=pe;const me=V.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"]);const we=Symbol("internals");function ye(e){return e&&String(e).trim().toLowerCase()}function be(e){return!1===e||null==e?e:V.isArray(e)?e.map(be):String(e)}function ve(e,t,r,n,i){return V.isFunction(n)?n.call(this,t,r):(i&&(t=r),V.isString(t)?V.isString(n)?-1!==t.indexOf(n):V.isRegExp(n)?n.test(t):void 0:void 0)}class Te{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=ye(t);if(!i)throw new Error("header name must be a non-empty string");const o=V.findKey(n,i);(!o||void 0===n[o]||!0===r||void 0===r&&!1!==n[o])&&(n[o||t]=be(e))}const o=(e,t)=>V.forEach(e,(e,r)=>i(e,r,t));if(V.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(V.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&me[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t})(e),t);else if(V.isObject(e)&&V.isIterable(e)){let r,n,i={};for(const t of e){if(!V.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[n=t[0]]=(r=i[n])?V.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,r);return this}get(e,t){if(e=ye(e)){const r=V.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(V.isFunction(t))return t.call(this,e,r);if(V.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ye(e)){const r=V.findKey(this,e);return!(!r||void 0===this[r]||t&&!ve(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=ye(e)){const i=V.findKey(r,e);!i||t&&!ve(0,r[i],i,t)||(delete r[i],n=!0)}}return V.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!ve(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return V.forEach(this,(n,i)=>{const o=V.findKey(r,i);if(o)return t[o]=be(n),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}(i):String(i).trim();s!==i&&delete t[i],t[s]=be(n),r[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return V.forEach(this,(r,n)=>{null!=r&&!1!==r&&(t[n]=e&&V.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){const t=(this[we]=this[we]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=ye(e);t[n]||(!function(e,t){const r=V.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})})}(r,e),t[n]=!0)}return V.isArray(e)?e.forEach(n):n(e),this}}Te.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Te.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}}),V.freezeMethods(Te);var Se=Te;function ke(e,t){const r=this||fe,n=t||r,i=Se.from(n.headers);let o=n.data;return V.forEach(e,function(e){o=e.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Ee(e){return!(!e||!e.__CANCEL__)}function Pe(e,t,r){Q.call(this,null==e?"canceled":e,Q.ERR_CANCELED,t,r),this.name="CanceledError"}function Re(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new Q("Request failed with status code "+r.status,[Q.ERR_BAD_REQUEST,Q.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}V.inherits(Pe,Q,{__CANCEL__:!0});const Ie=(e,t,r=3)=>{let n=0;const i=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=n[s];i||(i=c),r[o]=a,n[o]=c;let l=s,h=0;for(;l!==o;)h+=r[l++],l%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const d=u&&c-u;return d?Math.round(1e3*h/d):void 0}}(50,250);return function(e,t){let r,n,i=0,o=1e3/t;const s=(t,o=Date.now())=>{i=o,r=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=o?s(e,t):(r=e,n||(n=setTimeout(()=>{n=null,s(r)},o-a)))},()=>r&&s(r)]}(r=>{const o=r.loaded,s=r.lengthComputable?r.total:void 0,a=o-n,c=i(a);n=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&o<=s?(s-o)/c:void 0,event:r,lengthComputable:null!=s,[t?"download":"upload"]:!0})},r)},Ce=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Oe=e=>(...t)=>V.asap(()=>e(...t));var Ae=de.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,de.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(de.origin),de.navigator&&/(msie|trident)/i.test(de.navigator.userAgent)):()=>!0,De=de.hasStandardBrowserEnv?{write(e,t,r,n,i,o){const s=[e+"="+encodeURIComponent(t)];V.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),V.isString(n)&&s.push("path="+n),V.isString(i)&&s.push("domain="+i),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function xe(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Ne=e=>e instanceof Se?{...e}:e;function Le(e,t){t=t||{};const r={};function n(e,t,r,n){return V.isPlainObject(e)&&V.isPlainObject(t)?V.merge.call({caseless:n},e,t):V.isPlainObject(t)?V.merge({},t):V.isArray(t)?t.slice():t}function i(e,t,r,i){return V.isUndefined(t)?V.isUndefined(e)?void 0:n(void 0,e,0,i):n(e,t,0,i)}function o(e,t){if(!V.isUndefined(t))return n(void 0,t)}function s(e,t){return V.isUndefined(t)?V.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,i,o){return o in t?n(r,i):o in e?n(void 0,r):void 0}const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,r)=>i(Ne(e),Ne(t),0,!0)};return V.forEach(Object.keys({...e,...t}),function(n){const o=c[n]||i,s=o(e[n],t[n],n);V.isUndefined(s)&&o!==a||(r[n]=s)}),r}var _e=e=>{const t=Le({},e);let r,{data:n,withXSRFToken:i,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=Se.from(a),t.url=ne(xe(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),V.isFormData(n))if(de.hasStandardBrowserEnv||de.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(r=a.getContentType())){const[e,...t]=r?r.split(";").map(e=>e.trim()).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(de.hasStandardBrowserEnv&&(i&&V.isFunction(i)&&(i=i(t)),i||!1!==i&&Ae(t.url))){const e=o&&s&&De.read(s);e&&a.set(o,e)}return t};var Ue="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){const n=_e(e);let i=n.data;const o=Se.from(n.headers).normalize();let s,a,c,u,l,{responseType:h,onUploadProgress:d,onDownloadProgress:g}=n;function p(){u&&u(),l&&l(),n.cancelToken&&n.cancelToken.unsubscribe(s),n.signal&&n.signal.removeEventListener("abort",s)}let f=new XMLHttpRequest;function m(){if(!f)return;const n=Se.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());Re(function(e){t(e),p()},function(e){r(e),p()},{data:h&&"text"!==h&&"json"!==h?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:n,config:e,request:f}),f=null}f.open(n.method.toUpperCase(),n.url,!0),f.timeout=n.timeout,"onloadend"in f?f.onloadend=m:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(m)},f.onabort=function(){f&&(r(new Q("Request aborted",Q.ECONNABORTED,e,f)),f=null)},f.onerror=function(){r(new Q("Network Error",Q.ERR_NETWORK,e,f)),f=null},f.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||oe;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new Q(t,i.clarifyTimeoutError?Q.ETIMEDOUT:Q.ECONNABORTED,e,f)),f=null},void 0===i&&o.setContentType(null),"setRequestHeader"in f&&V.forEach(o.toJSON(),function(e,t){f.setRequestHeader(t,e)}),V.isUndefined(n.withCredentials)||(f.withCredentials=!!n.withCredentials),h&&"json"!==h&&(f.responseType=n.responseType),g&&([c,l]=Ie(g,!0),f.addEventListener("progress",c)),d&&f.upload&&([a,u]=Ie(d),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",u)),(n.cancelToken||n.signal)&&(s=t=>{f&&(r(!t||t.type?new Pe(null,e,f):t),f.abort(),f=null)},n.cancelToken&&n.cancelToken.subscribe(s),n.signal&&(n.signal.aborted?s():n.signal.addEventListener("abort",s)));const w=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);w&&-1===de.protocols.indexOf(w)?r(new Q("Unsupported protocol "+w+":",Q.ERR_BAD_REQUEST,e)):f.send(i||null)})};var Fe=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const i=function(e){if(!r){r=!0,s();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Q?t:new Pe(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new Q(`timeout ${t} of ms exceeded`,Q.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));const{signal:a}=n;return a.unsubscribe=()=>V.asap(s),a}};const je=function*(e,t){let r=e.byteLength;if(!t||r<t)return void(yield e);let n,i=0;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},Be=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},Me=(e,t,r,n)=>{const i=async function*(e,t){for await(const r of Be(e))yield*je(r,t)}(e,t);let o,s=0,a=e=>{o||(o=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await i.next();if(t)return a(),void e.close();let o=n.byteLength;if(r){let e=s+=o;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},ze="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Ke=ze&&"function"==typeof ReadableStream,He=ze&&("function"==typeof TextEncoder?(Ve=new TextEncoder,e=>Ve.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Ve;const Qe=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},$e=Ke&&Qe(()=>{let e=!1;const t=new Request(de.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),qe=Ke&&Qe(()=>V.isReadableStream(new Response("").body)),Je={stream:qe&&(e=>e.body)};var We;ze&&(We=new Response,["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Je[e]&&(Je[e]=V.isFunction(We[e])?t=>t[e]():(t,r)=>{throw new Q(`Response type '${e}' is not supported`,Q.ERR_NOT_SUPPORT,r)})}));const Xe=async(e,t)=>{const r=V.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(V.isBlob(e))return e.size;if(V.isSpecCompliantForm(e)){const t=new Request(de.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return V.isArrayBufferView(e)||V.isArrayBuffer(e)?e.byteLength:(V.isURLSearchParams(e)&&(e+=""),V.isString(e)?(await He(e)).byteLength:void 0)})(t):r};const Ye={http:null,xhr:Ue,fetch:ze&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:l,withCredentials:h="same-origin",fetchOptions:d}=_e(e);u=u?(u+"").toLowerCase():"text";let g,p=Fe([i,o&&o.toAbortSignal()],s);const f=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let m;try{if(c&&$e&&"get"!==r&&"head"!==r&&0!==(m=await Xe(l,n))){let e,r=new Request(t,{method:"POST",body:n,duplex:"half"});if(V.isFormData(n)&&(e=r.headers.get("content-type"))&&l.setContentType(e),r.body){const[e,t]=Ce(m,Ie(Oe(c)));n=Me(r.body,65536,e,t)}}V.isString(h)||(h=h?"include":"omit");const i="credentials"in Request.prototype;g=new Request(t,{...d,signal:p,method:r.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",credentials:i?h:void 0});let o=await fetch(g,d);const s=qe&&("stream"===u||"response"===u);if(qe&&(a||s&&f)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=o[t]});const t=V.toFiniteNumber(o.headers.get("content-length")),[r,n]=a&&Ce(t,Ie(Oe(a),!0))||[];o=new Response(Me(o.body,65536,r,()=>{n&&n(),f&&f()}),e)}u=u||"text";let w=await Je[V.findKey(Je,u)||"text"](o,e);return!s&&f&&f(),await new Promise((t,r)=>{Re(t,r,{data:w,headers:Se.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:g})})}catch(t){if(f&&f(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Q("Network Error",Q.ERR_NETWORK,e,g),{cause:t.cause||t});throw Q.from(t,t&&t.code,e,g)}})};V.forEach(Ye,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Ge=e=>`- ${e}`,Ze=e=>V.isFunction(e)||null===e||!1===e;var et=e=>{e=V.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let o=0;o<t;o++){let t;if(r=e[o],n=r,!Ze(r)&&(n=Ye[(t=String(r)).toLowerCase()],void 0===n))throw new Q(`Unknown adapter '${t}'`);if(n)break;i[t||"#"+o]=n}if(!n){const e=Object.entries(i).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Q("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Ge).join("\n"):" "+Ge(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function tt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Pe(null,e)}function rt(e){tt(e),e.headers=Se.from(e.headers),e.data=ke.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return et(e.adapter||fe.adapter)(e).then(function(t){return tt(e),t.data=ke.call(e,e.transformResponse,t),t.headers=Se.from(t.headers),t},function(t){return Ee(t)||(tt(e),t&&t.response&&(t.response.data=ke.call(e,e.transformResponse,t.response),t.response.headers=Se.from(t.response.headers))),Promise.reject(t)})}const nt="1.11.0",it={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{it[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const ot={};it.transitional=function(e,t,r){function n(e,t){return"[Axios v"+nt+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,o)=>{if(!1===e)throw new Q(n(i," has been removed"+(t?" in "+t:"")),Q.ERR_DEPRECATED);return t&&!ot[i]&&(ot[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,o)}},it.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var st={assertOptions:function(e,t,r){if("object"!=typeof e)throw new Q("options must be an object",Q.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],s=t[o];if(s){const t=e[o],r=void 0===t||s(t,o,e);if(!0!==r)throw new Q("option "+o+" must be "+r,Q.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new Q("Unknown option "+o,Q.ERR_BAD_OPTION)}},validators:it};const at=st.validators;class ct{constructor(e){this.defaults=e||{},this.interceptors={request:new ie,response:new ie}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Le(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;void 0!==r&&st.assertOptions(r,{silentJSONParsing:at.transitional(at.boolean),forcedJSONParsing:at.transitional(at.boolean),clarifyTimeoutError:at.transitional(at.boolean)},!1),null!=n&&(V.isFunction(n)?t.paramsSerializer={serialize:n}:st.assertOptions(n,{encode:at.function,serialize:at.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),st.assertOptions(t,{baseUrl:at.spelling("baseURL"),withXsrfToken:at.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&V.merge(i.common,i[t.method]);i&&V.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=Se.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const c=[];let u;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,h=0;if(!a){const e=[rt.bind(this),void 0];for(e.unshift(...s),e.push(...c),l=e.length,u=Promise.resolve(t);h<l;)u=u.then(e[h++],e[h++]);return u}l=s.length;let d=t;for(h=0;h<l;){const e=s[h++],t=s[h++];try{d=e(d)}catch(e){t.call(this,e);break}}try{u=rt.call(this,d)}catch(e){return Promise.reject(e)}for(h=0,l=c.length;h<l;)u=u.then(c[h++],c[h++]);return u}getUri(e){return ne(xe((e=Le(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}V.forEach(["delete","get","head","options"],function(e){ct.prototype[e]=function(t,r){return this.request(Le(r||{},{method:e,url:t,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(e){function t(t){return function(r,n,i){return this.request(Le(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ct.prototype[e]=t(),ct.prototype[e+"Form"]=t(!0)});var ut=ct;class lt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e(function(e,n,i){r.reason||(r.reason=new Pe(e,n,i),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new lt(function(t){e=t}),cancel:e}}}var ht=lt;const dt={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};Object.entries(dt).forEach(([e,t])=>{dt[t]=e});var gt=dt;const pt=function t(r){const n=new ut(r),i=e(ut.prototype.request,n);return V.extend(i,ut.prototype,n,{allOwnKeys:!0}),V.extend(i,n,null,{allOwnKeys:!0}),i.create=function(e){return t(Le(r,e))},i}(fe);pt.Axios=ut,pt.CanceledError=Pe,pt.CancelToken=ht,pt.isCancel=Ee,pt.VERSION=nt,pt.toFormData=G,pt.AxiosError=Q,pt.Cancel=pt.CanceledError,pt.all=function(e){return Promise.all(e)},pt.spread=function(e){return function(t){return e.apply(null,t)}},pt.isAxiosError=function(e){return V.isObject(e)&&!0===e.isAxiosError},pt.mergeConfig=Le,pt.AxiosHeaders=Se,pt.formToJSON=e=>ge(V.isHTMLForm(e)?new FormData(e):e),pt.getAdapter=et,pt.HttpStatusCode=gt,pt.default=pt;const ft=pt.create({timeout:1e4,headers:{"Content-Type":"application/json"}});ft.interceptors.request.use(e=>e,e=>Promise.reject(e)),ft.interceptors.response.use(e=>e,e=>Promise.reject(e));var mt=require("ua-parser-js");const wt="undefined"!=typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>Date.now();function yt(e,t,r="0"){const n=String(e);if(n.length<t){let e=n;for(let i=0;i<t-n.length;i+=1)e=r+e;return e}return n}function bt(){const e=new Date,t=parseInt(`${e.getFullYear()}${yt(e.getMonth()+1,2)}${yt(e.getDate(),2)}`,10).toString(16),r=parseInt(`${yt(e.getHours(),2)}${yt(e.getMinutes(),2)}${yt(e.getSeconds(),2)}${yt(e.getMilliseconds(),3)}`,10).toString(16);let n=t+r.length+r;for(;n.length<32;)n+=Math.floor(16*Math.random()).toString(16);return`${n.slice(0,8)}-${n.slice(8,16)}-${n.slice(16)}`}let vt=0;function Tt(){const e=Date.now().toString(36).slice(-8).padStart(8,"0");vt=(vt+1)%46656;const t=Math.floor(36*Math.random());return e+(vt.toString(36).padStart(2,"0")+t.toString(36)).padStart(4,"0").slice(-4)}const St=()=>(()=>{if("undefined"!=typeof WeixinJSBridge)return!0;var e=navigator.userAgent.toLowerCase();return!(-1===e.indexOf("micromessenger")&&"micromessenger"!=e.match(/MicroMessenger/i))})()?"WECHAT":(()=>{const e=navigator.userAgent.toLowerCase();return!(-1===e.indexOf("alipay")&&"alipay"!=e.match(/Alipay/i))})()?"ALIPAY":"OTHER",kt=e=>{const t=e.indexOf("#");if(-1===t)return"";return e.slice(t+1).replace(/^\//,"").split("?")[0]},Et=(e,t)=>["HONGSHUN"].includes(t)&&"chargeMoney"===e&&window.location.href.indexOf("showMoney=false")>-1?"EQUITY":{login:"LOGIN",buyPkgListNew:"BUY_LIST",cardDetailInfo:"CARD_DETAIL",flowSettle:"SETTLEMENT",chargeMoney:"WALLET",payOrderDetail:"ORDER_DETAIL"}[e]||e,Pt=()=>{const e=(console.log("window.UAParser-----",mt),console.log("UAParser-----",window),mt.getResult());return["iOS","Android"].includes(e?.os?.name)?e?.os?.name:"其他"};class Rt{constructor(e){this.config=e,this.isReporting=!1}async report(e,t){this.config.getConfig().debugSwitch&&console.log("report----------",e,t);try{const r=this.formatReportData(e,t);this.config.getConfig().customReport?await this.config.getConfig().customReport(e,r):await this.defaultReport(e,r)}catch(t){console.error("上报失败:",t),this.config.getConfig().debugSwitch&&console.error("上报失败详情:",{type:e,error:t.message,stack:t.stack})}}getDeviceInfo(){return{screen:{width:screen.width,height:screen.height,availWidth:screen.availWidth,availHeight:screen.availHeight,colorDepth:screen.colorDepth,pixelDepth:screen.pixelDepth},viewport:{width:window.innerWidth,height:window.innerHeight},connection:navigator.connection?{effectiveType:navigator.connection.effectiveType,downlink:navigator.connection.downlink,rtt:navigator.connection.rtt}:null,memory:navigator.memory?{usedJSHeapSize:navigator.memory.usedJSHeapSize,totalJSHeapSize:navigator.memory.totalJSHeapSize,jsHeapSizeLimit:navigator.memory.jsHeapSizeLimit}:null}}formatReportData(e,t){const r={sessionId:this.config.getConfig().sessionId||"",channel:St(),uiVer:this.config.getConfig().uiVersion,osType:Pt(),screenWidth:screen.width,screenHeight:screen.height,windowInnerWidth:window.innerWidth,windowInnerHeight:window.innerHeight,netType:navigator.connection?navigator.connection.effectiveType:"",tags:{customerId:this.config.getConfig().customerId,deviceId:this.config.getConfig().deviceId,deviceNo:this.config.getConfig().deviceNo,userId:this.config.getConfig().userId}},n=Array.isArray(t)?t:[t];return n.forEach(e=>{const t=Object.assign({},r.tags||{},e&&e.tags||{});Object.assign(e,r),Object.keys(t).length>0&&(e.tags=t)}),n}async defaultReport(e,t){const r=this.config.getReportUrl(),n=this.config.getThirdPartyConfig();r&&await this.reportToBackend(r,t),n&&Object.keys(n).length>0&&await this.reportToThirdParty(n,t)}async reportToBackend(e,t){if(!navigator.sendBeacon||this.isObjectOverSizeLimit(t,60))return this.config.getConfig().debugSwitch&&console.warn("浏览器不支持 sendBeacon,使用 axios"),await this.reportViaAxios(e,t);{const r=new FormData;r.append("events",JSON.stringify(t));const n=navigator.sendBeacon(e,r);if(this.config.getConfig().debugSwitch&&console.log("上报数据:",e,t),!n)return await this.reportViaAxios(e,FormData)}}async reportViaAxios(e,t){try{return(await ft.post(e,t)).data}catch(e){console.error("后端上报失败:",e)}}async reportToThirdParty(e,t){const r=[];e.baidu&&window._hmt&&r.push(this.reportToBaidu(e.baidu,t)),e.umeng&&window._um&&r.push(this.reportToUmeng(e.umeng,t)),e.sensors&&window.sensors&&r.push(this.reportToSensors(e.sensors,t)),e.tencent&&window.MTA&&r.push(this.reportToTencent(e.tencent,t)),e.custom&&r.push(this.reportToCustom(e.custom,t));try{await Promise.allSettled(r)}catch(e){console.error("第三方上报失败:",e)}}async reportToBaidu(e,t){window._hmt&&window._hmt.push(["_trackEvent",t.type,JSON.stringify(t.data)])}async reportToUmeng(e,t){window._um&&window._um.push(["track",t.type,t.data])}async reportToSensors(e,t){window.sensors&&window.sensors.track(t.type,t.data[0]||{})}async reportToTencent(e,t){window.MTA&&window.MTA.Event.stat(t.type,t.data[0]||{})}async reportToCustom(e,t){"function"==typeof e.report&&await e.report(t)}isObjectOverSizeLimit(e,t){const r=JSON.stringify(e);return(new TextEncoder).encode(r).length/1024>t}}class It{constructor(e){this.config=e,this.reporter=new Rt(e),this.errorQueue=[],this.isInitialized=!1,this.reportTimer=null,this.errorCache=new Map,this.errorCacheTimeout=5e3,this.maxCacheSize=100,this.errorFingerprint=this.createErrorFingerprint.bind(this),this.errorTimeout=null,this.resourceErrorTimeout=null,this.lastResourceError=null}createErrorFingerprint(e,t){const r=e?.message||e?.toString()||e,n=e?.stack||t.stack;return`${t.type||"unknown"}:${r}:${window.location.href}:${n?n.split("\n")[0]:""}`}isDuplicateError(e,t){const r=this.errorFingerprint(e,t),n=Date.now();if(this.cleanupErrorCache(n),this.errorCache.has(r)){if(n-this.errorCache.get(r)<this.errorCacheTimeout)return!0}if(this.errorCache.set(r,n),this.errorCache.size>this.maxCacheSize){const e=this.errorCache.keys().next().value;this.errorCache.delete(e)}return!1}cleanupErrorCache(e){for(const[t,r]of this.errorCache.entries())e-r>this.errorCacheTimeout&&this.errorCache.delete(t)}init(){if(this.isInitialized)return;const e=this.config.getConfig();(e.enableErrorTracking||e.enableResourceError)&&this.setupErrorListener(),e.enableUnhandledRejection&&this.setupUnhandledRejectionListener(),e.reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushErrorQueue()},e))}setupErrorListener(){window.addEventListener("error",e=>{e.target&&e.target!==window?this.handleResourceError(e):this.handleJavaScriptError(e)},!0)}handleJavaScriptError(e){this.errorTimeout&&clearTimeout(this.errorTimeout),this.errorTimeout=setTimeout(()=>{this.handleError(e.error||e.message,{type:"javascript",filename:e.filename,lineno:e.lineno,colno:e.colno,stack:e.error?.stack})},100)}handleResourceError(e){const t=`${e.target.tagName}:${e.target.src||e.target.href}`;this.lastResourceError!==t?(this.lastResourceError=t,this.resourceErrorTimeout&&clearTimeout(this.resourceErrorTimeout),this.resourceErrorTimeout=setTimeout(()=>{this.handleError(`Resource load failed: ${e.target.src||e.target.href}`,{type:"resource",tagName:e.target.tagName,src:e.target.src,href:e.target.href}),setTimeout(()=>{this.lastResourceError=null},2e3)},100)):this.config.getConfig().debugSwitch&&console.log("忽略重复的资源加载错误:",t)}setupUnhandledRejectionListener(){let e=null,t=null;window.addEventListener("unhandledrejection",r=>{const n=`${r.reason?.message||r.reason}:${r.reason?.stack||""}`;t!==n?(t=n,e&&clearTimeout(e),e=setTimeout(()=>{this.handleError(r.reason,{type:"unhandledrejection",stack:r.reason?.stack}),setTimeout(()=>{t=null},1e3)},100)):this.config.getConfig().debugSwitch&&console.log("忽略重复的 Promise 拒绝:",r.reason)})}handleError(e,t={}){if(this.isDuplicateError(e,t))return void(this.config.getConfig().debugSwitch&&console.log("忽略重复错误:",e?.message||e));const r=this.parseStack(e),n={message:e?.message||e?.toString()||e,stack:e?.stack||t.stack,type:t.type||"unknown",timestamp:Date.now(),url:window.location.href,userAgent:navigator.userAgent,fileName:r.fileName,lineNumber:r.lineNumber,columnNumber:r.columnNumber,functionName:r.functionName,stackFrames:r.stackFrames,...t};this.errorQueue.push(n),this.config.getConfig().debugSwitch&&console.log("errorInfo-----",n),0===this.config.getConfig().reportInterval?this.reporter.report("error",[n]):this.errorQueue.length>=this.config.getConfig().maxQueueSize&&this.flushErrorQueue()}parseStack(e){const t=e?.stack||"",r=e?.message||e?.toString()||"",n={errMessage:r,errStack:t,fileName:"",lineNumber:"",columnNumber:"",functionName:"",stackFrames:[]};if(!t)return n;try{const e=/^\s*at\s+([^(]+?)\s+\((.+?):(\d+):(\d+)\)$/,i=/^\s*at\s+(.+?):(\d+):(\d+)$/,o=/^\s*([^@]*)@(.+?):(\d+):(\d+)$/;let s=t;if(r&&t.startsWith(r))s=t.substring(r.length).replace(/^\n+/,"");else if(t.includes("\n")){const e=t.split("\n");!e[0]||e[0].trim().startsWith("at")||e[0].includes("@")||(s=e.slice(1).join("\n"))}const a=s.split("\n").filter(e=>e.trim()),c=[];for(const t of a){let r=null,n=t.match(e);n?r={functionName:n[1].trim(),fileName:n[2],lineNumber:parseInt(n[3]),columnNumber:parseInt(n[4])}:(n=t.match(i),n?r={functionName:"",fileName:n[1],lineNumber:parseInt(n[2]),columnNumber:parseInt(n[3])}:(n=t.match(o),n&&(r={functionName:n[1].trim(),fileName:n[2],lineNumber:parseInt(n[3]),columnNumber:parseInt(n[4])}))),r&&c.push(r)}if(c.length>0){const e=c[0];n.fileName=e.fileName,n.lineNumber=e.lineNumber,n.columnNumber=e.columnNumber,n.functionName=e.functionName}n.stackFrames=c}catch(e){this.config?.getConfig()?.debugSwitch&&console.warn("解析堆栈失败:",e)}return n}reportError(e,t={}){this.handleError(e,t)}flushErrorQueue(){this.errorQueue.length>0&&(this.reporter.report("error",[...this.errorQueue]),this.errorQueue=[])}destroy(){this.config.getConfig().reportInterval>0&&this.flushErrorQueue(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.isInitialized=!1}}class Ct{constructor(e){this.config=e,this.reporter=new Rt(e),this.eventQueue=[],this.isInitialized=!1,this.clickListener=null,this.pageViewListener=null,this.reportTimer=null,this.originalPushState=null,this.originalReplaceState=null,this.pageHistory=[],this.currentPage=null,this.currentPageStartTime=Date.now(),this.previousPage=null,this.previousPageStayTime=0}init(){if(this.isInitialized)return;const e=this.config.getConfig();this.currentPage={url:window.location.href,title:document.title,enterTime:Date.now(),referrer:document.referrer},this.currentPageStartTime=Date.now(),e.enableClickTracking&&this.setupClickTracking(),e.enablePageViewTracking&&this.setupPageViewTracking(),window.addEventListener("beforeunload",()=>{this.handlePageUnload()}),document.addEventListener("visibilitychange",()=>{}),this.config.getConfig().reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0}handlePageUnload(){if(this.currentPage){const e=Date.now()-this.currentPageStartTime;this.previousPage={...this.currentPage,stayTime:e,leaveTime:Date.now()},this.previousPageStayTime=e}}setupClickTracking(){this.clickListener=e=>{const t=e.target,r={type:"click",timestamp:Date.now(),url:window.location.href,element:{tagName:t.tagName,className:t.className,id:t.id,text:t.textContent?.substring(0,50)},position:{x:e.clientX,y:e.clientY}};this.handleEvent("click",r)},document.addEventListener("click",this.clickListener,!0)}setupPageViewTracking(){const e=this.config.getConfig().pageViewTracking||{};let t=window.location.href,r=Date.now();const n=e.debounce||100;this.pageViewListener=()=>{const e=window.location.href,i=Date.now();e===t&&i-r<n&&this.config.getConfig().debugSwitch?console.log("忽略重复的页面浏览事件:",e):(this.handlePageChange(e,i),t=e,r=i,this.handleEvent("pageview",{uuid:Tt(),timestamp:i,pageKey:Et(kt(e),this.config.getConfig().uiVersion),pageUri:kt(e),eventType:"VIEW"}))},!1!==e.listenPopstate&&window.addEventListener("popstate",this.pageViewListener),!1!==e.listenHistoryAPI&&(this.originalPushState=history.pushState,this.originalReplaceState=history.replaceState,history.pushState=function(...e){this.originalPushState.apply(history,e),setTimeout(()=>{this.pageViewListener()},0)}.bind(this),history.replaceState=function(...e){this.originalReplaceState.apply(history,e),setTimeout(()=>{this.pageViewListener()},0)}.bind(this)),e.vueRouterMode&&(this.config.getConfig().debugSwitch&&console.log("Vue Router 模式:页面浏览追踪已优化"),this.pageViewListener())}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushEventQueue()},e))}handlePageChange(e,t){if(this.currentPage){const r=t-this.currentPageStartTime;this.previousPage={...this.currentPage,stayTime:r,leaveTime:t},this.previousPageStayTime=r,this.pageHistory.push({...this.previousPage}),this.pageHistory.length>20&&this.pageHistory.shift(),this.config.getConfig().debugSwitch&&console.log(`页面切换: ${this.currentPage.url} → ${e},停留时间: ${r}ms`)}this.currentPage={url:e,title:document.title,enterTime:t,referrer:document.referrer},this.currentPageStartTime=t}getPreviousPageInfo(){return{previousPage:this.previousPage?{url:this.previousPage.url,title:this.previousPage.title,stayTime:this.previousPageStayTime}:null,previousPageStayTime:this.previousPageStayTime}}getCurrentPageStayTime(){return this.currentPageStartTime?Date.now()-this.currentPageStartTime:0}handleEvent(e,t){const r=this.getPreviousPageInfo(),n={...t,refer:kt(r?.previousPage?.url),duration:r?.previousPageStayTime};this.eventQueue.push(n),this.config.getConfig().debugSwitch&&console.log("eventInfo----",n),0===this.config.getConfig().reportInterval?this.reporter.report("event",[n]):this.eventQueue.length>=this.config.getConfig().maxQueueSize&&this.flushEventQueue()}reportEvent(e,t={}){const r={uuid:Tt(),timestamp:Date.now(),actionKey:e,pageKey:Et(kt(window.location.href),this.config.getConfig().uiVersion),pageUri:kt(window.location.href),eventType:"CLICK",tags:t};this.handleEvent(e,r)}flushEventQueue(){this.eventQueue.length>0&&(this.reporter.report("event",[...this.eventQueue]),this.eventQueue=[])}destroy(){this.flushEventQueue(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.clickListener&&(document.removeEventListener("click",this.clickListener,!0),this.clickListener=null),this.pageViewListener&&(window.removeEventListener("popstate",this.pageViewListener),this.pageViewListener=null),this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),this.originalReplaceState&&(history.replaceState=this.originalReplaceState,this.originalReplaceState=null),this.isInitialized=!1}}class Ot{constructor(e){this.config=e,this.reporter=new Rt(e),this.isInitialized=!1,this.pageStartTime=Date.now(),this.performanceQueue=[],this.thirdPartySDKs={},this.reportTimer=null,this.currentRoute=null,this.routeStartTime=Date.now(),this.routeHistory=[],this.vueRouter=null,this.metrics={fcp:0,lcp:0,fid:0,cls:0,ttfb:0,domLoad:0,windowLoad:0,resourceLoad:[],apiRequests:[],pageStayTime:0}}init(){if(this.isInitialized)return;const e=this.config.getConfig();e.enablePerformanceTracking&&this.setupPerformanceMonitoring(),e.enableResourceTracking&&this.setupResourceMonitoring(),e.enableInteractionTracking&&this.setupInteractionMonitoring(),this.initThirdPartySDKs(),e.reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushPerformanceQueue()},e))}setupVueRouterMonitoring(e){e&&!this.vueRouter&&(this.vueRouter=e,this.currentRoute=e.currentRoute.value,e.beforeEach((e,t,r)=>{t.name&&this.handleRouteLeave(t,e),r()}),e.afterEach((e,t)=>{this.handleRouteEnter(e,t)}),e.beforeResolve((e,t,r)=>{t.name&&this.calculateRouteStayTime(t),r()}),this.config?.config?.debugSwitch&&console.log("Vue Router 监控已设置"))}handleRouteLeave(e,t){const r=Date.now()-this.routeStartTime;this.recordRouteStayTime(e,r),this.currentRoute=e,this.routeStartTime=Date.now()}handleRouteEnter(e,t){this.routeStartTime=Date.now(),this.currentRoute=e,this.recordRouteEnter(e,t)}recordRouteStayTime(e,t){const r={name:e.name||"unknown",path:e.path,fullPath:e.fullPath,stayTime:t,enterTime:this.routeStartTime,leaveTime:Date.now(),params:e.params,query:e.query,meta:e.meta};this.routeHistory.push(r),this.metrics.pageStayTime=t,this.reportRouteStayTime(r),this.config?.config?.debugSwitch&&console.log("路由数据",r)}recordRouteEnter(e,t){e.name,e.path,e.fullPath,Date.now(),e.params,e.query,e.meta,t&&(t.name,t.path),this.config?.config?.debugSwitch&&console.log(`进入路由: ${e.name||e.path}`)}calculateRouteStayTime(e){if(!this.routeStartTime)return 0;return Date.now()-this.routeStartTime}reportRouteStayTime(e){const t={type:"route_stay_time",timestamp:Date.now(),route:e,user:this.config.getUser(),device:this.getDeviceInfo()};this.reporter.report("route_performance",[t])}getCurrentRoute(){return this.currentRoute}getRouteHistory(){return[...this.routeHistory]}getCurrentPageStayTime(){return this.routeStartTime?Date.now()-this.routeStartTime:0}getRoutePerformanceStats(){const e={totalRoutes:this.routeHistory.length,averageStayTime:0,routesByPath:new Map,totalStayTime:0};return this.routeHistory.length>0&&(this.routeHistory.forEach(t=>{e.totalStayTime+=t.stayTime,e.routesByPath.has(t.path)||e.routesByPath.set(t.path,{count:0,totalStayTime:0,averageStayTime:0});const r=e.routesByPath.get(t.path);r.count++,r.totalStayTime+=t.stayTime,r.averageStayTime=r.totalStayTime/r.count}),e.averageStayTime=e.totalStayTime/e.totalRoutes),e}setupPerformanceMonitoring(){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{this.captureDOMLoadTime()}):this.captureDOMLoadTime(),window.addEventListener("load",()=>{this.captureWindowLoadTime(),this.captureWebVitals(),this.reportPerformanceMetrics()})}setupResourceMonitoring(){if("undefined"!=typeof window&&"PerformanceObserver"in window){const e=new PerformanceObserver(e=>{for(const t of e.getEntries())"resource"===t.entryType&&this.handleResourceLoad(t)});try{e.observe({entryTypes:["resource"]})}catch(e){this.setupResourceFallback()}}}setupInteractionMonitoring(){let e=0,t=0;const r=n=>{0===e&&(e=wt(),t=e-this.metrics.fcp,this.metrics.fid=t,document.removeEventListener("click",r,!0),document.removeEventListener("keydown",r,!0),document.removeEventListener("touchstart",r,!0))};document.addEventListener("click",r,!0),document.addEventListener("keydown",r,!0),document.addEventListener("touchstart",r,!0)}captureDOMLoadTime(){this.metrics.domLoad=wt()}captureWindowLoadTime(){this.metrics.windowLoad=wt()}captureWebVitals(){if("undefined"!=typeof window&&"PerformanceObserver"in window)try{new PerformanceObserver(e=>{for(const t of e.getEntries())"first-contentful-paint"===t.name&&(this.metrics.fcp=t.startTime,this.config?.config?.debugSwitch&&console.log("FCP:",t.startTime))}).observe({type:"paint",buffered:!0})}catch(e){console.warn("FCP监控失败:",e)}if("undefined"!=typeof window&&"PerformanceObserver"in window)try{new PerformanceObserver(e=>{for(const t of e.getEntries())this.metrics.lcp=t.startTime}).observe({entryTypes:["largest-contentful-paint"]})}catch(e){console.warn("LCP监控失败:",e)}if("undefined"!=typeof window&&"PerformanceObserver"in window)try{let e=0;new PerformanceObserver(t=>{for(const r of t.getEntries())r.hadRecentInput||(e+=r.value);this.metrics.cls=e}).observe({entryTypes:["layout-shift"]})}catch(e){console.warn("CLS监控失败:",e)}}handleResourceLoad(e){const t={name:e.name,type:e.initiatorType,duration:e.duration,size:e.transferSize,timestamp:Date.now()};this.metrics.resourceLoad.push(t),e.duration>3e3&&this.reportSlowResource(t)}handlePageHidden(){this.calculatePageStayTime()}handlePageVisible(){this.pageStartTime=Date.now()}calculatePageStayTime(){const e=Date.now()-this.pageStartTime;this.reportPageStayTime(e)}reportPerformanceMetrics(){const e={type:"performance",timestamp:Date.now(),url:window.location.href,userAgent:navigator.userAgent,metrics:this.metrics,user:this.config.getUser(),device:this.getDeviceInfo()};this.performanceQueue.push(e),this.config.getConfig().debugSwitch&&console.log("Performance Data:",e),0===this.config.getConfig().reportInterval?this.reporter.report("performance",[e]):this.performanceQueue.length>=this.config.getConfig().maxQueueSize&&this.flushPerformanceQueue()}reportSlowResource(e){this.reporter.report("slow_resource",[e])}reportSlowApi(e){this.reporter.report("slow_api",[e])}reportPageStayTime(e){const t={type:"page_stay",url:window.location.href,stayTime:e,timestamp:Date.now()};this.reporter.report("page_stay",[t])}getDeviceInfo(){return{screen:{width:screen.width,height:screen.height,availWidth:screen.availWidth,availHeight:screen.availHeight,colorDepth:screen.colorDepth,pixelDepth:screen.pixelDepth},viewport:{width:window.innerWidth,height:window.innerHeight},connection:navigator.connection?{effectiveType:navigator.connection.effectiveType,downlink:navigator.connection.downlink,rtt:navigator.connection.rtt}:null,memory:navigator.memory?{usedJSHeapSize:navigator.memory.usedJSHeapSize,totalJSHeapSize:navigator.memory.totalJSHeapSize,jsHeapSizeLimit:navigator.memory.jsHeapSizeLimit}:null}}initThirdPartySDKs(){const e=this.config.getThirdPartyConfig();e.baidu&&window._hmt&&(this.thirdPartySDKs.baidu=window._hmt),e.umeng&&window._um&&(this.thirdPartySDKs.umeng=window._um),e.sensors&&window.sensors&&(this.thirdPartySDKs.sensors=window.sensors),e.tencent&&window.MTA&&(this.thirdPartySDKs.tencent=window.MTA)}flushPerformanceQueue(){this.performanceQueue.length>0&&(this.reporter.report("performance",[...this.performanceQueue]),this.performanceQueue=[])}reportPerformance(e={}){const t={type:"custom_performance",timestamp:Date.now(),url:window.location.href,metrics:e,user:this.config.getUser()};this.reporter.report("performance",[t])}getCurrentMetrics(){return{...this.metrics}}destroy(){this.config.getConfig().reportInterval>0&&this.flushPerformanceQueue(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.isInitialized=!1}}class At{constructor(e){this.config=e,this.reporter=new Rt(e),this.isInitialized=!1,this.behaviorQueue=[],this.sessionId=this.generateSessionId(),this.pageStartTime=Date.now(),this.scrollDepth=0,this.mouseMovements=[],this.keyStrokes=[],this.formInteractions=[],this.timeTracker=null,this.reportTimer=null,this.originalPushState=null,this.originalReplaceState=null,this.behaviors={pageViews:[],clicks:[],scrolls:[],formSubmissions:[],navigation:[],timeOnPage:0}}init(){if(this.isInitialized)return;const e=this.config.getConfig();e.enableUserInteractionTracking&&this.setupUserInteractionTracking(),e.enableFormTracking&&this.setupFormTracking(),e.enableScrollTracking&&this.setupScrollTracking(),e.enableMouseTracking&&this.setupMouseTracking(),e.enableKeyboardTracking&&this.setupKeyboardTracking(),this.setupTimeTracking(),e.reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushBehaviorQueue()},e))}setupUserInteractionTracking(){document.addEventListener("click",e=>{this.trackClick(e)},!0),document.addEventListener("dblclick",e=>{this.trackDoubleClick(e)},!0),document.addEventListener("contextmenu",e=>{this.trackRightClick(e)},!0),"ontouchstart"in window&&document.addEventListener("touchstart",e=>{this.trackTouch(e)},!0)}setupFormTracking(){document.addEventListener("submit",e=>{this.trackFormSubmission(e)},!0),document.addEventListener("change",e=>{"INPUT"!==e.target.tagName&&"SELECT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName||this.trackFormFieldChange(e)},!0),document.addEventListener("focus",e=>{"INPUT"!==e.target.tagName&&"SELECT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName||this.trackFormFieldFocus(e)},!0),document.addEventListener("blur",e=>{"INPUT"!==e.target.tagName&&"SELECT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName||this.trackFormFieldBlur(e)},!0)}setupScrollTracking(){let e;document.addEventListener("scroll",()=>{clearTimeout(e),e=setTimeout(()=>{const e=window.pageYOffset||document.documentElement.scrollTop,t=document.documentElement.scrollHeight,r=document.documentElement.clientHeight,n=Math.round(e/(t-r)*100);n>this.scrollDepth&&(this.scrollDepth=n,this.trackScroll(n,e))},100)},{passive:!0})}setupMouseTracking(){let e,t=[];document.addEventListener("mousemove",r=>{clearTimeout(e),t.push({x:r.clientX,y:r.clientY,timestamp:Date.now()}),t.length>100&&t.shift(),e=setTimeout(()=>{t.length>10&&(this.trackMouseMovement(t),t=[])},1e3)},{passive:!0})}setupKeyboardTracking(){document.addEventListener("keydown",e=>{"password"!==e.target.type&&this.trackKeyStroke(e)},!0)}setupTimeTracking(){this.timeTracker&&clearInterval(this.timeTracker),this.timeTracker=setInterval(()=>{this.behaviors.timeOnPage+=1},1e3),window.addEventListener("beforeunload",()=>{this.reportTimeOnPage()})}trackReferrer(){const e=document.referrer;if(e){const t={type:"referrer",url:e,domain:this.extractDomain(e),timestamp:Date.now()};this.config.getConfig().debugSwitch&&console.log("referrerData----",t),this.behaviors.navigation.push(t),this.reportBehavior("referrer",t)}}trackPageView(){const e={type:"pageview",url:window.location.href,title:document.title,timestamp:Date.now(),sessionId:this.sessionId,referrer:document.referrer};this.behaviors.pageViews.push(e),this.reportBehavior("pageview",e),this.pageStartTime=Date.now(),this.scrollDepth=0}trackClick(e){const t={type:"click",element:{tagName:e.target.tagName,className:e.target.className,id:e.target.id,text:e.target.textContent?.substring(0,50),href:e.target.href},position:{x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY},timestamp:Date.now(),sessionId:this.sessionId};this.behaviors.clicks.push(t),this.reportBehavior("click",t)}trackDoubleClick(e){const t={type:"doubleclick",element:{tagName:e.target.tagName,className:e.target.className,id:e.target.id},position:{x:e.clientX,y:e.clientY},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("doubleclick",t)}trackRightClick(e){const t={type:"rightclick",element:{tagName:e.target.tagName,className:e.target.className,id:e.target.id},position:{x:e.clientX,y:e.clientY},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("rightclick",t)}trackTouch(e){const t={type:"touch",touches:Array.from(e.touches).map(e=>({x:e.clientX,y:e.clientY,identifier:e.identifier})),timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("touch",t)}trackFormSubmission(e){const t={type:"form_submission",form:{action:e.target.action,method:e.target.method,id:e.target.id,className:e.target.className},fields:this.getFormFields(e.target),timestamp:Date.now(),sessionId:this.sessionId};this.behaviors.formSubmissions.push(t),this.reportBehavior("form_submission",t)}trackFormFieldChange(e){const t={type:"form_field_change",field:{name:e.target.name,type:e.target.type,value:"password"===e.target.type?"***":e.target.value,id:e.target.id},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("form_field_change",t)}trackFormFieldFocus(e){const t={type:"form_field_focus",field:{name:e.target.name,type:e.target.type,id:e.target.id},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("form_field_focus",t)}trackFormFieldBlur(e){const t={type:"form_field_blur",field:{name:e.target.name,type:e.target.type,id:e.target.id},timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("form_field_blur",t)}trackScroll(e,t){const r={type:"scroll",depth:e,scrollTop:t,timestamp:Date.now(),sessionId:this.sessionId};this.config.getConfig().debugSwitch&&console.log("scrollData---",r),this.reportBehavior("scroll",r)}trackMouseMovement(e){const t={type:"mouse_movement",movements:e,timestamp:Date.now(),sessionId:this.sessionId};this.config.getConfig().debugSwitch&&console.log("mouse_movement---",t),this.reportBehavior("mouse_movement",t)}trackKeyStroke(e){const t={type:"keystroke",key:e.key,code:e.code,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,timestamp:Date.now(),sessionId:this.sessionId};this.config.getConfig().debugSwitch&&console.log("keystroke---",t),this.reportBehavior("keystroke",t)}reportBehavior(e,t){const r={type:e,data:t,user:this.config.getUser(),config:{appId:this.config.getConfig().appId,appVersion:this.config.getConfig().appVersion}};this.behaviorQueue.push(r),0===this.config.getConfig().reportInterval?this.reporter.report("behavior",[r]):this.behaviorQueue.length>=this.config.getConfig().maxQueueSize&&this.flushBehaviorQueue()}reportCustomBehavior(e,t={}){const r={type:"custom_behavior",eventName:e,...t,timestamp:Date.now(),sessionId:this.sessionId};this.reportBehavior("custom_behavior",r)}flushBehaviorQueue(){this.behaviorQueue.length>0&&(this.reporter.report("behavior",[...this.behaviorQueue]),this.behaviorQueue=[])}getFormFields(e){const t=[],r=e.elements;for(let e=0;e<r.length;e++){const n=r[e];n.name&&t.push({name:n.name,type:n.type,value:"password"===n.type?"***":n.value})}return t}extractDomain(e){try{return new URL(e).hostname}catch(t){return e}}generateSessionId(){return"session_"+Date.now()+"_"+Math.random().toString(36).substr(2,9)}getCurrentBehaviors(){return{...this.behaviors}}getSessionId(){return this.sessionId}destroy(){this.config.getConfig().reportInterval>0&&this.flushBehaviorQueue(),this.reportTimeOnPage(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.timeTracker&&(clearInterval(this.timeTracker),this.timeTracker=null),this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),this.originalReplaceState&&(history.replaceState=this.originalReplaceState,this.originalReplaceState=null),this.isInitialized=!1}}class Dt{constructor(e,t=null){this.config=e,this.reporter=new Rt(e),this.eventTracker=t,this.isInitialized=!1,this.observer=null,this.trackedElements=new Map,this.exposureQueue=[],this.reportTimer=null,this.scrollTimer=null,this.useFallback=!1,this.lastReportTime=new Map,this.debounceTime=500,this.defaultOptions={threshold:.5,rootMargin:"0px",scrollThrottle:100}}init(){if(this.isInitialized)return;this.isIntersectionObserverSupported()?(this.createObserver(),this.useFallback=!1,this.config.getConfig().debugSwitch&&console.log("曝光追踪器初始化完成(使用 Intersection Observer API)")):(this.setupFallbackTracking(),this.useFallback=!0,this.config.getConfig().debugSwitch&&console.warn("浏览器不支持 Intersection Observer,使用降级方案(滚动事件追踪)"));const e=this.config.getConfig();e.reportInterval>0&&this.setupPeriodicReport(),this.isInitialized=!0,e.debugSwitch&&console.log("曝光追踪器初始化完成")}isIntersectionObserverSupported(){return"undefined"!=typeof window&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype}createObserver(){const e={root:null,rootMargin:this.defaultOptions.rootMargin,threshold:[0,.5,1]};this.observer=new IntersectionObserver(e=>{e.forEach(e=>{this.handleIntersection(e)})},e)}handleIntersection(e){console.log("entry-------",e);const t=e.target,r=this.getElementId(t),n=this.getElementConfig(t),i=n.threshold||this.defaultOptions.threshold,o=e.intersectionRatio,s=o>=i;if(this.config.getConfig().debugSwitch&&console.log(`元素 ${r} 可见性检查:`,{visibleRatio:(100*o).toFixed(2)+"%",threshold:(100*i).toFixed(2)+"%",isThresholdMet:s}),s){this.trackedElements.has(r)||this.trackedElements.set(r,{element:t,config:n});const e=this.trackedElements.get(r),i=Date.now(),s=i-(this.lastReportTime.get(r)||0);s>=this.debounceTime?(this.lastReportTime.set(r,i),this.triggerExposure(t,r,e,o,0),this.config.getConfig().debugSwitch&&console.log(`元素 ${r} 进入可视区域,可见比例: ${(100*o).toFixed(2)}%,立即触发曝光`)):this.config.getConfig().debugSwitch&&console.log(`元素 ${r} 跳过上报(去重),距离上次上报 ${s}ms,需要间隔 ${this.debounceTime}ms`)}}triggerExposure(e,t,r,n,i){const o=this.extractProductInfo(e,r.config);let s={};this.eventTracker&&"function"==typeof this.eventTracker.getPreviousPageInfo&&(s=this.eventTracker.getPreviousPageInfo());const a=this.getElementConfig(e),c={uuid:Tt(),timestamp:Date.now(),pageKey:Et(kt(window.location.href),this.config.getConfig().uiVersion),pageUri:kt(window.location.href),eventType:"EXPOSE",actionKey:"",refer:kt(s?.previousPage?.url),duration:s?.previousPageStayTime,viewParam:{...o},tags:{...a}};this.exposureQueue.push(c),this.config.getConfig().debugSwitch&&console.log("商品曝光事件:",c);0===this.config.getConfig().reportInterval?Promise.resolve().then(()=>{this.reporter.report("exposure",this.getReportData([c])).catch(e=>{console.error("曝光上报失败:",e),this.config.getConfig().debugSwitch&&console.error("曝光上报失败详情:",e)})}):this.exposureQueue.length>=this.config.getConfig().maxQueueSize&&this.flushExposureQueue()}setupFallbackTracking(){this.observer={observe:e=>{const t=this.getElementId(e);this.trackedElements.has(t)},unobserve:e=>{const t=this.getElementId(e);this.trackedElements.delete(t)},disconnect:()=>{this.trackedElements.clear(),this.removeScrollListener()}},this.addScrollListener(),setTimeout(()=>{this.checkAllElementsVisibility()},100)}addScrollListener(){if(this.scrollHandler)return;let e=0;const t=this.defaultOptions.scrollThrottle;this.scrollHandler=()=>{const r=Date.now();r-e>=t&&(e=r,this.checkAllElementsVisibility())},window.addEventListener("scroll",this.scrollHandler,{passive:!0}),window.addEventListener("touchmove",this.scrollHandler,{passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0})}removeScrollListener(){this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler),window.removeEventListener("touchmove",this.scrollHandler),window.removeEventListener("resize",this.scrollHandler),this.scrollHandler=null)}checkAllElementsVisibility(){if(!this.useFallback)return;const e=window.innerHeight,t=window.innerWidth;this.trackedElements.forEach((r,n)=>{const i=r.element;if(!i||!document.contains(i))return void this.trackedElements.delete(n);const o=r.config.threshold||this.defaultOptions.threshold,s=this.calculateVisibleRatio(i,0,e,0,t);if(s>=o){const e=Date.now(),t=e-(this.lastReportTime.get(n)||0);t>=this.debounceTime?(this.lastReportTime.set(n,e),this.triggerExposure(i,n,r,s,0),this.config.getConfig().debugSwitch&&console.log(`元素 ${n} 进入可视区域,可见比例: ${(100*s).toFixed(2)}%,立即触发曝光`)):this.config.getConfig().debugSwitch&&console.log(`元素 ${n} 跳过上报(去重),距离上次上报 ${t}ms,需要间隔 ${this.debounceTime}ms`)}})}calculateVisibleRatio(e,t,r,n,i){const o=e.getBoundingClientRect();if(o.bottom<t||o.top>r||o.right<n||o.left>i)return 0;const s=Math.max(o.top,t),a=Math.min(o.bottom,r),c=Math.max(o.left,n),u=Math.min(o.right,i),l=Math.max(0,u-c)*Math.max(0,a-s),h=o.width*o.height;return 0===h?0:l/h}trackProduct(e,t={}){if(!this.isInitialized)return void console.warn("曝光追踪器未初始化");if(!e||"object"!=typeof e||!e.nodeType)return void console.warn("无效的元素,无法追踪");const r=this.getElementId(e),n={...t};this.trackedElements.has(r)&&this.untrackProduct(e),e.setAttribute("data-exposure-tracked","true"),e.setAttribute("data-exposure-config",JSON.stringify(n)),this.trackedElements.set(r,{element:e,config:n}),this.observer&&this.observer.observe(e),this.useFallback&&setTimeout(()=>{this.checkAllElementsVisibility()},0),this.config.getConfig().debugSwitch&&console.log(`开始追踪商品元素: ${r}`,n)}trackProducts(e,t={}){if(!this.isInitialized||!this.observer)return void console.warn("曝光追踪器未初始化");let r=[];if("string"==typeof e)r=Array.from(document.querySelectorAll(e));else{if(!Array.isArray(e))return void console.warn("无效的选择器或元素列表");r=e}r.forEach((e,r)=>{const n=Array.isArray(t)?t[r]||{}:t;this.trackProduct(e,n)}),this.config.getConfig().debugSwitch&&console.log(`批量追踪了 ${r.length} 个商品元素`)}untrackProduct(e){if(!this.observer)return;const t=this.getElementId(e);this.observer.unobserve&&this.observer.unobserve(e),this.trackedElements.delete(t),this.lastReportTime.delete(t),e&&e.removeAttribute&&(e.removeAttribute("data-exposure-tracked"),e.removeAttribute("data-exposure-config")),this.config.getConfig().debugSwitch&&console.log(`取消追踪商品元素: ${t}`)}untrackAll(){this.observer&&(this.useFallback||this.trackedElements.forEach((e,t)=>{e.element&&this.observer.unobserve&&this.observer.unobserve(e.element)}),this.trackedElements.clear(),this.config.getConfig().debugSwitch&&console.log("已取消追踪所有商品元素"))}getElementId(e){if(e.getAttribute("data-exposure-id"))return e.getAttribute("data-exposure-id");if(e._exposureUniqueId)return e._exposureUniqueId;if(e.id)return`id_${e.id}`;if(e.getAttribute("data-product-id"))return`product_${e.getAttribute("data-product-id")}`;const t=Tt();return e._exposureUniqueId=t,t}getElementConfig(e){const t=e.getAttribute("data-exposure-config");if(t)try{return JSON.parse(t)}catch(e){return{}}return{}}extractProductInfo(e,t={}){const r={productId:t.productId||e.getAttribute("data-product-id")||null,productName:t.productName||e.getAttribute("data-product-name")||null,productPrice:t.productPrice||e.getAttribute("data-product-price")||null,productCategory:t.productCategory||e.getAttribute("data-product-category")||null,productImage:t.productImage||e.getAttribute("data-product-image")||null};return Object.keys(r).forEach(e=>{null===r[e]&&delete r[e]}),r}setupPeriodicReport(){const e=this.config.getConfig().reportInterval;e>0&&(this.reportTimer&&clearInterval(this.reportTimer),this.reportTimer=setInterval(()=>{this.flushExposureQueue()},e))}getReportData(e){if(e.length>0){const r=e[0];return r.tags&&(r.tags.exposeContent=(t=e.map(e=>e.viewParam?.productId).filter(Boolean),Array.from(new Set(t)))),delete r.viewParam,r}var t;return null}flushExposureQueue(){if(this.exposureQueue.length>0){const e=[...this.exposureQueue];this.exposureQueue=[],Promise.resolve().then(()=>{this.reporter.report("exposure",this.getReportData(e)).catch(e=>{console.error("批量曝光上报失败:",e),this.config.getConfig().debugSwitch&&console.error("批量曝光上报失败详情:",e)})})}}reportExposure(e={}){let t={};this.eventTracker&&"function"==typeof this.eventTracker.getPreviousPageInfo&&(t=this.eventTracker.getPreviousPageInfo());const r={uuid:Tt(),timestamp:Date.now(),pageKey:Et(kt(window.location.href),this.config.getConfig().uiVersion),pageUri:kt(window.location.href),eventType:"EXPOSE",actionKey:"",refer:kt(t?.previousPage?.url),duration:t?.previousPageStayTime,viewParam:{...e},tags:{...config}};Promise.resolve().then(()=>{this.reporter.report("exposure",this.getReportData(r)).catch(e=>{console.error("手动曝光上报失败:",e),this.config.getConfig().debugSwitch&&console.error("手动曝光上报失败详情:",e)})})}getTrackedElements(){return Array.from(this.trackedElements.keys())}getExposureQueue(){return[...this.exposureQueue]}destroy(){this.flushExposureQueue(),this.reportTimer&&(clearInterval(this.reportTimer),this.reportTimer=null),this.untrackAll(),this.observer&&(this.observer.disconnect&&this.observer.disconnect(),this.observer=null),this.removeScrollListener(),this.trackedElements.clear(),this.exposureQueue=[],this.lastReportTime.clear(),this.useFallback=!1,this.isInitialized=!1,this.config.getConfig().debugSwitch&&console.log("曝光追踪器已销毁")}}class xt{constructor(e){this.config=e,this.integratedSDKs={},this.isInitialized=!1}init(){if(this.isInitialized)return;const e=this.config.getThirdPartyConfig();e.baidu&&e.baidu.enabled&&this.initBaiduAnalytics(e.baidu),e.umeng&&e.umeng.enabled&&this.initUmengAnalytics(e.umeng),e.sensors&&e.sensors.enabled&&this.initSensorsAnalytics(e.sensors),e.tencent&&e.tencent.enabled&&this.initTencentAnalytics(e.tencent),e.google&&e.google.enabled&&this.initGoogleAnalytics(e.google),e.custom&&e.custom.enabled&&this.initCustomAnalytics(e.custom),this.isInitialized=!0}initBaiduAnalytics(e){try{window._hmt?(this.integratedSDKs.baidu={name:"baidu",instance:window._hmt,config:e},e.siteId&&window._hmt.push(["_setAccount",e.siteId]),!1!==e.autoPageview&&window._hmt.push(["_trackPageview"]),console.log("百度统计集成成功")):console.warn("百度统计未加载,请检查脚本是否正确引入")}catch(e){console.error("百度统计集成失败:",e)}}initUmengAnalytics(e){try{window._um?(this.integratedSDKs.umeng={name:"umeng",instance:window._um,config:e},e.siteId&&window._um.push(["setAccount",e.siteId]),!1!==e.autoPageview&&window._um.push(["trackPageview"]),console.log("友盟统计集成成功")):console.warn("友盟统计未加载,请检查脚本是否正确引入")}catch(e){console.error("友盟统计集成失败:",e)}}initSensorsAnalytics(e){try{window.sensors?(this.integratedSDKs.sensors={name:"sensors",instance:window.sensors,config:e},e.serverUrl&&window.sensors.setServerUrl(e.serverUrl),e.siteId&&window.sensors.setSiteId(e.siteId),!1!==e.autoPageview&&window.sensors.trackPageview(),console.log("神策数据集成成功")):console.warn("神策数据未加载,请检查脚本是否正确引入")}catch(e){console.error("神策数据集成失败:",e)}}initTencentAnalytics(e){try{window.MTA?(this.integratedSDKs.tencent={name:"tencent",instance:window.MTA,config:e},e.appId&&window.MTA.setAppId(e.appId),!1!==e.autoPageview&&window.MTA.trackPageview(),console.log("腾讯云分析集成成功")):console.warn("腾讯云分析未加载,请检查脚本是否正确引入")}catch(e){console.error("腾讯云分析集成失败:",e)}}initGoogleAnalytics(e){try{window.gtag?(this.integratedSDKs.google={name:"google",instance:window.gtag,config:e},e.measurementId&&window.gtag("config",e.measurementId,{page_title:document.title,page_location:window.location.href}),console.log("Google Analytics集成成功")):console.warn("Google Analytics未加载,请检查脚本是否正确引入")}catch(e){console.error("Google Analytics集成失败:",e)}}initCustomAnalytics(e){try{if("function"==typeof e.init){const t=e.init(e);this.integratedSDKs.custom={name:"custom",instance:t,config:e},console.log("自定义第三方集成成功")}else console.warn("自定义第三方配置缺少init函数")}catch(e){console.error("自定义第三方集成失败:",e)}}reportEvent(e,t={}){Object.values(this.integratedSDKs).forEach(r=>{try{this.reportToSDK(r,e,t)}catch(e){console.error(`上报事件到${r.name}失败:`,e)}})}reportPageView(e={}){Object.values(this.integratedSDKs).forEach(t=>{try{this.reportPageViewToSDK(t,e)}catch(e){console.error(`上报页面浏览到${t.name}失败:`,e)}})}reportUser(e={}){Object.values(this.integratedSDKs).forEach(t=>{try{this.reportUserToSDK(t,e)}catch(e){console.error(`上报用户信息到${t.name}失败:`,e)}})}reportPerformance(e={}){Object.values(this.integratedSDKs).forEach(t=>{try{this.reportPerformanceToSDK(t,e)}catch(e){console.error(`上报性能指标到${t.name}失败:`,e)}})}reportToSDK(e,t,r){switch(e.name){case"baidu":e.instance&&e.instance.push&&e.instance.push(["_trackEvent",t,JSON.stringify(r)]);break;case"umeng":e.instance&&e.instance.push&&e.instance.push(["track",t,r]);break;case"sensors":e.instance&&e.instance.track&&e.instance.track(t,r);break;case"tencent":e.instance&&e.instance.Event&&e.instance.Event.stat&&e.instance.Event.stat(t,r);break;case"google":e.instance&&"function"==typeof e.instance&&e.instance("event",t,r);break;case"custom":e.instance&&"function"==typeof e.instance.track&&e.instance.track(t,r);break;default:console.warn(`未知的SDK类型: ${e.name}`)}}reportPageViewToSDK(e,t){switch(e.name){case"baidu":e.instance&&e.instance.push&&e.instance.push(["_trackPageview",t.url||window.location.href]);break;case"umeng":e.instance&&e.instance.push&&e.instance.push(["trackPageview",t.url||window.location.href]);break;case"sensors":e.instance&&e.instance.trackPageview&&e.instance.trackPageview(t);break;case"tencent":e.instance&&e.instance.trackPageview&&e.instance.trackPageview(t.url||window.location.href);break;case"google":e.instance&&"function"==typeof e.instance&&e.instance("config",e.config.measurementId,{page_title:t.title||document.title,page_location:t.url||window.location.href});break;case"custom":e.instance&&"function"==typeof e.instance.trackPageview&&e.instance.trackPageview(t);break;default:console.warn(`未知的SDK类型: ${e.name}`)}}reportUserToSDK(e,t){switch(e.name){case"baidu":e.instance&&e.instance.push&&(e.instance.push(["_setUserTag","userId",t.userId]),e.instance.push(["_setUserTag","userType",t.userType]));break;case"umeng":e.instance&&e.instance.push&&(e.instance.push(["setUserTag","userId",t.userId]),e.instance.push(["setUserTag","userType",t.userType]));break;case"sensors":e.instance&&e.instance.setProfile&&e.instance.setProfile(t);break;case"tencent":e.instance&&e.instance.setUserInfo&&e.instance.setUserInfo(t);break;case"google":e.instance&&"function"==typeof e.instance&&e.instance("set","user_id",t.userId);break;case"custom":e.instance&&"function"==typeof e.instance.setUser&&e.instance.setUser(t);break;default:console.warn(`未知的SDK类型: ${e.name}`)}}reportPerformanceToSDK(e,t){switch(e.name){case"baidu":e.instance&&e.instance.push&&e.instance.push(["_trackEvent","performance",JSON.stringify(t)]);break;case"umeng":e.instance&&e.instance.push&&e.instance.push(["track","performance",t]);break;case"sensors":e.instance&&e.instance.track&&e.instance.track("performance",t);break;case"tencent":e.instance&&e.instance.Event&&e.instance.Event.stat&&e.instance.Event.stat("performance",t);break;case"google":e.instance&&"function"==typeof e.instance&&e.instance("event","performance",t);break;case"custom":e.instance&&"function"==typeof e.instance.trackPerformance&&e.instance.trackPerformance(t);break;default:console.warn(`未知的SDK类型: ${e.name}`)}}isSDKIntegrated(e){return!!this.integratedSDKs[e]}getIntegratedSDKs(){return Object.keys(this.integratedSDKs)}getSDKInstance(e){return this.integratedSDKs[e]?.instance||null}destroy(){Object.values(this.integratedSDKs).forEach(e=>{try{e.instance&&"function"==typeof e.instance.destroy&&e.instance.destroy()}catch(t){console.error(`销毁${e.name}失败:`,t)}}),this.integratedSDKs={},this.isInitialized=!1}}class Nt{constructor(e={}){this.config={appId:e.appId||"",appVersion:e.appVersion||"1.0.0",environment:e.environment||"production",debugSwitch:!0===e.debugSwitch,customerId:e.customerId||"",userId:e.userId||"",deviceNo:e.deviceNo||"",deviceId:e.userId||"",uiVersion:e.uiVersion||"",sessionId:bt(),reportUrl:e.reportUrl||"",reportInterval:e.reportInterval||5e3,maxQueueSize:e.maxQueueSize||100,enableErrorTracking:!1!==e.enableErrorTracking,enableUnhandledRejection:!1!==e.enableUnhandledRejection,enableResourceError:!1!==e.enableResourceError,enableEventTracking:!1!==e.enableEventTracking,enableClickTracking:!1!==e.enableClickTracking,enablePageViewTracking:!1!==e.enablePageViewTracking,enablePerformanceTracking:!1!==e.enablePerformanceTracking,enableResourceTracking:!1!==e.enableResourceTracking,enableApiTracking:!1!==e.enableApiTracking,enableInteractionTracking:!1!==e.enableInteractionTracking,enableUserInteractionTracking:!1!==e.enableUserInteractionTracking,enableFormTracking:!1!==e.enableFormTracking,enableScrollTracking:!1!==e.enableScrollTracking,enableMouseTracking:!1!==e.enableMouseTracking,enableKeyboardTracking:!1!==e.enableKeyboardTracking,thirdPartyConfig:e.thirdPartyConfig||{},user:e.user||null,customReport:e.customReport||null},this.user=null}updateConfig(e){this.config={...this.config,...e}}setUser(e){this.user=e}getConfig(){return this.config}getUser(){return this.user}getReportUrl(){return this.config.reportUrl}getThirdPartyConfig(){return this.config.thirdPartyConfig}isErrorTrackingEnabled(){return this.config.enableErrorTracking}isEventTrackingEnabled(){return this.config.enableEventTracking}}"undefined"==typeof window||window?.axios||(window.axios=ft);class Lt{constructor(e={}){this.config=new Nt(e),this.errorTracker=new It(this.config),this.eventTracker=new Ct(this.config),this.performanceTracker=new Ot(this.config),this.userBehaviorTracker=new At(this.config),this.exposureTracker=new Dt(this.config,this.eventTracker),this.thirdPartyIntegrator=new xt(this.config),this.init()}init(){this.eventTracker.init(),this.exposureTracker.init(),this.thirdPartyIntegrator.init(),console.log("Frontend SDK 初始化完成")}reportError(e,t={}){this.errorTracker.reportError(e,t)}reportEvent(e,t={}){this.eventTracker.reportEvent(e,t)}getPreviousPageInfo(){return this.eventTracker.getPreviousPageInfo()}getCurrentPageStayTime(){return this.eventTracker.getCurrentPageStayTime()}getPageHistory(){return this.eventTracker.pageHistory||[]}reportPerformance(e={}){this.performanceTracker.reportPerformance(e)}reportBehavior(e,t={}){this.userBehaviorTracker.reportCustomBehavior(e,t)}setUser(e){this.config.setUser(e),this.thirdPartyIntegrator.reportUser(e)}setConfig(e){this.config.updateConfig(e)}getPerformanceMetrics(){return this.performanceTracker.getCurrentMetrics()}getBehaviorData(){return this.userBehaviorTracker.getCurrentBehaviors()}getSessionId(){return this.userBehaviorTracker.getSessionId()}isThirdPartySDKIntegrated(e){return this.thirdPartyIntegrator.isSDKIntegrated(e)}getIntegratedThirdPartySDKs(){return this.thirdPartyIntegrator.getIntegratedSDKs()}setupVueRouterMonitoring(e){e?(this.performanceTracker.setupVueRouterMonitoring(e),console.log("Vue Router 监控已设置")):console.warn("Vue Router 实例未提供")}getCurrentRoute(){return this.performanceTracker.getCurrentRoute()}getRouteHistory(){return this.performanceTracker.getRouteHistory()}getCurrentRouteStayTime(){return this.performanceTracker.getCurrentPageStayTime()}getRoutePerformanceStats(){return this.performanceTracker.getRoutePerformanceStats()}trackProduct(e,t={}){return this.exposureTracker.trackProduct(e,t)}trackProducts(e,t={}){return this.exposureTracker.trackProducts(e,t)}untrackProduct(e){return this.exposureTracker.untrackProduct(e)}untrackAllProducts(){return this.exposureTracker.untrackAll()}reportExposure(e={}){return this.exposureTracker.reportExposure(e)}getTrackedProducts(){return this.exposureTracker.getTrackedElements()}getExposureQueue(){return this.exposureTracker.getExposureQueue()}flushExposureQueue(){return this.exposureTracker.flushExposureQueue()}destroy(){this.errorTracker.destroy(),this.eventTracker.destroy(),this.performanceTracker.destroy(),this.userBehaviorTracker.destroy(),this.exposureTracker.destroy(),this.thirdPartyIntegrator.destroy(),console.log("Frontend SDK 已销毁")}}export{Lt as default,wt as performanceNow};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|