@datarangers/sdk-javascript 0.1.1 → 0.1.2
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/es/index-base.min.js +1 -1
- package/es/index.min.js +1 -1
- package/lib/index-base.min.js +1 -1
- package/lib/index.min.js +1 -1
- package/package.json +1 -1
package/es/index-base.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=function(){return t=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},t.apply(this,arguments)};function e(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var r,n,o=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}function i(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(e(arguments[i]));return t}var r,n=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 r(n){e(n),i.off(t,r)})}},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}(),o=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)},s=(r=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return r+=1}),a=function(t){return function(t,e,i){if("string"==typeof t&&"number"==typeof e&&"number"==typeof i){var r,n=[];i=i<=25?i:i%25;var o=String.fromCharCode(i+97);r=t.split(o);for(var s=0;s<r.length;s++){var a=parseInt(r[s],i);a=1*a^e;var c=String.fromCharCode(a);n.push(c)}return n.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,r,n=t.split("=");n.length&&(i=n[0],r=n[1]);try{e[i]=decodeURIComponent(void 0===r?"":r)}catch(t){e[i]=r}})}catch(t){}return e},f=function(t){for(var e=0,i=0,r=(t+="").length,n=0;n<r;n++)((e=31*e+t.charCodeAt(i++))>0x7fffffffffff||e<-0x800000000000)&&(e&=0xffffffffffff);return e<0&&(e+=0x7ffffffffffff),e};var p=function(t){var e,i,r=[],n=t.length;n%2!=0&&(i=n+1,t=(e=t).length>=i?e:new Array(i-e.length+1).join("0")+e),n=t.length;for(var o=0;o<n;o+=2)r.push(parseInt(t.substr(o,2),16));return r},l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(t,e){return t(e={exports:{}},e.exports),e.exports}var d=g(function(t,e){var i;i=function(){function t(){for(var t=0,e={};t<arguments.length;t++){var i=arguments[t];for(var r in i)e[r]=i[r]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(r){function n(){}function o(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=t({path:"/"},n.defaults,o)).expires&&(o.expires=new Date(1*new Date+864e5*o.expires)),o.expires=o.expires?o.expires.toUTCString():"";try{var s=JSON.stringify(i);/^[\{\[]/.test(s)&&(i=s)}catch(t){}i=r.write?r.write(i,e):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var c in o)o[c]&&(a+="; "+c,!0!==o[c]&&(a+="="+o[c].split(";")[0]));return document.cookie=e+"="+i+a}}function s(t,i){if("undefined"!=typeof document){for(var n={},o=document.cookie?document.cookie.split("; "):[],s=0;s<o.length;s++){var a=o[s].split("="),c=a.slice(1).join("=");i||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var h=e(a[0]);if(c=(r.read||r)(c,h)||e(c),i)try{c=JSON.parse(c)}catch(t){}if(n[h]=c,t===h)break}catch(t){}}return t?n[t]:n}}return n.set=o,n.get=function(t){return s(t,!1)},n.getJSON=function(t){return s(t,!0)},n.remove=function(e,i){o(e,"",t(i,{expires:-1}))},n.defaults={},n.withConverter=i,n}(function(){})},t.exports=i()}),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 d.get(t)}catch(t){return""}},setCookie:function(t,e,i,r){try{var n=r||document.domain,o=+new Date+i;d.set(t,e,{expires:new Date(o),path:"/",domain:n})}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,r){this._storage.setCookie(t,e,i,r)},t.prototype.removeItem=function(t){this._storage.removeItem(t)},t}(),S=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,r=i?h(i).hostname:"",n=u(window.location.href),o=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion)?"wap":"web";this.utm=function(t,e,i,r){var n=new E(!1),o=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 p in u)u[p]&&(-1!==h.indexOf(p)?(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data[p]=u[p]):c[p]=u[p],f=!0);if(f)o.setItem(a,"1"),n.setCookie(s,JSON.stringify(c),r,i);else{var l=n.getCookie(s,i);l&&(c=JSON.parse(l))}o.getItem(a)&&(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data.$utm_from_url=1)}catch(t){return u}return c}(this.appid,n,this.domain,this.cookie_expire);var s=this.browser(),a=this.os();return{browser:s.browser,browser_version:s.browser_version,platform:o,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:r,utm:this.utm,latest_data:this.last(i,r)}},t.prototype.last=function(t,e){var i="",r="",n="",o=location.hostname,s=!1;if(t&&e&&o!==e){i=t,r=e,s=!0;var a=u(t);a.keyword&&(n=a.keyword)}return{$latest_referrer:i,$latest_referrer_host:r,$latest_search_keyword:n,isLast:s}},t.prototype.browser=function(){var t,e,i="",r=""+parseFloat(this.appVersion),n=this.userAgent;return-1!==n.indexOf("Edge")||-1!==n.indexOf("Edg")?(i="Microsoft Edge",-1!==n.indexOf("Edge")?(t=n.indexOf("Edge"),r=n.substring(t+5)):(t=n.indexOf("Edg"),r=n.substring(t+4))):-1!==(t=n.indexOf("MSIE"))?(i="Microsoft Internet Explorer",r=n.substring(t+5)):-1!==(t=n.indexOf("Lark"))?(i="Lark",r=n.substring(t+5,t+11)):-1!==(t=n.indexOf("MetaSr"))?(i="sougoubrowser",r=n.substring(t+7,t+10)):-1!==n.indexOf("MQQBrowser")||-1!==n.indexOf("QQBrowser")?(i="qqbrowser",-1!==n.indexOf("MQQBrowser")?(t=n.indexOf("MQQBrowser"),r=n.substring(t+11,t+15)):-1!==n.indexOf("QQBrowser")&&(t=n.indexOf("QQBrowser"),r=n.substring(t+10,t+17))):-1!==n.indexOf("Chrome")?-1!==(t=n.indexOf("MicroMessenger"))?(i="weixin",r=n.substring(t+15,t+20)):-1!==(t=n.indexOf("360"))?(i="360browser",r=n.substring(n.indexOf("Chrome")+7)):-1!==n.indexOf("baidubrowser")||-1!==n.indexOf("BIDUBrowser")?(-1!==n.indexOf("baidubrowser")?(t=n.indexOf("baidubrowser"),r=n.substring(t+13,t+16)):-1!==n.indexOf("BIDUBrowser")&&(t=n.indexOf("BIDUBrowser"),r=n.substring(t+12,t+15)),i="baidubrowser"):-1!==(t=n.indexOf("xiaomi"))?-1!==n.indexOf("openlanguagexiaomi")?(i="openlanguage xiaomi",r=n.substring(t+7,t+13)):(i="xiaomi",r=n.substring(t-7,t-1)):-1!==(t=n.indexOf("TTWebView"))?(i="TTWebView",r=n.substring(t+10,t+23)):(-1!==(t=n.indexOf("Chrome"))||-1!==(t=n.indexOf("Chrome")))&&(i="Chrome",r=n.substring(t+7)):-1!==n.indexOf("Safari")?-1!==(t=n.indexOf("QQ"))?(i="qqbrowser",r=n.substring(t+10,t+16)):-1!==(t=n.indexOf("Safari"))&&(i="Safari",r=n.substring(t+7),-1!==(t=n.indexOf("Version"))&&(r=n.substring(t+8))):-1!==(t=n.indexOf("Firefox"))?(i="Firefox",r=n.substring(t+8)):-1!==(t=n.indexOf("MicroMessenger"))?(i="weixin",r=n.substring(t+15,t+20)):-1!==(t=n.indexOf("QQ"))?(i="qqbrowser",r=n.substring(t+3,t+8)):-1!==(t=n.indexOf("Opera"))&&(i="Opera",r=n.substring(t+6),-1!==(t=n.indexOf("Version"))&&(r=n.substring(t+8))),-1!==(e=r.indexOf(";"))&&(r=r.substring(0,e)),-1!==(e=r.indexOf(" "))&&(r=r.substring(0,e)),-1!==(e=r.indexOf(")"))&&(r=r.substring(0,e)),{browser:i,browser_version:r}},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)/}],r=0;r<i.length;r++){var n=i[r];if(n.r.test(this.userAgent)){"Mac OS X"===(t=n.s)&&this.isNewIpad()&&(t="iOS");break}}var o=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=o(/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=o(/Android ([\.\_\d]+)/,a))||(c=o(/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 (",""),r=i.indexOf(";");e=i.slice(0,r)}}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}(),w=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}(),T=function(){function t(){this.support=this.isSupportLS()}return t.prototype.isSupportLS=function(){try{return localStorage.setItem("_applogtest-test-key","hi"),localStorage.getItem("_applogtest-test-key"),localStorage.removeItem("_applogtest-test-key"),!0}catch(t){return!1}},t.prototype.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{}},t.prototype.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},t.prototype.removeItem=function(t){try{localStorage.removeItem(t)}catch(t){}},t}(),D=function(){function t(){this.support=this.isSupportSession()}return t.prototype.isSupportSession=function(){try{return sessionStorage.setItem("_applogtest-test-key","hi"),sessionStorage.getItem("_applogtest-test-key"),sessionStorage.removeItem("_applogtest-test-key"),!0}catch(t){return!1}},t.prototype.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{}},t.prototype.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},t.prototype.removeItem=function(t){try{sessionStorage.removeItem(t)}catch(t){}},t}(),I=function(){function t(){this.defaultExpireTime=6048e5,this.local=new T,this.session=new D,this.cache=new w}return t.prototype.getLocalItem=function(t){return this.local.getItem(t)},t.prototype.setLocalItem=function(t,e){this.local.setItem(t,e)},t.prototype.removeLocalItem=function(t){this.local.removeItem(t)},t.prototype.getSessionItem=function(t){return this.session.getItem(t)},t.prototype.setSessionItem=function(t,e){this.session.setItem(t,e)},t.prototype.removeSessionItem=function(t){this.session.removeItem(t)},t.prototype.getCacheItem=function(t){return this.cache.getItem(t)},t.prototype.setCacheItem=function(t,e){this.cache.setItem(t,e)},t.prototype.removeCacheItem=function(t){this.cache.removeItem(t)},t.prototype.getCookie=function(t,e){try{return d.get(t)}catch(t){return""}},t.prototype.setCookie=function(t,e,i,r){void 0===i&&(i=this.defaultExpireTime);try{var n=r||document.domain,o=+new Date+i;d.set(t,e,{expires:new Date(o),path:"/",domain:n})}catch(t){}},t.prototype.removeCookie=function(t,e){try{d.remove(t,{path:"/",domain:e||""})}catch(t){}},t}(),A={cn:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},k="0.1.0",B=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","$bav2b_slide"],this.paramsNameWhiteList=["$inactive","$inline","$target_uuid_list","$source_uuid","$is_spider","$source_id","$is_first_time","$user_unique_id_type","_staging_flag","$exposure_type","$direction","$offsetY","$offsetX"],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 r=i.events,n=i.header;if(!r||!r.length)return!1;var o=!0;return r.forEach(function(t){e.checkEventName(t.event)||(o=!1,t.checkEvent="事件名不能以 $ or __开头"),e.checkEventParams(t.params)||(o=!1,t.checkParams="属性名不能以 $ or __开头")}),this.checkEventParams(n)||(o=!1),o},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 r in e){if(!this.calculate(r,"params")){i=!1;break}if("string"==typeof e[r]&&e[r].length>1024){console.warn("params: "+r+" 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.SubmitSuccess="submit-success",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.CustomHeader="custom-request-header",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 C=y,R=void 0,O=(new Date).getTimezoneOffset(),M=parseInt(""+-O/60,10),x=60*O,G=function(){function e(t,e){this.is_first_time=!0,this.configPersist=!1,this.enableClientTransport=!1,this.initConfig=e,this.collect=t;var i=new S(e.app_id,e.cookie_domain||"",e.cookie_expire||7776e6).init();this.eventCheck=new B(t,e);var r="__tea_cache_first_"+e.app_id;this.configKey="__tea_cache_config_"+e.app_id,this.storage=new I,e.configPersist&&(this.configPersist=!0,this.storage=1===e.configPersist?this.sessionStorage:this.localStorage);var n=this.storage.getLocalItem(r);n&&1==n?this.is_first_time=!1:(this.is_first_time=!0,this.storage.setLocalItem(r,"1")),this.envInfo={user:{user_unique_id:R,user_type:R,user_id:R,user_is_auth:R,user_is_login:R,device_id:R,web_id:R,ip_addr_id:R,user_unique_id_type:R,anonymous_id:R},header:{app_id:R,app_name:R,app_install_id:R,install_id:R,app_package:R,app_channel:R,app_version:R,ab_version:R,os_name:i.os_name,os_version:i.os_version,device_model:i.device_model,ab_client:R,traffic_type:R,client_ip:R,device_brand:R,os_api:R,access:R,language:i.language,region:R,app_language:R,app_region:R,creative_id:i.utm.creative_id,ad_id:i.utm.ad_id,campaign_id:i.utm.campaign_id,log_type:R,rnd:R,platform:i.platform,sdk_version:k,sdk_lib:"js",province:R,city:R,timezone:M,tz_offset:x,tz_name:R,sim_region:R,carrier:R,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:R,wechat_openid:R}},this.ab_version="",this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(i),this.initDomain(),this.initABData(),this.setEnableClientTransport(!!this.initConfig.transport)}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(A[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(){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.setEnableClientTransport=function(t){this.enableClientTransport=t},e.prototype.getEnableClientTransport=function(){return this.enableClientTransport},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.1.0&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(r){void 0!==e[r]&&null!==e[r]||i.delete(r);try{i.eventCheck.calculate(r,"config")}catch(t){}if("traffic_type"===r&&i.isLast&&(i.envInfo.header.custom.$latest_traffic_source_type=e[r]),"evtParams"===r)i.evtParams=t({},i.evtParams||{},e.evtParams||{});else if("_staging_flag"===r)i.evtParams=t({},i.evtParams||{},{_staging_flag:e._staging_flag});else if("reportErrorCallback"===r&&"function"==typeof e[r])i.reportErrorCallback=e[r];else{var n="",o="";if(r.indexOf(".")>-1){var s=r.split(".");n=s[0],o=s[1]}n?"user"===n||"header"===n?i.envInfo[n][o]=e[r]:i.envInfo.header.custom[o]=e[r]:Object.hasOwnProperty.call(i.envInfo.user,r)?["user_type","ip_addr_id"].indexOf(r)>-1?i.envInfo.user[r]=e[r]?Number(e[r]):e[r]:["user_id","web_id","user_unique_id","user_unique_id_type","anonymous_id"].indexOf(r)>-1?i.envInfo.user[r]=e[r]?String(e[r]):e[r]:["user_is_auth","user_is_login"].indexOf(r)>-1?i.envInfo.user[r]=Boolean(e[r]):"device_id"===r&&(i.envInfo.user[r]=e[r]):Object.hasOwnProperty.call(i.envInfo.header,r)?i.envInfo.header[r]=e[r]:i.envInfo.header.custom[r]=e[r]}})},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.getItem=function(t){return this.initConfig&&1===this.initConfig.configPersist?this.storage.getSessionItem(t):this.storage.getLocalItem(t)},e.prototype.setItem=function(t,e){this.initConfig&&1===this.initConfig.configPersist?this.storage.setSessionItem(t,e):this.storage.setLocalItem(t,e)},e.prototype.setStore=function(t){try{if(!this.configPersist)return;var e=this.getItem(this.configKey)||{};if(e&&Object.keys(t).length){var i=Object.assign(t,e);this.setItem(this.configKey,i)}}catch(t){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.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.getItem(this.configKey)||{};e&&Object.hasOwnProperty.call(e,t)&&(delete e[t],this.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})}},e}(),F=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}(),q=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}(),P=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.storgae=new I,this.eventCheck=new B(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(C.Ready,function(){i.reportAll(!1)}),this.collect.on(C.ConfigDomain,function(){i.reportUrl=i.configManager.getUrl("event")}),this.collect.on(C.Event,function(t){i.event(t)}),this.collect.on(C.BeconEvent,function(t){i.beconEvent(t)}),this.collect.on(C.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 r=i(t,this.storgae.getCacheItem(this.eventKey)||[]);if(this.storgae.setCacheItem(this.eventKey,r),this.reportTimeout&&clearTimeout(this.reportTimeout),r.length>=this.maxReport)this.report(!1);else{var n=this.reportTime;this.reportTimeout=setTimeout(function(){e.report(!1),e.reportTimeout=null},n)}}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.storgae.getCacheItem(this.beconKey)||[]);this.storgae.setCacheItem(this.beconKey,e),this.collect.destroyInstance||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.storgae.removeCacheItem(this.beconKey),this.send(this.split(this.merge(e)),!0))},e.prototype.reportBecon=function(){var t=this.storgae.getCacheItem(this.beconKey)||[];t&&t.length&&(this.storgae.removeCacheItem(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.storgae.getCacheItem(this.eventKey)||[];e.length&&(this.storgae.removeCacheItem(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 r;r=t.slice(i,i+this.eventLimit);var n=this.split(this.merge(r));this.send(n,e)}else{n=this.split(this.merge(t));this.send(n,e)}},e.prototype.handleRefer=function(){var t="";try{if(this.config.spa||this.config.autotrack){var e=this.storgae.getLocalItem(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 r=this,n=this.configManager.get(),o=n.header,s=n.user;o.referrer=this.handleRefer(),o.custom=JSON.stringify(o.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)),r.collect.dynamicParamsFilter){var n=r.collect.dynamicParamsFilter();Object.keys(n).length&&(e.params=t({},e.params,n))}c&&(e.params.$user_unique_id_type=c);var o=r.configManager.getAbCache(),h=r.configManager.getAbVersion();return h&&o&&(r.config.disable_ab_reset||o.uuid===s.user_unique_id)&&(e.ab_sdk_version=h),e.session_id=r.collect.sessionManager.getSessionId(),e.params=JSON.stringify(e.params),e}catch(t){return r.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:o}));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 r=JSON.parse(JSON.stringify(t));i.config.filter&&((r=i.config.filter(r))||console.warn("filter must return data !!")),i.collect.eventFilter&&r&&((r=i.collect.eventFilter(r))||console.warn("filterEvent api must return data !!"));var n=r||t,o=JSON.parse(JSON.stringify(n));if(i.eventCheck.checkVerify(o),!n.length)return;i.collect.emit(C.SubmitBefore,n);var s=i.collect.cryptoData(n);i.collect.requestManager.useRequest({url:i.reportUrl,data:s,success:function(t,e,r,n,s){t&&0!==t.e?(i.collect.emit(C.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:n,endTime:Date.now(),status:s}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:o,code:t.e,failType:"数据异常失败",status:"fail"})):(i.collect.emit(C.SubmitSuccess,{eventData:e,res:t,response:t,startTime:n,endTime:Date.now(),status:s}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:o,code:200,status:"success"}))},fail:function(t,e,r,n){i.configManager.get("reportErrorCallback")(t,e),i.collect.emit(C.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:r,errorMessage:n,endTime:Date.now()}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报网络异常",time:Date.now(),data:o,code:e,failType:"网络异常失败",status:"fail"})},timeout:i.timeout,useBeacon:e,encryption:i.config.enable_encryption,encryption_header:i.config.encryption_header}),i.collect.emit(C.SubmitVerifyH,n),i.collect.emit(C.SubmitAfter,n)}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}(),U=function t(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t)},N=function(){return U().replace(/-/g,"").slice(0,19)},V=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)})},K=function(){function t(){}return t.prototype.apply=function(t,e){var i=this;this.collect=t,this.storage=new I,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(C.SessionReset,function(){i.resetSessionId()}),this.collect.on(C.SessionResetTime,function(){i.updateSessionIdTime()}))},t.prototype.updateSessionIdTime=function(){var t=this.storage.getSessionItem(this.sessionKey);if(t&&t.sessionId){var e=t.timestamp;Date.now()-e>this.expireTime?t={sessionId:V(),timestamp:Date.now()}:t.timestamp=Date.now(),this.storage.setSessionItem(this.sessionKey,t),this.resetExpTime()}},t.prototype.setSessionId=function(){var t=this,e=this.storage.getSessionItem(this.sessionKey);e&&e.sessionId?e.timestamp=Date.now():e={sessionId:V(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,e),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime)},t.prototype.getSessionId=function(){var t=this.storage.getSessionItem(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:V(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,t)},t.prototype.checkEXp=function(){var t=this.storage.getSessionItem(this.sessionKey);t&&t.sessionId&&(Date.now()-t.timestamp+30>=this.expireTime&&(t={sessionId:V(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,t)))},t}(),L=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 I,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(C.AnonymousId,function(t){i.setAnonymousId(t)}),this.collect.on(C.ConfigUuid,function(t){i.setUuid(t)}),this.collect.on(C.ConfigWebId,function(t){i.setWebId(t)}),this.timeout=e.timeout||3e5,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.getLocalItem(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(C.CustomWebId,function(){t.tokenReady=!0,t.collect.emit(C.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:N(),user_unique_id:this.configManager.get("user_unique_id")||N()}):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 r=this.collect.cryptoData(i);this.collect.requestManager.useRequest({url:e,data:r,success:function(e){var i;if(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});else{var r=t.getLocalId();i=r,t.collect.configManager.set({localWebId:r}),t.collect.emit(C.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})},fail:function(){var e=t.getLocalId();t.complete({web_id:t.configManager.get("web_id")||e,user_unique_id:t.configManager.get("user_unique_id")||e}),t.collect.configManager.set({localWebId:e}),t.collect.emit(C.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~")},timeout:this.timeout,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},t.prototype.getLocalId=function(){for(var t=N(),e=0;0===t.indexOf("0")||0===t.indexOf("9");){if(e>=10){t=t.replace(/^(0|9)/,"");break}t=N(),e++}return t},t.prototype.complete=function(t){var e=t.web_id,i=t.user_unique_id;if(!e&&!i)return this.collect.emit(C.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(C.TokenComplete)},t.prototype.completeAnonymous=function(t){var e=t.anonymous_id||V(),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(C.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(C.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"),r=this.cacheToken&&this.cacheToken.user_unique_id;if(e===i&&e===r)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(C.TokenChange,{type:"uuid",id:t}),this.collect.emit(C.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(C.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(C.TokenChange,{type:"uuid",id:t})),this.configManager.set({anonymous_id:t}),this.cacheToken.anonymous_id=t,this.collect.emit(C.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(C.TokenChange,{type:"uuid",id:t})),e!==t&&(this.configManager.set({web_id:t}),this.cacheToken.web_id=t,this.collect.emit(C.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.setLocalItem(this.tokenKey,t),this.cacheToken=t},t.prototype.getReady=function(){return this.tokenReady},t.prototype.getTobId=function(){var t=this;this.configManager.getUrl("tobid");var e={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?e.anonymous_id=this.configManager.get("anonymous_id"):e.web_id=this.configManager.get("web_id");var i=this.collect.cryptoData(e);return new Promise(function(e){t.collect.requestManager.useRequest({url:t.configManager.getUrl("tobid"),data:i,success:function(i){i&&0===i.e?(e(i.tobid),t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"GetToken请求成功",logType:"fetch",level:"info",time:Date.now(),data:i,infoType:"sdk"})):(e(""),t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),data:i,infoType:"sdk"}))},fail:function(){e(""),t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),infoType:"sdk"})},timeout:t.timeout,encryption:t.config.enable_encryption,encryption_header:t.config.encryption_header})})},t}(),z=function(){function t(t,e){var i=this;this.collector=t,this.config=e,this.requestType=e.request_type||"xhr",this.supportBeacon=!(!window.navigator||!window.navigator.sendBeacon),this.errorCode={NO_URL:4001,IMG_ON:4e3,IMG_CATCH:4002,BEACON_FALSE:4003,XHR_ERROR:5002,TIMEOUT:5005,FETCH_ERROR:5006},this.errorMessage={BEACON_FALSE:"xhr sendbeacon error",XHR_ERROR:"xhr request error",BEACON:"xhr sendbeacon error",TIMEOUT:"xhr request timeout",FETCH_ERROR:"fetch network error",FETCH_RESPONSE_ERROR:"fetch response error"},this.customHeader=e.custom_request_header||{},this.collector.on(C.CustomHeader,function(t){i.setRequestHeader(t)})}return t.prototype.setRequestHeader=function(t){this.customHeader=Object.assign(this.customHeader,t)},t.prototype.useFetch=function(t){var e=this,i=t.url,r=t.data,n=t.method,o=t.success,s=t.fail,a=t.status,c=t.timeout,h=t.useBeacon,u=t.encryption,f=t.encryption_header;if(window.fetch&&"undefined"!=typeof Request){var p={method:n||"POST"};if(h){if(!("keepalive"in Request.prototype))return void this.useSendBeacon(t);var l=this.collector.configManager.get("browser"),g=this.collector.configManager.get("browser_version");if(g=g.split("."),"Chrome"===l&&g.length&&g[0]&&Number(g[0])<82)return void this.useSendBeacon(t);p.keepalive=!0}var d=JSON.stringify(r),m={"Content-Type":"application/json; charset=utf-8"};u&&f&&(m["Content-Type"]="application/octet-stream;tt-data="+f),p.body=d,p.headers=m;var y=null;y="undefined"!=typeof AbortController?new AbortController:{signal:null,abort:function(){}};var _=setTimeout(function(){y.abort()},c);if(Object.keys(this.customHeader).length)for(var b in this.customHeader)m[b]=this.customHeader[b];p.signal=y.signal;var E=Date.now();try{fetch(i,p).then(function(t){return t.ok||s&&s(r,t.status,E,t.statusText||e.errorMessage.FETCH_RESPONSE_ERROR),t.json()}).then(function(t){clearTimeout(_),o&&o(t,r,a,E,200)}).catch(function(t){clearTimeout(_),s&&s(r,e.errorCode.FETCH_ERROR,E,t.message||e.errorMessage.FETCH_ERROR)})}catch(e){this.useXhr(t),this.collector.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK useFetch 发送请求发生了一些问题",level:"error",time:Date.now(),data:e.message||"SDK useFetch has some errors",infoType:"sdk"})}}else h?this.useSendBeacon(t):this.useXhr(t),console.log("your browser not support fetch, use normal request")},t.prototype.useSendBeacon=function(t){if(this.supportBeacon){var e=t.url,i=t.data,r=t.status,n=t.success,o=t.fail,s=Date.now();window.navigator.sendBeacon(e,JSON.stringify(i))?n&&n({e:0},i,r,s,200):o&&o(i,this.errorCode.BEACON_FALSE,s,this.errorMessage.BEACON_FALSE)}else this.useXhr(t)},t.prototype.useXhr=function(t){var e=this,i=t.url,r=t.data,n=t.method,o=t.success,s=t.fail,a=t.timeout,c=t.withCredentials,h=t.encryption,u=t.encryption_header,f=t.status;try{var p=new XMLHttpRequest;p.open(n||"POST",i,!0);var l=Date.now();if(p.setRequestHeader("Content-Type","application/json; charset=utf-8"),h&&u?p.setRequestHeader("Content-Type","application/octet-stream;tt-data="+u):p.setRequestHeader("Content-Type","application/json; charset=utf-8"),Object.keys(this.customHeader).length)for(var g in this.customHeader)p.setRequestHeader(g,this.customHeader[g]);c&&(p.withCredentials=!0),a&&(p.timeout=a,p.ontimeout=function(){s&&s(r,e.errorCode.TIMEOUT,l,e.errorMessage.TIMEOUT)}),p.onload=function(){if(o){var t=null;if(p.responseText){try{t=JSON.parse(p.responseText)}catch(e){t={}}o(t,r,f,l,p.status)}else s&&s(r,e.errorCode.XHR_ERROR,l,e.errorMessage.XHR_ERROR)}},p.onerror=function(){s&&s(r,e.errorCode.XHR_ERROR,l,e.errorMessage.XHR_ERROR),p.abort()},p.send(JSON.stringify(r))}catch(t){this.collector.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK useXhr 发送请求发生了一些问题",level:"error",time:Date.now(),data:t.message,infoType:"sdk"})}},t.prototype.useRequest=function(t){var e=t.useBeacon;this.config.transport&&this.collector.configManager.getEnableClientTransport()?this.useCustomRequest(t):"fetch"!==this.requestType?e?this.useSendBeacon(t):this.useXhr(t):this.useFetch(t)},t.prototype.useCustomRequest=function(t){var e=this.config.transport,i=t.url,r=t.data,n=t.success,o=t.fail;if(e)try{e.post({url:i,data:JSON.stringify(r),success:function(t){n&&n(t,r)},fail:function(t){o&&o(t,r)}})}catch(e){this.collector.configManager.setEnableClientTransport(!1),this.useRequest(t)}},t}(),H=g(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 r(){return new i(null)}var n="undefined"!=typeof navigator;n&&"Microsoft Internet Explorer"==navigator.appName?(i.prototype.am=function(t,e,i,r,n,o){for(var s=32767&e,a=e>>15;--o>=0;){var c=32767&this[t],h=this[t++]>>15,u=a*c+h*s;n=((c=s*c+((32767&u)<<15)+i[r]+(1073741823&n))>>>30)+(u>>>15)+a*h+(n>>>30),i[r++]=1073741823&c}return n},e=30):n&&"Netscape"!=navigator.appName?(i.prototype.am=function(t,e,i,r,n,o){for(;--o>=0;){var s=e*this[t++]+i[r]+n;n=Math.floor(s/67108864),i[r++]=67108863&s}return n},e=26):(i.prototype.am=function(t,e,i,r,n,o){for(var s=16383&e,a=e>>14;--o>=0;){var c=16383&this[t],h=this[t++]>>14,u=a*c+h*s;n=((c=s*c+((16383&u)<<14)+i[r]+n)>>28)+(u>>14)+a*h,i[r++]=268435455&c}return n},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 o,s,a=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)a[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)a[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)a[o++]=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=r();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 p(t){this.m=t}function l(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 g(t,e){return t&e}function d(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 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),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 S(t){this.r2=r(),this.q3=r(),i.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}p.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},p.prototype.revert=function(t){return t},p.prototype.reduce=function(t){t.divRemTo(this.m,null,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)},l.prototype.convert=function(t){var e=r();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},l.prototype.revert=function(t){var e=r();return t.copyTo(e),this.reduce(e),e},l.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],r=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,r,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)},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)},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 r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,o=!1,s=0;--n>=0;){var a=8==r?255&t[n]:h(t,n);a<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+r>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+=r)>=this.DB&&(s-=this.DB))}8==r&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&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,r=t%this.DB,n=this.DB-r,o=(1<<n)-1,s=Math.floor(t/this.DB),a=this.s<<r&this.DM;for(i=this.t-1;i>=0;--i)e[i+s+1]=this[i]>>n|a,a=(this[i]&o)<<r;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 r=t%this.DB,n=this.DB-r,o=(1<<r)-1;e[0]=this[i]>>r;for(var s=i+1;s<this.t;++s)e[s-i-1]|=(this[s]&o)<<n,e[s-i]=this[s]>>r;r>0&&(e[this.t-i-1]|=(this.s&o)<<n),e.t=this.t-i,e.clamp()}},i.prototype.subTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()},i.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),o=r.t;for(e.t=o+n.t;--o>=0;)e[o]=0;for(o=0;o<n.t;++o)e[o+r.t]=r.am(0,n[o],e,o,0,r.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 r=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,r,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,n){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t<o.t)return null!=e&&e.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=r());var a=r(),c=this.s,h=t.s,u=this.DB-f(o[o.t-1]);u>0?(o.lShiftTo(u,a),s.lShiftTo(u,n)):(o.copyTo(a),s.copyTo(n));var p=a.t,l=a[p-1];if(0!=l){var g=l*(1<<this.F1)+(p>1?a[p-2]>>this.F2:0),d=this.FV/g,m=(1<<this.F1)/g,y=1<<this.F2,v=n.t,_=v-p,b=null==e?r():e;for(a.dlShiftTo(_,b),n.compareTo(b)>=0&&(n[n.t++]=1,n.subTo(b,n)),i.ONE.dlShiftTo(p,b),b.subTo(a,a);a.t<p;)a[a.t++]=0;for(;--_>=0;){var E=n[--v]==l?this.DM:Math.floor(n[v]*d+(n[v-1]+y)*m);if((n[v]+=a.am(0,E,n,_,0,p))<E)for(a.dlShiftTo(_,b),n.subTo(b,n);n[v]<--E;)n.subTo(b,n)}null!=e&&(n.drShiftTo(p,e),c!=h&&i.ZERO.subTo(e,e)),n.t=p,n.clamp(),u>0&&n.rShiftTo(u,n),c<0&&i.ZERO.subTo(n,n)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(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 n=r(),o=r(),s=e.convert(this),a=f(t)-1;for(s.copyTo(n);--a>=0;)if(e.sqrTo(n,o),(t&1<<a)>0)e.mulTo(o,s,n);else{var c=n;n=o,o=c}return e.revert(n)},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,r=(1<<e)-1,n=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(i=this[s]>>a)>0&&(n=!0,o=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)&r,a<=0&&(a+=this.DB,--s)),i>0&&(n=!0),n&&(o+=c(i));return n?o:"0"},i.prototype.negate=function(){var t=r();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=r();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 p(e):new l(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)},S.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=r();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.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)},S.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var w,T,D,I=[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)/I[I.length-1];function k(){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>=G&&(D-=G)}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),n=u(i),o=r(),s=r(),a="";for(this.divRemTo(n,o,s);o.signum()>0;)a=(i+s.intValue()).toString(t).substr(1)+a,o.divRemTo(n,o,s);return s.intValue().toString(t)+a},i.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),o=!1,s=0,a=0,c=0;c<t.length;++c){var u=h(t,c);u<0?"-"==t.charAt(c)&&0==this.signum()&&(o=!0):(a=e*a+u,++s>=r&&(this.dMultiply(n),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),o&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),d,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 n=new Array,o=7&t;n.length=1+(t>>3),e.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}},i.prototype.bitwiseTo=function(t,e,i){var r,n,o=Math.min(t.t,this.t);for(r=0;r<o;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(n=t.s&this.DM,r=o;r<this.t;++r)i[r]=e(this[r],n);i.t=this.t}else{for(n=this.s&this.DM,r=o;r<t.t;++r)i[r]=e(n,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},i.prototype.changeBit=function(t,e){var r=i.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},i.prototype.addTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[i++]=r:r<-1&&(e[i++]=this.DV+r),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 r,n=Math.min(this.t+t.t,e);for(i.s=0,i.t=n;n>0;)i[--n]=0;for(r=i.t-this.t;n<r;++n)i[n+this.t]=this.am(0,t[n],i,n,0,this.t);for(r=Math.min(t.t,e);n<r;++n)this.am(0,t[n],i,n,0,e-n);i.clamp()},i.prototype.multiplyUpperTo=function(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-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 r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i},i.prototype.millerRabin=function(t){var e=this.subtract(i.ONE),n=e.getLowestSetBit();if(n<=0)return!1;var o=e.shiftRight(n);(t=t+1>>1)>I.length&&(t=I.length);for(var s=r(),a=0;a<t;++a){s.fromInt(I[Math.floor(Math.random()*I.length)]);var c=s.modPow(o,this);if(0!=c.compareTo(i.ONE)&&0!=c.compareTo(e)){for(var h=1;h++<n&&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=r();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,r=this.DB-t*this.DB%8,n=0;if(t-- >0)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<<this.DB-r);t>=0;)r<8?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),128&i&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(n>0||i!=this.s)&&(e[n++]=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=r();return this.bitwiseTo(t,g,e),e},i.prototype.or=function(t){var e=r();return this.bitwiseTo(t,d,e),e},i.prototype.xor=function(t){var e=r();return this.bitwiseTo(t,m,e),e},i.prototype.andNot=function(t){var e=r();return this.bitwiseTo(t,y,e),e},i.prototype.not=function(){for(var t=r(),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=r();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},i.prototype.shiftRight=function(t){var e=r();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:!!(this[e]&1<<t%this.DB)},i.prototype.setBit=function(t){return this.changeBit(t,d)},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=r();return this.addTo(t,e),e},i.prototype.subtract=function(t){var e=r();return this.subTo(t,e),e},i.prototype.multiply=function(t){var e=r();return this.multiplyTo(t,e),e},i.prototype.divide=function(t){var e=r();return this.divRemTo(t,e,null),e},i.prototype.remainder=function(t){var e=r();return this.divRemTo(t,null,e),e},i.prototype.divideAndRemainder=function(t){var e=r(),i=r();return this.divRemTo(t,e,i),new Array(e,i)},i.prototype.modPow=function(t,e){var i,n,o=t.bitLength(),s=u(1);if(o<=0)return s;i=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new p(e):e.isEven()?new S(e):new l(e);var a=new Array,c=3,h=i-1,g=(1<<i)-1;if(a[1]=n.convert(this),i>1){var d=r();for(n.sqrTo(a[1],d);c<=g;)a[c]=r(),n.mulTo(d,a[c-2],a[c]),c+=2}var m,y,v=t.t-1,_=!0,b=r();for(o=f(t[v])-1;v>=0;){for(o>=h?m=t[v]>>o-h&g:(m=(t[v]&(1<<o+1)-1)<<h-o,v>0&&(m|=t[v-1]>>this.DB+o-h)),c=i;!(1&m);)m>>=1,--c;if((o-=c)<0&&(o+=this.DB,--v),_)a[m].copyTo(s),_=!1;else{for(;c>1;)n.sqrTo(s,b),n.sqrTo(b,s),c-=2;c>0?n.sqrTo(s,b):(y=s,s=b,b=y),n.mulTo(b,a[m],s)}for(;v>=0&&!(t[v]&1<<o);)n.sqrTo(s,b),y=s,s=b,b=y,--o<0&&(o=this.DB-1,--v)}return n.revert(s)},i.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return i.ZERO;for(var r=t.clone(),n=this.clone(),o=u(1),s=u(0),a=u(0),c=u(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(t,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),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);r.compareTo(n)>=0?(r.subTo(n,r),e&&o.subTo(a,o),s.subTo(c,s)):(n.subTo(r,n),e&&a.subTo(o,a),c.subTo(s,c))}return 0!=n.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 r=e;e=i,i=r}var n=e.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)return e;for(n<o&&(o=n),o>0&&(e.rShiftTo(o,e),i.rShiftTo(o,i));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return o>0&&i.lShiftTo(o,i),i},i.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=I[I.length-1]){for(e=0;e<I.length;++e)if(i[0]==I[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<I.length;){for(var r=I[e],n=e+1;n<I.length&&r<A;)r*=I[n++];for(r=i.modInt(r);e<n;)if(r%I[e++]==0)return!1}return i.millerRabin(t)},i.prototype.square=function(){var t=r();return this.squareTo(t),t},i.prototype.Barrett=S,null==T){var B;if(T=new Array,D=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var C=new Uint8Array(32);for(window.crypto.getRandomValues(C),B=0;B<32;++B)T[D++]=C[B]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var R=window.crypto.random(32);for(B=0;B<R.length;++B)T[D++]=255&R.charCodeAt(B)}for(;D<G;)B=Math.floor(65536*Math.random()),T[D++]=B>>>8,T[D++]=255&B;D=0,k()}function O(){if(null==w){for(k(),(w=new x).init(T),D=0;D<T.length;++D)T[D]=0;D=0}return w.next()}function M(){}function x(){this.i=0,this.j=0,this.S=new Array}M.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=O()},x.prototype.init=function(t){var e,i,r;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,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0},x.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 G=256;t.exports={default:i,BigInteger:i,SecureRandom:M}}).call(l)});H.BigInteger,H.SecureRandom;const{BigInteger:j}=H;class J{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 W extends J{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 r="";for(let t=0;t<i;t++)r+="f";r=new j(r,16),e=r.xor(t).add(j.ONE),e=e.toString(16).replace(/^-/,"")}return e}(t))}getValue(){return this.v}}class X extends J{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map(t=>t.getEncodedHex()).join(""),this.v}}function $(t,e){return+t[e+2]<8?1:128&+t.substr(e+2,2)}function Z(t,e){const i=$(t,e),r=t.substr(e+2,2*i);if(!r)return-1;return(+r[0]<8?new j(r,16):new j(r.substr(2),16)).intValue()}function Q(t,e){return e+2*($(t,e)+1)}var Y={encodeDer(t,e){const i=new W(t),r=new W(e);return new X([i,r]).getEncodedHex()},decodeDer(t){const e=Q(t,0),i=Q(t,e),r=Z(t,e),n=t.substr(i,2*r),o=i+n.length,s=Q(t,o),a=Z(t,o),c=t.substr(s,2*a);return{r:new j(n,16),s:new j(c,16)}}};const{BigInteger:tt}=H,et=new tt("2"),it=new tt("3");class rt{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 rt(this.q,this.x.negate().mod(this.q))}add(t){return new rt(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new rt(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new rt(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new rt(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new rt(this.q,this.x.square().mod(this.q))}}class nt{constructor(t,e,i,r){this.curve=t,this.x=e,this.y=i,this.z=null==r?tt.ONE:r,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(tt.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(tt.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(tt.ZERO)&&!this.y.toBigInteger().equals(tt.ZERO)}negate(){return new nt(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(),r=this.z,n=t.x.toBigInteger(),o=t.y.toBigInteger(),s=t.z,a=this.curve.q,c=e.multiply(s).mod(a),h=n.multiply(r).mod(a),u=c.subtract(h),f=i.multiply(s).mod(a),p=o.multiply(r).mod(a),l=f.subtract(p);if(tt.ZERO.equals(u))return tt.ZERO.equals(l)?this.twice():this.curve.infinity;const g=c.add(h),d=r.multiply(s).mod(a),m=u.square().mod(a),y=u.multiply(m).mod(a),v=d.multiply(l.square()).subtract(g.multiply(m)).mod(a),_=u.multiply(v).mod(a),b=l.multiply(m.multiply(c).subtract(v)).subtract(f.multiply(y)).mod(a),E=y.multiply(d).mod(a);return new nt(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,r=this.curve.q,n=this.curve.a.toBigInteger(),o=t.square().multiply(it).add(n.multiply(i.square())).mod(r),s=e.shiftLeft(1).multiply(i).mod(r),a=e.square().mod(r),c=a.multiply(t).multiply(i).mod(r),h=s.square().mod(r),u=o.square().subtract(c.shiftLeft(3)).mod(r),f=s.multiply(u).mod(r),p=o.multiply(c.shiftLeft(2).subtract(u)).subtract(h.shiftLeft(1).multiply(a)).mod(r),l=s.multiply(h).mod(r);return new nt(this.curve,this.curve.fromBigInteger(f),this.curve.fromBigInteger(p),l)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const e=t.multiply(it),i=this.negate();let r=this;for(let n=e.bitLength()-2;n>0;n--){r=r.twice();const o=e.testBit(n);o!==t.testBit(n)&&(r=r.add(o?this:i))}return r}}var ot={ECPointFp:nt,ECCurveFp:class{constructor(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new nt(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 rt(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 tt(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 tt("4")).add(tt.ONE),this.q));return i.toBigInteger().mod(et).equals(new tt(t.substr(0,2),16).subtract(et))||(i=i.negate()),new nt(this,e,i);case 4:case 6:case 7:const r=(t.length-2)/2,n=t.substr(2,r),o=t.substr(r+2,r);return new nt(this,this.fromBigInteger(new tt(n,16)),this.fromBigInteger(new tt(o,16)));default:return null}}}};const{BigInteger:st,SecureRandom:at}=H,{ECCurveFp:ct}=ot,ht=new at,{curve:ut,G:ft,n:pt}=lt();function lt(){const t=new st("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),e=new st("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),i=new st("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),r=new ct(t,e,i),n=r.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:r,G:n,n:new st("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function gt(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}var dt={getGlobalCurve:function(){return ut},generateEcparam:lt,generateKeyPairHex:function(t,e,i){const r=(t?new st(t,e,i):new st(pt.bitLength(),ht)).mod(pt.subtract(st.ONE)).add(st.ONE),n=gt(r.toString(16),64),o=ft.multiply(r);return{privateKey:n,publicKey:"04"+gt(o.getX().toBigInteger().toString(16),64)+gt(o.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 r="03";return new st(t.substr(e+2,e),16).mod(new st("2")).equals(st.ZERO)&&(r="02"),r+i},utf8ToHex:function(t){const e=(t=unescape(encodeURIComponent(t))).length,i=[];for(let r=0;r<e;r++)i[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;const r=[];for(let t=0;t<e;t++){const e=i[t>>>2]>>>24-t%4*8&255;r.push((e>>>4).toString(16)),r.push((15&e).toString(16))}return r.join("")},leftPad:gt,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 r=0;r<2*t.length;r+=2)e[r>>>3]|=parseInt(t[i],10)<<24-r%8*4,i++;try{const i=[];for(let r=0;r<t.length;r++){const t=e[r>>>2]>>>24-r%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=gt(t,i+1)),i=t.length;for(let r=0;r<i;r+=2)e.push(parseInt(t.substr(r,2),16));return e},verifyPublicKey:function(t){const e=ut.decodePointHex(t);if(!e)return!1;const i=e.getX();return e.getY().square().equals(i.multiply(i.square()).add(i.multiply(ut.a)).add(ut.b))},comparePublicKeyHex:function(t,e){const i=ut.decodePointHex(t);if(!i)return!1;const r=ut.decodePointHex(e);return!!r&&i.equals(r)}};const mt=new Uint32Array(68),yt=new Uint32Array(64);function vt(t,e){const i=31&e;return t<<i|t>>>32-i}function _t(t,e){const i=[];for(let r=t.length-1;r>=0;r--)i[r]=255&(t[r]^e[r]);return i}function bt(t){return t^vt(t,9)^vt(t,17)}function Et(t){return t^vt(t,15)^vt(t,23)}function St(t){let e=8*t.length,i=e%512;i=i>=448?512-i%448-1:448-i-1;const r=new Array((i-7)/8),n=new Array(8);for(let t=0,e=r.length;t<e;t++)r[t]=0;for(let t=0,e=n.length;t<e;t++)n[t]=0;e=e.toString(2);for(let t=7;t>=0;t--)if(e.length>8){const i=e.length-8;n[t]=parseInt(e.substr(i),2),e=e.substr(0,i)}else e.length>0&&(n[t]=parseInt(e,2),e="");const o=new Uint8Array([...t,128,...r,...n]),s=new DataView(o.buffer,0),a=o.length/64,c=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<a;t++){mt.fill(0),yt.fill(0);const e=16*t;for(let t=0;t<16;t++)mt[t]=s.getUint32(4*(e+t),!1);for(let t=16;t<68;t++)mt[t]=Et(mt[t-16]^mt[t-9]^vt(mt[t-3],15))^vt(mt[t-13],7)^mt[t-6];for(let t=0;t<64;t++)yt[t]=mt[t]^mt[t+4];const i=2043430169,r=2055708042;let n,o,a,h,u,f=c[0],p=c[1],l=c[2],g=c[3],d=c[4],m=c[5],y=c[6],v=c[7];for(let t=0;t<64;t++)u=t>=0&&t<=15?i:r,n=vt(vt(f,12)+d+vt(u,t),7),o=n^vt(f,12),a=(t>=0&&t<=15?f^p^l:f&p|f&l|p&l)+g+o+yt[t],h=(t>=0&&t<=15?d^m^y:d&m|~d&y)+v+n+mt[t],g=l,l=vt(p,9),p=f,f=a,v=y,y=vt(m,19),m=d,d=bt(h);c[0]^=f,c[1]^=p,c[2]^=l,c[3]^=g,c[4]^=d,c[5]^=m,c[6]^=y,c[7]^=v}const h=[];for(let t=0,e=c.length;t<e;t++){const e=c[t];h.push((4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e)}return h}const wt=new Uint8Array(64),Tt=new Uint8Array(64);for(let t=0;t<64;t++)wt[t]=54,Tt[t]=92;var Dt={sm3:St,hmac:function(t,e){for(e.length>64&&(e=St(e));e.length<64;)e.push(0);const i=_t(e,wt),r=_t(e,Tt),n=St([...i,...t]);return St([...r,...n])}};const{BigInteger:It}=H,{encodeDer:At,decodeDer:kt}=Y,Bt=Dt.sm3,{G:Ct,curve:Rt,n:Ot}=dt.generateEcparam();function Mt(t,e,i="1234567812345678"){i=dt.utf8ToHex(i);const r=dt.leftPad(Ct.curve.a.toBigInteger().toRadix(16),64),n=dt.leftPad(Ct.curve.b.toBigInteger().toRadix(16),64),o=dt.leftPad(Ct.getX().toBigInteger().toRadix(16),64),s=dt.leftPad(Ct.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=Ct.curve.decodePointHex(e);a=dt.leftPad(t.getX().toBigInteger().toRadix(16),64),c=dt.leftPad(t.getY().toBigInteger().toRadix(16),64)}const h=dt.hexToArray(i+r+n+o+s+a+c),u=4*i.length;h.unshift(255&u),h.unshift(u>>8&255);const f=Bt(h);return dt.arrayToHex(Bt(f.concat(dt.hexToArray(t))))}function xt(){const t=dt.generateKeyPairHex(),e=Rt.decodePointHex(t.publicKey);return t.k=new It(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}var Gt={generateKeyPairHex:dt.generateKeyPairHex,compressPublicKeyHex:dt.compressPublicKeyHex,comparePublicKeyHex:dt.comparePublicKeyHex,doEncrypt:function(t,e,i=1){t="string"==typeof t?dt.hexToArray(dt.utf8ToHex(t)):Array.prototype.slice.call(t),e=dt.getGlobalCurve().decodePointHex(e);const r=dt.generateKeyPairHex(),n=new It(r.privateKey,16);let o=r.publicKey;o.length>128&&(o=o.substr(o.length-128));const s=e.multiply(n),a=dt.hexToArray(dt.leftPad(s.getX().toBigInteger().toRadix(16),64)),c=dt.hexToArray(dt.leftPad(s.getY().toBigInteger().toRadix(16),64)),h=dt.arrayToHex(Bt([].concat(a,t,c)));let u=1,f=0,p=[];const l=[].concat(a,c),g=()=>{p=Bt([...l,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,f=0};g();for(let e=0,i=t.length;e<i;e++)f===p.length&&g(),t[e]^=255&p[f++];const d=dt.arrayToHex(t);return 0===i?o+d+h:o+h+d},doDecrypt:function(t,e,i=1,{output:r="string"}={}){e=new It(e,16);let n=t.substr(128,64),o=t.substr(192);0===i&&(n=t.substr(t.length-64),o=t.substr(128,t.length-128-64));const s=dt.hexToArray(o),a=dt.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=dt.hexToArray(dt.leftPad(a.getX().toBigInteger().toRadix(16),64)),h=dt.hexToArray(dt.leftPad(a.getY().toBigInteger().toRadix(16),64));let u=1,f=0,p=[];const l=[].concat(c,h),g=()=>{p=Bt([...l,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,f=0};g();for(let t=0,e=s.length;t<e;t++)f===p.length&&g(),s[t]^=255&p[f++];return dt.arrayToHex(Bt([].concat(c,s,h)))===n.toLowerCase()?"array"===r?s:dt.arrayToUtf8(s):"array"===r?[]:""},doSignature:function(t,e,{pointPool:i,der:r,hash:n,publicKey:o,userId:s}={}){let a="string"==typeof t?dt.utf8ToHex(t):dt.arrayToHex(t);n&&(o=o||function(t){const e=Ct.multiply(new It(t,16)),i=dt.leftPad(e.getX().toBigInteger().toString(16),64),r=dt.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+i+r}(e),a=Mt(a,o,s));const c=new It(e,16),h=new It(a,16);let u=null,f=null,p=null;do{do{let t;t=i&&i.length?i.pop():xt(),u=t.k,f=h.add(t.x1).mod(Ot)}while(f.equals(It.ZERO)||f.add(u).equals(Ot));p=c.add(It.ONE).modInverse(Ot).multiply(u.subtract(f.multiply(c))).mod(Ot)}while(p.equals(It.ZERO));return r?At(f,p):dt.leftPad(f.toString(16),64)+dt.leftPad(p.toString(16),64)},doVerifySignature:function(t,e,i,{der:r,hash:n,userId:o}={}){let s,a,c="string"==typeof t?dt.utf8ToHex(t):dt.arrayToHex(t);if(n&&(c=Mt(c,i,o)),r){const t=kt(e);s=t.r,a=t.s}else s=new It(e.substring(0,64),16),a=new It(e.substring(64),16);const h=Rt.decodePointHex(i),u=new It(c,16),f=s.add(a).mod(Ot);if(f.equals(It.ZERO))return!1;const p=Ct.multiply(a).add(h.multiply(f)),l=u.add(p.getX().toBigInteger()).mod(Ot);return s.equals(l)},getPoint:xt,verifyPublicKey:dt.verifyPublicKey};const{sm3:Ft,hmac:qt}=Dt;function Pt(t){return t.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join("")}function Ut(t){const e=[];let i=t.length;var r,n;i%2!=0&&(n=i+1,t=(r=t).length>=n?r:new Array(n-r.length+1).join("0")+r),i=t.length;for(let r=0;r<i;r+=2)e.push(parseInt(t.substr(r,2),16));return e}const Nt=16,Vt=[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],Kt=[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 Lt(t){const e=[];for(let i=0,r=t.length;i<r;i+=2)e.push(parseInt(t.substr(i,2),16));return e}function zt(t,e){return t<<e|t>>>32-e}function Ht(t){return(255&Vt[t>>>24&255])<<24|(255&Vt[t>>>16&255])<<16|(255&Vt[t>>>8&255])<<8|255&Vt[255&t]}function jt(t){return t^zt(t,2)^zt(t,10)^zt(t,18)^zt(t,24)}function Jt(t){return t^zt(t,13)^zt(t,23)}function Wt(t,e,i){const r=new Array(4),n=new Array(4);for(let e=0;e<4;e++)n[0]=255&t[4*e],n[1]=255&t[4*e+1],n[2]=255&t[4*e+2],n[3]=255&t[4*e+3],r[e]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];for(let t,e=0;e<32;e+=4)t=r[1]^r[2]^r[3]^i[e+0],r[0]^=jt(Ht(t)),t=r[2]^r[3]^r[0]^i[e+1],r[1]^=jt(Ht(t)),t=r[3]^r[0]^r[1]^i[e+2],r[2]^=jt(Ht(t)),t=r[0]^r[1]^r[2]^i[e+3],r[3]^=jt(Ht(t));for(let t=0;t<16;t+=4)e[t]=r[3-t/4]>>>24&255,e[t+1]=r[3-t/4]>>>16&255,e[t+2]=r[3-t/4]>>>8&255,e[t+3]=255&r[3-t/4]}function Xt(t,e,i,{padding:r="pkcs#7",mode:n,iv:o=[],output:s="string"}={}){if("cbc"===n&&("string"==typeof o&&(o=Lt(o)),16!==o.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=Lt(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,r=t.length;i<r;i++){const r=t.codePointAt(i);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>>6),e.push(128|63&r);else if(r<=55295||r>=57344&&r<=65535)e.push(224|r>>>12),e.push(128|r>>>6&63),e.push(128|63&r);else{if(!(r>=65536&&r<=1114111))throw e.push(r),new Error("input is not supported");i++,e.push(240|r>>>18&28),e.push(128|r>>>12&63),e.push(128|r>>>6&63),e.push(128|63&r)}}return e}(t):Lt(t):[...t],("pkcs#5"===r||"pkcs#7"===r)&&0!==i){const e=Nt-t.length%Nt;for(let i=0;i<e;i++)t.push(e)}const a=new Array(32);!function(t,e,i){const r=new Array(4),n=new Array(4);for(let e=0;e<4;e++)n[0]=255&t[0+4*e],n[1]=255&t[1+4*e],n[2]=255&t[2+4*e],n[3]=255&t[3+4*e],r[e]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];r[0]^=2746333894,r[1]^=1453994832,r[2]^=1736282519,r[3]^=2993693404;for(let t,i=0;i<32;i+=4)t=r[1]^r[2]^r[3]^Kt[i+0],e[i+0]=r[0]^=Jt(Ht(t)),t=r[2]^r[3]^r[0]^Kt[i+1],e[i+1]=r[1]^=Jt(Ht(t)),t=r[3]^r[0]^r[1]^Kt[i+2],e[i+2]=r[2]^=Jt(Ht(t)),t=r[0]^r[1]^r[2]^Kt[i+3],e[i+3]=r[3]^=Jt(Ht(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=o,u=t.length,f=0;for(;u>=Nt;){const e=t.slice(f,f+16),r=new Array(16);if("cbc"===n)for(let t=0;t<Nt;t++)0!==i&&(e[t]^=h[t]);Wt(e,r,a);for(let t=0;t<Nt;t++)"cbc"===n&&0===i&&(r[t]^=h[t]),c[f+t]=r[t];"cbc"===n&&(h=0!==i?r:e),u-=Nt,f+=Nt}if(("pkcs#5"===r||"pkcs#7"===r)&&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,r=t.length;i<r;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 $t={sm2:Gt,sm3:function(t,e){if(t="string"==typeof t?function(t){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t.codePointAt(i);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>>6),e.push(128|63&r);else if(r<=55295||r>=57344&&r<=65535)e.push(224|r>>>12),e.push(128|r>>>6&63),e.push(128|63&r);else{if(!(r>=65536&&r<=1114111))throw e.push(r),new Error("input is not supported");i++,e.push(240|r>>>18&28),e.push(128|r>>>12&63),e.push(128|r>>>6&63),e.push(128|63&r)}}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?Ut(i):Array.prototype.slice.call(i),Pt(qt(t,i))}return Pt(Ft(t))},sm4:{encrypt:(t,e,i)=>Xt(t,e,1,i),decrypt:(t,e,i)=>Xt(t,e,0,i)}}.sm2;var Zt=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 n,this.logger=new F(t),this.remotePlugin=new Map,this.Types=C}return e.usePlugin=function(t,i,r){if(i){for(var n=!1,o=0,s=e.plugins.length;o<s;o++){if(e.plugins[o].name===i){e.plugins[o].plugin=t,e.plugins[o].options=r||{},n=!0;break}}n||e.plugins.push({name:i,plugin:t,options:r})}else e.plugins.push({plugin:t})},e.prototype.init=function(t){var i,r=this;this.inited?console.log("init can be call only one time"):t&&o(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 F(this.name,t.log),this.configManager=new G(this,t),this.appBridge=new q(t,this.configManager),this.bridgeReport=this.appBridge.bridgeInject(),this.requestManager=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?(this.inited=!0,this.emit(C.Init)):(t.enable_encryption&&"sm"===t.encryption_type&&this.initCrypto(),this.configManager.set({app_id:t.app_id}),this.eventManager=new P,this.tokenManager=new L,this.sessionManager=new K,Promise.all([new Promise(function(t){r.once(C.TokenComplete,function(){t(!0)})}),new Promise(function(t){r.once(C.Start,function(){t(!0)})})]).then(function(){try{e.plugins.reduce(function(t,e){var i=e.plugin,n=e.options,o=Object.assign(r.initConfig,n),s=new i;return s.apply(r,o),t.push(s),t},r.pluginInstances)}catch(t){console.log("load plugin error, "+t.message),r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}r.sdkReady=!0,r.emit(C.Ready),r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:r.configManager.get("user")}),r.logger.info("appid: "+t.app_id+", userInfo:"+JSON.stringify(r.configManager.get("user"))),r.logger.info("appid: "+t.app_id+", sdk is ready, version is "+k+", you can report now !!!");try{(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(t){r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}r.pageView(),r.on(C.TokenChange,function(e){"webid"!==e.type&&"anonymous_id"!==e.type||r.pageView(),r.logger.info("appid: "+t.app_id+" token change, new userInfo:"+JSON.stringify(r.configManager.get("user"))),r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:r.configManager.get("user")})}),r.on(C.TokenReset,function(){r.logger.info("appid: "+t.app_id+" token reset, new userInfo:"+JSON.stringify(r.configManager.get("user"))),r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:r.configManager.get("user")})}),r.on(C.RouteChange,function(e){e.init||t.disable_route_report||r.pageView()})}),this.tokenManager.apply(this,t),this.eventManager.apply(this,t),this.sessionManager.apply(this,t),this.inited=!0,this.emit(C.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&&o(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 r=this.configManager.getStore();r&&(i=Object.assign(r,e)),this.configManager.setStore(e)}i.web_id,i.user_unique_id;var n=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]])}return i}(i,["web_id","user_unique_id"]);i.hasOwnProperty("web_id")&&this.emit(C.ConfigWebId,i.web_id),i.hasOwnProperty("user_unique_id")&&this.emit(C.ConfigUuid,i.user_unique_id),this.configManager.set(n),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(C.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(C.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(C.Ready)))},e.prototype.event=function(t,e){var i=this;try{if(this.initConfig&&this.initConfig.disable_track_event)return;var r=[];if(Array.isArray(t))t.forEach(function(t){var e=i.processEvent(t[0],t[1]||{});e&&r.push(e)});else{var n=this.processEvent(t,e);if(!n)return;r.push(n)}this.bridgeReport?r.forEach(function(t){var e=t.event,r=t.params;i.appBridge.onEventV3(e,JSON.stringify(r))}):r.length&&(this.emit(C.Event,r),this.emit(C.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=[],r=this.processEvent(t,e||{});r&&(i.push(r),i.length&&(this.emit(C.BeconEvent,i),this.emit(C.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 r=e;"object"!=typeof r&&(r={}),r.profile?delete r.profile:r.event_index=s();var n=void 0;return r.local_ms?(n=r.local_ms,delete r.local_ms):n=+new Date,{event:i,params:r,local_time_ms:n,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)},r=t({},i,e);this.event("predefine_pageview",r)}else console.warn("predefinePageView should call after init")},e.prototype.clearEventCache=function(){this.emit(C.CleanEvents)},e.prototype.setWebIDviaUnionID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_unionid:t}),this.emit(C.CustomWebId)}},e.prototype.setWebIDviaOpenID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_openid:t}),this.emit(C.CustomWebId)}},e.prototype.setAnonymousId=function(t){this.emit(C.AnonymousId,t)},e.prototype.setNativeAppId=function(t){this.bridgeReport&&this.appBridge.setNativeAppId(t)},e.prototype.enableTransPort=function(){this.configManager.setEnableClientTransport(!0)},e.prototype.disableTransPort=function(){this.configManager.setEnableClientTransport(!1)},e.prototype.resetStayDuration=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(C.ResetStay,{url_path:t,title:e,url:i},C.Stay)},e.prototype.resetStayParams=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(C.SetStay,{url_path:t,title:e,url:i},C.Stay)},e.prototype.getToken=function(e,i){var r=this;if(this.inited){var n=!1,o=function(i){if(!n){n=!0;var o=r.configManager.get().user;return i&&(o.tobid=i,o["diss".split("").reverse().join("")]=i),e(t({},o))}},s=function(){r.tokenManager.getTobId().then(function(t){o(t)})};this.sdkReady?s():(i&&setTimeout(function(){o()},i),this.on(C.Ready,function(){s()}))}else this.logger.warn("getToken must be use after function init")},e.prototype.startTrackEvent=function(t){t&&this.emit(C.TrackDurationStart,t,C.TrackDuration)},e.prototype.endTrackEvent=function(t,e){void 0===e&&(e={}),t&&this.emit(C.TrackDurationEnd,{eventName:t,params:e},C.TrackDuration)},e.prototype.pauseTrackEvent=function(t){t&&this.emit(C.TrackDurationPause,t,C.TrackDuration)},e.prototype.resumeTrackEvent=function(t){t&&this.emit(C.TrackDurationResume,t,C.TrackDuration)},e.prototype.profileSet=function(t){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(t)):this.emit(C.ProfileSet,t,C.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(C.ProfileSetOnce,t,C.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(C.ProfileIncrement,t,C.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(C.ProfileUnset,t,C.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(C.ProfileAppend,t,C.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(C.AbExternalVersion,"string"==typeof t&&t?(""+t).trim():null,C.Ab)},e.prototype.getVar=function(t,e,i){this.bridgeReport?this.appBridge.getVar(t,e,i):this.emit(C.AbVar,{name:t,defaultValue:e,callback:i},C.Ab)},e.prototype.getAllVars=function(t){this.bridgeReport?this.appBridge.getAllVars(t):this.emit(C.AbAllVars,t,C.Ab)},e.prototype.getABconfig=function(t,e){this.emit(C.AbConfig,{params:t,callback:e},C.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(C.AbVersionChangeOn,t,C.Ab),function(){e.emit(C.AbVersionChangeOff,t,C.Ab)}},e.prototype.offAbSdkVersionChange=function(t){this.emit(C.AbVersionChangeOff,t,C.Ab)},e.prototype.openOverlayer=function(){this.emit(C.AbOpenLayer,"",C.Ab)},e.prototype.closeOverlayer=function(){this.emit(C.AbCloseLayer,"",C.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=(o=JSON.stringify(t),s=this.publicKey,void 0===(a=1)&&(a=1),"04"+$t.doEncrypt(o,s,a)),r=p(i);e=new Uint8Array(r)}else e="data="+(n=JSON.stringify(t),window.btoa?window.btoa(encodeURIComponent(n)):encodeURIComponent(n));return e}catch(e){return t}var n,o,s,a},e.prototype.destoryInstance=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(C.TokenComplete))},e.prototype.destoryInstace=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(C.TokenComplete))},e.plugins=[],e}(),Qt=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",this.eventCheck=new B(t,e),this.cache={},this.collect.on(C.ProfileSet,function(t){i.setProfile(t)}),this.collect.on(C.ProfileSetOnce,function(t){i.setOnceProfile(t)}),this.collect.on(C.ProfileUnset,function(t){i.unsetProfile(t)}),this.collect.on(C.ProfileIncrement,function(t){i.incrementProfile(t)}),this.collect.on(C.ProfileAppend,function(t){i.appendProfile(t)}),this.collect.on(C.ProfileClear,function(){i.cache={}}),this.ready(C.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 r=function(t){i[t].length&&i[t].forEach(function(i){e.collect.hook.emit(t,i)})};for(var n in i)r(n)}},e.prototype.report=function(t,e){var i=this;void 0===e&&(e={});try{if(this.config.disable_track_event)return;var r=[];r.push(this.collect.processEvent(t,e));var n=this.collect.eventManager.merge(r,!0),o=this.collect.cryptoData(n);this.collect.configManager.getUrl("profile");this.collect.requestManager.useRequest({url:this.reportUrl,data:o,timeout:1e5,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header,zip:!0,success:function(t,e,r,n,o){t&&0!==t.e?i.collect.emit(C.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:n,endTime:Date.now(),status:o}):i.collect.emit(C.SubmitSuccess,{eventData:e,res:t,response:t,startTime:n,endTime:Date.now(),status:o})},fail:function(t,e,r){i.collect.emit(C.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:r,endTime:Date.now()})}}),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 r in e)"string"==typeof e[r]||"Array"===Object.prototype.toString.call(e[r]).slice(8,-1)?i[r]=e[r]:console.warn("please check the value of param: "+r+", 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 r={};for(var n in t)"string"==typeof t[n]||"number"==typeof t[n]||"Array"===Object.prototype.toString.call(t[n]).slice(8,-1)?r[n]=t[n]:console.warn("please check the value of params:"+n+", must be string,number,Array !!!");var o=Object.keys(r);if(!o.length)return;var s=Date.now();return o.filter(function(r){var n=i.cache[r];return e?!n:!(n&&i.compare(n.val,t[r])&&s-n.timestamp<i.duration)}).reduce(function(t,e){return t[e]=r[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}(),Yt=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,r=Date.now()+e;return i=window.setTimeout(function n(){var o=Date.now()-r;t(),r+=e,i=window.setTimeout(n,Math.max(0,e-o))},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 r=this.collect.Types;this.collect.on(r.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}(),te=500,ee=5005;var ie=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(),r=i.header,n={events:[e],user:i.user,header:r};t.eventStore(n)},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 r=JSON.parse(JSON.stringify(t));e=t,Array.isArray(e)?r.forEach(function(t){i.fetchLog(t)}):this.fetchLog(r)}catch(t){console.log("web verify post error ~")}},t.prototype.fetchLog=function(t){!function(t,e,i,r,n,o,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),r&&(u.withCredentials=!0),i&&(u.timeout=i,u.ontimeout=function(){o&&o(e,ee)}),u.onload=function(){if(n){var t=null;if(u.responseText){try{t=JSON.parse(u.responseText)}catch(e){t={}}n(t,e)}}},u.onerror=function(){u.abort(),o&&o(e,te)},c?u.send(e):u.send(JSON.stringify(e))}catch(t){}}(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}();Zt.usePlugin(ie,"verifyH"),Zt.usePlugin(Qt,"profile"),Zt.usePlugin(Yt,"heartbeat");var re=new Zt("default"),ne=Zt;export{ne as Collector,re as default};
|
|
1
|
+
var t=function(){return t=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},t.apply(this,arguments)};function e(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var r,n,o=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}function i(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(e(arguments[i]));return t}var r,n=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 r(n){e(n),i.off(t,r)})}},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}(),o=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)},s=(r=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return r+=1}),a=function(t){return function(t,e,i){if("string"==typeof t&&"number"==typeof e&&"number"==typeof i){var r,n=[];i=i<=25?i:i%25;var o=String.fromCharCode(i+97);r=t.split(o);for(var s=0;s<r.length;s++){var a=parseInt(r[s],i);a=1*a^e;var c=String.fromCharCode(a);n.push(c)}return n.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,r,n=t.split("=");n.length&&(i=n[0],r=n[1]);try{e[i]=decodeURIComponent(void 0===r?"":r)}catch(t){e[i]=r}})}catch(t){}return e},f=function(t){for(var e=0,i=0,r=(t+="").length,n=0;n<r;n++)((e=31*e+t.charCodeAt(i++))>0x7fffffffffff||e<-0x800000000000)&&(e&=0xffffffffffff);return e<0&&(e+=0x7ffffffffffff),e};var p=function(t){var e,i,r=[],n=t.length;n%2!=0&&(i=n+1,t=(e=t).length>=i?e:new Array(i-e.length+1).join("0")+e),n=t.length;for(var o=0;o<n;o+=2)r.push(parseInt(t.substr(o,2),16));return r},l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(t,e){return t(e={exports:{}},e.exports),e.exports}var d=g(function(t,e){var i;i=function(){function t(){for(var t=0,e={};t<arguments.length;t++){var i=arguments[t];for(var r in i)e[r]=i[r]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(r){function n(){}function o(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=t({path:"/"},n.defaults,o)).expires&&(o.expires=new Date(1*new Date+864e5*o.expires)),o.expires=o.expires?o.expires.toUTCString():"";try{var s=JSON.stringify(i);/^[\{\[]/.test(s)&&(i=s)}catch(t){}i=r.write?r.write(i,e):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var c in o)o[c]&&(a+="; "+c,!0!==o[c]&&(a+="="+o[c].split(";")[0]));return document.cookie=e+"="+i+a}}function s(t,i){if("undefined"!=typeof document){for(var n={},o=document.cookie?document.cookie.split("; "):[],s=0;s<o.length;s++){var a=o[s].split("="),c=a.slice(1).join("=");i||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var h=e(a[0]);if(c=(r.read||r)(c,h)||e(c),i)try{c=JSON.parse(c)}catch(t){}if(n[h]=c,t===h)break}catch(t){}}return t?n[t]:n}}return n.set=o,n.get=function(t){return s(t,!1)},n.getJSON=function(t){return s(t,!0)},n.remove=function(e,i){o(e,"",t(i,{expires:-1}))},n.defaults={},n.withConverter=i,n}(function(){})},t.exports=i()}),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 d.get(t)}catch(t){return""}},setCookie:function(t,e,i,r){try{var n=r||document.domain,o=+new Date+i;d.set(t,e,{expires:new Date(o),path:"/",domain:n})}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,r){this._storage.setCookie(t,e,i,r)},t.prototype.removeItem=function(t){this._storage.removeItem(t)},t}(),S=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,r=i?h(i).hostname:"",n=u(window.location.href),o=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion)?"wap":"web";this.utm=function(t,e,i,r){var n=new E(!1),o=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 p in u)u[p]&&(-1!==h.indexOf(p)?(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data[p]=u[p]):c[p]=u[p],f=!0);if(f)o.setItem(a,"1"),n.setCookie(s,JSON.stringify(c),r,i);else{var l=n.getCookie(s,i);l&&(c=JSON.parse(l))}o.getItem(a)&&(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data.$utm_from_url=1)}catch(t){return u}return c}(this.appid,n,this.domain,this.cookie_expire);var s=this.browser(),a=this.os();return{browser:s.browser,browser_version:s.browser_version,platform:o,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:r,utm:this.utm,latest_data:this.last(i,r)}},t.prototype.last=function(t,e){var i="",r="",n="",o=location.hostname,s=!1;if(t&&e&&o!==e){i=t,r=e,s=!0;var a=u(t);a.keyword&&(n=a.keyword)}return{$latest_referrer:i,$latest_referrer_host:r,$latest_search_keyword:n,isLast:s}},t.prototype.browser=function(){var t,e,i="",r=""+parseFloat(this.appVersion),n=this.userAgent;return-1!==n.indexOf("Edge")||-1!==n.indexOf("Edg")?(i="Microsoft Edge",-1!==n.indexOf("Edge")?(t=n.indexOf("Edge"),r=n.substring(t+5)):(t=n.indexOf("Edg"),r=n.substring(t+4))):-1!==(t=n.indexOf("MSIE"))?(i="Microsoft Internet Explorer",r=n.substring(t+5)):-1!==(t=n.indexOf("Lark"))?(i="Lark",r=n.substring(t+5,t+11)):-1!==(t=n.indexOf("MetaSr"))?(i="sougoubrowser",r=n.substring(t+7,t+10)):-1!==n.indexOf("MQQBrowser")||-1!==n.indexOf("QQBrowser")?(i="qqbrowser",-1!==n.indexOf("MQQBrowser")?(t=n.indexOf("MQQBrowser"),r=n.substring(t+11,t+15)):-1!==n.indexOf("QQBrowser")&&(t=n.indexOf("QQBrowser"),r=n.substring(t+10,t+17))):-1!==n.indexOf("Chrome")?-1!==(t=n.indexOf("MicroMessenger"))?(i="weixin",r=n.substring(t+15,t+20)):-1!==(t=n.indexOf("360"))?(i="360browser",r=n.substring(n.indexOf("Chrome")+7)):-1!==n.indexOf("baidubrowser")||-1!==n.indexOf("BIDUBrowser")?(-1!==n.indexOf("baidubrowser")?(t=n.indexOf("baidubrowser"),r=n.substring(t+13,t+16)):-1!==n.indexOf("BIDUBrowser")&&(t=n.indexOf("BIDUBrowser"),r=n.substring(t+12,t+15)),i="baidubrowser"):-1!==(t=n.indexOf("xiaomi"))?-1!==n.indexOf("openlanguagexiaomi")?(i="openlanguage xiaomi",r=n.substring(t+7,t+13)):(i="xiaomi",r=n.substring(t-7,t-1)):-1!==(t=n.indexOf("TTWebView"))?(i="TTWebView",r=n.substring(t+10,t+23)):(-1!==(t=n.indexOf("Chrome"))||-1!==(t=n.indexOf("Chrome")))&&(i="Chrome",r=n.substring(t+7)):-1!==n.indexOf("Safari")?-1!==(t=n.indexOf("QQ"))?(i="qqbrowser",r=n.substring(t+10,t+16)):-1!==(t=n.indexOf("Safari"))&&(i="Safari",r=n.substring(t+7),-1!==(t=n.indexOf("Version"))&&(r=n.substring(t+8))):-1!==(t=n.indexOf("Firefox"))?(i="Firefox",r=n.substring(t+8)):-1!==(t=n.indexOf("MicroMessenger"))?(i="weixin",r=n.substring(t+15,t+20)):-1!==(t=n.indexOf("QQ"))?(i="qqbrowser",r=n.substring(t+3,t+8)):-1!==(t=n.indexOf("Opera"))&&(i="Opera",r=n.substring(t+6),-1!==(t=n.indexOf("Version"))&&(r=n.substring(t+8))),-1!==(e=r.indexOf(";"))&&(r=r.substring(0,e)),-1!==(e=r.indexOf(" "))&&(r=r.substring(0,e)),-1!==(e=r.indexOf(")"))&&(r=r.substring(0,e)),{browser:i,browser_version:r}},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)/}],r=0;r<i.length;r++){var n=i[r];if(n.r.test(this.userAgent)){"Mac OS X"===(t=n.s)&&this.isNewIpad()&&(t="iOS");break}}var o=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=o(/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=o(/Android ([\.\_\d]+)/,a))||(c=o(/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 (",""),r=i.indexOf(";");e=i.slice(0,r)}}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}(),w=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}(),T=function(){function t(){this.support=this.isSupportLS()}return t.prototype.isSupportLS=function(){try{return localStorage.setItem("_applogtest-test-key","hi"),localStorage.getItem("_applogtest-test-key"),localStorage.removeItem("_applogtest-test-key"),!0}catch(t){return!1}},t.prototype.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{}},t.prototype.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},t.prototype.removeItem=function(t){try{localStorage.removeItem(t)}catch(t){}},t}(),D=function(){function t(){this.support=this.isSupportSession()}return t.prototype.isSupportSession=function(){try{return sessionStorage.setItem("_applogtest-test-key","hi"),sessionStorage.getItem("_applogtest-test-key"),sessionStorage.removeItem("_applogtest-test-key"),!0}catch(t){return!1}},t.prototype.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{}},t.prototype.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},t.prototype.removeItem=function(t){try{sessionStorage.removeItem(t)}catch(t){}},t}(),I=function(){function t(){this.defaultExpireTime=6048e5,this.local=new T,this.session=new D,this.cache=new w}return t.prototype.getLocalItem=function(t){return this.local.getItem(t)},t.prototype.setLocalItem=function(t,e){this.local.setItem(t,e)},t.prototype.removeLocalItem=function(t){this.local.removeItem(t)},t.prototype.getSessionItem=function(t){return this.session.getItem(t)},t.prototype.setSessionItem=function(t,e){this.session.setItem(t,e)},t.prototype.removeSessionItem=function(t){this.session.removeItem(t)},t.prototype.getCacheItem=function(t){return this.cache.getItem(t)},t.prototype.setCacheItem=function(t,e){this.cache.setItem(t,e)},t.prototype.removeCacheItem=function(t){this.cache.removeItem(t)},t.prototype.getCookie=function(t,e){try{return d.get(t)}catch(t){return""}},t.prototype.setCookie=function(t,e,i,r){void 0===i&&(i=this.defaultExpireTime);try{var n=r||document.domain,o=+new Date+i;d.set(t,e,{expires:new Date(o),path:"/",domain:n})}catch(t){}},t.prototype.removeCookie=function(t,e){try{d.remove(t,{path:"/",domain:e||""})}catch(t){}},t}(),A={cn:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},k="0.1.2",B=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","$bav2b_slide"],this.paramsNameWhiteList=["$inactive","$inline","$target_uuid_list","$source_uuid","$is_spider","$source_id","$is_first_time","$user_unique_id_type","_staging_flag","$exposure_type","$direction","$offsetY","$offsetX"],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 r=i.events,n=i.header;if(!r||!r.length)return!1;var o=!0;return r.forEach(function(t){e.checkEventName(t.event)||(o=!1,t.checkEvent="事件名不能以 $ or __开头"),e.checkEventParams(t.params)||(o=!1,t.checkParams="属性名不能以 $ or __开头")}),this.checkEventParams(n)||(o=!1),o},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 r in e){if(!this.calculate(r,"params")){i=!1;break}if("string"==typeof e[r]&&e[r].length>1024){console.warn("params: "+r+" 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.SubmitSuccess="submit-success",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.CustomHeader="custom-request-header",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 C=y,R=void 0,O=(new Date).getTimezoneOffset(),M=parseInt(""+-O/60,10),x=60*O,G=function(){function e(t,e){this.is_first_time=!0,this.configPersist=!1,this.enableClientTransport=!1,this.initConfig=e,this.collect=t;var i=new S(e.app_id,e.cookie_domain||"",e.cookie_expire||7776e6).init();this.eventCheck=new B(t,e);var r="__tea_cache_first_"+e.app_id;this.configKey="__tea_cache_config_"+e.app_id,this.storage=new I,e.configPersist&&(this.configPersist=!0,this.storage=1===e.configPersist?this.sessionStorage:this.localStorage);var n=this.storage.getLocalItem(r);n&&1==n?this.is_first_time=!1:(this.is_first_time=!0,this.storage.setLocalItem(r,"1")),this.envInfo={user:{user_unique_id:R,user_type:R,user_id:R,user_is_auth:R,user_is_login:R,device_id:R,web_id:R,ip_addr_id:R,user_unique_id_type:R,anonymous_id:R},header:{app_id:R,app_name:R,app_install_id:R,install_id:R,app_package:R,app_channel:R,app_version:R,ab_version:R,os_name:i.os_name,os_version:i.os_version,device_model:i.device_model,ab_client:R,traffic_type:R,client_ip:R,device_brand:R,os_api:R,access:R,language:i.language,region:R,app_language:R,app_region:R,creative_id:i.utm.creative_id,ad_id:i.utm.ad_id,campaign_id:i.utm.campaign_id,log_type:R,rnd:R,platform:i.platform,sdk_version:k,sdk_lib:"js",province:R,city:R,timezone:M,tz_offset:x,tz_name:R,sim_region:R,carrier:R,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:R,wechat_openid:R}},this.ab_version="",this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(i),this.initDomain(),this.initABData(),this.setEnableClientTransport(!!this.initConfig.transport)}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(A[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.storage.getCookie(t,this.initConfig.ab_cookie_domain);e=i?JSON.parse(i):null}else e=this.storage.getLocalItem(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(){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.setEnableClientTransport=function(t){this.enableClientTransport=t},e.prototype.getEnableClientTransport=function(){return this.enableClientTransport},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.1.2&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(r){void 0!==e[r]&&null!==e[r]||i.delete(r);try{i.eventCheck.calculate(r,"config")}catch(t){}if("traffic_type"===r&&i.isLast&&(i.envInfo.header.custom.$latest_traffic_source_type=e[r]),"evtParams"===r)i.evtParams=t({},i.evtParams||{},e.evtParams||{});else if("_staging_flag"===r)i.evtParams=t({},i.evtParams||{},{_staging_flag:e._staging_flag});else if("reportErrorCallback"===r&&"function"==typeof e[r])i.reportErrorCallback=e[r];else{var n="",o="";if(r.indexOf(".")>-1){var s=r.split(".");n=s[0],o=s[1]}n?"user"===n||"header"===n?i.envInfo[n][o]=e[r]:i.envInfo.header.custom[o]=e[r]:Object.hasOwnProperty.call(i.envInfo.user,r)?["user_type","ip_addr_id"].indexOf(r)>-1?i.envInfo.user[r]=e[r]?Number(e[r]):e[r]:["user_id","web_id","user_unique_id","user_unique_id_type","anonymous_id"].indexOf(r)>-1?i.envInfo.user[r]=e[r]?String(e[r]):e[r]:["user_is_auth","user_is_login"].indexOf(r)>-1?i.envInfo.user[r]=Boolean(e[r]):"device_id"===r&&(i.envInfo.user[r]=e[r]):Object.hasOwnProperty.call(i.envInfo.header,r)?i.envInfo.header[r]=e[r]:i.envInfo.header.custom[r]=e[r]}})},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.getItem=function(t){return this.initConfig&&1===this.initConfig.configPersist?this.storage.getSessionItem(t):this.storage.getLocalItem(t)},e.prototype.setItem=function(t,e){this.initConfig&&1===this.initConfig.configPersist?this.storage.setSessionItem(t,e):this.storage.setLocalItem(t,e)},e.prototype.setStore=function(t){try{if(!this.configPersist)return;var e=this.getItem(this.configKey)||{};if(e&&Object.keys(t).length){var i=Object.assign(t,e);this.setItem(this.configKey,i)}}catch(t){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.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.getItem(this.configKey)||{};e&&Object.hasOwnProperty.call(e,t)&&(delete e[t],this.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})}},e}(),F=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}(),q=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}(),P=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.storgae=new I,this.eventCheck=new B(t,e),this.maxReport=e.max_report||20,this.reportTime=e.reportTime||30,this.timeout=e.timeout||1e5,this.enable_ttwebid=e.enable_ttwebid,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(C.Ready,function(){i.reportAll(!1)}),this.collect.on(C.ConfigDomain,function(){i.reportUrl=i.configManager.getUrl("event")}),this.collect.on(C.Event,function(t){i.event(t)}),this.collect.on(C.BeconEvent,function(t){i.beconEvent(t)}),this.collect.on(C.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 r=i(t,this.storgae.getCacheItem(this.eventKey)||[]);if(this.storgae.setCacheItem(this.eventKey,r),this.reportTimeout&&clearTimeout(this.reportTimeout),r.length>=this.maxReport)this.report(!1);else{var n=this.reportTime;this.reportTimeout=setTimeout(function(){e.report(!1),e.reportTimeout=null},n)}}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.storgae.getCacheItem(this.beconKey)||[]);this.storgae.setCacheItem(this.beconKey,e),this.collect.destroyInstance||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.storgae.removeCacheItem(this.beconKey),this.send(this.split(this.merge(e)),!0))},e.prototype.reportBecon=function(){var t=this.storgae.getCacheItem(this.beconKey)||[];t&&t.length&&(this.storgae.removeCacheItem(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.storgae.getCacheItem(this.eventKey)||[];e.length&&(this.storgae.removeCacheItem(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 r;r=t.slice(i,i+this.eventLimit);var n=this.split(this.merge(r));this.send(n,e)}else{n=this.split(this.merge(t));this.send(n,e)}},e.prototype.handleRefer=function(){var t="";try{if(this.config.spa||this.config.autotrack){var e=this.storgae.getLocalItem(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 r=this,n=this.configManager.get(),o=n.header,s=n.user;o.referrer=this.handleRefer(),o.custom=JSON.stringify(o.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)),r.collect.dynamicParamsFilter){var n=r.collect.dynamicParamsFilter();Object.keys(n).length&&(e.params=t({},e.params,n))}c&&(e.params.$user_unique_id_type=c);var o=r.configManager.getAbCache(),h=r.configManager.getAbVersion();return h&&o&&(r.config.disable_ab_reset||o.uuid===s.user_unique_id)&&(e.ab_sdk_version=h),e.session_id=r.collect.sessionManager.getSessionId(),e.params=JSON.stringify(e.params),e}catch(t){return r.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:o}));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 r=JSON.parse(JSON.stringify(t));i.config.filter&&((r=i.config.filter(r))||console.warn("filter must return data !!")),i.collect.eventFilter&&r&&((r=i.collect.eventFilter(r))||console.warn("filterEvent api must return data !!"));var n=r||t,o=JSON.parse(JSON.stringify(n));if(i.eventCheck.checkVerify(o),!n.length)return;i.collect.emit(C.SubmitBefore,n);var s=i.collect.cryptoData(n);i.collect.requestManager.useRequest({url:i.reportUrl,data:s,success:function(t,e,r,n,s){t&&0!==t.e?(i.collect.emit(C.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:n,endTime:Date.now(),status:s}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:o,code:t.e,failType:"数据异常失败",status:"fail"})):(i.collect.emit(C.SubmitSuccess,{eventData:e,res:t,response:t,startTime:n,endTime:Date.now(),status:s}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:o,code:200,status:"success"}))},fail:function(t,e,r,n){i.configManager.get("reportErrorCallback")(t,e),i.collect.emit(C.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:r,errorMessage:n,endTime:Date.now()}),i.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_EVENT,info:"埋点上报网络异常",time:Date.now(),data:o,code:e,failType:"网络异常失败",status:"fail"})},timeout:i.timeout,useBeacon:e,encryption:i.config.enable_encryption,encryption_header:i.config.encryption_header,withCredentials:i.enable_ttwebid}),i.collect.emit(C.SubmitVerifyH,n),i.collect.emit(C.SubmitAfter,n)}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}(),U=function t(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t)},N=function(){return U().replace(/-/g,"").slice(0,19)},V=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)})},L=function(){function t(){}return t.prototype.apply=function(t,e){var i=this;this.collect=t,this.storage=new I,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(C.SessionReset,function(){i.resetSessionId()}),this.collect.on(C.SessionResetTime,function(){i.updateSessionIdTime()}))},t.prototype.updateSessionIdTime=function(){var t=this.storage.getSessionItem(this.sessionKey);if(t&&t.sessionId){var e=t.timestamp;Date.now()-e>this.expireTime?t={sessionId:V(),timestamp:Date.now()}:t.timestamp=Date.now(),this.storage.setSessionItem(this.sessionKey,t),this.resetExpTime()}},t.prototype.setSessionId=function(){var t=this,e=this.storage.getSessionItem(this.sessionKey);e&&e.sessionId?e.timestamp=Date.now():e={sessionId:V(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,e),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime)},t.prototype.getSessionId=function(){var t=this.storage.getSessionItem(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:V(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,t)},t.prototype.checkEXp=function(){var t=this.storage.getSessionItem(this.sessionKey);t&&t.sessionId&&(Date.now()-t.timestamp+30>=this.expireTime&&(t={sessionId:V(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,t)))},t}(),K=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 I,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(C.AnonymousId,function(t){i.setAnonymousId(t)}),this.collect.on(C.ConfigUuid,function(t){i.setUuid(t)}),this.collect.on(C.ConfigWebId,function(t){i.setWebId(t)}),this.timeout=e.timeout||3e5,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.getLocalItem(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(C.CustomWebId,function(){t.tokenReady=!0,t.collect.emit(C.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:N(),user_unique_id:this.configManager.get("user_unique_id")||N()}):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 r=this.collect.cryptoData(i);this.collect.requestManager.useRequest({url:e,data:r,success:function(e){var i;if(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});else{var r=t.getLocalId();i=r,t.collect.configManager.set({localWebId:r}),t.collect.emit(C.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})},fail:function(){var e=t.getLocalId();t.complete({web_id:t.configManager.get("web_id")||e,user_unique_id:t.configManager.get("user_unique_id")||e}),t.collect.configManager.set({localWebId:e}),t.collect.emit(C.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~")},timeout:this.timeout,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},t.prototype.getLocalId=function(){for(var t=N(),e=0;0===t.indexOf("0")||0===t.indexOf("9");){if(e>=10){t=t.replace(/^(0|9)/,"");break}t=N(),e++}return t},t.prototype.complete=function(t){var e=t.web_id,i=t.user_unique_id;if(!e&&!i)return this.collect.emit(C.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(C.TokenComplete)},t.prototype.completeAnonymous=function(t){var e=t.anonymous_id||V(),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(C.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(C.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"),r=this.cacheToken&&this.cacheToken.user_unique_id;if(e===i&&e===r)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(C.TokenChange,{type:"uuid",id:t}),this.collect.emit(C.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(C.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(C.TokenChange,{type:"uuid",id:t})),this.configManager.set({anonymous_id:t}),this.cacheToken.anonymous_id=t,this.collect.emit(C.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(C.TokenChange,{type:"uuid",id:t})),e!==t&&(this.configManager.set({web_id:t}),this.cacheToken.web_id=t,this.collect.emit(C.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.setLocalItem(this.tokenKey,t),this.cacheToken=t},t.prototype.getReady=function(){return this.tokenReady},t.prototype.getTobId=function(){var t=this;this.configManager.getUrl("tobid");var e={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?e.anonymous_id=this.configManager.get("anonymous_id"):e.web_id=this.configManager.get("web_id");var i=this.collect.cryptoData(e);return new Promise(function(e){t.collect.requestManager.useRequest({url:t.configManager.getUrl("tobid"),data:i,success:function(i){i&&0===i.e?(e(i.tobid),t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"GetToken请求成功",logType:"fetch",level:"info",time:Date.now(),data:i,infoType:"sdk"})):(e(""),t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),data:i,infoType:"sdk"}))},fail:function(){e(""),t.collect.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),infoType:"sdk"})},timeout:t.timeout,encryption:t.config.enable_encryption,encryption_header:t.config.encryption_header,withCredentials:t.enableTTwebid})})},t}(),z=function(){function t(t,e){var i=this;this.collector=t,this.config=e,this.requestType=e.request_type||"xhr",this.supportBeacon=!(!window.navigator||!window.navigator.sendBeacon),this.errorCode={NO_URL:4001,IMG_ON:4e3,IMG_CATCH:4002,BEACON_FALSE:4003,XHR_ERROR:5002,TIMEOUT:5005,FETCH_ERROR:5006},this.errorMessage={BEACON_FALSE:"xhr sendbeacon error",XHR_ERROR:"xhr request error",BEACON:"xhr sendbeacon error",TIMEOUT:"xhr request timeout",FETCH_ERROR:"fetch network error",FETCH_RESPONSE_ERROR:"fetch response error"},this.customHeader=e.custom_request_header||{},this.collector.on(C.CustomHeader,function(t){i.setRequestHeader(t)})}return t.prototype.setRequestHeader=function(t){this.customHeader=Object.assign(this.customHeader,t)},t.prototype.useFetch=function(t){var e=this,i=t.url,r=t.data,n=t.method,o=t.success,s=t.fail,a=t.status,c=t.timeout,h=t.useBeacon,u=t.encryption,f=t.encryption_header,p=t.withCredentials;if(window.fetch&&"undefined"!=typeof Request){var l={method:n||"POST"};if(h){if(!("keepalive"in Request.prototype))return void this.useSendBeacon(t);var g=this.collector.configManager.get("browser"),d=this.collector.configManager.get("browser_version");if(d=d.split("."),"Chrome"===g&&d.length&&d[0]&&Number(d[0])<82)return void this.useSendBeacon(t);l.keepalive=!0}var m=JSON.stringify(r),y={"Content-Type":"application/json; charset=utf-8"};u&&f&&(y["Content-Type"]="application/octet-stream;tt-data="+f),p&&(l.credentials="include"),l.body=m,l.headers=y;var _=null;_="undefined"!=typeof AbortController?new AbortController:{signal:null,abort:function(){}};var b=setTimeout(function(){_.abort()},c);if(Object.keys(this.customHeader).length)for(var E in this.customHeader)y[E]=this.customHeader[E];l.signal=_.signal;var S=Date.now();try{fetch(i,l).then(function(t){return t.ok||s&&s(r,t.status,S,t.statusText||e.errorMessage.FETCH_RESPONSE_ERROR),t.json()}).then(function(t){clearTimeout(b),o&&o(t,r,a,S,200)}).catch(function(t){clearTimeout(b),s&&s(r,e.errorCode.FETCH_ERROR,S,t.message||e.errorMessage.FETCH_ERROR)})}catch(e){this.useXhr(t),this.collector.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK useFetch 发送请求发生了一些问题",level:"error",time:Date.now(),data:e.message||"SDK useFetch has some errors",infoType:"sdk"})}}else h?this.useSendBeacon(t):this.useXhr(t),console.log("your browser not support fetch, use normal request")},t.prototype.useSendBeacon=function(t){if(this.supportBeacon){var e=t.url,i=t.data,r=t.status,n=t.success,o=t.fail,s=Date.now();window.navigator.sendBeacon(e,JSON.stringify(i))?n&&n({e:0},i,r,s,200):o&&o(i,this.errorCode.BEACON_FALSE,s,this.errorMessage.BEACON_FALSE)}else this.useXhr(t)},t.prototype.useXhr=function(t){var e=this,i=t.url,r=t.data,n=t.method,o=t.success,s=t.fail,a=t.timeout,c=t.withCredentials,h=t.encryption,u=t.encryption_header,f=t.status;try{var p=new XMLHttpRequest;p.open(n||"POST",i,!0);var l=Date.now();if(p.setRequestHeader("Content-Type","application/json; charset=utf-8"),h&&u?p.setRequestHeader("Content-Type","application/octet-stream;tt-data="+u):p.setRequestHeader("Content-Type","application/json; charset=utf-8"),Object.keys(this.customHeader).length)for(var g in this.customHeader)p.setRequestHeader(g,this.customHeader[g]);c&&(p.withCredentials=!0),a&&(p.timeout=a,p.ontimeout=function(){s&&s(r,e.errorCode.TIMEOUT,l,e.errorMessage.TIMEOUT)}),p.onload=function(){if(o){var t=null;if(p.responseText){try{t=JSON.parse(p.responseText)}catch(e){t={}}o(t,r,f,l,p.status)}else s&&s(r,e.errorCode.XHR_ERROR,l,e.errorMessage.XHR_ERROR)}},p.onerror=function(){s&&s(r,e.errorCode.XHR_ERROR,l,e.errorMessage.XHR_ERROR),p.abort()},p.send(JSON.stringify(r))}catch(t){this.collector.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK useXhr 发送请求发生了一些问题",level:"error",time:Date.now(),data:t.message,infoType:"sdk"})}},t.prototype.useRequest=function(t){var e=t.useBeacon;this.config.transport&&this.collector.configManager.getEnableClientTransport()?this.useCustomRequest(t):"fetch"!==this.requestType?e?this.useSendBeacon(t):this.useXhr(t):this.useFetch(t)},t.prototype.useCustomRequest=function(t){var e=this.config.transport,i=t.url,r=t.data,n=t.success,o=t.fail;if(e)try{e.post({url:i,data:JSON.stringify(r),success:function(t){n&&n(t,r)},fail:function(t){o&&o(t,r)}})}catch(e){this.collector.configManager.setEnableClientTransport(!1),this.useRequest(t)}},t}(),H=g(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 r(){return new i(null)}var n="undefined"!=typeof navigator;n&&"Microsoft Internet Explorer"==navigator.appName?(i.prototype.am=function(t,e,i,r,n,o){for(var s=32767&e,a=e>>15;--o>=0;){var c=32767&this[t],h=this[t++]>>15,u=a*c+h*s;n=((c=s*c+((32767&u)<<15)+i[r]+(1073741823&n))>>>30)+(u>>>15)+a*h+(n>>>30),i[r++]=1073741823&c}return n},e=30):n&&"Netscape"!=navigator.appName?(i.prototype.am=function(t,e,i,r,n,o){for(;--o>=0;){var s=e*this[t++]+i[r]+n;n=Math.floor(s/67108864),i[r++]=67108863&s}return n},e=26):(i.prototype.am=function(t,e,i,r,n,o){for(var s=16383&e,a=e>>14;--o>=0;){var c=16383&this[t],h=this[t++]>>14,u=a*c+h*s;n=((c=s*c+((16383&u)<<14)+i[r]+n)>>28)+(u>>14)+a*h,i[r++]=268435455&c}return n},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 o,s,a=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)a[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)a[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)a[o++]=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=r();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 p(t){this.m=t}function l(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 g(t,e){return t&e}function d(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 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),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 S(t){this.r2=r(),this.q3=r(),i.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}p.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},p.prototype.revert=function(t){return t},p.prototype.reduce=function(t){t.divRemTo(this.m,null,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)},l.prototype.convert=function(t){var e=r();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},l.prototype.revert=function(t){var e=r();return t.copyTo(e),this.reduce(e),e},l.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],r=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,r,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)},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)},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 r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,o=!1,s=0;--n>=0;){var a=8==r?255&t[n]:h(t,n);a<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+r>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+=r)>=this.DB&&(s-=this.DB))}8==r&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&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,r=t%this.DB,n=this.DB-r,o=(1<<n)-1,s=Math.floor(t/this.DB),a=this.s<<r&this.DM;for(i=this.t-1;i>=0;--i)e[i+s+1]=this[i]>>n|a,a=(this[i]&o)<<r;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 r=t%this.DB,n=this.DB-r,o=(1<<r)-1;e[0]=this[i]>>r;for(var s=i+1;s<this.t;++s)e[s-i-1]|=(this[s]&o)<<n,e[s-i]=this[s]>>r;r>0&&(e[this.t-i-1]|=(this.s&o)<<n),e.t=this.t-i,e.clamp()}},i.prototype.subTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()},i.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),o=r.t;for(e.t=o+n.t;--o>=0;)e[o]=0;for(o=0;o<n.t;++o)e[o+r.t]=r.am(0,n[o],e,o,0,r.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 r=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,r,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,n){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t<o.t)return null!=e&&e.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=r());var a=r(),c=this.s,h=t.s,u=this.DB-f(o[o.t-1]);u>0?(o.lShiftTo(u,a),s.lShiftTo(u,n)):(o.copyTo(a),s.copyTo(n));var p=a.t,l=a[p-1];if(0!=l){var g=l*(1<<this.F1)+(p>1?a[p-2]>>this.F2:0),d=this.FV/g,m=(1<<this.F1)/g,y=1<<this.F2,v=n.t,_=v-p,b=null==e?r():e;for(a.dlShiftTo(_,b),n.compareTo(b)>=0&&(n[n.t++]=1,n.subTo(b,n)),i.ONE.dlShiftTo(p,b),b.subTo(a,a);a.t<p;)a[a.t++]=0;for(;--_>=0;){var E=n[--v]==l?this.DM:Math.floor(n[v]*d+(n[v-1]+y)*m);if((n[v]+=a.am(0,E,n,_,0,p))<E)for(a.dlShiftTo(_,b),n.subTo(b,n);n[v]<--E;)n.subTo(b,n)}null!=e&&(n.drShiftTo(p,e),c!=h&&i.ZERO.subTo(e,e)),n.t=p,n.clamp(),u>0&&n.rShiftTo(u,n),c<0&&i.ZERO.subTo(n,n)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(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 n=r(),o=r(),s=e.convert(this),a=f(t)-1;for(s.copyTo(n);--a>=0;)if(e.sqrTo(n,o),(t&1<<a)>0)e.mulTo(o,s,n);else{var c=n;n=o,o=c}return e.revert(n)},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,r=(1<<e)-1,n=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(i=this[s]>>a)>0&&(n=!0,o=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)&r,a<=0&&(a+=this.DB,--s)),i>0&&(n=!0),n&&(o+=c(i));return n?o:"0"},i.prototype.negate=function(){var t=r();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=r();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 p(e):new l(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)},S.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=r();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.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)},S.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var w,T,D,I=[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)/I[I.length-1];function k(){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>=G&&(D-=G)}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),n=u(i),o=r(),s=r(),a="";for(this.divRemTo(n,o,s);o.signum()>0;)a=(i+s.intValue()).toString(t).substr(1)+a,o.divRemTo(n,o,s);return s.intValue().toString(t)+a},i.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),o=!1,s=0,a=0,c=0;c<t.length;++c){var u=h(t,c);u<0?"-"==t.charAt(c)&&0==this.signum()&&(o=!0):(a=e*a+u,++s>=r&&(this.dMultiply(n),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),o&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),d,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 n=new Array,o=7&t;n.length=1+(t>>3),e.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}},i.prototype.bitwiseTo=function(t,e,i){var r,n,o=Math.min(t.t,this.t);for(r=0;r<o;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(n=t.s&this.DM,r=o;r<this.t;++r)i[r]=e(this[r],n);i.t=this.t}else{for(n=this.s&this.DM,r=o;r<t.t;++r)i[r]=e(n,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},i.prototype.changeBit=function(t,e){var r=i.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},i.prototype.addTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[i++]=r:r<-1&&(e[i++]=this.DV+r),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 r,n=Math.min(this.t+t.t,e);for(i.s=0,i.t=n;n>0;)i[--n]=0;for(r=i.t-this.t;n<r;++n)i[n+this.t]=this.am(0,t[n],i,n,0,this.t);for(r=Math.min(t.t,e);n<r;++n)this.am(0,t[n],i,n,0,e-n);i.clamp()},i.prototype.multiplyUpperTo=function(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-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 r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i},i.prototype.millerRabin=function(t){var e=this.subtract(i.ONE),n=e.getLowestSetBit();if(n<=0)return!1;var o=e.shiftRight(n);(t=t+1>>1)>I.length&&(t=I.length);for(var s=r(),a=0;a<t;++a){s.fromInt(I[Math.floor(Math.random()*I.length)]);var c=s.modPow(o,this);if(0!=c.compareTo(i.ONE)&&0!=c.compareTo(e)){for(var h=1;h++<n&&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=r();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,r=this.DB-t*this.DB%8,n=0;if(t-- >0)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<<this.DB-r);t>=0;)r<8?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),128&i&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(n>0||i!=this.s)&&(e[n++]=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=r();return this.bitwiseTo(t,g,e),e},i.prototype.or=function(t){var e=r();return this.bitwiseTo(t,d,e),e},i.prototype.xor=function(t){var e=r();return this.bitwiseTo(t,m,e),e},i.prototype.andNot=function(t){var e=r();return this.bitwiseTo(t,y,e),e},i.prototype.not=function(){for(var t=r(),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=r();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},i.prototype.shiftRight=function(t){var e=r();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:!!(this[e]&1<<t%this.DB)},i.prototype.setBit=function(t){return this.changeBit(t,d)},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=r();return this.addTo(t,e),e},i.prototype.subtract=function(t){var e=r();return this.subTo(t,e),e},i.prototype.multiply=function(t){var e=r();return this.multiplyTo(t,e),e},i.prototype.divide=function(t){var e=r();return this.divRemTo(t,e,null),e},i.prototype.remainder=function(t){var e=r();return this.divRemTo(t,null,e),e},i.prototype.divideAndRemainder=function(t){var e=r(),i=r();return this.divRemTo(t,e,i),new Array(e,i)},i.prototype.modPow=function(t,e){var i,n,o=t.bitLength(),s=u(1);if(o<=0)return s;i=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new p(e):e.isEven()?new S(e):new l(e);var a=new Array,c=3,h=i-1,g=(1<<i)-1;if(a[1]=n.convert(this),i>1){var d=r();for(n.sqrTo(a[1],d);c<=g;)a[c]=r(),n.mulTo(d,a[c-2],a[c]),c+=2}var m,y,v=t.t-1,_=!0,b=r();for(o=f(t[v])-1;v>=0;){for(o>=h?m=t[v]>>o-h&g:(m=(t[v]&(1<<o+1)-1)<<h-o,v>0&&(m|=t[v-1]>>this.DB+o-h)),c=i;!(1&m);)m>>=1,--c;if((o-=c)<0&&(o+=this.DB,--v),_)a[m].copyTo(s),_=!1;else{for(;c>1;)n.sqrTo(s,b),n.sqrTo(b,s),c-=2;c>0?n.sqrTo(s,b):(y=s,s=b,b=y),n.mulTo(b,a[m],s)}for(;v>=0&&!(t[v]&1<<o);)n.sqrTo(s,b),y=s,s=b,b=y,--o<0&&(o=this.DB-1,--v)}return n.revert(s)},i.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return i.ZERO;for(var r=t.clone(),n=this.clone(),o=u(1),s=u(0),a=u(0),c=u(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(t,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),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);r.compareTo(n)>=0?(r.subTo(n,r),e&&o.subTo(a,o),s.subTo(c,s)):(n.subTo(r,n),e&&a.subTo(o,a),c.subTo(s,c))}return 0!=n.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 r=e;e=i,i=r}var n=e.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)return e;for(n<o&&(o=n),o>0&&(e.rShiftTo(o,e),i.rShiftTo(o,i));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return o>0&&i.lShiftTo(o,i),i},i.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=I[I.length-1]){for(e=0;e<I.length;++e)if(i[0]==I[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<I.length;){for(var r=I[e],n=e+1;n<I.length&&r<A;)r*=I[n++];for(r=i.modInt(r);e<n;)if(r%I[e++]==0)return!1}return i.millerRabin(t)},i.prototype.square=function(){var t=r();return this.squareTo(t),t},i.prototype.Barrett=S,null==T){var B;if(T=new Array,D=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var C=new Uint8Array(32);for(window.crypto.getRandomValues(C),B=0;B<32;++B)T[D++]=C[B]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var R=window.crypto.random(32);for(B=0;B<R.length;++B)T[D++]=255&R.charCodeAt(B)}for(;D<G;)B=Math.floor(65536*Math.random()),T[D++]=B>>>8,T[D++]=255&B;D=0,k()}function O(){if(null==w){for(k(),(w=new x).init(T),D=0;D<T.length;++D)T[D]=0;D=0}return w.next()}function M(){}function x(){this.i=0,this.j=0,this.S=new Array}M.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=O()},x.prototype.init=function(t){var e,i,r;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,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0},x.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 G=256;t.exports={default:i,BigInteger:i,SecureRandom:M}}).call(l)});H.BigInteger,H.SecureRandom;const{BigInteger:j}=H;class J{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 W extends J{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 r="";for(let t=0;t<i;t++)r+="f";r=new j(r,16),e=r.xor(t).add(j.ONE),e=e.toString(16).replace(/^-/,"")}return e}(t))}getValue(){return this.v}}class X extends J{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map(t=>t.getEncodedHex()).join(""),this.v}}function $(t,e){return+t[e+2]<8?1:128&+t.substr(e+2,2)}function Z(t,e){const i=$(t,e),r=t.substr(e+2,2*i);if(!r)return-1;return(+r[0]<8?new j(r,16):new j(r.substr(2),16)).intValue()}function Q(t,e){return e+2*($(t,e)+1)}var Y={encodeDer(t,e){const i=new W(t),r=new W(e);return new X([i,r]).getEncodedHex()},decodeDer(t){const e=Q(t,0),i=Q(t,e),r=Z(t,e),n=t.substr(i,2*r),o=i+n.length,s=Q(t,o),a=Z(t,o),c=t.substr(s,2*a);return{r:new j(n,16),s:new j(c,16)}}};const{BigInteger:tt}=H,et=new tt("2"),it=new tt("3");class rt{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 rt(this.q,this.x.negate().mod(this.q))}add(t){return new rt(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new rt(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new rt(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new rt(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new rt(this.q,this.x.square().mod(this.q))}}class nt{constructor(t,e,i,r){this.curve=t,this.x=e,this.y=i,this.z=null==r?tt.ONE:r,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(tt.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(tt.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(tt.ZERO)&&!this.y.toBigInteger().equals(tt.ZERO)}negate(){return new nt(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(),r=this.z,n=t.x.toBigInteger(),o=t.y.toBigInteger(),s=t.z,a=this.curve.q,c=e.multiply(s).mod(a),h=n.multiply(r).mod(a),u=c.subtract(h),f=i.multiply(s).mod(a),p=o.multiply(r).mod(a),l=f.subtract(p);if(tt.ZERO.equals(u))return tt.ZERO.equals(l)?this.twice():this.curve.infinity;const g=c.add(h),d=r.multiply(s).mod(a),m=u.square().mod(a),y=u.multiply(m).mod(a),v=d.multiply(l.square()).subtract(g.multiply(m)).mod(a),_=u.multiply(v).mod(a),b=l.multiply(m.multiply(c).subtract(v)).subtract(f.multiply(y)).mod(a),E=y.multiply(d).mod(a);return new nt(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,r=this.curve.q,n=this.curve.a.toBigInteger(),o=t.square().multiply(it).add(n.multiply(i.square())).mod(r),s=e.shiftLeft(1).multiply(i).mod(r),a=e.square().mod(r),c=a.multiply(t).multiply(i).mod(r),h=s.square().mod(r),u=o.square().subtract(c.shiftLeft(3)).mod(r),f=s.multiply(u).mod(r),p=o.multiply(c.shiftLeft(2).subtract(u)).subtract(h.shiftLeft(1).multiply(a)).mod(r),l=s.multiply(h).mod(r);return new nt(this.curve,this.curve.fromBigInteger(f),this.curve.fromBigInteger(p),l)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const e=t.multiply(it),i=this.negate();let r=this;for(let n=e.bitLength()-2;n>0;n--){r=r.twice();const o=e.testBit(n);o!==t.testBit(n)&&(r=r.add(o?this:i))}return r}}var ot={ECPointFp:nt,ECCurveFp:class{constructor(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new nt(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 rt(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 tt(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 tt("4")).add(tt.ONE),this.q));return i.toBigInteger().mod(et).equals(new tt(t.substr(0,2),16).subtract(et))||(i=i.negate()),new nt(this,e,i);case 4:case 6:case 7:const r=(t.length-2)/2,n=t.substr(2,r),o=t.substr(r+2,r);return new nt(this,this.fromBigInteger(new tt(n,16)),this.fromBigInteger(new tt(o,16)));default:return null}}}};const{BigInteger:st,SecureRandom:at}=H,{ECCurveFp:ct}=ot,ht=new at,{curve:ut,G:ft,n:pt}=lt();function lt(){const t=new st("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),e=new st("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),i=new st("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),r=new ct(t,e,i),n=r.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:r,G:n,n:new st("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function gt(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}var dt={getGlobalCurve:function(){return ut},generateEcparam:lt,generateKeyPairHex:function(t,e,i){const r=(t?new st(t,e,i):new st(pt.bitLength(),ht)).mod(pt.subtract(st.ONE)).add(st.ONE),n=gt(r.toString(16),64),o=ft.multiply(r);return{privateKey:n,publicKey:"04"+gt(o.getX().toBigInteger().toString(16),64)+gt(o.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 r="03";return new st(t.substr(e+2,e),16).mod(new st("2")).equals(st.ZERO)&&(r="02"),r+i},utf8ToHex:function(t){const e=(t=unescape(encodeURIComponent(t))).length,i=[];for(let r=0;r<e;r++)i[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;const r=[];for(let t=0;t<e;t++){const e=i[t>>>2]>>>24-t%4*8&255;r.push((e>>>4).toString(16)),r.push((15&e).toString(16))}return r.join("")},leftPad:gt,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 r=0;r<2*t.length;r+=2)e[r>>>3]|=parseInt(t[i],10)<<24-r%8*4,i++;try{const i=[];for(let r=0;r<t.length;r++){const t=e[r>>>2]>>>24-r%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=gt(t,i+1)),i=t.length;for(let r=0;r<i;r+=2)e.push(parseInt(t.substr(r,2),16));return e},verifyPublicKey:function(t){const e=ut.decodePointHex(t);if(!e)return!1;const i=e.getX();return e.getY().square().equals(i.multiply(i.square()).add(i.multiply(ut.a)).add(ut.b))},comparePublicKeyHex:function(t,e){const i=ut.decodePointHex(t);if(!i)return!1;const r=ut.decodePointHex(e);return!!r&&i.equals(r)}};const mt=new Uint32Array(68),yt=new Uint32Array(64);function vt(t,e){const i=31&e;return t<<i|t>>>32-i}function _t(t,e){const i=[];for(let r=t.length-1;r>=0;r--)i[r]=255&(t[r]^e[r]);return i}function bt(t){return t^vt(t,9)^vt(t,17)}function Et(t){return t^vt(t,15)^vt(t,23)}function St(t){let e=8*t.length,i=e%512;i=i>=448?512-i%448-1:448-i-1;const r=new Array((i-7)/8),n=new Array(8);for(let t=0,e=r.length;t<e;t++)r[t]=0;for(let t=0,e=n.length;t<e;t++)n[t]=0;e=e.toString(2);for(let t=7;t>=0;t--)if(e.length>8){const i=e.length-8;n[t]=parseInt(e.substr(i),2),e=e.substr(0,i)}else e.length>0&&(n[t]=parseInt(e,2),e="");const o=new Uint8Array([...t,128,...r,...n]),s=new DataView(o.buffer,0),a=o.length/64,c=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<a;t++){mt.fill(0),yt.fill(0);const e=16*t;for(let t=0;t<16;t++)mt[t]=s.getUint32(4*(e+t),!1);for(let t=16;t<68;t++)mt[t]=Et(mt[t-16]^mt[t-9]^vt(mt[t-3],15))^vt(mt[t-13],7)^mt[t-6];for(let t=0;t<64;t++)yt[t]=mt[t]^mt[t+4];const i=2043430169,r=2055708042;let n,o,a,h,u,f=c[0],p=c[1],l=c[2],g=c[3],d=c[4],m=c[5],y=c[6],v=c[7];for(let t=0;t<64;t++)u=t>=0&&t<=15?i:r,n=vt(vt(f,12)+d+vt(u,t),7),o=n^vt(f,12),a=(t>=0&&t<=15?f^p^l:f&p|f&l|p&l)+g+o+yt[t],h=(t>=0&&t<=15?d^m^y:d&m|~d&y)+v+n+mt[t],g=l,l=vt(p,9),p=f,f=a,v=y,y=vt(m,19),m=d,d=bt(h);c[0]^=f,c[1]^=p,c[2]^=l,c[3]^=g,c[4]^=d,c[5]^=m,c[6]^=y,c[7]^=v}const h=[];for(let t=0,e=c.length;t<e;t++){const e=c[t];h.push((4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e)}return h}const wt=new Uint8Array(64),Tt=new Uint8Array(64);for(let t=0;t<64;t++)wt[t]=54,Tt[t]=92;var Dt={sm3:St,hmac:function(t,e){for(e.length>64&&(e=St(e));e.length<64;)e.push(0);const i=_t(e,wt),r=_t(e,Tt),n=St([...i,...t]);return St([...r,...n])}};const{BigInteger:It}=H,{encodeDer:At,decodeDer:kt}=Y,Bt=Dt.sm3,{G:Ct,curve:Rt,n:Ot}=dt.generateEcparam();function Mt(t,e,i="1234567812345678"){i=dt.utf8ToHex(i);const r=dt.leftPad(Ct.curve.a.toBigInteger().toRadix(16),64),n=dt.leftPad(Ct.curve.b.toBigInteger().toRadix(16),64),o=dt.leftPad(Ct.getX().toBigInteger().toRadix(16),64),s=dt.leftPad(Ct.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=Ct.curve.decodePointHex(e);a=dt.leftPad(t.getX().toBigInteger().toRadix(16),64),c=dt.leftPad(t.getY().toBigInteger().toRadix(16),64)}const h=dt.hexToArray(i+r+n+o+s+a+c),u=4*i.length;h.unshift(255&u),h.unshift(u>>8&255);const f=Bt(h);return dt.arrayToHex(Bt(f.concat(dt.hexToArray(t))))}function xt(){const t=dt.generateKeyPairHex(),e=Rt.decodePointHex(t.publicKey);return t.k=new It(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}var Gt={generateKeyPairHex:dt.generateKeyPairHex,compressPublicKeyHex:dt.compressPublicKeyHex,comparePublicKeyHex:dt.comparePublicKeyHex,doEncrypt:function(t,e,i=1){t="string"==typeof t?dt.hexToArray(dt.utf8ToHex(t)):Array.prototype.slice.call(t),e=dt.getGlobalCurve().decodePointHex(e);const r=dt.generateKeyPairHex(),n=new It(r.privateKey,16);let o=r.publicKey;o.length>128&&(o=o.substr(o.length-128));const s=e.multiply(n),a=dt.hexToArray(dt.leftPad(s.getX().toBigInteger().toRadix(16),64)),c=dt.hexToArray(dt.leftPad(s.getY().toBigInteger().toRadix(16),64)),h=dt.arrayToHex(Bt([].concat(a,t,c)));let u=1,f=0,p=[];const l=[].concat(a,c),g=()=>{p=Bt([...l,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,f=0};g();for(let e=0,i=t.length;e<i;e++)f===p.length&&g(),t[e]^=255&p[f++];const d=dt.arrayToHex(t);return 0===i?o+d+h:o+h+d},doDecrypt:function(t,e,i=1,{output:r="string"}={}){e=new It(e,16);let n=t.substr(128,64),o=t.substr(192);0===i&&(n=t.substr(t.length-64),o=t.substr(128,t.length-128-64));const s=dt.hexToArray(o),a=dt.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=dt.hexToArray(dt.leftPad(a.getX().toBigInteger().toRadix(16),64)),h=dt.hexToArray(dt.leftPad(a.getY().toBigInteger().toRadix(16),64));let u=1,f=0,p=[];const l=[].concat(c,h),g=()=>{p=Bt([...l,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,f=0};g();for(let t=0,e=s.length;t<e;t++)f===p.length&&g(),s[t]^=255&p[f++];return dt.arrayToHex(Bt([].concat(c,s,h)))===n.toLowerCase()?"array"===r?s:dt.arrayToUtf8(s):"array"===r?[]:""},doSignature:function(t,e,{pointPool:i,der:r,hash:n,publicKey:o,userId:s}={}){let a="string"==typeof t?dt.utf8ToHex(t):dt.arrayToHex(t);n&&(o=o||function(t){const e=Ct.multiply(new It(t,16)),i=dt.leftPad(e.getX().toBigInteger().toString(16),64),r=dt.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+i+r}(e),a=Mt(a,o,s));const c=new It(e,16),h=new It(a,16);let u=null,f=null,p=null;do{do{let t;t=i&&i.length?i.pop():xt(),u=t.k,f=h.add(t.x1).mod(Ot)}while(f.equals(It.ZERO)||f.add(u).equals(Ot));p=c.add(It.ONE).modInverse(Ot).multiply(u.subtract(f.multiply(c))).mod(Ot)}while(p.equals(It.ZERO));return r?At(f,p):dt.leftPad(f.toString(16),64)+dt.leftPad(p.toString(16),64)},doVerifySignature:function(t,e,i,{der:r,hash:n,userId:o}={}){let s,a,c="string"==typeof t?dt.utf8ToHex(t):dt.arrayToHex(t);if(n&&(c=Mt(c,i,o)),r){const t=kt(e);s=t.r,a=t.s}else s=new It(e.substring(0,64),16),a=new It(e.substring(64),16);const h=Rt.decodePointHex(i),u=new It(c,16),f=s.add(a).mod(Ot);if(f.equals(It.ZERO))return!1;const p=Ct.multiply(a).add(h.multiply(f)),l=u.add(p.getX().toBigInteger()).mod(Ot);return s.equals(l)},getPoint:xt,verifyPublicKey:dt.verifyPublicKey};const{sm3:Ft,hmac:qt}=Dt;function Pt(t){return t.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join("")}function Ut(t){const e=[];let i=t.length;var r,n;i%2!=0&&(n=i+1,t=(r=t).length>=n?r:new Array(n-r.length+1).join("0")+r),i=t.length;for(let r=0;r<i;r+=2)e.push(parseInt(t.substr(r,2),16));return e}const Nt=16,Vt=[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],Lt=[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 Kt(t){const e=[];for(let i=0,r=t.length;i<r;i+=2)e.push(parseInt(t.substr(i,2),16));return e}function zt(t,e){return t<<e|t>>>32-e}function Ht(t){return(255&Vt[t>>>24&255])<<24|(255&Vt[t>>>16&255])<<16|(255&Vt[t>>>8&255])<<8|255&Vt[255&t]}function jt(t){return t^zt(t,2)^zt(t,10)^zt(t,18)^zt(t,24)}function Jt(t){return t^zt(t,13)^zt(t,23)}function Wt(t,e,i){const r=new Array(4),n=new Array(4);for(let e=0;e<4;e++)n[0]=255&t[4*e],n[1]=255&t[4*e+1],n[2]=255&t[4*e+2],n[3]=255&t[4*e+3],r[e]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];for(let t,e=0;e<32;e+=4)t=r[1]^r[2]^r[3]^i[e+0],r[0]^=jt(Ht(t)),t=r[2]^r[3]^r[0]^i[e+1],r[1]^=jt(Ht(t)),t=r[3]^r[0]^r[1]^i[e+2],r[2]^=jt(Ht(t)),t=r[0]^r[1]^r[2]^i[e+3],r[3]^=jt(Ht(t));for(let t=0;t<16;t+=4)e[t]=r[3-t/4]>>>24&255,e[t+1]=r[3-t/4]>>>16&255,e[t+2]=r[3-t/4]>>>8&255,e[t+3]=255&r[3-t/4]}function Xt(t,e,i,{padding:r="pkcs#7",mode:n,iv:o=[],output:s="string"}={}){if("cbc"===n&&("string"==typeof o&&(o=Kt(o)),16!==o.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=Kt(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,r=t.length;i<r;i++){const r=t.codePointAt(i);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>>6),e.push(128|63&r);else if(r<=55295||r>=57344&&r<=65535)e.push(224|r>>>12),e.push(128|r>>>6&63),e.push(128|63&r);else{if(!(r>=65536&&r<=1114111))throw e.push(r),new Error("input is not supported");i++,e.push(240|r>>>18&28),e.push(128|r>>>12&63),e.push(128|r>>>6&63),e.push(128|63&r)}}return e}(t):Kt(t):[...t],("pkcs#5"===r||"pkcs#7"===r)&&0!==i){const e=Nt-t.length%Nt;for(let i=0;i<e;i++)t.push(e)}const a=new Array(32);!function(t,e,i){const r=new Array(4),n=new Array(4);for(let e=0;e<4;e++)n[0]=255&t[0+4*e],n[1]=255&t[1+4*e],n[2]=255&t[2+4*e],n[3]=255&t[3+4*e],r[e]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];r[0]^=2746333894,r[1]^=1453994832,r[2]^=1736282519,r[3]^=2993693404;for(let t,i=0;i<32;i+=4)t=r[1]^r[2]^r[3]^Lt[i+0],e[i+0]=r[0]^=Jt(Ht(t)),t=r[2]^r[3]^r[0]^Lt[i+1],e[i+1]=r[1]^=Jt(Ht(t)),t=r[3]^r[0]^r[1]^Lt[i+2],e[i+2]=r[2]^=Jt(Ht(t)),t=r[0]^r[1]^r[2]^Lt[i+3],e[i+3]=r[3]^=Jt(Ht(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=o,u=t.length,f=0;for(;u>=Nt;){const e=t.slice(f,f+16),r=new Array(16);if("cbc"===n)for(let t=0;t<Nt;t++)0!==i&&(e[t]^=h[t]);Wt(e,r,a);for(let t=0;t<Nt;t++)"cbc"===n&&0===i&&(r[t]^=h[t]),c[f+t]=r[t];"cbc"===n&&(h=0!==i?r:e),u-=Nt,f+=Nt}if(("pkcs#5"===r||"pkcs#7"===r)&&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,r=t.length;i<r;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 $t={sm2:Gt,sm3:function(t,e){if(t="string"==typeof t?function(t){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t.codePointAt(i);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>>6),e.push(128|63&r);else if(r<=55295||r>=57344&&r<=65535)e.push(224|r>>>12),e.push(128|r>>>6&63),e.push(128|63&r);else{if(!(r>=65536&&r<=1114111))throw e.push(r),new Error("input is not supported");i++,e.push(240|r>>>18&28),e.push(128|r>>>12&63),e.push(128|r>>>6&63),e.push(128|63&r)}}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?Ut(i):Array.prototype.slice.call(i),Pt(qt(t,i))}return Pt(Ft(t))},sm4:{encrypt:(t,e,i)=>Xt(t,e,1,i),decrypt:(t,e,i)=>Xt(t,e,0,i)}}.sm2;var Zt=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 n,this.logger=new F(t),this.remotePlugin=new Map,this.Types=C}return e.usePlugin=function(t,i,r){if(i){for(var n=!1,o=0,s=e.plugins.length;o<s;o++){if(e.plugins[o].name===i){e.plugins[o].plugin=t,e.plugins[o].options=r||{},n=!0;break}}n||e.plugins.push({name:i,plugin:t,options:r})}else e.plugins.push({plugin:t})},e.prototype.init=function(t){var i,r=this;this.inited?console.log("init can be call only one time"):t&&o(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 F(this.name,t.log),this.configManager=new G(this,t),this.appBridge=new q(t,this.configManager),this.bridgeReport=this.appBridge.bridgeInject(),this.requestManager=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?(this.inited=!0,this.emit(C.Init)):(t.enable_encryption&&"sm"===t.encryption_type&&this.initCrypto(),this.configManager.set({app_id:t.app_id}),this.eventManager=new P,this.tokenManager=new K,this.sessionManager=new L,Promise.all([new Promise(function(t){r.once(C.TokenComplete,function(){t(!0)})}),new Promise(function(t){r.once(C.Start,function(){t(!0)})})]).then(function(){try{e.plugins.reduce(function(t,e){var i=e.plugin,n=e.options,o=Object.assign(r.initConfig,n),s=new i;return s.apply(r,o),t.push(s),t},r.pluginInstances)}catch(t){console.log("load plugin error, "+t.message),r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}r.sdkReady=!0,r.emit(C.Ready),r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:r.configManager.get("user")}),r.logger.info("appid: "+t.app_id+", userInfo:"+JSON.stringify(r.configManager.get("user"))),r.logger.info("appid: "+t.app_id+", sdk is ready, version is "+k+", you can report now !!!");try{(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(t){r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}r.pageView(),r.on(C.TokenChange,function(e){"webid"!==e.type&&"anonymous_id"!==e.type||r.pageView(),r.logger.info("appid: "+t.app_id+" token change, new userInfo:"+JSON.stringify(r.configManager.get("user"))),r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:r.configManager.get("user")})}),r.on(C.TokenReset,function(){r.logger.info("appid: "+t.app_id+" token reset, new userInfo:"+JSON.stringify(r.configManager.get("user"))),r.emit(v.DEBUGGER_MESSAGE,{type:v.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:r.configManager.get("user")})}),r.on(C.RouteChange,function(e){e.init||t.disable_route_report||r.pageView()})}),this.tokenManager.apply(this,t),this.eventManager.apply(this,t),this.sessionManager.apply(this,t),this.inited=!0,this.emit(C.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&&o(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 r=this.configManager.getStore();r&&(i=Object.assign(r,e)),this.configManager.setStore(e)}i.web_id,i.user_unique_id;var n=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]])}return i}(i,["web_id","user_unique_id"]);i.hasOwnProperty("web_id")&&this.emit(C.ConfigWebId,i.web_id),i.hasOwnProperty("user_unique_id")&&this.emit(C.ConfigUuid,i.user_unique_id),this.configManager.set(n),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(C.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(C.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(C.Ready)))},e.prototype.event=function(t,e){var i=this;try{if(this.initConfig&&this.initConfig.disable_track_event)return;var r=[];if(Array.isArray(t))t.forEach(function(t){var e=i.processEvent(t[0],t[1]||{});e&&r.push(e)});else{var n=this.processEvent(t,e);if(!n)return;r.push(n)}this.bridgeReport?r.forEach(function(t){var e=t.event,r=t.params;i.appBridge.onEventV3(e,JSON.stringify(r))}):r.length&&(this.emit(C.Event,r),this.emit(C.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=[],r=this.processEvent(t,e||{});r&&(i.push(r),i.length&&(this.emit(C.BeconEvent,i),this.emit(C.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 r=e;"object"!=typeof r&&(r={}),r.profile?delete r.profile:r.event_index=s();var n=void 0;return r.local_ms?(n=r.local_ms,delete r.local_ms):n=+new Date,{event:i,params:r,local_time_ms:n,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)},r=t({},i,e);this.event("predefine_pageview",r)}else console.warn("predefinePageView should call after init")},e.prototype.clearEventCache=function(){this.emit(C.CleanEvents)},e.prototype.setWebIDviaUnionID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_unionid:t}),this.emit(C.CustomWebId)}},e.prototype.setWebIDviaOpenID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_openid:t}),this.emit(C.CustomWebId)}},e.prototype.setAnonymousId=function(t){this.emit(C.AnonymousId,t)},e.prototype.setNativeAppId=function(t){this.bridgeReport&&this.appBridge.setNativeAppId(t)},e.prototype.enableTransPort=function(){this.configManager.setEnableClientTransport(!0)},e.prototype.disableTransPort=function(){this.configManager.setEnableClientTransport(!1)},e.prototype.resetStayDuration=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(C.ResetStay,{url_path:t,title:e,url:i},C.Stay)},e.prototype.resetStayParams=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(C.SetStay,{url_path:t,title:e,url:i},C.Stay)},e.prototype.getToken=function(e,i){var r=this;if(this.inited){var n=!1,o=function(i){if(!n){n=!0;var o=r.configManager.get().user;return i&&(o.tobid=i,o["diss".split("").reverse().join("")]=i),e(t({},o))}},s=function(){r.tokenManager.getTobId().then(function(t){o(t)})};this.sdkReady?s():(i&&setTimeout(function(){o()},i),this.on(C.Ready,function(){s()}))}else this.logger.warn("getToken must be use after function init")},e.prototype.startTrackEvent=function(t){t&&this.emit(C.TrackDurationStart,t,C.TrackDuration)},e.prototype.endTrackEvent=function(t,e){void 0===e&&(e={}),t&&this.emit(C.TrackDurationEnd,{eventName:t,params:e},C.TrackDuration)},e.prototype.pauseTrackEvent=function(t){t&&this.emit(C.TrackDurationPause,t,C.TrackDuration)},e.prototype.resumeTrackEvent=function(t){t&&this.emit(C.TrackDurationResume,t,C.TrackDuration)},e.prototype.profileSet=function(t){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(t)):this.emit(C.ProfileSet,t,C.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(C.ProfileSetOnce,t,C.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(C.ProfileIncrement,t,C.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(C.ProfileUnset,t,C.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(C.ProfileAppend,t,C.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(C.AbExternalVersion,"string"==typeof t&&t?(""+t).trim():null,C.Ab)},e.prototype.getVar=function(t,e,i){this.bridgeReport?this.appBridge.getVar(t,e,i):this.emit(C.AbVar,{name:t,defaultValue:e,callback:i},C.Ab)},e.prototype.getAllVars=function(t){this.bridgeReport?this.appBridge.getAllVars(t):this.emit(C.AbAllVars,t,C.Ab)},e.prototype.getABconfig=function(t,e){this.emit(C.AbConfig,{params:t,callback:e},C.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(C.AbVersionChangeOn,t,C.Ab),function(){e.emit(C.AbVersionChangeOff,t,C.Ab)}},e.prototype.offAbSdkVersionChange=function(t){this.emit(C.AbVersionChangeOff,t,C.Ab)},e.prototype.openOverlayer=function(){this.emit(C.AbOpenLayer,"",C.Ab)},e.prototype.closeOverlayer=function(){this.emit(C.AbCloseLayer,"",C.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=(o=JSON.stringify(t),s=this.publicKey,void 0===(a=1)&&(a=1),"04"+$t.doEncrypt(o,s,a)),r=p(i);e=new Uint8Array(r)}else e="data="+(n=JSON.stringify(t),window.btoa?window.btoa(encodeURIComponent(n)):encodeURIComponent(n));return e}catch(e){return t}var n,o,s,a},e.prototype.destoryInstance=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(C.TokenComplete))},e.prototype.destoryInstace=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(C.TokenComplete))},e.plugins=[],e}(),Qt=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",this.eventCheck=new B(t,e),this.cache={},this.collect.on(C.ProfileSet,function(t){i.setProfile(t)}),this.collect.on(C.ProfileSetOnce,function(t){i.setOnceProfile(t)}),this.collect.on(C.ProfileUnset,function(t){i.unsetProfile(t)}),this.collect.on(C.ProfileIncrement,function(t){i.incrementProfile(t)}),this.collect.on(C.ProfileAppend,function(t){i.appendProfile(t)}),this.collect.on(C.ProfileClear,function(){i.cache={}}),this.ready(C.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 r=function(t){i[t].length&&i[t].forEach(function(i){e.collect.hook.emit(t,i)})};for(var n in i)r(n)}},e.prototype.report=function(t,e){var i=this;void 0===e&&(e={});try{if(this.config.disable_track_event)return;var r=[];r.push(this.collect.processEvent(t,e));var n=this.collect.eventManager.merge(r,!0),o=this.collect.cryptoData(n);this.collect.configManager.getUrl("profile");this.collect.requestManager.useRequest({url:this.reportUrl,data:o,timeout:1e5,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header,zip:!0,success:function(t,e,r,n,o){t&&0!==t.e?i.collect.emit(C.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:n,endTime:Date.now(),status:o}):i.collect.emit(C.SubmitSuccess,{eventData:e,res:t,response:t,startTime:n,endTime:Date.now(),status:o})},fail:function(t,e,r){i.collect.emit(C.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:r,endTime:Date.now()})}}),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 r in e)"string"==typeof e[r]||"Array"===Object.prototype.toString.call(e[r]).slice(8,-1)?i[r]=e[r]:console.warn("please check the value of param: "+r+", 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 r={};for(var n in t)"string"==typeof t[n]||"number"==typeof t[n]||"Array"===Object.prototype.toString.call(t[n]).slice(8,-1)?r[n]=t[n]:console.warn("please check the value of params:"+n+", must be string,number,Array !!!");var o=Object.keys(r);if(!o.length)return;var s=Date.now();return o.filter(function(r){var n=i.cache[r];return e?!n:!(n&&i.compare(n.val,t[r])&&s-n.timestamp<i.duration)}).reduce(function(t,e){return t[e]=r[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}(),Yt=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,r=Date.now()+e;return i=window.setTimeout(function n(){var o=Date.now()-r;t(),r+=e,i=window.setTimeout(n,Math.max(0,e-o))},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 r=this.collect.Types;this.collect.on(r.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}(),te=500,ee=5005;var ie=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(),r=i.header,n={events:[e],user:i.user,header:r};t.eventStore(n)},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 r=JSON.parse(JSON.stringify(t));e=t,Array.isArray(e)?r.forEach(function(t){i.fetchLog(t)}):this.fetchLog(r)}catch(t){console.log("web verify post error ~")}},t.prototype.fetchLog=function(t){!function(t,e,i,r,n,o,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),r&&(u.withCredentials=!0),i&&(u.timeout=i,u.ontimeout=function(){o&&o(e,ee)}),u.onload=function(){if(n){var t=null;if(u.responseText){try{t=JSON.parse(u.responseText)}catch(e){t={}}n(t,e)}}},u.onerror=function(){u.abort(),o&&o(e,te)},c?u.send(e):u.send(JSON.stringify(e))}catch(t){}}(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}();Zt.usePlugin(ie,"verifyH"),Zt.usePlugin(Qt,"profile"),Zt.usePlugin(Yt,"heartbeat");var re=new Zt("default"),ne=Zt;export{ne as Collector,re as default};
|