gio-miniprogram-sdk 4.3.0 → 4.3.1

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/quickapp.js CHANGED
@@ -1 +1 @@
1
- import t from"@system.app";import e from"@system.device";import i from"@system.fetch";import s from"@system.image";import n from"@system.network";import r from"@system.router";import o from"@system.share";import a from"@system.storage";const l=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,g=t=>["undefined","null"].includes(U(t)),u=t=>"string"===U(t),c=t=>"number"===U(t),d=t=>"boolean"===U(t),h=t=>"[object Object]"==={}.toString.call(t)&&!g(t),p=t=>["function","asyncfunction"].includes(U(t)),v=t=>Array.isArray(t)&&"array"===U(t),m=t=>"date"===U(t),f=t=>{try{return Array.from(t)[0]}catch(t){return}},I=t=>{try{const e=Array.from(t);return e[e.length-1]}catch(t){return}},y=(t,e=1)=>v(t)&&c(e)?t.slice(e>0?e:1,t.length):t,S=(t,e=!1)=>{if(v(t)){let i=0;const s=[];for(const n of t)n&&!N(n)&&(s[i++]=n),e&&0===n&&(s[i++]=n);return s}return t},O=(t,e)=>{if(v(t)){const i=t.findIndex(e);return 0>i?void 0:t[i]}},b=t=>g(t)?"":""+t,w=(t,e)=>"string"===U(t)?t.split(e):t,P=t=>{if(u(t)){const e=w(t,"");return`${f(e).toLowerCase()}${y(e).join("")}`}return t},k=(t,e)=>(u(t)||(t=b(t)),t.slice(0,e.length)===e),_={}.hasOwnProperty,T=(t,e)=>!g(t)&&_.call(t,e),E=t=>h(t)?Object.keys(t):[],C=(t,e)=>{E(t).forEach((i=>e(t[i],i)))},A=(t,e)=>{const i=E(t);return!(!h(t)||!h(e)||i.length!==E(e).length||i.map(((i,s)=>h(t[i])?A(t[i],e[i]):t[i]===e[i])).includes(!1))},q=(t,e,i)=>{let s=t;return h(t)?(e.split(".").forEach((t=>{s=s?s[t]:i})),s):i},j=(t,e)=>{if(!h(t))return!1;try{if("string"===U(e))return delete t[e];if("array"===U(e))return e.map((e=>delete t[e]));"object"===U(e)&&e.constructor===RegExp&&E(t).forEach((i=>{e.test(i)&&j(t,i)}))}catch(t){return!1}},x=(t,e=250,i,s)=>{let n,r=0;return"boolean"!==U(i)&&(s=t,t=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function g(){r=Date.now(),t.apply(a,o)}s&&!n&&g(),n&&clearTimeout(n),void 0===s&&l>e?g():!0!==i&&(n=setTimeout(s?function(){n=void 0}:g,void 0===s?e-l:e))}},N=t=>v(t)?0===t.length:h(t)?0===E(t).length:!t,U=t=>({}.toString.call(t).slice(8,-1).toLowerCase()),D=t=>{function e(t){return 10>t?"0"+t:t}return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+" "+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+"."+e(t.getMilliseconds())};var K=Object.freeze({__proto__:null,isNil:g,isString:u,isNaN:t=>"NaN"===b(Number(t)),isNumber:c,isBoolean:d,isObject:h,isRegExp:t=>"[object RegExp]"==={}.toString.call(t),isFunction:p,isArray:v,isDate:m,fixed:(t,e)=>c(t)?Number(t.toFixed(c(e)?e:2)):u(t)&&"NaN"!==b(Number(t))?Number(Number(t).toFixed(c(e)?e:2)):t,head:f,last:I,drop:y,dropWhile:(t,e)=>v(t)?t.filter((t=>!e(t))):t,compact:S,find:O,isEqualArray:(t,e)=>!(!v(t)||!v(e)||t.length!==e.length)&&t.every(((t,i)=>t===e[i])),toString:b,split:w,lowerFirst:P,upperFirst:t=>{if(u(t)){const e=w(t,"");return`${f(e).toUpperCase()}${y(e).join("")}`}return t},startsWith:k,endsWith:(t,e)=>{const{length:i}=t;let s=i;s>i&&(s=i);const n=s;return s-=e.length,s>=0&&t.slice(s,n)===e},hasOwnProperty:_,has:T,keys:E,forEach:C,isEqual:A,get:q,unset:j,throttle:x,isEmpty:N,typeOf:U,formatDate:D});const $=(t,e)=>{console.log("%c[GrowingIO]:"+t,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[e]||"")},H=(t,e=!0,i="参数不合法")=>$(`${e?"调用":"设置"} ${t} 失败,${i}!`,"warn"),L=t=>{try{return t()}catch(t){return}},R=(t,e)=>{if(p(t))try{t(e)}catch(t){$("回调执行失败!"+t,"error")}},V=t=>u(t)?t.trim().substring(0,100):t,F=(t,e)=>u(t)&&!N(t)&&t.match(l)?e():($("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),M=t=>(g(t)||E(t).forEach((e=>{p(t[e])?t[e]=L((()=>t[e]())):h(t[e])?j(t,e):v(t[e])||(t[e]=b(t[e]))})),t),B=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})),G=t=>t.pixelRatio?Math.round(t.screenHeight*t.pixelRatio):t.screenHeight,Q=t=>t.pixelRatio?Math.round(t.screenWidth*t.pixelRatio):t.screenWidth,z=(t,e)=>{if(t){const i=t.toLowerCase();return-1!==i.indexOf("android")?e+"-Android":-1!==i.indexOf("ios")?e+"-iOS":t}},W=t=>{if(u(t)){const e=t.indexOf("?");return-1!==e?[t.substring(0,e),t.substring(e+1)]:[t,""]}return["",""]},J=t=>u(t)?t.startsWith("/")?t:"/"+t:"",Y=t=>L((()=>{switch(t){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let t;return t||(t=L((()=>swan))),t||(t=L((()=>my))),t||(t=L((()=>tt))),t||(t=L((()=>qq))),t||(t=L((()=>ks))),t||(t=L((()=>jd))),t||(t=L((()=>wx))),t}}})),Z=t=>L((()=>{switch(t){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return L((()=>__ttConfig))||(null===global||void 0===global?void 0:global.TMAConfig)||(null===globalThis||void 0===globalThis?void 0:globalThis.TMAConfig);case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),X=()=>{let t;return!t&&L((()=>swan))&&(t="swan"),!t&&L((()=>tt))&&(t="tt"),!t&&L((()=>qq))&&(t="qq"),!t&&L((()=>my.tb))&&(t="tb"),!t&&L((()=>my))&&(t="my"),!t&&L((()=>ks))&&(t="ks"),!t&&L((()=>jd))&&(t="jd"),!t&&L((()=>wx))&&(t="wx"),t||O(E(global),(t=>b(t).toLowerCase().includes("quickapp")))&&(t="quickapp"),t},et=()=>{var t;return null!==(t=L((()=>{var t;return null!==(t=L((()=>{var t;return null!==(t=L((()=>$global)))&&void 0!==t?t:global})))&&void 0!==t?t:window})))&&void 0!==t?t:globalThis},it=t=>{const e={};return h(t)&&(j(t,"&&sendTo"),C(t,((t,i)=>{const s=b(i).slice(0,100);h(t)?e[s]=it(t):v(t)?(e[s]=S(t.slice(0,100),!0),e[s]=e[s].join("||").slice(0,1e3)):m(t)?e[s]=D(t):e[s]=g(t)?"":b(t).slice(0,1e3)}))),e},st=(t,e)=>{const i=()=>e.map((e=>t.getStorageSync(e)));try{return t.minip.canIUse("batchGetStorageSync")?t.minip.batchGetStorageSync(e):i()}catch(t){return i()}},nt=(t,e)=>{const i=()=>e.map((({key:e,value:i})=>t.setStorageSync(e,i)));try{return t.minip.canIUse("batchSetStorageSync")?t.minip.batchSetStorageSync(e):i()}catch(t){return i()}},rt=t=>E(t||{}).map((e=>e?`${e}=${g(t[e])?"":t[e]}`:"")).join("&"),ot=t=>{(k(t,"?")||k(t,"&"))&&(t=t.slice(1,t.length));const e={};return t.split("&").forEach((t=>{const i=t.split("=");i[0]&&(e[i[0]]=i[1])})),e},at=(t={},e={})=>{const i={};return E(e).forEach((t=>{["string","number","boolean"].includes(U(e[t]))&&(i[t]=e[t])})),Object.assign({},i,t)};var lt=Object.freeze({__proto__:null,consoleText:$,callError:H,niceTry:L,niceCallback:R,limitString:V,eventNameValidate:F,getDynamicAttributes:M,guid:B,getScreenHeight:G,getScreenWidth:Q,getOS:z,compareVersion:(t="",e="")=>{const i=t=>t.replace(/\s+/g,""),s=t=>t.replace(/[vV]/g,""),n=i(s(t)),r=i(s(e)),o=n.split("."),a=r.split(".");for(let t=0;3>t;t++){let e=Number(o[t]),i=Number(a[t]);if(e>i)return 1;if(i>e)return-1;if(!isNaN(e)&&isNaN(i))return 1;if(isNaN(e)&&!isNaN(i))return-1}return 0},getVueVersion:t=>{if(t){const e=Number(f(w(t.version,".")));return Number.isNaN(e)?0:e}return 0},splitPath:W,normalPath:J,isTaro3:t=>{const{Current:e,createComponent:i}=t;return!(!t||!e||i)},getPlainMinip:Y,getPlainConfig:Z,getPlainPlatform:X,getSubKeys:t=>E(t).filter((t=>t.indexOf("__sub")>-1&&t.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let t=L((()=>getApp({allowDefault:!0})));return t||(t=et()),t},getGlobal:et,limitObject:it,batchGetStorageSync:st,batchSetStorageSync:nt,qsStringify:rt,qsParse:ot,hashCode:(t,e=!1)=>{let i=0;if(N(t)||"boolean"==typeof t)return i;let s=0;for(;s<t.length;)i=(i<<5)-i+t.charCodeAt(s),i|=0,s++;return e?Math.abs(i):i},getLaunchQuery:at});const gt=t=>u(t)&&t.length>0||c(t)&&t>0,ut={autotrack:{type:"boolean",default:!0},compress:{type:"boolean",default:!0},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},extraParams:{type:"array",default:[]},followShare:{type:"boolean",default:!0},forceLogin:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:3e5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},requestTimeout:{type:"number",default:5e3},taro:{type:["object","module"],default:!1},taroVue:{type:["object","function"],default:!1},tbConfig:{type:"object",default:{cloud:void 0,cloudFuncSend:!1,cloudFuncName:"httpTunnel",cloudFuncHandler:"main",cloudAppId:void 0,path:void 0}},trackPage:{type:"boolean",default:!0},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},ct=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],dt=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...ct],ht={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},pt=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],vt=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],mt=[...vt,"appChannel","language","platformVersion"],ft={gsid:"_growing_gsid_",originalSource:"_gdp_original_source_",userId:"_growing_userId_",userKey:"_growing_userKey_",gioId:"_growing_gioId_",plugin_gsid:"_growing_plugin_gsid_",plugin_originalSource:"_gdp_plugin_original_source_",plugin_userId:"_growing_plugin_userId_",plugin_userKey:"_growing_plugin_userKey_",plugin_gioId:"_growing_plugin_gioId_"};var It="MINIP_LIFECYCLE",yt="ON_COMMIT_REQUEST",St="ON_COMPOSE_AFTER",Ot="ON_COMPOSE_BEFORE",bt="ON_ERROR",wt="ON_INSTALL",Pt="ON_SEND_AFTER",kt="ON_SEND_BEFORE",_t="OPTION_CHANGE",Tt="OPTION_INITIALIZED",Et="SDK_INITIALIZED";class Ct{constructor(t){this.growingIO=t,this.main=(t,e,i=!0)=>{t||(t=this.growingIO.trackingId);const{sdkVersion:s,platformConfig:n,minipInstance:r,userStore:o,dataStore:a,dataStore:{scene:l,eventHooks:{currentPage:g},generalProps:u}}=this.growingIO,{version:c,dataSourceId:d,appId:h,idMapping:p,ignoreFields:v}=a.getTrackerVds(t),m=a.locationData[t],{systemInfo:f={},network:I={}}=r,{brand:y,model:S,platform:O,language:b}=f,w=g.getPagePath(),P={appChannel:"scn:"+(l||"NA"),appVersion:c,dataSourceId:d,deviceBrand:y,deviceId:o.getUid(),deviceModel:S,deviceType:z(O,n.name),domain:h,language:b,latitude:null==m?void 0:m.latitude,longitude:null==m?void 0:m.longitude,networkState:(null==I?void 0:I.networkType)||(null==I?void 0:I.type)||(null==I?void 0:I.subtype),operatingSystem:z(O,n.name),path:w,platform:n.platform,platformVersion:n.name+(f.version?" "+f.version:""),query:w?g.getPageQeury():"",screenHeight:G(f),screenWidth:Q(f),sdkVersion:s,sessionId:o.getSessionId(t),title:g.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:o.getUserId(t)};return p&&(P.userKey=o.getUserKey(t)),i&&!N(u[t])&&(P.attributes=Object.assign({},u[t])),N(P.attributes)||(P.attributes=it(M(Object.assign({},P.attributes)))),N(v)||v.forEach((t=>{j(P,t)})),N(e)?Object.assign(Object.assign({},P),{trackingId:t}):Object.assign(Object.assign(Object.assign({},P),e),{trackingId:t})}}}function At(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{l(s.next(t))}catch(t){r(t)}}function a(t){try{l(s.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class qt{constructor(t){this.growingIO=t,this.enterParams={},this.main=(t,e)=>{var i,s;const n=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:g,dataStore:u,dataStore:{trackersExecute:c,shareOut:d,lastCloseTime:h,saveStorageInfo:p,setOriginalSource:v}}=this.growingIO;r.emit(It,{event:"App "+t,timestamp:n,params:null!==(i=e[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",t,n);const m=l.listeners.app;switch(r.emit(Ot,{event:"App "+t,params:null!==(s=e[0])&&void 0!==s?s:{}}),t){case m.appLaunch:this.enterParams=Object.assign({},e[0]);break;case m.appCreate:case m.appShow:{const{path:t,query:i,referralPage:s}=this.enterParamsParse(e[0]);!d&&a.originalSource&&t&&c((e=>{v(e,{path:t,query:i,referralPage:s})})),h?(Date.now()-h>a.keepAlive||u.lastScene&&u.scene!==u.lastScene)&&(c((t=>{o.setSessionId(t)})),c((e=>{if(t)this.buildVisitEvent(e,{path:t,query:i});else{const t=u.lastPageEvent[e];this.buildVisitEvent(e,{path:t.path,query:t.query})}}))):c((e=>{u.lastVisitEvent[e]={path:t,query:i,referralPage:s},this.buildVisitEvent(e,{path:t,query:i,referralPage:s})}));break}case m.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),p(),o.saveUserInfo(),c((t=>{this.buildCloseEvent(t),a.forceLogin||g.initiateRequest(t,!0)}))}},this.enterParamsParse=(t={})=>{var e;const{gioPlatform:i,minipInstance:s,dataStore:n}=this.growingIO;let r="",o="",a="";if("quickapp"!==i&&s.minip.canIUse("getEnterOptionsSync")){const{path:i,query:l,scene:g,referrerInfo:u}=s.minip.getEnterOptionsSync()||{};r=i||t.path,o=l||t.query,a=(null==u?void 0:u.appId)||(null===(e=null==t?void 0:t.referrerInfo)||void 0===e?void 0:e.appId)||"",n.scene=g||t.scene,o=N(null==u?void 0:u.extraData)?rt(o):rt(at(o,u.extraData))}else{const{path:e,query:i,referrerInfo:s}=t;r=e,o=rt(i),a=(null==s?void 0:s.appId)||"",this.parseScene(t)}return{path:r,query:o,referralPage:a}},this.parseScene=t=>{var e;const{minipInstance:i,gioPlatform:s,dataStore:n}=this.growingIO;let r;if("quickapp"===s){const{extra:t,type:e}=i.getAppSource();r=(null==t?void 0:t.scene)||e}else N(t)||((null===(e=null==t?void 0:t.query)||void 0===e?void 0:e.wxShoppingListScene)?r=t.query.wxShoppingListScene:(null==t?void 0:t.scene)?r=t.scene:n.scene="NA");n.scene=r},this.buildVisitEvent=(t,e)=>{const{dataStore:{getOriginalSource:i,eventContextBuilder:s,eventInterceptor:n},vdsConfig:r}=this.growingIO,o=i(t),a=(null==e?void 0:e.query)||"";let l=Object.assign({eventType:"VISIT"},s(t,{}));!N(e)&&e.path&&(l.path=e.path||"",l.query="string"===U(a)?a:rt(a),e.referralPage&&(l.referralPage=e.referralPage)),r.originalSource&&!N(o)&&(l=Object.assign(Object.assign({},l),o)),n(l)},this.buildCloseEvent=t=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},e(t)))}}}class jt{constructor(t){this.growingIO=t,this.getPagePath=()=>{var t,e,i;const{minipInstance:s,inPlugin:n,dataStore:r,trackingId:o}=this.growingIO,a=s.getCurrentPath();if(n){const t=r.getTrackerVds(o);return a||"/插件"+t.appId}return a||(null===(t=r.eventHooks.appEffects.enterParams)||void 0===t?void 0:t.path)||(null===(e=r.lastPageEvent[o])||void 0===e?void 0:e.path)||(null===(i=r.lastVisitEvent[o])||void 0===i?void 0:i.path)},this.getPageQeury=()=>{var t,e,i,s,n,r;const{minipInstance:o,dataStore:a,trackingId:l}=this.growingIO,g=o.getCurrentPage(),u=o.getCurrentPath(),{enterParams:c={}}=a.eventHooks.appEffects;if(!u)return c.path?this.qsQuery(at(null==c?void 0:c.query,null===(i=null==c?void 0:c.referrerInfo)||void 0===i?void 0:i.extraData)):(null===(s=a.lastPageEvent[l])||void 0===s?void 0:s.path)?null===(n=a.lastPageEvent[l])||void 0===n?void 0:n.query:null===(r=a.lastVisitEvent[l])||void 0===r?void 0:r.query;{const i=null!==(t=g.options)&&void 0!==t?t:g.$taroParams;if(!N(i))return j(i,"$taroTimestamp"),this.qsQuery(i);if(!N(this.queryOption[u]))return this.qsQuery(this.queryOption[u]);if(u===c.path)return this.qsQuery(at(null==c?void 0:c.query,null===(e=null==c?void 0:c.referrerInfo)||void 0===e?void 0:e.extraData))}},this.getPageTitle=t=>{const{minipInstance:e,inPlugin:i,dataStore:s}=this.growingIO,n=e.getCurrentPath(),r=this.settedTitle[n]||e.getPageTitle(e.getCurrentPage());if(i){const e=s.getTrackerVds(t||this.growingIO.trackingId);return r||`/插件${e.appId}${n?"_"+I(n.split("/")):""}`}return r},this.qsQuery=(t={})=>{const e=Object.assign({},t);return j(e,"wxShoppingListScene"),rt(e)},this.getReferralPage=t=>{var e,i,s;const{minipInstance:n,dataStore:{lastPageEvent:r,scene:o,eventHooks:a}}=this.growingIO;return(null===(e=r[t])||void 0===e?void 0:e.path)||(null===(s=null===(i=a.appEffects.enterParams)||void 0===i?void 0:i.referrerInfo)||void 0===s?void 0:s.appId)||(o?`scn:${n.scnPrefix}${o}`:null)},this.updateShareResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=J(e+(i?"?"+i:"")),t.query=i,t},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=J(e+(i?"?"+i:"")),t.query=i,t},this.eventSetPageProps=(t,e)=>{const i=L((()=>this.pageProps[t][this.getPagePath()]));return N(i)?e.attributes:it(M(Object.assign(Object.assign({},e.attributes),i)))},this.queryOption={},this.settedTitle={},this.pageProps={}}buildShareQuery(t){var e,i;const s=W(null!==(e=t.path)&&void 0!==e?e:"");let n=this.getPagePath(),r={},o=T(t,"path");if(o&&(n=f(s),r=ot(I(s))||{}),N(r)&&(r=ot(null!==(i=t.query)&&void 0!==i?i:"")||{},S(E(r)).forEach((t=>{t.toLowerCase().startsWith("utm_")&&j(r,t)}))),!o&&N(r)){const t=this.growingIO.minipInstance.getCurrentPage();r=t.options||this.queryOption[t.route]||{}}return[n,rt(r)]}}class xt{constructor(t){this.growingIO=t,this.main=(t,e,i)=>{var s,n;const r=Date.now(),{emitter:o,minipInstance:a,plugins:l,vdsConfig:g,platformConfig:u,dataStore:{getTrackerVds:c,getOriginalSource:d,setOriginalSource:h,trackersExecute:v,eventHooks:m,toggleShareOut:f,buildAppMessageEvent:I,buildTimelineEvent:y,buildAddFavorites:S}}=this.growingIO,{currentPage:O}=m;if(this.prevEvent[e]&&50>Date.now()-Number(this.prevEvent[e]))return;t||(t=a.getCurrentPage()),t.route||(t.route=a.getCurrentPath(t));const b=t.route||t.uri||t.__route__||(null===(s=null==t?void 0:t.$page)||void 0===s?void 0:s.fullPath)||"";o.emit(It,{event:"Page "+e,timestamp:r,params:{page:t,args:i[0]}}),g.debug&&console.log("Page:",b,"#",e,r),this.prevEvent[e]=Date.now();const w=u.listeners.page;switch(o.emit(Ot,{page:t,event:"Page "+e,params:{page:t,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=e,e){case w.pageLoad:O.queryOption[b]=q(t,"options")||q(t,"__displayReporter.query")||q(t,"$page.query")||q(t,"$wx.__displayReporter.query")||q(t,"$taroParams")||i[0]||{},j(O.queryOption[b],"$taroTimestamp");break;case w.pageShow:v((t=>{const e=d(t);N(e)||e.path!==b||h(t,Object.assign(Object.assign({},e),{title:O.getPageTitle()}));const{trackPage:i}=c(t);i&&this.buildPageEvent(t)})),f(!1);break;case w.pageHide:case w.pageUnload:break;case w.shareApp:f(!0),v((t=>{const{followShare:e}=c(t);e&&I(t,i)}));break;case w.shareTime:v((t=>{const{followShare:e}=c(t);e&&y(t,i)}));break;case w.addFavorites:v((t=>{const{followShare:e}=c(t);e&&S(t,i)}));break;case w.tabTap:{const t=null===(n=null==l?void 0:l.gioEventAutoTracking)||void 0===n?void 0:n.buildTabClickEvent;g.autotrack&&t&&p(t)&&t(this.growingIO.trackingId,i[0]);break}}},this.buildPageEvent=(t,e)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:s,eventHooks:{currentPage:n}}}=this.growingIO,r=Object.assign({eventType:"PAGE",referralPage:n.getReferralPage(t)},i(t));r.attributes=n.eventSetPageProps(t,r),!N(e)&&e.title&&(r.title=e.title),s(r)},this.prevEvent={}}}class Nt{constructor(t){var e;this.growingIO=t,this.isNormalFc=(t,e)=>p(e)&&"constructor"!==t,this.objectTraverse=(t,e)=>{Object.getOwnPropertyNames(t).forEach((i=>e(i,t))),T(t,"methods")&&Object.getOwnPropertyNames(t.methods).forEach((i=>{t[i]||e(i,t.methods)})),T(t,"lifetimes")&&Object.getOwnPropertyNames(t.lifetimes).forEach((i=>{t[i]||e(i,t.lifetimes)})),T(t,"pageLifetimes")&&Object.getOwnPropertyNames(t.pageLifetimes).forEach((i=>{t[i]||e(i,t.pageLifetimes)}))},this.supLifeFcs=(t,e)=>{v(this[e+"Handlers"])&&this[e+"Handlers"].forEach((e=>{p(t[e])||["onShareAppMessage","onShareTimeline"].includes(e)||(t[e]=()=>{})}))},this.lifeFcEffects=(t,e,i)=>{const s=this;return["onShareTimeline","onAddToFavorites"].includes(t)?function(...n){let r=e.apply(this,n);"onShareTimeline"===t&&s.growingIO.vdsConfig.followShare&&(r=s.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===t&&(r=s.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(n);return r&&o.push(r),s[`def${i}Cbs`][t].apply(this,o),r}:function(...n){var r;return At(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===t){if(o=null!==(r=e.apply(this,n))&&void 0!==r?r:{},"promise"===U(o)&&(o=yield o.then((t=>t))),"promise"===U(o.promise)){const t=function(){return At(this,void 0,void 0,(function*(){let t=o;return new Promise((e=>{let i=setTimeout((()=>{e(Object.assign({},t)),clearTimeout(i),i=void 0}),3e3);o.promise.then((s=>{t=s,e(Object.assign({},t)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield t()),j(o,"promise")}s.growingIO.vdsConfig.followShare&&(o=s.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(n);o&&a.push(o),s[`def${i}Cbs`][t].apply(this,a)}catch(t){$(t,"error")}return"onShareAppMessage"!==t&&(o=e.apply(this,n)),s.growingIO.emitter.emit(It,{event:`${i} ${t}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(n)}}),o}))}},this.customFcEffects=(t,e)=>{const i=this;return function(...s){var n,r;let o;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let e=s[0]||{};T(e,"type")&&((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))||(e=s[s.length-1]),((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))&&i.actionEventTypes.includes(e.type)&&(p(i.actionEffects)||(i.actionEffects=(null===(r=null===(n=i.growingIO.plugins)||void 0===n?void 0:n.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(e,t))}catch(t){$(t,"error")}return o=e.apply(this,s),o}},this.appApplyProxy=(t,e)=>this.appHandlers.includes(t)?this.lifeFcEffects(t,e,"App"):this.customFcEffects(t,e),this.pageApplyProxy=(t,e)=>this.pageHandlers.includes(t)?this.lifeFcEffects(t,e,"Page"):this.customFcEffects(t,e),this.appOverriding=t=>(this.setAppEffectCbs(),this.supLifeFcs(t,"app"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.appApplyProxy(t,e[t]))})),t),this.pageOverriding=t=>(this.setPageEffectCbs(),this.supLifeFcs(t,"page"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.componentOverriding=t=>(this.setPageEffectCbs(),t.methods||(t.methods={}),this.supLifeFcs(this.growingIO.inPlugin?t:t.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?t:t.methods,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.setAppEffectCbs=()=>{const t=this;this.appHandlers.forEach((e=>{this.defAppCbs[e]=function(...i){t.appEffects.main(e,i)}}))},this.setPageEffectCbs=()=>{const t=this;this.pageHandlers.forEach((e=>{this.defPageCbs[e]=function(...i){t.pageEffects.main(this,e,i)}}))},this.growingApp=t=>p(this.originalApp)?this.originalApp(this.appOverriding(t)):this.appOverriding(t),this.growingPage=t=>p(this.originalPage)?this.originalPage(this.pageOverriding(t)):this.pageOverriding(t),this.growingComponent=t=>p(this.originalComponent)?this.originalComponent(this.componentOverriding(t)):this.componentOverriding(t),this.growingBehavior=t=>p(this.originalBehavior)?this.originalBehavior(this.componentOverriding(t)):this.componentOverriding(t),this.nativeGrowing=(t=["App","Page","Component","Behavior"])=>{const e=this,{platformConfig:i}=this.growingIO,s=i.hooks;if(t.includes("App"))try{s.App&&!this.appHooked&&(App=function(...t){return e.originalApp(e.appOverriding(t[0]))},this.appHooked=!0)}catch(t){}if(t.includes("Page"))try{s.Page&&!this.pageHooked&&(Page=function(...t){return e.originalPage(e.pageOverriding(t[0]))},this.pageHooked=!0)}catch(t){}if(t.includes("Component"))try{s.Component&&!this.componentHooked&&(Component=function(...t){return e.originalComponent(e.componentOverriding(t[0]))},this.componentHooked=!0)}catch(t){}if(t.includes("Behavior"))try{s.Behavior&&!this.behaviorHooked&&(Behavior=function(...t){return e.originalBehavior(e.componentOverriding(t[0]))},this.behaviorHooked=!0)}catch(t){}},this.initOriginalValue=()=>{this.setAppEffectCbs(),this.setPageEffectCbs(),this.originalApp=L((()=>App||global.App)),this.originalPage=L((()=>Page||global.Page)),this.originalComponent=L((()=>Component||global.Component)),this.originalBehavior=L((()=>Behavior||global.Behavior))},this.initEventHooks=()=>{const t=this,{platformConfig:e,gioPlatform:i}=this.growingIO;this.initOriginalValue(),e.canHook?(this.nativeGrowing(),et().GioApp=L((()=>null!==App&&void 0!==App?App:this.originalApp)),et().GioPage=L((()=>null!==Page&&void 0!==Page?Page:this.originalPage)),et().GioComponent=L((()=>null!==Component&&void 0!==Component?Component:this.originalComponent)),et().GioBehavior=L((()=>null!==Behavior&&void 0!==Behavior?Behavior:this.originalBehavior))):"quickapp"===i&&(et().GioApp=function(...e){return t.appOverriding(e[0])},et().GioPage=function(...e){return t.pageOverriding(e[0])},et().GioComponent=function(...e){return t.pageOverriding(e[0])})};const i=null===(e=this.growingIO)||void 0===e?void 0:e.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new qt(this.growingIO),this.pageEffects=new xt(this.growingIO),this.currentPage=new jt(this.growingIO)}}class Ut{constructor(t){var e,i;this.growingIO=t,this.ALLOW_SETTING_KEYS=E(ut),this.getStorageKey=(t,e)=>{const{inPlugin:i}=this.growingIO;return`${t===this.growingIO.trackingId?"":t}${ft[i?"plugin_"+e:e]}`},this.getGsid=t=>{let e=Number(this._gsid[t]);return Number.isNaN(e)||e>=1e9||1>e?(this.setGsid(t,1),1):e},this.setGsid=(t,e)=>{let i=Number(e);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[t]=i,10>this._gsid[t]-this._stid[t]||this.saveStorageInfo()},this.initStorageInfo=t=>{const{minipInstance:e}=this.growingIO,i=e.getStorageSync(this.getStorageKey(t,"gsid"));let s=Number(i);(Number.isNaN(s)||s>=1e9||1>s)&&(s=1),this._gsid[t]=s,this._stid[t]=s,s!==i&&e.setStorageSync(this.getStorageKey(t,"gsid"),s)},this.saveStorageInfo=()=>{const{minipInstance:t}=this.growingIO;this._stid=Object.assign({},this._gsid),nt(t,this.initializedTrackingIds.map((t=>({key:this.getStorageKey(t,"gsid"),value:this._gsid[t]}))))},this.setOriginalSource=(t,e)=>{const{minipInstance:i}=this.growingIO;i.setStorageSync(this.getStorageKey(t,"originalSource"),JSON.stringify(e))},this.getOriginalSource=t=>{var e;const{minipInstance:i}=this.growingIO;return null!==(e=L((()=>JSON.parse(i.getStorageSync(this.getStorageKey(t,"originalSource"))))))&&void 0!==e?e:{}},this.getTrackerVds=t=>this.growingIO.trackingId===t?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=t=>{const e=this.initOptions(t);return e.trackingId=t.trackingId,this.growingIO.trackingId=t.trackingId,this.growingIO.vdsConfig=e,e},this.initTrackerHooker=t=>{var e,i;const{platformConfig:s,inPlugin:n,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:l}=t;a||l||"quickapp"===r.platform||(s.canHook=!0),!n||["tbp","jdp"].includes(r.platform)?this.eventHooks.initEventHooks():this.eventHooks.initOriginalValue(),a&&(null===(e=null==o?void 0:o.gioUniAppAdapter)||void 0===e||e.main()),l&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=t=>{var e,i,s,n,r,o;const{projectId:a,dataSourceId:l,appId:g,trackingId:u}=t,c={};return this.ALLOW_SETTING_KEYS.forEach((e=>{const i=ut[e].type;(v(i)?i.includes(U(t[e])):U(t[e])===ut[e].type)?"ignoreFields"===e?c.ignoreFields=t.ignoreFields.filter((t=>vt.includes(t))):"extraParams"===e?c.extraParams=t.extraParams.filter((t=>mt.includes(t))):(c[e]=t[e],["dataCollect","autotrack"].includes(e)&&!c[e]&&$("已关闭"+ht[e],"info")):c[e]=ut[e].default})),c.uploadInterval=Math.round(c.uploadInterval),(Number.isNaN(c.uploadInterval)||0>c.uploadInterval||c.uploadInterval>3e3)&&(c.uploadInterval=1e3),c.enableIdMapping&&!c.idMapping&&(c.idMapping=!0,c.idMapping||this.growingIO.userStore.setUserKey(u,"")),j(c,"enableIdMapping"),c.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(c.requestTimeout))&&c.requestTimeout>0||(c.requestTimeout=5e3),Object.assign(Object.assign({},c),{projectId:a,dataSourceId:l,appId:g,trackingId:u,performance:{monitor:null===(i=null===(e=c.performance)||void 0===e?void 0:e.monitor)||void 0===i||i,exception:null===(n=null===(s=c.performance)||void 0===s?void 0:s.exception)||void 0===n||n,network:null!==(o=null===(r=c.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(t,e,i)=>{var s;const{userStore:n,emitter:r}=this.growingIO,o=this.getTrackerVds(t),a=u(e)&&this.ALLOW_SETTING_KEYS.includes(e),l=a&&typeof i===(null===(s=ut[e])||void 0===s?void 0:s.type);if(a&&l){const s=Object.assign({},o);return this.updateVdsConfig(t,Object.assign(Object.assign({},o),{[e]:i})),"dataCollect"===e&&s.dataCollect!==i&&i&&(n.setSessionId(t),this.sendVisit(t),this.sendPage(t)),r.emit(_t,{optionName:e,optionValue:i}),!0}return H("setOption > "+e),!1},this.getOption=(t,e)=>{const i=this.getTrackerVds(t);return e&&T(this.growingIO.vdsConfig,e)?T(i,e)?i[e]:this.growingIO.vdsConfig[e]:N(e)?i:void H("getOption > "+e)},this.updateVdsConfig=(t,e)=>{t===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),e),et().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[t]=Object.assign(Object.assign({},this.growingIO.subInstance[t]),e),et().vdsConfig.subInstance[t]=this.growingIO.subInstance[t])},this.toggleShareOut=t=>{d(t)?this.shareOut=t:this.shareOut=!this.shareOut},this.sendVisit=(t,e)=>{this.eventHooks.appEffects.buildVisitEvent(t,e)},this.sendPage=(t,e)=>{this.eventHooks.pageEffects.buildPageEvent(t,e)},this.eventConverter=t=>{const{dataStore:e,uploader:i}=this.growingIO,{dataCollect:s}=this.getTrackerVds(t.trackingId);if(s){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(t.eventType)||(t.eventSequenceId=e.getGsid(t.trackingId),e.setGsid(t.trackingId,t.eventSequenceId+1));const s={};C(t,((t,e)=>{var i;if("element"===e){const e=null!==(i=f(t))&&void 0!==i?i:{};C(e,((t,e)=>{N(t)&&0!==t||(s[e]=t)}))}else N(t)&&0!==t||(s[e]=t)})),this.growingIO.emitter.emit(St,{composedEvent:s}),i.commitRequest(Object.assign(Object.assign({},s),{requestId:B()}))}},this.eventRefactor=t=>{var e,i;const s=Object.assign(Object.assign({},t),this.eventContextBuilder(t.trackingId,{path:t.path,query:t.query,timestamp:t.timestamp}));return s.attributes=Object.assign(Object.assign({},null!==(e=s.attributes)&&void 0!==e?e:{}),null!==(i=t.attributes)&&void 0!==i?i:{}),s},this.eventInterceptor=t=>{const{systemInfo:e,network:i}=this.growingIO.minipInstance;N(e)||N(i)?this.interceptEvents.push(t):N(this.interceptEvents)?this.eventConverter(t):([...this.interceptEvents,t].forEach((t=>{this.eventConverter(this.eventRefactor(t))})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:t,network:e}}=this.growingIO;t&&e&&!N(this.interceptEvents)&&([...this.interceptEvents].forEach((t=>{this.eventConverter(this.eventRefactor(t))})),this.interceptEvents=[])},this.buildAppMessageEvent=(t,e)=>{var i,s;const n=e[0];let r;2>e.length?1===e.length&&(r=n):r=e[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(t));g.attributes=it(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$from:n.from,$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:f(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildTimelineEvent=(t,e)=>{var i,s;const n=e[0];let r;2>e.length?1===e.length&&(r=n):r=e[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(t));g.attributes=it(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:f(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildAddFavorites=(t,e)=>{var i;const s=e[0];let n;2>e.length?1===e.length&&(n=s):n=e[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==n?void 0:n.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(t));l.attributes=it(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$share_title:null==n?void 0:n.title,$share_path:f(a),$share_query:a[1]})),o(l)},this.trackersExecute=t=>{this.initializedTrackingIds.forEach((e=>{"function"===U(t)&&t(e)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new Ct(this.growingIO).main,this.eventHooks=new Nt(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:s,minipInstance:n}=this.growingIO;s.on(Et,(({trackingId:t})=>{this.initializedTrackingIds.push(t),this.initStorageInfo(t)})),s.on(yt,(({eventData:t,trackingId:e})=>{"VISIT"===t.eventType&&(this.lastVisitEvent[e]=t),"PAGE"===t.eventType&&(this.lastPageEvent[e]=t)})),p(null===(e=n.minip)||void 0===e?void 0:e.onAppHide)&&n.minip.onAppHide((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];C(e,(t=>{t.start&&(t.leng=t.leng+(+Date.now()-t.start))}))}))})),p(null===(i=n.minip)||void 0===i?void 0:i.onAppShow)&&n.minip.onAppShow((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];C(e,(t=>{t.start&&(t.start=+Date.now())}))}))})),s.on(_t,(({optionName:t,optionValue:e})=>{"dataCollect"===t&&!1===e&&this.trackersExecute((t=>{this.growingIO.clearTrackTimer(t)}))}))}get scene(){return this._scene}set scene(t){const e=this._scene;this._scene=t,e!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:t,oldScene:e})}}const Dt={name:"QuickApp",platform:"quickapp",scnPrefix:"quickapp_",appHandlers:["onCreate","onShow","onHide","onDestroy","onError"],pageHandlers:["onInit","onReady","onShow","onHide","onDestroy","onMenuPress","onShareAppMessage"],actionEventTypes:["click","longpress","blur","change"],canHook:!1,hooks:{App:!1,Page:!1,Component:!1,Behavior:!1},listeners:{app:{appCreate:"onCreate",appShow:"onShow",appHide:"onHide",appClose:"onDestroy"},page:{pageLoad:"onInit",pageReady:"onReady",pageShow:"onShow",pageHide:"onHide",pageClose:"onDestroy",menuPress:"onMenuPress",tabTap:void 0,shareApp:"onShareAppMessage"},actions:{click:["click","longpress"],change:["blur","change"],submit:[]}}};class Kt{constructor(t){this.growingIO=t,this.minip=Y("quickapp"),this.hookSetTitle=()=>{var t;const e=null===(t=this.minip)||void 0===t?void 0:t.setNavigationBarTitle,i=this;e&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const t=i.getCurrentPath(),{title:e}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.settedTitle[t]=e}return e.apply(this,arguments)}})},this.navigateTo=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateTo(t)},this.switchTab=t=>{var e;null===(e=this.minip)||void 0===e||e.switchTab(t)},this.navigateToMiniProgram=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateToMiniProgram(t)},this.getImageInfo=({src:t,success:e,fail:i,complete:s})=>{var n;return null===(n=this.minip)||void 0===n?void 0:n.getImageInfo({src:t,success:e,fail:i,complete:s})},this.initImpression=t=>{var e,i;null===(i=null===(e=this.growingIO.plugins)||void 0===e?void 0:e.gioImpressionTracking)||void 0===i||i.main(t,"observeAll")},this.getCurrentPage=()=>L((()=>I(getCurrentPages())))||{},this.getCurrentPath=()=>{const t=this.getCurrentPage();return(null==t?void 0:t.route)||(null==t?void 0:t.uri)||(null==t?void 0:t.__route__)||""},this.getPageTitle=t=>{var e;const i=X();let s="",n=Z(i);"string"===U(n)&&(n=null!==(e=L((()=>JSON.parse(n))))&&void 0!==e?e:{});const r=(null==t?void 0:t.data)||t.$data||{};if(s=u(null==r?void 0:r.gioPageTitle)?null==r?void 0:r.gioPageTitle:"",n){const{enterParams:e}=this.growingIO.dataStore.eventHooks.appEffects;t.route||N(e)||(t.route=e.path||"",s=this._getTitleFromTabbar(n,t.route)),L((()=>{var e,r,o,a,l,g;if(!s){const u=n.page||{},c=u[t.route]||u[t.route+".html"];s=c?null===(e=null==c?void 0:c.window)||void 0===e?void 0:e.navigationBarTitleText:["wx","tt"].includes(i)?null===(a=null===(o=null===(r=n||global||$global)||void 0===r?void 0:r.global)||void 0===o?void 0:o.window)||void 0===a?void 0:a.navigationBarTitleText:null===(g=null===(l=n||global||$global)||void 0===l?void 0:l.window)||void 0===g?void 0:g.navigationBarTitleText}})),s||(s=this._getTitleFromTabbar(n,t.route))}return V(s)},this._getTitleFromTabbar=(t,e)=>{var i,s;const n=null===(s=null===(i=null==t?void 0:t.tabBar)||void 0===i?void 0:i.list)||void 0===s?void 0:s.find((t=>t.pagePath===e||t.pagePath===e+".html"));return(null==n?void 0:n.text)||""},this.getStorageSync=t=>{var e;let i=null===(e=this.minip)||void 0===e?void 0:e.getStorageSync(t);return h(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=t=>new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:t,success:({data:t})=>e(t),fail:()=>e("")})})),this.setStorageSync=(t,e,i)=>{var s;i&&(e={value:e,expiredAt:i}),null===(s=this.minip)||void 0===s||s.setStorageSync(t,e)},this.setStorage=(t,e)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:t,data:e})},this.removeStorageSync=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorageSync(t)},this.removeStorage=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorage(t)},this.getNetworkType=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{t.network=i,e(i)},fail:()=>e(null)})}))},this.request=({url:t,data:e,header:i,timeout:s,method:n,success:r,fail:o,complete:a})=>{var l;const g=null===(l=this.minip)||void 0===l?void 0:l.request({url:t,data:e,header:i,headers:i,timeout:s,method:n,success:r,fail:o,complete:a});let u=setTimeout((()=>{(null==g?void 0:g.abort)&&p(null==g?void 0:g.abort)&&(null==g||g.abort()),clearTimeout(u),u=null}),(s||1e4)+10);return g},this.getSystemInfo=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{t.systemInfo=i,e(i)},fail:()=>e(null)})}))},this.getSetting=()=>new Promise((t=>{var e;null===(e=this.minip)||void 0===e||e.getSetting({success:t,fail:t})}));const{platformConfig:{platform:e,scnPrefix:i}}=this.growingIO;this.platform=e,this.scnPrefix=i,this.growingIO.emitter.on(Tt,(()=>{this.getNetworkType().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()}))}))}}class $t extends Kt{constructor(l){super(l),this.growingIO=l,this.getAppSource=()=>{const{source:e}=t.getInfo();return this.appSource=e||{},this.appSource},this.navigateTo=()=>{},this.switchTab=()=>{},this.navigateToMiniProgram=()=>{},this.onAppShow=()=>{},this.onAppHide=()=>{},this.getImageInfo=({src:t,success:e,fail:i,complete:n})=>null==s?void 0:s.getImageInfo({uri:t,success:e,fail:i,complete:n}),this.initImpression=()=>{},this.initShareAppMessage=t=>{const{platformConfig:e}=t;try{this.growingIO.shareAppMessage=function(){var i;const s=arguments[0];null==o||o.share(s),null===(i=null==t?void 0:t.eventTracking)||void 0===i||i.pageEffects(this,e.listeners.page.shareApp,arguments)}}catch(t){}},this.getCurrentPage=()=>(null==r?void 0:r.getPages)?I(null==r?void 0:r.getPages()):{},this.getCurrentPath=()=>{const t=null==r?void 0:r.getState();return null==t?void 0:t.path},this.getPageTitle=t=>{var e,i,s,n,o;let a="";try{if(a=u(null==t?void 0:t.gioPageTitle)?null==t?void 0:t.gioPageTitle:"",!a){const r=null!==(o=null===(n=null===(s=null===(i=null===(e=null==t?void 0:t.$app)||void 0===e?void 0:e.$def)||void 0===i?void 0:i.manifast)||void 0===s?void 0:s.display)||void 0===n?void 0:n.pages)&&void 0!==o?o:{},l=null==r?void 0:r[t.route];l&&(a=l.titleBarText)}if(!a){const t=null==r?void 0:r.getState();a=(null==t?void 0:t.name)||""}}catch(t){return""}return V(a)},this.getStorageSync=()=>"",this.getStorage=t=>At(this,void 0,void 0,(function*(){return yield new Promise((e=>{null==a||a.get({key:t,success:t=>e(t),fail:()=>e(null)})}))})),this.setStorageSync=()=>{},this.setStorage=(t,e)=>{},this.removeStorageSync=()=>{},this.removeStorage=t=>{null==a||a.delete({key:t})},this.getNetworkType=()=>At(this,void 0,void 0,(function*(){const t=this;return yield new Promise((e=>{null==n||n.getType({success:i=>{t.network=i,e(i)},fail:()=>e(null)})}))})),this.request=({url:t,header:e,method:s,data:n,success:r,fail:o,complete:a})=>null==i?void 0:i.fetch({url:t,header:e,method:s,data:n,success:r,fail:o,complete:a}),this.getSystemInfo=()=>At(this,void 0,void 0,(function*(){const t=this;return yield new Promise((i=>{null==e||e.getInfo({success:e=>{const s=Object.assign(Object.assign({},e),{version:e.platformVersionName,platform:e.osType});t.systemInfo=s,i(s)},fail:()=>i(null)})}))})),this.growingIO.emitter.on(It,(({event:t})=>{switch(t){case"App onCreate":this.getNetworkType().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()}));break;case"App onCreateEnd":this.setStorage=(t,e)=>{null==a||a.set({key:t,value:e})}}}))}}const Ht=["gioPerformance"];class Lt{constructor(t){var e,i,s,n,r,o;this.growingIO=t,this.innerPluginInit=()=>{var t;Ht.forEach((t=>{var e;return j(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins,t)})),E(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins).forEach((t=>{var e,i;const{name:s,method:n}=null!==(i=null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins[t])&&void 0!==i?i:{};O(this.pluginItems,(t=>t.name===s))||this.pluginItems.push({name:P(s||t),method:n||(t=>{})})})),N(this.pluginItems)||this.installAll()},this.install=(t,e,i)=>{var s,n;const{emitter:r}=this.growingIO,o=e||O(this.pluginItems,(e=>e.name===t));if((null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[t])return $(`重复加载插件 ${t} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return $(`插件加载失败!不存在名为 ${t} 的插件!`,"error"),!1;try{return(null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[t]=new o.method(this.growingIO,i),e&&(r.emit(wt,t),$("加载插件 "+t,"info")),!0}catch(i){return this.lifeError(e,i),$(`插件【${t}】加载异常 ${i}`,"error"),!1}},this.installAll=t=>{(t||this.pluginItems).forEach((e=>{this.install(e.name,t?e:void 0,t?null==e?void 0:e.options:void 0)&&!O(this.pluginItems,(t=>t.name===e.name))&&this.pluginItems.push({name:P(e.name),method:e.method?e.method:()=>{}})}))},this.uninstall=t=>{var e;j(this.pluginItems,t);const i=j(null===(e=this.growingIO)||void 0===e?void 0:e.plugins,t);return i||$(`卸载插件 ${t} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((t=>this.uninstall(t.name)))},this.lifeError=(t,e)=>{this.growingIO.emitter.emit(bt,{plugin:t,error:e}),$(`插件执行错误 ${t.name} ${e}`,"error")},this.callLifeCycle=(t,e)=>{this.pluginItems.forEach((i=>{const s=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][t]:void 0;if(s&&p(s))try{s(e)}catch(t){this.lifeError(i,t)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(e=this.growingIO.emitter)||void 0===e||e.on(wt,(t=>this.callLifeCycle("onInstall",t))),null===(i=this.growingIO.emitter)||void 0===i||i.on(bt,(t=>this.callLifeCycle("onError",t))),null===(s=this.growingIO.emitter)||void 0===s||s.on(Ot,(t=>this.callLifeCycle("onComposeBefore",t))),null===(n=this.growingIO.emitter)||void 0===n||n.on(St,(t=>this.callLifeCycle("onComposeAfter",t))),null===(r=this.growingIO.emitter)||void 0===r||r.on(kt,(t=>this.callLifeCycle("onSendBefore",t))),null===(o=this.growingIO.emitter)||void 0===o||o.on(Pt,(t=>this.callLifeCycle("onSendAfter",t)))}}var Rt={},Vt={}.hasOwnProperty;function Ft(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(t){return null}}function Mt(t){try{return encodeURIComponent(t)}catch(t){return null}}Rt.stringify=function(t,e){e=e||"";var i,s,n=[];for(s in"string"!=typeof e&&(e="?"),t)if(Vt.call(t,s)){if((i=t[s])||null!=i&&!isNaN(i)||(i=""),s=Mt(s),i=Mt(i),null===s||null===i)continue;n.push(s+"="+i)}return n.length?e+n.join("&"):""},Rt.parse=function(t){for(var e,i=/([^=?#&]+)=?([^&]*)/g,s={};e=i.exec(t);){var n=Ft(e[1]),r=Ft(e[2]);null===n||null===r||n in s||(s[n]=r)}return s};class Bt{constructor(t){this.growingIO=t,this.generateURL=t=>{const{serverUrl:e,projectId:i}=this.growingIO.dataStore.getTrackerVds(t);return k(e,"http")?`${e}/v3/projects/${i}/collect`:`https://${e}/v3/projects/${i}/collect`},this.getHoardingQueue=t=>{var e;return null!==(e=this.hoardingQueue[t])&&void 0!==e?e:[]},this.getRequestQueue=t=>{var e;return null!==(e=this.requestQueue[t])&&void 0!==e?e:[]},this.commitRequest=t=>{var e,i;const s=Object.assign({},t),{vdsConfig:n,emitter:r}=this.growingIO;r.emit(yt,{eventData:t,trackingId:t.trackingId}),n.forceLogin?(g(this.hoardingQueue[t.trackingId])&&(this.hoardingQueue[t.trackingId]=[]),null===(e=this.hoardingQueue[t.trackingId])||void 0===e||e.push(s)):(g(this.requestQueue[t.trackingId])&&(this.requestQueue[t.trackingId]=[]),null===(i=this.requestQueue[t.trackingId])||void 0===i||i.push(s),this.initiateRequest(t.trackingId))},this.initiateRequest=(t,e)=>{const{plugins:i,vdsConfig:s,minipInstance:n,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(t),...this.getRequestQueue(t)],a=t=>{var a,l;if(null===(a=null==s?void 0:s.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(l=null==i?void 0:i.gioTaobaoAdapter)||void 0===l||l.singleInvoke(t);else if(e)this.batchInvoke(t);else{const{uploadInterval:e}=this.growingIO.dataStore.getTrackerVds(t);x(this.batchInvoke,e,!1,!1)(t)}o.some((t=>"VISIT"===t.eventType))&&n.removeStorageSync(r.getStorageKey(t,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(t);else{let e=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(t),clearInterval(e),e=void 0)}),500)}},this.batchInvoke=t=>{const{vdsConfig:e,emitter:i}=this.growingIO,s=this.getHoardingQueue(t),n=this.getRequestQueue(t);let r=[...s,...n];r.length>50?(r=r.slice(0,50),s.length>50?this.hoardingQueue[t]=s.slice(50):(this.requestQueue[t]=n.slice(50-s.length),this.hoardingQueue[t]=[])):(this.hoardingQueue[t]=[],this.requestQueue[t]=[]);let o=r.filter((t=>(this.retryIds[t.requestId]||0)<=this.retryLimit));if(N(o))return;const a=o.map((t=>{const e=Object.assign({},t);return j(e,["requestId","trackingId"]),e}));e.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(kt,{eventsQueue:o,requestData:a,trackingId:t})},this.sendEvent=(t,e)=>{var i;const s=f(t).trackingId,{minipInstance:n,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:g}=r.getTrackerVds(s);this.requestingNum+=1;const u={"content-type":"jdp"===n.platform?"application/json":"application/json;charset=UTF-8"};let c=[...e];const d=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);d&&(c=a.gioCompress.compressToUTF16(JSON.stringify(e)),u["X-Compress-Codec"]="1");const h=this.generateURL(s);n.request({url:`${h}?stm=${Date.now()}&compress=${d?"1":"0"}`,header:u,method:"POST",data:c,timeout:g,fail:e=>{[200,204].includes(e.code)||(t.forEach((t=>{this.requestFailFn(t)})),$("请求失败!"+JSON.stringify(e),"error"))},complete:t=>{this.requestingNum-=1,o.emit(Pt,{result:t,requestData:e}),this.initiateRequest(s)}})},this.requestFailFn=t=>{if(this.retryIds[t.requestId]||(this.retryIds[t.requestId]=0),this.retryIds[t.requestId]+=1,!this.requestQueue[t.trackingId].some((e=>e.requestId===t.requestId))){let e=setTimeout((()=>{N(this.requestQueue[t.trackingId])?(this.requestQueue[t.trackingId].push(t),this.initiateRequest(t.trackingId)):this.requestQueue[t.trackingId].push(t),clearTimeout(e),e=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:e,vdsConfig:i,plugins:s}=this.growingIO;e.on(kt,(({eventsQueue:t,requestData:e,trackingId:n})=>{var r,o;n===this.growingIO.trackingId&&((null===(r=null==i?void 0:i.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==s?void 0:s.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(t,e):this.sendEvent(t,e))}))}}class Gt{constructor(t){this.growingIO=t,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:t}=this.growingIO;return this._uid||(this._uid=t.getStorageSync(this._getUidKey())),this._uid||(this._uid=B(),t.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=t=>{const e=this._uid;this._uid=t,e!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:t,oldUId:e}))},this.getSessionId=t=>(this._sessionId[t]||this.setSessionId(t),this._sessionId[t]),this.setSessionId=(t,e)=>{const i=this._sessionId[t];e||(e=B()),this._sessionId[t]=e,i!==e&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:e,oldSessionId:i})},this._getUserIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"userId"),this.getUserId=t=>{const{minipInstance:e}=this.growingIO;return this._userId[t]||(this._userId[t]=e.getStorageSync(this._getUserIdKey(t))),this._userId[t]},this.setUserId=(t,e)=>{const i=this._userId[t];this._userId[t]=g(e)?"":e,i!==this._userId[t]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(t),this._userId[t]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:e,oldUserId:i})),e&&this.setGioId(t,e)},this._getUserKeyKey=t=>this.growingIO.dataStore.getStorageKey(t,"userKey"),this.getUserKey=t=>{const{minipInstance:e}=this.growingIO;return this._userKey[t]||(this._userKey[t]=e.getStorageSync(this._getUserKeyKey(t))),this._userKey[t]},this.setUserKey=(t,e)=>{const i=this._userKey[t];this._userKey[t]=g(e)?"":e,i!==this._userKey[t]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(t),this._userKey[t]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:e,oldUserKey:i}))},this._getGioIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"gioId"),this.getGioId=t=>{const{minipInstance:e}=this.growingIO;return this._gioId[t]||(this._gioId[t]=e.getStorageSync(this._getGioIdKey(t))),this._gioId[t]},this.setGioId=(t,e)=>{const i=this._gioId[t];this._gioId[t]=g(e)?"":e,i!==this._gioId[t]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(t),this._gioId[t]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:e,oldGioId:i}))},this.initUserInfo=t=>{var e;const{minipInstance:i}=this.growingIO,s=[this._getUidKey(),this._getUserIdKey(t),this._getUserKeyKey(t),this._getGioIdKey(t)],n=null!==(e=st(i,s))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,i)=>{"_uid"===e?this.getUid():this[e][t]=n[i]}))},this.saveUserInfo=()=>{const{minipInstance:t,dataStore:{trackersExecute:e}}=this.growingIO;e((e=>{nt(t,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(e),value:this._userId[e]},{key:this._getUserKeyKey(e),value:this._userKey[e]},{key:this._getGioIdKey(e),value:this._gioId[e]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={}}}const Qt=new class{constructor(){var t;this.init=t=>{var e;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:t});try{if($("Gio小程序SDK 初始化中...","info"),t.trackingId&&this.dataStore.initializedTrackingIds.includes(t.trackingId))throw Error(`已存在实例 ${t.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(t);return null===(e=this.emitter)||void 0===e||e.emit(Tt,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(t.trackingId),this.emitter.emit(Et,i),this.trackingId&&this.trackingId!==t.trackingId||(et().__gio__=()=>this),$("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&$("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(t){return $(t,"error"),!1}},this.handlerDistribute=(t,e,i)=>{const{initializedTrackingIds:s,getTrackerVds:n}=this.dataStore;if(n(t)&&s.includes(t))return this[e](t,...i);$(`不存在实例:${t},请检查!`,"warn")},this.registerPlugins=t=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...t],this.plugins.installAll(t)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(t,e)=>this.dataStore.getOption(t,e),this.setOption=(t,e,i)=>{var s;return E(ht).includes(e)?typeof i===(null===(s=ut[e])||void 0===s?void 0:s.type)?(this.dataStore.setOption(t,e,i),$(`已修改${ht[e]}: ${i}`,"info"),!0):($(`参数格式不正确:${i},请检查后重试!`,"error"),!1):($(`不存在可修改的配置项:${e},请检查后重试!`,"error"),!1)},this.setPageAttributes=(t,e)=>{if(h(e)&&!N(e)){const{currentPage:i}=this.dataStore.eventHooks,s=i.getPagePath();return N(i.pageProps[t])&&(i.pageProps[t]={}),N(i.pageProps[t][s])&&(i.pageProps[t][s]={}),N(e)||C(e,((e,n)=>{p(i.pageProps[t][s][n])&&!p(e)||(i.pageProps[t][s][n]=e)})),!0}return H("setPageAttributes"),!1},this.clearPageAttributes=(t,e)=>{try{if(!N(this.dataStore.eventHooks.currentPage.pageProps[t])){const{currentPage:i}=this.dataStore.eventHooks,s=i.getPagePath();v(e)&&!N(e)?e.forEach((e=>{j(i.pageProps[t][s],e)})):i.pageProps[t][s]={}}}catch(t){return H("clearPageAttributes"),!1}},this.sendPage=(t,e)=>{const{trackPage:i}=this.dataStore.getTrackerVds(t);i?$("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(t,e)},this.identify=(t,e)=>{if(t===this.trackingId)if(this.vdsConfig.forceLogin){if(!gt(e))return void H("identify");const t=b(e).slice(0,1e3);this.userStore.setUid(t),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((e=>{const i=this.uploader.getHoardingQueue(e);i.forEach(((e,s)=>i[s].deviceId=t)),this.uploader.initiateRequest(e,!0)}))}else H("identify",!1,"forceLogin未开启");else H("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(t,e)=>{var i,s,n,r;if(h(e)&&!N(e)){const{eventContextBuilder:o,eventInterceptor:a,lastVisitEvent:l}=this.dataStore,g=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},o(t));g.attributes=it(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),M(e))),g.path||(g.path=null===(s=l[t])||void 0===s?void 0:s.path,g.query=null===(n=l[t])||void 0===n?void 0:n.query,g.title=null===(r=l[t])||void 0===r?void 0:r.title),a(g)}else H("setUserAttributes")},this.setUserId=(t,e,i)=>{if(gt(e)){const s=this.userStore.getGioId(t);e=b(e).slice(0,1e3),i=b(i).slice(0,1e3),this.userStore.setUserId(t,e);const{idMapping:n}=this.dataStore.getTrackerVds(t);n&&this.userStore.setUserKey(t,g(i)?"":i),s&&s!==e&&(this.userStore.setSessionId(t),this.dataStore.sendVisit(t))}else H("setUserId")},this.clearUserId=t=>{this.userStore.setUserId(t,void 0),this.userStore.setUserKey(t,void 0)},this.setGeneralProps=(t,e)=>h(e)&&!N(e)?(N(this.dataStore.generalProps[t])&&(this.dataStore.generalProps[t]={}),C(e,((e,i)=>{p(this.dataStore.generalProps[t][i])&&!p(e)||(this.dataStore.generalProps[t][i]=e)})),!0):(H("setGeneralProps"),!1),this.clearGeneralProps=(t,e)=>{try{N(this.dataStore.generalProps[t])||(v(e)&&!N(e)?e.forEach((e=>{j(this.dataStore.generalProps[t],e)})):this.dataStore.generalProps[t]={})}catch(t){return H("clearGeneralProps"),!1}},this.track=(t,e,i)=>{F(e,(()=>{var s;const{eventContextBuilder:n,eventInterceptor:r}=this.dataStore,o=Object.assign({eventType:"CUSTOM",eventName:e},n(t));o.attributes=it(Object.assign(Object.assign({},null!==(s=o.attributes)&&void 0!==s?s:{}),M(Object.assign({},h(i)&&!N(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(o["&&sendTo"]=i["&&sendTo"]),r(o)}))},this.trackTimerStart=(t,e)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(t);return i?F(e,(()=>{const i=B();return this.dataStore.trackTimers[t]||(this.dataStore.trackTimers[t]={}),this.dataStore.trackTimers[t][i]={eventName:e,leng:0,start:+Date.now()},i})):($("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(t,e,i)=>{var s;const{dataCollect:n}=this.dataStore.getTrackerVds(t),r=this.dataStore.trackTimers[t];if(e&&r&&r[e]){if(n){const n=864e5,o=r[e];if(0!==o.start){const t=+Date.now()-o.start;o.leng=t>0?o.leng+t:0}const{eventContextBuilder:a,eventInterceptor:l}=this.dataStore,g=Object.assign({eventType:"CUSTOM",eventName:o.eventName},a(t));return g.attributes=it(Object.assign(Object.assign({},null!==(s=g.attributes)&&void 0!==s?s:{}),M(Object.assign(Object.assign({},h(i)&&!N(i)?i:{}),{event_duration:o.leng>n?0:o.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(g["&&sendTo"]=i["&&sendTo"]),l(g),!0}return $("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return $("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(t,e)=>{const i=this.dataStore.trackTimers[t];return e&&i&&i[e]?(delete i[e],!0):($("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=t=>{this.dataStore.trackTimers[t]={}},this.setLocation=(t,e,i)=>{N(this.dataStore.locationData[t])&&(this.dataStore.locationData[t]={});const s=this.dataStore.locationData[t],n=t=>t>=-180&&180>=t;n(e)&&n(i)&&(s.latitude!==e||s.longitude!==i)&&(this.dataStore.locationData[t]={latitude:e,longitude:i})},this.updateImpression=()=>{$("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(t,e,i)=>{$("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),R(i,{})},this.getGioInfo=t=>{const{getUid:e,getUserId:i,getUserKey:s,getSessionId:n}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:l,idMapping:g,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(t),d={gioappid:o,giocs1:i(t)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:n(t),giou:e()};return d.giodatacollect=l,d.giodatasourceid=a,g&&(d.giouserkey=s(t)),N(u)||u.forEach((e=>{var i;c.includes(e)||(d["gio"+e]=(null!==(i=this.dataStore.lastVisitEvent[t])&&void 0!==i?i:{})[e])})),Rt.stringify(d)},this.utils=Object.assign(Object.assign(Object.assign({},K),lt),{qs:Rt}),this.emitter={all:t=t||new Map,on:function(e,i){var s=t.get(e);s?s.push(i):t.set(e,[i])},off:function(e,i){var s=t.get(e);s&&(i?s.splice(s.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var s=t.get(e);s&&s.slice().map((function(t){t(i)})),(s=t.get("*"))&&s.slice().map((function(t){t(e,i)}))}},this.gioPlatform="quickapp",this.gioFramework="native",this.sdkVersion="4.3.0";try{"quickapp"===this.gioPlatform||p(getApp)&&p(App)?this.inPlugin=!1:this.inPlugin=!0}catch(t){this.inPlugin=!0}this.inPlugin&&$("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Dt,this.minipInstance=new $t(this),this.dataStore=new Ut(this),this.userStore=new Gt(this),this.uploader=new Bt(this),this.plugins=new Lt(this),this.plugins.innerPluginInit()}},zt=function(){var t;const e=arguments[0];let i="g0",s=e;if(e.indexOf(".")>-1&&(i=null!==(t=e.split(".")[0])&&void 0!==t?t:"g0",s=e.split(".")[1]),u(s)&&dt.includes(s)&&Qt[s]){const t=y(Array.from(arguments));if("init"===s){const e=((t,e)=>{const i=b(e[0]),s=b(e[1]),n=(4===e.length?e[3]:e[2])||{};return i&&s?t.dataStore.initializedTrackingIds.some(((e,n)=>{const r=0===n?t.vdsConfig:t.subInstance[e];return r.projectId===i&&r.dataSourceId===s}))?($("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:s,appId:b(4===e.length?e[2]:""),userOptions:n}:($('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})(Qt,t);if(e){const{projectId:t,dataSourceId:s,appId:n,userOptions:r}=e;return Qt.init(Object.assign(Object.assign({},r),{projectId:t,dataSourceId:s,appId:n,trackingId:i}))}return!1}if("registerPlugins"===s)Qt.registerPlugins(t[0]);else{if(Qt.gioSDKInitialized&&Qt.vdsConfig)return ct.includes(s)?L((()=>Qt.handlerDistribute(i,s,t))):L((()=>Qt[s](...t)));$("SDK未初始化!","error")}}else if(pt.includes(s))$(`方法 ${b(s)} 已被弃用,请移除!`,"warn");else{if("canIUse"===s)return dt.includes(arguments[1])&&!!Qt[arguments[1]];$(`不存在名为 ${b(s)} 的方法调用!`,"error")}};et().gdp=zt,et().gioSDKVersion=Qt.sdkVersion;const{growingApp:Wt,growingPage:Jt,growingComponent:Yt,growingBehavior:Zt,initOriginalValue:Xt}=Qt.dataStore.eventHooks;Xt();const te=L((()=>null!=Wt?Wt:App)),ee=L((()=>null!=Jt?Jt:Page)),ie=L((()=>null!=Yt?Yt:Component)),se=L((()=>null!=Zt?Zt:Behavior));export{te as GioApp,se as GioBehavior,ie as GioComponent,ee as GioPage,zt as default};
1
+ import e from"@system.app";import t from"@system.device";import i from"@system.fetch";import s from"@system.image";import n from"@system.network";import r from"@system.router";import o from"@system.share";import a from"@system.storage";const l=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,g=e=>["undefined","null"].includes(U(e)),u=e=>"string"===U(e),c=e=>"number"===U(e),d=e=>"boolean"===U(e),h=e=>"[object Object]"==={}.toString.call(e)&&!g(e),p=e=>["function","asyncfunction"].includes(U(e)),v=e=>Array.isArray(e)&&"array"===U(e),m=e=>"date"===U(e),f=e=>{try{return Array.from(e)[0]}catch(e){return}},I=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},y=(e,t=1)=>v(e)&&c(t)?e.slice(t>0?t:1,e.length):e,S=(e,t=!1)=>{if(v(e)){let i=0;const s=[];for(const n of e)n&&!N(n)&&(s[i++]=n),t&&0===n&&(s[i++]=n);return s}return e},O=(e,t)=>{if(v(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},w=e=>g(e)?"":""+e,b=(e,t)=>"string"===U(e)?e.split(t):e,P=e=>{if(u(e)){const t=b(e,"");return`${f(t).toLowerCase()}${y(t).join("")}`}return e},k=(e,t)=>(u(e)||(e=w(e)),e.slice(0,t.length)===t),_={}.hasOwnProperty,T=(e,t)=>!g(e)&&_.call(e,t),E=e=>h(e)?Object.keys(e):[],C=(e,t)=>{E(e).forEach((i=>t(e[i],i)))},A=(e,t)=>{const i=E(e);return!(!h(e)||!h(t)||i.length!==E(t).length||i.map(((i,s)=>h(e[i])?A(e[i],t[i]):e[i]===t[i])).includes(!1))},x=(e,t,i)=>{let s=e;return h(e)?(t.split(".").forEach((e=>{s=s?s[e]:i})),s):i},q=(e,t)=>{if(!h(e))return!1;try{if("string"===U(t))return delete e[t];if("array"===U(t))return t.map((t=>delete e[t]));"object"===U(t)&&t.constructor===RegExp&&E(e).forEach((i=>{t.test(i)&&q(e,i)}))}catch(e){return!1}},j=(e,t=250,i,s)=>{let n,r=0;return"boolean"!==U(i)&&(s=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function g(){r=Date.now(),e.apply(a,o)}s&&!n&&g(),n&&clearTimeout(n),void 0===s&&l>t?g():!0!==i&&(n=setTimeout(s?function(){n=void 0}:g,void 0===s?t-l:t))}},N=e=>v(e)?0===e.length:h(e)?0===E(e).length:!e,U=e=>({}.toString.call(e).slice(8,-1).toLowerCase()),D=e=>{function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())};var K=Object.freeze({__proto__:null,isNil:g,isString:u,isNaN:e=>"NaN"===w(Number(e)),isNumber:c,isBoolean:d,isObject:h,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:p,isArray:v,isDate:m,fixed:(e,t)=>c(e)?Number(e.toFixed(c(t)?t:2)):u(e)&&"NaN"!==w(Number(e))?Number(Number(e).toFixed(c(t)?t:2)):e,head:f,last:I,drop:y,dropWhile:(e,t)=>v(e)?e.filter((e=>!t(e))):e,compact:S,find:O,isEqualArray:(e,t)=>!(!v(e)||!v(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:w,split:b,lowerFirst:P,upperFirst:e=>{if(u(e)){const t=b(e,"");return`${f(t).toUpperCase()}${y(t).join("")}`}return e},startsWith:k,endsWith:(e,t)=>{const{length:i}=e;let s=i;s>i&&(s=i);const n=s;return s-=t.length,s>=0&&e.slice(s,n)===t},hasOwnProperty:_,has:T,keys:E,forEach:C,isEqual:A,get:x,unset:q,throttle:j,isEmpty:N,typeOf:U,formatDate:D});const H=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},$=(e,t=!0,i="参数不合法")=>H(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),L=e=>{try{return e()}catch(e){return}},R=(e,t)=>{if(p(e))try{e(t)}catch(e){H("回调执行失败!"+e,"error")}},B=e=>u(e)?e.trim().substring(0,100):e,V=(e,t)=>u(e)&&!N(e)&&e.match(l)?t():(H("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),F=e=>(g(e)||E(e).forEach((t=>{p(e[t])?e[t]=L((()=>e[t]())):h(e[t])?q(e,t):v(e[t])||(e[t]=w(e[t]))})),e),M=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),G=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,Q=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,z=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},W=e=>{if(u(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},J=e=>u(e)?e.startsWith("/")?e:"/"+e:"",Y=e=>L((()=>{switch(e){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let e;return e||(e=L((()=>swan))),e||(e=L((()=>my))),e||(e=L((()=>tt))),e||(e=L((()=>qq))),e||(e=L((()=>ks))),e||(e=L((()=>jd))),e||(e=L((()=>wx))),e}}})),Z=e=>L((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return L((()=>__ttConfig))||(null===global||void 0===global?void 0:global.TMAConfig)||(null===globalThis||void 0===globalThis?void 0:globalThis.TMAConfig);case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),X=()=>{let e;return!e&&L((()=>swan))&&(e="swan"),!e&&L((()=>tt))&&(e="tt"),!e&&L((()=>qq))&&(e="qq"),!e&&L((()=>my.tb))&&(e="tb"),!e&&L((()=>my))&&(e="my"),!e&&L((()=>ks))&&(e="ks"),!e&&L((()=>jd))&&(e="jd"),!e&&L((()=>wx))&&(e="wx"),e||O(E(global),(e=>w(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},ee=()=>{var e;return null!==(e=L((()=>{var e;return null!==(e=L((()=>{var e;return null!==(e=L((()=>$global)))&&void 0!==e?e:global})))&&void 0!==e?e:window})))&&void 0!==e?e:globalThis},te=e=>{const t={};return h(e)&&(q(e,"&&sendTo"),C(e,((e,i)=>{const s=w(i).slice(0,100);h(e)?t[s]=te(e):v(e)?(t[s]=S(e.slice(0,100),!0),t[s]=t[s].join("||").slice(0,1e3)):m(e)?t[s]=D(e):t[s]=g(e)?"":w(e).slice(0,1e3)}))),t},ie=(e,t)=>{const i=()=>t.map((t=>e.getStorageSync(t)));try{return e.minip.canIUse("batchGetStorageSync")?e.minip.batchGetStorageSync(t):i()}catch(e){return i()}},se=(e,t)=>{const i=()=>t.map((({key:t,value:i})=>e.setStorageSync(t,i)));try{return e.minip.canIUse("batchSetStorageSync")?e.minip.batchSetStorageSync(t):i()}catch(e){return i()}},ne=e=>E(e||{}).map((t=>t?`${t}=${g(e[t])?"":e[t]}`:"")).join("&"),re=e=>{(k(e,"?")||k(e,"&"))&&(e=e.slice(1,e.length));const t={};return e.split("&").forEach((e=>{const i=e.split("=");i[0]&&(t[i[0]]=i[1])})),t},oe=(e={},t={})=>{const i={};return E(t).forEach((e=>{["string","number","boolean"].includes(U(t[e]))&&(i[e]=t[e])})),Object.assign({},i,e)};var ae=Object.freeze({__proto__:null,consoleText:H,callError:$,niceTry:L,niceCallback:R,limitString:B,eventNameValidate:V,getDynamicAttributes:F,guid:M,getScreenHeight:G,getScreenWidth:Q,getOS:z,compareVersion:(e="",t="")=>{const i=e=>e.replace(/\s+/g,""),s=e=>e.replace(/[vV]/g,""),n=i(s(e)),r=i(s(t)),o=n.split("."),a=r.split(".");for(let e=0;3>e;e++){let t=Number(o[e]),i=Number(a[e]);if(t>i)return 1;if(i>t)return-1;if(!isNaN(t)&&isNaN(i))return 1;if(isNaN(t)&&!isNaN(i))return-1}return 0},getVueVersion:e=>{if(e){const t=Number(f(b(e.version,".")));return Number.isNaN(t)?0:t}return 0},splitPath:W,normalPath:J,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:Y,getPlainConfig:Z,getPlainPlatform:X,getSubKeys:e=>E(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let e=L((()=>getApp({allowDefault:!0})));return e||(e=ee()),e},getGlobal:ee,limitObject:te,batchGetStorageSync:ie,batchSetStorageSync:se,qsStringify:ne,qsParse:re,hashCode:(e,t=!1)=>{let i=0;if(N(e)||"boolean"==typeof e)return i;let s=0;for(;s<e.length;)i=(i<<5)-i+e.charCodeAt(s),i|=0,s++;return t?Math.abs(i):i},getLaunchQuery:oe});const le=e=>u(e)&&e.length>0||c(e)&&e>0,ge={autotrack:{type:"boolean",default:!0},compress:{type:"boolean",default:!0},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},extraParams:{type:"array",default:[]},followShare:{type:"boolean",default:!0},forceLogin:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},impressionScale:{type:"number",default:0},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},sessionExpires:{type:"number",default:-1},requestTimeout:{type:"number",default:5e3},taro:{type:["object","module"],default:!1},taroVue:{type:["object","function"],default:!1},tbConfig:{type:"object",default:{cloud:void 0,cloudFuncSend:!1,cloudFuncName:"httpTunnel",cloudFuncHandler:"main",cloudAppId:void 0,path:void 0}},trackPage:{type:"boolean",default:!0},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},ue=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],ce=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...ue],de={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},he=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],pe=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],ve=[...pe,"appChannel","language","platformVersion"],me={gsid:"_growing_gsid_",originalSource:"_gdp_original_source_",userId:"_growing_userId_",userKey:"_growing_userKey_",gioId:"_growing_gioId_",plugin_gsid:"_growing_plugin_gsid_",plugin_originalSource:"_gdp_plugin_original_source_",plugin_userId:"_growing_plugin_userId_",plugin_userKey:"_growing_plugin_userKey_",plugin_gioId:"_growing_plugin_gioId_"};var fe="MINIP_LIFECYCLE",Ie="ON_COMMIT_REQUEST",ye="ON_COMPOSE_AFTER",Se="ON_COMPOSE_BEFORE",Oe="ON_ERROR",we="ON_INSTALL",be="ON_SEND_AFTER",Pe="ON_SEND_BEFORE",ke="OPTION_CHANGE",_e="OPTION_INITIALIZED",Te="SDK_INITIALIZED",Ee="SESSIONID_UPDATE";class Ce{constructor(e){this.growingIO=e,this.main=(e,t,i=!0)=>{e||(e=this.growingIO.trackingId);const{sdkVersion:s,platformConfig:n,minipInstance:r,userStore:o,dataStore:a,dataStore:{scene:l,eventHooks:{currentPage:g},generalProps:u}}=this.growingIO,{version:c,dataSourceId:d,appId:h,idMapping:p,ignoreFields:v}=a.getTrackerVds(e),m=a.locationData[e],{systemInfo:f={},network:I={}}=r,{brand:y,model:S,platform:O,language:w}=f,b=g.getPagePath(),P={appChannel:"scn:"+(l||"NA"),appVersion:c,dataSourceId:d,deviceBrand:y,deviceId:o.getUid(),deviceModel:S,deviceType:z(O,n.name),domain:h,language:w,latitude:null==m?void 0:m.latitude,longitude:null==m?void 0:m.longitude,networkState:(null==I?void 0:I.networkType)||(null==I?void 0:I.type)||(null==I?void 0:I.subtype),operatingSystem:z(O,n.name),path:b,platform:n.platform,platformVersion:n.name+(f.version?" "+f.version:""),query:b?g.getPageQuery():"",screenHeight:G(f),screenWidth:Q(f),sdkVersion:s,sessionId:o.getSessionId(e),title:g.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:o.getUserId(e)};return p&&(P.userKey=o.getUserKey(e)),i&&!N(u[e])&&(P.attributes=Object.assign({},u[e])),N(P.attributes)||(P.attributes=te(F(Object.assign({},P.attributes)))),N(v)||v.forEach((e=>{q(P,e)})),N(t)?Object.assign(Object.assign({},P),{trackingId:e}):Object.assign(Object.assign(Object.assign({},P),t),{trackingId:e})}}}function Ae(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{l(s.next(e))}catch(e){r(e)}}function a(e){try{l(s.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class xe{constructor(e){this.growingIO=e,this.enterParams={},this.main=(e,t)=>{var i,s;const n=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:g,dataStore:u,dataStore:{trackersExecute:c,shareOut:d,lastCloseTime:h,saveStorageInfo:p,setOriginalSource:v}}=this.growingIO;r.emit(fe,{event:"App "+e,timestamp:n,params:null!==(i=t[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",e,n);const m=l.listeners.app;switch(r.emit(Se,{event:"App "+e,params:null!==(s=t[0])&&void 0!==s?s:{}}),e){case m.appLaunch:this.enterParams=Object.assign({},t[0]);break;case m.appCreate:case m.appShow:{const{path:e,query:i,referralPage:s}=this.enterParamsParse(t[0]);!d&&a.originalSource&&e&&c((t=>{v(t,{path:e,query:i,referralPage:s})})),h?(Date.now()-h>60*a.keepAlive*1e3||u.lastScene&&u.scene!==u.lastScene)&&c((e=>{o.setSessionId(e)})):c((t=>{u.lastVisitEvent[t]={path:e,query:i,referralPage:s},this.buildVisitEvent(t,{path:e,query:i,referralPage:s})}));break}case m.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),p(),o.saveUserInfo(),c((e=>{this.buildCloseEvent(e),a.forceLogin||g.initiateRequest(e,!0)}))}},this.enterParamsParse=(e={})=>{var t;const{gioPlatform:i,minipInstance:s,dataStore:n}=this.growingIO;let r="",o="",a="";if("quickapp"!==i&&s.minip.canIUse("getEnterOptionsSync")){const{path:i,query:l,scene:g,referrerInfo:u}=s.minip.getEnterOptionsSync()||{};r=i||e.path,o=l||e.query,a=(null==u?void 0:u.appId)||(null===(t=null==e?void 0:e.referrerInfo)||void 0===t?void 0:t.appId)||"",n.scene=g||e.scene,o=N(null==u?void 0:u.extraData)?ne(o):ne(oe(o,u.extraData))}else{const{path:t,query:i,referrerInfo:s}=e;r=t,o=ne(i),a=(null==s?void 0:s.appId)||"",this.parseScene(e)}return{path:r,query:o,referralPage:a}},this.parseScene=e=>{var t;const{minipInstance:i,gioPlatform:s,dataStore:n}=this.growingIO;let r;if("quickapp"===s){const{extra:e,type:t}=i.getAppSource();r=(null==e?void 0:e.scene)||t}else N(e)||((null===(t=null==e?void 0:e.query)||void 0===t?void 0:t.wxShoppingListScene)?r=e.query.wxShoppingListScene:(null==e?void 0:e.scene)?r=e.scene:n.scene="NA");n.scene=r},this.buildVisitEvent=(e,t)=>{const{dataStore:{getOriginalSource:i,eventContextBuilder:s,eventInterceptor:n},vdsConfig:r}=this.growingIO,o=i(e),a=(null==t?void 0:t.query)||"";let l=Object.assign({eventType:"VISIT"},s(e,{}));!N(t)&&t.path&&(l.path=t.path||"",l.query="string"===U(a)?a:ne(a),t.referralPage&&(l.referralPage=t.referralPage)),r.originalSource&&!N(o)&&(l=Object.assign(Object.assign({},l),o)),n(l)},this.buildCloseEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},t(e)))}}}class qe{constructor(e){this.growingIO=e,this.lifeBeforeShow=!0,this.getPagePath=()=>{var e,t,i;const{minipInstance:s,inPlugin:n,dataStore:r,trackingId:o}=this.growingIO,a=s.getCurrentPath();if(n){const e=r.getTrackerVds(o);return a||"/插件"+e.appId}return a||(null===(e=r.eventHooks.appEffects.enterParams)||void 0===e?void 0:e.path)||(null===(t=r.lastPageEvent[o])||void 0===t?void 0:t.path)||(null===(i=r.lastVisitEvent[o])||void 0===i?void 0:i.path)},this.getPageQuery=()=>{var e,t,i,s,n,r;const{minipInstance:o,dataStore:a,trackingId:l}=this.growingIO,g=o.getCurrentPage(),u=o.getCurrentPath(),{enterParams:c={}}=a.eventHooks.appEffects;if(!u)return c.path?this.qsQuery(oe(null==c?void 0:c.query,null===(i=null==c?void 0:c.referrerInfo)||void 0===i?void 0:i.extraData)):(null===(s=a.lastPageEvent[l])||void 0===s?void 0:s.path)?null===(n=a.lastPageEvent[l])||void 0===n?void 0:n.query:null===(r=a.lastVisitEvent[l])||void 0===r?void 0:r.query;{const i=null!==(e=g.options)&&void 0!==e?e:g.$taroParams;if(!N(i))return q(i,"$taroTimestamp"),this.qsQuery(i);if(!N(this.queryOption[u]))return this.qsQuery(this.queryOption[u]);if(u===c.path)return this.qsQuery(oe(null==c?void 0:c.query,null===(t=null==c?void 0:c.referrerInfo)||void 0===t?void 0:t.extraData))}},this.getPageTitle=e=>{const{minipInstance:t,inPlugin:i,dataStore:s}=this.growingIO,n=t.getCurrentPath(),r=this.configuredTitle[n]||t.getPageTitle(t.getCurrentPage());if(i){const t=s.getTrackerVds(e||this.growingIO.trackingId);return r||`/插件${t.appId}${n?"_"+I(n.split("/")):""}`}return r},this.qsQuery=(e={})=>{const t=Object.assign({},e);return q(t,"wxShoppingListScene"),ne(t)},this.getReferralPage=e=>{var t,i,s;const{minipInstance:n,dataStore:{lastPageEvent:r,scene:o,eventHooks:a}}=this.growingIO;return(null===(t=r[e])||void 0===t?void 0:t.path)||(null===(s=null===(i=a.appEffects.enterParams)||void 0===i?void 0:i.referrerInfo)||void 0===s?void 0:s.appId)||(o?`scn:${n.scnPrefix}${o}`:null)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=J(t+(i?"?"+i:"")),e.query=i,e},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=J(t+(i?"?"+i:"")),e.query=i,e},this.eventSetPageProps=(e,t)=>{const i=L((()=>this.pageProps[e][this.getPagePath()]));return N(i)?t.attributes:te(F(Object.assign(Object.assign({},t.attributes),i)))},this.queryOption={},this.configuredTitle={},this.pageProps={}}buildShareQuery(e){var t,i;const s=W(null!==(t=e.path)&&void 0!==t?t:"");let n=this.getPagePath(),r={},o=T(e,"path");if(o&&(n=f(s),r=re(I(s))||{}),N(r)&&(r=re(null!==(i=e.query)&&void 0!==i?i:"")||{},S(E(r)).forEach((e=>{e.toLowerCase().startsWith("utm_")&&q(r,e)}))),!o&&N(r)){const e=this.growingIO.minipInstance.getCurrentPage();r=e.options||this.queryOption[e.route]||{}}return[n,ne(r)]}}class je{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var s,n;const r=Date.now(),{emitter:o,minipInstance:a,plugins:l,vdsConfig:g,platformConfig:u,dataStore:{getTrackerVds:c,getOriginalSource:d,setOriginalSource:h,trackersExecute:v,eventHooks:m,toggleShareOut:f,buildAppMessageEvent:I,buildTimelineEvent:y,buildAddFavorites:S}}=this.growingIO,{currentPage:O}=m;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=a.getCurrentPage()),e.route||(e.route=a.getCurrentPath(e));const w=e.route||e.uri||e.__route__||(null===(s=null==e?void 0:e.$page)||void 0===s?void 0:s.fullPath)||"";o.emit(fe,{event:"Page "+t,timestamp:r,params:{page:e,args:i[0]}}),g.debug&&console.log("Page:",w,"#",t,r),this.prevEvent[t]=Date.now();const b=u.listeners.page;switch(o.emit(Se,{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=t,t){case b.pageLoad:O.queryOption[w]=x(e,"options")||x(e,"__displayReporter.query")||x(e,"$page.query")||x(e,"$wx.__displayReporter.query")||x(e,"$taroParams")||i[0]||{},q(O.queryOption[w],"$taroTimestamp");break;case b.pageShow:v((e=>{const t=d(e);N(t)||t.path!==w||h(e,Object.assign(Object.assign({},t),{title:O.getPageTitle()}));const{trackPage:i}=c(e);i&&this.buildPageEvent(e)})),f(!1);break;case b.pageHide:case b.pageUnload:break;case b.shareApp:f(!0),v((e=>{const{followShare:t}=c(e);t&&I(e,i)}));break;case b.shareTime:v((e=>{const{followShare:t}=c(e);t&&y(e,i)}));break;case b.addFavorites:v((e=>{const{followShare:t}=c(e);t&&S(e,i)}));break;case b.tabTap:{const e=null===(n=null==l?void 0:l.gioEventAutoTracking)||void 0===n?void 0:n.buildTabClickEvent;g.autotrack&&e&&p(e)&&e(this.growingIO.trackingId,i[0]);break}}O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=t+"End",["onHideEnd","onUnloadEnd"].includes(O.currentLifecycle)&&(O.lifeBeforeShow=!0),"onShowEnd"===O.currentLifecycle&&(O.lifeBeforeShow=!1)},this.buildPageEvent=(e,t)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:s,eventHooks:{currentPage:n}}}=this.growingIO,r=Object.assign({eventType:"PAGE",referralPage:n.getReferralPage(e)},i(e));r.attributes=n.eventSetPageProps(e,r),!N(t)&&t.title&&(r.title=t.title),s(r)},this.prevEvent={}}}class Ne{constructor(e){var t;this.growingIO=e,this.isNormalFc=(e,t)=>p(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),T(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),T(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),T(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{v(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{p(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=()=>{})}))},this.lifeFcEffects=(e,t,i)=>{const s=this;return["onShareTimeline","onAddToFavorites"].includes(e)?function(...n){let r=t.apply(this,n);"onShareTimeline"===e&&s.growingIO.vdsConfig.followShare&&(r=s.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=s.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(n);return r&&o.push(r),s[`def${i}Cbs`][e].apply(this,o),r}:function(...n){var r;return Ae(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=t.apply(this,n))&&void 0!==r?r:{},"promise"===U(o)&&(o=yield o.then((e=>e))),"promise"===U(o.promise)){const e=function(){return Ae(this,void 0,void 0,(function*(){let e=o;return new Promise((t=>{let i=setTimeout((()=>{t(Object.assign({},e)),clearTimeout(i),i=void 0}),3e3);o.promise.then((s=>{e=s,t(Object.assign({},e)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield e()),q(o,"promise")}s.growingIO.vdsConfig.followShare&&(o=s.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(n);o&&a.push(o),s[`def${i}Cbs`][e].apply(this,a)}catch(e){H(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,n)),s.growingIO.emitter.emit(fe,{event:`${i} ${e}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(n)}}),o}))}},this.customFcEffects=(e,t)=>{const i=this;return function(...s){var n,r;let o;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let t=s[0]||{};T(t,"type")&&((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))||(t=s[s.length-1]),((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))&&i.actionEventTypes.includes(t.type)&&(p(i.actionEffects)||(i.actionEffects=(null===(r=null===(n=i.growingIO.plugins)||void 0===n?void 0:n.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(t,e))}catch(e){H(e,"error")}return o=t.apply(this,s),o}},this.appApplyProxy=(e,t)=>this.appHandlers.includes(e)?this.lifeFcEffects(e,t,"App"):this.customFcEffects(e,t),this.pageApplyProxy=(e,t)=>this.pageHandlers.includes(e)?this.lifeFcEffects(e,t,"Page"):this.customFcEffects(e,t),this.appOverriding=e=>(this.setAppEffectCbs(),this.supLifeFcs(e,"app"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.appApplyProxy(e,t[e]))})),e),this.pageOverriding=e=>(this.setPageEffectCbs(),this.supLifeFcs(e,"page"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.componentOverriding=e=>(this.setPageEffectCbs(),e.methods||(e.methods={}),this.supLifeFcs(this.growingIO.inPlugin?e:e.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?e:e.methods,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.setAppEffectCbs=()=>{const e=this;this.appHandlers.forEach((t=>{this.defAppCbs[t]=function(...i){e.appEffects.main(t,i)}}))},this.setPageEffectCbs=()=>{const e=this;this.pageHandlers.forEach((t=>{this.defPageCbs[t]=function(...i){e.pageEffects.main(this,t,i)}}))},this.growingApp=e=>p(this.originalApp)?this.originalApp(this.appOverriding(e)):this.appOverriding(e),this.growingPage=e=>p(this.originalPage)?this.originalPage(this.pageOverriding(e)):this.pageOverriding(e),this.growingComponent=e=>p(this.originalComponent)?this.originalComponent(this.componentOverriding(e)):this.componentOverriding(e),this.growingBehavior=e=>p(this.originalBehavior)?this.originalBehavior(this.componentOverriding(e)):this.componentOverriding(e),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,s=i.hooks;if(e.includes("App"))try{s.App&&!this.appHooked&&(App=function(...e){return t.originalApp(t.appOverriding(e[0]))},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{s.Page&&!this.pageHooked&&(Page=function(...e){return t.originalPage(t.pageOverriding(e[0]))},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{s.Component&&!this.componentHooked&&(Component=function(...e){return t.originalComponent(t.componentOverriding(e[0]))},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{s.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.originalBehavior(t.componentOverriding(e[0]))},this.behaviorHooked=!0)}catch(e){}},this.initOriginalValue=()=>{this.setAppEffectCbs(),this.setPageEffectCbs(),this.originalApp=L((()=>App||global.App)),this.originalPage=L((()=>Page||global.Page)),this.originalComponent=L((()=>Component||global.Component)),this.originalBehavior=L((()=>Behavior||global.Behavior))},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;this.initOriginalValue(),t.canHook?(this.nativeGrowing(),ee().GioApp=L((()=>null!==App&&void 0!==App?App:this.originalApp)),ee().GioPage=L((()=>null!==Page&&void 0!==Page?Page:this.originalPage)),ee().GioComponent=L((()=>null!==Component&&void 0!==Component?Component:this.originalComponent)),ee().GioBehavior=L((()=>null!==Behavior&&void 0!==Behavior?Behavior:this.originalBehavior))):"quickapp"===i&&(ee().GioApp=function(...t){return e.appOverriding(t[0])},ee().GioPage=function(...t){return e.pageOverriding(t[0])},ee().GioComponent=function(...t){return e.pageOverriding(t[0])})};const i=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new xe(this.growingIO),this.pageEffects=new je(this.growingIO),this.currentPage=new qe(this.growingIO)}}class Ue{constructor(e){var t,i;this.growingIO=e,this.ALLOW_SETTING_KEYS=E(ge),this.getStorageKey=(e,t)=>{const{inPlugin:i}=this.growingIO;return`${e===this.growingIO.trackingId?"":e}${me[i?"plugin_"+t:t]}`},this.getGsid=e=>{let t=Number(this._gsid[e]);return Number.isNaN(t)||t>=1e9||1>t?(this.setGsid(e,1),1):t},this.setGsid=(e,t)=>{let i=Number(t);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[e]=i,10>this._gsid[e]-this._stid[e]||this.saveStorageInfo()},this.initStorageInfo=e=>{const{minipInstance:t}=this.growingIO,i=t.getStorageSync(this.getStorageKey(e,"gsid"));let s=Number(i);(Number.isNaN(s)||s>=1e9||1>s)&&(s=1),this._gsid[e]=s,this._stid[e]=s,s!==i&&t.setStorageSync(this.getStorageKey(e,"gsid"),s)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=Object.assign({},this._gsid),se(e,this.initializedTrackingIds.map((e=>({key:this.getStorageKey(e,"gsid"),value:this._gsid[e]}))))},this.setOriginalSource=(e,t)=>{const{minipInstance:i}=this.growingIO;i.setStorageSync(this.getStorageKey(e,"originalSource"),JSON.stringify(t))},this.getOriginalSource=e=>{var t;const{minipInstance:i}=this.growingIO;return null!==(t=L((()=>JSON.parse(i.getStorageSync(this.getStorageKey(e,"originalSource"))))))&&void 0!==t?t:{}},this.getTrackerVds=e=>this.growingIO.trackingId===e?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=e=>{const t=this.initOptions(e);return t.trackingId=e.trackingId,this.growingIO.trackingId=e.trackingId,this.growingIO.vdsConfig=t,t},this.initTrackerHooker=e=>{var t,i;const{platformConfig:s,inPlugin:n,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:l}=e;a||l||"quickapp"===r.platform||(s.canHook=!0),!n||["tbp","jdp"].includes(r.platform)?this.eventHooks.initEventHooks():this.eventHooks.initOriginalValue(),a&&(null===(t=null==o?void 0:o.gioUniAppAdapter)||void 0===t||t.main()),l&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=e=>{var t,i,s,n,r,o;const{projectId:a,dataSourceId:l,appId:g,trackingId:u}=e,c={};return this.ALLOW_SETTING_KEYS.forEach((t=>{const i=ge[t].type;(v(i)?i.includes(U(e[t])):U(e[t])===ge[t].type)?"ignoreFields"===t?c.ignoreFields=e.ignoreFields.filter((e=>pe.includes(e))):"extraParams"===t?c.extraParams=e.extraParams.filter((e=>ve.includes(e))):(c[t]=e[t],["dataCollect","autotrack"].includes(t)&&!c[t]&&H("已关闭"+de[t],"info")):c[t]=ge[t].default})),c.uploadInterval=Math.round(c.uploadInterval),(Number.isNaN(c.uploadInterval)||0>c.uploadInterval||c.uploadInterval>3e3)&&(c.uploadInterval=1e3),c.enableIdMapping&&!c.idMapping&&(c.idMapping=!0,c.idMapping||this.growingIO.userStore.setUserKey(u,"")),q(c,"enableIdMapping"),c.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(c.requestTimeout))&&c.requestTimeout>0||(c.requestTimeout=5e3),(0>c.impressionScale||c.impressionScale>1)&&(c.impressionScale=0),(0>c.keepAlive||c.keepAlive>1440)&&(c.keepAlive=5),(1>c.sessionExpires||c.sessionExpires>1440)&&(c.sessionExpires=-1),Object.assign(Object.assign({},c),{projectId:a,dataSourceId:l,appId:g,trackingId:u,performance:{monitor:null===(i=null===(t=c.performance)||void 0===t?void 0:t.monitor)||void 0===i||i,exception:null===(n=null===(s=c.performance)||void 0===s?void 0:s.exception)||void 0===n||n,network:null!==(o=null===(r=c.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(e,t,i)=>{var s;const{userStore:n,emitter:r}=this.growingIO,o=this.getTrackerVds(e),a=u(t)&&this.ALLOW_SETTING_KEYS.includes(t),l=a&&typeof i===(null===(s=ge[t])||void 0===s?void 0:s.type);if(a&&l){const s=Object.assign({},o);return this.updateVdsConfig(e,Object.assign(Object.assign({},o),{[t]:i})),"dataCollect"===t&&s.dataCollect!==i&&i&&n.setSessionId(e),r.emit(ke,{optionName:t,optionValue:i}),!0}return $("setOption > "+t),!1},this.getOption=(e,t)=>{const i=this.getTrackerVds(e);return t&&T(this.growingIO.vdsConfig,t)?T(i,t)?i[t]:this.growingIO.vdsConfig[t]:N(t)?i:void $("getOption > "+t)},this.updateVdsConfig=(e,t)=>{e===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),t),ee().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[e]=Object.assign(Object.assign({},this.growingIO.subInstance[e]),t),ee().vdsConfig.subInstance[e]=this.growingIO.subInstance[e])},this.toggleShareOut=e=>{d(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=(e,t)=>{this.eventHooks.appEffects.buildVisitEvent(e,t)},this.sendPage=(e,t)=>{this.eventHooks.pageEffects.buildPageEvent(e,t)},this.eventConverter=e=>{const{dataStore:t,uploader:i}=this.growingIO,{dataCollect:s}=this.getTrackerVds(e.trackingId);if(s){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=t.getGsid(e.trackingId),t.setGsid(e.trackingId,e.eventSequenceId+1));const s={};C(e,((e,t)=>{var i;if("element"===t){const t=null!==(i=f(e))&&void 0!==i?i:{};C(t,((e,t)=>{N(e)&&0!==e||(s[t]=e)}))}else N(e)&&0!==e||(s[t]=e)})),this.growingIO.emitter.emit(ye,{composedEvent:s}),i.commitRequest(Object.assign(Object.assign({},s),{requestId:M()}))}},this.eventRefactor=e=>{var t,i;const s=Object.assign(Object.assign({},e),this.eventContextBuilder(e.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));return s.attributes=Object.assign(Object.assign({},null!==(t=s.attributes)&&void 0!==t?t:{}),null!==(i=e.attributes)&&void 0!==i?i:{}),s},this.eventInterceptor=e=>{const{systemInfo:t,network:i}=this.growingIO.minipInstance;N(t)||N(i)?this.interceptEvents.push(e):N(this.interceptEvents)?this.eventConverter(e):([...this.interceptEvents,e].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!N(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.buildAppMessageEvent=(e,t)=>{var i,s;const n=t[0];let r;2>t.length?1===t.length&&(r=n):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(e));g.attributes=te(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$from:n.from,$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:f(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildTimelineEvent=(e,t)=>{var i,s;const n=t[0];let r;2>t.length?1===t.length&&(r=n):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(e));g.attributes=te(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:f(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildAddFavorites=(e,t)=>{var i;const s=t[0];let n;2>t.length?1===t.length&&(n=s):n=t[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==n?void 0:n.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(e));l.attributes=te(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$share_title:null==n?void 0:n.title,$share_path:f(a),$share_query:a[1]})),o(l)},this.trackersExecute=e=>{this.initializedTrackingIds.forEach((t=>{"function"===U(e)&&e(t)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new Ce(this.growingIO).main,this.eventHooks=new Ne(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:s,minipInstance:n}=this.growingIO;s.on(Te,(({trackingId:e})=>{this.initializedTrackingIds.push(e),this.initStorageInfo(e)})),s.on(Ie,(({eventData:e,trackingId:t})=>{"VISIT"===e.eventType&&(this.lastVisitEvent[t]=e),"PAGE"===e.eventType&&(this.lastPageEvent[t]=e)})),p(null===(t=n.minip)||void 0===t?void 0:t.onAppHide)&&n.minip.onAppHide((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];C(t,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))}))})),p(null===(i=n.minip)||void 0===i?void 0:i.onAppShow)&&n.minip.onAppShow((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];C(t,(e=>{e.start&&(e.start=+Date.now())}))}))})),s.on(ke,(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.trackersExecute((e=>{this.growingIO.clearTrackTimer(e)}))})),this.growingIO.emitter.on(Ee,(({oldSessionId:e,trackingId:t})=>{if(e){const{getPagePath:e,getPageQuery:i}=this.eventHooks.currentPage,s=e(),n=i();if(s)this.sendVisit(t,{path:s,query:n});else{const e=this.lastPageEvent[t];this.sendVisit(t,{path:e.path,query:e.query})}this.eventHooks.currentPage.lifeBeforeShow||this.sendPage(t)}}))}get scene(){return this._scene}set scene(e){const t=this._scene;this._scene=e,t!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:e,oldScene:t})}}const De={name:"QuickApp",platform:"quickapp",scnPrefix:"quickapp_",appHandlers:["onCreate","onShow","onHide","onDestroy","onError"],pageHandlers:["onInit","onReady","onShow","onHide","onDestroy","onMenuPress","onShareAppMessage"],actionEventTypes:["click","longpress","blur","change"],canHook:!1,hooks:{App:!1,Page:!1,Component:!1,Behavior:!1},listeners:{app:{appCreate:"onCreate",appShow:"onShow",appHide:"onHide",appClose:"onDestroy"},page:{pageLoad:"onInit",pageReady:"onReady",pageShow:"onShow",pageHide:"onHide",pageClose:"onDestroy",menuPress:"onMenuPress",tabTap:void 0,shareApp:"onShareAppMessage"},actions:{click:["click","longpress"],change:["blur","change"],submit:[]}}};class Ke{constructor(e){this.growingIO=e,this.minip=Y("quickapp"),this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBarTitle,i=this;t&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const e=i.getCurrentPath(),{title:t}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.configuredTitle[e]=t}return t.apply(this,arguments)}})},this.navigateTo=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateTo(e)},this.switchTab=e=>{var t;null===(t=this.minip)||void 0===t||t.switchTab(e)},this.navigateToMiniProgram=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateToMiniProgram(e)},this.getImageInfo=({src:e,success:t,fail:i,complete:s})=>{var n;return null===(n=this.minip)||void 0===n?void 0:n.getImageInfo({src:e,success:t,fail:i,complete:s})},this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"observeAll")},this.getCurrentPage=()=>L((()=>I(getCurrentPages())))||{},this.getCurrentPath=()=>{const e=this.getCurrentPage();return(null==e?void 0:e.route)||(null==e?void 0:e.uri)||(null==e?void 0:e.__route__)||""},this.getPageTitle=e=>{var t;const i=X();let s="",n=Z(i);"string"===U(n)&&(n=null!==(t=L((()=>JSON.parse(n))))&&void 0!==t?t:{});const r=(null==e?void 0:e.data)||e.$data||{};if(s=u(null==r?void 0:r.gioPageTitle)?null==r?void 0:r.gioPageTitle:"",n){const{enterParams:t}=this.growingIO.dataStore.eventHooks.appEffects;e.route||N(t)||(e.route=t.path||"",s=this._getTitleFromTabBar(n,e.route)),L((()=>{var t,r,o,a,l,g;if(!s){const u=n.page||{},c=u[e.route]||u[e.route+".html"];s=c?null===(t=null==c?void 0:c.window)||void 0===t?void 0:t.navigationBarTitleText:["wx","tt"].includes(i)?null===(a=null===(o=null===(r=n||global||$global)||void 0===r?void 0:r.global)||void 0===o?void 0:o.window)||void 0===a?void 0:a.navigationBarTitleText:null===(g=null===(l=n||global||$global)||void 0===l?void 0:l.window)||void 0===g?void 0:g.navigationBarTitleText}})),s||(s=this._getTitleFromTabBar(n,e.route))}return B(s)},this._getTitleFromTabBar=(e,t)=>{var i,s;const n=null===(s=null===(i=null==e?void 0:e.tabBar)||void 0===i?void 0:i.list)||void 0===s?void 0:s.find((e=>e.pagePath===t||e.pagePath===t+".html"));return(null==n?void 0:n.text)||""},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return h(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=e=>new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:e,success:({data:e})=>t(e),fail:()=>t("")})})),this.setStorageSync=(e,t,i)=>{var s;i&&(t={value:t,expiredAt:i}),null===(s=this.minip)||void 0===s||s.setStorageSync(e,t)},this.setStorage=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:e,data:t})},this.removeStorageSync=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorageSync(e)},this.removeStorage=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorage(e)},this.getNetworkType=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{e.network=i,t(i)},fail:()=>t(null)})}))},this.request=({url:e,data:t,header:i,timeout:s,method:n,success:r,fail:o,complete:a})=>{var l;const g=null===(l=this.minip)||void 0===l?void 0:l.request({url:e,data:t,header:i,headers:i,timeout:s,method:n,success:r,fail:o,complete:a});let u=setTimeout((()=>{(null==g?void 0:g.abort)&&p(null==g?void 0:g.abort)&&(null==g||g.abort()),clearTimeout(u),u=null}),(s||1e4)+10);return g},this.getSystemInfo=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{e.systemInfo=i,t(i)},fail:()=>t(null)})}))},this.getSetting=()=>new Promise((e=>{var t;null===(t=this.minip)||void 0===t||t.getSetting({success:e,fail:e})}));const{platformConfig:{platform:t,scnPrefix:i}}=this.growingIO;this.platform=t,this.scnPrefix=i,this.growingIO.emitter.on(_e,(()=>{this.getNetworkType().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()}))}))}}class He extends Ke{constructor(l){super(l),this.growingIO=l,this.getAppSource=()=>{const{source:t}=e.getInfo();return this.appSource=t||{},this.appSource},this.navigateTo=()=>{},this.switchTab=()=>{},this.navigateToMiniProgram=()=>{},this.onAppShow=()=>{},this.onAppHide=()=>{},this.getImageInfo=({src:e,success:t,fail:i,complete:n})=>null==s?void 0:s.getImageInfo({uri:e,success:t,fail:i,complete:n}),this.initImpression=()=>{},this.initShareAppMessage=e=>{const{platformConfig:t}=e;try{this.growingIO.shareAppMessage=function(){var i;const s=arguments[0];null==o||o.share(s),null===(i=null==e?void 0:e.eventTracking)||void 0===i||i.pageEffects(this,t.listeners.page.shareApp,arguments)}}catch(e){}},this.getCurrentPage=()=>(null==r?void 0:r.getPages)?I(null==r?void 0:r.getPages()):{},this.getCurrentPath=()=>{const e=null==r?void 0:r.getState();return null==e?void 0:e.path},this.getPageTitle=e=>{var t,i,s,n,o;let a="";try{if(a=u(null==e?void 0:e.gioPageTitle)?null==e?void 0:e.gioPageTitle:"",!a){const r=null!==(o=null===(n=null===(s=null===(i=null===(t=null==e?void 0:e.$app)||void 0===t?void 0:t.$def)||void 0===i?void 0:i.manifast)||void 0===s?void 0:s.display)||void 0===n?void 0:n.pages)&&void 0!==o?o:{},l=null==r?void 0:r[e.route];l&&(a=l.titleBarText)}if(!a){const e=null==r?void 0:r.getState();a=(null==e?void 0:e.name)||""}}catch(e){return""}return B(a)},this.getStorageSync=()=>"",this.getStorage=e=>Ae(this,void 0,void 0,(function*(){return yield new Promise((t=>{null==a||a.get({key:e,success:e=>t(e),fail:()=>t(null)})}))})),this.setStorageSync=()=>{},this.setStorage=(e,t)=>{},this.removeStorageSync=()=>{},this.removeStorage=e=>{null==a||a.delete({key:e})},this.getNetworkType=()=>Ae(this,void 0,void 0,(function*(){const e=this;return yield new Promise((t=>{null==n||n.getType({success:i=>{e.network=i,t(i)},fail:()=>t(null)})}))})),this.request=({url:e,header:t,method:s,data:n,success:r,fail:o,complete:a})=>null==i?void 0:i.fetch({url:e,header:t,method:s,data:n,success:r,fail:o,complete:a}),this.getSystemInfo=()=>Ae(this,void 0,void 0,(function*(){const e=this;return yield new Promise((i=>{null==t||t.getInfo({success:t=>{const s=Object.assign(Object.assign({},t),{version:t.platformVersionName,platform:t.osType});e.systemInfo=s,i(s)},fail:()=>i(null)})}))})),this.growingIO.emitter.on(fe,(({event:e})=>{switch(e){case"App onCreate":this.getNetworkType().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()}));break;case"App onCreateEnd":this.setStorage=(e,t)=>{null==a||a.set({key:e,value:t})}}}))}}const $e=["gioPerformance"];class Le{constructor(e){var t,i,s,n,r,o;this.growingIO=e,this.innerPluginInit=()=>{var e;$e.forEach((e=>{var t;return q(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins,e)})),E(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins).forEach((e=>{var t,i;const{name:s,method:n}=null!==(i=null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins[e])&&void 0!==i?i:{};O(this.pluginItems,(e=>e.name===s))||this.pluginItems.push({name:P(s||e),method:n||(e=>{})})})),N(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var s,n;const{emitter:r}=this.growingIO,o=t||O(this.pluginItems,(t=>t.name===e));if((null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[e])return H(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return H(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return(null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[e]=new o.method(this.growingIO,i),t&&(r.emit(we,e),H("加载插件 "+e,"info")),!0}catch(i){return this.lifeError(t,i),H(`插件【${e}】加载异常 ${i}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>{this.install(t.name,e?t:void 0,e?null==t?void 0:t.options:void 0)&&!O(this.pluginItems,(e=>e.name===t.name))&&this.pluginItems.push({name:P(t.name),method:t.method?t.method:()=>{}})}))},this.uninstall=e=>{var t;q(this.pluginItems,e);const i=q(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||H(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>{this.growingIO.emitter.emit(Oe,{plugin:e,error:t}),H(`插件执行错误 ${e.name} ${t}`,"error")},this.callLifeCycle=(e,t)=>{this.pluginItems.forEach((i=>{const s=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][e]:void 0;if(s&&p(s))try{s(t)}catch(e){this.lifeError(i,e)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(t=this.growingIO.emitter)||void 0===t||t.on(we,(e=>this.callLifeCycle("onInstall",e))),null===(i=this.growingIO.emitter)||void 0===i||i.on(Oe,(e=>this.callLifeCycle("onError",e))),null===(s=this.growingIO.emitter)||void 0===s||s.on(Se,(e=>this.callLifeCycle("onComposeBefore",e))),null===(n=this.growingIO.emitter)||void 0===n||n.on(ye,(e=>this.callLifeCycle("onComposeAfter",e))),null===(r=this.growingIO.emitter)||void 0===r||r.on(Pe,(e=>this.callLifeCycle("onSendBefore",e))),null===(o=this.growingIO.emitter)||void 0===o||o.on(be,(e=>this.callLifeCycle("onSendAfter",e)))}}var Re={},Be={}.hasOwnProperty;function Ve(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function Fe(e){try{return encodeURIComponent(e)}catch(e){return null}}Re.stringify=function(e,t){t=t||"";var i,s,n=[];for(s in"string"!=typeof t&&(t="?"),e)if(Be.call(e,s)){if((i=e[s])||null!=i&&!isNaN(i)||(i=""),s=Fe(s),i=Fe(i),null===s||null===i)continue;n.push(s+"="+i)}return n.length?t+n.join("&"):""},Re.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,s={};t=i.exec(e);){var n=Ve(t[1]),r=Ve(t[2]);null===n||null===r||n in s||(s[n]=r)}return s};class Me{constructor(e){this.growingIO=e,this.generateURL=e=>{const{serverUrl:t,projectId:i}=this.growingIO.dataStore.getTrackerVds(e);return k(t,"http")?`${t}/v3/projects/${i}/collect`:`https://${t}/v3/projects/${i}/collect`},this.getHoardingQueue=e=>{var t;return null!==(t=this.hoardingQueue[e])&&void 0!==t?t:[]},this.getRequestQueue=e=>{var t;return null!==(t=this.requestQueue[e])&&void 0!==t?t:[]},this.commitRequest=e=>{var t,i;const s=Object.assign({},e),{vdsConfig:n,emitter:r}=this.growingIO;r.emit(Ie,{eventData:e,trackingId:e.trackingId}),n.forceLogin?(g(this.hoardingQueue[e.trackingId])&&(this.hoardingQueue[e.trackingId]=[]),null===(t=this.hoardingQueue[e.trackingId])||void 0===t||t.push(s)):(g(this.requestQueue[e.trackingId])&&(this.requestQueue[e.trackingId]=[]),null===(i=this.requestQueue[e.trackingId])||void 0===i||i.push(s),this.initiateRequest(e.trackingId))},this.initiateRequest=(e,t)=>{const{plugins:i,vdsConfig:s,minipInstance:n,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(e),...this.getRequestQueue(e)],a=e=>{var a,l;if(null===(a=null==s?void 0:s.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(l=null==i?void 0:i.gioTaobaoAdapter)||void 0===l||l.singleInvoke(e);else if(t)this.batchInvoke(e);else{const{uploadInterval:t}=this.growingIO.dataStore.getTrackerVds(e);j(this.batchInvoke,t,!1,!1)(e)}o.some((e=>"VISIT"===e.eventType))&&n.removeStorageSync(r.getStorageKey(e,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(e);else{let t=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(e),clearInterval(t),t=void 0)}),500)}},this.batchInvoke=e=>{const{vdsConfig:t,emitter:i}=this.growingIO,s=this.getHoardingQueue(e),n=this.getRequestQueue(e);let r=[...s,...n];r.length>50?(r=r.slice(0,50),s.length>50?this.hoardingQueue[e]=s.slice(50):(this.requestQueue[e]=n.slice(50-s.length),this.hoardingQueue[e]=[])):(this.hoardingQueue[e]=[],this.requestQueue[e]=[]);let o=r.filter((e=>(this.retryIds[e.requestId]||0)<=this.retryLimit));if(N(o))return;const a=o.map((e=>{const t=Object.assign({},e);return q(t,["requestId","trackingId"]),t}));t.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(Pe,{eventsQueue:o,requestData:a,trackingId:e})},this.sendEvent=(e,t)=>{var i;const s=f(e).trackingId,{minipInstance:n,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:g}=r.getTrackerVds(s);this.requestingNum+=1;const u={"content-type":"jdp"===n.platform?"application/json":"application/json;charset=UTF-8"};let c=[...t];const d=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);d&&(c=a.gioCompress.compressToUTF16(JSON.stringify(t)),u["X-Compress-Codec"]="1");const h=this.generateURL(s);n.request({url:`${h}?stm=${Date.now()}&compress=${d?"1":"0"}`,header:u,method:"POST",data:c,timeout:g,fail:t=>{[200,204].includes(t.code)||(e.forEach((e=>{this.requestFailFn(e)})),H("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,o.emit(be,{result:e,requestData:t}),this.initiateRequest(s)}})},this.requestFailFn=e=>{if(this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1,!this.requestQueue[e.trackingId].some((t=>t.requestId===e.requestId))){let t=setTimeout((()=>{N(this.requestQueue[e.trackingId])?(this.requestQueue[e.trackingId].push(e),this.initiateRequest(e.trackingId)):this.requestQueue[e.trackingId].push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:t,vdsConfig:i,plugins:s}=this.growingIO;t.on(Pe,(({eventsQueue:e,requestData:t,trackingId:n})=>{var r,o;n===this.growingIO.trackingId&&((null===(r=null==i?void 0:i.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==s?void 0:s.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(e,t):this.sendEvent(e,t))}))}}class Ge{constructor(e){this.growingIO=e,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:e}=this.growingIO;return this._uid||(this._uid=e.getStorageSync(this._getUidKey())),this._uid||(this._uid=M(),e.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=e=>{const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))},this.getSessionId=e=>{const{vdsConfig:{sessionExpires:t},dataStore:{trackersExecute:i}}=this.growingIO;return this._sessionId[e]||this.setSessionId(e),t>-1&&(Date.now()>this._sessionExpires&&i((e=>{this.setSessionId(e)})),this._sessionExpires=Date.now()+6e4*t),this._sessionId[e]},this.setSessionId=(e,t)=>{const i=this._sessionId[e];t||(t=M()),this._sessionId[e]=t;const{sessionExpires:s}=this.growingIO.vdsConfig;s>-1&&(this._sessionExpires=Date.now()+6e4*s),i!==t&&this.growingIO.emitter.emit(Ee,{trackingId:e,newSessionId:t,oldSessionId:i})},this._getUserIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"userId"),this.getUserId=e=>{const{minipInstance:t}=this.growingIO;return this._userId[e]||(this._userId[e]=t.getStorageSync(this._getUserIdKey(e))),this._userId[e]},this.setUserId=(e,t)=>{const i=this._userId[e];this._userId[e]=g(t)?"":t,i!==this._userId[e]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(e),this._userId[e]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:t,oldUserId:i})),t&&this.setGioId(e,t)},this._getUserKeyKey=e=>this.growingIO.dataStore.getStorageKey(e,"userKey"),this.getUserKey=e=>{const{minipInstance:t}=this.growingIO;return this._userKey[e]||(this._userKey[e]=t.getStorageSync(this._getUserKeyKey(e))),this._userKey[e]},this.setUserKey=(e,t)=>{const i=this._userKey[e];this._userKey[e]=g(t)?"":t,i!==this._userKey[e]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(e),this._userKey[e]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:t,oldUserKey:i}))},this._getGioIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"gioId"),this.getGioId=e=>{const{minipInstance:t}=this.growingIO;return this._gioId[e]||(this._gioId[e]=t.getStorageSync(this._getGioIdKey(e))),this._gioId[e]},this.setGioId=(e,t)=>{const i=this._gioId[e];this._gioId[e]=g(t)?"":t,i!==this._gioId[e]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(e),this._gioId[e]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:t,oldGioId:i}))},this.initUserInfo=e=>{var t;const{minipInstance:i}=this.growingIO,s=[this._getUidKey(),this._getUserIdKey(e),this._getUserKeyKey(e),this._getGioIdKey(e)],n=null!==(t=ie(i,s))&&void 0!==t?t:[];["_uid","_userId","_userKey","_gioId"].forEach(((t,i)=>{"_uid"===t?this.getUid():this[t][e]=n[i]}))},this.saveUserInfo=()=>{const{minipInstance:e,dataStore:{trackersExecute:t}}=this.growingIO;t((t=>{se(e,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(t),value:this._userId[t]},{key:this._getUserKeyKey(t),value:this._userKey[t]},{key:this._getGioIdKey(t),value:this._gioId[t]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={},this._sessionExpires=-1}}const Qe=new class{constructor(){var e;this.init=e=>{var t;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:e});try{if(H("Gio小程序SDK 初始化中...","info"),e.trackingId&&this.dataStore.initializedTrackingIds.includes(e.trackingId))throw Error(`已存在实例 ${e.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(e);return null===(t=this.emitter)||void 0===t||t.emit(_e,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(e.trackingId),this.emitter.emit(Te,i),this.trackingId&&this.trackingId!==e.trackingId||(ee().__gio__=()=>this),H("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&H("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(e){return H(e,"error"),!1}},this.handlerDistribute=(e,t,i)=>{const{initializedTrackingIds:s,getTrackerVds:n}=this.dataStore;if(n(e)&&s.includes(e))return this[t](e,...i);H(`不存在实例:${e},请检查!`,"warn")},this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(e,t)=>this.dataStore.getOption(e,t),this.setOption=(e,t,i)=>{var s;return E(de).includes(t)?typeof i===(null===(s=ge[t])||void 0===s?void 0:s.type)?(this.dataStore.setOption(e,t,i),H(`已修改${de[t]}: ${i}`,"info"),!0):(H(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(H(`不存在可修改的配置项:${t},请检查后重试!`,"error"),!1)},this.setPageAttributes=(e,t)=>{if(h(t)&&!N(t)){const{currentPage:i}=this.dataStore.eventHooks,s=i.getPagePath();return N(i.pageProps[e])&&(i.pageProps[e]={}),N(i.pageProps[e][s])&&(i.pageProps[e][s]={}),N(t)||C(t,((t,n)=>{p(i.pageProps[e][s][n])&&!p(t)||(i.pageProps[e][s][n]=t)})),!0}return $("setPageAttributes"),!1},this.clearPageAttributes=(e,t)=>{try{if(!N(this.dataStore.eventHooks.currentPage.pageProps[e])){const{currentPage:i}=this.dataStore.eventHooks,s=i.getPagePath();v(t)&&!N(t)?t.forEach((t=>{q(i.pageProps[e][s],t)})):i.pageProps[e][s]={}}}catch(e){return $("clearPageAttributes"),!1}},this.sendPage=(e,t)=>{const{trackPage:i}=this.dataStore.getTrackerVds(e);i?H("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(e,t)},this.identify=(e,t)=>{if(e===this.trackingId)if(this.vdsConfig.forceLogin){if(!le(t))return void $("identify");const e=w(t).slice(0,1e3);this.userStore.setUid(e),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((t=>{const i=this.uploader.getHoardingQueue(t);i.forEach(((t,s)=>i[s].deviceId=e)),this.uploader.initiateRequest(t,!0)}))}else $("identify",!1,"forceLogin未开启");else $("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(e,t)=>{var i,s,n,r;if(h(t)&&!N(t)){const{eventContextBuilder:o,eventInterceptor:a,lastVisitEvent:l}=this.dataStore,g=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},o(e));g.attributes=te(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),F(t))),g.path||(g.path=null===(s=l[e])||void 0===s?void 0:s.path,g.query=null===(n=l[e])||void 0===n?void 0:n.query,g.title=null===(r=l[e])||void 0===r?void 0:r.title),a(g)}else $("setUserAttributes")},this.setUserId=(e,t,i)=>{if(le(t)){const s=this.userStore.getGioId(e);t=w(t).slice(0,1e3),i=w(i).slice(0,1e3),this.userStore.setUserId(e,t);const{idMapping:n}=this.dataStore.getTrackerVds(e);n&&this.userStore.setUserKey(e,g(i)?"":i),s&&s!==t&&this.userStore.setSessionId(e)}else $("setUserId")},this.clearUserId=e=>{this.userStore.setUserId(e,void 0),this.userStore.setUserKey(e,void 0)},this.setGeneralProps=(e,t)=>h(t)&&!N(t)?(N(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]={}),C(t,((t,i)=>{p(this.dataStore.generalProps[e][i])&&!p(t)||(this.dataStore.generalProps[e][i]=t)})),!0):($("setGeneralProps"),!1),this.clearGeneralProps=(e,t)=>{try{N(this.dataStore.generalProps[e])||(v(t)&&!N(t)?t.forEach((t=>{q(this.dataStore.generalProps[e],t)})):this.dataStore.generalProps[e]={})}catch(e){return $("clearGeneralProps"),!1}},this.track=(e,t,i)=>{V(t,(()=>{var s;const{eventContextBuilder:n,eventInterceptor:r}=this.dataStore,o=Object.assign({eventType:"CUSTOM",eventName:t},n(e));o.attributes=te(Object.assign(Object.assign({},null!==(s=o.attributes)&&void 0!==s?s:{}),F(Object.assign({},h(i)&&!N(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(o["&&sendTo"]=i["&&sendTo"]),r(o)}))},this.trackTimerStart=(e,t)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(e);return i?V(t,(()=>{const i=M();return this.dataStore.trackTimers[e]||(this.dataStore.trackTimers[e]={}),this.dataStore.trackTimers[e][i]={eventName:t,leng:0,start:+Date.now()},i})):(H("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return e.start&&(e.leng=e.leng+(+Date.now()-e.start)),e.start=0,!0}return!1},this.trackTimerResume=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return 0===e.start&&(e.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t,i)=>{var s;const{dataCollect:n}=this.dataStore.getTrackerVds(e),r=this.dataStore.trackTimers[e];if(t&&r&&r[t]){if(n){const n=864e5,o=r[t];if(0!==o.start){const e=+Date.now()-o.start;o.leng=e>0?o.leng+e:0}const{eventContextBuilder:a,eventInterceptor:l}=this.dataStore,g=Object.assign({eventType:"CUSTOM",eventName:o.eventName},a(e));return g.attributes=te(Object.assign(Object.assign({},null!==(s=g.attributes)&&void 0!==s?s:{}),F(Object.assign(Object.assign({},h(i)&&!N(i)?i:{}),{event_duration:o.leng>n?0:o.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(g["&&sendTo"]=i["&&sendTo"]),l(g),!0}return H("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return H("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(e,t)=>{const i=this.dataStore.trackTimers[e];return t&&i&&i[t]?(delete i[t],!0):(H("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=e=>{this.dataStore.trackTimers[e]={}},this.setLocation=(e,t,i)=>{N(this.dataStore.locationData[e])&&(this.dataStore.locationData[e]={});const s=this.dataStore.locationData[e],n=e=>e>=-180&&180>=e;n(t)&&n(i)&&(s.latitude!==t||s.longitude!==i)&&(this.dataStore.locationData[e]={latitude:t,longitude:i})},this.updateImpression=()=>{H("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(e,t,i)=>{H("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),R(i,{})},this.getGioInfo=e=>{const{getUid:t,getUserId:i,getUserKey:s,getSessionId:n}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:l,idMapping:g,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(e),d={gioappid:o,giocs1:i(e)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:n(e),giou:t()};return d.giodatacollect=l,d.giodatasourceid=a,g&&(d.giouserkey=s(e)),N(u)||u.forEach((t=>{var i;c.includes(t)||(d["gio"+t]=(null!==(i=this.dataStore.lastVisitEvent[e])&&void 0!==i?i:{})[t])})),Re.stringify(d)},this.utils=Object.assign(Object.assign(Object.assign({},K),ae),{qs:Re}),this.emitter={all:e=e||new Map,on:function(t,i){var s=e.get(t);s?s.push(i):e.set(t,[i])},off:function(t,i){var s=e.get(t);s&&(i?s.splice(s.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var s=e.get(t);s&&s.slice().map((function(e){e(i)})),(s=e.get("*"))&&s.slice().map((function(e){e(t,i)}))}},this.gioPlatform="quickapp",this.gioFramework="native",this.sdkVersion="4.3.1";try{"quickapp"===this.gioPlatform||p(getApp)&&p(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&H("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=De,this.minipInstance=new He(this),this.dataStore=new Ue(this),this.userStore=new Ge(this),this.uploader=new Me(this),this.plugins=new Le(this),this.plugins.innerPluginInit()}},ze=function(){var e;const t=arguments[0];let i="g0",s=t;if(t.indexOf(".")>-1&&(i=null!==(e=t.split(".")[0])&&void 0!==e?e:"g0",s=t.split(".")[1]),u(s)&&ce.includes(s)&&Qe[s]){const e=y(Array.from(arguments));if("init"===s){const t=((e,t)=>{const i=w(t[0]),s=w(t[1]),n=(4===t.length?t[3]:t[2])||{};return i&&s?e.dataStore.initializedTrackingIds.some(((t,n)=>{const r=0===n?e.vdsConfig:e.subInstance[t];return r.projectId===i&&r.dataSourceId===s}))?(H("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:s,appId:w(4===t.length?t[2]:""),userOptions:n}:(H('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})(Qe,e);if(t){const{projectId:e,dataSourceId:s,appId:n,userOptions:r}=t;return Qe.init(Object.assign(Object.assign({},r),{projectId:e,dataSourceId:s,appId:n,trackingId:i}))}return!1}if("registerPlugins"===s)Qe.registerPlugins(e[0]);else{if(Qe.gioSDKInitialized&&Qe.vdsConfig)return ue.includes(s)?L((()=>Qe.handlerDistribute(i,s,e))):L((()=>Qe[s](...e)));H("SDK未初始化!","error")}}else if(he.includes(s))H(`方法 ${w(s)} 已被弃用,请移除!`,"warn");else{if("canIUse"===s)return ce.includes(arguments[1])&&!!Qe[arguments[1]];H(`不存在名为 ${w(s)} 的方法调用!`,"error")}};ee().gdp=ze,ee().gioSDKVersion=Qe.sdkVersion;const{growingApp:We,growingPage:Je,growingComponent:Ye,growingBehavior:Ze,initOriginalValue:Xe}=Qe.dataStore.eventHooks;Xe();const et=L((()=>null!=We?We:App)),it=L((()=>null!=Je?Je:Page)),st=L((()=>null!=Ye?Ye:Component)),nt=L((()=>null!=Ze?Ze:Behavior));export{et as GioApp,nt as GioBehavior,st as GioComponent,it as GioPage,ze as default};