"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[589],{23589:function(t,e,n){let r;n.r(e),n.d(e,{EID:function(){return u},EVENT_TYPE:function(){return c},Logger:function(){return I},logger:function(){return D}});let i="__wehshop__client__did",o={MINUTE:6e4,HOUR:36e5},s=["div","a","img","p"];function a(t,e){try{window.localStorage.setItem(t,JSON.stringify(e))}catch(t){}}function l(t){let e=window.localStorage.getItem(t);try{if(e)return JSON.parse(e)}catch(t){return e}}let c={CLICK:2,CLICK_BLANK:1},u={COMMON:"0x00000000",COMMON_CLICK:"10000001",BLANK:"0"},d="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var h={randomUUID:d};let f=new Uint8Array(16);function g(){if(!r&&!(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(f)}let p=[];for(let t=0;t<256;++t)p.push((t+256).toString(16).slice(1));var w=function(t,e,n){if(h.randomUUID&&!e&&!t)return h.randomUUID();t=t||{};let r=t.random||(t.rng||g)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(let t=0;t<16;++t)e[n+t]=r[t];return e}return function(t,e=0){return(p[t[e+0]]+p[t[e+1]]+p[t[e+2]]+p[t[e+3]]+"-"+p[t[e+4]]+p[t[e+5]]+"-"+p[t[e+6]]+p[t[e+7]]+"-"+p[t[e+8]]+p[t[e+9]]+"-"+p[t[e+10]]+p[t[e+11]]+p[t[e+12]]+p[t[e+13]]+p[t[e+14]]+p[t[e+15]]).toLowerCase()}(r)},m=n(6258),y=n(6154),_=n(63413);y.Z.defaults.withCredentials=!0,y.Z.defaults.timeout=6e4;class I{setGlobalConfig(t){this.config={...this.config,...t}}async getDId(){if(_.Kc){let t=await (0,m.V6)();return t.did?(this.version=t.version,this.dontReport=!t.logAgreed,t.did):""}{let t=l(i);if(null==t?void 0:t.did)return null==t?void 0:t.did;let e=w();return e?(a(i,{did:e}),e):""}}async init(){if(!this.DID)try{this.DID=await this.getDId()}catch(t){console.warn("did error",t)}if(!this.uid)try{this.uid=await this.getUid()}catch(t){console.warn("uid error",t)}await this.regOnLoad()}async getUid(){if(_.Kc)return"";try{let t=await (0,m.PR)({noLogin:!0});if(t)return null==t?void 0:t.uid}catch(t){return""}}getParams(t,e,n){return{eid:t,event_type:e,ext:this.version?{...n,version:this.version}:n,time:Date.now(),refer_url:document.referrer,url:location.href,platform:this.config.platform,did:this.DID,launch_time:function(t){try{let e=localStorage.getItem(t);if(e){let n={expires:Date.now(),...JSON.parse(e)};if(Date.now()-n.expires>=1*o.MINUTE){let e=Date.now();return n.expires=e,a(t,n),e}return n.expires}a(t,{expires:Date.now()})}catch(t){return null}}("__wehshop__launch_time_key")||Date.now(),uid:this.uid,localVersion:_.Kc||!1}}log(t){var e,n,r;return this.dontReport?Promise.resolve(null):(e=this.config.logUrl,n={method:"POST"},r={},new Promise((i,o)=>{fetch(e,{...n,headers:{"content-type":"application/json",...r},credentials:"include",body:t&&JSON.stringify(t)}).then(t=>t.json()).then(t=>i(t)).catch(t=>o(t))}))}async regOnLoad(){return new Promise(t=>{setTimeout(async()=>{let e="打开页面上报";console.time(e),console.log("打开页面上报..."),await this.log({eid:this.EID.BLANK,event_type:this.EVENT_TYPE.CLICK_BLANK}),console.timeEnd(e),t()},500)})}static getInstance(){if((null==window?void 0:window.logger)instanceof I)return window.logger;let t=new I;return window.logger=t,t}constructor(){this.EVENT_TYPE=c,this.EID=u,this.config={platform:"native",logUrl:"",clickEles:s},this.DID=_.Kc?"":l("did")||"",this.dontReport=!!_.Kc,this.init()}}let D=I.getInstance()}}]);