gio-miniprogram-sdk 4.0.0 → 4.0.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/alipay.js +1 -1
- package/dist/baidu.js +1 -1
- package/dist/bytedance.js +1 -1
- package/dist/jingdong.js +1 -1
- package/dist/kuaishou.js +1 -1
- package/dist/plugins/gioImpressionTracking.js +1 -1
- package/dist/qq.js +1 -1
- package/dist/quickapp.js +1 -1
- package/dist/taobao.js +1 -1
- package/dist/taro.js +1 -1
- package/dist/uniapp.js +1 -1
- package/dist/wechat.js +1 -1
- package/package.json +1 -1
- package/src/constants/config.ts +2 -2
- package/src/constants/regex.ts +15 -0
- package/src/core/dataStore/index.ts +8 -1
- package/src/core/growingIO.ts +1 -2
- package/src/core/uploader.ts +2 -7
- package/src/pluginsOut/frameworks/gioTaobaoAdapter.ts +0 -1
- package/src/pluginsOut/frameworks/gioTaroAdapter.ts +291 -190
- package/src/pluginsOut/ordinary/gioImpressionTracking.ts +56 -21
- package/src/types/base.ts +2 -0
- package/src/types/eventHooks.ts +3 -3
- package/src/types/uploader.ts +0 -2
- package/src/pluginsOut/README.md +0 -50
package/dist/quickapp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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=e=>["undefined","null"].includes(x(e)),u=e=>"string"===x(e),g=e=>"number"===x(e),h=e=>"boolean"===x(e),c=e=>"[object Object]"==={}.toString.call(e)&&!l(e),d=e=>["function","asyncfunction"].includes(x(e)),p=e=>Array.isArray(e)&&"array"===x(e),v=e=>{try{return Array.from(e)[0]}catch(e){return}},m=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},f=(e,t=1)=>p(e)&&g(t)?e.slice(t>0?t:1,e.length):e,I=e=>{if(p(e)){let t=0;const i=[];for(const s of e)s&&!N(s)&&(i[t++]=s);return i}return e},S=(e,t)=>{if(p(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},y=e=>l(e)?"":""+e,w=(e,t)=>"string"===x(e)?e.split(t):e,O=e=>{if(u(e)){const t=w(e,"");return`${v(t).toLowerCase()}${f(t).join("")}`}return e},b=(e,t)=>e.slice(0,t.length)===t,P={}.hasOwnProperty,C=(e,t)=>!l(e)&&P.call(e,t),T=e=>c(e)?Object.keys(e):[],_=(e,t)=>{T(e).forEach((i=>t(e[i],i)))},k=(e,t)=>{const i=T(e);return!(!c(e)||!c(t)||i.length!==T(t).length||i.map(((i,s)=>c(e[i])?k(e[i],t[i]):e[i]===t[i])).includes(!1))},E=(e,t,i)=>{let s=e;return c(e)?(t.split(".").forEach((e=>{s=s?s[e]:i})),s):i},A=(e,t)=>{if(!c(e))return!1;try{if("string"===x(t))return delete e[t];if("array"===x(t))return t.map((t=>delete e[t]));"object"===x(t)&&t.constructor===RegExp&&T(e).forEach((i=>{t.test(i)&&A(e,i)}))}catch(e){return!1}},q=(e,t=250,i,s)=>{let n,r=0;return"boolean"!==x(i)&&(s=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function u(){r=Date.now(),e.apply(a,o)}s&&!n&&u(),n&&clearTimeout(n),void 0===s&&l>t?u():!0!==i&&(n=setTimeout(s?function(){n=void 0}:u,void 0===s?t-l:t))}},N=e=>p(e)?0===e.length:c(e)?0===T(e).length:!e,x=e=>({}.toString.call(e).slice(8,-1).toLowerCase());var j=Object.freeze({__proto__:null,isNil:l,isString:u,isNaN:e=>"NaN"===y(Number(e)),isNumber:g,isBoolean:h,isObject:c,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:d,isArray:p,isDate:e=>"date"===x(e),fixed:(e,t)=>g(e)?Number(e.toFixed(g(t)?t:2)):u(e)&&"NaN"!==y(Number(e))?Number(Number(e).toFixed(g(t)?t:2)):e,head:v,last:m,drop:f,dropWhile:(e,t)=>p(e)?e.filter((e=>!t(e))):e,compact:I,find:S,isEqualArray:(e,t)=>!(!p(e)||!p(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:y,split:w,lowerFirst:O,upperFirst:e=>{if(u(e)){const t=w(e,"");return`${v(t).toUpperCase()}${f(t).join("")}`}return e},startsWith:b,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:P,has:C,keys:T,forEach:_,isEqual:k,get:E,unset:A,throttle:q,isEmpty:N,typeOf:x,formatDate: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())}});const D=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},$=(e,t=!0,i="参数不合法")=>D(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),H=e=>{try{return e()}catch(e){return}},U=e=>u(e)?e.trim().substring(0,100):e,L=(e,t)=>u(e)&&!N(e)&&e.match(/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/)?t():(D("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),B=()=>"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)})),F=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,R=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,K=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},M=e=>{if(u(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},G=e=>u(e)?e.startsWith("/")?e:"/"+e:"",V=e=>H((()=>{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=H((()=>swan))),e||(e=H((()=>my))),e||(e=H((()=>tt))),e||(e=H((()=>qq))),e||(e=H((()=>ks))),e||(e=H((()=>jd))),e||(e=H((()=>wx))),e}}})),Q=e=>H((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return __ttConfig;case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),W=()=>{let e;return!e&&H((()=>swan))&&(e="swan"),!e&&H((()=>tt))&&(e="tt"),!e&&H((()=>qq))&&(e="qq"),!e&&H((()=>my.tb))&&(e="tb"),!e&&H((()=>my))&&(e="my"),!e&&H((()=>ks))&&(e="ks"),!e&&H((()=>jd))&&(e="jd"),!e&&H((()=>wx))&&(e="wx"),e||S(T(global),(e=>y(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},z=e=>T(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),J=()=>{let e=H((()=>getApp({allowDefault:!0})));return e||(e=Y()),e},Y=()=>{var e;return null!==(e=H((()=>$global)))&&void 0!==e?e:global},Z=e=>{const t={};return c(e)&&_(e,((e,i)=>{const s=y(i).slice(0,100);c(e)?t[s]=Z(e):p(e)?(t[s]=e.slice(0,100),t[s]=t[s].join("||").slice(0,1e3)):t[s]=l(e)?"":y(e).slice(0,1e3)})),t},X=(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()}},ee=(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()}},te=e=>T(e||{}).map((t=>t?`${t}=${l(e[t])?"":e[t]}`:"")).join("&"),ie=e=>{(b(e,"?")||b(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};var se=Object.freeze({__proto__:null,consoleText:D,callError:$,niceTry:H,niceCallback:(e,t)=>{if(d(e))try{e(t)}catch(e){D("回调执行失败!"+e,"error")}},limitString:U,eventNameValidate:L,guid:B,getScreenHeight:F,getScreenWidth:R,getOS:K,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.parseInt(v(w(e.version,".")),10);return Number.isNaN(t)?0:t}return 0},splitPath:M,normalPath:G,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:V,getPlainConfig:Q,getPlainPlatform:W,getSubKeys:z,getAppInst:J,getGlobal:Y,limitObject:Z,batchGetStorageSync:X,batchSetStorageSync:ee,qsStringify:te,qsParse:ie,hashCode:e=>{let t=0;if(N(e)||"boolean"==typeof e)return t;let i=0;for(;i<e.length;)t=(t<<5)-t+e.charCodeAt(i),t&=t,i++;return t}});const ne=e=>u(e)&&e.length>0||g(e)&&e>0,re={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"},subpackage:{type:"boolean",default:!1},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}},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},oe=["clearGeneralProps","clearTrackTimer","clearUserId","getDeviceId","getGioInfo","getOption","identify","init","registerPlugins","removeTimer","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart","updateImpression","getABTest"],ae={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},le=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],ue=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],ge=[...ue,"appChannel","language","platformVersion"];class he{constructor(e){this.growingIO=e,this.main=e=>{var t,i,s,n,r;const{sdkVersion:o,vdsConfig:a,platformConfig:l,minipInstance:u,userStore:g,dataStore:{scene:h,eventHooks:c,locationData:d,lastVisitEvent:p}}=this.growingIO,{systemInfo:v={},network:m={}}=u,{brand:f,model:I,platform:S,language:y,version:w}=v,O={appChannel:"scn:"+(h||"NA"),appVersion:a.version,dataSourceId:a.dataSourceId,deviceBrand:f,deviceId:g.uid,deviceModel:I,deviceType:K(S,l.name),domain:a.appId,language:y,latitude:null==d?void 0:d.latitude,longitude:null==d?void 0:d.longitude,networkState:(null==m?void 0:m.networkType)||(null==m?void 0:m.type)||(null==m?void 0:m.subtype),operatingSystem:K(S,l.name),path:(null===(t=c.currentPage)||void 0===t?void 0:t.path)?null===(i=c.currentPage)||void 0===i?void 0:i.path:p.path,platform:l.platform,platformVersion:l.name+(w?" "+w:""),query:(null===(s=c.currentPage)||void 0===s?void 0:s.path)?null===(n=c.currentPage)||void 0===n?void 0:n.query:p.query,screenHeight:F(v),screenWidth:R(v),sdkVersion:o,sessionId:g.sessionId,title:(null===(r=c.currentPage)||void 0===r?void 0:r.title)||u.getPageTitle(u.getCurrentPage()),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:g.userId};return a.idMapping&&(O.userKey=g.userKey),N(a.ignoreFields)||a.ignoreFields.forEach((e=>{A(O,e)})),N(e)?O:Object.assign(Object.assign({},O),e)}}}function ce(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())}))}class de{constructor(e){this.growingIO=e,this.main=(e,t)=>{var i,s;const n=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:u,dataStore:g,dataStore:{shareOut:h,keepAlive:c,lastCloseTime:d,eventHooks:p,saveStorageInfo:v}}=this.growingIO;r.emit("minipLifecycle",{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("onComposeBefore",{event:"App "+e,params:null!==(s=t[0])&&void 0!==s?s:{}}),e){case m.appCreate:case m.appShow:{const{path:e,query:i}=this.enterParamsParse(t[0]);!h&&a.originalSource&&g.setOriginalSource({path:e,query:i}),d?(Date.now()-d>c||g.lastScene&&g.scene!==g.lastScene)&&(o.sessionId="",p.currentPage.time=void 0,this.buildVisitEvent({path:e,query:i})):(this.growingIO.dataStore.lastVisitEvent={path:e,query:i},this.buildVisitEvent({path:e,query:i}));break}case m.appClose:g.lastScene=g.scene,g.lastCloseTime=Date.now(),v(),o.saveUserInfo(),this.buildCloseEvent(),a.forceLogin||u.initiateRequest(!0)}},this.enterParamsParse=e=>{const{gioPlatform:t,minipInstance:i,dataStore:s}=this.growingIO;let n="",r="";const o=(e,t={})=>{n=e,r=T(t).map((e=>`${e}=${t[e]}`)).join("&")};if("quickapp"!==t&&i.minip.canIUse("getEnterOptionsSync")){const{path:t,query:n,scene:a,referrerInfo:l}=i.minip.getEnterOptionsSync()||{},u=e.query||n;if(o(e.path||t,u),s.scene=e.scene||a,!N(l)&&c(null==l?void 0:l.extraData)){let e=[];_(l.extraData,((t,i)=>{!C(u,i)&&["string","number","boolean"].includes(x(t))&&e.push(`${i}=${t}`)}));const t=e.join("&");r=r&&t?`${r}&${t}`:r||t}}else{const{path:t,query:i}=e;o(t,i),this.parseScene(e)}return{path:n,query:r}},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=>{const{dataStore:t,vdsConfig:i,minipInstance:s}=this.growingIO,{originalSourceName:n,getOriginalSource:r,eventContextBuilder:o,eventInterceptor:a}=t,u=r(),g=(null==e?void 0:e.query)||"";let h=Object.assign({eventType:"VISIT"},o({path:(null==e?void 0:e.path)||"",query:"string"===x(g)?g:te(g)}));i.originalSource&&!l(u)&&(h=Object.assign(Object.assign({},h),u),i.dataCollect&&s.removeStorageSync(n)),a(h)},this.buildCloseEvent=()=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:t}}=this.growingIO;t(Object.assign({eventType:"APP_CLOSED"},e()))}}}class pe{constructor(e){this.growingIO=e,this.parsePage=(e,t)=>{var i;const s=e.route||e.uri||e.__route__||(null===(i=null==e?void 0:e.$page)||void 0===i?void 0:i.fullPath)||"";N(t)?this.query=void 0:this.query=this.getQuery(t),this.path!==s&&(this.time=Date.now()),this.path=s,this.title=this.settedTitle[this.path]||this.growingIO.minipInstance.getPageTitle(e||this.growingIO.minipInstance.getCurrentPage())},this.getQuery=e=>{const t=Object.assign({},e);return A(t,"wxShoppingListScene"),te(t)},this.getReferralPage=()=>{const{minipInstance:e,dataStore:{lastPageEvent:t,scene:i}}=this.growingIO;return(null==t?void 0:t.path)||(i?`scn:${e.scnPrefix}${i}`:null)},this.saveShareId=e=>{(null==e?void 0:e.gioShareId)&&(this.queryShareId=e.gioShareId)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=G(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=G(t+(i?"?"+i:"")),e.query=i,e},this.query=void 0,this.settedTitle={},this.pageProps={}}buildShareQuery(e){var t,i,s;const n=M(null!==(t=e.path)&&void 0!==t?t:"");let r=this.path,o={},a=C(e,"path");return a&&(r=v(n),o=ie(m(n))||{}),N(o)&&(o=ie(null!==(i=e.query)&&void 0!==i?i:"")||{}),!a&&N(o)&&(o=ie(null!==(s=this.query)&&void 0!==s?s:"")||{}),[r,te(o)]}}class ve{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var s,n;const r=Date.now(),{emitter:o,minipInstance:a,plugins:l,vdsConfig:u,platformConfig:g,dataStore:{shareOut:h,eventHooks:c,toggleShareOut:p,buildAppMessageEvent:v,buildTimelineEvent:m,buildAddFavorites:f},inPlugin:I}=this.growingIO,{currentPage:S}=c;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=a.getCurrentPage()),e.route||(e.route=a.getCurrentPath(e));const y=e.route||e.uri||e.__route__||(null===(s=null==e?void 0:e.$page)||void 0===s?void 0:s.fullPath)||"";o.emit("minipLifecycle",{event:"Page "+t,timestamp:r,params:{page:e,args:i[0]}}),u.debug&&console.log("Page:",y,"#",t,r),this.prevEvent[t]=Date.now();const w=g.listeners.page;switch(o.emit("onComposeBefore",{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),S.lastLifecycle=S.currentLifecycle,S.currentLifecycle=t,t){case w.pageLoad:this.argQuery[y]=E(e,"options")||E(e,"__displayReporter.query")||E(e,"$page.query")||E(e,"$wx.__displayReporter.query")||i[0]||{},A(this.argQuery[y],"$taroTimestamp"),S.parsePage(e,this.argQuery[y]);break;case w.pageShow:I?(S.parsePage(e,this.argQuery[y]),S.path||(S.path=`/插件${u.appId}}`,S.title=`/插件${u.appId}}`),this.buildPageEvent()):h&&c.currentPage.time||(S.parsePage(e,this.argQuery[y]),c.currentPage.time=Date.now(),this.buildPageEvent()),p(!1),S.saveShareId(this.argQuery[y]);break;case w.pageHide:case w.pageUnload:break;case w.shareApp:p(!0),u.followShare&&v(i);break;case w.shareTime:u.followShare&&m(i);break;case w.addFavorites:f(i);break;case w.tabTap:{const e=null===(n=null==l?void 0:l.gioEventAutoTracking)||void 0===n?void 0:n.buildTabClickEvent;u.autotrack&&e&&d(e)&&e(i[0]);break}}t===w.pageUnload&&(S.pageProps[y]=void 0)},this.buildPageEvent=e=>{var t;const{dataStore:{eventContextBuilder:i,eventInterceptor:s,eventHooks:n}}=this.growingIO,{currentPage:r}=n,o=Object.assign(Object.assign({eventType:"PAGE",referralPage:r.getReferralPage()},i()),{timestamp:r.time});N(r.pageProps[o.path])||(o.attributes=r.pageProps[o.path]),!N(e)&&e.path&&(o.path=e.path,o.query=e.query,o.title=null!==(t=e.title)&&void 0!==t?t:o.title),s(o)},this.prevEvent={},this.argQuery={}}}class me{constructor(e){var t,i;this.growingIO=e,this.isNormalFc=(e,t)=>d(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),C(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),C(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),C(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{p(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{d(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 ce(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=yield t.apply(this,n))&&void 0!==r?r:{},"promise"===x(o.promise)){const e=function(){return ce(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()),A(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){D(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,n)),s.growingIO.emitter.emit("minipLifecycle",{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]||{};C(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)&&(d(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){D(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=>this.originalApp(this.appOverriding(e)),this.growingPage=e=>this.originalPage(this.pageOverriding(e)),this.growingComponent=e=>this.originalComponent(this.componentOverriding(e)),this.growingBehavior=e=>this.originalBehavior(this.componentOverriding(e)),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,s=i.hooks;if(this.setAppEffectCbs(),this.setPageEffectCbs(),e.includes("App"))try{s.App&&!this.appHooked&&(App=function(...e){return t.growingApp(e[0])},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{s.Page&&!this.pageHooked&&(Page=function(...e){return t.growingPage(e[0])},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{s.Component&&!this.componentHooked&&(Component=function(...e){return t.growingComponent(e[0])},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{s.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.growingBehavior(e[0])},this.behaviorHooked=!0)}catch(e){}},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;t.canHook?(this.nativeGrowing(),Y().GioApp=H((()=>null!==App&&void 0!==App?App:window.GioApp)),Y().GioPage=H((()=>null!==Page&&void 0!==Page?Page:window.GioPage)),Y().GioComponent=H((()=>null!==Component&&void 0!==Component?Component:window.GioComponent)),Y().GioBehavior=H((()=>Behavior))):"quickapp"===i&&(window.GioApp=function(...t){return e.appOverriding(t[0])},window.GioPage=function(...t){return e.pageOverriding(t[0])},window.GioComponent=function(...t){return e.pageOverriding(t[0])})};const s=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=s.appHandlers,this.pageHandlers=s.pageHandlers,this.actionEventTypes=s.actionEventTypes,this.originalApp=s.originalApp,this.originalPage=s.originalPage,this.originalComponent=s.originalComponent,this.originalBehavior=null!==(i=s.originalBehavior)&&void 0!==i?i:function(){},this.appEffects=new de(this.growingIO),this.pageEffects=new ve(this.growingIO),this.currentPage=new pe(this.growingIO)}}class fe{constructor(e){var t,i;this.growingIO=e,this.ALLOW_SETTING_KEYS=T(re),this.gsidStorageName="_growing_gsid_",this.originalSourceName="gdp_original_source",this.initStorageInfo=()=>{const{minipInstance:e}=this.growingIO,t=J(),i=t.gio_gsid?t.gio_gsid:Number.parseInt(e.getStorageSync(this.gsidStorageName),10);this._gsid=Number.isNaN(i)||i>=1e9||1>i?1:i,this._stid=this._gsid,i!==this._gsid&&e.setStorageSync(this.gsidStorageName,this._gsid)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=this._gsid,ee(e,[{key:this.gsidStorageName,value:this._gsid}])},this.setOriginalSource=({path:e,query:t})=>{const{minipInstance:i}=this.growingIO;if(l(this.getOriginalSource())){const s={path:e,query:t,title:""};i.setStorageSync(this.originalSourceName,JSON.stringify(s))}},this.getOriginalSource=()=>{const{minipInstance:e}=this.growingIO;return H((()=>JSON.parse(e.getStorageSync(this.originalSourceName))))},this.initOptions=e=>{var t,i,s,n,r,o,a,l;const{projectId:u,dataSourceId:g,appId:h}=e,c={};this.ALLOW_SETTING_KEYS.forEach((t=>{const i=re[t].type;(p(i)?i.includes(x(e[t])):x(e[t])===re[t].type)?"ignoreFields"===t?c.ignoreFields=e.ignoreFields.filter((e=>ue.includes(e))):"extraParams"===t?c.extraParams=e.extraParams.filter((e=>ge.includes(e))):c[t]=e[t]:c[t]=re[t].default})),c.uploadInterval=Math.round(c.uploadInterval),(Number.isNaN(c.uploadInterval)||0>c.uploadInterval||c.uploadInterval>2e3)&&(c.uploadInterval=1e3),c.enableIdMapping&&!c.idMapping&&(c.idMapping=!0),c.pluginMode&&(this.growingIO.inPlugin=!0),this.growingIO.vdsConfig=Object.assign(Object.assign({},c),{projectId:u,dataSourceId:g,appId:h,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.keepAlive=c.keepAlive,c.dataCollect||D("已关闭数据采集","info"),c.autotrack||D("已关闭无埋点","info");const{plugins:d,inPlugin:v,minipInstance:m}=this.growingIO,{uniVue:f,taro:I}=c;f||I||(this.growingIO.platformConfig.canHook=!0),v&&!["tbp","jdp"].includes(m.platform)||this.eventHooks.initEventHooks(),f&&(null===(a=null==d?void 0:d.gioUniAppAdapter)||void 0===a||a.main()),I&&(null===(l=null==d?void 0:d.gioTaroAdapter)||void 0===l||l.main())},this.setOption=(e,t)=>{var i;const{vdsConfig:s,userStore:n,uploader:r,emitter:o}=this.growingIO,a=u(e)&&this.ALLOW_SETTING_KEYS.includes(e),l=a&&typeof t===(null===(i=re[e])||void 0===i?void 0:i.type);if(a&&l){if("dataCollect"===e&&!1===s.dataCollect&&!0===t){let e=setTimeout((()=>{n.sessionId="";const{path:t,query:i,settedTitle:s}=this.eventHooks.currentPage;this.eventHooks.currentPage.title=s[t]||this.growingIO.minipInstance.getPageTitle(this.growingIO.minipInstance.getCurrentPage()),this.sendVisit({path:t,query:i}),this.eventHooks.currentPage.time=Date.now(),this.sendPage({path:t,query:i}),clearTimeout(e),e=null}),0)}return s[e]=t,"serverUrl"===e&&(null==r||r.generateURL()),o.emit("OPTION_CHANGE",{optionName:e,optionValue:t}),!0}return $("setOption > "+e),!1},this.getOption=e=>{const{vdsConfig:t}=this.growingIO;return e&&C(t,y(e))?t[y(e)]:l(e)?Object.assign({},t):void $("getOption > "+e)},this.toggleShareOut=e=>{h(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=e=>{this.eventHooks.appEffects.buildVisitEvent(null!=e?e:this.lastVisitEvent),this.eventHooks.currentPage.time=Date.now()},this.sendPage=e=>{this.eventHooks.pageEffects.buildPageEvent(e)},this.eventConverter=e=>{const{vdsConfig:t,dataStore:i,uploader:s}=this.growingIO;if(t.dataCollect){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=i.gsid,this.growingIO.dataStore.gsid+=1);const t={};_(e,((e,i)=>{var s;if("element"===i){const i=null!==(s=v(e))&&void 0!==s?s:{};_(i,((e,i)=>{N(e)&&0!==e||(t[i]=e)}))}else N(e)&&0!==e||(t[i]=e)})),this.growingIO.emitter.emit("onComposeAfter",{composedEvent:t}),s.commitRequest(Object.assign(Object.assign({},t),{requestId:B()}))}},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=>{const t=Object.assign(Object.assign({},e),this.eventContextBuilder({path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(t)})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!N(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{const t=Object.assign(Object.assign({},e),this.eventContextBuilder({path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(t)})),this.interceptEvents=[])},this.buildAppMessageEvent=e=>{var t;const i=e[0];let s;2>e.length?1===e.length&&(s=i):s=e[1];const{dataStore:{eventContextBuilder:n,eventInterceptor:r}}=this.growingIO,o=((null==s?void 0:s.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share",attributes:Object.assign({$from:i.from,$target:null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.id,$share_title:null==s?void 0:s.title,$share_path:v(o),$share_query:o[1]},null==s?void 0:s.attributes)},n()))},this.buildTimelineEvent=e=>{var t;const i=e[0];let s;2>e.length?1===e.length&&(s=i):s=e[1];const{dataStore:{eventContextBuilder:n,eventInterceptor:r}}=this.growingIO,o=((null==s?void 0:s.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline",attributes:Object.assign({$target:null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.id,$share_title:null==s?void 0:s.title,$share_path:v(o),$share_query:o[1]},null==s?void 0:s.attributes)},n()))},this.buildAddFavorites=e=>{const t=e[0];let i;2>e.length?1===e.length&&(i=t):i=e[1];const{dataStore:{eventContextBuilder:s,eventInterceptor:n}}=this.growingIO,r=((null==i?void 0:i.path)||"").split("?");n(Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites",attributes:{$share_title:null==i?void 0:i.title,$share_path:v(r),$share_query:r[1]}},s()))},this.initStorageInfo(),this.eventContextBuilder=new he(this.growingIO).main,this.shareOut=!1,this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[],this.eventHooks=new me(this.growingIO),this.growingIO.emitter.on("onComposeAfter",(({composedEvent:e})=>{"VISIT"!==e.eventType&&"vst"!==e.t||(this.lastVisitEvent=e),"PAGE"!==e.eventType&&"page"!==e.t||(this.lastPageEvent=e)})),d(null===(t=this.growingIO.minipInstance.minip)||void 0===t?void 0:t.onAppHide)&&this.growingIO.minipInstance.minip.onAppHide((()=>{_(this.trackTimers,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))})),d(null===(i=this.growingIO.minipInstance.minip)||void 0===i?void 0:i.onAppShow)&&this.growingIO.minipInstance.minip.onAppShow((()=>{_(this.trackTimers,(e=>{e.start&&(e.start=+Date.now())}))})),this.growingIO.emitter.on("OPTION_CHANGE",(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.growingIO.clearTrackTimer()}))}get gsid(){const e=J(),t=z(e);return!N(t)&&e.gio_gsid?e.gio_gsid:this._gsid}set gsid(e){const t=Number.parseInt(e,10);this._gsid=Number.isNaN(t)||e>=1e9||1>e?1:e,J().gio_gsid=this._gsid,10>this._gsid-this._stid||this.saveStorageInfo()}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 Ie={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 Se{constructor(e){this.growingIO=e,this.minip=V("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.settedTitle[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=()=>H((()=>m(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,i;let s="";const n=Q(W());try{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:"",0===s.length){const t=n.page[e.route]||n.page[e.route+".html"];s=t?t.window.navigationBarTitleText:n.global.window.navigationBarTitleText}if(0===s.length){const r=null===(i=null===(t=null==n?void 0:n.tabBar)||void 0===t?void 0:t.list)||void 0===i?void 0:i.find((t=>t.pagePath===e.route||t.pagePath===e.route+".html"));s=(null==r?void 0:r.text)||""}}catch(e){return""}return U(s)},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return c(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 u=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 g=setTimeout((()=>{(null==u?void 0:u.abort)&&d(null==u?void 0:u.abort)&&(null==u||u.abort()),clearTimeout(g),g=null}),(s||1e4)+10);return u},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("OPTION_INITIALIZED",(()=>{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 ye extends Se{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{vdsConfig:t,platformConfig:i}=e;try{this.growingIO.shareAppMessage=function(){var s;const n=arguments[0];n&&n.type&&!/^text.*/.test(n.type)&&n.data&&t.followShare&&(-1===n.data.indexOf("?")?n.data=n.data+"?suid="+e.userStore.uid:n.data=n.data+"&suid="+e.userStore.uid),null==o||o.share(n),null===(s=null==e?void 0:e.eventTracking)||void 0===s||s.pageEffects(this,i.listeners.page.shareApp,arguments)}}catch(e){}},this.getCurrentPage=()=>(null==r?void 0:r.getPages)?m(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 U(a)},this.getStorageSync=()=>"",this.getStorage=e=>ce(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=()=>ce(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=()=>ce(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("minipLifecycle",(({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})}}}))}}let we;const Oe={};var be,Pe,Ce;Pe={name:"gioCustomTracking",method:class{constructor(e){this.growingIO=e,this.getDynamicAttributes=e=>(we.isNil(e)||we.keys(e).forEach((t=>{we.isFunction(e[t])?e[t]=e[t]():we.isArray(e[t])||(e[t]=we.toString(e[t]))})),e),this.buildCustomEvent=(e,t)=>{we.eventNameValidate(e,(()=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:s}}=this.growingIO;s(Object.assign({eventType:"CUSTOM",eventName:e,attributes:we.limitObject(this.getDynamicAttributes(we.isObject(t)&&!we.isEmpty(t)?t:void 0))},i()))}))},this.buildUserAttributesEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i,lastVisitEvent:s}}=this.growingIO,n=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES",attributes:we.limitObject(e)},t());n.path||(n.path=s.path,n.query=s.query,n.title=s.title),i(n)},we=this.growingIO.utils}}},Ce=Oe,(be=["pluginsIn","gioCustomTracking"]).map((function(e,t){Ce[e]=t==be.length-1?Pe:Ce[e]||{},Ce=Ce[e]}));class Te{constructor(e){this.growingIO=e,this.innerPluginInit=()=>{T(Oe.pluginsIn).forEach((e=>{const{name:t,method:i}=Oe.pluginsIn[e],s=this.pluginItems.find((e=>e.name===t));s||this.pluginItems.push({name:O(t||e),method:i||(e=>{})})})),N(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var s;const n=t||this.pluginItems.find((t=>t.name===e));if(null===(s=this.growingIO)||void 0===s?void 0:s.plugins[e])return D(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!n)return D(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return this.growingIO.plugins[e]=new n.method(this.growingIO,i),t&&D("加载插件:"+e,"info"),!0}catch(t){return D(`插件【${e}】加载异常 ${t}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>this.install(t.name,e?t:void 0,t.options)))},this.uninstall=e=>{var t;A(this.pluginItems,e);const i=A(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||D(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>D(`插件执行错误 ${e.name} ${t}`,"error"),this.onComposeBefore=e=>{this.pluginItems.forEach((t=>{var i;const s=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onComposeBefore;if(s&&d(s))try{s(e)}catch(e){this.lifeError(t,e)}}))},this.onComposeAfter=e=>{this.pluginItems.forEach((t=>{var i;const s=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onComposeAfter;if(s&&d(s))try{s(e)}catch(e){this.lifeError(t,e)}}))},this.onSendBefore=e=>{this.pluginItems.forEach((t=>{var i;const s=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onSendBefore;if(s&&d(s))try{s(e)}catch(e){this.lifeError(t,e)}}))},this.onSendAfter=e=>{this.pluginItems.forEach((t=>{var i;const s=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onSendAfter;if(s&&d(s))try{s(e)}catch(e){this.lifeError(t,e)}}))},this.pluginItems=[],this.growingIO.emitter.on("onComposeBefore",this.onComposeBefore),this.growingIO.emitter.on("onComposeAfter",this.onComposeAfter),this.growingIO.emitter.on("onSendBefore",this.onSendBefore),this.growingIO.emitter.on("onSendAfter",this.onSendAfter)}}var _e={},ke={}.hasOwnProperty;function Ee(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function Ae(e){try{return encodeURIComponent(e)}catch(e){return null}}_e.stringify=function(e,t){t=t||"";var i,s,n=[];for(s in"string"!=typeof t&&(t="?"),e)if(ke.call(e,s)){if((i=e[s])||null!=i&&!isNaN(i)||(i=""),s=Ae(s),i=Ae(i),null===s||null===i)continue;n.push(s+"="+i)}return n.length?t+n.join("&"):""},_e.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,s={};t=i.exec(e);){var n=Ee(t[1]),r=Ee(t[2]);null===n||null===r||n in s||(s[n]=r)}return s};class qe{constructor(e){this.growingIO=e,this.generateURL=()=>{const{serverUrl:e,projectId:t}=this.growingIO.vdsConfig;return b(e,"http")?`${e}/v3/projects/${t}/collect`:`https://${e}/v3/projects/${t}/collect`},this.commitRequest=e=>{const t=Object.assign({},e),{vdsConfig:i}=this.growingIO;i.forceLogin?this.hoardingQueue.push(t):(this.requestQueue.push(t),this.initiateRequest())},this.initiateRequest=e=>{var t,i;const{plugins:s,vdsConfig:n}=this.growingIO;[...this.hoardingQueue,...this.requestQueue].length>0&&this.requestingNum<this.requestLimit&&((null===(t=null==n?void 0:n.tbConfig)||void 0===t?void 0:t.cloudFuncSend)?null===(i=null==s?void 0:s.gioTaobaoAdapter)||void 0===i||i.singleInvoke():e?this.batchInvoke():this.batchInvokeThrottle())},this.batchInvoke=()=>{var e,t;const{vdsConfig:i,plugins:s,emitter:n}=this.growingIO;let r=[...this.hoardingQueue,...this.requestQueue];r.length>50?(r=r.slice(0,50),this.hoardingQueue.length>50?this.hoardingQueue=this.hoardingQueue.slice(50):(this.hoardingQueue=[],this.requestQueue=this.requestQueue.slice(50-this.hoardingQueue.length))):(this.hoardingQueue=[],this.requestQueue=[]);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 A(t,"requestId"),t}));i.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),n.emit("onSendBefore",{requestData:a}),(null===(e=null==i?void 0:i.tbConfig)||void 0===e?void 0:e.cloudAppId)?null===(t=null==s?void 0:s.gioTaobaoAdapter)||void 0===t||t.tbCloudAppInvoke(a):this.normalBatchInvoke(o,a)},this.batchInvokeThrottle=q(this.batchInvoke,this.growingIO.vdsConfig.uploadInterval,!1,!1),this.normalBatchInvoke=(e,t)=>{var i;const{minipInstance:s,vdsConfig:n,emitter:r,plugins:o}=this.growingIO;this.requestingNum+=1;const a={"content-type":"jdp"===s.platform?"application/json":"application/json;charset=UTF-8"};let l=[...t];const u=n.compress&&(null===(i=null==o?void 0:o.gioCompress)||void 0===i?void 0:i.compressToUTF16);u&&(l=o.gioCompress.compressToUTF16(JSON.stringify(t)),a["X-Compress-Codec"]="1"),s.request({url:`${this.requestURL}?stm=${Date.now()}&compress=${u?"1":"0"}`,header:a,method:"POST",data:l,timeout:this.requestTimeout,fail:t=>{[200,204].includes(t.code)||(p(e)?e.forEach((e=>{this.requestFailFn(e)})):this.requestFailFn(e),D("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,r.emit("onSendAfter",{result:e}),this.initiateRequest()}})},this.requestFailFn=e=>{this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1;const t=this.requestQueue.some((t=>t.requestId===e.requestId));if(!t){let t=setTimeout((()=>{N(this.requestQueue)?(this.requestQueue.push(e),this.initiateRequest()):this.requestQueue.push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue=[],this.requestQueue=[],this.requestLimit=3,this.requestTimeout=5e3,this.retryLimit=2,this.retryIds={},this.requestingNum=0,this.requestURL=this.generateURL()}}class Ne{constructor(e){var t;this.growingIO=e,this.initUserInfo=()=>{var e;const{minipInstance:t}=this.growingIO,i=[this.uidStorageName,this.userIdStorageName,this.userKeyStorageName,this.gioIdStorageName],s=null!==(e=X(t,i))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,t)=>{this[e]=s[t],"_uid"!==e||this[e]||(this.uid=B())}))},this.saveUserInfo=()=>{const{minipInstance:e}=this.growingIO;ee(e,[{key:this.uidStorageName,value:this.uid},{key:this.userIdStorageName,value:this.userId},{key:this.userKeyStorageName,value:this.userKey},{key:this.gioIdStorageName,value:this.gioId}])};const{inPlugin:i}=this.growingIO;this.uidStorageName=i?"_growing_plugin_uid_":"_growing_uid_",this.userIdStorageName=i?"_growing_plugin_userId_":"_growing_userId_",this.userKeyStorageName=i?"_growing_plugin_userKey_":"_growing_userKey_",this.gioIdStorageName=i?"_growing_plugin_gioId_":"_growing_gioId_",this._sessionId=B(),this._uid=void 0,this._userId=void 0,this._userKey=void 0,this._gioId=void 0,"quickapp"!==(null===(t=this.growingIO)||void 0===t?void 0:t.gioPlatform)&&this.initUserInfo()}get sessionId(){return this._sessionId||(this._sessionId=B()),this._sessionId}set sessionId(e){const t=this._sessionId;this._sessionId=e||B(),t!==this._sessionId&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:this._sessionId,oldSessionId:t})}get uid(){return this._uid}set uid(e){const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this.uidStorageName,this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))}get userId(){return this._userId}set userId(e){const t=this._userId;this._userId=e,t!==this._userId&&(this.growingIO.minipInstance.setStorage(this.userIdStorageName,this._userId),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:e,oldUserId:t})),e&&(this.gioId=e)}get userKey(){return this._userKey}set userKey(e){const t=this._userKey;this._userKey=e,t!==this._userKey&&(this.growingIO.minipInstance.setStorage(this.userKeyStorageName,this._userKey),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:e,oldUserKey:t}))}get gioId(){return this._gioId}set gioId(e){const t=this._gioId;this._gioId=e,t!==this._gioId&&(this.growingIO.minipInstance.setStorage(this.gioIdStorageName,this._gioId),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:e,oldGioId:t}))}}const xe=new class{constructor(){var e;this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.init=e=>{var t;return D("Gio小程序SDK 初始化中...","info"),this.dataStore.initOptions(e),null===(t=this.emitter)||void 0===t||t.emit("OPTION_INITIALIZED",this),this.gioSDKInitialized=!0,this.vdsConfig.subpackage||(J().__gio__=()=>this),this.uploader=new qe(this),this.vdsConfig.idMapping||(this.userStore.userKey=""),this.emitter.emit("SDK_INITIALIZED",this),D("Gio小程序SDK 初始化完成!","success"),this.vdsConfig.forceLogin&&D("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(),!0},this.getOption=e=>this.dataStore.getOption(e),this.setOption=(e,t)=>{if(T(ae).includes(e)){const i=this.dataStore.setOption(e,t);return i&&ae[e]&&D(`已${t?"开启":"关闭"}${ae[e]}`,"info"),i}return D(`不存在可修改的配置项:${e},请检查后重试!`,"warn"),!1},this.getDeviceId=()=>this.userStore.uid,this.identify=e=>{if(this.vdsConfig.forceLogin){if(!ne(e))return void $("identify");const t=y(e).slice(0,1e3);this.userStore.uid=t,this.uploader.hoardingQueue.forEach(((e,i)=>this.uploader.hoardingQueue[i].deviceId=t)),this.dataStore.setOption("forceLogin",!1),this.uploader.initiateRequest(!0)}else $("identify",!1,"forceLogin未开启")},this.setUserId=(e,t)=>{if(ne(e)){const i=this.userStore.gioId;if(e=y(e).slice(0,1e3),t=y(t).slice(0,1e3),this.userStore.userId=e,this.vdsConfig.idMapping&&(this.userStore.userKey=l(t)?"":t),i&&i!==e){this.userStore.sessionId="";const{path:e,query:t,settedTitle:i}=this.dataStore.eventHooks.currentPage;this.dataStore.eventHooks.currentPage.title=i[e]||this.minipInstance.getPageTitle(this.minipInstance.getCurrentPage()),this.dataStore.sendVisit({path:e,query:t})}}else $("setUserId")},this.clearUserId=()=>{this.userStore.userId=void 0,this.userStore.userKey=void 0},this.setUserAttributes=e=>{var t,i;!N(e)&&c(e)?null===(i=null===(t=this.plugins)||void 0===t?void 0:t.gioCustomTracking)||void 0===i||i.buildUserAttributesEvent(e):$("setUserAttributes")},this.track=(e,t)=>{var i,s;((null===(s=null===(i=this.plugins)||void 0===i?void 0:i.gioCustomTracking)||void 0===s?void 0:s.buildCustomEvent)||function(){})(e,Object.assign(Object.assign({},this.dataStore.generalProps),c(t)&&!N(t)?t:{}))},this.trackTimerStart=e=>!!this.vdsConfig.dataCollect&&L(e,(()=>{const t=B();return this.dataStore.trackTimers[t]={eventName:e,leng:0,start:+Date.now()},t})),this.trackTimerPause=e=>{if(e&&this.dataStore.trackTimers[e]){const t=this.dataStore.trackTimers[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=e=>{if(e&&this.dataStore.trackTimers[e]){const t=this.dataStore.trackTimers[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t)=>{if(this.vdsConfig.dataCollect){const i=864e5;if(e&&this.dataStore.trackTimers[e]){const s=this.dataStore.trackTimers[e];if(0!==s.start){const e=+Date.now()-s.start;s.leng=e>0?s.leng+e:0}const{eventContextBuilder:n,eventInterceptor:r}=this.dataStore;return r(Object.assign(Object.assign({eventType:"CUSTOM",eventName:s.eventName,attributes:Z(Object.assign(Object.assign({},t),{event_duration:s.leng>i?0:s.leng/1e3}))},n()),{customEventType:0})),this.removeTimer(e),!0}return D("未查找到对应的计时器,请检查!","error"),!1}return!1},this.removeTimer=e=>!(!e||!this.dataStore.trackTimers[e]||(delete this.dataStore.trackTimers[e],0)),this.clearTrackTimer=()=>{this.dataStore.trackTimers={}},this.setGeneralProps=e=>{c(e)&&!N(e)?(this.dataStore.generalProps=Object.assign(Object.assign({},this.dataStore.generalProps),e),T(this.dataStore.generalProps).forEach((e=>{[void 0,null].includes(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]="")}))):$("setGeneralProps")},this.clearGeneralProps=e=>{p(e)&&!N(e)?e.forEach((e=>{A(this.dataStore.generalProps,e)})):this.dataStore.generalProps={}},this.setPageAttributes=e=>{const{currentPage:t}=this.dataStore.eventHooks,i=this.minipInstance.getCurrentPath();["onLoad","attached"].includes(t.currentLifecycle)&&(t.pageProps[i]=Z(e))},this.updateImpression=()=>{D("当前未集成半自动浏览插件,请集成插件后再调用 updateImpression!","warn")},this.setLocation=(e,t)=>{const i={latitude:e,longitude:t},s=this.dataStore.locationData,n=e=>e>=-180&&180>=e;n(e)&&n(t)&&(s.latitude!==e||s.longitude!==t)&&(this.dataStore.locationData=i)},this.getGioInfo=()=>{const{uid:e,userId:t,userKey:i,sessionId:s}=this.userStore,{projectId:n,appId:r,dataSourceId:o,dataCollect:a,idMapping:l,extraParams:u,ignoreFields:g}=this.vdsConfig,h={gioappid:r,giocs1:t||"",gioplatform:this.platformConfig.platform,gioprojectid:n,gios:s,giou:e};return h.giodatacollect=a,h.giodatasourceid=o,l&&(h.giouserkey=i),N(u)||u.forEach((e=>{g.includes(e)||(h["gio"+e]=this.dataStore.lastVisitEvent[e])})),_e.stringify(h)},this.utils=Object.assign(Object.assign(Object.assign({},j),se),{qs:_e}),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.0.0";try{"quickapp"===this.gioPlatform||d(getApp)&&d(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&D("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Ie,this.minipInstance=new ye(this),this.dataStore=new fe(this),this.userStore=new Ne(this),this.plugins=new Te(this),this.plugins.innerPluginInit()}},je=function(){const e=arguments[0];if(u(e)&&oe.includes(e)&&xe[e]){const i=f(Array.from(arguments));if("init"===e){const e=!(t=xe).vdsConfig&&!t.gioSDKInitialized||(D("SDK重复初始化,请检查是否重复加载SDK或接入其他平台SDK导致冲突!","warn"),!1),s=(e=>!!I(e)||(D('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "你的应用 AppId", options); 进行初始化!',"error"),!1))(i),n=(e=>{const t=e[0];let i=m(e);return ne(t)?(c(i)&&i||(i={}),{projectId:t,userOptions:i}):(D("SDK初始化失败,accountId 参数不合法!","error"),!1)})(i),r=(e=>{const t=e[1];let i=e[2];const s=m(e);return t&&u(t)?ne(i)?{dataSourceId:t,appId:i,options:s}:(D("SDK初始化失败,appId 参数不合法!","error"),!1):(D("SDK初始化失败,dataSourceId 参数不合法!","error"),!1)})(i);if(e&&s&&n&&r){const{projectId:e}=n,{dataSourceId:t,appId:i,options:s}=r;return xe.init(Object.assign(Object.assign({},s),{projectId:e,dataSourceId:t,appId:i}))}}else if("registerPlugins"===e)xe.registerPlugins(i[0]);else{if(xe.gioSDKInitialized&&xe.vdsConfig)return xe[e](...i);D("SDK未初始化!","error")}}else le.includes(e)?D(`方法 ${y(e)} 已被弃用!`,"warn"):D(`不存在名为 ${y(e)} 的方法调用!`,"error");var t};Y().gdp=je,Y().gioSDKVersion=xe.sdkVersion;const De=H((()=>{var e;return null!==(e=xe.dataStore.eventHooks.growingApp)&&void 0!==e?e:App})),$e=H((()=>{var e;return null!==(e=xe.dataStore.eventHooks.growingPage)&&void 0!==e?e:Page})),He=H((()=>{var e;return null!==(e=xe.dataStore.eventHooks.growingComponent)&&void 0!==e?e:Component})),Ue=H((()=>{var e;return null!==(e=xe.dataStore.eventHooks.growingBehavior)&&void 0!==e?e:Behavior}));export default je;export{De as GioApp,Ue as GioBehavior,He as GioComponent,$e as GioPage};
|
|
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=e=>["undefined","null"].includes(x(e)),u=e=>"string"===x(e),g=e=>"number"===x(e),h=e=>"boolean"===x(e),c=e=>"[object Object]"==={}.toString.call(e)&&!l(e),d=e=>["function","asyncfunction"].includes(x(e)),p=e=>Array.isArray(e)&&"array"===x(e),v=e=>{try{return Array.from(e)[0]}catch(e){return}},m=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},f=(e,t=1)=>p(e)&&g(t)?e.slice(t>0?t:1,e.length):e,I=e=>{if(p(e)){let t=0;const i=[];for(const s of e)s&&!N(s)&&(i[t++]=s);return i}return e},S=(e,t)=>{if(p(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},y=e=>l(e)?"":""+e,w=(e,t)=>"string"===x(e)?e.split(t):e,O=e=>{if(u(e)){const t=w(e,"");return`${v(t).toLowerCase()}${f(t).join("")}`}return e},b=(e,t)=>e.slice(0,t.length)===t,P={}.hasOwnProperty,T=(e,t)=>!l(e)&&P.call(e,t),C=e=>c(e)?Object.keys(e):[],_=(e,t)=>{C(e).forEach((i=>t(e[i],i)))},k=(e,t)=>{const i=C(e);return!(!c(e)||!c(t)||i.length!==C(t).length||i.map(((i,s)=>c(e[i])?k(e[i],t[i]):e[i]===t[i])).includes(!1))},E=(e,t,i)=>{let s=e;return c(e)?(t.split(".").forEach((e=>{s=s?s[e]:i})),s):i},A=(e,t)=>{if(!c(e))return!1;try{if("string"===x(t))return delete e[t];if("array"===x(t))return t.map((t=>delete e[t]));"object"===x(t)&&t.constructor===RegExp&&C(e).forEach((i=>{t.test(i)&&A(e,i)}))}catch(e){return!1}},q=(e,t=250,i,s)=>{let n,r=0;return"boolean"!==x(i)&&(s=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function u(){r=Date.now(),e.apply(a,o)}s&&!n&&u(),n&&clearTimeout(n),void 0===s&&l>t?u():!0!==i&&(n=setTimeout(s?function(){n=void 0}:u,void 0===s?t-l:t))}},N=e=>p(e)?0===e.length:c(e)?0===C(e).length:!e,x=e=>({}.toString.call(e).slice(8,-1).toLowerCase());var j=Object.freeze({__proto__:null,isNil:l,isString:u,isNaN:e=>"NaN"===y(Number(e)),isNumber:g,isBoolean:h,isObject:c,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:d,isArray:p,isDate:e=>"date"===x(e),fixed:(e,t)=>g(e)?Number(e.toFixed(g(t)?t:2)):u(e)&&"NaN"!==y(Number(e))?Number(Number(e).toFixed(g(t)?t:2)):e,head:v,last:m,drop:f,dropWhile:(e,t)=>p(e)?e.filter((e=>!t(e))):e,compact:I,find:S,isEqualArray:(e,t)=>!(!p(e)||!p(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:y,split:w,lowerFirst:O,upperFirst:e=>{if(u(e)){const t=w(e,"");return`${v(t).toUpperCase()}${f(t).join("")}`}return e},startsWith:b,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:P,has:T,keys:C,forEach:_,isEqual:k,get:E,unset:A,throttle:q,isEmpty:N,typeOf:x,formatDate: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())}});const D=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},$=(e,t=!0,i="参数不合法")=>D(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),H=e=>{try{return e()}catch(e){return}},U=e=>u(e)?e.trim().substring(0,100):e,L=(e,t)=>u(e)&&!N(e)&&e.match(/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/)?t():(D("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),B=()=>"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)})),F=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,R=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,K=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},M=e=>{if(u(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},G=e=>u(e)?e.startsWith("/")?e:"/"+e:"",V=e=>H((()=>{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=H((()=>swan))),e||(e=H((()=>my))),e||(e=H((()=>tt))),e||(e=H((()=>qq))),e||(e=H((()=>ks))),e||(e=H((()=>jd))),e||(e=H((()=>wx))),e}}})),Q=e=>H((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return __ttConfig;case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),W=()=>{let e;return!e&&H((()=>swan))&&(e="swan"),!e&&H((()=>tt))&&(e="tt"),!e&&H((()=>qq))&&(e="qq"),!e&&H((()=>my.tb))&&(e="tb"),!e&&H((()=>my))&&(e="my"),!e&&H((()=>ks))&&(e="ks"),!e&&H((()=>jd))&&(e="jd"),!e&&H((()=>wx))&&(e="wx"),e||S(C(global),(e=>y(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},z=e=>C(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),J=()=>{let e=H((()=>getApp({allowDefault:!0})));return e||(e=Y()),e},Y=()=>{var e;return null!==(e=H((()=>$global)))&&void 0!==e?e:global},Z=e=>{const t={};return c(e)&&_(e,((e,i)=>{const s=y(i).slice(0,100);c(e)?t[s]=Z(e):p(e)?(t[s]=e.slice(0,100),t[s]=t[s].join("||").slice(0,1e3)):t[s]=l(e)?"":y(e).slice(0,1e3)})),t},X=(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()}},ee=(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()}},te=e=>C(e||{}).map((t=>t?`${t}=${l(e[t])?"":e[t]}`:"")).join("&"),ie=e=>{(b(e,"?")||b(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};var se=Object.freeze({__proto__:null,consoleText:D,callError:$,niceTry:H,niceCallback:(e,t)=>{if(d(e))try{e(t)}catch(e){D("回调执行失败!"+e,"error")}},limitString:U,eventNameValidate:L,guid:B,getScreenHeight:F,getScreenWidth:R,getOS:K,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.parseInt(v(w(e.version,".")),10);return Number.isNaN(t)?0:t}return 0},splitPath:M,normalPath:G,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:V,getPlainConfig:Q,getPlainPlatform:W,getSubKeys:z,getAppInst:J,getGlobal:Y,limitObject:Z,batchGetStorageSync:X,batchSetStorageSync:ee,qsStringify:te,qsParse:ie,hashCode:e=>{let t=0;if(N(e)||"boolean"==typeof e)return t;let i=0;for(;i<e.length;)t=(t<<5)-t+e.charCodeAt(i),t&=t,i++;return t}});const ne=e=>u(e)&&e.length>0||g(e)&&e>0,re={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}},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},oe=["clearGeneralProps","clearTrackTimer","clearUserId","getDeviceId","getGioInfo","getOption","identify","init","registerPlugins","removeTimer","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart","updateImpression","getABTest"],ae={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},le=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],ue=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],ge=[...ue,"appChannel","language","platformVersion"];class he{constructor(e){this.growingIO=e,this.main=e=>{var t,i,s,n,r;const{sdkVersion:o,vdsConfig:a,platformConfig:l,minipInstance:u,userStore:g,dataStore:{scene:h,eventHooks:c,locationData:d,lastVisitEvent:p}}=this.growingIO,{systemInfo:v={},network:m={}}=u,{brand:f,model:I,platform:S,language:y,version:w}=v,O={appChannel:"scn:"+(h||"NA"),appVersion:a.version,dataSourceId:a.dataSourceId,deviceBrand:f,deviceId:g.uid,deviceModel:I,deviceType:K(S,l.name),domain:a.appId,language:y,latitude:null==d?void 0:d.latitude,longitude:null==d?void 0:d.longitude,networkState:(null==m?void 0:m.networkType)||(null==m?void 0:m.type)||(null==m?void 0:m.subtype),operatingSystem:K(S,l.name),path:(null===(t=c.currentPage)||void 0===t?void 0:t.path)?null===(i=c.currentPage)||void 0===i?void 0:i.path:p.path,platform:l.platform,platformVersion:l.name+(w?" "+w:""),query:(null===(s=c.currentPage)||void 0===s?void 0:s.path)?null===(n=c.currentPage)||void 0===n?void 0:n.query:p.query,screenHeight:F(v),screenWidth:R(v),sdkVersion:o,sessionId:g.sessionId,title:(null===(r=c.currentPage)||void 0===r?void 0:r.title)||u.getPageTitle(u.getCurrentPage()),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:g.userId};return a.idMapping&&(O.userKey=g.userKey),N(a.ignoreFields)||a.ignoreFields.forEach((e=>{A(O,e)})),N(e)?O:Object.assign(Object.assign({},O),e)}}}function ce(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())}))}class de{constructor(e){this.growingIO=e,this.main=(e,t)=>{var i,s;const n=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:u,dataStore:g,dataStore:{shareOut:h,keepAlive:c,lastCloseTime:d,eventHooks:p,saveStorageInfo:v}}=this.growingIO;r.emit("minipLifecycle",{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("onComposeBefore",{event:"App "+e,params:null!==(s=t[0])&&void 0!==s?s:{}}),e){case m.appCreate:case m.appShow:{const{path:e,query:i}=this.enterParamsParse(t[0]);!h&&a.originalSource&&g.setOriginalSource({path:e,query:i}),d?(Date.now()-d>c||g.lastScene&&g.scene!==g.lastScene)&&(o.sessionId="",p.currentPage.time=void 0,this.buildVisitEvent({path:e,query:i})):(this.growingIO.dataStore.lastVisitEvent={path:e,query:i},this.buildVisitEvent({path:e,query:i}));break}case m.appClose:g.lastScene=g.scene,g.lastCloseTime=Date.now(),v(),o.saveUserInfo(),this.buildCloseEvent(),a.forceLogin||u.initiateRequest(!0)}},this.enterParamsParse=e=>{const{gioPlatform:t,minipInstance:i,dataStore:s}=this.growingIO;let n="",r="";const o=(e,t={})=>{n=e,r=C(t).map((e=>`${e}=${t[e]}`)).join("&")};if("quickapp"!==t&&i.minip.canIUse("getEnterOptionsSync")){const{path:t,query:n,scene:a,referrerInfo:l}=i.minip.getEnterOptionsSync()||{},u=e.query||n;if(o(e.path||t,u),s.scene=e.scene||a,!N(l)&&c(null==l?void 0:l.extraData)){let e=[];_(l.extraData,((t,i)=>{!T(u,i)&&["string","number","boolean"].includes(x(t))&&e.push(`${i}=${t}`)}));const t=e.join("&");r=r&&t?`${r}&${t}`:r||t}}else{const{path:t,query:i}=e;o(t,i),this.parseScene(e)}return{path:n,query:r}},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=>{const{dataStore:t,vdsConfig:i,minipInstance:s}=this.growingIO,{originalSourceName:n,getOriginalSource:r,eventContextBuilder:o,eventInterceptor:a}=t,u=r(),g=(null==e?void 0:e.query)||"";let h=Object.assign({eventType:"VISIT"},o({path:(null==e?void 0:e.path)||"",query:"string"===x(g)?g:te(g)}));i.originalSource&&!l(u)&&(h=Object.assign(Object.assign({},h),u),i.dataCollect&&s.removeStorageSync(n)),a(h)},this.buildCloseEvent=()=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:t}}=this.growingIO;t(Object.assign({eventType:"APP_CLOSED"},e()))}}}class pe{constructor(e){this.growingIO=e,this.parsePage=(e,t)=>{var i;const s=e.route||e.uri||e.__route__||(null===(i=null==e?void 0:e.$page)||void 0===i?void 0:i.fullPath)||"";N(t)?this.query=void 0:this.query=this.getQuery(t),this.path!==s&&(this.time=Date.now()),this.path=s,this.title=this.settedTitle[this.path]||this.growingIO.minipInstance.getPageTitle(e||this.growingIO.minipInstance.getCurrentPage())},this.getQuery=e=>{const t=Object.assign({},e);return A(t,"wxShoppingListScene"),te(t)},this.getReferralPage=()=>{const{minipInstance:e,dataStore:{lastPageEvent:t,scene:i}}=this.growingIO;return(null==t?void 0:t.path)||(i?`scn:${e.scnPrefix}${i}`:null)},this.saveShareId=e=>{(null==e?void 0:e.gioShareId)&&(this.queryShareId=e.gioShareId)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=G(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=G(t+(i?"?"+i:"")),e.query=i,e},this.query=void 0,this.settedTitle={},this.pageProps={}}buildShareQuery(e){var t,i,s;const n=M(null!==(t=e.path)&&void 0!==t?t:"");let r=this.path,o={},a=T(e,"path");return a&&(r=v(n),o=ie(m(n))||{}),N(o)&&(o=ie(null!==(i=e.query)&&void 0!==i?i:"")||{}),!a&&N(o)&&(o=ie(null!==(s=this.query)&&void 0!==s?s:"")||{}),[r,te(o)]}}class ve{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var s,n;const r=Date.now(),{emitter:o,minipInstance:a,plugins:l,vdsConfig:u,platformConfig:g,dataStore:{shareOut:h,eventHooks:c,toggleShareOut:p,buildAppMessageEvent:v,buildTimelineEvent:m,buildAddFavorites:f},inPlugin:I}=this.growingIO,{currentPage:S}=c;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=a.getCurrentPage()),e.route||(e.route=a.getCurrentPath(e));const y=e.route||e.uri||e.__route__||(null===(s=null==e?void 0:e.$page)||void 0===s?void 0:s.fullPath)||"";o.emit("minipLifecycle",{event:"Page "+t,timestamp:r,params:{page:e,args:i[0]}}),u.debug&&console.log("Page:",y,"#",t,r),this.prevEvent[t]=Date.now();const w=g.listeners.page;switch(o.emit("onComposeBefore",{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),S.lastLifecycle=S.currentLifecycle,S.currentLifecycle=t,t){case w.pageLoad:this.argQuery[y]=E(e,"options")||E(e,"__displayReporter.query")||E(e,"$page.query")||E(e,"$wx.__displayReporter.query")||i[0]||{},A(this.argQuery[y],"$taroTimestamp"),S.parsePage(e,this.argQuery[y]);break;case w.pageShow:I?(S.parsePage(e,this.argQuery[y]),S.path||(S.path=`/插件${u.appId}}`,S.title=`/插件${u.appId}}`),this.buildPageEvent()):h&&c.currentPage.time||(S.parsePage(e,this.argQuery[y]),c.currentPage.time=Date.now(),this.buildPageEvent()),p(!1),S.saveShareId(this.argQuery[y]);break;case w.pageHide:case w.pageUnload:break;case w.shareApp:p(!0),u.followShare&&v(i);break;case w.shareTime:u.followShare&&m(i);break;case w.addFavorites:f(i);break;case w.tabTap:{const e=null===(n=null==l?void 0:l.gioEventAutoTracking)||void 0===n?void 0:n.buildTabClickEvent;u.autotrack&&e&&d(e)&&e(i[0]);break}}t===w.pageUnload&&(S.pageProps[y]=void 0)},this.buildPageEvent=e=>{var t;const{dataStore:{eventContextBuilder:i,eventInterceptor:s,eventHooks:n}}=this.growingIO,{currentPage:r}=n,o=Object.assign(Object.assign({eventType:"PAGE",referralPage:r.getReferralPage()},i()),{timestamp:r.time});N(r.pageProps[o.path])||(o.attributes=r.pageProps[o.path]),!N(e)&&e.path&&(o.path=e.path,o.query=e.query,o.title=null!==(t=e.title)&&void 0!==t?t:o.title),s(o)},this.prevEvent={},this.argQuery={}}}class me{constructor(e){var t,i;this.growingIO=e,this.isNormalFc=(e,t)=>d(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)=>{p(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{d(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 ce(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=yield t.apply(this,n))&&void 0!==r?r:{},"promise"===x(o.promise)){const e=function(){return ce(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()),A(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){D(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,n)),s.growingIO.emitter.emit("minipLifecycle",{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)&&(d(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){D(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=>this.originalApp(this.appOverriding(e)),this.growingPage=e=>this.originalPage(this.pageOverriding(e)),this.growingComponent=e=>this.originalComponent(this.componentOverriding(e)),this.growingBehavior=e=>this.originalBehavior(this.componentOverriding(e)),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,s=i.hooks;if(this.setAppEffectCbs(),this.setPageEffectCbs(),e.includes("App"))try{s.App&&!this.appHooked&&(App=function(...e){return t.growingApp(e[0])},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{s.Page&&!this.pageHooked&&(Page=function(...e){return t.growingPage(e[0])},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{s.Component&&!this.componentHooked&&(Component=function(...e){return t.growingComponent(e[0])},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{s.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.growingBehavior(e[0])},this.behaviorHooked=!0)}catch(e){}},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;t.canHook?(this.nativeGrowing(),Y().GioApp=H((()=>null!==App&&void 0!==App?App:window.GioApp)),Y().GioPage=H((()=>null!==Page&&void 0!==Page?Page:window.GioPage)),Y().GioComponent=H((()=>null!==Component&&void 0!==Component?Component:window.GioComponent)),Y().GioBehavior=H((()=>Behavior))):"quickapp"===i&&(window.GioApp=function(...t){return e.appOverriding(t[0])},window.GioPage=function(...t){return e.pageOverriding(t[0])},window.GioComponent=function(...t){return e.pageOverriding(t[0])})};const s=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=s.appHandlers,this.pageHandlers=s.pageHandlers,this.actionEventTypes=s.actionEventTypes,this.originalApp=s.originalApp,this.originalPage=s.originalPage,this.originalComponent=s.originalComponent,this.originalBehavior=null!==(i=s.originalBehavior)&&void 0!==i?i:function(){},this.appEffects=new de(this.growingIO),this.pageEffects=new ve(this.growingIO),this.currentPage=new pe(this.growingIO)}}class fe{constructor(e){var t,i;this.growingIO=e,this.ALLOW_SETTING_KEYS=C(re),this.gsidStorageName="_growing_gsid_",this.originalSourceName="gdp_original_source",this.initStorageInfo=()=>{const{minipInstance:e}=this.growingIO,t=J(),i=t.gio_gsid?t.gio_gsid:Number.parseInt(e.getStorageSync(this.gsidStorageName),10);this._gsid=Number.isNaN(i)||i>=1e9||1>i?1:i,this._stid=this._gsid,i!==this._gsid&&e.setStorageSync(this.gsidStorageName,this._gsid)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=this._gsid,ee(e,[{key:this.gsidStorageName,value:this._gsid}])},this.setOriginalSource=({path:e,query:t})=>{const{minipInstance:i}=this.growingIO;if(l(this.getOriginalSource())){const s={path:e,query:t,title:""};i.setStorageSync(this.originalSourceName,JSON.stringify(s))}},this.getOriginalSource=()=>{const{minipInstance:e}=this.growingIO;return H((()=>JSON.parse(e.getStorageSync(this.originalSourceName))))},this.initOptions=e=>{var t,i,s,n,r,o,a,l;const{projectId:u,dataSourceId:g,appId:h}=e,c={};this.ALLOW_SETTING_KEYS.forEach((t=>{const i=re[t].type;(p(i)?i.includes(x(e[t])):x(e[t])===re[t].type)?"ignoreFields"===t?c.ignoreFields=e.ignoreFields.filter((e=>ue.includes(e))):"extraParams"===t?c.extraParams=e.extraParams.filter((e=>ge.includes(e))):c[t]=e[t]:c[t]=re[t].default})),c.uploadInterval=Math.round(c.uploadInterval),(Number.isNaN(c.uploadInterval)||0>c.uploadInterval||c.uploadInterval>2e3)&&(c.uploadInterval=1e3),c.enableIdMapping&&!c.idMapping&&(c.idMapping=!0),c.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(c.requestTimeout))&&c.requestTimeout>0||(c.requestTimeout=5e3),this.growingIO.vdsConfig=Object.assign(Object.assign({},c),{projectId:u,dataSourceId:g,appId:h,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.keepAlive=c.keepAlive,c.dataCollect||D("已关闭数据采集","info"),c.autotrack||D("已关闭无埋点","info");const{plugins:d,inPlugin:v,minipInstance:m}=this.growingIO,{uniVue:f,taro:I}=c;f||I||(this.growingIO.platformConfig.canHook=!0),v&&!["tbp","jdp"].includes(m.platform)||this.eventHooks.initEventHooks(),f&&(null===(a=null==d?void 0:d.gioUniAppAdapter)||void 0===a||a.main()),I&&(null===(l=null==d?void 0:d.gioTaroAdapter)||void 0===l||l.main())},this.setOption=(e,t)=>{var i;const{vdsConfig:s,userStore:n,uploader:r,emitter:o}=this.growingIO,a=u(e)&&this.ALLOW_SETTING_KEYS.includes(e),l=a&&typeof t===(null===(i=re[e])||void 0===i?void 0:i.type);if(a&&l){if("dataCollect"===e&&!1===s.dataCollect&&!0===t){let e=setTimeout((()=>{n.sessionId="";const{path:t,query:i,settedTitle:s}=this.eventHooks.currentPage;this.eventHooks.currentPage.title=s[t]||this.growingIO.minipInstance.getPageTitle(this.growingIO.minipInstance.getCurrentPage()),this.sendVisit({path:t,query:i}),this.eventHooks.currentPage.time=Date.now(),this.sendPage({path:t,query:i}),clearTimeout(e),e=null}),0)}return s[e]=t,"serverUrl"===e&&(null==r||r.generateURL()),o.emit("OPTION_CHANGE",{optionName:e,optionValue:t}),!0}return $("setOption > "+e),!1},this.getOption=e=>{const{vdsConfig:t}=this.growingIO;return e&&T(t,y(e))?t[y(e)]:l(e)?Object.assign({},t):void $("getOption > "+e)},this.toggleShareOut=e=>{h(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=e=>{this.eventHooks.appEffects.buildVisitEvent(null!=e?e:this.lastVisitEvent),this.eventHooks.currentPage.time=Date.now()},this.sendPage=e=>{this.eventHooks.pageEffects.buildPageEvent(e)},this.eventConverter=e=>{const{vdsConfig:t,dataStore:i,uploader:s}=this.growingIO;if(t.dataCollect){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=i.gsid,this.growingIO.dataStore.gsid+=1);const t={};_(e,((e,i)=>{var s;if("element"===i){const i=null!==(s=v(e))&&void 0!==s?s:{};_(i,((e,i)=>{N(e)&&0!==e||(t[i]=e)}))}else N(e)&&0!==e||(t[i]=e)})),this.growingIO.emitter.emit("onComposeAfter",{composedEvent:t}),s.commitRequest(Object.assign(Object.assign({},t),{requestId:B()}))}},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=>{const t=Object.assign(Object.assign({},e),this.eventContextBuilder({path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(t)})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!N(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{const t=Object.assign(Object.assign({},e),this.eventContextBuilder({path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(t)})),this.interceptEvents=[])},this.buildAppMessageEvent=e=>{var t;const i=e[0];let s;2>e.length?1===e.length&&(s=i):s=e[1];const{dataStore:{eventContextBuilder:n,eventInterceptor:r}}=this.growingIO,o=((null==s?void 0:s.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share",attributes:Object.assign({$from:i.from,$target:null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.id,$share_title:null==s?void 0:s.title,$share_path:v(o),$share_query:o[1]},null==s?void 0:s.attributes)},n()))},this.buildTimelineEvent=e=>{var t;const i=e[0];let s;2>e.length?1===e.length&&(s=i):s=e[1];const{dataStore:{eventContextBuilder:n,eventInterceptor:r}}=this.growingIO,o=((null==s?void 0:s.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline",attributes:Object.assign({$target:null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.id,$share_title:null==s?void 0:s.title,$share_path:v(o),$share_query:o[1]},null==s?void 0:s.attributes)},n()))},this.buildAddFavorites=e=>{const t=e[0];let i;2>e.length?1===e.length&&(i=t):i=e[1];const{dataStore:{eventContextBuilder:s,eventInterceptor:n}}=this.growingIO,r=((null==i?void 0:i.path)||"").split("?");n(Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites",attributes:{$share_title:null==i?void 0:i.title,$share_path:v(r),$share_query:r[1]}},s()))},this.initStorageInfo(),this.eventContextBuilder=new he(this.growingIO).main,this.eventHooks=new me(this.growingIO),this.shareOut=!1,this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[],this.growingIO.emitter.on("onComposeAfter",(({composedEvent:e})=>{"VISIT"!==e.eventType&&"vst"!==e.t||(this.lastVisitEvent=e),"PAGE"!==e.eventType&&"page"!==e.t||(this.lastPageEvent=e)})),d(null===(t=this.growingIO.minipInstance.minip)||void 0===t?void 0:t.onAppHide)&&this.growingIO.minipInstance.minip.onAppHide((()=>{_(this.trackTimers,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))})),d(null===(i=this.growingIO.minipInstance.minip)||void 0===i?void 0:i.onAppShow)&&this.growingIO.minipInstance.minip.onAppShow((()=>{_(this.trackTimers,(e=>{e.start&&(e.start=+Date.now())}))})),this.growingIO.emitter.on("OPTION_CHANGE",(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.growingIO.clearTrackTimer()}))}get gsid(){const e=J(),t=z(e);return!N(t)&&e.gio_gsid?e.gio_gsid:this._gsid}set gsid(e){const t=Number.parseInt(e,10);this._gsid=Number.isNaN(t)||e>=1e9||1>e?1:e,J().gio_gsid=this._gsid,10>this._gsid-this._stid||this.saveStorageInfo()}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 Ie={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 Se{constructor(e){this.growingIO=e,this.minip=V("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.settedTitle[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=()=>H((()=>m(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,i;let s="";const n=Q(W());try{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:"",0===s.length){const t=n.page[e.route]||n.page[e.route+".html"];s=t?t.window.navigationBarTitleText:n.global.window.navigationBarTitleText}if(0===s.length){const r=null===(i=null===(t=null==n?void 0:n.tabBar)||void 0===t?void 0:t.list)||void 0===i?void 0:i.find((t=>t.pagePath===e.route||t.pagePath===e.route+".html"));s=(null==r?void 0:r.text)||""}}catch(e){return""}return U(s)},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return c(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 u=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 g=setTimeout((()=>{(null==u?void 0:u.abort)&&d(null==u?void 0:u.abort)&&(null==u||u.abort()),clearTimeout(g),g=null}),(s||1e4)+10);return u},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("OPTION_INITIALIZED",(()=>{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 ye extends Se{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{vdsConfig:t,platformConfig:i}=e;try{this.growingIO.shareAppMessage=function(){var s;const n=arguments[0];n&&n.type&&!/^text.*/.test(n.type)&&n.data&&t.followShare&&(-1===n.data.indexOf("?")?n.data=n.data+"?suid="+e.userStore.uid:n.data=n.data+"&suid="+e.userStore.uid),null==o||o.share(n),null===(s=null==e?void 0:e.eventTracking)||void 0===s||s.pageEffects(this,i.listeners.page.shareApp,arguments)}}catch(e){}},this.getCurrentPage=()=>(null==r?void 0:r.getPages)?m(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 U(a)},this.getStorageSync=()=>"",this.getStorage=e=>ce(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=()=>ce(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=()=>ce(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("minipLifecycle",(({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})}}}))}}let we;const Oe={};var be,Pe,Te;Pe={name:"gioCustomTracking",method:class{constructor(e){this.growingIO=e,this.getDynamicAttributes=e=>(we.isNil(e)||we.keys(e).forEach((t=>{we.isFunction(e[t])?e[t]=e[t]():we.isArray(e[t])||(e[t]=we.toString(e[t]))})),e),this.buildCustomEvent=(e,t)=>{we.eventNameValidate(e,(()=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:s}}=this.growingIO;s(Object.assign({eventType:"CUSTOM",eventName:e,attributes:we.limitObject(this.getDynamicAttributes(we.isObject(t)&&!we.isEmpty(t)?t:void 0))},i()))}))},this.buildUserAttributesEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i,lastVisitEvent:s}}=this.growingIO,n=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES",attributes:we.limitObject(e)},t());n.path||(n.path=s.path,n.query=s.query,n.title=s.title),i(n)},we=this.growingIO.utils}}},Te=Oe,(be=["pluginsIn","gioCustomTracking"]).map((function(e,t){Te[e]=t==be.length-1?Pe:Te[e]||{},Te=Te[e]}));class Ce{constructor(e){this.growingIO=e,this.innerPluginInit=()=>{C(Oe.pluginsIn).forEach((e=>{const{name:t,method:i}=Oe.pluginsIn[e],s=this.pluginItems.find((e=>e.name===t));s||this.pluginItems.push({name:O(t||e),method:i||(e=>{})})})),N(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var s;const n=t||this.pluginItems.find((t=>t.name===e));if(null===(s=this.growingIO)||void 0===s?void 0:s.plugins[e])return D(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!n)return D(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return this.growingIO.plugins[e]=new n.method(this.growingIO,i),t&&D("加载插件:"+e,"info"),!0}catch(t){return D(`插件【${e}】加载异常 ${t}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>this.install(t.name,e?t:void 0,t.options)))},this.uninstall=e=>{var t;A(this.pluginItems,e);const i=A(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||D(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>D(`插件执行错误 ${e.name} ${t}`,"error"),this.onComposeBefore=e=>{this.pluginItems.forEach((t=>{var i;const s=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onComposeBefore;if(s&&d(s))try{s(e)}catch(e){this.lifeError(t,e)}}))},this.onComposeAfter=e=>{this.pluginItems.forEach((t=>{var i;const s=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onComposeAfter;if(s&&d(s))try{s(e)}catch(e){this.lifeError(t,e)}}))},this.onSendBefore=e=>{this.pluginItems.forEach((t=>{var i;const s=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onSendBefore;if(s&&d(s))try{s(e)}catch(e){this.lifeError(t,e)}}))},this.onSendAfter=e=>{this.pluginItems.forEach((t=>{var i;const s=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onSendAfter;if(s&&d(s))try{s(e)}catch(e){this.lifeError(t,e)}}))},this.pluginItems=[],this.growingIO.emitter.on("onComposeBefore",this.onComposeBefore),this.growingIO.emitter.on("onComposeAfter",this.onComposeAfter),this.growingIO.emitter.on("onSendBefore",this.onSendBefore),this.growingIO.emitter.on("onSendAfter",this.onSendAfter)}}var _e={},ke={}.hasOwnProperty;function Ee(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function Ae(e){try{return encodeURIComponent(e)}catch(e){return null}}_e.stringify=function(e,t){t=t||"";var i,s,n=[];for(s in"string"!=typeof t&&(t="?"),e)if(ke.call(e,s)){if((i=e[s])||null!=i&&!isNaN(i)||(i=""),s=Ae(s),i=Ae(i),null===s||null===i)continue;n.push(s+"="+i)}return n.length?t+n.join("&"):""},_e.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,s={};t=i.exec(e);){var n=Ee(t[1]),r=Ee(t[2]);null===n||null===r||n in s||(s[n]=r)}return s};class qe{constructor(e){this.growingIO=e,this.generateURL=()=>{const{serverUrl:e,projectId:t}=this.growingIO.vdsConfig;return b(e,"http")?`${e}/v3/projects/${t}/collect`:`https://${e}/v3/projects/${t}/collect`},this.commitRequest=e=>{const t=Object.assign({},e),{vdsConfig:i}=this.growingIO;i.forceLogin?this.hoardingQueue.push(t):(this.requestQueue.push(t),this.initiateRequest())},this.initiateRequest=e=>{var t,i;const{plugins:s,vdsConfig:n}=this.growingIO;[...this.hoardingQueue,...this.requestQueue].length>0&&this.requestingNum<this.requestLimit&&((null===(t=null==n?void 0:n.tbConfig)||void 0===t?void 0:t.cloudFuncSend)?null===(i=null==s?void 0:s.gioTaobaoAdapter)||void 0===i||i.singleInvoke():e?this.batchInvoke():this.batchInvokeThrottle())},this.batchInvoke=()=>{var e,t;const{vdsConfig:i,plugins:s,emitter:n}=this.growingIO;let r=[...this.hoardingQueue,...this.requestQueue];r.length>50?(r=r.slice(0,50),this.hoardingQueue.length>50?this.hoardingQueue=this.hoardingQueue.slice(50):(this.requestQueue=this.requestQueue.slice(50-this.hoardingQueue.length),this.hoardingQueue=[])):(this.hoardingQueue=[],this.requestQueue=[]);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 A(t,"requestId"),t}));i.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),n.emit("onSendBefore",{requestData:a}),(null===(e=null==i?void 0:i.tbConfig)||void 0===e?void 0:e.cloudAppId)?null===(t=null==s?void 0:s.gioTaobaoAdapter)||void 0===t||t.tbCloudAppInvoke(a):this.normalBatchInvoke(o,a)},this.batchInvokeThrottle=q(this.batchInvoke,this.growingIO.vdsConfig.uploadInterval,!1,!1),this.normalBatchInvoke=(e,t)=>{var i;const{minipInstance:s,vdsConfig:n,emitter:r,plugins:o}=this.growingIO;this.requestingNum+=1;const a={"content-type":"jdp"===s.platform?"application/json":"application/json;charset=UTF-8"};let l=[...t];const u=n.compress&&(null===(i=null==o?void 0:o.gioCompress)||void 0===i?void 0:i.compressToUTF16);u&&(l=o.gioCompress.compressToUTF16(JSON.stringify(t)),a["X-Compress-Codec"]="1"),s.request({url:`${this.requestURL}?stm=${Date.now()}&compress=${u?"1":"0"}`,header:a,method:"POST",data:l,timeout:n.requestTimeout,fail:t=>{[200,204].includes(t.code)||(p(e)?e.forEach((e=>{this.requestFailFn(e)})):this.requestFailFn(e),D("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,r.emit("onSendAfter",{result:e}),this.initiateRequest()}})},this.requestFailFn=e=>{this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1;const t=this.requestQueue.some((t=>t.requestId===e.requestId));if(!t){let t=setTimeout((()=>{N(this.requestQueue)?(this.requestQueue.push(e),this.initiateRequest()):this.requestQueue.push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue=[],this.requestQueue=[],this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0,this.requestURL=this.generateURL()}}class Ne{constructor(e){var t;this.growingIO=e,this.initUserInfo=()=>{var e;const{minipInstance:t}=this.growingIO,i=[this.uidStorageName,this.userIdStorageName,this.userKeyStorageName,this.gioIdStorageName],s=null!==(e=X(t,i))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,t)=>{this[e]=s[t],"_uid"!==e||this[e]||(this.uid=B())}))},this.saveUserInfo=()=>{const{minipInstance:e}=this.growingIO;ee(e,[{key:this.uidStorageName,value:this.uid},{key:this.userIdStorageName,value:this.userId},{key:this.userKeyStorageName,value:this.userKey},{key:this.gioIdStorageName,value:this.gioId}])};const{inPlugin:i}=this.growingIO;this.uidStorageName=i?"_growing_plugin_uid_":"_growing_uid_",this.userIdStorageName=i?"_growing_plugin_userId_":"_growing_userId_",this.userKeyStorageName=i?"_growing_plugin_userKey_":"_growing_userKey_",this.gioIdStorageName=i?"_growing_plugin_gioId_":"_growing_gioId_",this._sessionId=B(),this._uid=void 0,this._userId=void 0,this._userKey=void 0,this._gioId=void 0,"quickapp"!==(null===(t=this.growingIO)||void 0===t?void 0:t.gioPlatform)&&this.initUserInfo()}get sessionId(){return this._sessionId||(this._sessionId=B()),this._sessionId}set sessionId(e){const t=this._sessionId;this._sessionId=e||B(),t!==this._sessionId&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:this._sessionId,oldSessionId:t})}get uid(){return this._uid}set uid(e){const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this.uidStorageName,this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))}get userId(){return this._userId}set userId(e){const t=this._userId;this._userId=e,t!==this._userId&&(this.growingIO.minipInstance.setStorage(this.userIdStorageName,this._userId),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:e,oldUserId:t})),e&&(this.gioId=e)}get userKey(){return this._userKey}set userKey(e){const t=this._userKey;this._userKey=e,t!==this._userKey&&(this.growingIO.minipInstance.setStorage(this.userKeyStorageName,this._userKey),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:e,oldUserKey:t}))}get gioId(){return this._gioId}set gioId(e){const t=this._gioId;this._gioId=e,t!==this._gioId&&(this.growingIO.minipInstance.setStorage(this.gioIdStorageName,this._gioId),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:e,oldGioId:t}))}}const xe=new class{constructor(){var e;this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.init=e=>{var t;return D("Gio小程序SDK 初始化中...","info"),this.dataStore.initOptions(e),null===(t=this.emitter)||void 0===t||t.emit("OPTION_INITIALIZED",this),this.gioSDKInitialized=!0,this.vdsConfig.subpackage||(J().__gio__=()=>this),this.uploader=new qe(this),this.vdsConfig.idMapping||(this.userStore.userKey=""),this.emitter.emit("SDK_INITIALIZED",this),D("Gio小程序SDK 初始化完成!","success"),this.vdsConfig.forceLogin&&D("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(),!0},this.getOption=e=>this.dataStore.getOption(e),this.setOption=(e,t)=>{if(C(ae).includes(e)){const i=this.dataStore.setOption(e,t);return i&&ae[e]&&D(`已${t?"开启":"关闭"}${ae[e]}`,"info"),i}return D(`不存在可修改的配置项:${e},请检查后重试!`,"warn"),!1},this.getDeviceId=()=>this.userStore.uid,this.identify=e=>{if(this.vdsConfig.forceLogin){if(!ne(e))return void $("identify");const t=y(e).slice(0,1e3);this.userStore.uid=t,this.uploader.hoardingQueue.forEach(((e,i)=>this.uploader.hoardingQueue[i].deviceId=t)),this.dataStore.setOption("forceLogin",!1),this.uploader.initiateRequest(!0)}else $("identify",!1,"forceLogin未开启")},this.setUserId=(e,t)=>{if(ne(e)){const i=this.userStore.gioId;if(e=y(e).slice(0,1e3),t=y(t).slice(0,1e3),this.userStore.userId=e,this.vdsConfig.idMapping&&(this.userStore.userKey=l(t)?"":t),i&&i!==e){this.userStore.sessionId="";const{path:e,query:t,settedTitle:i}=this.dataStore.eventHooks.currentPage;this.dataStore.eventHooks.currentPage.title=i[e]||this.minipInstance.getPageTitle(this.minipInstance.getCurrentPage()),this.dataStore.sendVisit({path:e,query:t})}}else $("setUserId")},this.clearUserId=()=>{this.userStore.userId=void 0,this.userStore.userKey=void 0},this.setUserAttributes=e=>{var t,i;!N(e)&&c(e)?null===(i=null===(t=this.plugins)||void 0===t?void 0:t.gioCustomTracking)||void 0===i||i.buildUserAttributesEvent(e):$("setUserAttributes")},this.track=(e,t)=>{var i,s;((null===(s=null===(i=this.plugins)||void 0===i?void 0:i.gioCustomTracking)||void 0===s?void 0:s.buildCustomEvent)||function(){})(e,Object.assign(Object.assign({},this.dataStore.generalProps),c(t)&&!N(t)?t:{}))},this.trackTimerStart=e=>!!this.vdsConfig.dataCollect&&L(e,(()=>{const t=B();return this.dataStore.trackTimers[t]={eventName:e,leng:0,start:+Date.now()},t})),this.trackTimerPause=e=>{if(e&&this.dataStore.trackTimers[e]){const t=this.dataStore.trackTimers[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=e=>{if(e&&this.dataStore.trackTimers[e]){const t=this.dataStore.trackTimers[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t)=>{if(this.vdsConfig.dataCollect){const i=864e5;if(e&&this.dataStore.trackTimers[e]){const s=this.dataStore.trackTimers[e];if(0!==s.start){const e=+Date.now()-s.start;s.leng=e>0?s.leng+e:0}const{eventContextBuilder:n,eventInterceptor:r}=this.dataStore;return r(Object.assign({eventType:"CUSTOM",eventName:s.eventName,attributes:Z(Object.assign(Object.assign({},t),{event_duration:s.leng>i?0:s.leng/1e3}))},n())),this.removeTimer(e),!0}return D("未查找到对应的计时器,请检查!","error"),!1}return!1},this.removeTimer=e=>!(!e||!this.dataStore.trackTimers[e]||(delete this.dataStore.trackTimers[e],0)),this.clearTrackTimer=()=>{this.dataStore.trackTimers={}},this.setGeneralProps=e=>{c(e)&&!N(e)?(this.dataStore.generalProps=Object.assign(Object.assign({},this.dataStore.generalProps),e),C(this.dataStore.generalProps).forEach((e=>{[void 0,null].includes(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]="")}))):$("setGeneralProps")},this.clearGeneralProps=e=>{p(e)&&!N(e)?e.forEach((e=>{A(this.dataStore.generalProps,e)})):this.dataStore.generalProps={}},this.setPageAttributes=e=>{const{currentPage:t}=this.dataStore.eventHooks,i=this.minipInstance.getCurrentPath();["onLoad","attached"].includes(t.currentLifecycle)&&(t.pageProps[i]=Z(e))},this.updateImpression=()=>{D("当前未集成半自动浏览插件,请集成插件后再调用 updateImpression!","warn")},this.setLocation=(e,t)=>{const i={latitude:e,longitude:t},s=this.dataStore.locationData,n=e=>e>=-180&&180>=e;n(e)&&n(t)&&(s.latitude!==e||s.longitude!==t)&&(this.dataStore.locationData=i)},this.getGioInfo=()=>{const{uid:e,userId:t,userKey:i,sessionId:s}=this.userStore,{projectId:n,appId:r,dataSourceId:o,dataCollect:a,idMapping:l,extraParams:u,ignoreFields:g}=this.vdsConfig,h={gioappid:r,giocs1:t||"",gioplatform:this.platformConfig.platform,gioprojectid:n,gios:s,giou:e};return h.giodatacollect=a,h.giodatasourceid=o,l&&(h.giouserkey=i),N(u)||u.forEach((e=>{g.includes(e)||(h["gio"+e]=this.dataStore.lastVisitEvent[e])})),_e.stringify(h)},this.utils=Object.assign(Object.assign(Object.assign({},j),se),{qs:_e}),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.0.1";try{"quickapp"===this.gioPlatform||d(getApp)&&d(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&D("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Ie,this.minipInstance=new ye(this),this.dataStore=new fe(this),this.userStore=new Ne(this),this.plugins=new Ce(this),this.plugins.innerPluginInit()}},je=function(){const e=arguments[0];if(u(e)&&oe.includes(e)&&xe[e]){const i=f(Array.from(arguments));if("init"===e){const e=!(t=xe).vdsConfig&&!t.gioSDKInitialized||(D("SDK重复初始化,请检查是否重复加载SDK或接入其他平台SDK导致冲突!","warn"),!1),s=(e=>!!I(e)||(D('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "你的应用 AppId", options); 进行初始化!',"error"),!1))(i),n=(e=>{const t=e[0];let i=m(e);return ne(t)?(c(i)&&i||(i={}),{projectId:t,userOptions:i}):(D("SDK初始化失败,accountId 参数不合法!","error"),!1)})(i),r=(e=>{const t=e[1];let i=e[2];const s=m(e);return t&&u(t)?ne(i)?{dataSourceId:t,appId:i,options:s}:(D("SDK初始化失败,appId 参数不合法!","error"),!1):(D("SDK初始化失败,dataSourceId 参数不合法!","error"),!1)})(i);if(e&&s&&n&&r){const{projectId:e}=n,{dataSourceId:t,appId:i,options:s}=r;return xe.init(Object.assign(Object.assign({},s),{projectId:e,dataSourceId:t,appId:i}))}}else if("registerPlugins"===e)xe.registerPlugins(i[0]);else{if(xe.gioSDKInitialized&&xe.vdsConfig)return xe[e](...i);D("SDK未初始化!","error")}}else le.includes(e)?D(`方法 ${y(e)} 已被弃用!`,"warn"):D(`不存在名为 ${y(e)} 的方法调用!`,"error");var t};Y().gdp=je,Y().gioSDKVersion=xe.sdkVersion;const De=H((()=>{var e;return null!==(e=xe.dataStore.eventHooks.growingApp)&&void 0!==e?e:App})),$e=H((()=>{var e;return null!==(e=xe.dataStore.eventHooks.growingPage)&&void 0!==e?e:Page})),He=H((()=>{var e;return null!==(e=xe.dataStore.eventHooks.growingComponent)&&void 0!==e?e:Component})),Ue=H((()=>{var e;return null!==(e=xe.dataStore.eventHooks.growingBehavior)&&void 0!==e?e:Behavior}));export default je;export{De as GioApp,Ue as GioBehavior,He as GioComponent,$e as GioPage};
|
package/dist/taobao.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=e=>["undefined","null"].includes(T(e)),t=e=>"string"===T(e),i=e=>"number"===T(e),n=e=>"boolean"===T(e),s=t=>"[object Object]"==={}.toString.call(t)&&!e(t),r=e=>["function","asyncfunction"].includes(T(e)),o=e=>Array.isArray(e)&&"array"===T(e),a=e=>{try{return Array.from(e)[0]}catch(e){return}},l=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},u=(e,t=1)=>o(e)&&i(t)?e.slice(t>0?t:1,e.length):e,g=e=>{if(o(e)){let t=0;const i=[];for(const n of e)n&&!P(n)&&(i[t++]=n);return i}return e},c=(e,t)=>{if(o(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},h=t=>e(t)?"":""+t,d=(e,t)=>"string"===T(e)?e.split(t):e,p=e=>{if(t(e)){const t=d(e,"");return`${a(t).toLowerCase()}${u(t).join("")}`}return e},v=(e,t)=>e.slice(0,t.length)===t,m={}.hasOwnProperty,f=(t,i)=>!e(t)&&m.call(t,i),I=e=>s(e)?Object.keys(e):[],S=(e,t)=>{I(e).forEach((i=>t(e[i],i)))},y=(e,t)=>{const i=I(e);return!(!s(e)||!s(t)||i.length!==I(t).length||i.map(((i,n)=>s(e[i])?y(e[i],t[i]):e[i]===t[i])).includes(!1))},w=(e,t,i)=>{let n=e;return s(e)?(t.split(".").forEach((e=>{n=n?n[e]:i})),n):i},O=(e,t)=>{if(!s(e))return!1;try{if("string"===T(t))return delete e[t];if("array"===T(t))return t.map((t=>delete e[t]));"object"===T(t)&&t.constructor===RegExp&&I(e).forEach((i=>{t.test(i)&&O(e,i)}))}catch(e){return!1}},b=(e,t=250,i,n)=>{let s,r=0;return"boolean"!==T(i)&&(n=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function u(){r=Date.now(),e.apply(a,o)}n&&!s&&u(),s&&clearTimeout(s),void 0===n&&l>t?u():!0!==i&&(s=setTimeout(n?function(){s=void 0}:u,void 0===n?t-l:t))}},P=e=>o(e)?0===e.length:s(e)?0===I(e).length:!e,T=e=>({}.toString.call(e).slice(8,-1).toLowerCase());var C=Object.freeze({__proto__:null,isNil:e,isString:t,isNaN:e=>"NaN"===h(Number(e)),isNumber:i,isBoolean:n,isObject:s,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:r,isArray:o,isDate:e=>"date"===T(e),fixed:(e,n)=>i(e)?Number(e.toFixed(i(n)?n:2)):t(e)&&"NaN"!==h(Number(e))?Number(Number(e).toFixed(i(n)?n:2)):e,head:a,last:l,drop:u,dropWhile:(e,t)=>o(e)?e.filter((e=>!t(e))):e,compact:g,find:c,isEqualArray:(e,t)=>!(!o(e)||!o(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:h,split:d,lowerFirst:p,upperFirst:e=>{if(t(e)){const t=d(e,"");return`${a(t).toUpperCase()}${u(t).join("")}`}return e},startsWith:v,endsWith:(e,t)=>{const{length:i}=e;let n=i;n>i&&(n=i);const s=n;return n-=t.length,n>=0&&e.slice(n,s)===t},hasOwnProperty:m,has:f,keys:I,forEach:S,isEqual:y,get:w,unset:O,throttle:b,isEmpty:P,typeOf:T,formatDate: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())}});const _=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},k=(e,t=!0,i="参数不合法")=>_(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),E=e=>{try{return e()}catch(e){return}},A=e=>t(e)?e.trim().substring(0,100):e,q=(e,i)=>t(e)&&!P(e)&&e.match(/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/)?i():(_("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),N=()=>"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)})),j=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,x=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,D=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},F=e=>{if(t(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},U=e=>t(e)?e.startsWith("/")?e:"/"+e:"",$=e=>E((()=>{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=E((()=>swan))),e||(e=E((()=>my))),e||(e=E((()=>tt))),e||(e=E((()=>qq))),e||(e=E((()=>ks))),e||(e=E((()=>jd))),e||(e=E((()=>wx))),e}}})),H=e=>E((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return __ttConfig;case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),L=()=>{let e;return!e&&E((()=>swan))&&(e="swan"),!e&&E((()=>tt))&&(e="tt"),!e&&E((()=>qq))&&(e="qq"),!e&&E((()=>my.tb))&&(e="tb"),!e&&E((()=>my))&&(e="my"),!e&&E((()=>ks))&&(e="ks"),!e&&E((()=>jd))&&(e="jd"),!e&&E((()=>wx))&&(e="wx"),e||c(I(global),(e=>h(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},R=e=>I(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),B=()=>{let e=E((()=>getApp({allowDefault:!0})));return e||(e=K()),e},K=()=>{var e;return null!==(e=E((()=>$global)))&&void 0!==e?e:global},Q=t=>{const i={};return s(t)&&S(t,((t,n)=>{const r=h(n).slice(0,100);s(t)?i[r]=Q(t):o(t)?(i[r]=t.slice(0,100),i[r]=i[r].join("||").slice(0,1e3)):i[r]=e(t)?"":h(t).slice(0,1e3)})),i},G=(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()}},M=(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()}},V=t=>I(t||{}).map((i=>i?`${i}=${e(t[i])?"":t[i]}`:"")).join("&"),z=e=>{(v(e,"?")||v(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};var W=Object.freeze({__proto__:null,consoleText:_,callError:k,niceTry:E,niceCallback:(e,t)=>{if(r(e))try{e(t)}catch(e){_("回调执行失败!"+e,"error")}},limitString:A,eventNameValidate:q,guid:N,getScreenHeight:j,getScreenWidth:x,getOS:D,compareVersion:(e="",t="")=>{const i=e=>e.replace(/\s+/g,""),n=e=>e.replace(/[vV]/g,""),s=i(n(e)),r=i(n(t)),o=s.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.parseInt(a(d(e.version,".")),10);return Number.isNaN(t)?0:t}return 0},splitPath:F,normalPath:U,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:$,getPlainConfig:H,getPlainPlatform:L,getSubKeys:R,getAppInst:B,getGlobal:K,limitObject:Q,batchGetStorageSync:G,batchSetStorageSync:M,qsStringify:V,qsParse:z,hashCode:e=>{let t=0;if(P(e)||"boolean"==typeof e)return t;let i=0;for(;i<e.length;)t=(t<<5)-t+e.charCodeAt(i),t&=t,i++;return t}});const J=e=>t(e)&&e.length>0||i(e)&&e>0,Z={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"},subpackage:{type:"boolean",default:!1},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}},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},Y=["clearGeneralProps","clearTrackTimer","clearUserId","getDeviceId","getGioInfo","getOption","identify","init","registerPlugins","removeTimer","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart","updateImpression","getABTest"],X={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},ee=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],te=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],ie=[...te,"appChannel","language","platformVersion"];class ne{constructor(e){this.growingIO=e,this.main=e=>{var t,i,n,s,r;const{sdkVersion:o,vdsConfig:a,platformConfig:l,minipInstance:u,userStore:g,dataStore:{scene:c,eventHooks:h,locationData:d,lastVisitEvent:p}}=this.growingIO,{systemInfo:v={},network:m={}}=u,{brand:f,model:I,platform:S,language:y,version:w}=v,b={appChannel:"scn:"+(c||"NA"),appVersion:a.version,dataSourceId:a.dataSourceId,deviceBrand:f,deviceId:g.uid,deviceModel:I,deviceType:D(S,l.name),domain:a.appId,language:y,latitude:null==d?void 0:d.latitude,longitude:null==d?void 0:d.longitude,networkState:(null==m?void 0:m.networkType)||(null==m?void 0:m.type)||(null==m?void 0:m.subtype),operatingSystem:D(S,l.name),path:(null===(t=h.currentPage)||void 0===t?void 0:t.path)?null===(i=h.currentPage)||void 0===i?void 0:i.path:p.path,platform:l.platform,platformVersion:l.name+(w?" "+w:""),query:(null===(n=h.currentPage)||void 0===n?void 0:n.path)?null===(s=h.currentPage)||void 0===s?void 0:s.query:p.query,screenHeight:j(v),screenWidth:x(v),sdkVersion:o,sessionId:g.sessionId,title:(null===(r=h.currentPage)||void 0===r?void 0:r.title)||u.getPageTitle(u.getCurrentPage()),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:g.userId};return a.idMapping&&(b.userKey=g.userKey),P(a.ignoreFields)||a.ignoreFields.forEach((e=>{O(b,e)})),P(e)?b:Object.assign(Object.assign({},b),e)}}}function se(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))}class re{constructor(t){this.growingIO=t,this.main=(e,t)=>{var i,n;const s=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:u,dataStore:g,dataStore:{shareOut:c,keepAlive:h,lastCloseTime:d,eventHooks:p,saveStorageInfo:v}}=this.growingIO;r.emit("minipLifecycle",{event:"App "+e,timestamp:s,params:null!==(i=t[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",e,s);const m=l.listeners.app;switch(r.emit("onComposeBefore",{event:"App "+e,params:null!==(n=t[0])&&void 0!==n?n:{}}),e){case m.appCreate:case m.appShow:{const{path:e,query:i}=this.enterParamsParse(t[0]);!c&&a.originalSource&&g.setOriginalSource({path:e,query:i}),d?(Date.now()-d>h||g.lastScene&&g.scene!==g.lastScene)&&(o.sessionId="",p.currentPage.time=void 0,this.buildVisitEvent({path:e,query:i})):(this.growingIO.dataStore.lastVisitEvent={path:e,query:i},this.buildVisitEvent({path:e,query:i}));break}case m.appClose:g.lastScene=g.scene,g.lastCloseTime=Date.now(),v(),o.saveUserInfo(),this.buildCloseEvent(),a.forceLogin||u.initiateRequest(!0)}},this.enterParamsParse=e=>{const{gioPlatform:t,minipInstance:i,dataStore:n}=this.growingIO;let r="",o="";const a=(e,t={})=>{r=e,o=I(t).map((e=>`${e}=${t[e]}`)).join("&")};if("quickapp"!==t&&i.minip.canIUse("getEnterOptionsSync")){const{path:t,query:r,scene:l,referrerInfo:u}=i.minip.getEnterOptionsSync()||{},g=e.query||r;if(a(e.path||t,g),n.scene=e.scene||l,!P(u)&&s(null==u?void 0:u.extraData)){let e=[];S(u.extraData,((t,i)=>{!f(g,i)&&["string","number","boolean"].includes(T(t))&&e.push(`${i}=${t}`)}));const t=e.join("&");o=o&&t?`${o}&${t}`:o||t}}else{const{path:t,query:i}=e;a(t,i),this.parseScene(e)}return{path:r,query:o}},this.parseScene=e=>{var t;const{minipInstance:i,gioPlatform:n,dataStore:s}=this.growingIO;let r;if("quickapp"===n){const{extra:e,type:t}=i.getAppSource();r=(null==e?void 0:e.scene)||t}else P(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:s.scene="NA");s.scene=r},this.buildVisitEvent=t=>{const{dataStore:i,vdsConfig:n,minipInstance:s}=this.growingIO,{originalSourceName:r,getOriginalSource:o,eventContextBuilder:a,eventInterceptor:l}=i,u=o(),g=(null==t?void 0:t.query)||"";let c=Object.assign({eventType:"VISIT"},a({path:(null==t?void 0:t.path)||"",query:"string"===T(g)?g:V(g)}));n.originalSource&&!e(u)&&(c=Object.assign(Object.assign({},c),u),n.dataCollect&&s.removeStorageSync(r)),l(c)},this.buildCloseEvent=()=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:t}}=this.growingIO;t(Object.assign({eventType:"APP_CLOSED"},e()))}}}class oe{constructor(e){this.growingIO=e,this.parsePage=(e,t)=>{var i;const n=e.route||e.uri||e.__route__||(null===(i=null==e?void 0:e.$page)||void 0===i?void 0:i.fullPath)||"";P(t)?this.query=void 0:this.query=this.getQuery(t),this.path!==n&&(this.time=Date.now()),this.path=n,this.title=this.settedTitle[this.path]||this.growingIO.minipInstance.getPageTitle(e||this.growingIO.minipInstance.getCurrentPage())},this.getQuery=e=>{const t=Object.assign({},e);return O(t,"wxShoppingListScene"),V(t)},this.getReferralPage=()=>{const{minipInstance:e,dataStore:{lastPageEvent:t,scene:i}}=this.growingIO;return(null==t?void 0:t.path)||(i?`scn:${e.scnPrefix}${i}`:null)},this.saveShareId=e=>{(null==e?void 0:e.gioShareId)&&(this.queryShareId=e.gioShareId)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=U(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=U(t+(i?"?"+i:"")),e.query=i,e},this.query=void 0,this.settedTitle={},this.pageProps={}}buildShareQuery(e){var t,i,n;const s=F(null!==(t=e.path)&&void 0!==t?t:"");let r=this.path,o={},u=f(e,"path");return u&&(r=a(s),o=z(l(s))||{}),P(o)&&(o=z(null!==(i=e.query)&&void 0!==i?i:"")||{}),!u&&P(o)&&(o=z(null!==(n=this.query)&&void 0!==n?n:"")||{}),[r,V(o)]}}class ae{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var n,s;const o=Date.now(),{emitter:a,minipInstance:l,plugins:u,vdsConfig:g,platformConfig:c,dataStore:{shareOut:h,eventHooks:d,toggleShareOut:p,buildAppMessageEvent:v,buildTimelineEvent:m,buildAddFavorites:f},inPlugin:I}=this.growingIO,{currentPage:S}=d;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=l.getCurrentPage()),e.route||(e.route=l.getCurrentPath(e));const y=e.route||e.uri||e.__route__||(null===(n=null==e?void 0:e.$page)||void 0===n?void 0:n.fullPath)||"";a.emit("minipLifecycle",{event:"Page "+t,timestamp:o,params:{page:e,args:i[0]}}),g.debug&&console.log("Page:",y,"#",t,o),this.prevEvent[t]=Date.now();const b=c.listeners.page;switch(a.emit("onComposeBefore",{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),S.lastLifecycle=S.currentLifecycle,S.currentLifecycle=t,t){case b.pageLoad:this.argQuery[y]=w(e,"options")||w(e,"__displayReporter.query")||w(e,"$page.query")||w(e,"$wx.__displayReporter.query")||i[0]||{},O(this.argQuery[y],"$taroTimestamp"),S.parsePage(e,this.argQuery[y]);break;case b.pageShow:I?(S.parsePage(e,this.argQuery[y]),S.path||(S.path=`/插件${g.appId}}`,S.title=`/插件${g.appId}}`),this.buildPageEvent()):h&&d.currentPage.time||(S.parsePage(e,this.argQuery[y]),d.currentPage.time=Date.now(),this.buildPageEvent()),p(!1),S.saveShareId(this.argQuery[y]);break;case b.pageHide:case b.pageUnload:break;case b.shareApp:p(!0),g.followShare&&v(i);break;case b.shareTime:g.followShare&&m(i);break;case b.addFavorites:f(i);break;case b.tabTap:{const e=null===(s=null==u?void 0:u.gioEventAutoTracking)||void 0===s?void 0:s.buildTabClickEvent;g.autotrack&&e&&r(e)&&e(i[0]);break}}t===b.pageUnload&&(S.pageProps[y]=void 0)},this.buildPageEvent=e=>{var t;const{dataStore:{eventContextBuilder:i,eventInterceptor:n,eventHooks:s}}=this.growingIO,{currentPage:r}=s,o=Object.assign(Object.assign({eventType:"PAGE",referralPage:r.getReferralPage()},i()),{timestamp:r.time});P(r.pageProps[o.path])||(o.attributes=r.pageProps[o.path]),!P(e)&&e.path&&(o.path=e.path,o.query=e.query,o.title=null!==(t=e.title)&&void 0!==t?t:o.title),n(o)},this.prevEvent={},this.argQuery={}}}class le{constructor(e){var t,i;this.growingIO=e,this.isNormalFc=(e,t)=>r(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),f(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),f(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),f(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{o(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{r(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=()=>{})}))},this.lifeFcEffects=(e,t,i)=>{const n=this;return["onShareTimeline","onAddToFavorites"].includes(e)?function(...s){let r=t.apply(this,s);"onShareTimeline"===e&&n.growingIO.vdsConfig.followShare&&(r=n.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=n.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(s);return r&&o.push(r),n[`def${i}Cbs`][e].apply(this,o),r}:function(...s){var r;return se(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=yield t.apply(this,s))&&void 0!==r?r:{},"promise"===T(o.promise)){const e=function(){return se(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((n=>{e=n,t(Object.assign({},e)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield e()),O(o,"promise")}n.growingIO.vdsConfig.followShare&&(o=n.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(s);o&&a.push(o),n[`def${i}Cbs`][e].apply(this,a)}catch(e){_(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,s)),n.growingIO.emitter.emit("minipLifecycle",{event:`${i} ${e}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(s)}}),o}))}},this.customFcEffects=(e,t)=>{const i=this;return function(...n){var s,o;let a;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let t=n[0]||{};f(t,"type")&&((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))||(t=n[n.length-1]),((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))&&i.actionEventTypes.includes(t.type)&&(r(i.actionEffects)||(i.actionEffects=(null===(o=null===(s=i.growingIO.plugins)||void 0===s?void 0:s.gioEventAutoTracking)||void 0===o?void 0:o.main)||function(){}),null==i||i.actionEffects(t,e))}catch(e){_(e,"error")}return a=t.apply(this,n),a}},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=>this.originalApp(this.appOverriding(e)),this.growingPage=e=>this.originalPage(this.pageOverriding(e)),this.growingComponent=e=>this.originalComponent(this.componentOverriding(e)),this.growingBehavior=e=>this.originalBehavior(this.componentOverriding(e)),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,n=i.hooks;if(this.setAppEffectCbs(),this.setPageEffectCbs(),e.includes("App"))try{n.App&&!this.appHooked&&(App=function(...e){return t.growingApp(e[0])},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{n.Page&&!this.pageHooked&&(Page=function(...e){return t.growingPage(e[0])},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{n.Component&&!this.componentHooked&&(Component=function(...e){return t.growingComponent(e[0])},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{n.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.growingBehavior(e[0])},this.behaviorHooked=!0)}catch(e){}},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;t.canHook?(this.nativeGrowing(),K().GioApp=E((()=>null!==App&&void 0!==App?App:window.GioApp)),K().GioPage=E((()=>null!==Page&&void 0!==Page?Page:window.GioPage)),K().GioComponent=E((()=>null!==Component&&void 0!==Component?Component:window.GioComponent)),K().GioBehavior=E((()=>Behavior))):"quickapp"===i&&(window.GioApp=function(...t){return e.appOverriding(t[0])},window.GioPage=function(...t){return e.pageOverriding(t[0])},window.GioComponent=function(...t){return e.pageOverriding(t[0])})};const n=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=n.appHandlers,this.pageHandlers=n.pageHandlers,this.actionEventTypes=n.actionEventTypes,this.originalApp=n.originalApp,this.originalPage=n.originalPage,this.originalComponent=n.originalComponent,this.originalBehavior=null!==(i=n.originalBehavior)&&void 0!==i?i:function(){},this.appEffects=new re(this.growingIO),this.pageEffects=new ae(this.growingIO),this.currentPage=new oe(this.growingIO)}}class ue{constructor(i){var s,l;this.growingIO=i,this.ALLOW_SETTING_KEYS=I(Z),this.gsidStorageName="_growing_gsid_",this.originalSourceName="gdp_original_source",this.initStorageInfo=()=>{const{minipInstance:e}=this.growingIO,t=B(),i=t.gio_gsid?t.gio_gsid:Number.parseInt(e.getStorageSync(this.gsidStorageName),10);this._gsid=Number.isNaN(i)||i>=1e9||1>i?1:i,this._stid=this._gsid,i!==this._gsid&&e.setStorageSync(this.gsidStorageName,this._gsid)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=this._gsid,M(e,[{key:this.gsidStorageName,value:this._gsid}])},this.setOriginalSource=({path:t,query:i})=>{const{minipInstance:n}=this.growingIO;if(e(this.getOriginalSource())){const e={path:t,query:i,title:""};n.setStorageSync(this.originalSourceName,JSON.stringify(e))}},this.getOriginalSource=()=>{const{minipInstance:e}=this.growingIO;return E((()=>JSON.parse(e.getStorageSync(this.originalSourceName))))},this.initOptions=e=>{var t,i,n,s,r,a,l,u;const{projectId:g,dataSourceId:c,appId:h}=e,d={};this.ALLOW_SETTING_KEYS.forEach((t=>{const i=Z[t].type;(o(i)?i.includes(T(e[t])):T(e[t])===Z[t].type)?"ignoreFields"===t?d.ignoreFields=e.ignoreFields.filter((e=>te.includes(e))):"extraParams"===t?d.extraParams=e.extraParams.filter((e=>ie.includes(e))):d[t]=e[t]:d[t]=Z[t].default})),d.uploadInterval=Math.round(d.uploadInterval),(Number.isNaN(d.uploadInterval)||0>d.uploadInterval||d.uploadInterval>2e3)&&(d.uploadInterval=1e3),d.enableIdMapping&&!d.idMapping&&(d.idMapping=!0),d.pluginMode&&(this.growingIO.inPlugin=!0),this.growingIO.vdsConfig=Object.assign(Object.assign({},d),{projectId:g,dataSourceId:c,appId:h,performance:{monitor:null===(i=null===(t=d.performance)||void 0===t?void 0:t.monitor)||void 0===i||i,exception:null===(s=null===(n=d.performance)||void 0===n?void 0:n.exception)||void 0===s||s,network:null!==(a=null===(r=d.performance)||void 0===r?void 0:r.network)&&void 0!==a&&a}}),this.keepAlive=d.keepAlive,d.dataCollect||_("已关闭数据采集","info"),d.autotrack||_("已关闭无埋点","info");const{plugins:p,inPlugin:v,minipInstance:m}=this.growingIO,{uniVue:f,taro:I}=d;f||I||(this.growingIO.platformConfig.canHook=!0),v&&!["tbp","jdp"].includes(m.platform)||this.eventHooks.initEventHooks(),f&&(null===(l=null==p?void 0:p.gioUniAppAdapter)||void 0===l||l.main()),I&&(null===(u=null==p?void 0:p.gioTaroAdapter)||void 0===u||u.main())},this.setOption=(e,i)=>{var n;const{vdsConfig:s,userStore:r,uploader:o,emitter:a}=this.growingIO,l=t(e)&&this.ALLOW_SETTING_KEYS.includes(e),u=l&&typeof i===(null===(n=Z[e])||void 0===n?void 0:n.type);if(l&&u){if("dataCollect"===e&&!1===s.dataCollect&&!0===i){let e=setTimeout((()=>{r.sessionId="";const{path:t,query:i,settedTitle:n}=this.eventHooks.currentPage;this.eventHooks.currentPage.title=n[t]||this.growingIO.minipInstance.getPageTitle(this.growingIO.minipInstance.getCurrentPage()),this.sendVisit({path:t,query:i}),this.eventHooks.currentPage.time=Date.now(),this.sendPage({path:t,query:i}),clearTimeout(e),e=null}),0)}return s[e]=i,"serverUrl"===e&&(null==o||o.generateURL()),a.emit("OPTION_CHANGE",{optionName:e,optionValue:i}),!0}return k("setOption > "+e),!1},this.getOption=t=>{const{vdsConfig:i}=this.growingIO;return t&&f(i,h(t))?i[h(t)]:e(t)?Object.assign({},i):void k("getOption > "+t)},this.toggleShareOut=e=>{n(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=e=>{this.eventHooks.appEffects.buildVisitEvent(null!=e?e:this.lastVisitEvent),this.eventHooks.currentPage.time=Date.now()},this.sendPage=e=>{this.eventHooks.pageEffects.buildPageEvent(e)},this.eventConverter=e=>{const{vdsConfig:t,dataStore:i,uploader:n}=this.growingIO;if(t.dataCollect){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=i.gsid,this.growingIO.dataStore.gsid+=1);const t={};S(e,((e,i)=>{var n;if("element"===i){const i=null!==(n=a(e))&&void 0!==n?n:{};S(i,((e,i)=>{P(e)&&0!==e||(t[i]=e)}))}else P(e)&&0!==e||(t[i]=e)})),this.growingIO.emitter.emit("onComposeAfter",{composedEvent:t}),n.commitRequest(Object.assign(Object.assign({},t),{requestId:N()}))}},this.eventInterceptor=e=>{const{systemInfo:t,network:i}=this.growingIO.minipInstance;P(t)||P(i)?this.interceptEvents.push(e):P(this.interceptEvents)?this.eventConverter(e):([...this.interceptEvents,e].forEach((e=>{const t=Object.assign(Object.assign({},e),this.eventContextBuilder({path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(t)})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!P(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{const t=Object.assign(Object.assign({},e),this.eventContextBuilder({path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(t)})),this.interceptEvents=[])},this.buildAppMessageEvent=e=>{var t;const i=e[0];let n;2>e.length?1===e.length&&(n=i):n=e[1];const{dataStore:{eventContextBuilder:s,eventInterceptor:r}}=this.growingIO,o=((null==n?void 0:n.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share",attributes:Object.assign({$from:i.from,$target:null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.id,$share_title:null==n?void 0:n.title,$share_path:a(o),$share_query:o[1]},null==n?void 0:n.attributes)},s()))},this.buildTimelineEvent=e=>{var t;const i=e[0];let n;2>e.length?1===e.length&&(n=i):n=e[1];const{dataStore:{eventContextBuilder:s,eventInterceptor:r}}=this.growingIO,o=((null==n?void 0:n.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline",attributes:Object.assign({$target:null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.id,$share_title:null==n?void 0:n.title,$share_path:a(o),$share_query:o[1]},null==n?void 0:n.attributes)},s()))},this.buildAddFavorites=e=>{const t=e[0];let i;2>e.length?1===e.length&&(i=t):i=e[1];const{dataStore:{eventContextBuilder:n,eventInterceptor:s}}=this.growingIO,r=((null==i?void 0:i.path)||"").split("?");s(Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites",attributes:{$share_title:null==i?void 0:i.title,$share_path:a(r),$share_query:r[1]}},n()))},this.initStorageInfo(),this.eventContextBuilder=new ne(this.growingIO).main,this.shareOut=!1,this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[],this.eventHooks=new le(this.growingIO),this.growingIO.emitter.on("onComposeAfter",(({composedEvent:e})=>{"VISIT"!==e.eventType&&"vst"!==e.t||(this.lastVisitEvent=e),"PAGE"!==e.eventType&&"page"!==e.t||(this.lastPageEvent=e)})),r(null===(s=this.growingIO.minipInstance.minip)||void 0===s?void 0:s.onAppHide)&&this.growingIO.minipInstance.minip.onAppHide((()=>{S(this.trackTimers,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))})),r(null===(l=this.growingIO.minipInstance.minip)||void 0===l?void 0:l.onAppShow)&&this.growingIO.minipInstance.minip.onAppShow((()=>{S(this.trackTimers,(e=>{e.start&&(e.start=+Date.now())}))})),this.growingIO.emitter.on("OPTION_CHANGE",(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.growingIO.clearTrackTimer()}))}get gsid(){const e=B(),t=R(e);return!P(t)&&e.gio_gsid?e.gio_gsid:this._gsid}set gsid(e){const t=Number.parseInt(e,10);this._gsid=Number.isNaN(t)||e>=1e9||1>e?1:e,B().gio_gsid=this._gsid,10>this._gsid-this._stid||this.saveStorageInfo()}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 ge={scnPrefix:"",appHandlers:["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange"],pageHandlers:["onLoad","onShow","onReady","onHide","onShareAppMessage","onTabItemTap","onUnload","onPullDownRefresh","onReachBottom","onResize"],actionEventTypes:["onclick","tap","onTap","longpress","longTap","blur","change","onChange","submit","confirm","getuserinfo","getphonenumber","contact","mouseup"],originalApp:E((()=>App)),originalPage:E((()=>Page)),originalComponent:E((()=>Component)),originalBehavior:E((()=>Behavior)),canHook:!0,hooks:{App:!0,Page:!0,Component:!0,Behavior:!0},listeners:{app:{appLaunch:"onLaunch",appShow:"onShow",appClose:"onHide"},page:{pageLoad:"onLoad",pageShow:"onShow",pageReady:"onReady",pageHide:"onHide",pageUnload:"onUnload",tabTap:"onTabItemTap",shareApp:"onShareAppMessage"},actions:{click:["onclick","tap","longpress","longTap","getuserinfo","getphonenumber","contact","mouseup"],change:["blur","change","confirm"],submit:["submit"]}}},ce=Object.assign(Object.assign({},ge),{pageHandlers:[...ge.pageHandlers,"onInit","didMount","didUnmount"],listeners:Object.assign(Object.assign({},ge.listeners),{page:Object.assign(Object.assign({},ge.listeners.page),{onInit:"onInit",didMount:"didMount",didUnmount:"didUnmount"})}),name:"Taobao",platform:"tbp",scnPrefix:"tbp_",hooks:Object.assign(Object.assign({},null==ge?void 0:ge.hooks),{Behavior:!1})});class he{constructor(e){this.growingIO=e,this.minip=$("tb"),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.settedTitle[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:n})=>{var s;return null===(s=this.minip)||void 0===s?void 0:s.getImageInfo({src:e,success:t,fail:i,complete:n})},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=()=>E((()=>l(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 i,n;let s="";const r=H(L());try{const o=(null==e?void 0:e.data)||e.$data||{};if(s=t(null==o?void 0:o.gioPageTitle)?null==o?void 0:o.gioPageTitle:"",0===s.length){const t=r.page[e.route]||r.page[e.route+".html"];s=t?t.window.navigationBarTitleText:r.global.window.navigationBarTitleText}if(0===s.length){const t=null===(n=null===(i=null==r?void 0:r.tabBar)||void 0===i?void 0:i.list)||void 0===n?void 0:n.find((t=>t.pagePath===e.route||t.pagePath===e.route+".html"));s=(null==t?void 0:t.text)||""}}catch(e){return""}return A(s)},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return s(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 n;i&&(t={value:t,expiredAt:i}),null===(n=this.minip)||void 0===n||n.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:n,method:s,success:o,fail:a,complete:l})=>{var u;const g=null===(u=this.minip)||void 0===u?void 0:u.request({url:e,data:t,header:i,headers:i,timeout:n,method:s,success:o,fail:a,complete:l});let c=setTimeout((()=>{(null==g?void 0:g.abort)&&r(null==g?void 0:g.abort)&&(null==g||g.abort()),clearTimeout(c),c=null}),(n||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:i,scnPrefix:n}}=this.growingIO;this.platform=i,this.scnPrefix=n,this.growingIO.emitter.on("OPTION_INITIALIZED",(()=>{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 de extends he{constructor(e){super(e),this.growingIO=e,this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBar,i=this;t&&Object.defineProperty(this.minip,"setNavigationBar",{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.settedTitle[e]=t}return t.apply(this,arguments)}})},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,"selectAll")},this.getStorageSync=e=>{const{data:t}=my.getStorageSync({key:e});return t},this.setStorageSync=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorageSync({key:e,data:t})},this.hookSetTitle()}}let pe;var ve={name:"gioTaobaoAdapter",method:class{constructor(e){this.growingIO=e,this.getSceneInfo=(e,t)=>{var i;null===(i=this.growingIO.minipInstance.minip)||void 0===i||i.getRelationAppInfo({success:i=>t(e,i),fail:()=>t(e,{})})},this.getRelationAppInfo=e=>{var t;null===(t=this.growingIO.minipInstance.minip)||void 0===t||t.getRelationAppInfo({success:e,fail:()=>e({})})},this.singleInvoke=()=>{var e;const{vdsConfig:t,emitter:i,uploader:n}=this.growingIO;if(n.hoardingQueue=[...n.hoardingQueue].filter((e=>(n.retryIds[e.requestId]||0)<n.retryLimit)),n.requestQueue=[...n.requestQueue].filter((e=>(n.retryIds[e.requestId]||0)<n.retryLimit)),pe.isEmpty([...n.hoardingQueue,...n.requestQueue]))return;let s=null!==(e=n.hoardingQueue.shift())&&void 0!==e?e:n.requestQueue.shift();t.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(s,null,2)),i.emit("onSendBefore",{requestData:s}),this.cloudFuncInvoke(s)},this.cloudFuncInvoke=e=>{var t,i;const{vdsConfig:n,emitter:s,uploader:r}=this.growingIO,{serverUrl:o,projectId:a,tbConfig:l}=n,u=pe.niceTry((()=>{var e;return null!==(e=getApp())&&void 0!==e?e:$global})),g=null!==(t=l.cloud)&&void 0!==t?t:u.cloud;(null===(i=null==g?void 0:g.function)||void 0===i?void 0:i.invoke)?(r.requestingNum+=1,g.function.invoke(l.cloudFuncName,{domain:o,path:`/v3/projects/${a}/collect`,params:{stm:Date.now()},body:e},l.cloudFuncHandler).then((t=>{r.requestingNum-=1,t.success?s.emit("onSendAfter",{result:t}):(r.requestFailFn(e),pe.consoleText("请求失败! "+JSON.stringify(t),"error")),r.initiateRequest()})).catch((t=>{r.requestingNum-=1,r.requestFailFn(e),pe.consoleText("请求失败! "+JSON.stringify(t),"error"),r.initiateRequest()}))):pe.consoleText("请求失败!无法获取 cloud 对象,请检查 tbConfig 配置项!","error")};const{utils:t,emitter:i}=this.growingIO;pe=t,i.on("OPTION_INITIALIZED",(e=>{const{inPlugin:t,dataStore:i}=e;t&&(pe.getGlobal().Component=function(...e){return i.eventHooks.componentOverriding(e[0])})})),i.on("minipLifecycle",(({event:e})=>{const{dataStore:t,vdsConfig:i}=this.growingIO,n="小部件"+i.appId;switch(e){case"Page onInit":{const e=(e,i)=>{var s;const r=pe.keys(e).map((t=>`${t}=${e[t]}`)).join("&");t.scene=null!==(s=i.sceneId)&&void 0!==s?s:"",t.sendVisit({path:n,query:r,title:n})};this.getRelationAppInfo((t=>this.getSceneInfo(t,e)))}break;case"Page didMount":t.sendPage({path:n,title:n})}}))}tbCloudAppInvoke(e){var t,i;const{vdsConfig:n,emitter:s,uploader:r}=this.growingIO,{serverUrl:o,projectId:a,tbConfig:l}=n,u=pe.niceTry((()=>{var e;return null!==(e=getApp())&&void 0!==e?e:$global})),g=null!==(t=l.cloud)&&void 0!==t?t:u.cloud;(null===(i=null==g?void 0:g.application)||void 0===i?void 0:i.httpRequest)?(r.requestingNum+=1,g.application.httpRequest({path:l.path,method:"POST",headers:{"Content-Type":"application/json;charset=UTF-8"},params:{serverUrl:o,projectId:a,stm:Date.now()},body:e,exts:{cloudAppId:l.cloudAppId}}).then((t=>{r.requestingNum-=1,t.success?s.emit("onSendAfter",{result:t}):(pe.isArray(e)?e.forEach((e=>{r.requestFailFn(e)})):r.requestFailFn(e),pe.consoleText("请求失败! "+JSON.stringify(t),"error")),r.initiateRequest()})).catch((t=>{r.requestingNum-=1,pe.isArray(e)?e.forEach((e=>{r.requestFailFn(e)})):r.requestFailFn(e),pe.consoleText("请求失败! "+JSON.stringify(t),"error"),r.initiateRequest()}))):pe.consoleText("请求失败!无法获取 cloud 对象,请检查 tbConfig 配置项!","error")}}};let me;const fe={};function Ie(e,t,i){var n=e;t.map((function(e,s){n[e]=s==t.length-1?i:n[e]||{},n=n[e]}))}Ie(fe,["pluginsIn","gioCustomTracking"],{name:"gioCustomTracking",method:class{constructor(e){this.growingIO=e,this.getDynamicAttributes=e=>(me.isNil(e)||me.keys(e).forEach((t=>{me.isFunction(e[t])?e[t]=e[t]():me.isArray(e[t])||(e[t]=me.toString(e[t]))})),e),this.buildCustomEvent=(e,t)=>{me.eventNameValidate(e,(()=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:n}}=this.growingIO;n(Object.assign({eventType:"CUSTOM",eventName:e,attributes:me.limitObject(this.getDynamicAttributes(me.isObject(t)&&!me.isEmpty(t)?t:void 0))},i()))}))},this.buildUserAttributesEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i,lastVisitEvent:n}}=this.growingIO,s=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES",attributes:me.limitObject(e)},t());s.path||(s.path=n.path,s.query=n.query,s.title=n.title),i(s)},me=this.growingIO.utils}}}),Ie(fe,["pluginsIn","gioTaobaoAdapter"],ve);class Se{constructor(e){this.growingIO=e,this.innerPluginInit=()=>{I(fe.pluginsIn).forEach((e=>{const{name:t,method:i}=fe.pluginsIn[e];this.pluginItems.find((e=>e.name===t))||this.pluginItems.push({name:p(t||e),method:i||(e=>{})})})),P(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var n;const s=t||this.pluginItems.find((t=>t.name===e));if(null===(n=this.growingIO)||void 0===n?void 0:n.plugins[e])return _(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!s)return _(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return this.growingIO.plugins[e]=new s.method(this.growingIO,i),t&&_("加载插件:"+e,"info"),!0}catch(t){return _(`插件【${e}】加载异常 ${t}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>this.install(t.name,e?t:void 0,t.options)))},this.uninstall=e=>{var t;O(this.pluginItems,e);const i=O(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||_(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>_(`插件执行错误 ${e.name} ${t}`,"error"),this.onComposeBefore=e=>{this.pluginItems.forEach((t=>{var i;const n=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onComposeBefore;if(n&&r(n))try{n(e)}catch(e){this.lifeError(t,e)}}))},this.onComposeAfter=e=>{this.pluginItems.forEach((t=>{var i;const n=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onComposeAfter;if(n&&r(n))try{n(e)}catch(e){this.lifeError(t,e)}}))},this.onSendBefore=e=>{this.pluginItems.forEach((t=>{var i;const n=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onSendBefore;if(n&&r(n))try{n(e)}catch(e){this.lifeError(t,e)}}))},this.onSendAfter=e=>{this.pluginItems.forEach((t=>{var i;const n=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onSendAfter;if(n&&r(n))try{n(e)}catch(e){this.lifeError(t,e)}}))},this.pluginItems=[],this.growingIO.emitter.on("onComposeBefore",this.onComposeBefore),this.growingIO.emitter.on("onComposeAfter",this.onComposeAfter),this.growingIO.emitter.on("onSendBefore",this.onSendBefore),this.growingIO.emitter.on("onSendAfter",this.onSendAfter)}}var ye={},we={}.hasOwnProperty;function Oe(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function be(e){try{return encodeURIComponent(e)}catch(e){return null}}ye.stringify=function(e,t){t=t||"";var i,n,s=[];for(n in"string"!=typeof t&&(t="?"),e)if(we.call(e,n)){if((i=e[n])||null!=i&&!isNaN(i)||(i=""),n=be(n),i=be(i),null===n||null===i)continue;s.push(n+"="+i)}return s.length?t+s.join("&"):""},ye.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,n={};t=i.exec(e);){var s=Oe(t[1]),r=Oe(t[2]);null===s||null===r||s in n||(n[s]=r)}return n};class Pe{constructor(e){this.growingIO=e,this.generateURL=()=>{const{serverUrl:e,projectId:t}=this.growingIO.vdsConfig;return v(e,"http")?`${e}/v3/projects/${t}/collect`:`https://${e}/v3/projects/${t}/collect`},this.commitRequest=e=>{const t=Object.assign({},e),{vdsConfig:i}=this.growingIO;i.forceLogin?this.hoardingQueue.push(t):(this.requestQueue.push(t),this.initiateRequest())},this.initiateRequest=e=>{var t,i;const{plugins:n,vdsConfig:s}=this.growingIO;[...this.hoardingQueue,...this.requestQueue].length>0&&this.requestingNum<this.requestLimit&&((null===(t=null==s?void 0:s.tbConfig)||void 0===t?void 0:t.cloudFuncSend)?null===(i=null==n?void 0:n.gioTaobaoAdapter)||void 0===i||i.singleInvoke():e?this.batchInvoke():this.batchInvokeThrottle())},this.batchInvoke=()=>{var e,t;const{vdsConfig:i,plugins:n,emitter:s}=this.growingIO;let r=[...this.hoardingQueue,...this.requestQueue];r.length>50?(r=r.slice(0,50),this.hoardingQueue.length>50?this.hoardingQueue=this.hoardingQueue.slice(50):(this.hoardingQueue=[],this.requestQueue=this.requestQueue.slice(50-this.hoardingQueue.length))):(this.hoardingQueue=[],this.requestQueue=[]);let o=r.filter((e=>(this.retryIds[e.requestId]||0)<=this.retryLimit));if(P(o))return;const a=o.map((e=>{const t=Object.assign({},e);return O(t,"requestId"),t}));i.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),s.emit("onSendBefore",{requestData:a}),(null===(e=null==i?void 0:i.tbConfig)||void 0===e?void 0:e.cloudAppId)?null===(t=null==n?void 0:n.gioTaobaoAdapter)||void 0===t||t.tbCloudAppInvoke(a):this.normalBatchInvoke(o,a)},this.batchInvokeThrottle=b(this.batchInvoke,this.growingIO.vdsConfig.uploadInterval,!1,!1),this.normalBatchInvoke=(e,t)=>{var i;const{minipInstance:n,vdsConfig:s,emitter:r,plugins:a}=this.growingIO;this.requestingNum+=1;const l={"content-type":"jdp"===n.platform?"application/json":"application/json;charset=UTF-8"};let u=[...t];const g=s.compress&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);g&&(u=a.gioCompress.compressToUTF16(JSON.stringify(t)),l["X-Compress-Codec"]="1"),n.request({url:`${this.requestURL}?stm=${Date.now()}&compress=${g?"1":"0"}`,header:l,method:"POST",data:u,timeout:this.requestTimeout,fail:t=>{[200,204].includes(t.code)||(o(e)?e.forEach((e=>{this.requestFailFn(e)})):this.requestFailFn(e),_("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,r.emit("onSendAfter",{result:e}),this.initiateRequest()}})},this.requestFailFn=e=>{if(this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1,!this.requestQueue.some((t=>t.requestId===e.requestId))){let t=setTimeout((()=>{P(this.requestQueue)?(this.requestQueue.push(e),this.initiateRequest()):this.requestQueue.push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue=[],this.requestQueue=[],this.requestLimit=3,this.requestTimeout=5e3,this.retryLimit=2,this.retryIds={},this.requestingNum=0,this.requestURL=this.generateURL()}}class Te{constructor(e){var t;this.growingIO=e,this.initUserInfo=()=>{var e;const{minipInstance:t}=this.growingIO,i=[this.uidStorageName,this.userIdStorageName,this.userKeyStorageName,this.gioIdStorageName],n=null!==(e=G(t,i))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,t)=>{this[e]=n[t],"_uid"!==e||this[e]||(this.uid=N())}))},this.saveUserInfo=()=>{const{minipInstance:e}=this.growingIO;M(e,[{key:this.uidStorageName,value:this.uid},{key:this.userIdStorageName,value:this.userId},{key:this.userKeyStorageName,value:this.userKey},{key:this.gioIdStorageName,value:this.gioId}])};const{inPlugin:i}=this.growingIO;this.uidStorageName=i?"_growing_plugin_uid_":"_growing_uid_",this.userIdStorageName=i?"_growing_plugin_userId_":"_growing_userId_",this.userKeyStorageName=i?"_growing_plugin_userKey_":"_growing_userKey_",this.gioIdStorageName=i?"_growing_plugin_gioId_":"_growing_gioId_",this._sessionId=N(),this._uid=void 0,this._userId=void 0,this._userKey=void 0,this._gioId=void 0,"quickapp"!==(null===(t=this.growingIO)||void 0===t?void 0:t.gioPlatform)&&this.initUserInfo()}get sessionId(){return this._sessionId||(this._sessionId=N()),this._sessionId}set sessionId(e){const t=this._sessionId;this._sessionId=e||N(),t!==this._sessionId&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:this._sessionId,oldSessionId:t})}get uid(){return this._uid}set uid(e){const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this.uidStorageName,this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))}get userId(){return this._userId}set userId(e){const t=this._userId;this._userId=e,t!==this._userId&&(this.growingIO.minipInstance.setStorage(this.userIdStorageName,this._userId),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:e,oldUserId:t})),e&&(this.gioId=e)}get userKey(){return this._userKey}set userKey(e){const t=this._userKey;this._userKey=e,t!==this._userKey&&(this.growingIO.minipInstance.setStorage(this.userKeyStorageName,this._userKey),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:e,oldUserKey:t}))}get gioId(){return this._gioId}set gioId(e){const t=this._gioId;this._gioId=e,t!==this._gioId&&(this.growingIO.minipInstance.setStorage(this.gioIdStorageName,this._gioId),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:e,oldGioId:t}))}}const Ce=new class{constructor(){var t;this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.init=e=>{var t;return _("Gio小程序SDK 初始化中...","info"),this.dataStore.initOptions(e),null===(t=this.emitter)||void 0===t||t.emit("OPTION_INITIALIZED",this),this.gioSDKInitialized=!0,this.vdsConfig.subpackage||(B().__gio__=()=>this),this.uploader=new Pe(this),this.vdsConfig.idMapping||(this.userStore.userKey=""),this.emitter.emit("SDK_INITIALIZED",this),_("Gio小程序SDK 初始化完成!","success"),this.vdsConfig.forceLogin&&_("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(),!0},this.getOption=e=>this.dataStore.getOption(e),this.setOption=(e,t)=>{if(I(X).includes(e)){const i=this.dataStore.setOption(e,t);return i&&X[e]&&_(`已${t?"开启":"关闭"}${X[e]}`,"info"),i}return _(`不存在可修改的配置项:${e},请检查后重试!`,"warn"),!1},this.getDeviceId=()=>this.userStore.uid,this.identify=e=>{if(this.vdsConfig.forceLogin){if(!J(e))return void k("identify");const t=h(e).slice(0,1e3);this.userStore.uid=t,this.uploader.hoardingQueue.forEach(((e,i)=>this.uploader.hoardingQueue[i].deviceId=t)),this.dataStore.setOption("forceLogin",!1),this.uploader.initiateRequest(!0)}else k("identify",!1,"forceLogin未开启")},this.setUserId=(t,i)=>{if(J(t)){const n=this.userStore.gioId;if(t=h(t).slice(0,1e3),i=h(i).slice(0,1e3),this.userStore.userId=t,this.vdsConfig.idMapping&&(this.userStore.userKey=e(i)?"":i),n&&n!==t){this.userStore.sessionId="";const{path:e,query:t,settedTitle:i}=this.dataStore.eventHooks.currentPage;this.dataStore.eventHooks.currentPage.title=i[e]||this.minipInstance.getPageTitle(this.minipInstance.getCurrentPage()),this.dataStore.sendVisit({path:e,query:t})}}else k("setUserId")},this.clearUserId=()=>{this.userStore.userId=void 0,this.userStore.userKey=void 0},this.setUserAttributes=e=>{var t,i;!P(e)&&s(e)?null===(i=null===(t=this.plugins)||void 0===t?void 0:t.gioCustomTracking)||void 0===i||i.buildUserAttributesEvent(e):k("setUserAttributes")},this.track=(e,t)=>{var i,n;((null===(n=null===(i=this.plugins)||void 0===i?void 0:i.gioCustomTracking)||void 0===n?void 0:n.buildCustomEvent)||function(){})(e,Object.assign(Object.assign({},this.dataStore.generalProps),s(t)&&!P(t)?t:{}))},this.trackTimerStart=e=>!!this.vdsConfig.dataCollect&&q(e,(()=>{const t=N();return this.dataStore.trackTimers[t]={eventName:e,leng:0,start:+Date.now()},t})),this.trackTimerPause=e=>{if(e&&this.dataStore.trackTimers[e]){const t=this.dataStore.trackTimers[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=e=>{if(e&&this.dataStore.trackTimers[e]){const t=this.dataStore.trackTimers[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t)=>{if(this.vdsConfig.dataCollect){const i=864e5;if(e&&this.dataStore.trackTimers[e]){const n=this.dataStore.trackTimers[e];if(0!==n.start){const e=+Date.now()-n.start;n.leng=e>0?n.leng+e:0}const{eventContextBuilder:s,eventInterceptor:r}=this.dataStore;return r(Object.assign(Object.assign({eventType:"CUSTOM",eventName:n.eventName,attributes:Q(Object.assign(Object.assign({},t),{event_duration:n.leng>i?0:n.leng/1e3}))},s()),{customEventType:0})),this.removeTimer(e),!0}return _("未查找到对应的计时器,请检查!","error"),!1}return!1},this.removeTimer=e=>!(!e||!this.dataStore.trackTimers[e]||(delete this.dataStore.trackTimers[e],0)),this.clearTrackTimer=()=>{this.dataStore.trackTimers={}},this.setGeneralProps=e=>{s(e)&&!P(e)?(this.dataStore.generalProps=Object.assign(Object.assign({},this.dataStore.generalProps),e),I(this.dataStore.generalProps).forEach((e=>{[void 0,null].includes(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]="")}))):k("setGeneralProps")},this.clearGeneralProps=e=>{o(e)&&!P(e)?e.forEach((e=>{O(this.dataStore.generalProps,e)})):this.dataStore.generalProps={}},this.setPageAttributes=e=>{const{currentPage:t}=this.dataStore.eventHooks,i=this.minipInstance.getCurrentPath();["onLoad","attached"].includes(t.currentLifecycle)&&(t.pageProps[i]=Q(e))},this.updateImpression=()=>{_("当前未集成半自动浏览插件,请集成插件后再调用 updateImpression!","warn")},this.setLocation=(e,t)=>{const i={latitude:e,longitude:t},n=this.dataStore.locationData,s=e=>e>=-180&&180>=e;s(e)&&s(t)&&(n.latitude!==e||n.longitude!==t)&&(this.dataStore.locationData=i)},this.getGioInfo=()=>{const{uid:e,userId:t,userKey:i,sessionId:n}=this.userStore,{projectId:s,appId:r,dataSourceId:o,dataCollect:a,idMapping:l,extraParams:u,ignoreFields:g}=this.vdsConfig,c={gioappid:r,giocs1:t||"",gioplatform:this.platformConfig.platform,gioprojectid:s,gios:n,giou:e};return c.giodatacollect=a,c.giodatasourceid=o,l&&(c.giouserkey=i),P(u)||u.forEach((e=>{g.includes(e)||(c["gio"+e]=this.dataStore.lastVisitEvent[e])})),ye.stringify(c)},this.utils=Object.assign(Object.assign(Object.assign({},C),W),{qs:ye}),this.emitter={all:t=t||new Map,on:function(e,i){var n=t.get(e);n?n.push(i):t.set(e,[i])},off:function(e,i){var n=t.get(e);n&&(i?n.splice(n.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var n=t.get(e);n&&n.slice().map((function(e){e(i)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,i)}))}},this.gioPlatform="tb",this.gioFramework="native",this.sdkVersion="4.0.0";try{"quickapp"===this.gioPlatform||r(getApp)&&r(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&_("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=ce,this.minipInstance=new de(this),this.dataStore=new ue(this),this.userStore=new Te(this),this.plugins=new Se(this),this.plugins.innerPluginInit()}},_e=function(){const e=arguments[0];if(t(e)&&Y.includes(e)&&Ce[e]){const n=u(Array.from(arguments));if("init"===e){const e=!(i=Ce).vdsConfig&&!i.gioSDKInitialized||(_("SDK重复初始化,请检查是否重复加载SDK或接入其他平台SDK导致冲突!","warn"),!1),r=(e=>!!g(e)||(_('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "你的应用 AppId", options); 进行初始化!',"error"),!1))(n),o=(e=>{const t=e[0];let i=l(e);return J(t)?(s(i)&&i||(i={}),{projectId:t,userOptions:i}):(_("SDK初始化失败,accountId 参数不合法!","error"),!1)})(n),a=(e=>{const i=e[1];let n=e[2];const s=l(e);return i&&t(i)?J(n)?{dataSourceId:i,appId:n,options:s}:(_("SDK初始化失败,appId 参数不合法!","error"),!1):(_("SDK初始化失败,dataSourceId 参数不合法!","error"),!1)})(n);if(e&&r&&o&&a){const{projectId:e}=o,{dataSourceId:t,appId:i,options:n}=a;return Ce.init(Object.assign(Object.assign({},n),{projectId:e,dataSourceId:t,appId:i}))}}else if("registerPlugins"===e)Ce.registerPlugins(n[0]);else{if(Ce.gioSDKInitialized&&Ce.vdsConfig)return Ce[e](...n);_("SDK未初始化!","error")}}else ee.includes(e)?_(`方法 ${h(e)} 已被弃用!`,"warn"):_(`不存在名为 ${h(e)} 的方法调用!`,"error");var i};K().gdp=_e,K().gioSDKVersion=Ce.sdkVersion;const ke=E((()=>{var e;return null!==(e=Ce.dataStore.eventHooks.growingApp)&&void 0!==e?e:App})),Ee=E((()=>{var e;return null!==(e=Ce.dataStore.eventHooks.growingPage)&&void 0!==e?e:Page})),Ae=E((()=>{var e;return null!==(e=Ce.dataStore.eventHooks.growingComponent)&&void 0!==e?e:Component})),qe=E((()=>{var e;return null!==(e=Ce.dataStore.eventHooks.growingBehavior)&&void 0!==e?e:Behavior}));export default _e;export{ke as GioApp,qe as GioBehavior,Ae as GioComponent,Ee as GioPage};
|
|
1
|
+
const e=e=>["undefined","null"].includes(T(e)),t=e=>"string"===T(e),i=e=>"number"===T(e),n=e=>"boolean"===T(e),s=t=>"[object Object]"==={}.toString.call(t)&&!e(t),r=e=>["function","asyncfunction"].includes(T(e)),o=e=>Array.isArray(e)&&"array"===T(e),a=e=>{try{return Array.from(e)[0]}catch(e){return}},l=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},u=(e,t=1)=>o(e)&&i(t)?e.slice(t>0?t:1,e.length):e,g=e=>{if(o(e)){let t=0;const i=[];for(const n of e)n&&!P(n)&&(i[t++]=n);return i}return e},c=(e,t)=>{if(o(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},h=t=>e(t)?"":""+t,d=(e,t)=>"string"===T(e)?e.split(t):e,p=e=>{if(t(e)){const t=d(e,"");return`${a(t).toLowerCase()}${u(t).join("")}`}return e},v=(e,t)=>e.slice(0,t.length)===t,m={}.hasOwnProperty,f=(t,i)=>!e(t)&&m.call(t,i),I=e=>s(e)?Object.keys(e):[],S=(e,t)=>{I(e).forEach((i=>t(e[i],i)))},y=(e,t)=>{const i=I(e);return!(!s(e)||!s(t)||i.length!==I(t).length||i.map(((i,n)=>s(e[i])?y(e[i],t[i]):e[i]===t[i])).includes(!1))},w=(e,t,i)=>{let n=e;return s(e)?(t.split(".").forEach((e=>{n=n?n[e]:i})),n):i},O=(e,t)=>{if(!s(e))return!1;try{if("string"===T(t))return delete e[t];if("array"===T(t))return t.map((t=>delete e[t]));"object"===T(t)&&t.constructor===RegExp&&I(e).forEach((i=>{t.test(i)&&O(e,i)}))}catch(e){return!1}},b=(e,t=250,i,n)=>{let s,r=0;return"boolean"!==T(i)&&(n=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function u(){r=Date.now(),e.apply(a,o)}n&&!s&&u(),s&&clearTimeout(s),void 0===n&&l>t?u():!0!==i&&(s=setTimeout(n?function(){s=void 0}:u,void 0===n?t-l:t))}},P=e=>o(e)?0===e.length:s(e)?0===I(e).length:!e,T=e=>({}.toString.call(e).slice(8,-1).toLowerCase());var C=Object.freeze({__proto__:null,isNil:e,isString:t,isNaN:e=>"NaN"===h(Number(e)),isNumber:i,isBoolean:n,isObject:s,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:r,isArray:o,isDate:e=>"date"===T(e),fixed:(e,n)=>i(e)?Number(e.toFixed(i(n)?n:2)):t(e)&&"NaN"!==h(Number(e))?Number(Number(e).toFixed(i(n)?n:2)):e,head:a,last:l,drop:u,dropWhile:(e,t)=>o(e)?e.filter((e=>!t(e))):e,compact:g,find:c,isEqualArray:(e,t)=>!(!o(e)||!o(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:h,split:d,lowerFirst:p,upperFirst:e=>{if(t(e)){const t=d(e,"");return`${a(t).toUpperCase()}${u(t).join("")}`}return e},startsWith:v,endsWith:(e,t)=>{const{length:i}=e;let n=i;n>i&&(n=i);const s=n;return n-=t.length,n>=0&&e.slice(n,s)===t},hasOwnProperty:m,has:f,keys:I,forEach:S,isEqual:y,get:w,unset:O,throttle:b,isEmpty:P,typeOf:T,formatDate: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())}});const _=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},k=(e,t=!0,i="参数不合法")=>_(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),E=e=>{try{return e()}catch(e){return}},A=e=>t(e)?e.trim().substring(0,100):e,q=(e,i)=>t(e)&&!P(e)&&e.match(/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/)?i():(_("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),N=()=>"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)})),j=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,x=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,D=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},F=e=>{if(t(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},U=e=>t(e)?e.startsWith("/")?e:"/"+e:"",$=e=>E((()=>{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=E((()=>swan))),e||(e=E((()=>my))),e||(e=E((()=>tt))),e||(e=E((()=>qq))),e||(e=E((()=>ks))),e||(e=E((()=>jd))),e||(e=E((()=>wx))),e}}})),H=e=>E((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return __ttConfig;case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),L=()=>{let e;return!e&&E((()=>swan))&&(e="swan"),!e&&E((()=>tt))&&(e="tt"),!e&&E((()=>qq))&&(e="qq"),!e&&E((()=>my.tb))&&(e="tb"),!e&&E((()=>my))&&(e="my"),!e&&E((()=>ks))&&(e="ks"),!e&&E((()=>jd))&&(e="jd"),!e&&E((()=>wx))&&(e="wx"),e||c(I(global),(e=>h(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},R=e=>I(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),B=()=>{let e=E((()=>getApp({allowDefault:!0})));return e||(e=K()),e},K=()=>{var e;return null!==(e=E((()=>$global)))&&void 0!==e?e:global},Q=t=>{const i={};return s(t)&&S(t,((t,n)=>{const r=h(n).slice(0,100);s(t)?i[r]=Q(t):o(t)?(i[r]=t.slice(0,100),i[r]=i[r].join("||").slice(0,1e3)):i[r]=e(t)?"":h(t).slice(0,1e3)})),i},G=(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()}},M=(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()}},V=t=>I(t||{}).map((i=>i?`${i}=${e(t[i])?"":t[i]}`:"")).join("&"),z=e=>{(v(e,"?")||v(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};var W=Object.freeze({__proto__:null,consoleText:_,callError:k,niceTry:E,niceCallback:(e,t)=>{if(r(e))try{e(t)}catch(e){_("回调执行失败!"+e,"error")}},limitString:A,eventNameValidate:q,guid:N,getScreenHeight:j,getScreenWidth:x,getOS:D,compareVersion:(e="",t="")=>{const i=e=>e.replace(/\s+/g,""),n=e=>e.replace(/[vV]/g,""),s=i(n(e)),r=i(n(t)),o=s.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.parseInt(a(d(e.version,".")),10);return Number.isNaN(t)?0:t}return 0},splitPath:F,normalPath:U,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:$,getPlainConfig:H,getPlainPlatform:L,getSubKeys:R,getAppInst:B,getGlobal:K,limitObject:Q,batchGetStorageSync:G,batchSetStorageSync:M,qsStringify:V,qsParse:z,hashCode:e=>{let t=0;if(P(e)||"boolean"==typeof e)return t;let i=0;for(;i<e.length;)t=(t<<5)-t+e.charCodeAt(i),t&=t,i++;return t}});const J=e=>t(e)&&e.length>0||i(e)&&e>0,Z={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}},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},Y=["clearGeneralProps","clearTrackTimer","clearUserId","getDeviceId","getGioInfo","getOption","identify","init","registerPlugins","removeTimer","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart","updateImpression","getABTest"],X={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},ee=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],te=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],ie=[...te,"appChannel","language","platformVersion"];class ne{constructor(e){this.growingIO=e,this.main=e=>{var t,i,n,s,r;const{sdkVersion:o,vdsConfig:a,platformConfig:l,minipInstance:u,userStore:g,dataStore:{scene:c,eventHooks:h,locationData:d,lastVisitEvent:p}}=this.growingIO,{systemInfo:v={},network:m={}}=u,{brand:f,model:I,platform:S,language:y,version:w}=v,b={appChannel:"scn:"+(c||"NA"),appVersion:a.version,dataSourceId:a.dataSourceId,deviceBrand:f,deviceId:g.uid,deviceModel:I,deviceType:D(S,l.name),domain:a.appId,language:y,latitude:null==d?void 0:d.latitude,longitude:null==d?void 0:d.longitude,networkState:(null==m?void 0:m.networkType)||(null==m?void 0:m.type)||(null==m?void 0:m.subtype),operatingSystem:D(S,l.name),path:(null===(t=h.currentPage)||void 0===t?void 0:t.path)?null===(i=h.currentPage)||void 0===i?void 0:i.path:p.path,platform:l.platform,platformVersion:l.name+(w?" "+w:""),query:(null===(n=h.currentPage)||void 0===n?void 0:n.path)?null===(s=h.currentPage)||void 0===s?void 0:s.query:p.query,screenHeight:j(v),screenWidth:x(v),sdkVersion:o,sessionId:g.sessionId,title:(null===(r=h.currentPage)||void 0===r?void 0:r.title)||u.getPageTitle(u.getCurrentPage()),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:g.userId};return a.idMapping&&(b.userKey=g.userKey),P(a.ignoreFields)||a.ignoreFields.forEach((e=>{O(b,e)})),P(e)?b:Object.assign(Object.assign({},b),e)}}}function se(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))}class re{constructor(t){this.growingIO=t,this.main=(e,t)=>{var i,n;const s=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:u,dataStore:g,dataStore:{shareOut:c,keepAlive:h,lastCloseTime:d,eventHooks:p,saveStorageInfo:v}}=this.growingIO;r.emit("minipLifecycle",{event:"App "+e,timestamp:s,params:null!==(i=t[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",e,s);const m=l.listeners.app;switch(r.emit("onComposeBefore",{event:"App "+e,params:null!==(n=t[0])&&void 0!==n?n:{}}),e){case m.appCreate:case m.appShow:{const{path:e,query:i}=this.enterParamsParse(t[0]);!c&&a.originalSource&&g.setOriginalSource({path:e,query:i}),d?(Date.now()-d>h||g.lastScene&&g.scene!==g.lastScene)&&(o.sessionId="",p.currentPage.time=void 0,this.buildVisitEvent({path:e,query:i})):(this.growingIO.dataStore.lastVisitEvent={path:e,query:i},this.buildVisitEvent({path:e,query:i}));break}case m.appClose:g.lastScene=g.scene,g.lastCloseTime=Date.now(),v(),o.saveUserInfo(),this.buildCloseEvent(),a.forceLogin||u.initiateRequest(!0)}},this.enterParamsParse=e=>{const{gioPlatform:t,minipInstance:i,dataStore:n}=this.growingIO;let r="",o="";const a=(e,t={})=>{r=e,o=I(t).map((e=>`${e}=${t[e]}`)).join("&")};if("quickapp"!==t&&i.minip.canIUse("getEnterOptionsSync")){const{path:t,query:r,scene:l,referrerInfo:u}=i.minip.getEnterOptionsSync()||{},g=e.query||r;if(a(e.path||t,g),n.scene=e.scene||l,!P(u)&&s(null==u?void 0:u.extraData)){let e=[];S(u.extraData,((t,i)=>{!f(g,i)&&["string","number","boolean"].includes(T(t))&&e.push(`${i}=${t}`)}));const t=e.join("&");o=o&&t?`${o}&${t}`:o||t}}else{const{path:t,query:i}=e;a(t,i),this.parseScene(e)}return{path:r,query:o}},this.parseScene=e=>{var t;const{minipInstance:i,gioPlatform:n,dataStore:s}=this.growingIO;let r;if("quickapp"===n){const{extra:e,type:t}=i.getAppSource();r=(null==e?void 0:e.scene)||t}else P(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:s.scene="NA");s.scene=r},this.buildVisitEvent=t=>{const{dataStore:i,vdsConfig:n,minipInstance:s}=this.growingIO,{originalSourceName:r,getOriginalSource:o,eventContextBuilder:a,eventInterceptor:l}=i,u=o(),g=(null==t?void 0:t.query)||"";let c=Object.assign({eventType:"VISIT"},a({path:(null==t?void 0:t.path)||"",query:"string"===T(g)?g:V(g)}));n.originalSource&&!e(u)&&(c=Object.assign(Object.assign({},c),u),n.dataCollect&&s.removeStorageSync(r)),l(c)},this.buildCloseEvent=()=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:t}}=this.growingIO;t(Object.assign({eventType:"APP_CLOSED"},e()))}}}class oe{constructor(e){this.growingIO=e,this.parsePage=(e,t)=>{var i;const n=e.route||e.uri||e.__route__||(null===(i=null==e?void 0:e.$page)||void 0===i?void 0:i.fullPath)||"";P(t)?this.query=void 0:this.query=this.getQuery(t),this.path!==n&&(this.time=Date.now()),this.path=n,this.title=this.settedTitle[this.path]||this.growingIO.minipInstance.getPageTitle(e||this.growingIO.minipInstance.getCurrentPage())},this.getQuery=e=>{const t=Object.assign({},e);return O(t,"wxShoppingListScene"),V(t)},this.getReferralPage=()=>{const{minipInstance:e,dataStore:{lastPageEvent:t,scene:i}}=this.growingIO;return(null==t?void 0:t.path)||(i?`scn:${e.scnPrefix}${i}`:null)},this.saveShareId=e=>{(null==e?void 0:e.gioShareId)&&(this.queryShareId=e.gioShareId)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=U(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=U(t+(i?"?"+i:"")),e.query=i,e},this.query=void 0,this.settedTitle={},this.pageProps={}}buildShareQuery(e){var t,i,n;const s=F(null!==(t=e.path)&&void 0!==t?t:"");let r=this.path,o={},u=f(e,"path");return u&&(r=a(s),o=z(l(s))||{}),P(o)&&(o=z(null!==(i=e.query)&&void 0!==i?i:"")||{}),!u&&P(o)&&(o=z(null!==(n=this.query)&&void 0!==n?n:"")||{}),[r,V(o)]}}class ae{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var n,s;const o=Date.now(),{emitter:a,minipInstance:l,plugins:u,vdsConfig:g,platformConfig:c,dataStore:{shareOut:h,eventHooks:d,toggleShareOut:p,buildAppMessageEvent:v,buildTimelineEvent:m,buildAddFavorites:f},inPlugin:I}=this.growingIO,{currentPage:S}=d;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=l.getCurrentPage()),e.route||(e.route=l.getCurrentPath(e));const y=e.route||e.uri||e.__route__||(null===(n=null==e?void 0:e.$page)||void 0===n?void 0:n.fullPath)||"";a.emit("minipLifecycle",{event:"Page "+t,timestamp:o,params:{page:e,args:i[0]}}),g.debug&&console.log("Page:",y,"#",t,o),this.prevEvent[t]=Date.now();const b=c.listeners.page;switch(a.emit("onComposeBefore",{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),S.lastLifecycle=S.currentLifecycle,S.currentLifecycle=t,t){case b.pageLoad:this.argQuery[y]=w(e,"options")||w(e,"__displayReporter.query")||w(e,"$page.query")||w(e,"$wx.__displayReporter.query")||i[0]||{},O(this.argQuery[y],"$taroTimestamp"),S.parsePage(e,this.argQuery[y]);break;case b.pageShow:I?(S.parsePage(e,this.argQuery[y]),S.path||(S.path=`/插件${g.appId}}`,S.title=`/插件${g.appId}}`),this.buildPageEvent()):h&&d.currentPage.time||(S.parsePage(e,this.argQuery[y]),d.currentPage.time=Date.now(),this.buildPageEvent()),p(!1),S.saveShareId(this.argQuery[y]);break;case b.pageHide:case b.pageUnload:break;case b.shareApp:p(!0),g.followShare&&v(i);break;case b.shareTime:g.followShare&&m(i);break;case b.addFavorites:f(i);break;case b.tabTap:{const e=null===(s=null==u?void 0:u.gioEventAutoTracking)||void 0===s?void 0:s.buildTabClickEvent;g.autotrack&&e&&r(e)&&e(i[0]);break}}t===b.pageUnload&&(S.pageProps[y]=void 0)},this.buildPageEvent=e=>{var t;const{dataStore:{eventContextBuilder:i,eventInterceptor:n,eventHooks:s}}=this.growingIO,{currentPage:r}=s,o=Object.assign(Object.assign({eventType:"PAGE",referralPage:r.getReferralPage()},i()),{timestamp:r.time});P(r.pageProps[o.path])||(o.attributes=r.pageProps[o.path]),!P(e)&&e.path&&(o.path=e.path,o.query=e.query,o.title=null!==(t=e.title)&&void 0!==t?t:o.title),n(o)},this.prevEvent={},this.argQuery={}}}class le{constructor(e){var t,i;this.growingIO=e,this.isNormalFc=(e,t)=>r(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),f(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),f(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),f(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{o(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{r(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=()=>{})}))},this.lifeFcEffects=(e,t,i)=>{const n=this;return["onShareTimeline","onAddToFavorites"].includes(e)?function(...s){let r=t.apply(this,s);"onShareTimeline"===e&&n.growingIO.vdsConfig.followShare&&(r=n.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=n.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(s);return r&&o.push(r),n[`def${i}Cbs`][e].apply(this,o),r}:function(...s){var r;return se(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=yield t.apply(this,s))&&void 0!==r?r:{},"promise"===T(o.promise)){const e=function(){return se(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((n=>{e=n,t(Object.assign({},e)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield e()),O(o,"promise")}n.growingIO.vdsConfig.followShare&&(o=n.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(s);o&&a.push(o),n[`def${i}Cbs`][e].apply(this,a)}catch(e){_(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,s)),n.growingIO.emitter.emit("minipLifecycle",{event:`${i} ${e}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(s)}}),o}))}},this.customFcEffects=(e,t)=>{const i=this;return function(...n){var s,o;let a;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let t=n[0]||{};f(t,"type")&&((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))||(t=n[n.length-1]),((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))&&i.actionEventTypes.includes(t.type)&&(r(i.actionEffects)||(i.actionEffects=(null===(o=null===(s=i.growingIO.plugins)||void 0===s?void 0:s.gioEventAutoTracking)||void 0===o?void 0:o.main)||function(){}),null==i||i.actionEffects(t,e))}catch(e){_(e,"error")}return a=t.apply(this,n),a}},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=>this.originalApp(this.appOverriding(e)),this.growingPage=e=>this.originalPage(this.pageOverriding(e)),this.growingComponent=e=>this.originalComponent(this.componentOverriding(e)),this.growingBehavior=e=>this.originalBehavior(this.componentOverriding(e)),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,n=i.hooks;if(this.setAppEffectCbs(),this.setPageEffectCbs(),e.includes("App"))try{n.App&&!this.appHooked&&(App=function(...e){return t.growingApp(e[0])},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{n.Page&&!this.pageHooked&&(Page=function(...e){return t.growingPage(e[0])},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{n.Component&&!this.componentHooked&&(Component=function(...e){return t.growingComponent(e[0])},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{n.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.growingBehavior(e[0])},this.behaviorHooked=!0)}catch(e){}},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;t.canHook?(this.nativeGrowing(),K().GioApp=E((()=>null!==App&&void 0!==App?App:window.GioApp)),K().GioPage=E((()=>null!==Page&&void 0!==Page?Page:window.GioPage)),K().GioComponent=E((()=>null!==Component&&void 0!==Component?Component:window.GioComponent)),K().GioBehavior=E((()=>Behavior))):"quickapp"===i&&(window.GioApp=function(...t){return e.appOverriding(t[0])},window.GioPage=function(...t){return e.pageOverriding(t[0])},window.GioComponent=function(...t){return e.pageOverriding(t[0])})};const n=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=n.appHandlers,this.pageHandlers=n.pageHandlers,this.actionEventTypes=n.actionEventTypes,this.originalApp=n.originalApp,this.originalPage=n.originalPage,this.originalComponent=n.originalComponent,this.originalBehavior=null!==(i=n.originalBehavior)&&void 0!==i?i:function(){},this.appEffects=new re(this.growingIO),this.pageEffects=new ae(this.growingIO),this.currentPage=new oe(this.growingIO)}}class ue{constructor(i){var s,l;this.growingIO=i,this.ALLOW_SETTING_KEYS=I(Z),this.gsidStorageName="_growing_gsid_",this.originalSourceName="gdp_original_source",this.initStorageInfo=()=>{const{minipInstance:e}=this.growingIO,t=B(),i=t.gio_gsid?t.gio_gsid:Number.parseInt(e.getStorageSync(this.gsidStorageName),10);this._gsid=Number.isNaN(i)||i>=1e9||1>i?1:i,this._stid=this._gsid,i!==this._gsid&&e.setStorageSync(this.gsidStorageName,this._gsid)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=this._gsid,M(e,[{key:this.gsidStorageName,value:this._gsid}])},this.setOriginalSource=({path:t,query:i})=>{const{minipInstance:n}=this.growingIO;if(e(this.getOriginalSource())){const e={path:t,query:i,title:""};n.setStorageSync(this.originalSourceName,JSON.stringify(e))}},this.getOriginalSource=()=>{const{minipInstance:e}=this.growingIO;return E((()=>JSON.parse(e.getStorageSync(this.originalSourceName))))},this.initOptions=e=>{var t,i,n,s,r,a,l,u;const{projectId:g,dataSourceId:c,appId:h}=e,d={};this.ALLOW_SETTING_KEYS.forEach((t=>{const i=Z[t].type;(o(i)?i.includes(T(e[t])):T(e[t])===Z[t].type)?"ignoreFields"===t?d.ignoreFields=e.ignoreFields.filter((e=>te.includes(e))):"extraParams"===t?d.extraParams=e.extraParams.filter((e=>ie.includes(e))):d[t]=e[t]:d[t]=Z[t].default})),d.uploadInterval=Math.round(d.uploadInterval),(Number.isNaN(d.uploadInterval)||0>d.uploadInterval||d.uploadInterval>2e3)&&(d.uploadInterval=1e3),d.enableIdMapping&&!d.idMapping&&(d.idMapping=!0),d.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(d.requestTimeout))&&d.requestTimeout>0||(d.requestTimeout=5e3),this.growingIO.vdsConfig=Object.assign(Object.assign({},d),{projectId:g,dataSourceId:c,appId:h,performance:{monitor:null===(i=null===(t=d.performance)||void 0===t?void 0:t.monitor)||void 0===i||i,exception:null===(s=null===(n=d.performance)||void 0===n?void 0:n.exception)||void 0===s||s,network:null!==(a=null===(r=d.performance)||void 0===r?void 0:r.network)&&void 0!==a&&a}}),this.keepAlive=d.keepAlive,d.dataCollect||_("已关闭数据采集","info"),d.autotrack||_("已关闭无埋点","info");const{plugins:p,inPlugin:v,minipInstance:m}=this.growingIO,{uniVue:f,taro:I}=d;f||I||(this.growingIO.platformConfig.canHook=!0),v&&!["tbp","jdp"].includes(m.platform)||this.eventHooks.initEventHooks(),f&&(null===(l=null==p?void 0:p.gioUniAppAdapter)||void 0===l||l.main()),I&&(null===(u=null==p?void 0:p.gioTaroAdapter)||void 0===u||u.main())},this.setOption=(e,i)=>{var n;const{vdsConfig:s,userStore:r,uploader:o,emitter:a}=this.growingIO,l=t(e)&&this.ALLOW_SETTING_KEYS.includes(e),u=l&&typeof i===(null===(n=Z[e])||void 0===n?void 0:n.type);if(l&&u){if("dataCollect"===e&&!1===s.dataCollect&&!0===i){let e=setTimeout((()=>{r.sessionId="";const{path:t,query:i,settedTitle:n}=this.eventHooks.currentPage;this.eventHooks.currentPage.title=n[t]||this.growingIO.minipInstance.getPageTitle(this.growingIO.minipInstance.getCurrentPage()),this.sendVisit({path:t,query:i}),this.eventHooks.currentPage.time=Date.now(),this.sendPage({path:t,query:i}),clearTimeout(e),e=null}),0)}return s[e]=i,"serverUrl"===e&&(null==o||o.generateURL()),a.emit("OPTION_CHANGE",{optionName:e,optionValue:i}),!0}return k("setOption > "+e),!1},this.getOption=t=>{const{vdsConfig:i}=this.growingIO;return t&&f(i,h(t))?i[h(t)]:e(t)?Object.assign({},i):void k("getOption > "+t)},this.toggleShareOut=e=>{n(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=e=>{this.eventHooks.appEffects.buildVisitEvent(null!=e?e:this.lastVisitEvent),this.eventHooks.currentPage.time=Date.now()},this.sendPage=e=>{this.eventHooks.pageEffects.buildPageEvent(e)},this.eventConverter=e=>{const{vdsConfig:t,dataStore:i,uploader:n}=this.growingIO;if(t.dataCollect){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=i.gsid,this.growingIO.dataStore.gsid+=1);const t={};S(e,((e,i)=>{var n;if("element"===i){const i=null!==(n=a(e))&&void 0!==n?n:{};S(i,((e,i)=>{P(e)&&0!==e||(t[i]=e)}))}else P(e)&&0!==e||(t[i]=e)})),this.growingIO.emitter.emit("onComposeAfter",{composedEvent:t}),n.commitRequest(Object.assign(Object.assign({},t),{requestId:N()}))}},this.eventInterceptor=e=>{const{systemInfo:t,network:i}=this.growingIO.minipInstance;P(t)||P(i)?this.interceptEvents.push(e):P(this.interceptEvents)?this.eventConverter(e):([...this.interceptEvents,e].forEach((e=>{const t=Object.assign(Object.assign({},e),this.eventContextBuilder({path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(t)})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!P(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{const t=Object.assign(Object.assign({},e),this.eventContextBuilder({path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(t)})),this.interceptEvents=[])},this.buildAppMessageEvent=e=>{var t;const i=e[0];let n;2>e.length?1===e.length&&(n=i):n=e[1];const{dataStore:{eventContextBuilder:s,eventInterceptor:r}}=this.growingIO,o=((null==n?void 0:n.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share",attributes:Object.assign({$from:i.from,$target:null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.id,$share_title:null==n?void 0:n.title,$share_path:a(o),$share_query:o[1]},null==n?void 0:n.attributes)},s()))},this.buildTimelineEvent=e=>{var t;const i=e[0];let n;2>e.length?1===e.length&&(n=i):n=e[1];const{dataStore:{eventContextBuilder:s,eventInterceptor:r}}=this.growingIO,o=((null==n?void 0:n.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline",attributes:Object.assign({$target:null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.id,$share_title:null==n?void 0:n.title,$share_path:a(o),$share_query:o[1]},null==n?void 0:n.attributes)},s()))},this.buildAddFavorites=e=>{const t=e[0];let i;2>e.length?1===e.length&&(i=t):i=e[1];const{dataStore:{eventContextBuilder:n,eventInterceptor:s}}=this.growingIO,r=((null==i?void 0:i.path)||"").split("?");s(Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites",attributes:{$share_title:null==i?void 0:i.title,$share_path:a(r),$share_query:r[1]}},n()))},this.initStorageInfo(),this.eventContextBuilder=new ne(this.growingIO).main,this.eventHooks=new le(this.growingIO),this.shareOut=!1,this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[],this.growingIO.emitter.on("onComposeAfter",(({composedEvent:e})=>{"VISIT"!==e.eventType&&"vst"!==e.t||(this.lastVisitEvent=e),"PAGE"!==e.eventType&&"page"!==e.t||(this.lastPageEvent=e)})),r(null===(s=this.growingIO.minipInstance.minip)||void 0===s?void 0:s.onAppHide)&&this.growingIO.minipInstance.minip.onAppHide((()=>{S(this.trackTimers,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))})),r(null===(l=this.growingIO.minipInstance.minip)||void 0===l?void 0:l.onAppShow)&&this.growingIO.minipInstance.minip.onAppShow((()=>{S(this.trackTimers,(e=>{e.start&&(e.start=+Date.now())}))})),this.growingIO.emitter.on("OPTION_CHANGE",(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.growingIO.clearTrackTimer()}))}get gsid(){const e=B(),t=R(e);return!P(t)&&e.gio_gsid?e.gio_gsid:this._gsid}set gsid(e){const t=Number.parseInt(e,10);this._gsid=Number.isNaN(t)||e>=1e9||1>e?1:e,B().gio_gsid=this._gsid,10>this._gsid-this._stid||this.saveStorageInfo()}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 ge={scnPrefix:"",appHandlers:["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange"],pageHandlers:["onLoad","onShow","onReady","onHide","onShareAppMessage","onTabItemTap","onUnload","onPullDownRefresh","onReachBottom","onResize"],actionEventTypes:["onclick","tap","onTap","longpress","longTap","blur","change","onChange","submit","confirm","getuserinfo","getphonenumber","contact","mouseup"],originalApp:E((()=>App)),originalPage:E((()=>Page)),originalComponent:E((()=>Component)),originalBehavior:E((()=>Behavior)),canHook:!0,hooks:{App:!0,Page:!0,Component:!0,Behavior:!0},listeners:{app:{appLaunch:"onLaunch",appShow:"onShow",appClose:"onHide"},page:{pageLoad:"onLoad",pageShow:"onShow",pageReady:"onReady",pageHide:"onHide",pageUnload:"onUnload",tabTap:"onTabItemTap",shareApp:"onShareAppMessage"},actions:{click:["onclick","tap","longpress","longTap","getuserinfo","getphonenumber","contact","mouseup"],change:["blur","change","confirm"],submit:["submit"]}}},ce=Object.assign(Object.assign({},ge),{pageHandlers:[...ge.pageHandlers,"onInit","didMount","didUnmount"],listeners:Object.assign(Object.assign({},ge.listeners),{page:Object.assign(Object.assign({},ge.listeners.page),{onInit:"onInit",didMount:"didMount",didUnmount:"didUnmount"})}),name:"Taobao",platform:"tbp",scnPrefix:"tbp_",hooks:Object.assign(Object.assign({},null==ge?void 0:ge.hooks),{Behavior:!1})});class he{constructor(e){this.growingIO=e,this.minip=$("tb"),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.settedTitle[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:n})=>{var s;return null===(s=this.minip)||void 0===s?void 0:s.getImageInfo({src:e,success:t,fail:i,complete:n})},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=()=>E((()=>l(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 i,n;let s="";const r=H(L());try{const o=(null==e?void 0:e.data)||e.$data||{};if(s=t(null==o?void 0:o.gioPageTitle)?null==o?void 0:o.gioPageTitle:"",0===s.length){const t=r.page[e.route]||r.page[e.route+".html"];s=t?t.window.navigationBarTitleText:r.global.window.navigationBarTitleText}if(0===s.length){const t=null===(n=null===(i=null==r?void 0:r.tabBar)||void 0===i?void 0:i.list)||void 0===n?void 0:n.find((t=>t.pagePath===e.route||t.pagePath===e.route+".html"));s=(null==t?void 0:t.text)||""}}catch(e){return""}return A(s)},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return s(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 n;i&&(t={value:t,expiredAt:i}),null===(n=this.minip)||void 0===n||n.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:n,method:s,success:o,fail:a,complete:l})=>{var u;const g=null===(u=this.minip)||void 0===u?void 0:u.request({url:e,data:t,header:i,headers:i,timeout:n,method:s,success:o,fail:a,complete:l});let c=setTimeout((()=>{(null==g?void 0:g.abort)&&r(null==g?void 0:g.abort)&&(null==g||g.abort()),clearTimeout(c),c=null}),(n||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:i,scnPrefix:n}}=this.growingIO;this.platform=i,this.scnPrefix=n,this.growingIO.emitter.on("OPTION_INITIALIZED",(()=>{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 de extends he{constructor(e){super(e),this.growingIO=e,this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBar,i=this;t&&Object.defineProperty(this.minip,"setNavigationBar",{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.settedTitle[e]=t}return t.apply(this,arguments)}})},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,"selectAll")},this.getStorageSync=e=>{const{data:t}=my.getStorageSync({key:e});return t},this.setStorageSync=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorageSync({key:e,data:t})},this.hookSetTitle()}}let pe;var ve={name:"gioTaobaoAdapter",method:class{constructor(e){this.growingIO=e,this.getSceneInfo=(e,t)=>{var i;null===(i=this.growingIO.minipInstance.minip)||void 0===i||i.getRelationAppInfo({success:i=>t(e,i),fail:()=>t(e,{})})},this.getRelationAppInfo=e=>{var t;null===(t=this.growingIO.minipInstance.minip)||void 0===t||t.getRelationAppInfo({success:e,fail:()=>e({})})},this.singleInvoke=()=>{var e;const{vdsConfig:t,emitter:i,uploader:n}=this.growingIO;if(n.hoardingQueue=[...n.hoardingQueue].filter((e=>(n.retryIds[e.requestId]||0)<n.retryLimit)),n.requestQueue=[...n.requestQueue].filter((e=>(n.retryIds[e.requestId]||0)<n.retryLimit)),pe.isEmpty([...n.hoardingQueue,...n.requestQueue]))return;let s=null!==(e=n.hoardingQueue.shift())&&void 0!==e?e:n.requestQueue.shift();t.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(s,null,2)),i.emit("onSendBefore",{requestData:s}),this.cloudFuncInvoke(s)},this.cloudFuncInvoke=e=>{var t,i;const{vdsConfig:n,emitter:s,uploader:r}=this.growingIO,{serverUrl:o,projectId:a,tbConfig:l}=n,u=pe.niceTry((()=>{var e;return null!==(e=getApp())&&void 0!==e?e:$global})),g=null!==(t=l.cloud)&&void 0!==t?t:u.cloud;(null===(i=null==g?void 0:g.function)||void 0===i?void 0:i.invoke)?(r.requestingNum+=1,g.function.invoke(l.cloudFuncName,{domain:o,path:`/v3/projects/${a}/collect`,params:{stm:Date.now()},body:e},l.cloudFuncHandler).then((t=>{r.requestingNum-=1,t.success?s.emit("onSendAfter",{result:t}):(r.requestFailFn(e),pe.consoleText("请求失败! "+JSON.stringify(t),"error")),r.initiateRequest()})).catch((t=>{r.requestingNum-=1,r.requestFailFn(e),pe.consoleText("请求失败! "+JSON.stringify(t),"error"),r.initiateRequest()}))):pe.consoleText("请求失败!无法获取 cloud 对象,请检查 tbConfig 配置项!","error")};const{utils:t,emitter:i}=this.growingIO;pe=t,i.on("OPTION_INITIALIZED",(e=>{const{inPlugin:t,dataStore:i}=e;t&&(pe.getGlobal().Component=function(...e){return i.eventHooks.componentOverriding(e[0])})})),i.on("minipLifecycle",(({event:e})=>{const{dataStore:t,vdsConfig:i}=this.growingIO,n="小部件"+i.appId;switch(e){case"Page onInit":{const e=(e,i)=>{var s;const r=pe.keys(e).map((t=>`${t}=${e[t]}`)).join("&");t.scene=null!==(s=i.sceneId)&&void 0!==s?s:"",t.sendVisit({path:n,query:r,title:n})};this.getRelationAppInfo((t=>this.getSceneInfo(t,e)))}break;case"Page didMount":t.sendPage({path:n,title:n})}}))}tbCloudAppInvoke(e){var t,i;const{vdsConfig:n,emitter:s,uploader:r}=this.growingIO,{serverUrl:o,projectId:a,tbConfig:l}=n,u=pe.niceTry((()=>{var e;return null!==(e=getApp())&&void 0!==e?e:$global})),g=null!==(t=l.cloud)&&void 0!==t?t:u.cloud;(null===(i=null==g?void 0:g.application)||void 0===i?void 0:i.httpRequest)?(r.requestingNum+=1,g.application.httpRequest({path:l.path,method:"POST",headers:{"Content-Type":"application/json;charset=UTF-8"},params:{serverUrl:o,projectId:a,stm:Date.now()},body:e,exts:{cloudAppId:l.cloudAppId}}).then((t=>{r.requestingNum-=1,t.success?s.emit("onSendAfter",{result:t}):(pe.isArray(e)?e.forEach((e=>{r.requestFailFn(e)})):r.requestFailFn(e),pe.consoleText("请求失败! "+JSON.stringify(t),"error")),r.initiateRequest()})).catch((t=>{r.requestingNum-=1,pe.isArray(e)?e.forEach((e=>{r.requestFailFn(e)})):r.requestFailFn(e),pe.consoleText("请求失败! "+JSON.stringify(t),"error"),r.initiateRequest()}))):pe.consoleText("请求失败!无法获取 cloud 对象,请检查 tbConfig 配置项!","error")}}};let me;const fe={};function Ie(e,t,i){var n=e;t.map((function(e,s){n[e]=s==t.length-1?i:n[e]||{},n=n[e]}))}Ie(fe,["pluginsIn","gioCustomTracking"],{name:"gioCustomTracking",method:class{constructor(e){this.growingIO=e,this.getDynamicAttributes=e=>(me.isNil(e)||me.keys(e).forEach((t=>{me.isFunction(e[t])?e[t]=e[t]():me.isArray(e[t])||(e[t]=me.toString(e[t]))})),e),this.buildCustomEvent=(e,t)=>{me.eventNameValidate(e,(()=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:n}}=this.growingIO;n(Object.assign({eventType:"CUSTOM",eventName:e,attributes:me.limitObject(this.getDynamicAttributes(me.isObject(t)&&!me.isEmpty(t)?t:void 0))},i()))}))},this.buildUserAttributesEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i,lastVisitEvent:n}}=this.growingIO,s=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES",attributes:me.limitObject(e)},t());s.path||(s.path=n.path,s.query=n.query,s.title=n.title),i(s)},me=this.growingIO.utils}}}),Ie(fe,["pluginsIn","gioTaobaoAdapter"],ve);class Se{constructor(e){this.growingIO=e,this.innerPluginInit=()=>{I(fe.pluginsIn).forEach((e=>{const{name:t,method:i}=fe.pluginsIn[e];this.pluginItems.find((e=>e.name===t))||this.pluginItems.push({name:p(t||e),method:i||(e=>{})})})),P(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var n;const s=t||this.pluginItems.find((t=>t.name===e));if(null===(n=this.growingIO)||void 0===n?void 0:n.plugins[e])return _(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!s)return _(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return this.growingIO.plugins[e]=new s.method(this.growingIO,i),t&&_("加载插件:"+e,"info"),!0}catch(t){return _(`插件【${e}】加载异常 ${t}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>this.install(t.name,e?t:void 0,t.options)))},this.uninstall=e=>{var t;O(this.pluginItems,e);const i=O(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||_(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>_(`插件执行错误 ${e.name} ${t}`,"error"),this.onComposeBefore=e=>{this.pluginItems.forEach((t=>{var i;const n=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onComposeBefore;if(n&&r(n))try{n(e)}catch(e){this.lifeError(t,e)}}))},this.onComposeAfter=e=>{this.pluginItems.forEach((t=>{var i;const n=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onComposeAfter;if(n&&r(n))try{n(e)}catch(e){this.lifeError(t,e)}}))},this.onSendBefore=e=>{this.pluginItems.forEach((t=>{var i;const n=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onSendBefore;if(n&&r(n))try{n(e)}catch(e){this.lifeError(t,e)}}))},this.onSendAfter=e=>{this.pluginItems.forEach((t=>{var i;const n=null===(i=this.growingIO.plugins[t.name])||void 0===i?void 0:i.onSendAfter;if(n&&r(n))try{n(e)}catch(e){this.lifeError(t,e)}}))},this.pluginItems=[],this.growingIO.emitter.on("onComposeBefore",this.onComposeBefore),this.growingIO.emitter.on("onComposeAfter",this.onComposeAfter),this.growingIO.emitter.on("onSendBefore",this.onSendBefore),this.growingIO.emitter.on("onSendAfter",this.onSendAfter)}}var ye={},we={}.hasOwnProperty;function Oe(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function be(e){try{return encodeURIComponent(e)}catch(e){return null}}ye.stringify=function(e,t){t=t||"";var i,n,s=[];for(n in"string"!=typeof t&&(t="?"),e)if(we.call(e,n)){if((i=e[n])||null!=i&&!isNaN(i)||(i=""),n=be(n),i=be(i),null===n||null===i)continue;s.push(n+"="+i)}return s.length?t+s.join("&"):""},ye.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,n={};t=i.exec(e);){var s=Oe(t[1]),r=Oe(t[2]);null===s||null===r||s in n||(n[s]=r)}return n};class Pe{constructor(e){this.growingIO=e,this.generateURL=()=>{const{serverUrl:e,projectId:t}=this.growingIO.vdsConfig;return v(e,"http")?`${e}/v3/projects/${t}/collect`:`https://${e}/v3/projects/${t}/collect`},this.commitRequest=e=>{const t=Object.assign({},e),{vdsConfig:i}=this.growingIO;i.forceLogin?this.hoardingQueue.push(t):(this.requestQueue.push(t),this.initiateRequest())},this.initiateRequest=e=>{var t,i;const{plugins:n,vdsConfig:s}=this.growingIO;[...this.hoardingQueue,...this.requestQueue].length>0&&this.requestingNum<this.requestLimit&&((null===(t=null==s?void 0:s.tbConfig)||void 0===t?void 0:t.cloudFuncSend)?null===(i=null==n?void 0:n.gioTaobaoAdapter)||void 0===i||i.singleInvoke():e?this.batchInvoke():this.batchInvokeThrottle())},this.batchInvoke=()=>{var e,t;const{vdsConfig:i,plugins:n,emitter:s}=this.growingIO;let r=[...this.hoardingQueue,...this.requestQueue];r.length>50?(r=r.slice(0,50),this.hoardingQueue.length>50?this.hoardingQueue=this.hoardingQueue.slice(50):(this.requestQueue=this.requestQueue.slice(50-this.hoardingQueue.length),this.hoardingQueue=[])):(this.hoardingQueue=[],this.requestQueue=[]);let o=r.filter((e=>(this.retryIds[e.requestId]||0)<=this.retryLimit));if(P(o))return;const a=o.map((e=>{const t=Object.assign({},e);return O(t,"requestId"),t}));i.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),s.emit("onSendBefore",{requestData:a}),(null===(e=null==i?void 0:i.tbConfig)||void 0===e?void 0:e.cloudAppId)?null===(t=null==n?void 0:n.gioTaobaoAdapter)||void 0===t||t.tbCloudAppInvoke(a):this.normalBatchInvoke(o,a)},this.batchInvokeThrottle=b(this.batchInvoke,this.growingIO.vdsConfig.uploadInterval,!1,!1),this.normalBatchInvoke=(e,t)=>{var i;const{minipInstance:n,vdsConfig:s,emitter:r,plugins:a}=this.growingIO;this.requestingNum+=1;const l={"content-type":"jdp"===n.platform?"application/json":"application/json;charset=UTF-8"};let u=[...t];const g=s.compress&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);g&&(u=a.gioCompress.compressToUTF16(JSON.stringify(t)),l["X-Compress-Codec"]="1"),n.request({url:`${this.requestURL}?stm=${Date.now()}&compress=${g?"1":"0"}`,header:l,method:"POST",data:u,timeout:s.requestTimeout,fail:t=>{[200,204].includes(t.code)||(o(e)?e.forEach((e=>{this.requestFailFn(e)})):this.requestFailFn(e),_("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,r.emit("onSendAfter",{result:e}),this.initiateRequest()}})},this.requestFailFn=e=>{if(this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1,!this.requestQueue.some((t=>t.requestId===e.requestId))){let t=setTimeout((()=>{P(this.requestQueue)?(this.requestQueue.push(e),this.initiateRequest()):this.requestQueue.push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue=[],this.requestQueue=[],this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0,this.requestURL=this.generateURL()}}class Te{constructor(e){var t;this.growingIO=e,this.initUserInfo=()=>{var e;const{minipInstance:t}=this.growingIO,i=[this.uidStorageName,this.userIdStorageName,this.userKeyStorageName,this.gioIdStorageName],n=null!==(e=G(t,i))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,t)=>{this[e]=n[t],"_uid"!==e||this[e]||(this.uid=N())}))},this.saveUserInfo=()=>{const{minipInstance:e}=this.growingIO;M(e,[{key:this.uidStorageName,value:this.uid},{key:this.userIdStorageName,value:this.userId},{key:this.userKeyStorageName,value:this.userKey},{key:this.gioIdStorageName,value:this.gioId}])};const{inPlugin:i}=this.growingIO;this.uidStorageName=i?"_growing_plugin_uid_":"_growing_uid_",this.userIdStorageName=i?"_growing_plugin_userId_":"_growing_userId_",this.userKeyStorageName=i?"_growing_plugin_userKey_":"_growing_userKey_",this.gioIdStorageName=i?"_growing_plugin_gioId_":"_growing_gioId_",this._sessionId=N(),this._uid=void 0,this._userId=void 0,this._userKey=void 0,this._gioId=void 0,"quickapp"!==(null===(t=this.growingIO)||void 0===t?void 0:t.gioPlatform)&&this.initUserInfo()}get sessionId(){return this._sessionId||(this._sessionId=N()),this._sessionId}set sessionId(e){const t=this._sessionId;this._sessionId=e||N(),t!==this._sessionId&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:this._sessionId,oldSessionId:t})}get uid(){return this._uid}set uid(e){const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this.uidStorageName,this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))}get userId(){return this._userId}set userId(e){const t=this._userId;this._userId=e,t!==this._userId&&(this.growingIO.minipInstance.setStorage(this.userIdStorageName,this._userId),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:e,oldUserId:t})),e&&(this.gioId=e)}get userKey(){return this._userKey}set userKey(e){const t=this._userKey;this._userKey=e,t!==this._userKey&&(this.growingIO.minipInstance.setStorage(this.userKeyStorageName,this._userKey),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:e,oldUserKey:t}))}get gioId(){return this._gioId}set gioId(e){const t=this._gioId;this._gioId=e,t!==this._gioId&&(this.growingIO.minipInstance.setStorage(this.gioIdStorageName,this._gioId),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:e,oldGioId:t}))}}const Ce=new class{constructor(){var t;this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.init=e=>{var t;return _("Gio小程序SDK 初始化中...","info"),this.dataStore.initOptions(e),null===(t=this.emitter)||void 0===t||t.emit("OPTION_INITIALIZED",this),this.gioSDKInitialized=!0,this.vdsConfig.subpackage||(B().__gio__=()=>this),this.uploader=new Pe(this),this.vdsConfig.idMapping||(this.userStore.userKey=""),this.emitter.emit("SDK_INITIALIZED",this),_("Gio小程序SDK 初始化完成!","success"),this.vdsConfig.forceLogin&&_("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(),!0},this.getOption=e=>this.dataStore.getOption(e),this.setOption=(e,t)=>{if(I(X).includes(e)){const i=this.dataStore.setOption(e,t);return i&&X[e]&&_(`已${t?"开启":"关闭"}${X[e]}`,"info"),i}return _(`不存在可修改的配置项:${e},请检查后重试!`,"warn"),!1},this.getDeviceId=()=>this.userStore.uid,this.identify=e=>{if(this.vdsConfig.forceLogin){if(!J(e))return void k("identify");const t=h(e).slice(0,1e3);this.userStore.uid=t,this.uploader.hoardingQueue.forEach(((e,i)=>this.uploader.hoardingQueue[i].deviceId=t)),this.dataStore.setOption("forceLogin",!1),this.uploader.initiateRequest(!0)}else k("identify",!1,"forceLogin未开启")},this.setUserId=(t,i)=>{if(J(t)){const n=this.userStore.gioId;if(t=h(t).slice(0,1e3),i=h(i).slice(0,1e3),this.userStore.userId=t,this.vdsConfig.idMapping&&(this.userStore.userKey=e(i)?"":i),n&&n!==t){this.userStore.sessionId="";const{path:e,query:t,settedTitle:i}=this.dataStore.eventHooks.currentPage;this.dataStore.eventHooks.currentPage.title=i[e]||this.minipInstance.getPageTitle(this.minipInstance.getCurrentPage()),this.dataStore.sendVisit({path:e,query:t})}}else k("setUserId")},this.clearUserId=()=>{this.userStore.userId=void 0,this.userStore.userKey=void 0},this.setUserAttributes=e=>{var t,i;!P(e)&&s(e)?null===(i=null===(t=this.plugins)||void 0===t?void 0:t.gioCustomTracking)||void 0===i||i.buildUserAttributesEvent(e):k("setUserAttributes")},this.track=(e,t)=>{var i,n;((null===(n=null===(i=this.plugins)||void 0===i?void 0:i.gioCustomTracking)||void 0===n?void 0:n.buildCustomEvent)||function(){})(e,Object.assign(Object.assign({},this.dataStore.generalProps),s(t)&&!P(t)?t:{}))},this.trackTimerStart=e=>!!this.vdsConfig.dataCollect&&q(e,(()=>{const t=N();return this.dataStore.trackTimers[t]={eventName:e,leng:0,start:+Date.now()},t})),this.trackTimerPause=e=>{if(e&&this.dataStore.trackTimers[e]){const t=this.dataStore.trackTimers[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=e=>{if(e&&this.dataStore.trackTimers[e]){const t=this.dataStore.trackTimers[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t)=>{if(this.vdsConfig.dataCollect){const i=864e5;if(e&&this.dataStore.trackTimers[e]){const n=this.dataStore.trackTimers[e];if(0!==n.start){const e=+Date.now()-n.start;n.leng=e>0?n.leng+e:0}const{eventContextBuilder:s,eventInterceptor:r}=this.dataStore;return r(Object.assign({eventType:"CUSTOM",eventName:n.eventName,attributes:Q(Object.assign(Object.assign({},t),{event_duration:n.leng>i?0:n.leng/1e3}))},s())),this.removeTimer(e),!0}return _("未查找到对应的计时器,请检查!","error"),!1}return!1},this.removeTimer=e=>!(!e||!this.dataStore.trackTimers[e]||(delete this.dataStore.trackTimers[e],0)),this.clearTrackTimer=()=>{this.dataStore.trackTimers={}},this.setGeneralProps=e=>{s(e)&&!P(e)?(this.dataStore.generalProps=Object.assign(Object.assign({},this.dataStore.generalProps),e),I(this.dataStore.generalProps).forEach((e=>{[void 0,null].includes(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]="")}))):k("setGeneralProps")},this.clearGeneralProps=e=>{o(e)&&!P(e)?e.forEach((e=>{O(this.dataStore.generalProps,e)})):this.dataStore.generalProps={}},this.setPageAttributes=e=>{const{currentPage:t}=this.dataStore.eventHooks,i=this.minipInstance.getCurrentPath();["onLoad","attached"].includes(t.currentLifecycle)&&(t.pageProps[i]=Q(e))},this.updateImpression=()=>{_("当前未集成半自动浏览插件,请集成插件后再调用 updateImpression!","warn")},this.setLocation=(e,t)=>{const i={latitude:e,longitude:t},n=this.dataStore.locationData,s=e=>e>=-180&&180>=e;s(e)&&s(t)&&(n.latitude!==e||n.longitude!==t)&&(this.dataStore.locationData=i)},this.getGioInfo=()=>{const{uid:e,userId:t,userKey:i,sessionId:n}=this.userStore,{projectId:s,appId:r,dataSourceId:o,dataCollect:a,idMapping:l,extraParams:u,ignoreFields:g}=this.vdsConfig,c={gioappid:r,giocs1:t||"",gioplatform:this.platformConfig.platform,gioprojectid:s,gios:n,giou:e};return c.giodatacollect=a,c.giodatasourceid=o,l&&(c.giouserkey=i),P(u)||u.forEach((e=>{g.includes(e)||(c["gio"+e]=this.dataStore.lastVisitEvent[e])})),ye.stringify(c)},this.utils=Object.assign(Object.assign(Object.assign({},C),W),{qs:ye}),this.emitter={all:t=t||new Map,on:function(e,i){var n=t.get(e);n?n.push(i):t.set(e,[i])},off:function(e,i){var n=t.get(e);n&&(i?n.splice(n.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var n=t.get(e);n&&n.slice().map((function(e){e(i)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,i)}))}},this.gioPlatform="tb",this.gioFramework="native",this.sdkVersion="4.0.1";try{"quickapp"===this.gioPlatform||r(getApp)&&r(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&_("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=ce,this.minipInstance=new de(this),this.dataStore=new ue(this),this.userStore=new Te(this),this.plugins=new Se(this),this.plugins.innerPluginInit()}},_e=function(){const e=arguments[0];if(t(e)&&Y.includes(e)&&Ce[e]){const n=u(Array.from(arguments));if("init"===e){const e=!(i=Ce).vdsConfig&&!i.gioSDKInitialized||(_("SDK重复初始化,请检查是否重复加载SDK或接入其他平台SDK导致冲突!","warn"),!1),r=(e=>!!g(e)||(_('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "你的应用 AppId", options); 进行初始化!',"error"),!1))(n),o=(e=>{const t=e[0];let i=l(e);return J(t)?(s(i)&&i||(i={}),{projectId:t,userOptions:i}):(_("SDK初始化失败,accountId 参数不合法!","error"),!1)})(n),a=(e=>{const i=e[1];let n=e[2];const s=l(e);return i&&t(i)?J(n)?{dataSourceId:i,appId:n,options:s}:(_("SDK初始化失败,appId 参数不合法!","error"),!1):(_("SDK初始化失败,dataSourceId 参数不合法!","error"),!1)})(n);if(e&&r&&o&&a){const{projectId:e}=o,{dataSourceId:t,appId:i,options:n}=a;return Ce.init(Object.assign(Object.assign({},n),{projectId:e,dataSourceId:t,appId:i}))}}else if("registerPlugins"===e)Ce.registerPlugins(n[0]);else{if(Ce.gioSDKInitialized&&Ce.vdsConfig)return Ce[e](...n);_("SDK未初始化!","error")}}else ee.includes(e)?_(`方法 ${h(e)} 已被弃用!`,"warn"):_(`不存在名为 ${h(e)} 的方法调用!`,"error");var i};K().gdp=_e,K().gioSDKVersion=Ce.sdkVersion;const ke=E((()=>{var e;return null!==(e=Ce.dataStore.eventHooks.growingApp)&&void 0!==e?e:App})),Ee=E((()=>{var e;return null!==(e=Ce.dataStore.eventHooks.growingPage)&&void 0!==e?e:Page})),Ae=E((()=>{var e;return null!==(e=Ce.dataStore.eventHooks.growingComponent)&&void 0!==e?e:Component})),qe=E((()=>{var e;return null!==(e=Ce.dataStore.eventHooks.growingBehavior)&&void 0!==e?e:Behavior}));export default _e;export{ke as GioApp,qe as GioBehavior,Ae as GioComponent,Ee as GioPage};
|