@datarangers/sdk-javascript 0.0.4 → 0.0.5-lite
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/README.md +11 -10
- package/es/index.min.js +1 -1
- package/lib/index.min.js +1 -1
- package/package.json +2 -3
- package/types/types.d.ts +1 -150
- package/es/index-base.min.js +0 -1
- package/es/plugin/ab.js +0 -1
- package/es/plugin/autotrack.js +0 -1
- package/es/plugin/duration.js +0 -1
- package/es/plugin/route.js +0 -1
- package/es/plugin/stay.js +0 -1
- package/es/plugin/store.js +0 -1
- package/lib/index-base.min.js +0 -1
- package/lib/plugin/ab.js +0 -1
- package/lib/plugin/autotrack.js +0 -1
- package/lib/plugin/duration.js +0 -1
- package/lib/plugin/route.js +0 -1
- package/lib/plugin/stay.js +0 -1
- package/lib/plugin/store.js +0 -1
package/es/plugin/route.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var o,r,n=a.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return i}function t(){for(var t=[],a=0;a<arguments.length;a++)t=t.concat(e(arguments[a]));return t}var a,o;!function(e){e.Init="init",e.Config="config",e.Start="start",e.Ready="ready",e.TokenComplete="token-complete",e.TokenStorage="token-storage",e.TokenFetch="token-fetch",e.TokenError="token-error",e.ConfigUuid="config-uuid",e.ConfigWebId="config-webid",e.ConfigDomain="config-domain",e.CustomWebId="custom-webid",e.AnonymousId="anonymous-id",e.TokenChange="token-change",e.TokenReset="token-reset",e.ConfigTransform="config-transform",e.EnvTransform="env-transform",e.SessionReset="session-reset",e.SessionResetTime="session-reset-time",e.Event="event",e.Events="events",e.EventNow="event-now",e.CleanEvents="clean-events",e.BeconEvent="becon-event",e.SubmitBefore="submit-before",e.SubmitScuess="submit-scuess",e.SubmitAfter="submit-after",e.SubmitError="submit-error",e.SubmitVerifyH="submit-verify-h5",e.Stay="stay",e.ResetStay="reset-stay",e.StayReady="stay-ready",e.SetStay="set-stay",e.RouteChange="route-change",e.RouteReady="route-ready",e.Ab="ab",e.AbVar="ab-var",e.AbAllVars="ab-all-vars",e.AbConfig="ab-config",e.AbExternalVersion="ab-external-version",e.AbVersionChangeOn="ab-version-change-on",e.AbVersionChangeOff="ab-version-change-off",e.AbOpenLayer="ab-open-layer",e.AbCloseLayer="ab-close-layer",e.AbReady="ab-ready",e.AbComplete="ab-complete",e.AbTimeout="ab-timeout",e.Profile="profile",e.ProfileSet="profile-set",e.ProfileSetOnce="profile-set-once",e.ProfileUnset="profile-unset",e.ProfileIncrement="profile-increment",e.ProfileAppend="profile-append",e.ProfileClear="profile-clear",e.TrackDuration="track-duration",e.TrackDurationStart="track-duration-start",e.TrackDurationEnd="track-duration-end",e.TrackDurationPause="track-duration-pause",e.TrackDurationResume="tracl-duration-resume",e.Autotrack="autotrack",e.AutotrackReady="autotrack-ready",e.CepReady="cep-ready",e.TracerReady="tracer-ready"}(a||(a={})),function(e){e.DEBUGGER_MESSAGE="debugger-message",e.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",e.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",e.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",e.DEBUGGER_MESSAGE_EVENT="debugger-message-event",e.DEVTOOL_WEB_READY="devtool-web-ready"}(o||(o={}));var r=function(){function e(){this.autotrack=!1,this.spa=!1,this.cache={},this.allowHash=!1}return e.prototype.apply=function(e,t){if(t.spa||t.autotrack){var a=e.Types;this.collect=e,this.config=t,this.appid=t.app_id,this.allowHash=t.allow_hash,this.fncArray=new Map,this.setKey(),this.setLocation(),this.hack(),this.init(),this.listener(),e.emit(a.RouteReady)}},e.prototype.setKey=function(){var e=this.collect.adapters.storage;this.storage=new e(!1),this.cache_key="__tea_cache_refer_"+this.appid,this.cache={refer_key:"",refer_title:document.title||location.pathname,refer_manual_key:"",routeChange:!1},this.config.autotrack&&"object"==typeof this.config.autotrack&&this.config.autotrack.page_manual_key&&(this.cache.refer_manual_key=this.config.autotrack.page_manual_key),this.storage.setItem(this.cache_key,this.cache)},e.prototype.hack=function(){var e=this,a=window.history.pushState;history.pushState=function(o){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];"function"==typeof history.onpushstate&&history.onpushstate({state:o});var i=a.call.apply(a,t([history,o],r));if(e.lastLocation!==location.href){var s=e.getPopStateChangeEventData();return e.setReferCache(e.lastLocation),e.lastLocation=location.href,e.sendPv(s,"pushState"),i}};var o=history.replaceState;history.replaceState=function(a){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];"function"==typeof history.onreplacestate&&history.onreplacestate({state:a});var i=o.call.apply(o,t([history,a],r));if(e.lastLocation!==location.href){var s=e.getPopStateChangeEventData();return e.setReferCache(e.lastLocation),e.lastLocation=location.href,e.sendPv(s),i}}},e.prototype.setLocation=function(){"undefined"!=typeof window&&(this.lastLocation=window.location.href)},e.prototype.getLocation=function(){return this.lastLocation},e.prototype.init=function(){var e=this.getPopStateChangeEventData();this.collect.emit("route-change",{config:e,init:!0})},e.prototype.listener=function(){var e=this,t=null;window.addEventListener("hashchange",(function(a){if(e.lastLocation!==window.location.href&&(clearTimeout(t),e.allowHash)){e.setReferCache(e.lastLocation),e.lastLocation=window.location.href;var o=e.getPopStateChangeEventData();e.sendPv(o)}})),window.addEventListener("popstate",(function(a){e.lastLocation!==window.location.href&&(t=setTimeout((function(){e.setReferCache(e.lastLocation),e.lastLocation=window.location.href;var t=e.getPopStateChangeEventData();e.sendPv(t)}),10))}))},e.prototype.getPopStateChangeEventData=function(){var e=this.pageConfig();return e.is_back=0,e},e.prototype.pageConfig=function(){try{var e=this.storage.getItem(this.cache_key)||{},t=!1,a=this.storage.getItem("__tea_cache_first_"+this.appid);return t=!a||1!=a,{is_html:1,url:location.href,referrer:this.handleRefer(),page_key:location.href,refer_page_key:this.handleRefer(),page_title:document.title||location.pathname,page_manual_key:this.config.autotrack&&this.config.autotrack.page_manual_key||"",refer_page_manual_key:e&&e.refer_manual_key||"",refer_page_title:e&&e.refer_title||"",page_path:location.pathname,page_host:location.host,is_first_time:""+t}}catch(e){return this.collect.emit(o.DEBUGGER_MESSAGE,{type:o.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),{}}},e.prototype.sendPv=function(e,t){this.collect.emit("route-change",{config:e,init:!1})},e.prototype.handleRefer=function(){var e="";try{var t=this.storage.getItem()||{};e=t.routeChange?t.refer_key:this.collect.configManager.get("referrer")}catch(t){e=document.referrer}return e},e.prototype.setReferCache=function(e){var t=this.storage.getItem(this.cache_key)||{};t.refer_key=e,t.routeChange=!0,this.storage.setItem(this.cache_key,t)},e}();export{r as default};
|
package/es/plugin/stay.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=function(){return t=Object.assign||function(t){for(var e,i=1,a=arguments.length;i<a;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},t.apply(this,arguments)},e=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)};Date.now(),Number((""+Math.random()).slice(2,8));var i,a,n=function(){var t=0;return["hidden","msHidden","webkitHidden"].forEach((function(e){void 0!==document[e]&&(t=1)})),t},s=function(){function i(t,i){this.maxDuration=432e5,this.aliveDTime=6e4,this.options={aliveName:"predefine_page_alive",params:{}},this.collect=t,this.config=i,this.pageStartTime=Date.now(),this.sessionStartTime=this.pageStartTime,this.timerHandler=null,e(i.enable_stay_duration)&&(this.options=Object.assign(this.options,i.enable_stay_duration))}return i.prototype.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},i.prototype.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},i.prototype.enable=function(t,e,i){this.url_path=t||this.url_path,this.url=i||this.url,this.title=e||this.title,this.disableCallback=this.enablePageAlive(),this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params},i.prototype.disable=function(){this.disableCallback(),this.pageStartTime=Date.now()},i.prototype.sendEvent=function(e,i){void 0===i&&(i=!1);var a=i?this.aliveDTime:Date.now()-this.sessionStartTime;a<0||a>this.aliveDTime||Date.now()-this.pageStartTime>this.maxDuration||(this.collect.beconEvent(this.options.aliveName,t({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),duration:a,is_support_visibility_change:n(),startTime:this.sessionStartTime,hidden:document.visibilityState,leave:e},this.customParmas)),this.sessionStartTime=Date.now(),this.resetParams(location.pathname,document.title,location.href))},i.prototype.getParams=function(t){switch(t){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},i.prototype.setUpTimer=function(){var t=this;return this.timerHandler&&clearInterval(this.timerHandler),setInterval((function(){Date.now()-t.sessionStartTime>t.aliveDTime&&t.sendEvent(!1,!0)}),1e3)},i.prototype.visibilitychange=function(){"hidden"===document.visibilityState?this.timerHandler&&(clearInterval(this.timerHandler),this.sendEvent(!1)):"visible"===document.visibilityState&&(this.sessionStartTime=Date.now(),this.timerHandler=this.setUpTimer())},i.prototype.beforeunload=function(){document.hidden||this.sendEvent(!0)},i.prototype.enablePageAlive=function(){var t=this;this.timerHandler=this.setUpTimer();var e=this.visibilitychange.bind(this),i=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",i),function(){t.beforeunload(),document.removeEventListener("visibilitychange",e),window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i)}},i}(),o=function(){function i(t,i){var a=this;this.maxDuration=432e5,this.aliveDTime=6e4,this.options={closeName:"predefine_page_close",params:{}},this.visibilitychange=function(){"hidden"===document.visibilityState?a.activeEndTime=Date.now():"visible"===document.visibilityState&&(a.activeEndTime&&(a.totalTime+=a.activeEndTime-a.activeStartTime,a.activeTimes+=1),a.activeEndTime=void 0,a.activeStartTime=Date.now())},this.beforeunload=function(){if(a.totalTime+=(a.activeEndTime||Date.now())-a.activeStartTime,a.config.autotrack){try{window.sessionStorage.setItem("_tea_cache_duration",JSON.stringify({duration:a.totalTime,page_title:document.title||location.pathname}))}catch(t){}}a.sendEventPageClose()},this.collect=t,this.config=i,this.maxDuration=i.maxDuration||864e5,this.pageStartTime=Date.now(),e(i.enable_stay_duration)&&(this.options=Object.assign(this.options,i.enable_stay_duration)),this.resetData()}return i.prototype.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},i.prototype.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},i.prototype.enable=function(t,e,i){this.url_path=t||this.url_path,this.url=i||this.url,this.title=e||this.title,this.disableCallback=this.enablePageClose()},i.prototype.disable=function(){this.disableCallback()},i.prototype.resetData=function(){this.activeStartTime=void 0===this.activeStartTime?this.pageStartTime:Date.now(),this.activeEndTime=void 0,this.activeTimes=1,this.totalTime=0,this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params,this.resetParams(location.pathname,document.title,location.href)},i.prototype.sendEventPageClose=function(){var e=Date.now()-this.pageStartTime;this.totalTime<0||e<0||this.totalTime>=this.maxDuration||(this.collect.beconEvent(this.options.closeName,t({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),active_times:this.activeTimes,duration:this.totalTime,total_duration:e,is_support_visibility_change:n()},this.customParmas)),this.pageStartTime=Date.now(),this.resetData())},i.prototype.getParams=function(t){switch(t){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},i.prototype.enablePageClose=function(){var t=this,e=this.visibilitychange.bind(this),i=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",i),function(){t.beforeunload(),document.removeEventListener("visibilitychange",e),window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i)}},i}();!function(t){t.Init="init",t.Config="config",t.Start="start",t.Ready="ready",t.TokenComplete="token-complete",t.TokenStorage="token-storage",t.TokenFetch="token-fetch",t.TokenError="token-error",t.ConfigUuid="config-uuid",t.ConfigWebId="config-webid",t.ConfigDomain="config-domain",t.CustomWebId="custom-webid",t.AnonymousId="anonymous-id",t.TokenChange="token-change",t.TokenReset="token-reset",t.ConfigTransform="config-transform",t.EnvTransform="env-transform",t.SessionReset="session-reset",t.SessionResetTime="session-reset-time",t.Event="event",t.Events="events",t.EventNow="event-now",t.CleanEvents="clean-events",t.BeconEvent="becon-event",t.SubmitBefore="submit-before",t.SubmitScuess="submit-scuess",t.SubmitAfter="submit-after",t.SubmitError="submit-error",t.SubmitVerifyH="submit-verify-h5",t.Stay="stay",t.ResetStay="reset-stay",t.StayReady="stay-ready",t.SetStay="set-stay",t.RouteChange="route-change",t.RouteReady="route-ready",t.Ab="ab",t.AbVar="ab-var",t.AbAllVars="ab-all-vars",t.AbConfig="ab-config",t.AbExternalVersion="ab-external-version",t.AbVersionChangeOn="ab-version-change-on",t.AbVersionChangeOff="ab-version-change-off",t.AbOpenLayer="ab-open-layer",t.AbCloseLayer="ab-close-layer",t.AbReady="ab-ready",t.AbComplete="ab-complete",t.AbTimeout="ab-timeout",t.Profile="profile",t.ProfileSet="profile-set",t.ProfileSetOnce="profile-set-once",t.ProfileUnset="profile-unset",t.ProfileIncrement="profile-increment",t.ProfileAppend="profile-append",t.ProfileClear="profile-clear",t.TrackDuration="track-duration",t.TrackDurationStart="track-duration-start",t.TrackDurationEnd="track-duration-end",t.TrackDurationPause="track-duration-pause",t.TrackDurationResume="tracl-duration-resume",t.Autotrack="autotrack",t.AutotrackReady="autotrack-ready",t.CepReady="cep-ready",t.TracerReady="tracer-ready"}(i||(i={})),function(t){t.DEBUGGER_MESSAGE="debugger-message",t.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",t.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",t.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",t.DEBUGGER_MESSAGE_EVENT="debugger-message-event",t.DEVTOOL_WEB_READY="devtool-web-ready"}(a||(a={}));var r=function(){function t(){}return t.prototype.apply=function(t,e){var i=this;if(this.collect=t,this.config=e,this.config.enable_stay_duration){this.title=document.title||location.pathname,this.url=location.href,this.url_path=location.pathname,this.pageAlive=new s(t,e),this.pageClose=new o(t,e);var a=this.collect.Types;this.collect.on(a.ResetStay,(function(t){var e=t.url_path,a=t.title,n=t.url;i.resetStayDuration(e,a,n)})),this.collect.on(a.RouteChange,(function(t){t.init||e.disable_route_report||i.resetStayDuration()})),this.collect.on(a.SetStay,(function(t){var e=t.url_path,a=t.title,n=t.url;i.setStayParmas(e,a,n)})),this.enable(this.url_path,this.title,this.url),this.ready(a.Stay),this.collect.emit(a.StayReady)}},t.prototype.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var a=function(t){i[t].length&&i[t].forEach((function(i){e.collect.hook.emit(t,i)}))};for(var n in i)a(n)}},t.prototype.enable=function(t,e,i){this.pageAlive.enable(t,e,i),this.pageClose.enable(t,e,i)},t.prototype.disable=function(){this.pageAlive.disable(),this.pageClose.disable()},t.prototype.setStayParmas=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.pageAlive.setParams(t,e,i),this.pageClose.setParams(t,e,i),this.collect.emit(a.DEBUGGER_MESSAGE,{type:a.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayParams",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},t.prototype.reset=function(t,e,i){this.disable(),this.enable(t,e,i)},t.prototype.resetStayDuration=function(t,e,i){this.reset(t,e,i),this.collect.emit(a.DEBUGGER_MESSAGE,{type:a.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayDuration",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},t}();export{r as default};
|
package/es/plugin/store.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=function(){function t(){this.retryWaitTime=3e3,this.retryStatus=!1,this.retryCacheStatus=!1}return t.prototype.apply=function(t,e){var r=this;if(e.enable_storage&&!e.disable_storage&&(this.collect=t,this.config=e,!this.collect.destroyInstance)){var a=t.Types,n=t.adapters,o=n.storage,i=n.fetch;this.storage=new o(!1),this.fetch=i,this.eventUrl=this.collect.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+e.app_id,this.storageNum=e.storage_num||50,this.retryNum=e.retry_num||3,this.retryInterval=1e3,t.on(a.SubmitError,(function(t){"f_data"===t.type&&r.storeData(t)})),t.on(a.Ready,(function(){r.checkStorage()}))}},t.prototype.retryRightNow=function(t){var e=this;if(this.retryStatus)this.errorCache.push(t);else{var r=0;this.retryStatus=!0;var a=setInterval((function(){if(3===r)return e.storeData(e.errorCache),e.retryStatus=!1,void clearInterval(a);var n=t.eventData;e.fetchData(n,(function(){e.retryStatus=!1,clearInterval(a),e.retryCacheStatus&&e.errorCache.splice(0,1),e.errorCache.length&&(e.retryCacheStatus=!0,e.retryRightNow(e.errorCache[0]))}),(function(){r++}))}),this.retryInterval)}},t.prototype.storeData=function(t){var e=this.storage.getItem(this.eventKey),r=t.eventData;Object.keys(e).length!==this.storageNum&&(e[Date.now()]=r,this.storage.setItem(this.eventKey,e))},t.prototype.checkStorage=function(){var t=this;try{if(!window.navigator.onLine)return;var e=this.storage.getItem(this.eventKey);if(!e||!Object.keys(e).length)return;var r={events:[{event:"ontest",params:{app_id:this.config.app_id},local_time_ms:Date.now()}],user:{user_unique_id:this.collect.configManager.get("web_id")},header:{}};this.fetchData([r],(function(){var r=JSON.parse(JSON.stringify(e)),a=function(a){t.fetchData(e[a],(function(){delete r[a],t.storage.setItem(t.eventKey,r)}),(function(){}),!1)};for(var n in e)a(n)}),(function(){}),!0)}catch(t){console.warn("error check storage")}},t.prototype.fetchData=function(t,e,r,a){this.fetch(this.eventUrl,t,3e4,!1,(function(){e&&e()}),(function(){r&&r(),console.log("network error,compensate report failk")}),a&&!this.config.channel_domain?"566f58151b0ed37e":"")},t}();export{t as default};
|
package/lib/index-base.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){return t=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,o,r=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return s}function i(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(e(arguments[i]));return t}var n,o=function(){function t(){this._hooks={},this._cache=[],this._hooksCache={}}return t.prototype.on=function(t,e){t&&e&&"function"==typeof e&&(this._hooks[t]||(this._hooks[t]=[]),this._hooks[t].push(e))},t.prototype.once=function(t,e){var i=this;if(t&&e&&"function"==typeof e){this.on(t,(function n(o){e(o),i.off(t,n)}))}},t.prototype.off=function(t,e){if(t&&this._hooks[t]&&this._hooks[t].length)if(e){var i=this._hooks[t].indexOf(e);-1!==i&&this._hooks[t].splice(i,1)}else this._hooks[t]=[]},t.prototype.emit=function(t,e,i){if(i){if(!t)return;-1!==this._cache.indexOf(i)?this._emit(t,e):(this._hooksCache.hasOwnProperty(i)||(this._hooksCache[i]={}),this._hooksCache[i].hasOwnProperty(t)||(this._hooksCache[i][t]=[]),this._hooksCache[i][t].push(e))}else this._emit(t,e)},t.prototype._emit=function(t,e){t&&this._hooks[t]&&this._hooks[t].length&&i(this._hooks[t]).forEach((function(t){try{t(e)}catch(t){}}))},t.prototype.set=function(t){t&&-1===this._cache.indexOf(t)&&this._cache.push(t)},t}(),r=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)},s=(n=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return n+=1}),a=function(t){return function(t,e,i){if("string"==typeof t&&"number"==typeof e&&"number"==typeof i){var n,o=[];i=i<=25?i:i%25;var r=String.fromCharCode(i+97);n=t.split(r);for(var s=0;s<n.length;s++){var a=parseInt(n[s],i);a=1*a^e;var c=String.fromCharCode(a);o.push(c)}return o.join("")}}(t,64,25)},c=function(t){!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",t,!1):window.addEventListener("beforeunload",t,!1)},h=function(t){var e=document.createElement("a");return e.href=t,e},u=function(t){var e={};try{var i=h(t).search;(i=i.slice(1)).split("&").forEach((function(t){var i,n,o=t.split("=");o.length&&(i=o[0],n=o[1]);try{e[i]=decodeURIComponent(void 0===n?"":n)}catch(t){e[i]=n}}))}catch(t){}return e},f=function(t){for(var e=0,i=0,n=(t+="").length,o=0;o<n;o++)((e=31*e+t.charCodeAt(i++))>0x7fffffffffff||e<-0x800000000000)&&(e&=0xffffffffffff);return e<0&&(e+=0x7ffffffffffff),e};var l=function(t){var e,i,n=[],o=t.length;o%2!=0&&(i=o+1,t=(e=t).length>=i?e:new Array(i-e.length+1).join("0")+e),o=t.length;for(var r=0;r<o;r+=2)n.push(parseInt(t.substr(r,2),16));return n},p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(t,e){return t(e={exports:{}},e.exports),e.exports}var g=d((function(t,e){t.exports=function(){function t(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)t[n]=i[n]}return t}function e(i,n){function o(e,o,r){if("undefined"!=typeof document){"number"==typeof(r=t({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in r)r[a]&&(s+="; "+a,!0!==r[a]&&(s+="="+r[a].split(";")[0]));return document.cookie=e+"="+i.write(o,e)+s}}function r(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split("; "):[],n={},o=0;o<e.length;o++){var r=e[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(n[a]=i.read(s,a),t===a)break}catch(t){}}return t?n[t]:n}}return Object.create({set:o,get:r,remove:function(e,i){o(e,"",t({},i,{expires:-1}))},withAttributes:function(i){return e(this.converter,t({},this.attributes,i))},withConverter:function(i){return e(t({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(i)}})}return e({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}()})),m=function(){function t(){this.cache={}}return t.prototype.setItem=function(t,e){this.cache[t]=e},t.prototype.getItem=function(t){return this.cache[t]},t.prototype.removeItem=function(t){this.cache[t]=void 0},t.prototype.getCookie=function(t){this.getItem(t)},t.prototype.setCookie=function(t,e){this.setItem(t,e)},t}();var y,v,_={getItem:function(t){try{var e=localStorage.getItem(t),i=e;try{e&&"string"==typeof e&&(i=JSON.parse(e))}catch(t){}return i||{}}catch(t){}return{}},setItem:function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},removeItem:function(t){try{localStorage.removeItem(t)}catch(t){}},getCookie:function(t,e){try{return g.get(t,{domain:e||document.domain})}catch(t){return""}},setCookie:function(t,e,i,n){try{var o=n||document.domain,r=+new Date+i;g.set(t,e,{expires:new Date(r),path:"/",domain:o})}catch(t){}},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(t){return!1}}()},b={getItem:function(t){try{var e=sessionStorage.getItem(t),i=e;try{e&&"string"==typeof e&&(i=JSON.parse(e))}catch(t){}return i||{}}catch(t){}return{}},setItem:function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},removeItem:function(t){try{sessionStorage.removeItem(t)}catch(t){}},getCookie:function(t){this.getItem(t)},setCookie:function(t,e){this.setItem(t,e)},isSupportSession:function(){try{return sessionStorage.setItem("_ranger-test-key","hi"),sessionStorage.getItem("_ranger-test-key"),sessionStorage.removeItem("_ranger-test-key"),!0}catch(t){return!1}}()},E=function(){function t(t,e){this._storage=e&&"session"===e?b:!t&&_.isSupportLS?_:new m}return t.prototype.getItem=function(t){return this._storage.getItem(t)},t.prototype.setItem=function(t,e){this._storage.setItem(t,e)},t.prototype.getCookie=function(t,e){return this._storage.getCookie(t,e)},t.prototype.setCookie=function(t,e,i,n){this._storage.setCookie(t,e,i,n)},t.prototype.removeItem=function(t){this._storage.removeItem(t)},t}(),w=function(){function t(t,e,i){this.appid=t,this.domain=e,this.userAgent=window.navigator.userAgent,this.appVersion=window.navigator.appVersion,this.cookie_expire=i}return t.prototype.init=function(){var t=window.navigator.userAgent,e=window.navigator.language,i=document.referrer,n=i?h(i).hostname:"",o=u(window.location.href),r=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion)?"wap":"web";this.utm=function(t,e,i,n){var o=new E(!1),r=new E(!1,"session"),s=t?"_tea_utm_cache_"+t:"_tea_utm_cache",a=t?"_$utm_from_url_"+t:"_$utm_from_url",c={},h=["tr_shareuser","tr_admaster","tr_param1","tr_param2","tr_param3","tr_param4","$utm_from_url"],u={ad_id:Number(e.ad_id)||void 0,campaign_id:Number(e.campaign_id)||void 0,creative_id:Number(e.creative_id)||void 0,utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,utm_term:e.utm_term,utm_content:e.utm_content,tr_shareuser:e.tr_shareuser,tr_admaster:e.tr_admaster,tr_param1:e.tr_param1,tr_param2:e.tr_param2,tr_param3:e.tr_param3,tr_param4:e.tr_param4};try{var f=!1;for(var l in u)u[l]&&(-1!==h.indexOf(l)?(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data[l]=u[l]):c[l]=u[l],f=!0);if(f)r.setItem(a,"1"),o.setCookie(s,JSON.stringify(c),n,i);else{var p=o.getCookie(s,i);p&&(c=JSON.parse(p))}r.getItem(a)&&(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data.$utm_from_url=1)}catch(t){return u}return c}(this.appid,o,this.domain,this.cookie_expire);var s=this.browser(),a=this.os();return{browser:s.browser,browser_version:s.browser_version,platform:r,os_name:a.os_name,os_version:a.os_version,userAgent:t,screen_width:window.screen&&window.screen.width,screen_height:window.screen&&window.screen.height,device_model:this.getDeviceModel(a.os_name),language:e,referrer:i,referrer_host:n,utm:this.utm,latest_data:this.last(i,n)}},t.prototype.last=function(t,e){var i="",n="",o="",r=location.hostname,s=!1;if(t&&e&&r!==e){i=t,n=e,s=!0;var a=u(t);a.keyword&&(o=a.keyword)}return{$latest_referrer:i,$latest_referrer_host:n,$latest_search_keyword:o,isLast:s}},t.prototype.browser=function(){var t,e,i="",n=""+parseFloat(this.appVersion),o=this.userAgent;return-1!==o.indexOf("Edge")||-1!==o.indexOf("Edg")?(i="Microsoft Edge",-1!==o.indexOf("Edge")?(t=o.indexOf("Edge"),n=o.substring(t+5)):(t=o.indexOf("Edg"),n=o.substring(t+4))):-1!==(t=o.indexOf("MSIE"))?(i="Microsoft Internet Explorer",n=o.substring(t+5)):-1!==(t=o.indexOf("Lark"))?(i="Lark",n=o.substring(t+5,t+11)):-1!==(t=o.indexOf("MetaSr"))?(i="sougoubrowser",n=o.substring(t+7,t+10)):-1!==o.indexOf("MQQBrowser")||-1!==o.indexOf("QQBrowser")?(i="qqbrowser",-1!==o.indexOf("MQQBrowser")?(t=o.indexOf("MQQBrowser"),n=o.substring(t+11,t+15)):-1!==o.indexOf("QQBrowser")&&(t=o.indexOf("QQBrowser"),n=o.substring(t+10,t+17))):-1!==o.indexOf("Chrome")?-1!==(t=o.indexOf("MicroMessenger"))?(i="weixin",n=o.substring(t+15,t+20)):-1!==(t=o.indexOf("360"))?(i="360browser",n=o.substring(o.indexOf("Chrome")+7)):-1!==o.indexOf("baidubrowser")||-1!==o.indexOf("BIDUBrowser")?(-1!==o.indexOf("baidubrowser")?(t=o.indexOf("baidubrowser"),n=o.substring(t+13,t+16)):-1!==o.indexOf("BIDUBrowser")&&(t=o.indexOf("BIDUBrowser"),n=o.substring(t+12,t+15)),i="baidubrowser"):-1!==(t=o.indexOf("xiaomi"))?-1!==o.indexOf("openlanguagexiaomi")?(i="openlanguage xiaomi",n=o.substring(t+7,t+13)):(i="xiaomi",n=o.substring(t-7,t-1)):-1!==(t=o.indexOf("TTWebView"))?(i="TTWebView",n=o.substring(t+10,t+23)):(-1!==(t=o.indexOf("Chrome"))||-1!==(t=o.indexOf("Chrome")))&&(i="Chrome",n=o.substring(t+7)):-1!==o.indexOf("Safari")?-1!==(t=o.indexOf("QQ"))?(i="qqbrowser",n=o.substring(t+10,t+16)):-1!==(t=o.indexOf("Safari"))&&(i="Safari",n=o.substring(t+7),-1!==(t=o.indexOf("Version"))&&(n=o.substring(t+8))):-1!==(t=o.indexOf("Firefox"))?(i="Firefox",n=o.substring(t+8)):-1!==(t=o.indexOf("MicroMessenger"))?(i="weixin",n=o.substring(t+15,t+20)):-1!==(t=o.indexOf("QQ"))?(i="qqbrowser",n=o.substring(t+3,t+8)):-1!==(t=o.indexOf("Opera"))&&(i="Opera",n=o.substring(t+6),-1!==(t=o.indexOf("Version"))&&(n=o.substring(t+8))),-1!==(e=n.indexOf(";"))&&(n=n.substring(0,e)),-1!==(e=n.indexOf(" "))&&(n=n.substring(0,e)),-1!==(e=n.indexOf(")"))&&(n=n.substring(0,e)),{browser:i,browser_version:n}},t.prototype.os=function(){for(var t="",e="",i=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0|Windows NT 10.1)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Android",r:/Android/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/}],n=0;n<i.length;n++){var o=i[n];if(o.r.test(this.userAgent)){"Mac OS X"===(t=o.s)&&this.isNewIpad()&&(t="iOS");break}}var r=function(t,e){var i=t.exec(e);return i&&i[1]?i[1]:""},s=function(t,e){var i=RegExp("(?:^|[^A-Z0-9-_]|[^A-Z0-9-]_|sprd-)(?:"+t+")","i").exec(e);return i?i.slice(1)[0]:""};/Windows/.test(t)&&(e=r(/Windows (.*)/,t),t="windows");var a,c;switch(t){case"Mac OS X":e=s("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent),t="mac";break;case"Android":a=this.userAgent,(c=r(/Android ([\.\_\d]+)/,a))||(c=r(/Android\/([\.\_\d]+)/,a)),e=c,t="android";break;case"iOS":e=this.isNewIpad()?s("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent):(e=/OS (\d+)_(\d+)_?(\d+)?/.exec(this.appVersion))?e[1]+"."+e[2]+"."+(0|e[3]):"",t="ios"}return{os_name:t,os_version:e}},t.prototype.getDeviceModel=function(t){var e="";try{if("android"===t)navigator.userAgent.split(";").forEach((function(t){t.indexOf("Build/")>-1&&(e=t.slice(0,t.indexOf("Build/")))}));else if("ios"===t||"mac"===t||"windows"===t)if(this.isNewIpad())e="iPad";else{var i=navigator.userAgent.replace("Mozilla/5.0 (",""),n=i.indexOf(";");e=i.slice(0,n)}}catch(t){return e.trim()}return e.trim()},t.prototype.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&navigator.maxTouchPoints>1},t}(),S={cn:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},T={cn:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},D=function(){function t(t,e){this.collector=t,this.config=e,this.eventNameWhiteList=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure","_be_active"],this.paramsNameWhiteList=["$inactive","$inline","$target_uuid_list","$source_uuid","$is_spider","$source_id","$is_first_time","$user_unique_id_type","_staging_flag"],this.regStr=new RegExp("^[a-zA-Z0-9][a-z0-9A-Z_.-]{1,255}$")}return t.prototype.checkVerify=function(t){var e=this;if(!t||!t.length)return!1;var i=t[0];if(!i)return!1;var n=i.events,o=i.header;if(!n||!n.length)return!1;var r=!0;return n.forEach((function(t){e.checkEventName(t.event)||(r=!1,t.checkEvent="事件名不能以 $ or __开头"),e.checkEventParams(t.params)||(r=!1,t.checkParams="属性名不能以 $ or __开头")})),this.checkEventParams(o)||(r=!1),r},t.prototype.checkEventName=function(t){return!!t&&this.calculate(t,"event")},t.prototype.checkEventParams=function(t){var e=t;"string"==typeof t&&(e=JSON.parse(e));var i=!0;if(!Object.keys(e).length)return i;for(var n in e){if(!this.calculate(n,"params")){i=!1;break}if("string"==typeof e[n]&&e[n].length>1024){console.warn("params: "+n+" can not over 1024 byte, please check;"),i=!1;break}}return i},t.prototype.calculate=function(t,e){return-1!==("event"===e?this.eventNameWhiteList:"params"===e?this.paramsNameWhiteList:[]).indexOf(t)||(!new RegExp("^\\$").test(t)&&!new RegExp("^__").test(t)||(console.warn(e+" name: "+t+" can not start with $ or __, pleace check;"),!1))},t}();!function(t){t.Init="init",t.Config="config",t.Start="start",t.Ready="ready",t.TokenComplete="token-complete",t.TokenStorage="token-storage",t.TokenFetch="token-fetch",t.TokenError="token-error",t.ConfigUuid="config-uuid",t.ConfigWebId="config-webid",t.ConfigDomain="config-domain",t.CustomWebId="custom-webid",t.AnonymousId="anonymous-id",t.TokenChange="token-change",t.TokenReset="token-reset",t.ConfigTransform="config-transform",t.EnvTransform="env-transform",t.SessionReset="session-reset",t.SessionResetTime="session-reset-time",t.Event="event",t.Events="events",t.EventNow="event-now",t.CleanEvents="clean-events",t.BeconEvent="becon-event",t.SubmitBefore="submit-before",t.SubmitScuess="submit-scuess",t.SubmitAfter="submit-after",t.SubmitError="submit-error",t.SubmitVerifyH="submit-verify-h5",t.Stay="stay",t.ResetStay="reset-stay",t.StayReady="stay-ready",t.SetStay="set-stay",t.RouteChange="route-change",t.RouteReady="route-ready",t.Ab="ab",t.AbVar="ab-var",t.AbAllVars="ab-all-vars",t.AbConfig="ab-config",t.AbExternalVersion="ab-external-version",t.AbVersionChangeOn="ab-version-change-on",t.AbVersionChangeOff="ab-version-change-off",t.AbOpenLayer="ab-open-layer",t.AbCloseLayer="ab-close-layer",t.AbReady="ab-ready",t.AbComplete="ab-complete",t.AbTimeout="ab-timeout",t.Profile="profile",t.ProfileSet="profile-set",t.ProfileSetOnce="profile-set-once",t.ProfileUnset="profile-unset",t.ProfileIncrement="profile-increment",t.ProfileAppend="profile-append",t.ProfileClear="profile-clear",t.TrackDuration="track-duration",t.TrackDurationStart="track-duration-start",t.TrackDurationEnd="track-duration-end",t.TrackDurationPause="track-duration-pause",t.TrackDurationResume="tracl-duration-resume",t.Autotrack="autotrack",t.AutotrackReady="autotrack-ready",t.CepReady="cep-ready",t.TracerReady="tracer-ready"}(y||(y={})),function(t){t.DEBUGGER_MESSAGE="debugger-message",t.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",t.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",t.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",t.DEBUGGER_MESSAGE_EVENT="debugger-message-event",t.DEVTOOL_WEB_READY="devtool-web-ready"}(v||(v={}));var k=y,A=void 0,I=(new Date).getTimezoneOffset(),B=parseInt(""+-I/60,10),x=60*I,M=function(){function e(t,e){this.is_first_time=!0,this.configPersist=!1,this.initConfig=e,this.collect=t;var i=new w(e.app_id,e.cookie_domain||"",e.cookie_expire||7776e6).init();this.eventCheck=new D(t,e);var n="__tea_cache_first_"+e.app_id;this.configKey="__tea_cache_config_"+e.app_id,this.sessionStorage=new E(!1,"session"),this.localStorage=new E(!1,"local"),e.configPersist&&(this.configPersist=!0,this.storage=1===e.configPersist?this.sessionStorage:this.localStorage);var o=this.localStorage.getItem(n);o&&1==o?this.is_first_time=!1:(this.is_first_time=!0,this.localStorage.setItem(n,"1")),this.envInfo={user:{user_unique_id:A,user_type:A,user_id:A,user_is_auth:A,user_is_login:A,device_id:A,web_id:A,ip_addr_id:A,user_unique_id_type:A,anonymous_id:A},header:{app_id:A,app_name:A,app_install_id:A,install_id:A,app_package:A,app_channel:A,app_version:A,ab_version:A,os_name:i.os_name,os_version:i.os_version,device_model:i.device_model,ab_client:A,traffic_type:A,client_ip:A,device_brand:A,os_api:A,access:A,language:i.language,region:A,app_language:A,app_region:A,creative_id:i.utm.creative_id,ad_id:i.utm.ad_id,campaign_id:i.utm.campaign_id,log_type:A,rnd:A,platform:i.platform,sdk_version:"0.0.4",sdk_lib:"js",province:A,city:A,timezone:B,tz_offset:x,tz_name:A,sim_region:A,carrier:A,resolution:i.screen_width+"x"+i.screen_height,browser:i.browser,browser_version:i.browser_version,referrer:i.referrer,referrer_host:i.referrer_host,width:i.screen_width,height:i.screen_height,screen_width:i.screen_width,screen_height:i.screen_height,utm_term:i.utm.utm_term,utm_content:i.utm.utm_content,utm_source:i.utm.utm_source,utm_medium:i.utm.utm_medium,utm_campaign:i.utm.utm_campaign,tracer_data:JSON.stringify(i.utm.tracer_data),custom:{},wechat_unionid:A,wechat_openid:A}},this.ab_version="",this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(i),this.initDomain(),this.initABData()}return e.prototype.initDomain=function(){var t=this.initConfig.channel_domain;if(t)this.domain=t;else{var e=this.initConfig.channel;this.domain=a(S[e])}},e.prototype.setDomain=function(t){this.domain=t},e.prototype.getDomain=function(){return this.domain},e.prototype.initABData=function(){var t="__tea_sdk_ab_version_"+this.initConfig.app_id,e=null;if(this.initConfig.ab_cross){var i=this.localStorage.getCookie(t,this.initConfig.ab_cookie_domain);e=i?JSON.parse(i):null}else e=this.localStorage.getItem(t);this.setAbCache(e)},e.prototype.setAbCache=function(t){this.ab_cache=t},e.prototype.getAbCache=function(){return this.ab_cache},e.prototype.clearAbCache=function(){console.log("清除AB内存"),this.ab_cache={},this.ab_version=""},e.prototype.setAbVersion=function(t){this.ab_version=t},e.prototype.getAbVersion=function(){return this.ab_version},e.prototype.getUrl=function(t){var e="";switch(t){case"event":e="/list";break;case"webid":e="/webid";break;case"tobid":e="/tobid";break;case"profile":e="/profile/list"}var i="";return this.initConfig.caller&&(i="?sdk_version=0.0.4&sdk_name=web&app_id="+this.initConfig.app_id+"&caller="+this.initConfig.caller),this.initConfig.enable_encryption&&"event"===t&&"sm"!==this.initConfig.encryption_type&&(i=this.initConfig.caller?i+"&encryption=1":i+"?encryption=1"),this.initConfig.report_url?""+this.initConfig.report_url+i:""+this.getDomain()+e+i},e.prototype.setCustom=function(t){if(t&&t.latest_data&&t.latest_data.isLast)for(var e in delete t.latest_data.isLast,this.isLast=!0,t.latest_data)this.envInfo.header.custom[e]=t.latest_data[e]},e.prototype.set=function(e){var i=this;Object.keys(e).forEach((function(n){void 0!==e[n]&&null!==e[n]||i.delete(n);try{i.eventCheck.calculate(n,"config")}catch(t){}if("traffic_type"===n&&i.isLast&&(i.envInfo.header.custom.$latest_traffic_source_type=e[n]),"evtParams"===n)i.evtParams=t({},i.evtParams||{},e.evtParams||{});else if("_staging_flag"===n)i.evtParams=t({},i.evtParams||{},{_staging_flag:e._staging_flag});else if("reportErrorCallback"===n&&"function"==typeof e[n])i.reportErrorCallback=e[n];else{var o="",r="";if(n.indexOf(".")>-1){var s=n.split(".");o=s[0],r=s[1]}o?"user"===o||"header"===o?i.envInfo[o][r]=e[n]:i.envInfo.header.custom[r]=e[n]:Object.hasOwnProperty.call(i.envInfo.user,n)?["user_type","ip_addr_id"].indexOf(n)>-1?i.envInfo.user[n]=e[n]?Number(e[n]):e[n]:["user_id","web_id","user_unique_id","user_unique_id_type","anonymous_id"].indexOf(n)>-1?i.envInfo.user[n]=e[n]?String(e[n]):e[n]:["user_is_auth","user_is_login"].indexOf(n)>-1?i.envInfo.user[n]=Boolean(e[n]):"device_id"===n&&(i.envInfo.user[n]=e[n]):Object.hasOwnProperty.call(i.envInfo.header,n)?i.envInfo.header[n]=e[n]:i.envInfo.header.custom[n]=e[n]}}))},e.prototype.get=function(t){try{return t?"evtParams"===t?this.evtParams:"reportErrorCallback"===t?this[t]:Object.hasOwnProperty.call(this.envInfo.user,t)?this.envInfo.user[t]:Object.hasOwnProperty.call(this.envInfo.header,t)?this.envInfo.header[t]:JSON.parse(JSON.stringify(this.envInfo[t])):JSON.parse(JSON.stringify(this.envInfo))}catch(t){console.log("get config stringify error "),this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.setStore=function(t){try{if(!this.configPersist)return;var e=this.storage.getItem(this.configKey)||{};if(e&&Object.keys(t).length){var i=Object.assign(t,e);this.storage.setItem(this.configKey,i)}}catch(t){console.log("setStore error"),this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.getStore=function(){try{if(!this.configPersist)return null;var t=this.storage.getItem(this.configKey)||{};return t&&Object.keys(t).length?t:null}catch(t){return this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),null}},e.prototype.delete=function(t){try{if(!this.configPersist)return;var e=this.storage.getItem(this.configKey)||{};e&&Object.hasOwnProperty.call(e,t)&&(delete e[t],this.storage.setItem(this.configKey,e))}catch(t){this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),console.log("delete error")}},e}(),O=function(){function t(t,e){this.isLog=e||!1,this.name=t||""}return t.prototype.info=function(t){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},t.prototype.warn=function(t){this.isLog&&console.warn("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},t.prototype.error=function(t){this.isLog&&console.error("[instance: "+this.name+"] "+t)},t.prototype.throw=function(t){throw this.error(this.name),new Error(t)},t}(),C=function(){function t(t,e){this.native=t.enable_native||t["evitaN".split("").reverse().join("")],this.os=e.get("os_name")}var e=t.prototype;return e.bridgeInject=function(){try{return!!this.native&&(AppLogBridge?(console.log("AppLogBridge is injected"),!0):(console.log("AppLogBridge is not inject"),!1))}catch(t){return console.log("AppLogBridge is not inject"),!1}},e.bridgeReady=function(){var t=this;return new Promise((function(e,i){try{t.bridgeInject()?AppLogBridge.hasStarted((function(t){console.log("AppLogBridge is started? : "+t),t?e(!0):i(!1)})):i(!1)}catch(t){console.log("AppLogBridge, error:"+JSON.stringify(t.stack)),i(!1)}}))},e.setNativeAppId=function(t){try{AppLogBridge.setNativeAppId(JSON.stringify(t)),console.log("change bridge appid, event report with appid: "+t)}catch(t){console.error("setNativeAppId error")}},e.setConfig=function(t){var e=this;try{Object.keys(t).forEach((function(i){"user_unique_id"===i?e.setUserUniqueId(t[i]):t[i]?e.addHeaderInfo(i,t[i]):e.removeHeaderInfo(i)}))}catch(t){console.error("setConfig error")}},e.setUserUniqueId=function(t){try{AppLogBridge.setUserUniqueId(t)}catch(t){console.error("setUserUniqueId error")}},e.addHeaderInfo=function(t,e){try{AppLogBridge.addHeaderInfo(t,e)}catch(t){console.error("addHeaderInfo error")}},e.setHeaderInfo=function(t){try{AppLogBridge.setHeaderInfo(JSON.stringify(t))}catch(t){console.error("setHeaderInfo error")}},e.removeHeaderInfo=function(t){try{AppLogBridge.removeHeaderInfo(t)}catch(t){console.error("removeHeaderInfo error")}},e.reportPv=function(t){this.onEventV3("predefine_pageview",t)},e.onEventV3=function(t,e){try{AppLogBridge.onEventV3(t,e)}catch(t){console.error("onEventV3 error")}},e.profileSet=function(t){try{AppLogBridge.profileSet(t)}catch(t){console.error("profileSet error")}},e.profileSetOnce=function(t){try{AppLogBridge.profileSetOnce(t)}catch(t){console.error("profileSetOnce error")}},e.profileIncrement=function(t){try{AppLogBridge.profileIncrement(t)}catch(t){console.error("profileIncrement error")}},e.profileUnset=function(t){try{AppLogBridge.profileUnset(t)}catch(t){console.error("profileUnset error")}},e.profileAppend=function(t){try{AppLogBridge.profileAppend(t)}catch(t){console.error("profileAppend error")}},e.setExternalAbVersion=function(t){try{AppLogBridge.setExternalAbVersion(t)}catch(t){console.error("setExternalAbVersion error")}},e.getVar=function(t,e,i){try{"android"===this.os?i(AppLogBridge.getABTestConfigValueForKey(t,e)):AppLogBridge.getABTestConfigValueForKey(t,e,(function(t){i(t)}))}catch(t){console.error("getVar error"),i(e)}},e.getAllVars=function(t){try{"android"===this.os?t(AppLogBridge.getAllAbTestConfigs()):AppLogBridge.getAllAbTestConfigs((function(e){t(e)}))}catch(e){console.error("getAllVars error"),t(null)}},e.getAbSdkVersion=function(t){try{"android"===this.os?t(AppLogBridge.getAbSdkVersion()):AppLogBridge.getAbSdkVersion((function(e){t(e)}))}catch(e){console.error("getAbSdkVersion error"),t("")}},t}(),G=500,R=5005;function F(t,e,i,n,o,r,s,a,c,h){try{var u=new XMLHttpRequest,f=a||"POST";u.open(f,""+t,!0),c&&h?u.setRequestHeader("Content-Type","application/octet-stream;tt-data="+h):u.setRequestHeader("Content-Type","application/json; charset=utf-8"),s&&u.setRequestHeader("X-MCS-AppKey",""+s),n&&(u.withCredentials=!0),i&&(u.timeout=i,u.ontimeout=function(){r&&r(e,R)}),u.onload=function(){if(o){var t=null;if(u.responseText){try{t=JSON.parse(u.responseText)}catch(e){t={}}o(t,e)}}},u.onerror=function(){u.abort(),r&&r(e,G)},c?u.send(e):u.send(JSON.stringify(e))}catch(t){}}var z=4001,P=4e3,q=4002,U=4003,N=function(t,e,i,n){try{var o=t.match(/\/v\d\//),r="";r=o?o[0]:-1!==t.indexOf("/v1/")?"/v1/":"/v2/";var s=t.split(r)[0];if(!s)return void n(t,e,z);e.forEach((function(o){var r=function(t){var e="";for(var i in t)t.hasOwnProperty(i)&&void 0!==t[i]&&(e+="&"+i+"="+encodeURIComponent(JSON.stringify(t[i])));return"&"===e[0]?e.slice(1):e}(o),a=new Image(1,1);a.onload=function(){a=null,i&&i()},a.onerror=function(){a=null,n&&n(t,e,P)},a.src=s+"/gif?"+r}))}catch(i){n&&n(t,e,q,i.message)}},V=function(t,e,i,n,o,r,s,a,c){var h=window.navigator.userAgent;if(-1===window.navigator.appName.indexOf("Microsoft Internet Explorer")||-1===h.indexOf("MSIE 8.0")&&-1===h.indexOf("MSIE 9.0")){if(s)return window.navigator&&window.navigator.sendBeacon?void(window.navigator.sendBeacon(t,JSON.stringify(e))?o():r(t,e,U)):void N(t,e,o,r)}else N(t,e,o,r);F(t,e,i,n,o,r,"","",a,c)},K=function(){function e(){this.eventLimit=50,this.eventCache=[],this.beconEventCache=[]}return e.prototype.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=t.configManager,this.cacheStorgae=new E(!0),this.localStorage=new E(!1),this.eventCheck=new D(t,e),this.maxReport=e.max_report||20,this.reportTime=e.reportTime||30,this.timeout=e.timeout||1e5,this.reportUrl=this.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+this.configManager.get("app_id"),this.beconKey="__tea_cache_events_becon_"+this.configManager.get("app_id"),this.abKey="__tea_sdk_ab_version_"+this.configManager.get("app_id"),this.refer_key="__tea_cache_refer_"+this.configManager.get("app_id"),this.collect.on(k.Ready,(function(){i.reportAll(!1)})),this.collect.on(k.ConfigDomain,(function(){i.reportUrl=i.configManager.getUrl("event")})),this.collect.on(k.Event,(function(t){i.event(t)})),this.collect.on(k.BeconEvent,(function(t){i.beconEvent(t)})),this.collect.on(k.CleanEvents,(function(){i.reportAll(!1)})),this.linster()},e.prototype.linster=function(){var t=this;window.addEventListener("unload",(function(){t.reportAll(!0)}),!1),c((function(){t.reportAll(!0)})),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&t.reportAll(!0)}),!1)},e.prototype.reportAll=function(t){this.report(t),this.reportBecon()},e.prototype.event=function(t){var e=this;try{var n=i(t,this.cacheStorgae.getItem(this.eventKey)||[]);if(this.cacheStorgae.setItem(this.eventKey,n),this.reportTimeout&&clearTimeout(this.reportTimeout),n.length>=this.maxReport)this.report(!1);else{var o=this.reportTime;this.reportTimeout=setTimeout((function(){e.report(!1),e.reportTimeout=null}),o)}}catch(t){this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.beconEvent=function(t){var e=i(t,this.cacheStorgae.getItem(this.beconKey)||[]);this.cacheStorgae.setItem(this.beconKey,e),this.collect.destroyInstance||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(e)),!0))},e.prototype.reportBecon=function(){var t=this.cacheStorgae.getItem(this.beconKey)||[];t&&t.length&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(t)),!0))},e.prototype.report=function(t){if(!this.collect.destroyInstance&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var e=this.cacheStorgae.getItem(this.eventKey)||[];e.length&&(this.cacheStorgae.removeItem(this.eventKey),this.sliceEvent(e,t))}},e.prototype.sliceEvent=function(t,e){if(t.length>this.eventLimit)for(var i=0;i<t.length;i+=this.eventLimit){var n;n=t.slice(i,i+this.eventLimit);var o=this.split(this.merge(n));this.send(o,e)}else{o=this.split(this.merge(t));this.send(o,e)}},e.prototype.handleRefer=function(){var t="";try{if(this.config.spa||this.config.autotrack){var e=this.localStorage.getItem(this.refer_key)||{};t=e.routeChange?e.refer_key:this.configManager.get("referrer")}else t=this.configManager.get("referrer")}catch(e){t=document.referrer}return t},e.prototype.merge=function(e,i){var n=this,o=this.configManager.get(),r=o.header,s=o.user;r.referrer=this.handleRefer(),r.custom=JSON.stringify(r.custom);var a=this.configManager.get("evtParams"),c=this.configManager.get("user_unique_id_type"),h=e.map((function(e){try{if(Object.keys(a).length&&!i&&(e.params=t({},e.params,a)),n.collect.dynamicParamsFilter){var o=n.collect.dynamicParamsFilter();Object.keys(o).length&&(e.params=t({},e.params,o))}c&&(e.params.$user_unique_id_type=c);var r=n.configManager.getAbCache(),h=n.configManager.getAbVersion();return h&&r&&(n.config.disable_ab_reset||r.uuid===s.user_unique_id)&&(e.ab_sdk_version=h),e.session_id=n.collect.sessionManager.getSessionId(),e.params=JSON.stringify(e.params),e}catch(t){return n.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),e}})),u=[];if(!Object.keys(s).length)return console.warn("user info error,cant report"),u;this.config.enable_anonymousid&&delete s.web_id;var f=JSON.parse(JSON.stringify({events:h,user:s,header:r}));return f.local_time=Math.floor(Date.now()/1e3),f.verbose=1,f.user_unique_type=this.config.enable_ttwebid?this.config.user_unique_type:void 0,u.push(f),u},e.prototype.split=function(t){return t=t.map((function(t){var e=[];return e.push(t),e}))},e.prototype.send=function(t,e){var i=this;t.length&&t.forEach((function(t){try{var n=JSON.parse(JSON.stringify(t));i.config.filter&&((n=i.config.filter(n))||console.warn("filter must return data !!")),i.collect.eventFilter&&n&&((n=i.collect.eventFilter(n))||console.warn("filterEvent api must return data !!"));var o=n||t,r=JSON.parse(JSON.stringify(o));if(i.eventCheck.checkVerify(r),!o.length)return;i.collect.emit(k.SubmitBefore,o);var s=i.collect.cryptoData(o);V(i.reportUrl,s,i.timeout,!1,(function(t,e){t&&0!==t.e?(i.collect.emit(k.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:r,code:t.e,failType:"数据异常",status:"fail"})):(i.collect.emit(k.SubmitScuess,{eventData:e,res:t}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:r,code:200,status:"success"}))}),(function(t,e){i.configManager.get("reportErrorCallback")(t,e),i.collect.emit(k.SubmitError,{type:"f_net",eventData:t,errorCode:e}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报网络异常",time:Date.now(),data:r,code:e,failType:"网络异常",status:"fail"})}),e,i.config.enable_encryption,i.config.encryption_header),i.eventCheck.checkVerify(o),i.collect.emit(k.SubmitVerifyH,o),i.collect.emit(k.SubmitAfter,o)}catch(t){console.warn("something error, "+JSON.stringify(t.stack)),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}}))},e}(),L=function t(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t)},j=function(){return L().replace(/-/g,"").slice(0,19)},H=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))},J=function(){function t(){}return t.prototype.apply=function(t,e){var i=this;this.collect=t,this.storage=new E(!1,"session"),this.sessionKey="__tea_session_id_"+e.app_id,this.expireTime=e.expireTime||18e5,this.disableSession=e.disable_session,this.disableSession||(this.setSessionId(),this.collect.on(k.SessionReset,(function(){i.resetSessionId()})),this.collect.on(k.SessionResetTime,(function(){i.updateSessionIdTime()})))},t.prototype.updateSessionIdTime=function(){var t=this.storage.getItem(this.sessionKey);if(t&&t.sessionId){var e=t.timestamp;Date.now()-e>this.expireTime?t={sessionId:H(),timestamp:Date.now()}:t.timestamp=Date.now(),this.storage.setItem(this.sessionKey,t),this.resetExpTime()}},t.prototype.setSessionId=function(){var t=this,e=this.storage.getItem(this.sessionKey);e&&e.sessionId?e.timestamp=Date.now():e={sessionId:H(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,e),this.sessionExp=setInterval((function(){t.checkEXp()}),this.expireTime)},t.prototype.getSessionId=function(){var t=this.storage.getItem(this.sessionKey);return this.disableSession?"":t&&t.sessionId?t.sessionId:""},t.prototype.resetExpTime=function(){var t=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval((function(){t.checkEXp()}),this.expireTime))},t.prototype.resetSessionId=function(){var t={sessionId:H(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,t)},t.prototype.checkEXp=function(){var t=this.storage.getItem(this.sessionKey);t&&t.sessionId&&(Date.now()-t.timestamp+30>=this.expireTime&&(t={sessionId:H(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,t)))},t}(),W=function(){function t(){this.cacheToken={},this.enableCookie=!1,this.enableTTwebid=!1,this.enableCustomWebid=!1,this.enableAnonymousid=!1}return t.prototype.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=this.collect.configManager,this.storage=new E(!1),this.tokenKey="__tea_cache_tokens_"+e.app_id,this.enableAnonymousid=e.enable_anonymousid,this.enableTTwebid=e.enable_ttwebid,this.enableCustomWebid=e.enable_custom_webid,this.collect.on(k.AnonymousId,(function(t){i.setAnonymousId(t)})),this.collect.on(k.ConfigUuid,(function(t){i.setUuid(t)})),this.collect.on(k.ConfigWebId,(function(t){i.setWebId(t)})),this.enableCookie=e.cross_subdomain,this.expiresTime=e.cookie_expire||6048e5,this.cookieDomain=e.cookie_domain||"",this.checkStorage()},t.prototype.checkStorage=function(){var t=this;if(this.enableCookie){var e=this.storage.getCookie(this.tokenKey,this.cookieDomain);this.cacheToken=e&&"string"==typeof e?JSON.parse(e):{}}else this.cacheToken=this.storage.getItem(this.tokenKey)||{};this.tokenType=this.cacheToken&&this.cacheToken._type_?this.cacheToken._type_:"default","custom"!==this.tokenType||this.enableCustomWebid||this.enableAnonymousid?this.enableAnonymousid?this.completeAnonymous(this.cacheToken):this.enableCustomWebid?this.collect.on(k.CustomWebId,(function(){t.tokenReady=!0,t.collect.emit(k.TokenComplete)})):this.checkEnv()||(this.enableTTwebid?this.completeTtWid(this.cacheToken):this.check()):this.remoteWebid()},t.prototype.check=function(){this.cacheToken&&this.cacheToken.web_id?this.complete(this.cacheToken):this.config.disable_webid?this.complete({web_id:j(),user_unique_id:this.configManager.get("user_unique_id")||j()}):this.remoteWebid()},t.prototype.checkEnv=function(){var t=window.navigator.userAgent;if(-1!==t.indexOf("miniProgram")||-1!==t.indexOf("MiniProgram")){var e=u(window.location.href);return!(!e||!e.Web_ID)&&(this.complete({web_id:""+e.Web_ID,user_unique_id:this.configManager.get("user_unique_id")||""+e.Web_ID}),!0)}return!1},t.prototype.remoteWebid=function(){var t=this,e=this.configManager.getUrl("webid"),i={app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer,user_unique_id:""};this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 发起WEBID请求",logType:"fetch",level:"info",time:Date.now(),data:i});var n=j();F(e,this.collect.cryptoData(i),3e5,!1,(function(e){var i;e&&0===e.e?(i=e.web_id,t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"WEBID请求成功",logType:"fetch",level:"info",time:Date.now(),data:e})):(i=n,t.collect.configManager.set({localWebId:n}),t.collect.emit(k.TokenError),t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"WEBID请求返回值异常",logType:"fetch",level:"warn",time:Date.now(),data:e}),t.collect.logger.warn("appid: "+t.config.app_id+" get webid error, use local webid~")),t.complete({web_id:t.configManager.get("web_id")||i,user_unique_id:t.configManager.get("user_unique_id")||i})}),(function(){t.complete({web_id:t.configManager.get("web_id")||n,user_unique_id:t.configManager.get("user_unique_id")||n}),t.collect.configManager.set({localWebId:n}),t.collect.emit(k.TokenError),t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"WEBID请求网络异常",logType:"fetch",level:"error",time:Date.now(),data:null}),t.collect.logger.warn("appid: "+t.config.app_id+", get webid error, use local webid~")}),"","",this.config.enable_encryption,this.config.encryption_header)},t.prototype.complete=function(t){var e=t.web_id,i=t.user_unique_id;if(!e&&!i)return this.collect.emit(k.TokenError),void console.warn("token error");t.timestamp=Date.now(),this.collect.configManager.set({web_id:e,user_unique_id:i}),this.setStorage(t),this.tokenReady=!0,this.collect.emit(k.TokenComplete)},t.prototype.completeAnonymous=function(t){var e=t.anonymous_id||H(),i=t.user_unique_id||this.configManager.get("user_unique_id");this.collect.configManager.set({anonymous_id:e,user_unique_id:i||e}),t.anonymous_id=e,t.user_unique_id=i||e,this.setStorage(t),this.tokenReady=!0,this.collect.emit(k.TokenComplete)},t.prototype.completeTtWid=function(t){var e=t.user_unique_id||"",i=this.configManager.get("user_unique_id");this.configManager.set({user_unique_id:i||e}),this.setStorage(t),this.tokenReady=!0,this.collect.emit(k.TokenComplete)},t.prototype.setUuid=function(t){if(t&&-1===["null","undefined","Null","None"].indexOf(t)){var e=String(t),i=this.configManager.get("user_unique_id"),n=this.cacheToken&&this.cacheToken.user_unique_id;if(e===i&&e===n)return;this.configManager.set({user_unique_id:e}),this.cacheToken||(this.cacheToken={}),this.cacheToken.user_unique_id=e,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(k.TokenChange,{type:"uuid",id:t}),this.collect.emit(k.SessionReset)}else this.clearUuid()},t.prototype.clearUuid=function(){if(!this.config.enable_ttwebid){var t=this.enableAnonymousid?this.configManager.get("anonymous_id"):this.configManager.get("web_id");this.configManager.get("user_unique_id")!==t&&(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(k.TokenReset))}},t.prototype.setAnonymousId=function(t){if(t&&this.enableAnonymousid){var e=this.configManager.get("anonymous_id"),i=this.configManager.get("user_unique_id");e!==t&&(e!==i&&i||(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.collect.emit(k.TokenChange,{type:"uuid",id:t})),this.configManager.set({anonymous_id:t}),this.cacheToken.anonymous_id=t,this.collect.emit(k.TokenChange,{type:"anonymous_id",id:t}),this.setStorage(this.cacheToken))}},t.prototype.setWebId=function(t){if(t&&!this.config.enable_ttwebid&&!this.enableAnonymousid){var e=this.configManager.get("web_id"),i=this.configManager.get("user_unique_id");i&&i!==e||(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.collect.emit(k.TokenChange,{type:"uuid",id:t})),e!==t&&(this.configManager.set({web_id:t}),this.cacheToken.web_id=t,this.collect.emit(k.TokenChange,{type:"webid",id:t})),this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken)}},t.prototype.setStorage=function(t){t._type_=this.enableCustomWebid?"custom":"default",delete t["diss".split("").reverse().join("")],this.enableCookie||this.enableTTwebid?this.storage.setCookie(this.tokenKey,t,this.expiresTime,this.cookieDomain):this.storage.setItem(this.tokenKey,t),this.cacheToken=t},t.prototype.getReady=function(){return this.tokenReady},t.prototype.getTobId=function(){var t=this,e=this.configManager.getUrl("tobid"),i={app_id:this.config.app_id,user_unique_id:this.configManager.get("user_unique_id"),user_unique_id_type:this.configManager.get("user_unique_id_type")};this.enableAnonymousid?i.anonymous_id=this.configManager.get("anonymous_id"):i.web_id=this.configManager.get("web_id");var n=this.collect.cryptoData(i);return new Promise((function(i){F(e,n,3e4,t.enableTTwebid,(function(t){t&&0===t.e?i(t.tobid):i("")}),(function(){i("")}),"","",t.config.enable_encryption,t.config.encryption_header)}))},t}(),Z=function(){function t(t,e){this.devToolReady=!1,this.devToolOrigin="*",this.sendAlready=!1,this.collect=t,this.config=e,this.app_id=e.app_id,this.filterEvent=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure","bav2b_page","bav2b_beat","bav2b_page_statistics","bav2b_click","bav2b_page_exposure","_be_active","predefine_pageview","__profile_set","__profile_set_once","__profile_increment","__profile_unset","__profile_append","predefine_page_alive","predefine_page_close","abtest_exposure"],e.enable_debug&&this.load()}return t.prototype.loadScript=function(t){try{var e=document.createElement("script");e.src=t,e.onerror=function(){console.log("load DevTool render fail")},e.onload=function(){console.log("load DevTool render success")},document.getElementsByTagName("body")[0].appendChild(e)}catch(t){console.log("devTool load fail, "+t.message)}},t.prototype.load=function(){try{this.loadBaseInfo(),this.loadHook();var t=u(window.location.href);if(!t.open_devtool_web||parseInt(t.app_id)!==this.app_id)return;this.addLintener(),this.loadDebuggerModule(),this.loadDevTool()}catch(t){console.log("debug fail, "+t.message)}},t.prototype.loadDevTool=function(){this.loadScript("https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/devtool/debug-web.js")},t.prototype.loadBaseInfo=function(){var t=this;this.info=[{title:"基本信息",type:1,infoName:{app_id:this.config.app_id,channel:this.config.channel,"上报域名":this.collect.configManager.getDomain(),"SDK版本":"0.0.4","SDK引入方式":"npm"}},{title:"用户信息",type:2,infoName:{uuid:this.collect.configManager.get("user").user_unique_id||"",web_id:this.collect.configManager.get("user").web_id||"",ssid:"点击获取SSID"}},{title:"公共参数信息",type:2,infoName:{"浏览器":this.collect.configManager.get("browser"),"浏览器版本":this.collect.configManager.get("browser_version"),"平台":this.collect.configManager.get("platform"),"设备型号":this.collect.configManager.get("device_model"),"操作系统":this.collect.configManager.get("os_name"),"操作系统版本":this.collect.configManager.get("os_version"),"屏幕分辨率":this.collect.configManager.get("resolution"),"来源":this.collect.configManager.get("referrer"),"自定义信息":""}},{title:"配置信息",type:3,infoName:{"全埋点":!!this.config.autotrack,"停留时长":!!this.config.enable_stay_duration}},{title:"A/B配置信息",type:4,infoName:{"A/B实验":!!this.config.enable_ab_test}},{title:"客户端信息",type:3,infoName:{"打通开关":!!this.config.Native}}],this.log=[],this.event=[],this.collect.on(k.Ready,(function(){t.info[1].infoName.uuid=t.collect.configManager.get("user").user_unique_id,t.info[1].infoName.web_id=t.collect.configManager.get("user").web_id,t.info[2].infoName["自定义信息"]=JSON.stringify(t.collect.configManager.get("custom")),t.config.enable_ab_test&&(t.info[4].infoName["已曝光VID"]=t.collect.configManager.getAbVersion(),t.info[4].infoName["A/B域名"]=t.config.ab_channel_domain||a(T[t.config.channel]),t.info[4].infoName["全部配置"]=t.collect.configManager.getAbData()),t.config.Native&&(t.info[5].infoName["是否打通"]=!!t.collect.bridgeReport)}))},t.prototype.loadHook=function(){var t=this;this.collect.on(v.DEBUGGER_MESSAGE,(function(e){switch(e.type){case v.DEBUGGER_MESSAGE_SDK:var i={time:e.time,type:e.logType||"sdk",level:e.level,name:e.info,show:!0,levelShow:!0,needDesc:!!e.data};return e.data&&(i.desc={content:JSON.stringify(e.data)}),t.updateLog(i),e.secType&&"AB"===e.secType?(t.info[4].infoName["已曝光VID"]=t.collect.configManager.getAbVersion(),t.info[4].infoName["全部配置"]=t.collect.configManager.getAbData()):"USER"===e.secType&&(t.info[1].infoName.uuid=t.collect.configManager.get("user").user_unique_id,t.info[1].infoName.web_id=t.collect.configManager.get("user").web_id),void t.updateInfo();case v.DEBUGGER_MESSAGE_EVENT:if(e.data&&e.data.length){var n=e.data[0],o=n.events;if(!o.length)return;o.forEach((function(i){i.checkShow=!0,i.searchShow=!0,i.success=e.status,i.type=-1!==t.filterEvent.indexOf(i.event)?"sdk":"cus",i.type=t.collect.bridgeReport?"bridge":i.type,i.info="","fail"===e.status&&(i.info={message:"code: "+e.code+", msg: "+e.failType})})),t.updateEvent(n)}return}}))},t.prototype.addLintener=function(){var t=this;window.addEventListener("message",(function(e){if(e&&e.data&&"devtool:web:ready"===e.data.type){if(t.devToolOrigin=e.origin,t.devToolReady=!0,t.sendAlready)return;console.log("inittttt"),t.sendData("devtool:web:init",{info:t.info,log:t.log,event:t.event}),t.sendAlready=!0}e&&e.data&&"devtool:web:ssid"===e.data.type&&t.collect.getToken((function(e){t.info[1].infoName.ssid=e.tobid,t.updateInfo()}))}))},t.prototype.sendData=function(t,e){try{var i={type:t,payload:e};(window.opener||window.parent).postMessage(i,this.devToolOrigin)}catch(t){}},t.prototype.updateInfo=function(){this.devToolReady&&this.sendData("devtool:web:info",this.info)},t.prototype.updateLog=function(t){this.devToolReady?this.sendData("devtool:web:log",t):this.log.push(t)},t.prototype.updateEvent=function(t){this.devToolReady?this.sendData("devtool:web:event",t):this.event.push(t)},t.prototype.loadDebuggerModule=function(){var t=document.head||document.getElementsByTagName("head")[0],e=document.createElement("style");e.appendChild(document.createTextNode("#debugger-applog-web {\n position: fixed;\n width: 90px;\n height: 30px;\n background: #23c243;\n border-radius: 6px;\n color: #fff;\n font-size: 12px;\n bottom: 5%;\n right: 10%;\n text-align: center;\n line-height: 30px;\n cursor: pointer;\n z-index:100;\n }")),t.appendChild(e);var i=document.createElement("div");i.innerHTML='<div id="debugger-applog-web" class="debugger-applog-web">AppLog调试</div>';var n=document.createElement("div");n.innerHTML='<div id="debugger-container" class="debugger-container"></div>',document.getElementsByTagName("body")[0].appendChild(i),document.getElementsByTagName("body")[0].appendChild(n),document.getElementById("debugger-applog-web").addEventListener("click",(function(){(window.opener||window.parent).postMessage({type:"devtool:web:open-draw"},location.origin)}))},t}(),X=d((function(t,e){(function(){var e;function i(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function n(){return new i(null)}var o="undefined"!=typeof navigator;o&&"Microsoft Internet Explorer"==navigator.appName?(i.prototype.am=function(t,e,i,n,o,r){for(var s=32767&e,a=e>>15;--r>=0;){var c=32767&this[t],h=this[t++]>>15,u=a*c+h*s;o=((c=s*c+((32767&u)<<15)+i[n]+(1073741823&o))>>>30)+(u>>>15)+a*h+(o>>>30),i[n++]=1073741823&c}return o},e=30):o&&"Netscape"!=navigator.appName?(i.prototype.am=function(t,e,i,n,o,r){for(;--r>=0;){var s=e*this[t++]+i[n]+o;o=Math.floor(s/67108864),i[n++]=67108863&s}return o},e=26):(i.prototype.am=function(t,e,i,n,o,r){for(var s=16383&e,a=e>>14;--r>=0;){var c=16383&this[t],h=this[t++]>>14,u=a*c+h*s;o=((c=s*c+((16383&u)<<14)+i[n]+o)>>28)+(u>>14)+a*h,i[n++]=268435455&c}return o},e=28),i.prototype.DB=e,i.prototype.DM=(1<<e)-1,i.prototype.DV=1<<e;i.prototype.FV=Math.pow(2,52),i.prototype.F1=52-e,i.prototype.F2=2*e-52;var r,s,a=new Array;for(r="0".charCodeAt(0),s=0;s<=9;++s)a[r++]=s;for(r="a".charCodeAt(0),s=10;s<36;++s)a[r++]=s;for(r="A".charCodeAt(0),s=10;s<36;++s)a[r++]=s;function c(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function h(t,e){var i=a[t.charCodeAt(e)];return null==i?-1:i}function u(t){var e=n();return e.fromInt(t),e}function f(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function l(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function d(t,e){return t&e}function g(t,e){return t|e}function m(t,e){return t^e}function y(t,e){return t&~e}function v(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function _(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function b(){}function E(t){return t}function w(t){this.r2=n(),this.q3=n(),i.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}l.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},l.prototype.revert=function(t){return t},l.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},l.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},l.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=n();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(i.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=n();return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],n=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},i.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},i.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},i.prototype.fromString=function(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return void this.fromRadix(t,e);n=2}this.t=0,this.s=0;for(var o=t.length,r=!1,s=0;--o>=0;){var a=8==n?255&t[o]:h(t,o);a<0?"-"==t.charAt(o)&&(r=!0):(r=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=n)>=this.DB&&(s-=this.DB))}8==n&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),r&&i.ZERO.subTo(this,this)},i.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},i.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},i.prototype.drShiftTo=function(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s},i.prototype.lShiftTo=function(t,e){var i,n=t%this.DB,o=this.DB-n,r=(1<<o)-1,s=Math.floor(t/this.DB),a=this.s<<n&this.DM;for(i=this.t-1;i>=0;--i)e[i+s+1]=this[i]>>o|a,a=(this[i]&r)<<n;for(i=s-1;i>=0;--i)e[i]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},i.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,o=this.DB-n,r=(1<<n)-1;e[0]=this[i]>>n;for(var s=i+1;s<this.t;++s)e[s-i-1]|=(this[s]&r)<<o,e[s-i]=this[s]>>n;n>0&&(e[this.t-i-1]|=(this.s&r)<<o),e.t=this.t-i,e.clamp()}},i.prototype.subTo=function(t,e){for(var i=0,n=0,o=Math.min(t.t,this.t);i<o;)n+=this[i]-t[i],e[i++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;i<this.t;)n+=this[i],e[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<t.t;)n-=t[i],e[i++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},i.prototype.multiplyTo=function(t,e){var n=this.abs(),o=t.abs(),r=n.t;for(e.t=r+o.t;--r>=0;)e[r]=0;for(r=0;r<o.t;++r)e[r+n.t]=n.am(0,o[r],e,r,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&i.ZERO.subTo(e,e)},i.prototype.squareTo=function(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var n=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,n,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},i.prototype.divRemTo=function(t,e,o){var r=t.abs();if(!(r.t<=0)){var s=this.abs();if(s.t<r.t)return null!=e&&e.fromInt(0),void(null!=o&&this.copyTo(o));null==o&&(o=n());var a=n(),c=this.s,h=t.s,u=this.DB-f(r[r.t-1]);u>0?(r.lShiftTo(u,a),s.lShiftTo(u,o)):(r.copyTo(a),s.copyTo(o));var l=a.t,p=a[l-1];if(0!=p){var d=p*(1<<this.F1)+(l>1?a[l-2]>>this.F2:0),g=this.FV/d,m=(1<<this.F1)/d,y=1<<this.F2,v=o.t,_=v-l,b=null==e?n():e;for(a.dlShiftTo(_,b),o.compareTo(b)>=0&&(o[o.t++]=1,o.subTo(b,o)),i.ONE.dlShiftTo(l,b),b.subTo(a,a);a.t<l;)a[a.t++]=0;for(;--_>=0;){var E=o[--v]==p?this.DM:Math.floor(o[v]*g+(o[v-1]+y)*m);if((o[v]+=a.am(0,E,o,_,0,l))<E)for(a.dlShiftTo(_,b),o.subTo(b,o);o[v]<--E;)o.subTo(b,o)}null!=e&&(o.drShiftTo(l,e),c!=h&&i.ZERO.subTo(e,e)),o.t=l,o.clamp(),u>0&&o.rShiftTo(u,o),c<0&&i.ZERO.subTo(o,o)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},i.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},i.prototype.exp=function(t,e){if(t>4294967295||t<1)return i.ONE;var o=n(),r=n(),s=e.convert(this),a=f(t)-1;for(s.copyTo(o);--a>=0;)if(e.sqrTo(o,r),(t&1<<a)>0)e.mulTo(r,s,o);else{var c=o;o=r,r=c}return e.revert(o)},i.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<<e)-1,o=!1,r="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(i=this[s]>>a)>0&&(o=!0,r=c(i));s>=0;)a<e?(i=(this[s]&(1<<a)-1)<<e-a,i|=this[--s]>>(a+=this.DB-e)):(i=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),i>0&&(o=!0),o&&(r+=c(i));return o?r:"0"},i.prototype.negate=function(){var t=n();return i.ZERO.subTo(this,t),t},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this[this.t-1]^this.s&this.DM)},i.prototype.mod=function(t){var e=n();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(i.ZERO)>0&&t.subTo(e,e),e},i.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new l(e):new p(e),this.exp(t,i)},i.ZERO=u(0),i.ONE=u(1),b.prototype.convert=E,b.prototype.revert=E,b.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},b.prototype.sqrTo=function(t,e){t.squareTo(e)},w.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=n();return t.copyTo(e),this.reduce(e),e},w.prototype.revert=function(t){return t},w.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},w.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},w.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var S,T,D,k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];function I(){var t;t=(new Date).getTime(),T[D++]^=255&t,T[D++]^=t>>8&255,T[D++]^=t>>16&255,T[D++]^=t>>24&255,D>=R&&(D-=R)}if(i.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},i.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),o=u(i),r=n(),s=n(),a="";for(this.divRemTo(o,r,s);r.signum()>0;)a=(i+s.intValue()).toString(t).substr(1)+a,r.divRemTo(o,r,s);return s.intValue().toString(t)+a},i.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),o=Math.pow(e,n),r=!1,s=0,a=0,c=0;c<t.length;++c){var u=h(t,c);u<0?"-"==t.charAt(c)&&0==this.signum()&&(r=!0):(a=e*a+u,++s>=n&&(this.dMultiply(o),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),r&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(t,e,n){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),g,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(i.ONE.shiftLeft(t-1),this);else{var o=new Array,r=7&t;o.length=1+(t>>3),e.nextBytes(o),r>0?o[0]&=(1<<r)-1:o[0]=0,this.fromString(o,256)}},i.prototype.bitwiseTo=function(t,e,i){var n,o,r=Math.min(t.t,this.t);for(n=0;n<r;++n)i[n]=e(this[n],t[n]);if(t.t<this.t){for(o=t.s&this.DM,n=r;n<this.t;++n)i[n]=e(this[n],o);i.t=this.t}else{for(o=this.s&this.DM,n=r;n<t.t;++n)i[n]=e(o,t[n]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},i.prototype.changeBit=function(t,e){var n=i.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n},i.prototype.addTo=function(t,e){for(var i=0,n=0,o=Math.min(t.t,this.t);i<o;)n+=this[i]+t[i],e[i++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;i<this.t;)n+=this[i],e[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<t.t;)n+=t[i],e[i++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},i.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},i.prototype.multiplyLowerTo=function(t,e,i){var n,o=Math.min(this.t+t.t,e);for(i.s=0,i.t=o;o>0;)i[--o]=0;for(n=i.t-this.t;o<n;++o)i[o+this.t]=this.am(0,t[o],i,o,0,this.t);for(n=Math.min(t.t,e);o<n;++o)this.am(0,t[o],i,o,0,e-o);i.clamp()},i.prototype.multiplyUpperTo=function(t,e,i){--e;var n=i.t=this.t+t.t-e;for(i.s=0;--n>=0;)i[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)i[this.t+n-e]=this.am(e-n,t[n],i,0,0,this.t+n-e);i.clamp(),i.drShiftTo(1,i)},i.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},i.prototype.millerRabin=function(t){var e=this.subtract(i.ONE),o=e.getLowestSetBit();if(o<=0)return!1;var r=e.shiftRight(o);(t=t+1>>1)>k.length&&(t=k.length);for(var s=n(),a=0;a<t;++a){s.fromInt(k[Math.floor(Math.random()*k.length)]);var c=s.modPow(r,this);if(0!=c.compareTo(i.ONE)&&0!=c.compareTo(e)){for(var h=1;h++<o&&0!=c.compareTo(e);)if(0==(c=c.modPowInt(2,this)).compareTo(i.ONE))return!1;if(0!=c.compareTo(e))return!1}}return!0},i.prototype.clone=function(){var t=n();return this.copyTo(t),t},i.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},i.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},i.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},i.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,o=0;if(t-- >0)for(n<this.DB&&(i=this[t]>>n)!=(this.s&this.DM)>>n&&(e[o++]=i|this.s<<this.DB-n);t>=0;)n<8?(i=(this[t]&(1<<n)-1)<<8-n,i|=this[--t]>>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==o&&(128&this.s)!=(128&i)&&++o,(o>0||i!=this.s)&&(e[o++]=i);return e},i.prototype.equals=function(t){return 0==this.compareTo(t)},i.prototype.min=function(t){return this.compareTo(t)<0?this:t},i.prototype.max=function(t){return this.compareTo(t)>0?this:t},i.prototype.and=function(t){var e=n();return this.bitwiseTo(t,d,e),e},i.prototype.or=function(t){var e=n();return this.bitwiseTo(t,g,e),e},i.prototype.xor=function(t){var e=n();return this.bitwiseTo(t,m,e),e},i.prototype.andNot=function(t){var e=n();return this.bitwiseTo(t,y,e),e},i.prototype.not=function(){for(var t=n(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},i.prototype.shiftLeft=function(t){var e=n();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},i.prototype.shiftRight=function(t){var e=n();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},i.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+v(this[t]);return this.s<0?this.t*this.DB:-1},i.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=_(this[i]^e);return t},i.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},i.prototype.setBit=function(t){return this.changeBit(t,g)},i.prototype.clearBit=function(t){return this.changeBit(t,y)},i.prototype.flipBit=function(t){return this.changeBit(t,m)},i.prototype.add=function(t){var e=n();return this.addTo(t,e),e},i.prototype.subtract=function(t){var e=n();return this.subTo(t,e),e},i.prototype.multiply=function(t){var e=n();return this.multiplyTo(t,e),e},i.prototype.divide=function(t){var e=n();return this.divRemTo(t,e,null),e},i.prototype.remainder=function(t){var e=n();return this.divRemTo(t,null,e),e},i.prototype.divideAndRemainder=function(t){var e=n(),i=n();return this.divRemTo(t,e,i),new Array(e,i)},i.prototype.modPow=function(t,e){var i,o,r=t.bitLength(),s=u(1);if(r<=0)return s;i=r<18?1:r<48?3:r<144?4:r<768?5:6,o=r<8?new l(e):e.isEven()?new w(e):new p(e);var a=new Array,c=3,h=i-1,d=(1<<i)-1;if(a[1]=o.convert(this),i>1){var g=n();for(o.sqrTo(a[1],g);c<=d;)a[c]=n(),o.mulTo(g,a[c-2],a[c]),c+=2}var m,y,v=t.t-1,_=!0,b=n();for(r=f(t[v])-1;v>=0;){for(r>=h?m=t[v]>>r-h&d:(m=(t[v]&(1<<r+1)-1)<<h-r,v>0&&(m|=t[v-1]>>this.DB+r-h)),c=i;0==(1&m);)m>>=1,--c;if((r-=c)<0&&(r+=this.DB,--v),_)a[m].copyTo(s),_=!1;else{for(;c>1;)o.sqrTo(s,b),o.sqrTo(b,s),c-=2;c>0?o.sqrTo(s,b):(y=s,s=b,b=y),o.mulTo(b,a[m],s)}for(;v>=0&&0==(t[v]&1<<r);)o.sqrTo(s,b),y=s,s=b,b=y,--r<0&&(r=this.DB-1,--v)}return o.revert(s)},i.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return i.ZERO;for(var n=t.clone(),o=this.clone(),r=u(1),s=u(0),a=u(0),c=u(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(r.isEven()&&s.isEven()||(r.addTo(this,r),s.subTo(t,s)),r.rShiftTo(1,r)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;o.isEven();)o.rShiftTo(1,o),e?(a.isEven()&&c.isEven()||(a.addTo(this,a),c.subTo(t,c)),a.rShiftTo(1,a)):c.isEven()||c.subTo(t,c),c.rShiftTo(1,c);n.compareTo(o)>=0?(n.subTo(o,n),e&&r.subTo(a,r),s.subTo(c,s)):(o.subTo(n,o),e&&a.subTo(r,a),c.subTo(s,c))}return 0!=o.compareTo(i.ONE)?i.ZERO:c.compareTo(t)>=0?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c},i.prototype.pow=function(t){return this.exp(t,new b)},i.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var o=e.getLowestSetBit(),r=i.getLowestSetBit();if(r<0)return e;for(o<r&&(r=o),r>0&&(e.rShiftTo(r,e),i.rShiftTo(r,i));e.signum()>0;)(o=e.getLowestSetBit())>0&&e.rShiftTo(o,e),(o=i.getLowestSetBit())>0&&i.rShiftTo(o,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return r>0&&i.lShiftTo(r,i),i},i.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=k[k.length-1]){for(e=0;e<k.length;++e)if(i[0]==k[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<k.length;){for(var n=k[e],o=e+1;o<k.length&&n<A;)n*=k[o++];for(n=i.modInt(n);e<o;)if(n%k[e++]==0)return!1}return i.millerRabin(t)},i.prototype.square=function(){var t=n();return this.squareTo(t),t},i.prototype.Barrett=w,null==T){var B;if(T=new Array,D=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var x=new Uint8Array(32);for(window.crypto.getRandomValues(x),B=0;B<32;++B)T[D++]=x[B]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var M=window.crypto.random(32);for(B=0;B<M.length;++B)T[D++]=255&M.charCodeAt(B)}for(;D<R;)B=Math.floor(65536*Math.random()),T[D++]=B>>>8,T[D++]=255&B;D=0,I()}function O(){if(null==S){for(I(),(S=new G).init(T),D=0;D<T.length;++D)T[D]=0;D=0}return S.next()}function C(){}function G(){this.i=0,this.j=0,this.S=new Array}C.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=O()},G.prototype.init=function(t){var e,i,n;for(e=0;e<256;++e)this.S[e]=e;for(i=0,e=0;e<256;++e)i=i+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[i],this.S[i]=n;this.i=0,this.j=0},G.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var R=256;t.exports={default:i,BigInteger:i,SecureRandom:C}}).call(p)}));X.BigInteger,X.SecureRandom;const{BigInteger:$}=X;class Q{constructor(){this.tlv=null,this.t="00",this.l="00",this.v=""}getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv}getLength(){const t=this.v.length/2;let e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;return(128+e.length/2).toString(16)+e}getValue(){return""}}class Y extends Q{constructor(t){super(),this.t="02",t&&(this.v=function(t){let e=t.toString(16);if("-"!==e[0])e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{e=e.substr(1);let i=e.length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);let n="";for(let t=0;t<i;t++)n+="f";n=new $(n,16),e=n.xor(t).add($.ONE),e=e.toString(16).replace(/^-/,"")}return e}(t))}getValue(){return this.v}}class tt extends Q{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map((t=>t.getEncodedHex())).join(""),this.v}}function et(t,e){return+t[e+2]<8?1:128&+t.substr(e+2,2)}function it(t,e){const i=et(t,e),n=t.substr(e+2,2*i);if(!n)return-1;return(+n[0]<8?new $(n,16):new $(n.substr(2),16)).intValue()}function nt(t,e){return e+2*(et(t,e)+1)}var ot={encodeDer(t,e){const i=new Y(t),n=new Y(e);return new tt([i,n]).getEncodedHex()},decodeDer(t){const e=nt(t,0),i=nt(t,e),n=it(t,e),o=t.substr(i,2*n),r=i+o.length,s=nt(t,r),a=it(t,r),c=t.substr(s,2*a);return{r:new $(o,16),s:new $(c,16)}}};const{BigInteger:rt}=X,st=new rt("2"),at=new rt("3");class ct{constructor(t,e){this.x=e,this.q=t}equals(t){return t===this||this.q.equals(t.q)&&this.x.equals(t.x)}toBigInteger(){return this.x}negate(){return new ct(this.q,this.x.negate().mod(this.q))}add(t){return new ct(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new ct(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new ct(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new ct(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new ct(this.q,this.x.square().mod(this.q))}}class ht{constructor(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?rt.ONE:n,this.zinv=null}getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}equals(t){if(t===this)return!0;if(this.isInfinity())return t.isInfinity();if(t.isInfinity())return this.isInfinity();if(!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(rt.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(rt.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(rt.ZERO)&&!this.y.toBigInteger().equals(rt.ZERO)}negate(){return new ht(this.curve,this.x,this.y.negate(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;const e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=this.z,o=t.x.toBigInteger(),r=t.y.toBigInteger(),s=t.z,a=this.curve.q,c=e.multiply(s).mod(a),h=o.multiply(n).mod(a),u=c.subtract(h),f=i.multiply(s).mod(a),l=r.multiply(n).mod(a),p=f.subtract(l);if(rt.ZERO.equals(u))return rt.ZERO.equals(p)?this.twice():this.curve.infinity;const d=c.add(h),g=n.multiply(s).mod(a),m=u.square().mod(a),y=u.multiply(m).mod(a),v=g.multiply(p.square()).subtract(d.multiply(m)).mod(a),_=u.multiply(v).mod(a),b=p.multiply(m.multiply(c).subtract(v)).subtract(f.multiply(y)).mod(a),E=y.multiply(g).mod(a);return new ht(this.curve,this.curve.fromBigInteger(_),this.curve.fromBigInteger(b),E)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),e=this.y.toBigInteger(),i=this.z,n=this.curve.q,o=this.curve.a.toBigInteger(),r=t.square().multiply(at).add(o.multiply(i.square())).mod(n),s=e.shiftLeft(1).multiply(i).mod(n),a=e.square().mod(n),c=a.multiply(t).multiply(i).mod(n),h=s.square().mod(n),u=r.square().subtract(c.shiftLeft(3)).mod(n),f=s.multiply(u).mod(n),l=r.multiply(c.shiftLeft(2).subtract(u)).subtract(h.shiftLeft(1).multiply(a)).mod(n),p=s.multiply(h).mod(n);return new ht(this.curve,this.curve.fromBigInteger(f),this.curve.fromBigInteger(l),p)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const e=t.multiply(at),i=this.negate();let n=this;for(let o=e.bitLength()-2;o>0;o--){n=n.twice();const r=e.testBit(o);r!==t.testBit(o)&&(n=n.add(r?this:i))}return n}}var ut={ECPointFp:ht,ECCurveFp:class{constructor(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ht(this,null,null)}equals(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}fromBigInteger(t){return new ct(this.q,t)}decodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const e=this.fromBigInteger(new rt(t.substr(2),16));let i=this.fromBigInteger(e.multiply(e.square()).add(e.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new rt("4")).add(rt.ONE),this.q));return i.toBigInteger().mod(st).equals(new rt(t.substr(0,2),16).subtract(st))||(i=i.negate()),new ht(this,e,i);case 4:case 6:case 7:const n=(t.length-2)/2,o=t.substr(2,n),r=t.substr(n+2,n);return new ht(this,this.fromBigInteger(new rt(o,16)),this.fromBigInteger(new rt(r,16)));default:return null}}}};const{BigInteger:ft,SecureRandom:lt}=X,{ECCurveFp:pt}=ut,dt=new lt,{curve:gt,G:mt,n:yt}=vt();function vt(){const t=new ft("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),e=new ft("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),i=new ft("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),n=new pt(t,e,i),o=n.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:n,G:o,n:new ft("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function _t(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}var bt={getGlobalCurve:function(){return gt},generateEcparam:vt,generateKeyPairHex:function(t,e,i){const n=(t?new ft(t,e,i):new ft(yt.bitLength(),dt)).mod(yt.subtract(ft.ONE)).add(ft.ONE),o=_t(n.toString(16),64),r=mt.multiply(n);return{privateKey:o,publicKey:"04"+_t(r.getX().toBigInteger().toString(16),64)+_t(r.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const e=(t.length-2)/2,i=t.substr(2,e);let n="03";return new ft(t.substr(e+2,e),16).mod(new ft("2")).equals(ft.ZERO)&&(n="02"),n+i},utf8ToHex:function(t){const e=(t=unescape(encodeURIComponent(t))).length,i=[];for(let n=0;n<e;n++)i[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;const n=[];for(let t=0;t<e;t++){const e=i[t>>>2]>>>24-t%4*8&255;n.push((e>>>4).toString(16)),n.push((15&e).toString(16))}return n.join("")},leftPad:_t,arrayToHex:function(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")},arrayToUtf8:function(t){const e=[];let i=0;for(let n=0;n<2*t.length;n+=2)e[n>>>3]|=parseInt(t[i],10)<<24-n%8*4,i++;try{const i=[];for(let n=0;n<t.length;n++){const t=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(t))}return decodeURIComponent(escape(i.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const e=[];let i=t.length;i%2!=0&&(t=_t(t,i+1)),i=t.length;for(let n=0;n<i;n+=2)e.push(parseInt(t.substr(n,2),16));return e},verifyPublicKey:function(t){const e=gt.decodePointHex(t);if(!e)return!1;const i=e.getX();return e.getY().square().equals(i.multiply(i.square()).add(i.multiply(gt.a)).add(gt.b))},comparePublicKeyHex:function(t,e){const i=gt.decodePointHex(t);if(!i)return!1;const n=gt.decodePointHex(e);return!!n&&i.equals(n)}};const Et=new Uint32Array(68),wt=new Uint32Array(64);function St(t,e){const i=31&e;return t<<i|t>>>32-i}function Tt(t,e){const i=[];for(let n=t.length-1;n>=0;n--)i[n]=255&(t[n]^e[n]);return i}function Dt(t){return t^St(t,9)^St(t,17)}function kt(t){let e=8*t.length,i=e%512;i=i>=448?512-i%448-1:448-i-1;const n=new Array((i-7)/8),o=new Array(8);for(let t=0,e=n.length;t<e;t++)n[t]=0;for(let t=0,e=o.length;t<e;t++)o[t]=0;e=e.toString(2);for(let t=7;t>=0;t--)if(e.length>8){const i=e.length-8;o[t]=parseInt(e.substr(i),2),e=e.substr(0,i)}else e.length>0&&(o[t]=parseInt(e,2),e="");const r=new Uint8Array([...t,128,...n,...o]),s=new DataView(r.buffer,0),a=r.length/64,c=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<a;t++){Et.fill(0),wt.fill(0);const e=16*t;for(let t=0;t<16;t++)Et[t]=s.getUint32(4*(e+t),!1);for(let t=16;t<68;t++)Et[t]=(h=Et[t-16]^Et[t-9]^St(Et[t-3],15))^St(h,15)^St(h,23)^St(Et[t-13],7)^Et[t-6];for(let t=0;t<64;t++)wt[t]=Et[t]^Et[t+4];const i=2043430169,n=2055708042;let o,r,a,u,f,l=c[0],p=c[1],d=c[2],g=c[3],m=c[4],y=c[5],v=c[6],_=c[7];for(let t=0;t<64;t++)f=t>=0&&t<=15?i:n,o=St(St(l,12)+m+St(f,t),7),r=o^St(l,12),a=(t>=0&&t<=15?l^p^d:l&p|l&d|p&d)+g+r+wt[t],u=(t>=0&&t<=15?m^y^v:m&y|~m&v)+_+o+Et[t],g=d,d=St(p,9),p=l,l=a,_=v,v=St(y,19),y=m,m=Dt(u);c[0]^=l,c[1]^=p,c[2]^=d,c[3]^=g,c[4]^=m,c[5]^=y,c[6]^=v,c[7]^=_}var h;const u=[];for(let t=0,e=c.length;t<e;t++){const e=c[t];u.push((4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e)}return u}const At=new Uint8Array(64),It=new Uint8Array(64);for(let t=0;t<64;t++)At[t]=54,It[t]=92;var Bt={sm3:kt,hmac:function(t,e){for(e.length>64&&(e=kt(e));e.length<64;)e.push(0);const i=Tt(e,At),n=Tt(e,It),o=kt([...i,...t]);return kt([...n,...o])}};const{BigInteger:xt}=X,{encodeDer:Mt,decodeDer:Ot}=ot,Ct=Bt.sm3,{G:Gt,curve:Rt,n:Ft}=bt.generateEcparam();function zt(t,e,i="1234567812345678"){i=bt.utf8ToHex(i);const n=bt.leftPad(Gt.curve.a.toBigInteger().toRadix(16),64),o=bt.leftPad(Gt.curve.b.toBigInteger().toRadix(16),64),r=bt.leftPad(Gt.getX().toBigInteger().toRadix(16),64),s=bt.leftPad(Gt.getY().toBigInteger().toRadix(16),64);let a,c;if(128===e.length)a=e.substr(0,64),c=e.substr(64,64);else{const t=Gt.curve.decodePointHex(e);a=bt.leftPad(t.getX().toBigInteger().toRadix(16),64),c=bt.leftPad(t.getY().toBigInteger().toRadix(16),64)}const h=bt.hexToArray(i+n+o+r+s+a+c),u=4*i.length;h.unshift(255&u),h.unshift(u>>8&255);const f=Ct(h);return bt.arrayToHex(Ct(f.concat(bt.hexToArray(t))))}function Pt(){const t=bt.generateKeyPairHex(),e=Rt.decodePointHex(t.publicKey);return t.k=new xt(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}var qt={generateKeyPairHex:bt.generateKeyPairHex,compressPublicKeyHex:bt.compressPublicKeyHex,comparePublicKeyHex:bt.comparePublicKeyHex,doEncrypt:function(t,e,i=1){t="string"==typeof t?bt.hexToArray(bt.utf8ToHex(t)):Array.prototype.slice.call(t),e=bt.getGlobalCurve().decodePointHex(e);const n=bt.generateKeyPairHex(),o=new xt(n.privateKey,16);let r=n.publicKey;r.length>128&&(r=r.substr(r.length-128));const s=e.multiply(o),a=bt.hexToArray(bt.leftPad(s.getX().toBigInteger().toRadix(16),64)),c=bt.hexToArray(bt.leftPad(s.getY().toBigInteger().toRadix(16),64)),h=bt.arrayToHex(Ct([].concat(a,t,c)));let u=1,f=0,l=[];const p=[].concat(a,c),d=()=>{l=Ct([...p,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,f=0};d();for(let e=0,i=t.length;e<i;e++)f===l.length&&d(),t[e]^=255&l[f++];const g=bt.arrayToHex(t);return 0===i?r+g+h:r+h+g},doDecrypt:function(t,e,i=1,{output:n="string"}={}){e=new xt(e,16);let o=t.substr(128,64),r=t.substr(192);0===i&&(o=t.substr(t.length-64),r=t.substr(128,t.length-128-64));const s=bt.hexToArray(r),a=bt.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=bt.hexToArray(bt.leftPad(a.getX().toBigInteger().toRadix(16),64)),h=bt.hexToArray(bt.leftPad(a.getY().toBigInteger().toRadix(16),64));let u=1,f=0,l=[];const p=[].concat(c,h),d=()=>{l=Ct([...p,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,f=0};d();for(let t=0,e=s.length;t<e;t++)f===l.length&&d(),s[t]^=255&l[f++];return bt.arrayToHex(Ct([].concat(c,s,h)))===o.toLowerCase()?"array"===n?s:bt.arrayToUtf8(s):"array"===n?[]:""},doSignature:function(t,e,{pointPool:i,der:n,hash:o,publicKey:r,userId:s}={}){let a="string"==typeof t?bt.utf8ToHex(t):bt.arrayToHex(t);o&&(r=r||function(t){const e=Gt.multiply(new xt(t,16)),i=bt.leftPad(e.getX().toBigInteger().toString(16),64),n=bt.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+i+n}(e),a=zt(a,r,s));const c=new xt(e,16),h=new xt(a,16);let u=null,f=null,l=null;do{do{let t;t=i&&i.length?i.pop():Pt(),u=t.k,f=h.add(t.x1).mod(Ft)}while(f.equals(xt.ZERO)||f.add(u).equals(Ft));l=c.add(xt.ONE).modInverse(Ft).multiply(u.subtract(f.multiply(c))).mod(Ft)}while(l.equals(xt.ZERO));return n?Mt(f,l):bt.leftPad(f.toString(16),64)+bt.leftPad(l.toString(16),64)},doVerifySignature:function(t,e,i,{der:n,hash:o,userId:r}={}){let s,a,c="string"==typeof t?bt.utf8ToHex(t):bt.arrayToHex(t);if(o&&(c=zt(c,i,r)),n){const t=Ot(e);s=t.r,a=t.s}else s=new xt(e.substring(0,64),16),a=new xt(e.substring(64),16);const h=Rt.decodePointHex(i),u=new xt(c,16),f=s.add(a).mod(Ft);if(f.equals(xt.ZERO))return!1;const l=Gt.multiply(a).add(h.multiply(f)),p=u.add(l.getX().toBigInteger()).mod(Ft);return s.equals(p)},getPoint:Pt,verifyPublicKey:bt.verifyPublicKey};const{sm3:Ut,hmac:Nt}=Bt;function Vt(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")}function Kt(t){const e=[];let i=t.length;var n,o;i%2!=0&&(o=i+1,t=(n=t).length>=o?n:new Array(o-n.length+1).join("0")+n),i=t.length;for(let n=0;n<i;n+=2)e.push(parseInt(t.substr(n,2),16));return e}const Lt=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],jt=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function Ht(t){const e=[];for(let i=0,n=t.length;i<n;i+=2)e.push(parseInt(t.substr(i,2),16));return e}function Jt(t,e){return t<<e|t>>>32-e}function Wt(t){return(255&Lt[t>>>24&255])<<24|(255&Lt[t>>>16&255])<<16|(255&Lt[t>>>8&255])<<8|255&Lt[255&t]}function Zt(t){return t^Jt(t,2)^Jt(t,10)^Jt(t,18)^Jt(t,24)}function Xt(t){return t^Jt(t,13)^Jt(t,23)}function $t(t,e,i){const n=new Array(4),o=new Array(4);for(let e=0;e<4;e++)o[0]=255&t[4*e],o[1]=255&t[4*e+1],o[2]=255&t[4*e+2],o[3]=255&t[4*e+3],n[e]=o[0]<<24|o[1]<<16|o[2]<<8|o[3];for(let t,e=0;e<32;e+=4)t=n[1]^n[2]^n[3]^i[e+0],n[0]^=Zt(Wt(t)),t=n[2]^n[3]^n[0]^i[e+1],n[1]^=Zt(Wt(t)),t=n[3]^n[0]^n[1]^i[e+2],n[2]^=Zt(Wt(t)),t=n[0]^n[1]^n[2]^i[e+3],n[3]^=Zt(Wt(t));for(let t=0;t<16;t+=4)e[t]=n[3-t/4]>>>24&255,e[t+1]=n[3-t/4]>>>16&255,e[t+2]=n[3-t/4]>>>8&255,e[t+3]=255&n[3-t/4]}function Qt(t,e,i,{padding:n="pkcs#7",mode:o,iv:r=[],output:s="string"}={}){if("cbc"===o&&("string"==typeof r&&(r=Ht(r)),16!==r.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=Ht(e)),16!==e.length)throw new Error("key is invalid");if(t="string"==typeof t?0!==i?function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t.codePointAt(i);if(n<=127)e.push(n);else if(n<=2047)e.push(192|n>>>6),e.push(128|63&n);else if(n<=55295||n>=57344&&n<=65535)e.push(224|n>>>12),e.push(128|n>>>6&63),e.push(128|63&n);else{if(!(n>=65536&&n<=1114111))throw e.push(n),new Error("input is not supported");i++,e.push(240|n>>>18&28),e.push(128|n>>>12&63),e.push(128|n>>>6&63),e.push(128|63&n)}}return e}(t):Ht(t):[...t],("pkcs#5"===n||"pkcs#7"===n)&&0!==i){const e=16-t.length%16;for(let i=0;i<e;i++)t.push(e)}const a=new Array(32);!function(t,e,i){const n=new Array(4),o=new Array(4);for(let e=0;e<4;e++)o[0]=255&t[0+4*e],o[1]=255&t[1+4*e],o[2]=255&t[2+4*e],o[3]=255&t[3+4*e],n[e]=o[0]<<24|o[1]<<16|o[2]<<8|o[3];n[0]^=2746333894,n[1]^=1453994832,n[2]^=1736282519,n[3]^=2993693404;for(let t,i=0;i<32;i+=4)t=n[1]^n[2]^n[3]^jt[i+0],e[i+0]=n[0]^=Xt(Wt(t)),t=n[2]^n[3]^n[0]^jt[i+1],e[i+1]=n[1]^=Xt(Wt(t)),t=n[3]^n[0]^n[1]^jt[i+2],e[i+2]=n[2]^=Xt(Wt(t)),t=n[0]^n[1]^n[2]^jt[i+3],e[i+3]=n[3]^=Xt(Wt(t));if(0===i)for(let t,i=0;i<16;i++)t=e[i],e[i]=e[31-i],e[31-i]=t}(e,a,i);const c=[];let h=r,u=t.length,f=0;for(;u>=16;){const e=t.slice(f,f+16),n=new Array(16);if("cbc"===o)for(let t=0;t<16;t++)0!==i&&(e[t]^=h[t]);$t(e,n,a);for(let t=0;t<16;t++)"cbc"===o&&0===i&&(n[t]^=h[t]),c[f+t]=n[t];"cbc"===o&&(h=0!==i?n:e),u-=16,f+=16}if(("pkcs#5"===n||"pkcs#7"===n)&&0===i){const t=c.length,e=c[t-1];for(let i=1;i<=e;i++)if(c[t-i]!==e)throw new Error("padding is invalid");c.splice(t-e,e)}return"array"!==s?0!==i?c.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join(""):function(t){const e=[];for(let i=0,n=t.length;i<n;i++)t[i]>=240&&t[i]<=247?(e.push(String.fromCodePoint(((7&t[i])<<18)+((63&t[i+1])<<12)+((63&t[i+2])<<6)+(63&t[i+3]))),i+=3):t[i]>=224&&t[i]<=239?(e.push(String.fromCodePoint(((15&t[i])<<12)+((63&t[i+1])<<6)+(63&t[i+2]))),i+=2):t[i]>=192&&t[i]<=223?(e.push(String.fromCodePoint(((31&t[i])<<6)+(63&t[i+1]))),i++):e.push(String.fromCodePoint(t[i]));return e.join("")}(c):c}var Yt={sm2:qt,sm3:function(t,e){if(t="string"==typeof t?function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t.codePointAt(i);if(n<=127)e.push(n);else if(n<=2047)e.push(192|n>>>6),e.push(128|63&n);else if(n<=55295||n>=57344&&n<=65535)e.push(224|n>>>12),e.push(128|n>>>6&63),e.push(128|63&n);else{if(!(n>=65536&&n<=1114111))throw e.push(n),new Error("input is not supported");i++,e.push(240|n>>>18&28),e.push(128|n>>>12&63),e.push(128|n>>>6&63),e.push(128|63&n)}}return e}(t):Array.prototype.slice.call(t),e){if("hmac"!==(e.mode||"hmac"))throw new Error("invalid mode");let i=e.key;if(!i)throw new Error("invalid key");return i="string"==typeof i?Kt(i):Array.prototype.slice.call(i),Vt(Nt(t,i))}return Vt(Ut(t))},sm4:{encrypt:(t,e,i)=>Qt(t,e,1,i),decrypt:(t,e,i)=>Qt(t,e,0,i)}}.sm2;var te=function(){function e(t){this.disableAutoPageView=!1,this.bridgeReport=!1,this.staging=!1,this.pluginInstances=[],this.sended=!1,this.started=!1,this.destroyInstance=!1,this.adapters={},this.sdkReady=!1,this.name=t,this.hook=new o,this.logger=new O(t),this.remotePlugin=new Map,this.Types=k,this.adapters.fetch=F,this.adapters.storage=E}return e.usePlugin=function(t,i,n){if(i){for(var o=!1,r=0,s=e.plugins.length;r<s;r++){if(e.plugins[r].name===i){e.plugins[r].plugin=t,e.plugins[r].options=n||{},o=!0;break}}o||e.plugins.push({name:i,plugin:t,options:n})}else e.plugins.push({plugin:t})},e.prototype.init=function(t){var i,n=this;this.inited?console.log("init can be call only one time"):t&&r(t)?t.app_id&&("number"==typeof(i=t.app_id)&&!isNaN(i))?!t.app_key||function(t){return"string"==typeof t}(t.app_key)?(t.channel_domain||-1!==["cn","sg","va"].indexOf(t.channel)||(console.warn("channel must be `cn`, `sg`,`va` !!!"),t.channel="cn"),this.logger=new O(this.name,t.log),this.configManager=new M(this,t),this.appBridge=new C(t,this.configManager),this.bridgeReport=this.appBridge.bridgeInject(),this.debugger=new Z(this,t),this.initConfig=t,this.env=t.channel_domain?"self":"public",this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 执行INIT",data:t,level:"info",time:Date.now()}),t.disable_auto_pv&&(this.disableAutoPageView=!0),this.bridgeReport||(t.enable_encryption&&"sm"===t.encryption_type&&this.initCrypto(),this.configManager.set({app_id:t.app_id}),this.eventManager=new K,this.tokenManager=new W,this.sessionManager=new J,Promise.all([new Promise((function(t){n.once(k.TokenComplete,(function(){t(!0)}))})),new Promise((function(t){n.once(k.Start,(function(){t(!0)}))}))]).then((function(){try{e.plugins.reduce((function(t,e){var i=e.plugin,o=e.options,r=Object.assign(n.initConfig,o),s=new i;return s.apply(n,r),t.push(s),t}),n.pluginInstances)}catch(t){console.log("load plugin error, "+t.message),n.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}n.sdkReady=!0,n.emit(k.Ready),n.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:n.configManager.get("user")}),n.logger.info("appid: "+t.app_id+", userInfo:"+JSON.stringify(n.configManager.get("user"))),n.logger.info("appid: "+t.app_id+", sdk is ready, version is 0.0.4, you can report now !!!");try{(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(t){n.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}n.pageView(),n.on(k.TokenChange,(function(e){"webid"!==e.type&&"anonymous_id"!==e.type||n.pageView(),n.logger.info("appid: "+t.app_id+" token change, new userInfo:"+JSON.stringify(n.configManager.get("user"))),n.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:n.configManager.get("user")})})),n.on(k.TokenReset,(function(){n.logger.info("appid: "+t.app_id+" token reset, new userInfo:"+JSON.stringify(n.configManager.get("user"))),n.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:n.configManager.get("user")})})),n.on(k.RouteChange,(function(e){e.init||t.disable_route_report||n.pageView()}))})),this.tokenManager.apply(this,t),this.eventManager.apply(this,t),this.sessionManager.apply(this,t),this.inited=!0,this.emit(k.Init))):console.warn("app_key param is error, must be string, please check!"):console.warn("app_id param is error, must be number, please check!"):console.warn("init params error,please check")},e.prototype.config=function(e){if(this.inited)if(e&&r(e))if(this.bridgeReport)this.appBridge.setConfig(e);else{e._staging_flag&&1===e._staging_flag&&(this.staging=!0),e.disable_auto_pv&&(this.disableAutoPageView=!0,delete e.disable_auto_pv);var i=t({},e);if(this.initConfig&&this.initConfig.configPersist){var n=this.configManager.getStore();n&&(i=Object.assign(n,e)),this.configManager.setStore(e)}i.web_id,i.user_unique_id;var o=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(i[n[o]]=t[n[o]])}return i}(i,["web_id","user_unique_id"]);i.hasOwnProperty("web_id")&&this.emit(k.ConfigWebId,i.web_id),i.hasOwnProperty("user_unique_id")&&this.emit(k.ConfigUuid,i.user_unique_id),this.configManager.set(o),this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 执行CONFIG",level:"info",time:Date.now(),data:i})}else this.logger.warn("config params is error, please check");else this.logger.warn("config must be use after function init")},e.prototype.setDomain=function(t){this.configManager&&this.configManager.setDomain(t),this.emit(k.ConfigDomain)},e.prototype.getConfig=function(t){return this.configManager.get(t)},e.prototype.send=function(){this.start()},e.prototype.start=function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(k.Start),this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 执行START",level:"info",time:Date.now()}),this.bridgeReport&&(this.pageView(),this.emit(k.Ready)))},e.prototype.event=function(t,e){var i=this;try{if(this.initConfig&&this.initConfig.disable_track_event)return;var n=[];if(Array.isArray(t))t.forEach((function(t){var e=i.processEvent(t[0],t[1]||{});e&&n.push(e)}));else{var o=this.processEvent(t,e);if(!o)return;n.push(o)}this.bridgeReport?n.forEach((function(t){var e=t.event,n=t.params;i.appBridge.onEventV3(e,JSON.stringify(n))})):n.length&&(this.emit(k.Event,n),this.emit(k.SessionResetTime))}catch(t){this.logger.warn("something error, please check"),this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.beconEvent=function(t,e){if(!this.initConfig||!this.initConfig.disable_track_event)if(Array.isArray(t))console.warn("beconEvent not support batch report, please check");else{var i=[],n=this.processEvent(t,e||{});n&&(i.push(n),i.length&&(this.emit(k.BeconEvent,i),this.emit(k.SessionResetTime)))}},e.prototype.processEvent=function(t,e){void 0===e&&(e={});try{if(!t)return this.logger.warn("eventName is null, please check"),null;var i=t;/^event\./.test(t)&&(i=t.slice(6));var n=e;"object"!=typeof n&&(n={}),n.profile?delete n.profile:n.event_index=s();var o=void 0;return n.local_ms?(o=n.local_ms,delete n.local_ms):o=+new Date,{event:i,params:n,local_time_ms:o,is_bav:this.initConfig&&this.initConfig.autotrack?1:0}}catch(i){return this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:i.message}),{event:t,params:e}}},e.prototype.dynamicParams=function(t){this.dynamicParamsFilter=t},e.prototype.filterEvent=function(t){this.eventFilter=t},e.prototype.on=function(t,e){this.hook.on(t,e)},e.prototype.once=function(t,e){this.hook.once(t,e)},e.prototype.off=function(t,e){this.hook.off(t,e)},e.prototype.emit=function(t,e,i){this.hook.emit(t,e,i)},e.prototype.set=function(t){this.hook.set(t)},e.prototype.pageView=function(){this.disableAutoPageView||this.predefinePageView()},e.prototype.predefinePageView=function(e){if(void 0===e&&(e={}),this.inited){var i={title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer,$is_first_time:""+(this.configManager&&this.configManager.is_first_time||!1)},n=t({},i,e);this.event("predefine_pageview",n)}else console.warn("predefinePageView should call after init")},e.prototype.clearEventCache=function(){this.emit(k.CleanEvents)},e.prototype.setWebIDviaUnionID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_unionid:t}),this.emit(k.CustomWebId)}},e.prototype.setWebIDviaOpenID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_openid:t}),this.emit(k.CustomWebId)}},e.prototype.setAnonymousId=function(t){this.emit(k.AnonymousId,t)},e.prototype.setNativeAppId=function(t){this.bridgeReport&&this.appBridge.setNativeAppId(t)},e.prototype.resetStayDuration=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(k.ResetStay,{url_path:t,title:e,url:i},k.Stay)},e.prototype.resetStayParams=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(k.SetStay,{url_path:t,title:e,url:i},k.Stay)},e.prototype.getToken=function(e,i){var n=this;if(this.inited){var o=!1,r=function(i){if(!o){o=!0;var r=n.configManager.get().user;return i&&(r.tobid=i,r["diss".split("").reverse().join("")]=i),e(t({},r))}},s=function(){n.tokenManager.getTobId().then((function(t){r(t)}))};this.sdkReady?s():(i&&setTimeout((function(){r()}),i),this.on(k.Ready,(function(){s()})))}else this.logger.warn("getToken must be use after function init")},e.prototype.startTrackEvent=function(t){t&&this.emit(k.TrackDurationStart,t,k.TrackDuration)},e.prototype.endTrackEvent=function(t,e){void 0===e&&(e={}),t&&this.emit(k.TrackDurationEnd,{eventName:t,params:e},k.TrackDuration)},e.prototype.pauseTrackEvent=function(t){t&&this.emit(k.TrackDurationPause,t,k.TrackDuration)},e.prototype.resumeTrackEvent=function(t){t&&this.emit(k.TrackDurationResume,t,k.TrackDuration)},e.prototype.profileSet=function(t){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(t)):this.emit(k.ProfileSet,t,k.Profile),this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSet",level:"info",time:Date.now(),data:t})},e.prototype.profileSetOnce=function(t){this.bridgeReport?this.appBridge.profileSetOnce(JSON.stringify(t)):this.emit(k.ProfileSetOnce,t,k.Profile),this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSetOnce",level:"info",time:Date.now(),data:t})},e.prototype.profileIncrement=function(t){this.bridgeReport?this.appBridge.profileIncrement(JSON.stringify(t)):this.emit(k.ProfileIncrement,t,k.Profile),this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileIncrement",level:"info",time:Date.now(),data:t})},e.prototype.profileUnset=function(t){this.bridgeReport?this.appBridge.profileUnset(t):this.emit(k.ProfileUnset,t,k.Profile),this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileUnset",level:"info",time:Date.now(),data:t})},e.prototype.profileAppend=function(t){this.bridgeReport?this.appBridge.profileAppend(JSON.stringify(t)):this.emit(k.ProfileAppend,t,k.Profile),this.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileAppend",level:"info",time:Date.now(),data:t})},e.prototype.setExternalAbVersion=function(t){this.bridgeReport?this.appBridge.setExternalAbVersion(t):this.emit(k.AbExternalVersion,"string"==typeof t&&t?(""+t).trim():null,k.Ab)},e.prototype.getVar=function(t,e,i){this.bridgeReport?this.appBridge.getVar(t,e,i):this.emit(k.AbVar,{name:t,defaultValue:e,callback:i},k.Ab)},e.prototype.getAllVars=function(t){this.bridgeReport?this.appBridge.getAllVars(t):this.emit(k.AbAllVars,t,k.Ab)},e.prototype.getABconfig=function(t,e){this.emit(k.AbConfig,{params:t,callback:e},k.Ab)},e.prototype.getAbSdkVersion=function(t){if(!this.bridgeReport||!t)return this.configManager.getAbVersion()||"";this.appBridge.getAbSdkVersion(t)},e.prototype.onAbSdkVersionChange=function(t){var e=this;return this.emit(k.AbVersionChangeOn,t,k.Ab),function(){e.emit(k.AbVersionChangeOff,t,k.Ab)}},e.prototype.offAbSdkVersionChange=function(t){this.emit(k.AbVersionChangeOff,t,k.Ab)},e.prototype.openOverlayer=function(){this.emit(k.AbOpenLayer,"",k.Ab)},e.prototype.closeOverlayer=function(){this.emit(k.AbCloseLayer,"",k.Ab)},e.prototype.initCrypto=function(){this.publicKey=this.initConfig.crypto_publicKey||"04BA9E229380DC0E41E10839B0C52A4763D3EDFE8903F3B8E81395523381E03AA995D295BD4A4088792E4785B224F7837EB4D2C7C05973C7AE8687A35ACAE470A0"},e.prototype.cryptoData=function(t){try{if(!this.initConfig.enable_encryption)return t;var e=void 0;if("sm"===this.initConfig.encryption_type){var i=(r=JSON.stringify(t),s=this.publicKey,void 0===(a=1)&&(a=1),"04"+Yt.doEncrypt(r,s,a)),n=l(i);e=new Uint8Array(n)}else e="data="+(o=JSON.stringify(t),window.btoa?window.btoa(encodeURIComponent(o)):encodeURIComponent(o));return e}catch(e){return t}var o,r,s,a},e.prototype.destoryInstace=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(k.TokenComplete))},e.plugins=[],e}(),ee=function(){function e(){}return e.prototype.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.duration=6e4,this.reportUrl=t.configManager.getDomain()+"/profile/list";var n=t.Types,o=t.adapters.fetch;this.eventCheck=new D(t,e),this.fetch=o,this.cache={},this.collect.on(n.ProfileSet,(function(t){i.setProfile(t)})),this.collect.on(n.ProfileSetOnce,(function(t){i.setOnceProfile(t)})),this.collect.on(n.ProfileUnset,(function(t){i.unsetProfile(t)})),this.collect.on(n.ProfileIncrement,(function(t){i.incrementProfile(t)})),this.collect.on(n.ProfileAppend,(function(t){i.appendProfile(t)})),this.collect.on(n.ProfileClear,(function(){i.cache={}})),this.ready(n.Profile)},e.prototype.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach((function(i){e.collect.hook.emit(t,i)}))};for(var o in i)n(o)}},e.prototype.report=function(t,e){void 0===e&&(e={});try{if(this.config.disable_track_event)return;var i=[];i.push(this.collect.processEvent(t,e));var n=this.collect.eventManager.merge(i,!0),o=this.collect.cryptoData(n),r=this.collect.configManager.getUrl("profile");this.fetch(r,o,1e5,!1,(function(){}),(function(){}),"","POST",this.config.enable_encryption,this.config.encryption_header),this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:n,code:200,status:"success"})}catch(t){this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.setProfile=function(e){var i=this.formatParams(e);i&&Object.keys(i).length&&(this.pushCache(i),this.report("__profile_set",t({},i,{profile:!0})))},e.prototype.setOnceProfile=function(e){var i=this.formatParams(e,!0);i&&Object.keys(i).length&&(this.pushCache(i),this.report("__profile_set_once",t({},i,{profile:!0})))},e.prototype.incrementProfile=function(e){e?this.report("__profile_increment",t({},e,{profile:!0})):console.warn("please check the params, must be object!!!")},e.prototype.unsetProfile=function(e){if(e){var i={};i[e]="1",this.report("__profile_unset",t({},i,{profile:!0}))}else console.warn("please check the key, must be string!!!")},e.prototype.appendProfile=function(e){if(e){var i={};for(var n in e)"string"==typeof e[n]||"Array"===Object.prototype.toString.call(e[n]).slice(8,-1)?i[n]=e[n]:console.warn("please check the value of param: "+n+", must be string or array !!!");Object.keys(i).length&&this.report("__profile_append",t({},i,{profile:!0}))}else console.warn("please check the params, must be object!!!")},e.prototype.pushCache=function(t){var e=this;Object.keys(t).forEach((function(i){e.cache[i]={val:e.clone(t[i]),timestamp:Date.now()}}))},e.prototype.formatParams=function(t,e){var i=this;void 0===e&&(e=!1);try{if(!t||"[object Object]"!==Object.prototype.toString.call(t))return void console.warn("please check the params type, must be object !!!");var n={};for(var o in t)"string"==typeof t[o]||"number"==typeof t[o]||"Array"===Object.prototype.toString.call(t[o]).slice(8,-1)?n[o]=t[o]:console.warn("please check the value of params:"+o+", must be string,number,Array !!!");var r=Object.keys(n);if(!r.length)return;var s=Date.now();return r.filter((function(n){var o=i.cache[n];return e?!o:!(o&&i.compare(o.val,t[n])&&s-o.timestamp<i.duration)})).reduce((function(t,e){return t[e]=n[e],t}),{})}catch(t){this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),console.log("error")}},e.prototype.compare=function(t,e){try{return JSON.stringify(t)===JSON.stringify(e)}catch(t){return this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),!1}},e.prototype.clone=function(t){try{return JSON.parse(JSON.stringify(t))}catch(e){return this.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}},e.prototype.unReady=function(){console.warn("sdk is not ready, please use this api after start")},e}(),ie=function(){function t(){var t=this;this.setInterval=function(){t.clearIntervalFunc=function(t,e){void 0===t&&(t=function(){}),void 0===e&&(e=1e3);var i,n=Date.now()+e;return i=window.setTimeout((function o(){var r=Date.now()-n;t(),n+=e,i=window.setTimeout(o,Math.max(0,e-r))}),e),function(){window.clearTimeout(i)}}((function(){t.isSessionhasEvent&&t.endCurrentSession()}),t.sessionInterval)},this.clearInterval=function(){t.clearIntervalFunc&&t.clearIntervalFunc()}}return t.prototype.apply=function(t,e){var i=this;if(this.collect=t,!e.disable_heartbeat){this.sessionInterval=6e4,this.startTime=0,this.lastTime=0,this.setInterval();var n=this.collect.Types;this.collect.on(n.SessionReset,(function(){i.process()}))}},t.prototype.endCurrentSession=function(){this.collect.event("_be_active",{start_time:this.startTime,end_time:this.lastTime,url:window.location.href,referrer:window.document.referrer,title:document.title||location.pathname}),this.isSessionhasEvent=!1,this.startTime=0},t.prototype.process=function(){this.isSessionhasEvent||(this.isSessionhasEvent=!0,this.startTime=+new Date);var t=this.lastTime||+new Date;this.lastTime=+new Date,this.lastTime-t>this.sessionInterval&&(this.clearInterval(),this.endCurrentSession(),this.setInterval())},t}(),ne=function(){function t(){}return t.prototype.apply=function(t,e){var i=this;if(this.collect=t,this.config=e,!this.config.channel_domain&&!this.config.disable_track_event&&!this.config.disable_sdk_monitor){var n=t.adapters.fetch;this.fetch=n,this.url=t.configManager.getUrl("event");var o=this.collect.Types;this.collect.on(o.Ready,(function(){i.sdkOnload()})),this.collect.on(o.SubmitError,(function(t){var e=t.type,n=t.eventData,o=t.errorCode;"f_data"===e&&i.sdkError(n,o)}))}},t.prototype.sdkOnload=function(){var t=this;try{var e=this.collect.configManager.get(),i=e.header,n=e.user,o=i.app_id,r=i.app_name,s=i.sdk_version,a=n.web_id,c={events:[{event:"onload",params:JSON.stringify({app_id:o,app_name:r||"",sdk_version:s,sdk_type:"npm",sdk_config:this.config,sdk_desc:"TOB"}),local_time_ms:Date.now()}],user:{user_unique_id:a},header:{}};setTimeout((function(){t.fetch(t.url,[c],3e4,!1,(function(){}),(function(){}),"566f58151b0ed37e")}),16)}catch(t){}},t.prototype.sdkError=function(t,e){var i=this;try{var n=t[0],o=n.user,r=n.header,s=[];t.forEach((function(t){t.events.forEach((function(t){s.push(t)}))}));var a={events:s.map((function(t){return{event:"on_error",params:JSON.stringify({error_code:e,app_id:r.app_id,app_name:r.app_name||"",error_event:t.event,sdk_version:r.sdk_version,local_time_ms:t.local_time_ms,tea_event_index:Date.now(),params:t.params,header:JSON.stringify(r),user:JSON.stringify(o)}),local_time_ms:Date.now()}})),user:{user_unique_id:o.user_unique_id},header:{}};setTimeout((function(){i.fetch(i.url,[a],3e4,!1,(function(){}),(function(){}),"566f58151b0ed37e")}),16)}catch(t){}},t}(),oe=function(){function t(){this.verifyReady=!1,this.cleanStatus=!1}return t.prototype.apply=function(t,e){var i=this;this.collector=t,this.config=e,this.eventStorage=[],this.collector.on("submit-verify-h5",(function(t){t&&t.length&&i.eventStore(t[0])})),this.checkUrl(),this.heartbeat()},t.prototype.checkUrl=function(){var t=window.location.href,e=u(t);e._r_d_&&e._r_c_k_?(this.verifyReady=!0,this.domain=e._r_d_,this.key=e._r_c_k_,this.checkCache()):this.collector.off("submit-verify-h5")},t.prototype.checkCache=function(){this.eventStorage.length&&this.postVerify(this.eventStorage)},t.prototype.heartbeat=function(){var t=this;this.heart=setInterval((function(){var e={event:"simulator_test__",local_time_ms:Date.now()},i=t.collector.configManager.get(),n=i.header,o={events:[e],user:i.user,header:n};t.eventStore(o)}),6e4)},t.prototype.eventStore=function(t){this.cleanStatus||(this.verifyReady?this.postVerify(t):this.eventStorage.push(t))},t.prototype.cleanVerify=function(){this.cleanStatus=!0,this.eventStorage=[],clearInterval(this.heart)},t.prototype.postVerify=function(t){var e,i=this;try{var n=JSON.parse(JSON.stringify(t));e=t,Array.isArray(e)?n.forEach((function(t){i.fetchLog(t)})):this.fetchLog(n)}catch(t){console.log("web verify post error ~")}},t.prototype.fetchLog=function(t){F(this.domain+"/simulator/h5/log?connection_key="+this.key,t,2e4,!1)},t.prototype.leave=function(){var t=this;document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&t.cleanVerify()})),c((function(){t.cleanVerify()}))},t}();te.usePlugin(oe,"verifyH"),te.usePlugin(ee,"profile"),te.usePlugin(ie,"heartbeat"),te.usePlugin(ne,"monitor");var re=new te("default"),se=te;exports.Collector=se,exports.default=re;
|
package/lib/plugin/ab.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},e.apply(this,arguments)},t="__rangers_ab_style__";var n,i,r={cn:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},o="https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/visual-ab-core.js",a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e){var t=function(){try{return!!Symbol.iterator}catch(e){return!1}}(),n=function(e){var n={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t&&(n[Symbol.iterator]=function(){return n}),n},i=function(e){return encodeURIComponent(e).replace(/%20/g,"+")},r=function(e){return decodeURIComponent(String(e).replace(/\+/g," "))};(function(){try{var t=e.URLSearchParams;return"a=1"===new t("?a=1").toString()&&"function"==typeof t.prototype.set&&"function"==typeof t.prototype.entries}catch(t){return!1}})()||function(){var r=function e(t){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var n=typeof t;if("undefined"===n);else if("string"===n)""!==t&&this._fromString(t);else if(t instanceof e){var i=this;t.forEach((function(e,t){i.append(t,e)}))}else{if(null===t||"object"!==n)throw new TypeError("Unsupported input's type for URLSearchParams");if("[object Array]"===Object.prototype.toString.call(t))for(var r=0;r<t.length;r++){var o=t[r];if("[object Array]"!==Object.prototype.toString.call(o)&&2===o.length)throw new TypeError("Expected [string, any] as entry at index "+r+" of URLSearchParams's input");this.append(o[0],o[1])}else for(var a in t)t.hasOwnProperty(a)&&this.append(a,t[a])}},o=r.prototype;o.append=function(e,t){e in this._entries?this._entries[e].push(String(t)):this._entries[e]=[String(t)]},o.delete=function(e){delete this._entries[e]},o.get=function(e){return e in this._entries?this._entries[e][0]:null},o.getAll=function(e){return e in this._entries?this._entries[e].slice(0):[]},o.has=function(e){return e in this._entries},o.set=function(e,t){this._entries[e]=[String(t)]},o.forEach=function(e,t){var n;for(var i in this._entries)if(this._entries.hasOwnProperty(i)){n=this._entries[i];for(var r=0;r<n.length;r++)e.call(t,n[r],i,this)}},o.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),n(e)},o.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),n(e)},o.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),n(e)},t&&(o[Symbol.iterator]=o.entries),o.toString=function(){var e=[];return this.forEach((function(t,n){e.push(i(n)+"="+i(t))})),e.join("&")},e.URLSearchParams=r}();var o=e.URLSearchParams.prototype;"function"!=typeof o.sort&&(o.sort=function(){var e=this,t=[];this.forEach((function(n,i){t.push([i,n]),e._entries||e.delete(i)})),t.sort((function(e,t){return e[0]<t[0]?-1:e[0]>t[0]?1:0})),e._entries&&(e._entries={});for(var n=0;n<t.length;n++)this.append(t[n][0],t[n][1])}),"function"!=typeof o._fromString&&Object.defineProperty(o,"_fromString",{enumerable:!1,configurable:!1,writable:!1,value:function(e){if(this._entries)this._entries={};else{var t=[];this.forEach((function(e,n){t.push(n)}));for(var n=0;n<t.length;n++)this.delete(t[n])}var i,o=(e=e.replace(/^\?/,"")).split("&");for(n=0;n<o.length;n++)i=o[n].split("="),this.append(r(i[0]),i.length>1?r(i[1]):"")}})}(void 0!==a?a:"undefined"!=typeof window?window:"undefined"!=typeof self?self:a),function(e){if(function(){try{var t=new e.URL("b","http://a");return t.pathname="c d","http://a/c%20d"===t.href&&t.searchParams}catch(t){return!1}}()||function(){var t=e.URL,n=function t(n,i){"string"!=typeof n&&(n=String(n)),i&&"string"!=typeof i&&(i=String(i));var r,o=document;if(i&&(void 0===e.location||i!==e.location.href)){i=i.toLowerCase(),(r=(o=document.implementation.createHTMLDocument("")).createElement("base")).href=i,o.head.appendChild(r);try{if(0!==r.href.indexOf(i))throw new Error(r.href)}catch(t){throw new Error("URL unable to set base "+i+" due to "+t)}}var a=o.createElement("a");a.href=n,r&&(o.body.appendChild(a),a.href=a.href);var s=o.createElement("input");if(s.type="url",s.value=n,":"===a.protocol||!/:/.test(a.href)||!s.checkValidity()&&!i)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:a});var c=new e.URLSearchParams(this.search),l=!0,h=!0,u=this;["append","delete","set"].forEach((function(e){var t=c[e];c[e]=function(){t.apply(c,arguments),l&&(h=!1,u.search=c.toString(),h=!0)}})),Object.defineProperty(this,"searchParams",{value:c,enumerable:!0});var f=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==f&&(f=this.search,h&&(l=!1,this.searchParams._fromString(this.search),l=!0))}})},i=n.prototype;["hash","host","hostname","port","protocol"].forEach((function(e){!function(e){Object.defineProperty(i,e,{get:function(){return this._anchorElement[e]},set:function(t){this._anchorElement[e]=t},enumerable:!0})}(e)})),Object.defineProperty(i,"search",{get:function(){return this._anchorElement.search},set:function(e){this._anchorElement.search=e,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(i,{toString:{get:function(){var e=this;return function(){return e.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(e){this._anchorElement.href=e,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(e){this._anchorElement.pathname=e},enumerable:!0},origin:{get:function(){var e={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],t=this._anchorElement.port!=e&&""!==this._anchorElement.port;return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(t?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(e){},enumerable:!0},username:{get:function(){return""},set:function(e){},enumerable:!0}}),n.createObjectURL=function(e){return t.createObjectURL.apply(t,arguments)},n.revokeObjectURL=function(e){return t.revokeObjectURL.apply(t,arguments)},e.URL=n}(),void 0!==e.location&&!("origin"in e.location)){var t=function(){return e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:"")};try{Object.defineProperty(e.location,"origin",{get:t,enumerable:!0})}catch(n){setInterval((function(){e.location.origin=t()}),100)}}}(void 0!==a?a:"undefined"!=typeof window?window:"undefined"!=typeof self?self:a),function(e){e.Init="init",e.Config="config",e.Start="start",e.Ready="ready",e.TokenComplete="token-complete",e.TokenStorage="token-storage",e.TokenFetch="token-fetch",e.TokenError="token-error",e.ConfigUuid="config-uuid",e.ConfigWebId="config-webid",e.ConfigDomain="config-domain",e.CustomWebId="custom-webid",e.AnonymousId="anonymous-id",e.TokenChange="token-change",e.TokenReset="token-reset",e.ConfigTransform="config-transform",e.EnvTransform="env-transform",e.SessionReset="session-reset",e.SessionResetTime="session-reset-time",e.Event="event",e.Events="events",e.EventNow="event-now",e.CleanEvents="clean-events",e.BeconEvent="becon-event",e.SubmitBefore="submit-before",e.SubmitScuess="submit-scuess",e.SubmitAfter="submit-after",e.SubmitError="submit-error",e.SubmitVerifyH="submit-verify-h5",e.Stay="stay",e.ResetStay="reset-stay",e.StayReady="stay-ready",e.SetStay="set-stay",e.RouteChange="route-change",e.RouteReady="route-ready",e.Ab="ab",e.AbVar="ab-var",e.AbAllVars="ab-all-vars",e.AbConfig="ab-config",e.AbExternalVersion="ab-external-version",e.AbVersionChangeOn="ab-version-change-on",e.AbVersionChangeOff="ab-version-change-off",e.AbOpenLayer="ab-open-layer",e.AbCloseLayer="ab-close-layer",e.AbReady="ab-ready",e.AbComplete="ab-complete",e.AbTimeout="ab-timeout",e.Profile="profile",e.ProfileSet="profile-set",e.ProfileSetOnce="profile-set-once",e.ProfileUnset="profile-unset",e.ProfileIncrement="profile-increment",e.ProfileAppend="profile-append",e.ProfileClear="profile-clear",e.TrackDuration="track-duration",e.TrackDurationStart="track-duration-start",e.TrackDurationEnd="track-duration-end",e.TrackDurationPause="track-duration-pause",e.TrackDurationResume="tracl-duration-resume",e.Autotrack="autotrack",e.AutotrackReady="autotrack-ready",e.CepReady="cep-ready",e.TracerReady="tracer-ready"}(n||(n={})),function(e){e.DEBUGGER_MESSAGE="debugger-message",e.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",e.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",e.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",e.DEBUGGER_MESSAGE_EVENT="debugger-message-event",e.DEVTOOL_WEB_READY="devtool-web-ready"}(i||(i={}));Date.now(),Number((""+Math.random()).slice(2,8));var s=function(e){return function(e,t,n){if("string"==typeof e&&"number"==typeof t&&"number"==typeof n){var i,r=[];n=n<=25?n:n%25;var o=String.fromCharCode(n+97);i=e.split(o);for(var a=0;a<i.length;a++){var s=parseInt(i[a],n);s=1*s^t;var c=String.fromCharCode(s);r.push(c)}return r.join("")}}(e,64,25)},c=function(e,t,n){var i=document.createElement("script");i.src=e,i.onerror=function(){n(e)},i.onload=function(){t()},document.getElementsByTagName("head")[0].appendChild(i)},l=function(e){var t=document.createElement("a");return t.href=e,t},h={},u=[];function f(e,t,n,i){var r=e&&e.source||window.opener||window.parent,o=e&&e.origin||i||"*",a={type:t,payload:n};r.postMessage(JSON.stringify(a),o)}function p(e,t){h[e]=h[e]||[],h[e].push(t)}function d(e){if(u.some((function(e){return"*"===e}))||u.some((function(t){return e.origin.indexOf(t)>-1}))){var t=e.data;if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(e){t=void 0}if(!t)return;var n=t.type,i=t.payload;h[n]&&h[n].forEach((function(t){"function"==typeof t&&t(e,i)}))}}var m="",v=!1;function b(e){var t=e.event,n=e.editorUrl;e.collectInstance,e.fromSession,v||(v=!0,c(n,(function(){f(t,"abEditorScriptloadSuccess")}),(function(){t&&f(t,"abEditorScriptloadError"),v=!1})))}function g(t,n){var i;window.TEAVisualEditor=window.TEAVisualEditor||{},(i=["*"]).length&&i.forEach((function(e){u.push(e)}));var r,a="";!function(t,n){var i=e({},t);i.filter&&delete i.filter,"object"==typeof i.autotrack&&i.autotrack.collect_url&&delete i.autotrack.collect_url,(window.opener||window.parent).postMessage({type:"tea:sdk:info",config:i,version:n},"*"),window.addEventListener("message",d,!1)}(n,"0.0.4");var s="";try{var c=window.performance.getEntriesByType("resource");if(c&&c.length&&(c.forEach((function(e){"script"===e.initiatorType&&e.name&&-1!==e.name.indexOf("collect")&&(s=e.name)})),s||document.currentScript&&(s=document.currentScript.src),s&&(r=s.split("/"))&&r.length)){a="https:/";for(var l=2;l<r.length&&l!==r.length-1;l++)a=a+"/"+r[l];a+="/visual-ab-core"}}catch(e){}p("tea:openVisualABEditor",(function(e){var i=e.data;if("string"==typeof e.data)try{i=JSON.parse(e.data)}catch(e){i=void 0}if(i){var r=i.lang;if(i.appId!==n.app_id)return f(e,"appIdError"),void console.error("abtest appid is not belong the page appid please check");var s=i.version;if(s)m=a?""+a+(s?"."+s:".1.0.1")+".js?query="+Date.now():o+"?query="+Date.now();else m=o+"?query="+Date.now();window.TEAVisualEditor.lang=r,window.TEAVisualEditor.__ab_domin=n.channel_domain||"",b({event:e,editorUrl:m,collectInstance:t})}}))}var y;!function(e){e[e.Var=0]="Var",e[e.All=1]="All"}(y||(y={}));var _=function(){function n(){this.fetchStatus="no",this.refreshFetchStatus="complete",this.versions=[],this.extVersions=[],this.mulilinkVersions=[],this.enable_multilink=!1,this.enable_ab_visual=!1,this.editMode=!1,this.callbacks=[],this.data=null,this.changeListener=new Map,this.readyStatus=!1,this.exposureCache=[]}return n.prototype.apply=function(e,t){var n=this;if(this.collect=e,this.config=t,this.config.enable_ab_test){var i=t.enable_multilink,o=t.ab_channel_domain,a=t.enable_ab_visual,c=t.ab_cross,l=t.ab_cookie_domain,h=t.disable_ab_reset,u=o||s(r[t.channel||"cn"]),f=e.adapters,p=f.storage,d=f.fetch;this.cacheStorgae=new p(!1),this.fetch=d,this.enable_multilink=i,this.enable_ab_visual=a,this.abKey="__tea_sdk_ab_version_"+t.app_id,this.ab_cross=c,this.ab_cookie_domain=l||"",this.fetchUrl=u+"/service/2/abtest_config/",this.reportUrl=""+e.configManager.getUrl("event"),this.exposureLimit=t.exposure_limit||20,this.ab_batch_time=t.ab_batch_time||500;var m=this.collect.Types;this.types=m,this.collect.on(m.TokenChange,(function(e){h||"uuid"===e.type&&n.readyStatus&&(n.clearCache(),n.fetchAB())})),this.collect.on(m.TokenReset,(function(){h||n.readyStatus&&(n.clearCache(),n.fetchAB())})),this.collect.on(m.AbVar,(function(e){var t=e.name,i=e.defaultValue,r=e.callback;n.getVar(t,i,r)})),this.collect.on(m.AbAllVars,(function(e){n.getAllVars(e)})),this.collect.on(m.AbConfig,(function(e){var t=e.params,i=e.callback;n.getABconfig(t,i)})),this.collect.on(m.AbExternalVersion,(function(e){n.setExternalAbVersion(e)})),this.collect.on(m.AbOpenLayer,(function(){n.openOverlayer()})),this.collect.on(m.AbCloseLayer,(function(){n.closeOverlayer()})),this.collect.on(m.AbVersionChangeOn,(function(e){n.changeListener.set(e,e)})),this.collect.on(m.AbVersionChangeOff,(function(e){n.changeListener.get(e)&&n.changeListener.delete(e)})),this.loadMode(),(this.enable_ab_visual||this.enable_multilink)&&this.openOverlayer(this.config.multilink_timeout_ms||500),this.checkLocal(),this.ready("ab"),this.readyStatus||(this.fetchAB(),this.readyStatus=!0),this.collect.emit(m.AbReady)}},n.prototype.ready=function(e){var t=this;if(this.collect.set(e),this.collect.hook._hooksCache.hasOwnProperty(e)){var n=this.collect.hook._hooksCache[e];if(!Object.keys(n).length)return;var i=function(e){n[e].length&&n[e].forEach((function(n){t.collect.hook.emit(e,n)}))};for(var r in n)i(r)}},n.prototype.loadMode=function(){var e,t,n=function(){try{return JSON.parse(atob(window.name))||void 0}catch(e){return}}(),i="";if(n){var r=n.scenario,o=n.href;r?(this.editMode=!0,i=r):!o||-1===o.indexOf("datatester")&&-1===o.indexOf("visual-editor")||(this.editMode=!0,i="visual-editor")}this.enable_ab_visual&&(g(this.collect,this.config),"visual-editor"===i)?this.collect.destoryInstace():this.enable_multilink&&(e=this.collect,t=this.config,window.TEAVisualEditor=window.TEAVisualEditor||{},window.TEAVisualEditor.appId=t.app_id,p("tea:openTesterEventInspector",(function(t){var n=t.data;if("string"==typeof t.data)try{n=JSON.parse(t.data)}catch(e){n=void 0}if(n){var i=n.referrer,r=n.lang,o=n.appId;window.TEAVisualEditor.__editor_ajax_domain=i||"",window.TEAVisualEditor.__ab_appId=o||"",window.TEAVisualEditor.lang=r||"",b({event:t,editorUrl:"https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/tester-event-inspector.js?query="+Date.now(),collectInstance:e})}})))},n.prototype.checkLocal=function(){var e=this.getABCache(),t=e.ab_version,n=e.ab_ext_version,i=e.ab_version_multilink,r=e.data,o=this.checkFromUrl();o?this.mulilinkVersions.push(o):this.mulilinkVersions=i||[],this.extVersions=n||[],this.versions=t||[],this.data=r;var a=this.versions.concat(this.extVersions);this.enable_multilink&&(a=a.concat(this.mulilinkVersions)),this.configVersions(a.join(","))},n.prototype.checkFromUrl=function(){var e=function(e){var t={};try{var n=l(e).search;(n=n.slice(1)).split("&").forEach((function(e){var n,i,r=e.split("=");r.length&&(n=r[0],i=r[1]);try{t[n]=decodeURIComponent(void 0===i?"":i)}catch(e){t[n]=i}}))}catch(e){}return t}(window.location.href);return e&&e.vid?e.vid:""},n.prototype.updateVersions=function(){var e=this.extVersions.length?this.versions.concat(this.extVersions):this.versions;this.enable_multilink&&(e=e.concat(this.mulilinkVersions)),this.configVersions(e.join(",")),this.updateABCache(),this.changeListener.size>0&&this.changeListener.forEach((function(t){"function"==typeof t&&t(e)}))},n.prototype.configVersions=function(e){this.collect.configManager.setAbVersion(e)},n.prototype.getVar=function(e,t,n){if(!e)throw new Error("variable must not be empty");if(void 0===t)throw new Error("variable no default value");if("function"!=typeof n)throw new Error("callback must be a function");var i={name:e,defaultValue:t,callback:n,type:y.Var};"complete"===this.fetchStatus&&"complete"===this.refreshFetchStatus?this.getRealVar(i,e):this.callbacks.push(i)},n.prototype.getRealVar=function(e,t){var n=e.name,r=e.defaultValue,o=e.callback,a=this.data;if(a){if(null!=(c=a[n])&&"[object Object]"==Object.prototype.toString.call(c)){var s=a[n].vid;return"$ab_url"===t?this.mulilinkVersions.includes(s)||this.mulilinkVersions.push(s):this.versions.includes(s)||this.versions.push(s),this.updateVersions(),this.fechEvent(s,t,r),o(a[n].val),void this.collect.emit(i.DEBUGGER_MESSAGE,{type:i.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 曝光了实验"+n,level:"info",time:Date.now(),data:a[n]})}var c;this.collect.emit(i.DEBUGGER_MESSAGE,{type:i.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getVar",level:"info",time:Date.now(),data:r}),o(r)}else o(r)},n.prototype.getAllVars=function(e){if("function"!=typeof e)throw new Error("callback must be a function");var t={callback:e,type:y.All};"complete"===this.fetchStatus&&"complete"===this.refreshFetchStatus?this.getRealAllVars(t):this.callbacks.push(t)},n.prototype.getRealAllVars=function(e){(0,e.callback)(this.data?JSON.parse(JSON.stringify(this.data)):{}),this.collect.emit(i.DEBUGGER_MESSAGE,{type:i.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getAllVars",level:"info",time:Date.now(),data:this.data})},n.prototype.fechEvent=function(e,t,n){try{if(this.config.disable_track_event)return;if(!e)return;var r=this.collect.configManager.get(),o=r.header,a=r.user,s=this.getABCache();if(s&&s.uuid&&s.uuid!==a.user_unique_id)return;var c={event:"abtest_exposure",ab_sdk_version:""+e,params:JSON.stringify({app_id:this.config.appId,ab_url:"$ab_url"===t?n:window.location.href}),local_time_ms:Date.now()};o.custom=JSON.stringify(o.custom);var l={events:[c],user:a,header:o};"$ab_url"===t&&window.navigator.sendBeacon?window.navigator.sendBeacon(this.reportUrl,JSON.stringify([l])):this.reportExposure(l)}catch(e){this.collect.emit(i.DEBUGGER_MESSAGE,{type:i.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},n.prototype.reportExposure=function(e){var t=this;this.exposureCache.push(e),this.reportTimeout&&clearTimeout(this.reportTimeout),this.exposureCache.length>=this.exposureLimit?this.report():this.reportTimeout=setTimeout((function(){t.report(),clearTimeout(t.reportTimeout)}),this.ab_batch_time)},n.prototype.report=function(){var e=this,t=this.collect.cryptoData(this.exposureCache);this.fetch(this.reportUrl,t,1e5,!1,(function(){}),(function(){}),"","POST",this.config.enable_encryption,this.config.encryption_header),this.exposureCache.forEach((function(t){e.collect.emit(i.DEBUGGER_MESSAGE,{type:i.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:[t],code:200,status:"success"})})),this.exposureCache=[]},n.prototype.setExternalAbVersion=function(e){this.extVersions=[e],this.updateVersions()},n.prototype.getABconfig=function(e,t){var n=Object.keys(e);n&&n.length&&this.collect.configManager.set(e),this.fetchAB(t)},n.prototype.get=function(e){if(this.ab_cross){var t=this.cacheStorgae.getCookie(e,this.ab_cookie_domain);return t?JSON.parse(t):null}return this.cacheStorgae.getItem(e)},n.prototype.set=function(e,t){this.ab_cross?this.cacheStorgae.setCookie(e,t,2592e6,this.ab_cookie_domain):this.cacheStorgae.setItem(e,t),this.collect.configManager.setAbCache(t)},n.prototype.getABCache=function(e){var t={ab_version:[],ab_ext_version:[],ab_version_multilink:[],data:null,timestamp:+new Date,uuid:""};return t=this.get(this.abKey)||t,Date.now()-t.timestamp>=2592e6?(this.cacheStorgae.removeItem(this.abKey),null):e?t[e]:t},n.prototype.updateABCache=function(){var e=this.getABCache();e.ab_version_multilink=this.mulilinkVersions,e.ab_ext_version=this.extVersions,e.ab_version=this.versions,e.timestamp=Date.now(),this.set(this.abKey,e)},n.prototype.setAbCache=function(e){var t=this.getABCache();t.data=this.data,t.uuid=e,t.timestamp=Date.now(),this.set(this.abKey,t)},n.prototype.clearCache=function(){this.refreshFetchStatus="ing",this.data={},this.extVersions=[],this.mulilinkVersions=[],this.versions=[],this.collect.configManager.clearAbCache()},n.prototype.openOverlayer=function(e){var n=this;if(function(){if(!document.getElementById(t)){var e="body { opacity: 0 !important; }",n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=t,i.type="text/css",i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e)),n.appendChild(i)}}(),e)var i=setTimeout((function(){n.closeOverlayer(),clearTimeout(i)}),e)},n.prototype.closeOverlayer=function(){var e;(e=document.getElementById(t))&&e.parentElement.removeChild(e)},n.prototype.fetchComplete=function(e,t){var n=this;if(e&&"[object Object]"==Object.prototype.toString.call(e)){this.data=e,this.setAbCache(t);var i=[];Object.keys(e).forEach((function(t){var n=e[t].vid;n&&i.push(n)})),this.versions=this.versions.filter((function(e){return i.includes(e)}));var r=e.$ab_url,o=e.$ab_modification;if(o&&o.val&&this.enable_ab_visual){if(this.collect.destroyInstance)return;this.getVar("$ab_modification",window.location.href,(function(){var e;e=o.val,window.TEAVisualEditor=window.TEAVisualEditor||{},window.TEAVisualEditor.__ab_config=e,c("https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/visual-ab-loader.js?query="+Date.now(),(function(){console.log("load visual render success")}),(function(){console.log("load visual render fail")})),n.closeOverlayer()}))}else if(r&&this.enable_multilink){this.mulilinkVersions=this.mulilinkVersions.filter((function(e){return i.includes(e)}));var a=r.val,s=r.vid;a&&s&&this.getVar("$ab_url",a,(function(){n.editMode||(a!==window.location.href?setTimeout((function(){if(!n.collect.destroyInstance){var e=""+a;e=-1===e.indexOf("http")?"https://"+e:e;var t=l(e).host;try{var i=new URL(e);t!==location.host?i.searchParams.append("vid",s):window.history.replaceState("","",e),window.location.href=i.href}catch(t){window.location.href=e}}}),100):n.closeOverlayer())}))}this.updateVersions()}else this.closeOverlayer();this.callbacks.forEach((function(e){return n[e.type===y.Var?"getRealVar":"getRealAllVars"](e,"")})),this.callbacks=[]},n.prototype.fetchAB=function(t){var n=this,r=this.collect.configManager.get(),o=r.header,a=r.user;this.config.enable_anonymousid&&delete a.web_id;var s=a.user_unique_id,c={header:e({aid:this.config.app_id},a||{},o||{},{ab_sdk_version:this.collect.configManager.getAbVersion(),ab_url:window.location.href})};this.collect.emit(i.DEBUGGER_MESSAGE,{type:i.DEBUGGER_MESSAGE_SDK,info:"SDK 发起AB实验请求",level:"info",logType:"fetch",time:Date.now(),data:c});var l=this.collect.cryptoData(c);this.fetch(this.fetchUrl,l,this.config.ab_timeout||3e3,!1,(function(e){n.fetchStatus="complete",n.refreshFetchStatus="complete";var r=e.data;"success"===e.message?(n.fetchComplete(r,s),t&&t(r)):(n.fetchComplete(null,s),t&&t(null)),n.collect.emit(n.types.AbComplete,r),n.collect.emit(i.DEBUGGER_MESSAGE,{type:i.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求成功",level:"info",logType:"fetch",time:Date.now(),data:r})}),(function(){n.fetchStatus="complete",n.refreshFetchStatus="complete",n.fetchComplete(null,s),t&&t(null),n.collect.emit(n.types.AbTimeout),n.collect.emit(i.DEBUGGER_MESSAGE,{type:i.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求网络异常",level:"error",logType:"fetch",time:Date.now()})}),"","",this.config.enable_encryption,this.config.encryption_header)},n.prototype.filterUrl=function(e){try{var t="";-1!==e.indexOf("&multilink=true")?t="&multilink=true[\0-ÿ]*":-1!==e.indexOf("?multilink=true")&&(t="\\?multilink=true[\0-ÿ]*");var n=new RegExp(t,"g");e=e.replace(n,"")}catch(e){}return e},n}();module.exports=_;
|
package/lib/plugin/autotrack.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)},t=function(e){return Array.isArray(e)};Date.now(),Number((""+Math.random()).slice(2,8));function n(e,t){if(void 0===t&&(t="list"),!e)return!1;if(t&&"list"===t){if(["LI","TR","DL"].includes(e.nodeName))return!0;if(e.dataset&&e.dataset.hasOwnProperty("teaIdx"))return!0;if(e.hasAttribute&&e.hasAttribute("data-tea-idx"))return!0}else{if(["A","BUTTON"].includes(e.nodeName))return!0;if(e.dataset&&e.dataset.hasOwnProperty("teaContainer"))return!0;if(e.hasAttribute&&e.hasAttribute("data-tea-container"))return!0;if(e.hasAttribute&&s(e,"ss"))return!0}return!1}var i=function(e,t){return!!s(e,t)};function o(e){for(var t=e;t&&!n(t,"container");){if("HTML"===t.nodeName||"BODY"===t.nodeName)return e;t=t.parentElement}return t||e}function r(e){var t="";return 3===e.nodeType?t=e.textContent.trim():e.dataset&&e.dataset.hasOwnProperty("teaTitle")||e.hasAttribute("ata-tea-title")?t=e.getAttribute("data-tea-title"):e.hasAttribute("title")?t=e.getAttribute("title"):"INPUT"===e.nodeName&&["button","submit"].includes(e.getAttribute("type"))?t=e.getAttribute("value"):"IMG"===e.nodeName&&e.getAttribute("alt")&&(t=e.getAttribute("alt")),t.slice(0,200)}var a=function(e,t){return e.hasAttribute?e.hasAttribute(t):e.attributes?!(!e.attributes[t]||!e.attributes[t].specified):void 0},s=function(e,n){if("string"==typeof n)return a(e,n);if(t(n)){for(var i=!1,o=0;o<n.length;o++){if(a(e,n[o])){i=!0;break}}return i}};var c=function(){function t(t,o,r){var a=this;this.clickEvent=function(e){(function(e,t){if(1!==e.nodeType)return!1;if(!t.svg&&function(e){if("svg"===e.tagName.toLowerCase())return!0;for(var t=e.parentElement,n=!1;t;)"svg"===t.tagName.toLowerCase()?(t=null,n=!0):t=t.parentElement;return n}(e))return!1;if(["HTML","BODY"].includes(e.tagName.toUpperCase()))return!1;var o=e;return!!("none"!==o.style.display&&(n(o,"container")||t.track_attr&&i(o,t.track_attr)||function(e){if(e.children.length){var t=e.children;return![].slice.call(t).some((function(e){return e.children.length>0}))}return!0}(o)))})(e.target,a.options)&&a.eventHandel({eventType:"dom",eventName:"click"},e)},this.changeEvent=function(e){a.eventHandel({eventType:"dom",eventName:"change"},e)},this.submitEvent=function(e){a.eventHandel({eventType:"dom",eventName:"submit"},e)},this.getPageViewEvent=function(t,n){n&&"pushState"===n&&a.eventHandel({eventType:"dom",eventName:"beat"},e({beat_type:0},t)),a.eventHandel({eventType:"dom",eventName:"page_view"},t)},this.getPageLoadEvent=function(e){a.eventHandel({eventType:"dom",eventName:"page_statistics"},{lcp:e})},this.config=r.getConfig().eventConfig,this.collect=o,this.options=t,this.beatTime=t.beat,this.statistics=!1}return t.prototype.init=function(e){this.eventHandel=e;var t=this.config.mode;this.addListener(t)},t.prototype.addListener=function(e){var t=this;if("proxy-capturing"===e&&(this.config.click&&window.document.addEventListener("click",this.clickEvent,!0),this.config.change&&window.document.addEventListener("change",this.changeEvent,!0),this.config.submit&&window.document.addEventListener("submit",this.submitEvent,!0),this.config.pv&&this.collect.on("route-change",(function(e){var n=e.config,i=e.name;t.getPageViewEvent(n,i)})),this.config.beat)){try{"complete"===document.readyState?this.beatEvent(this.beatTime):window.addEventListener("load",(function(){t.beatEvent(t.beatTime)}));var n=0,i=null;window.addEventListener("scroll",(function(){clearTimeout(i),i=setTimeout(o,500),n=document.documentElement.scrollTop||document.body.scrollTop}));var o=function(){(document.documentElement.scrollTop||document.body.scrollTop)==n&&t.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:1})}}catch(e){}try{var r=window.performance&&window.performance.getEntriesByType("paint");if(r&&r.length){var a=new PerformanceObserver((function(e){var n=e.getEntries(),i=n[n.length-1],o=i.renderTime||i.loadTime;t.statistics||(t.getPageLoadEvent(o),t.statistics=!0)}));a.observe({entryTypes:["largest-contentful-paint"]}),setTimeout((function(){t.statistics||(t.getPageLoadEvent(r[0].startTime||0),t.statistics=!0)}),2e3)}else this.getPageLoadEvent(0)}catch(e){this.getPageLoadEvent(0)}}},t.prototype.removeListener=function(){window.document.removeEventListener("click",this.clickEvent,!0),window.document.removeEventListener("change",this.changeEvent,!0),window.document.removeEventListener("submit",this.submitEvent,!0)},t.prototype.beatEvent=function(e){var t,n=this;try{var i;this.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:3}),this.beatTime&&(i=setInterval((function(){n.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:2})}),e)),t=function(){n.eventHandel({eventType:"dom",eventName:"beat",eventSend:"becon"},{beat_type:0}),n.beatTime&&clearInterval(i)},navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",t,!1):window.addEventListener("beforeunload",t,!1)}catch(e){}},t}(),u={eventConfig:{mode:"proxy-capturing",submit:!1,click:!0,change:!1,pv:!0,beat:!0,hashTag:!1,impr:!1},scoutConfig:{mode:"xpath"}},d=function(){function e(e,t){this.config=e,this.config.eventConfig=Object.assign(this.config.eventConfig,t)}return e.prototype.getConfig=function(){return this.config},e.prototype.setConfig=function(e){return this.config=e},e}();function l(e){for(var t=[];null!==e.parentElement;)t.push(e),e=e.parentElement;var i=[],o=[];return t.forEach((function(e){var t=function(e){if(null===e)return{str:"",index:0};var t=0,i=e.parentElement;if(i)for(var o=i.children,r=0;r<o.length&&o[r]!==e;r++)o[r].nodeName===e.nodeName&&t++;return{str:[e.nodeName.toLowerCase(),n(e,"list")?"[]":""].join(""),index:t}}(e),r=t.str,a=t.index;i.unshift(r),o.unshift(a)})),{element_path:"/"+i.join("/"),positions:o}}function p(e,n,s,c){var u={},d=function(e){if(e){var t=e.getBoundingClientRect(),n=t.width,i=t.height;return{left:t.left,top:t.top,element_width:n,element_height:i}}}(n),p=function(e,t){void 0===e&&(e={}),void 0===t&&(t={});var n=e.clientX,i=e.clientY,o=t.left,r=t.top,a=n-o>=0?n-o:0,s=i-r>=0?i-r:0;return{touch_x:Math.floor(a),touch_y:Math.floor(s)}}(e,d),h=d.element_width,v=d.element_height,f=p.touch_x,g=p.touch_y,m=l(n),_=m.element_path,b=m.positions,y=function(e){var t=o(e),n=[];return function e(t){var i=r(t);if(i&&-1===n.indexOf(i)&&n.push(i),t.childNodes.length>0)for(var o=t.childNodes,a=0;a<o.length;a++)8!==o[a].nodeType&&e(o[a])}(t),n}(n),w=window.performance.timing.navigationStart,E=Date.now()-w,T=b.map((function(e){return""+e})),x=null;if(window.TEAVisualEditor.getOriginXpath&&(x=window.TEAVisualEditor.getOriginXpath({xpath:_,positions:T})),u.element_path=x&&x.xpath||_,u.positions=x&&x.positions||T,c&&!c.text&&(u.texts=y,u.element_title=function(e){var t=o(e),n="";return function e(t){var i=r(t);if(i&&(n+=i),t.childNodes.length>0)for(var o=t.childNodes,a=0;a<o.length;a++)3===o[a].nodeType&&e(o[a])}(t),n}(n)),u.element_id=n.getAttribute("id")||"",u.element_class_name=n.getAttribute("class")||"",u.element_type=n.nodeType,u.element_width=Math.floor(h),u.element_height=Math.floor(v),u.touch_x=f,u.touch_y=g,u.page_manual_key="",u.elememt_manual_key="",u.since_page_start_ms=E,u.page_start_ms=w,u.page_path=location.pathname,u.page_host=location.host,s.track_attr&&i(n,s.track_attr)){var A=function(e,n){var i={};if("string"==typeof n)a(e,n)&&(i.attrs=e.getAttribute(n));else if(t(n))for(var o=0;o<n.length;o++)a(e,n[o])&&(i[n[o]]=e.getAttribute(n[o]));return i}(n,s.track_attr);for(var k in A)u[k]=A[k]}var N=o(n);return"A"===N.tagName&&(u.href=N.getAttribute("href")),"IMG"===n.tagName&&(u.src=n.getAttribute("src")),u}var h=function(t,n,i,o,r){return e({event:t},p(n,i,o,r),{is_html:1,page_key:window.location.href,page_title:document.title})},v=function(){function t(e,t){this.ignore={text:!1},this.initConfig=e,this.options=t,this.eventName=t&&"tea"===t.custom?{click:"__bav_click",page:"__bav_page",beat:"__bav_beat",static:"__bav_page_statistics",exposure:"__bav_page_exposure"}:{click:"bav2b_click",page:"bav2b_page",beat:"bav2b_beat",static:"bav2b_page_statistics",exposure:"bav2b_exposure"},t&&!1===t.text&&(this.ignore.text=!0),t&&t.exposure&&t.exposure.eventName&&(this.eventName.exposure=t.exposure.eventName)}return t.prototype.handleEvent=function(t,n){try{if(function(e){for(var t=e;t&&t.parentNode;){if(t.hasAttribute("data-tea-ignore"))return!0;if("HTML"===t.nodeName||"body"===t.nodeName)return!1;t=t.parentNode}return!1}(t.target))return null;var i="bav2b_click";switch(n){case"click":return i=this.eventName.click,h(i,t,t.target,this.options,this.ignore);case"exposure":return i=this.eventName.exposure,h(i,t,t.target,this.options,this.ignore);case"change":return e({},h(i="bav2b_change",t,t.target,this.options),function(e,t){try{if("bav2b_change"===e)return t.hasAttribute("data-tea-track")?{value:t.value}:{}}catch(e){return{}}}(i,t.target));case"submit":return h(i="bav2b_submit",t,t.target,this.options)}}catch(e){return console.error(e),null}},t.prototype.handleViewEvent=function(e){e.event=this.eventName.page,e.page_title=document.title,e.page_total_width=window.innerWidth,e.page_total_height=window.innerHeight;try{var t=window.sessionStorage.getItem("_tea_cache_duration");if(t){var n=JSON.parse(t);e.refer_page_duration_ms=n?n.duration:""}e.scroll_width=document.documentElement.scrollLeft?document.documentElement.scrollLeft+window.innerWidth:window.innerWidth,e.scroll_height=document.documentElement.scrollTop?document.documentElement.scrollTop+window.innerHeight:window.innerHeight,e.page_start_ms=window.performance.timing.navigationStart}catch(e){console.log("page event error "+JSON.stringify(e))}return e},t.prototype.handleStatisticsEvent=function(e){var t={};t.event=this.eventName.static,t.is_html=1,t.page_key=location.href,t.refer_page_key=document.referrer||"",t.page_title=document.title,t.page_manual_key=this.initConfig.autotrack.page_manual_key||"",t.refer_page_manual_key="";try{var n=e.lcp,i=window.performance.timing,o=i.loadEventEnd-i.navigationStart;t.page_init_cost_ms=parseInt(n||(o>0?o:0)),t.page_start_ms=i.navigationStart}catch(e){console.log("page_statistics event error "+JSON.stringify(e))}return t},t.prototype.handleBeadtEvent=function(e){e.event=this.eventName.beat,e.page_key=window.location.href,e.is_html=1,e.page_title=document.title,e.page_manual_key=this.initConfig.autotrack.page_manual_key||"";try{e.page_viewport_width=window.innerWidth,e.page_viewport_height=window.innerHeight,e.page_total_width=document.documentElement.scrollWidth,e.page_total_height=document.documentElement.scrollHeight,e.scroll_width=document.documentElement.scrollLeft+window.innerWidth,e.scroll_height=document.documentElement.scrollTop+window.innerHeight,e.since_page_start_ms=Date.now()-window.performance.timing.navigationStart,e.page_start_ms=window.performance.timing.navigationStart}catch(e){console.log("beat event error "+JSON.stringify(e))}return e},t}(),f=function(){function e(e){this.collect=e,this.eventNameList=["report_click_event","report_change_event","report_submit_event","report_exposure_event","report_page_view_event","report_page_statistics_event","report_beat_event"]}return e.prototype.send=function(e,t){var n=e.eventSend,i=t.event;delete t.event,n&&"becon"===n?this.collect.beconEvent(i,t):this.collect.event(i,t)},e.prototype.get=function(e,t){var n=Object.assign({headers:{"content-type":"application/json"},method:"GET"},t);fetch(e,n)},e.prototype.post=function(e,t){var n=Object.assign({headers:{"content-type":"application/json"},method:"POST"},t);fetch(e,n)},e}(),g={},m=[];function _(e,t,n,i){var o=e&&e.source||window.opener||window.parent,r=e&&e.origin||i||"*",a={type:t,payload:n};o.postMessage(JSON.stringify(a),r)}function b(e,t){g[e]=g[e]||[],g[e].push(t)}function y(e){if(m.some((function(e){return"*"===e}))||m.some((function(t){return e.origin.indexOf(t)>-1}))){var t=e.data;if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(e){t=void 0}if(!t)return;var n=t.type,i=t.payload;g[n]&&g[n].forEach((function(t){"function"==typeof t&&t(e,i)}))}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var w=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){e.exports=function(){function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}function t(n,i){function o(t,o,r){if("undefined"!=typeof document){"number"==typeof(r=e({},i,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var s in r)r[s]&&(a+="; "+s,!0!==r[s]&&(a+="="+r[s].split(";")[0]));return document.cookie=t+"="+n.write(o,t)+a}}function r(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],i={},o=0;o<t.length;o++){var r=t[o].split("="),a=r.slice(1).join("=");try{var s=decodeURIComponent(r[0]);if(i[s]=n.read(a,s),e===s)break}catch(e){}}return e?i[e]:i}}return Object.create({set:o,get:r,remove:function(t,n){o(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(i)},converter:{value:Object.freeze(n)}})}return t({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}()})),E=w;function T(){try{var e=window.TEAVisualEditor.lang=window.TEAVisualEditor.lang||E.get("lang"),t=window.TEAVisualEditor.__editor_ajax_domain=window.TEAVisualEditor.__editor_ajax_domain||E.get("_TEA_VE_APIHOST"),n=window.TEAVisualEditor.__editor_verison=window.TEAVisualEditor.__editor_verison||E.get("_VISUAL_EDITOR_V"),i=window.TEAVisualEditor.__editor_url=window.TEAVisualEditor.__editor_url||E.get("_VISUAL_EDITOR_U"),o=+new Date,r=new Date(o+18e5);E.set("_TEA_VE_OPEN","1",{expires:r}),E.set("_TEA_VE_APIHOST",t,{expires:r}),E.set("_VISUAL_EDITOR_U",i,{expires:r}),E.set("lang",e,{expires:r}),E.set("_VISUAL_EDITOR_V",n||"",{expires:r})}catch(e){console.log("set cookie err")}}var x=!1;function A(e){var t,n,i,o,r=e.event,a=e.editorUrl,s=e.autoTrackInstance;x||(x=!0,t=a,n=function(){_(r,"editorScriptloadSuccess"),s.destroy()},i=function(){r&&_(r,"editorScriptloadError"),x=!1},(o=document.createElement("script")).src=t,o.onerror=function(){i(t)},o.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(o))}function k(t,n){window.TEAVisualEditor=window.TEAVisualEditor||{};var i="",o="https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/visual-editor-rangers.js?query="+Date.now();window.TEAVisualEditor.appId=n.app_id;var r,a,s,c=n.channel_domain,u="";if((r=["*"]).length&&r.forEach((function(e){m.push(e)})),c){var d,l="";try{var p=window.performance.getEntriesByType("resource");if(p&&p.length&&(p.forEach((function(e){"script"===e.initiatorType&&e.name&&-1!==e.name.indexOf("collect")&&(l=e.name)})),l||document.currentScript&&(l=document.currentScript.src),l&&(d=l.split("/"))&&d.length)){u="https:/";for(var h=2;h<d.length&&h!==d.length-1;h++)u=u+"/"+d[h];if(u&&u.indexOf("/5.0")){var v=u.split("/5.0");u=v[0]||u}}}catch(e){}}if(a="0.0.4",(s=e({},n)).filter&&delete s.filter,"object"==typeof s.autotrack&&s.autotrack.collect_url&&delete s.autotrack.collect_url,(window.opener||window.parent).postMessage({type:"tea:sdk:info",config:s,version:a},"*"),window.addEventListener("message",y,!1),"1"===E.get("_TEA_VE_OPEN")){var f=function(){var e=E.get("_TEA_VE_APIHOST");try{e=JSON.parse(e)}catch(e){}return e}(),g="";f&&(window.TEAVisualEditor.__editor_ajax_domain=f,g=E.get("_VISUAL_EDITOR_U")),A({event:null,editorUrl:g||o,autoTrackInstance:t}),T()}else try{b("tea:openVisualEditor",(function(e){var n=e.data;if("string"==typeof e.data)try{n=JSON.parse(e.data)}catch(e){n=void 0}if(n){var r=n.referrer,a=n.lang;if(r&&(window.TEAVisualEditor.__editor_ajax_domain=r),i=o,c){var s=n.version;i=u?""+u+(s?"/visual-editor-rangers-v"+s:"/visual-editor-rangers-v1.0.0")+".js":o,window.TEAVisualEditor.__editor_verison=s}window.TEAVisualEditor.__editor_url=i,window.TEAVisualEditor.lang=a,A({event:e,editorUrl:i,autoTrackInstance:t}),T()}})),window.TEAVisualEditor.openAutotrackEditor=function(){A({event:null,editorUrl:window.TEAVisualEditor.__editor_url,autoTrackInstance:t})}}catch(e){console.log("receive message error")}try{b("tea:openHeatMapCore",(function(e){A({event:e,editorUrl:"https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/heatmap-core.js?query="+Date.now(),autoTrackInstance:t})}))}catch(e){console.log("openHeatMapCore error")}}var N=function(){function e(e){this._instance=null,this._intersection=e,this._intersection&&this.init()}return e.prototype.init=function(){var e=this;MutationObserver?(this._instance=new MutationObserver((function(t){t.forEach((function(t){"attributes"===t.type&&e.attributeChangeObserve(t),"childList"===t.type&&e.modifyNodeObserve(t)}))})),this._instance.observe(document.body,{childList:!0,attributes:!0,subtree:!0,attributeOldValue:!1})):console.log("your browser cannot support MutationObserver")},e.prototype.attributeChangeObserve=function(e){e.target.hasAttribute("data-exposure")?this.exposureAdd(e,"mutation"):this.exposureRemove(e)},e.prototype.modifyNodeObserve=function(e){var t=this;Array.prototype.forEach.call(e.addedNodes,(function(e){1===e.nodeType&&e.hasAttribute("data-exposure")&&t.exposureAdd(e,"intersect"),t.mapChild(e,t.exposureAdd)})),Array.prototype.forEach.call(e.removedNodes,(function(e){1===e.nodeType&&e.hasAttribute("data-exposure")&&t.exposureRemove(e),t.mapChild(e,t.exposureRemove)}))},e.prototype.mapChild=function(e,t){var n=this;1===e.nodeType&&e.children.length&&Array.prototype.forEach.call(e.children,(function(e){1===e.nodeType&&e.hasAttribute("data-exposure")&&t(e),n.mapChild(e,t)}))},e.prototype.exposureAdd=function(e,t){try{this._intersection&&this._intersection.exposureAdd(e,t)}catch(e){console.log("intersection error",JSON.stringify(e.message))}},e.prototype.exposureRemove=function(e){try{this._intersection&&this._intersection.exposureRemove(e)}catch(e){console.log("intersection error",JSON.stringify(e.message))}},e._exposure_observer=null,e}(),O=function(){function e(t,n){this.count=1,this.instance=this.buildObserver(),this.observeMap=e._observer_map,t.autotrack.exposure.ratio?this.Ratio=t.autotrack.exposure.ratio:0===t.autotrack.exposure.ratio?this.Ratio=0:this.Ratio=.5,this.EventHandle=n}return e.prototype.buildObserver=function(){var t=this;return e._observer_instance?(console.log("your browser cannot support IntersectionObserver"),null):(IntersectionObserver&&(e._observer_instance=new IntersectionObserver((function(e){e.forEach((function(e){t.observeMap.get(e.target._observeId)&&t.exposureEvent(e)}))}),{threshold:[.01,.25,.5,.75,1]})),e._observer_instance)},e.prototype.exposureAdd=function(e,t){var n=e;"mutation"===t&&(n=e.target);var i=n._observeId;if(i||this.observeMap.has(i)){if(!1===n.visible){var o=n.getBoundingClientRect(),r=o.top,a=o.left,s=o.right,c=o.bottom;r>=0&&c<=window.innerHeight&&a>=0&&s<=window.innerWidth&&(n.visible=!0,this.EventHandle({eventType:"dom",eventName:"exposure"},e))}}else n._observeId=this.count,n.visible=!1,this.observeMap.set(this.count,n),this.observe(n),this.count++},e.prototype.exposureRemove=function(e){this.observeMap.has(e._observeId)&&(this.observeMap.delete(e._observeId),this.unobserve(e))},e.prototype.exposureEvent=function(e){if(e.intersectionRatio>=this.Ratio&&e.isIntersecting){if("0"===e.target.style.opacity||"hidden"===e.target.style.visibility)return;if(!0===e.target.visible)return;e.target.visible=!0,this.EventHandle({eventType:"dom",eventName:"exposure"},e)}else e.target.visible=!1},e.prototype.observe=function(e){this.instance&&this.instance.observe(e)},e.prototype.unobserve=function(e){this.instance&&this.instance.unobserve(e)},e._observer_instance=null,e._observer_map=new Map,e}(),S=function(){function e(e,t){e.autotrack&&e.autotrack.exposure&&(this._intersection=new O(e,t),this._observer=new N(this._intersection),this._intersection&&this._observer?this.initObserver():console.log("your browser version cannot support exposure, please update~"))}return e.prototype.initObserver=function(){var e=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),(function(t){e._intersection.exposureAdd(t,"intersect")}))},e}(),I={hashTag:!1,impr:!1},C=function(){function e(){}return e.prototype.apply=function(e,t){if(this.autoTrackStart=!1,this.collect=e,this.config=t,t.autotrack){var n=e.Types;t.autotrack&&t.autotrack.collect_url&&!t.autotrack.collect_url()||(this.ready(n.Autotrack),this.collect.emit(n.AutotrackReady))}},e.prototype.ready=function(e){this.collect.set(e);var t=this.config.autotrack;t="object"==typeof t?t:{},t=Object.assign(I,t),this.destroyed=!1,this.options=t,this.Config=new d(u,this.options),this.Exposure=new S(this.config,this.handle.bind(this)),this.Listener=new c(t,this.collect,this.Config),this.EventHandle=new v(this.config,t),this.Request=new f(this.collect),this.autoTrackStart=!0,this.init(),k(this,this.config)},e.prototype.init=function(){this.Listener.init(this.handle.bind(this))},e.prototype.handle=function(e,t){"dom"===e.eventType&&this.handleDom(e,t)},e.prototype.handleDom=function(e,t){try{var n=e.eventName;if("click"===n||"exposure"===n||"change"===n||"submit"===n){var i=this.EventHandle.handleEvent(t,n);null!==i&&this.Request.send({eventType:"custom",eventName:"report_"+n+"_event",extra:{methods:"GET"}},i)}else if("page_view"===n||"page_statistics"===n){var o=void 0;o="page_view"===n?this.EventHandle.handleViewEvent(t):this.EventHandle.handleStatisticsEvent(t),this.Request.send({eventType:"custom",eventName:"report_${eventName}_event",extra:{methods:"GET"}},o)}else if("beat"===n){var r=this.EventHandle.handleBeadtEvent(t),a=e.eventSend;this.Request.send({eventType:"custom",eventName:"report_${eventName}_event",extra:{methods:"GET"},eventSend:a},r)}}catch(e){console.log("handel dom event error "+JSON.stringify(e))}},e.prototype.destroy=function(){if(!this.autoTrackStart)return console.warn("engine is undefined, make sure you have called autoTrack.start()");this.autoTrackStart=!1,this.Listener.removeListener()},e}();module.exports=C;
|
package/lib/plugin/duration.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t=function(){function t(){}return t.prototype.apply=function(t,a){var e=this;this.collector=t,this.config=a;var r=t.Types;t.on(r.TrackDurationStart,(function(t){e.trackStart(t)})),t.on(r.TrackDurationEnd,(function(t){e.trackEnd(t)})),t.on(r.TrackDurationPause,(function(t){e.trackPause(t)})),t.on(r.TrackDurationResume,(function(t){e.trackResume(t)})),this.Types=r,this.TrackMap=new Map,this.ready(r.TrackDuration)},t.prototype.ready=function(t){var a=this;if(this.collector.set(t),this.collector.hook._hooksCache.hasOwnProperty(t)){var e=this.collector.hook._hooksCache[t];if(!Object.keys(e).length)return;var r=function(t){e[t].length&&e[t].forEach((function(e){a.collector.hook.emit(t,e)}))};for(var o in e)r(o)}},t.prototype.trackStart=function(t){this.TrackMap.set(t,{startTime:Date.now(),isPause:!1,pauseTime:0,resumeTime:0})},t.prototype.trackEnd=function(t){var a=t.eventName,e=t.params;if(this.TrackMap.has(a)){var r=this.TrackMap.get(a),o=0;o=r.isPause?r.pauseTime-r.startTime:r.resumeTime?r.pauseTime-r.startTime+(Date.now()-r.resumeTime):Date.now()-r.startTime;var i=Object.assign(e,{event_duration:o});this.collector.event(a,i),this.cleanTrack(a)}},t.prototype.trackPause=function(t){if(this.TrackMap.has(t)){var a=this.TrackMap.get(t);a.isPause||(a.isPause=!0,a.pauseTime=Date.now(),this.TrackMap.set(t,a))}},t.prototype.trackResume=function(t){if(this.TrackMap.has(t)){var a=this.TrackMap.get(t);a.isPause&&(a.isPause=!1,a.resumeTime=Date.now(),this.TrackMap.set(t,a))}},t.prototype.cleanTrack=function(t){this.TrackMap.delete(t)},t}();module.exports=t;
|
package/lib/plugin/route.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var o,r,n=a.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return i}function t(){for(var t=[],a=0;a<arguments.length;a++)t=t.concat(e(arguments[a]));return t}var a,o;!function(e){e.Init="init",e.Config="config",e.Start="start",e.Ready="ready",e.TokenComplete="token-complete",e.TokenStorage="token-storage",e.TokenFetch="token-fetch",e.TokenError="token-error",e.ConfigUuid="config-uuid",e.ConfigWebId="config-webid",e.ConfigDomain="config-domain",e.CustomWebId="custom-webid",e.AnonymousId="anonymous-id",e.TokenChange="token-change",e.TokenReset="token-reset",e.ConfigTransform="config-transform",e.EnvTransform="env-transform",e.SessionReset="session-reset",e.SessionResetTime="session-reset-time",e.Event="event",e.Events="events",e.EventNow="event-now",e.CleanEvents="clean-events",e.BeconEvent="becon-event",e.SubmitBefore="submit-before",e.SubmitScuess="submit-scuess",e.SubmitAfter="submit-after",e.SubmitError="submit-error",e.SubmitVerifyH="submit-verify-h5",e.Stay="stay",e.ResetStay="reset-stay",e.StayReady="stay-ready",e.SetStay="set-stay",e.RouteChange="route-change",e.RouteReady="route-ready",e.Ab="ab",e.AbVar="ab-var",e.AbAllVars="ab-all-vars",e.AbConfig="ab-config",e.AbExternalVersion="ab-external-version",e.AbVersionChangeOn="ab-version-change-on",e.AbVersionChangeOff="ab-version-change-off",e.AbOpenLayer="ab-open-layer",e.AbCloseLayer="ab-close-layer",e.AbReady="ab-ready",e.AbComplete="ab-complete",e.AbTimeout="ab-timeout",e.Profile="profile",e.ProfileSet="profile-set",e.ProfileSetOnce="profile-set-once",e.ProfileUnset="profile-unset",e.ProfileIncrement="profile-increment",e.ProfileAppend="profile-append",e.ProfileClear="profile-clear",e.TrackDuration="track-duration",e.TrackDurationStart="track-duration-start",e.TrackDurationEnd="track-duration-end",e.TrackDurationPause="track-duration-pause",e.TrackDurationResume="tracl-duration-resume",e.Autotrack="autotrack",e.AutotrackReady="autotrack-ready",e.CepReady="cep-ready",e.TracerReady="tracer-ready"}(a||(a={})),function(e){e.DEBUGGER_MESSAGE="debugger-message",e.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",e.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",e.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",e.DEBUGGER_MESSAGE_EVENT="debugger-message-event",e.DEVTOOL_WEB_READY="devtool-web-ready"}(o||(o={}));var r=function(){function e(){this.autotrack=!1,this.spa=!1,this.cache={},this.allowHash=!1}return e.prototype.apply=function(e,t){if(t.spa||t.autotrack){var a=e.Types;this.collect=e,this.config=t,this.appid=t.app_id,this.allowHash=t.allow_hash,this.fncArray=new Map,this.setKey(),this.setLocation(),this.hack(),this.init(),this.listener(),e.emit(a.RouteReady)}},e.prototype.setKey=function(){var e=this.collect.adapters.storage;this.storage=new e(!1),this.cache_key="__tea_cache_refer_"+this.appid,this.cache={refer_key:"",refer_title:document.title||location.pathname,refer_manual_key:"",routeChange:!1},this.config.autotrack&&"object"==typeof this.config.autotrack&&this.config.autotrack.page_manual_key&&(this.cache.refer_manual_key=this.config.autotrack.page_manual_key),this.storage.setItem(this.cache_key,this.cache)},e.prototype.hack=function(){var e=this,a=window.history.pushState;history.pushState=function(o){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];"function"==typeof history.onpushstate&&history.onpushstate({state:o});var i=a.call.apply(a,t([history,o],r));if(e.lastLocation!==location.href){var s=e.getPopStateChangeEventData();return e.setReferCache(e.lastLocation),e.lastLocation=location.href,e.sendPv(s,"pushState"),i}};var o=history.replaceState;history.replaceState=function(a){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];"function"==typeof history.onreplacestate&&history.onreplacestate({state:a});var i=o.call.apply(o,t([history,a],r));if(e.lastLocation!==location.href){var s=e.getPopStateChangeEventData();return e.setReferCache(e.lastLocation),e.lastLocation=location.href,e.sendPv(s),i}}},e.prototype.setLocation=function(){"undefined"!=typeof window&&(this.lastLocation=window.location.href)},e.prototype.getLocation=function(){return this.lastLocation},e.prototype.init=function(){var e=this.getPopStateChangeEventData();this.collect.emit("route-change",{config:e,init:!0})},e.prototype.listener=function(){var e=this,t=null;window.addEventListener("hashchange",(function(a){if(e.lastLocation!==window.location.href&&(clearTimeout(t),e.allowHash)){e.setReferCache(e.lastLocation),e.lastLocation=window.location.href;var o=e.getPopStateChangeEventData();e.sendPv(o)}})),window.addEventListener("popstate",(function(a){e.lastLocation!==window.location.href&&(t=setTimeout((function(){e.setReferCache(e.lastLocation),e.lastLocation=window.location.href;var t=e.getPopStateChangeEventData();e.sendPv(t)}),10))}))},e.prototype.getPopStateChangeEventData=function(){var e=this.pageConfig();return e.is_back=0,e},e.prototype.pageConfig=function(){try{var e=this.storage.getItem(this.cache_key)||{},t=!1,a=this.storage.getItem("__tea_cache_first_"+this.appid);return t=!a||1!=a,{is_html:1,url:location.href,referrer:this.handleRefer(),page_key:location.href,refer_page_key:this.handleRefer(),page_title:document.title||location.pathname,page_manual_key:this.config.autotrack&&this.config.autotrack.page_manual_key||"",refer_page_manual_key:e&&e.refer_manual_key||"",refer_page_title:e&&e.refer_title||"",page_path:location.pathname,page_host:location.host,is_first_time:""+t}}catch(e){return this.collect.emit(o.DEBUGGER_MESSAGE,{type:o.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),{}}},e.prototype.sendPv=function(e,t){this.collect.emit("route-change",{config:e,init:!1})},e.prototype.handleRefer=function(){var e="";try{var t=this.storage.getItem()||{};e=t.routeChange?t.refer_key:this.collect.configManager.get("referrer")}catch(t){e=document.referrer}return e},e.prototype.setReferCache=function(e){var t=this.storage.getItem(this.cache_key)||{};t.refer_key=e,t.routeChange=!0,this.storage.setItem(this.cache_key,t)},e}();module.exports=r;
|
package/lib/plugin/stay.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t=function(){return t=Object.assign||function(t){for(var e,i=1,a=arguments.length;i<a;i++)for(var s in e=arguments[i])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},t.apply(this,arguments)},e=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)};Date.now(),Number((""+Math.random()).slice(2,8));var i,a,s=function(){var t=0;return["hidden","msHidden","webkitHidden"].forEach((function(e){void 0!==document[e]&&(t=1)})),t},n=function(){function i(t,i){this.maxDuration=432e5,this.aliveDTime=6e4,this.options={aliveName:"predefine_page_alive",params:{}},this.collect=t,this.config=i,this.pageStartTime=Date.now(),this.sessionStartTime=this.pageStartTime,this.timerHandler=null,e(i.enable_stay_duration)&&(this.options=Object.assign(this.options,i.enable_stay_duration))}return i.prototype.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},i.prototype.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},i.prototype.enable=function(t,e,i){this.url_path=t||this.url_path,this.url=i||this.url,this.title=e||this.title,this.disableCallback=this.enablePageAlive(),this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params},i.prototype.disable=function(){this.disableCallback(),this.pageStartTime=Date.now()},i.prototype.sendEvent=function(e,i){void 0===i&&(i=!1);var a=i?this.aliveDTime:Date.now()-this.sessionStartTime;a<0||a>this.aliveDTime||Date.now()-this.pageStartTime>this.maxDuration||(this.collect.beconEvent(this.options.aliveName,t({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),duration:a,is_support_visibility_change:s(),startTime:this.sessionStartTime,hidden:document.visibilityState,leave:e},this.customParmas)),this.sessionStartTime=Date.now(),this.resetParams(location.pathname,document.title,location.href))},i.prototype.getParams=function(t){switch(t){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},i.prototype.setUpTimer=function(){var t=this;return this.timerHandler&&clearInterval(this.timerHandler),setInterval((function(){Date.now()-t.sessionStartTime>t.aliveDTime&&t.sendEvent(!1,!0)}),1e3)},i.prototype.visibilitychange=function(){"hidden"===document.visibilityState?this.timerHandler&&(clearInterval(this.timerHandler),this.sendEvent(!1)):"visible"===document.visibilityState&&(this.sessionStartTime=Date.now(),this.timerHandler=this.setUpTimer())},i.prototype.beforeunload=function(){document.hidden||this.sendEvent(!0)},i.prototype.enablePageAlive=function(){var t=this;this.timerHandler=this.setUpTimer();var e=this.visibilitychange.bind(this),i=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",i),function(){t.beforeunload(),document.removeEventListener("visibilitychange",e),window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i)}},i}(),o=function(){function i(t,i){var a=this;this.maxDuration=432e5,this.aliveDTime=6e4,this.options={closeName:"predefine_page_close",params:{}},this.visibilitychange=function(){"hidden"===document.visibilityState?a.activeEndTime=Date.now():"visible"===document.visibilityState&&(a.activeEndTime&&(a.totalTime+=a.activeEndTime-a.activeStartTime,a.activeTimes+=1),a.activeEndTime=void 0,a.activeStartTime=Date.now())},this.beforeunload=function(){if(a.totalTime+=(a.activeEndTime||Date.now())-a.activeStartTime,a.config.autotrack){try{window.sessionStorage.setItem("_tea_cache_duration",JSON.stringify({duration:a.totalTime,page_title:document.title||location.pathname}))}catch(t){}}a.sendEventPageClose()},this.collect=t,this.config=i,this.maxDuration=i.maxDuration||864e5,this.pageStartTime=Date.now(),e(i.enable_stay_duration)&&(this.options=Object.assign(this.options,i.enable_stay_duration)),this.resetData()}return i.prototype.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},i.prototype.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},i.prototype.enable=function(t,e,i){this.url_path=t||this.url_path,this.url=i||this.url,this.title=e||this.title,this.disableCallback=this.enablePageClose()},i.prototype.disable=function(){this.disableCallback()},i.prototype.resetData=function(){this.activeStartTime=void 0===this.activeStartTime?this.pageStartTime:Date.now(),this.activeEndTime=void 0,this.activeTimes=1,this.totalTime=0,this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params,this.resetParams(location.pathname,document.title,location.href)},i.prototype.sendEventPageClose=function(){var e=Date.now()-this.pageStartTime;this.totalTime<0||e<0||this.totalTime>=this.maxDuration||(this.collect.beconEvent(this.options.closeName,t({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),active_times:this.activeTimes,duration:this.totalTime,total_duration:e,is_support_visibility_change:s()},this.customParmas)),this.pageStartTime=Date.now(),this.resetData())},i.prototype.getParams=function(t){switch(t){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},i.prototype.enablePageClose=function(){var t=this,e=this.visibilitychange.bind(this),i=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",i),function(){t.beforeunload(),document.removeEventListener("visibilitychange",e),window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i)}},i}();!function(t){t.Init="init",t.Config="config",t.Start="start",t.Ready="ready",t.TokenComplete="token-complete",t.TokenStorage="token-storage",t.TokenFetch="token-fetch",t.TokenError="token-error",t.ConfigUuid="config-uuid",t.ConfigWebId="config-webid",t.ConfigDomain="config-domain",t.CustomWebId="custom-webid",t.AnonymousId="anonymous-id",t.TokenChange="token-change",t.TokenReset="token-reset",t.ConfigTransform="config-transform",t.EnvTransform="env-transform",t.SessionReset="session-reset",t.SessionResetTime="session-reset-time",t.Event="event",t.Events="events",t.EventNow="event-now",t.CleanEvents="clean-events",t.BeconEvent="becon-event",t.SubmitBefore="submit-before",t.SubmitScuess="submit-scuess",t.SubmitAfter="submit-after",t.SubmitError="submit-error",t.SubmitVerifyH="submit-verify-h5",t.Stay="stay",t.ResetStay="reset-stay",t.StayReady="stay-ready",t.SetStay="set-stay",t.RouteChange="route-change",t.RouteReady="route-ready",t.Ab="ab",t.AbVar="ab-var",t.AbAllVars="ab-all-vars",t.AbConfig="ab-config",t.AbExternalVersion="ab-external-version",t.AbVersionChangeOn="ab-version-change-on",t.AbVersionChangeOff="ab-version-change-off",t.AbOpenLayer="ab-open-layer",t.AbCloseLayer="ab-close-layer",t.AbReady="ab-ready",t.AbComplete="ab-complete",t.AbTimeout="ab-timeout",t.Profile="profile",t.ProfileSet="profile-set",t.ProfileSetOnce="profile-set-once",t.ProfileUnset="profile-unset",t.ProfileIncrement="profile-increment",t.ProfileAppend="profile-append",t.ProfileClear="profile-clear",t.TrackDuration="track-duration",t.TrackDurationStart="track-duration-start",t.TrackDurationEnd="track-duration-end",t.TrackDurationPause="track-duration-pause",t.TrackDurationResume="tracl-duration-resume",t.Autotrack="autotrack",t.AutotrackReady="autotrack-ready",t.CepReady="cep-ready",t.TracerReady="tracer-ready"}(i||(i={})),function(t){t.DEBUGGER_MESSAGE="debugger-message",t.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",t.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",t.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",t.DEBUGGER_MESSAGE_EVENT="debugger-message-event",t.DEVTOOL_WEB_READY="devtool-web-ready"}(a||(a={}));var r=function(){function t(){}return t.prototype.apply=function(t,e){var i=this;if(this.collect=t,this.config=e,this.config.enable_stay_duration){this.title=document.title||location.pathname,this.url=location.href,this.url_path=location.pathname,this.pageAlive=new n(t,e),this.pageClose=new o(t,e);var a=this.collect.Types;this.collect.on(a.ResetStay,(function(t){var e=t.url_path,a=t.title,s=t.url;i.resetStayDuration(e,a,s)})),this.collect.on(a.RouteChange,(function(t){t.init||e.disable_route_report||i.resetStayDuration()})),this.collect.on(a.SetStay,(function(t){var e=t.url_path,a=t.title,s=t.url;i.setStayParmas(e,a,s)})),this.enable(this.url_path,this.title,this.url),this.ready(a.Stay),this.collect.emit(a.StayReady)}},t.prototype.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var a=function(t){i[t].length&&i[t].forEach((function(i){e.collect.hook.emit(t,i)}))};for(var s in i)a(s)}},t.prototype.enable=function(t,e,i){this.pageAlive.enable(t,e,i),this.pageClose.enable(t,e,i)},t.prototype.disable=function(){this.pageAlive.disable(),this.pageClose.disable()},t.prototype.setStayParmas=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.pageAlive.setParams(t,e,i),this.pageClose.setParams(t,e,i),this.collect.emit(a.DEBUGGER_MESSAGE,{type:a.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayParams",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},t.prototype.reset=function(t,e,i){this.disable(),this.enable(t,e,i)},t.prototype.resetStayDuration=function(t,e,i){this.reset(t,e,i),this.collect.emit(a.DEBUGGER_MESSAGE,{type:a.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayDuration",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},t}();module.exports=r;
|
package/lib/plugin/store.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t=function(){function t(){this.retryWaitTime=3e3,this.retryStatus=!1,this.retryCacheStatus=!1}return t.prototype.apply=function(t,e){var r=this;if(e.enable_storage&&!e.disable_storage&&(this.collect=t,this.config=e,!this.collect.destroyInstance)){var a=t.Types,n=t.adapters,o=n.storage,i=n.fetch;this.storage=new o(!1),this.fetch=i,this.eventUrl=this.collect.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+e.app_id,this.storageNum=e.storage_num||50,this.retryNum=e.retry_num||3,this.retryInterval=1e3,t.on(a.SubmitError,(function(t){"f_data"===t.type&&r.storeData(t)})),t.on(a.Ready,(function(){r.checkStorage()}))}},t.prototype.retryRightNow=function(t){var e=this;if(this.retryStatus)this.errorCache.push(t);else{var r=0;this.retryStatus=!0;var a=setInterval((function(){if(3===r)return e.storeData(e.errorCache),e.retryStatus=!1,void clearInterval(a);var n=t.eventData;e.fetchData(n,(function(){e.retryStatus=!1,clearInterval(a),e.retryCacheStatus&&e.errorCache.splice(0,1),e.errorCache.length&&(e.retryCacheStatus=!0,e.retryRightNow(e.errorCache[0]))}),(function(){r++}))}),this.retryInterval)}},t.prototype.storeData=function(t){var e=this.storage.getItem(this.eventKey),r=t.eventData;Object.keys(e).length!==this.storageNum&&(e[Date.now()]=r,this.storage.setItem(this.eventKey,e))},t.prototype.checkStorage=function(){var t=this;try{if(!window.navigator.onLine)return;var e=this.storage.getItem(this.eventKey);if(!e||!Object.keys(e).length)return;var r={events:[{event:"ontest",params:{app_id:this.config.app_id},local_time_ms:Date.now()}],user:{user_unique_id:this.collect.configManager.get("web_id")},header:{}};this.fetchData([r],(function(){var r=JSON.parse(JSON.stringify(e)),a=function(a){t.fetchData(e[a],(function(){delete r[a],t.storage.setItem(t.eventKey,r)}),(function(){}),!1)};for(var n in e)a(n)}),(function(){}),!0)}catch(t){console.warn("error check storage")}},t.prototype.fetchData=function(t,e,r,a){this.fetch(this.eventUrl,t,3e4,!1,(function(){e&&e()}),(function(){r&&r(),console.log("network error,compensate report failk")}),a&&!this.config.channel_domain?"566f58151b0ed37e":"")},t}();module.exports=t;
|