text: "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}"object"!==("undefined"==typeof JSON?"undefined":_typeof(JSON))&&(JSON={}),function(){var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta,rep;function f(e){return e<10?"0"+e:e}function this_value(){return this.valueOf()}function quote(e){return rx_escapable.lastIndex=0,rx_escapable.test(e)?'"'+e.replace(rx_escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var r,n,i,o,s,a=gap,c=t[e];switch(c&&"object"===_typeof(c)&&"function"==typeof c.toJSON&&(c=c.toJSON(e)),"function"==typeof rep&&(c=rep.call(t,e,c)),_typeof(c)){case"string":return quote(c);case"number":return isFinite(c)?String(c):"null";case"boolean":case"null":return String(c);case"object":if(!c)return"null";if(gap+=indent,s=[],"[object Array]"===Object.prototype.toString.apply(c)){for(o=c.length,r=0;r<o;r+=1)s[r]=str(r,c)||"null";return i=0===s.length?"[]":gap?"[\n"+gap+s.join(",\n"+gap)+"\n"+a+"]":"["+s.join(",")+"]",gap=a,i}if(rep&&"object"===_typeof(rep))for(o=rep.length,r=0;r<o;r+=1)"string"==typeof rep[r]&&(i=str(n=rep[r],c))&&s.push(quote(n)+(gap?": ":":")+i);else for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(i=str(n,c))&&s.push(quote(n)+(gap?": ":":")+i);return i=0===s.length?"{}":gap?"{\n"+gap+s.join(",\n"+gap)+"\n"+a+"}":"{"+s.join(",")+"}",gap=a,i}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value),"function"!=typeof JSON.stringify&&(meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(e,t,r){var n;if(gap="",indent="","number"==typeof r)for(n=0;n<r;n+=1)indent+=" ";else"string"==typeof r&&(indent=r);if(rep=t,t&&"function"!=typeof t&&("object"!==_typeof(t)||"number"!=typeof t.length))throw new Error("JSON.stringify");return str("",{"":e})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){var j;function walk(e,t){var r,n,i=e[t];if(i&&"object"===_typeof(i))for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(void 0!==(n=walk(i,r))?i[r]=n:delete i[r]);return reviver.call(e,t,i)}if(text=String(text),rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();var Config={LIB_VERSION:"1.3.0"},MAX_REFERRER_STRING_LENGTH=200,ArrayProto=Array.prototype,ObjProto=Object.prototype,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,nativeForEach=ArrayProto.forEach,breaker={},_={each:function(e,t,r){if(null!==e)if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,i=e.length;n<i;n++)if(n in e&&t.call(r,e[n],n,e)===breaker)return}else for(var o in e)if(hasOwnProperty.call(e,o)&&t.call(r,e[o],o,e)===breaker)return},extend:function(e){return _.each(slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e},formatDate:function(e){function t(e){return e<10?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+((r=e.getMilliseconds())<10?"00"+r:r<100?"0"+r:r);var r},formatJsonString:function(e){try{return JSON.stringify(e,null,8)}catch(t){return JSON.stringify(e)}},searchObjDate:function(e){(_.check.isObject(e)||_.check.isArray(e))&&_.each(e,function(t,r){_.check.isObject(t)||_.check.isArray(t)?_.searchObjDate(e[r]):_.check.isDate(t)&&(e[r]=_.formatDate(t))})}};_.check={isUndefined:function(e){return void 0===e},isObject:function(e){return"[object Object]"===toString.call(e)&&null!==e},isEmptyObject:function(e){if(_.check.isObject(e)){for(var t in e)if(hasOwnProperty.call(e,t))return!1;return!0}return!1},isArray:function(e){return"[object Array]"===toString.call(e)},isString:function(e){return"[object String]"===toString.call(e)},isDate:function(e){return"[object Date]"===toString.call(e)},isNumber:function(e){return"[object Number]"===toString.call(e)},isBoolean:function(e){return"[object Boolean]"===toString.call(e)},isJSONString:function(e){try{JSON.parse(e)}catch(e){return!1}return!0}},_.UUID=function(){var e=function(){for(var e=1*new Date,t=0;e===1*new Date;)t++;return e.toString(16)+t.toString(16)};return function(){var t=String(screen.height*screen.width);t=t&&/\d{5,}/.test(t)?t.toString(16):String(31242*Math.random()).replace(".","").slice(0,8);var r=e()+"-"+Math.random().toString(16).replace(".","")+"-"+function(){var e,t,r=navigator.userAgent,n=[],i=0;function o(e,t){var r,i=0;for(r=0;r<t.length;r++)i|=n[r]<<8*r;return e^i}for(e=0;e<r.length;e++)t=r.charCodeAt(e),n.unshift(255&t),n.length>=4&&(i=o(i,n),n=[]);return n.length>0&&(i=o(i,n)),i.toString(16)}()+"-"+t+"-"+e();return r||(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15)}}(),_.UUIDv4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})},_.getReferrer=function(e){var t=e||document.referrer;return"string"!=typeof t?"取值异常_referrer异常_"+String(t):(0===t.indexOf("https://www.baidu.com/")&&(t=t.split("?")[0]),"string"==typeof(t=t.slice(0,MAX_REFERRER_STRING_LENGTH))?t:"")},_.url=function(){function e(){return new RegExp(/(.*?)\.?([^\.]*?)\.(com|net|org|biz|ws|in|me|co\.uk|co|org\.uk|ltd\.uk|plc\.uk|me\.uk|edu|mil|br\.com|cn\.com|eu\.com|hu\.com|no\.com|qc\.com|sa\.com|se\.com|se\.net|us\.com|uy\.com|ac|co\.ac|gv\.ac|or\.ac|ac\.ac|af|am|as|at|ac\.at|co\.at|gv\.at|or\.at|asn\.au|com\.au|edu\.au|org\.au|net\.au|id\.au|be|ac\.be|adm\.br|adv\.br|am\.br|arq\.br|art\.br|bio\.br|cng\.br|cnt\.br|com\.br|ecn\.br|eng\.br|esp\.br|etc\.br|eti\.br|fm\.br|fot\.br|fst\.br|g12\.br|gov\.br|ind\.br|inf\.br|jor\.br|lel\.br|med\.br|mil\.br|net\.br|nom\.br|ntr\.br|odo\.br|org\.br|ppg\.br|pro\.br|psc\.br|psi\.br|rec\.br|slg\.br|tmp\.br|tur\.br|tv\.br|vet\.br|zlg\.br|br|ab\.ca|bc\.ca|mb\.ca|nb\.ca|nf\.ca|ns\.ca|nt\.ca|on\.ca|pe\.ca|qc\.ca|sk\.ca|yk\.ca|ca|cc|ac\.cn|net\.cn|com\.cn|edu\.cn|gov\.cn|org\.cn|bj\.cn|sh\.cn|tj\.cn|cq\.cn|he\.cn|nm\.cn|ln\.cn|jl\.cn|hl\.cn|js\.cn|zj\.cn|ah\.cn|gd\.cn|gx\.cn|hi\.cn|sc\.cn|gz\.cn|yn\.cn|xz\.cn|sn\.cn|gs\.cn|qh\.cn|nx\.cn|xj\.cn|tw\.cn|hk\.cn|mo\.cn|cn|cx|cz|de|dk|fo|com\.ec|tm\.fr|com\.fr|asso\.fr|presse\.fr|fr|gf|gs|co\.il|net\.il|ac\.il|k12\.il|gov\.il|muni\.il|ac\.in|co\.in|org\.in|ernet\.in|gov\.in|net\.in|res\.in|is|it|ac\.jp|co\.jp|go\.jp|or\.jp|ne\.jp|ac\.kr|co\.kr|go\.kr|ne\.kr|nm\.kr|or\.kr|li|lt|lu|asso\.mc|tm\.mc|com\.mm|org\.mm|net\.mm|edu\.mm|gov\.mm|ms|nl|no|nu|pl|ro|org\.ro|store\.ro|tm\.ro|firm\.ro|www\.ro|arts\.ro|rec\.ro|info\.ro|nom\.ro|nt\.ro|se|si|com\.sg|org\.sg|net\.sg|gov\.sg|sk|st|tf|ac\.th|co\.th|go\.th|mi\.th|net\.th|or\.th|tm|to|com\.tr|edu\.tr|gov\.tr|k12\.tr|net\.tr|org\.tr|com\.tw|org\.tw|net\.tw|ac\.uk|uk\.com|uk\.net|gb\.com|gb\.net|vg|sh|kz|ch|info|ua|gov|name|pro|ie|hk|com\.hk|org\.hk|net\.hk|edu\.hk|us|tk|cd|by|ad|lv|eu\.lv|bz|es|jp|cl|ag|mobi|eu|co\.nz|org\.nz|net\.nz|maori\.nz|iwi\.nz|io|la|md|sc|sg|vc|tw|travel|my|se|tv|pt|com\.pt|edu\.pt|asia|fi|com\.ve|net\.ve|fi|org\.ve|web\.ve|info\.ve|co\.ve|tel|im|gr|ru|net\.ru|org\.ru|hr|com\.hr|ly|xyz)$/)}function t(e,t){var r=e.charAt(0),n=t.split(r);return r===e?n:n[(e=parseInt(e.substring(1),10))<0?n.length+e:e-1]}function r(e,t){for(var r,n=e.charAt(0),i=t.split("&"),o=[],s={},a=[],c=e.substring(1),u=0,p=i.length;u<p;u++)if((o=i[u].match(/(.*?)=(.*)/))||(o=[i[u],i[u],""]),""!==o[1].replace(/\s/g,"")){if(o[2]=(r=o[2]||"",_.decodeURIComponent(r.replace(/\+/g," "))),c===o[1])return o[2];(a=o[1].match(/(.*)\[([0-9]+)\]/))?(s[a[1]]=s[a[1]]||[],s[a[1]][a[2]]=o[2]):s[o[1]]=o[2]}return n===e?s:s[c]}return function(n,i){var o,s={};if("tld?"===n)return e();if(i=i||window.location.toString(),!n)return i;if(n=n.toString(),o=i.match(/^mailto:([^\/].+)/))s.protocol="mailto",s.email=o[1];else{if((o=i.match(/(.*?)\/#\!(.*)/))&&(i=o[1]+o[2]),(o=i.match(/(.*?)#(.*)/))&&(s.hash=o[2],i=o[1]),s.hash&&n.match(/^#/))return r(n,s.hash);if((o=i.match(/(.*?)\?(.*)/))&&(s.query=o[2],i=o[1]),s.query&&n.match(/^\?/))return r(n,s.query);if((o=i.match(/(.*?)\:?\/\/(.*)/))&&(s.protocol=o[1].toLowerCase(),i=o[2]),(o=i.match(/(.*?)(\/.*)/))&&(s.path=o[2],i=o[1]),s.path=(s.path||"").replace(/^([^\/])/,"/$1").replace(/\/$/,""),n.match(/^[\-0-9]+$/)&&(n=n.replace(/^([^\/])/,"/$1")),n.match(/^\//))return t(n,s.path.substring(1));if((o=t("/-1",s.path.substring(1)))&&(o=o.match(/(.*?)\.(.*)/))&&(s.file=o[0],s.filename=o[1],s.fileext=o[2]),(o=i.match(/(.*)\:([0-9]+)$/))&&(s.port=o[2],i=o[1]),(o=i.match(/(.*?)@(.*)/))&&(s.auth=o[1],i=o[2]),s.auth&&(o=s.auth.match(/(.*)\:(.*)/),s.user=o?o[1]:s.auth,s.pass=o?o[2]:void 0),s.hostname=i.toLowerCase(),"."===n.charAt(0))return t(n,s.hostname);e()&&(o=s.hostname.match(e()))&&(s.tld=o[3],s.domain=o[2]?o[2]+"."+o[3]:void 0,s.sub=o[1]||void 0),s.port=s.port||("https"===s.protocol?"443":"80"),s.protocol=s.protocol||("443"===s.port?"https":"http")}return n in s?s[n]:"{}"===n?s:""}}(),_.hashCode=function(e){if("string"!=typeof e)return 0;var t=0;if(0===e.length)return t;for(var r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return t},_.decodeURIComponent=function(e){var t="";try{t=decodeURIComponent(e)}catch(r){t=e}return t},_.encodeURIComponent=function(e){var t="";try{t=encodeURIComponent(e)}catch(r){t=e}return t},_.utf8Encode=function(e){var t,r,n,i,o="";for(t=r=0,n=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i<n;i++){var s=e.charCodeAt(i),a=null;s<128?r++:a=s>127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==a&&(r>t&&(o+=e.substring(t,r)),o+=a,t=r=i+1)}return r>t&&(o+=e.substring(t,e.length)),o},_.base64Encode=function(e){var t,r,n,i,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(o=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,r=o>>12&63,n=o>>6&63,i=63&o,p[c++]=s.charAt(t)+s.charAt(r)+s.charAt(n)+s.charAt(i)}while(a<e.length);switch(u=p.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u},_.cookie={get:function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return _.decodeURIComponent(i.substring(t.length,i.length))}return null},set:function(e,t,r,n,i){var o="",s="",a="";if(r=null===r?73e3:r,n){var c=_.url("domain",location.href);o=c?"; domain=."+c:""}if(r){var u=new Date;"s"===String(r).slice(-1)?u.setTime(u.getTime()+1e3*Number(String(r).slice(0,-1))):u.setTime(u.getTime()+24*r*60*60*1e3),s="; expires="+u.toGMTString()}i&&(a="; secure");var p=e+"="+encodeURIComponent(t)+s+"; path=/"+o+a;return document.cookie=p,p},remove:function(e,t){_.cookie.set(e,"",-1,t)}},_.localStorage={get:function(e){try{return window.localStorage.getItem(e)}catch(e){_.localStorage.error(e)}},parse:function(e){var t;try{t=JSON.parse(_.localStorage.get(e))||null}catch(e){_.localStorage.error(e)}return t},set:function(e,t){try{window.localStorage.setItem(e,t)}catch(e){_.localStorage.error(e)}},remove:function(e){try{window.localStorage.removeItem(e)}catch(e){_.localStorage.error(e)}},error:function(e){console.error("localStorage error: "+e)},isSupported:function(){var e=!0;try{var t="__thinkingdatasupport__",r="testIsSupportStorage";_.localStorage.set(t,r),_.localStorage.get(t)!==r&&(e=!1),_.localStorage.remove(t)}catch(t){e=!1}return e}},_.stripEmptyProperties=function(e){var t={};return _.each(e,function(e,r){_.check.isString(e)&&e.length>0&&(t[r]=e)}),t},_.info={os:function(){var e=navigator.userAgent;return/Windows/i.test(e)?/Phone/.test(e)||/WPDesktop/.test(e)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(e)?"iOS":/Android/.test(e)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":""},browser:function(){var e={type:"",version:""};try{var t=navigator.userAgent.toLowerCase(),r=[];if(null!==t.match(/baidubrowser/)?(e.type="baidu",r.push(/baidubrowser\/([\d.]+)/)):null!==t.match(/bidubrowser/)?(e.type="baidu",r.push(/bidubrowser\/([\d.]+)/)):null!==t.match(/edga/)?(e.type="edge",r.push(/edga\/([\d.]+)/)):null!==t.match(/edgios/)?(e.type="edge",r.push(/edgios\/([\d.]+)/)):null!==t.match(/liebaofast/)?(e.type="liebao",r.push(/liebaofast\/([\d.]+)/)):null!==t.match(/sogoumobilebrowser/)?(e.type="sogou",r.push(/sogoumobilebrowser\/([\d.]+)/)):null!==t.match(/lbbrowser/)?(e.type="liebao",r.push(/lbbrowser\/([\d.]+)/)):null!==t.match(/crios/)?(e.type="chrome",r.push(/crios\/([\d.]+)/)):null!==t.match(/qihoobrowser/)?(e.type="360",r.push(/qihoobrowser\/([\d.]+)/)):null!==t.match(/mxios/)?(e.type="maxthon",r.push(/mxios\/([\d.]+)/)):null!==t.match(/fxios/)?(e.type="firefox",r.push(/fxios\/([\d.\w]+)/)):null!==t.match(/edge/)?(e.type="edge",r.push(/edge\/([\d.]+)/)):null!==t.match(/metasr/)?(e.type="sogou",r.push(/metasr ([\d.]+)/)):null!==t.match(/micromessenger/)?(e.type="micromessenger",r.push(/micromessenger\/([\d.]+)/)):null!==t.match(/mqqbrowser/)?(e.type="qq",r.push(/mqqbrowser\/([\d.]+)/)):null!==t.match(/qqbrowserlite/)?(e.type="qq",r.push(/qqbrowserlite\/([\d.]+)/)):null!==t.match(/tencenttraveler/)?(e.type="qq",r.push(/tencenttraveler\/([\d.]+)/)):null!==t.match(/qqbrowser/)?(e.type="qq",r.push(/qqbrowser\/([\d.]+)/)):null!==t.match(/maxthon/)?(e.type="maxthon",r.push(/maxthon\/([\d.]+)/)):null!==t.match(/ubrowser/)?(e.type="uc",r.push(/ubrowser\/([\d.]+)/)):null!==t.match(/ucbrowser/)?(e.type="uc",r.push(/ucbrowser\/([\d.]+)/)):null!==t.match(/firefox/)?(e.type="firefox",r.push(/firefox\/([\d.]+)/)):null!==t.match(/opera/)?(e.type="opera",r.push(/opera\/([\d.]+)/)):null!==t.match(/opr/)?(e.type="opera",r.push(/opr\/([\d.]+)/)):null!==t.match(/chrome/)?(e.type="chrome",r.push(/chrome\/([\d.]+)/)):null!==t.match(/safari/)?(e.type="safari",r.push(/version\/([\d.]+)/)):null===t.match(/trident/)&&null===t.match(/msie/)||(e.type="ie"),"ie"===e.type){var n=t.match(/trident\/([\d.]+)/)?t.match(/trident\/([\d.]+)/)[1]:"",i=t.match(/msie ([\d.]+)/)?t.match(/msie ([\d.]+)/)[1]:"";""!==n?e.version=String(parseInt(n)+4):""!==i&&(e.version=i)}else r&&(e.version=t.match(r[0])?t.match(r[0])[1]:"")}catch(e){Log.w("getting browser info failed due to ",e)}return e},properties:function(){var e=_.info.browser();return _.extend({"#os":_.info.os(),"#lib_version":Config.LIB_VERSION,"#lib":"js","#screen_height":screen.height,"#screen_width":screen.width,"#browser":e.type,"#browser_version":e.version})},pageProperties:function(){var e=_.getReferrer();return _.stripEmptyProperties({"#referrer":e,"#referrer_host":e?_.url("hostname",e):e,"#url":location.href,"#url_path":location.pathname,"#title":document.title})}};var Log=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"i",value:function(){if(!this.showLog)return!1;if(!0!==this.showLog&&"string"!==this.showLog||(arguments[0]=_.formatJsonString(arguments[0])),"object"===("undefined"==typeof console?"undefined":_typeof(console))&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}},{key:"w",value:function(){if(!this.showLog)return!1;if(!0!==this.showLog&&"string"!==this.showLog||(arguments[0]=_.formatJsonString(arguments[0])),"object"===("undefined"==typeof console?"undefined":_typeof(console))&&console.warn)try{return console.warn.apply(console,arguments)}catch(e){console.warn(arguments[0])}}}]),e}(),KEY_NAME_MATCH_REGEX=/^[a-zA-Z][a-zA-Z0-9_]{0,49}$/,PropertyChecker=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"stripProperties",value:function(e){return _.check.isObject(e)?(_.each(e,function(e,t){_.check.isString(e)||_.check.isNumber(e)||_.check.isDate(e)||_.check.isBoolean(e)||_.check.isArray(e)||Log.w("您的数据-",t,e,"-格式不满足要求，可能无法正确入库. 属性值只支持 String, Number, Date, Boolean, Array")}),e):e}},{key:"_checkPropertiesKey",value:function(e){var t=!0;return _.each(e,function(e,r){KEY_NAME_MATCH_REGEX.test(r)||(Log.w("不合法的 KEY 值: "+r),t=!1)}),t}},{key:"event",value:function(e){return!(!_.check.isString(e)||!KEY_NAME_MATCH_REGEX.test(e))||(Log.w("请检查参数格式, eventName 必须是英文字母或者 '_' 开头, 包含字母和数字的不超过50个字符的字符串: "+e),!1)}},{key:"propertyName",value:function(e){return!(!_.check.isString(e)||!KEY_NAME_MATCH_REGEX.test(e))||(Log.w("请检查参数格式, propertyName 必须是英文字母或者 '_' 开头, 包含字母和数字的不超过50个字符的字符串: "+e),!1)}},{key:"properties",value:function(e){return this.stripProperties(e),!e||(_.check.isObject(e)?!!this._checkPropertiesKey(e)||(Log.w("请检查参数格式, properties 的 key 只能以字母开头，包含数字、字母和下划线 _，长度最大为50个字符"),!1):(Log.w("properties 可以没有，但有的话必须是对象"),!1))}},{key:"propertiesMust",value:function(e){return this.stripProperties(e),void 0===e||!_.check.isObject(e)||_.check.isEmptyObject(e)?(Log.w("properties必须是对象且有值"),!1):!!this._checkPropertiesKey(e)||(Log.w("请检查参数格式, properties 的 key 只能以字母开头，包含数字、字母和下划线 _，长度最大为50个字符"),!1)}},{key:"userId",value:function(e){return!(!_.check.isString(e)||!/^.{1,63}$/.test(e))||(Log.w("用户 id 必须是不能为空，且小于 64 位的字符串"),!1)}}]),e}(),MASTER_INSTANCE_NAME="thinkingdata",DEFAULT_CONFIG={_name:MASTER_INSTANCE_NAME,appId:"",send_method:"image",persistence:"localStorage",persistencePrefix:"ThinkingDataJSSDK",persistenceEnabled:!0,crossSubDomain:!0,maxReferrerStringLength:200,showLog:!0,dataSendTimeout:3e3,useAppTrack:!1,strict:!1},ThinkingDataPersistence=function(e){this._state={},this.crossSubDomain=e.crossSubDomain,this.enabled=e.persistenceEnabled;var t=null;if(this.enabled){if(!1===e.crossSubDomain){var r=_.url("sub",location.href);this.name="string"==typeof r&&""!==r?e.persistencePrefix+"_"+r:e.persistencePrefix+"_root"}else this.name=e.persistencePrefix+"_cross";var n=e.persistence;"cookie"!==n&&"localStorage"!==n&&(Log.i("Unknown persistence type "+n+"; falling back to cookie"),n=e.persistence="cookie"),"localStorage"===n&&_.localStorage.isSupported()?(this.storage=_.localStorage,(t=_.cookie.get(this.name))&&_.cookie.remove(this.name,this.crossSubDomain)):(Log.i("localStorage is not support by the browser; falling back to cookie"),this.storage=_.cookie)}if(this._load(t),!this.getDistinctId()){var i=e.uuid?e.uuid:_.UUID();this._setDeviceId(i),this.setDistinctId(i)}};ThinkingDataPersistence.prototype._load=function(e){var t;this.enabled&&(null!==(t=null!==e?e:this.storage.get(this.name))&&_.check.isJSONString(t)&&(this._state=_.extend({},JSON.parse(t))),null!==e&&this._save())},ThinkingDataPersistence.prototype.getDistinctId=function(){return this._state.distinct_id},ThinkingDataPersistence.prototype.setDistinctId=function(e){this._set("distinct_id",e)},ThinkingDataPersistence.prototype.getAccountId=function(){return this._state.account_id},ThinkingDataPersistence.prototype.setAccountId=function(e){this._set("account_id",e)},ThinkingDataPersistence.prototype.getDeviceId=function(){return this._state.device_id},ThinkingDataPersistence.prototype.setSuperProperties=function(e){this._set("super_properties",e)},ThinkingDataPersistence.prototype.getSuperProperties=function(){return this._state.super_properties||{}},ThinkingDataPersistence.prototype.setEventTimer=function(e,t){var r=this._state.event_timers||{};r[e]=t,this._set("event_timers",r)},ThinkingDataPersistence.prototype.removeEventTimer=function(e){var t=(this._state.event_timers||{})[e];return _.check.isUndefined(t)||(delete this._state.event_timers[e],this._save()),t},ThinkingDataPersistence.prototype._setDeviceId=function(e){this._state.device_id?Log.w("Current device_id is ",this.getDeviceId(),", it couldn't been set to: ",e):this._set("device_id",e)},ThinkingDataPersistence.prototype._save=function(){this.enabled&&this.storage.set(this.name,JSON.stringify(this._state),73e3,this.crossSubDomain)},ThinkingDataPersistence.prototype._set=function(e,t){this._state=this._state||{},this._state[e]=t,this._save()};var ThinkingDataAnalyticsLib=function(){},tdMaster;function initAsModule(){return tdMaster=new ThinkingDataAnalyticsLib}ThinkingDataAnalyticsLib.prototype.trackLink=function(e,t,r){var n=this,i=this._getConfig("strict");if(PropertyChecker.properties(r)||!i){if(e&&_.check.isObject(e)){var o=[];_.each(e,function(e,t){e&&_.check.isArray(e)&&_.each(e,function(e){switch(t){case"tag":_.each(document.getElementsByTagName(e),function(e){o.indexOf(e)<0&&o.push(e)});break;case"class":_.each(document.getElementsByClassName(e),function(e){o.indexOf(e)<0&&o.push(e)});break;case"id":var r=document.getElementById(e);null!==r&&o.indexOf(r)<0&&o.push(r)}})}),_.each(o,function(e){if(null!==e){var o=_.extend({},_.info.pageProperties(),r);o["#element_type"]=e.nodeName.toLowerCase(),_.check.isUndefined(o.name)&&(o.name=e.getAttribute("td-name")||e.innerHTML||e.value||"未获取标识"),e.addEventListener("click",function(){n._sendRequest({type:"track",event:t,properties:i?PropertyChecker.stripProperties(o):o})})}})}}else Log.w("trackLink failed due to invalid properties.")},ThinkingDataAnalyticsLib.prototype.setPageProperty=function(e){PropertyChecker.properties(e)||!this._getConfig("strict")?_.extend(this.currentProps,e):Log.w("PageProperty 输入的参数有误")},ThinkingDataAnalyticsLib.prototype.getPageProperty=function(){return this.currentProps},ThinkingDataAnalyticsLib.prototype.login=function(e){("number"==typeof e&&(e=String(e)),PropertyChecker.userId(e)||!this._getConfig("strict"))?e!==this.persistence.getAccountId()&&this.persistence.setAccountId(e):Log.e("login 的参数必须是字符串")},ThinkingDataAnalyticsLib.prototype.logout=function(e){if(!0===e){var t=_.UUID();this.persistence.setDistinctId(t)}this.persistence.setAccountId("")},ThinkingDataAnalyticsLib.prototype.userSet=function(e,t){!PropertyChecker.propertiesMust(e)&&this._getConfig("strict")||this._sendRequest({type:"user_set",properties:e},t)},ThinkingDataAnalyticsLib.prototype.userSetOnce=function(e,t){!PropertyChecker.propertiesMust(e)&&this._getConfig("strict")||this._sendRequest({type:"user_setOnce",properties:e},t)},ThinkingDataAnalyticsLib.prototype.userUnset=function(e,t){if(PropertyChecker.propertyName(e)||!this._getConfig("strict")){var r={};r[e]=0,this._sendRequest({type:"user_unset",properties:r},t)}},ThinkingDataAnalyticsLib.prototype.userAdd=function(e,t){if(_.check.isString(e)){var r=e;(e={})[r]=1}PropertyChecker.propertiesMust(e)&&(!function(e){for(var t in e)if(!/-*\d+/.test(String(e[t])))return!1;return!0}(e)&&this._getConfig("strict")?Log.w("userAdd 属性中的值只能是数字"):this._sendRequest({type:"user_add",properties:e},t))},ThinkingDataAnalyticsLib.prototype.userAppend=function(e,t){PropertyChecker.propertiesMust(e)&&function(e){for(var t in e)if(!_.check.isArray(e[t]))return!1;return!0}(e)||!this._getConfig("strict")?this._sendRequest({type:"user_append",properties:e},t):Log.w("userAppend 属性中的值只能是 Array")},ThinkingDataAnalyticsLib.prototype.userDel=function(e){this._sendRequest({type:"user_del"},e)},ThinkingDataAnalyticsLib.prototype._sendRequest=function(e,t,r){var n=_.check.isUndefined(e.time)||!_.check.isDate(e.time)?new Date:e.time,i={data:[{"#type":e.type,"#time":_.formatDate(n),"#distinct_id":this.persistence.getDistinctId()}]};if(this.persistence.getAccountId()&&(i.data[0]["#account_id"]=this.persistence.getAccountId()),"track"===e.type){i.data[0]["#event_name"]=e.event,i.data[0].properties=_.extend({},{"#device_id":this.persistence.getDeviceId(),"#zone_offset":0-n.getTimezoneOffset()/60},_.info.properties(),this.getSuperProperties(),this.dynamicProperties?this.dynamicProperties():{},this.getPageProperty());var o=this.persistence.removeEventTimer(e.event);if(!_.check.isUndefined(o)){var s=(new Date).getTime()-o;i.data[0].properties["#duration"]=parseFloat((s/1e3).toFixed(3))}}else i.data[0].properties={};if(_.check.isObject(e.properties)&&!_.check.isEmptyObject(e.properties)&&_.extend(i.data[0].properties,e.properties),_.searchObjDate(i.data[0]),i["#app_id"]=this._getConfig("appId"),Log.i(i),this._getConfig("useAppTrack")){var a=window.ThinkingData_APP_JS_Bridge||{};if("object"===_typeof(a)&&a.thinkingdata_track)return a.thinkingdata_track(JSON.stringify(i)),void("function"==typeof t&&t());if(/td-sdk-ios/.test(navigator.userAgent)&&!window.MSStream){var c=document.createElement("iframe");return c.setAttribute("src","thinkinganalytics://trackEvent?event="+_.encodeURIComponent(JSON.stringify(i))),document.documentElement.appendChild(c),c.parentNode.removeChild(c),c=null,void("function"==typeof t&&t())}}r&&(i.data[0]["#uuid"]=_.UUIDv4()),i=JSON.stringify(i);var u=_.base64Encode(i),p="crc="+_.hashCode(u),h="&data="+_.encodeURIComponent(u)+"&ext="+_.encodeURIComponent(p);if("ajax"===this._getConfig("send_method")){var l=null;l=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");var f=this._getConfig("serverUrl");l.open("post",f,!0),l.setRequestHeader("Content-type","application/x-www-form-urlencoded"),l.onreadystatechange=function(){4===l.readyState&&200===l.status&&t&&t()},l.send(h)}else this._sendRequestWithImage(h,t);if(r&&void 0!==("undefined"==typeof navigator?"undefined":_typeof(navigator))&&navigator.sendBeacon){var g=new FormData;g.append("data",u),navigator.sendBeacon(this._getConfig("serverUrl"),g)}},ThinkingDataAnalyticsLib.prototype._sendRequestWithImage=function(e,t){function r(e){e&&!e.hasCalled&&(e.hasCalled=!0,e.callback&&e.callback())}var n=(-1!==this._getConfig("serverUrl").indexOf("?")?this._getConfig("serverUrl"):this._getConfig("serverUrl")+"?")+e,i=document.createElement("img");i.callback=t,setTimeout(r,this._getConfig("dataSendTimeout"),i),i.onload=function(){this.onload=null,r(this)},i.onerror=function(){this.onerror=null,r(this)},i.onabort=function(){this.onabort=null,r(this)},i.src=n},ThinkingDataAnalyticsLib.prototype.track=function(e,t,r,n){(PropertyChecker.event(e)&&PropertyChecker.properties(t)||!this._getConfig("strict"))&&this._sendRequest({type:"track",event:e,time:_.check.isDate(r)?r:new Date,properties:t},n)},ThinkingDataAnalyticsLib.prototype.trackWithBeacon=function(e,t,r,n){(PropertyChecker.event(e)&&PropertyChecker.properties(t)||!this._getConfig("strict"))&&this._sendRequest({type:"track",event:e,time:_.check.isDate(r)?r:new Date,properties:t},n,!0)},ThinkingDataAnalyticsLib.prototype.identify=function(e){("number"==typeof e&&(e=String(e)),PropertyChecker.userId(e)||!this._getConfig("strict"))?e!==this.persistence.getDistinctId()&&this.persistence.setDistinctId(e):Log.e("identify 的参数必须是字符串")},ThinkingDataAnalyticsLib.prototype.getDistinctId=function(){return this.persistence.getDistinctId()},ThinkingDataAnalyticsLib.prototype.getDeviceId=function(){return this.persistence.getDeviceId()},ThinkingDataAnalyticsLib.prototype.setSuperProperties=function(e){PropertyChecker.propertiesMust(e)||!this._getConfig("strict")?this.persistence.setSuperProperties(e):Log.w("setSuperProperties 参数不合法")},ThinkingDataAnalyticsLib.prototype.getSuperProperties=function(){return this.persistence.getSuperProperties()},ThinkingDataAnalyticsLib.prototype.clearSuperProperties=function(){this.persistence.setSuperProperties({})},ThinkingDataAnalyticsLib.prototype.unsetSuperProperty=function(e){if(_.check.isString(e)){var t=this.getSuperProperties();delete t[e],this.persistence.setSuperProperties(t)}},ThinkingDataAnalyticsLib.prototype.setDynamicSuperProperties=function(e){"function"==typeof e?PropertyChecker.properties(e())||!this._getConfig("strict")?this.dynamicProperties=e:Log.w("动态公共属性必须返回合法的属性值"):Log.w("setDynamicSuperProperties 的参数必须是 function 类型")},ThinkingDataAnalyticsLib.prototype.timeEvent=function(e){_.check.isUndefined(e)?Log.w("No event name provided to timeEvent"):this.persistence.setEventTimer(e,(new Date).getTime())},ThinkingDataAnalyticsLib.prototype.quick=function(e){"string"==typeof e&&"autoTrack"===e?this._sendRequest({type:"track",event:"ta_pageview",properties:_.info.pageProperties()}):Log.w("quick方法中没有这个功能"+e)},ThinkingDataAnalyticsLib.prototype._setConfig=function(e){_.check.isObject(e)&&(_.extend(this.config,e),this._getConfig("persistencePrefix")||(this.config.persistencePrefix=this.config.cookiePrefix),this.persistence)},ThinkingDataAnalyticsLib.prototype._getConfig=function(e){return this.config[e]},ThinkingDataAnalyticsLib.prototype.init=function(e){if(_.check.isUndefined(this.config)){this.config={},this.currentProps=this.currentProps||{},this._setConfig(_.extend({},DEFAULT_CONFIG,e)),this.persistence=new ThinkingDataPersistence(this.config),Log.showLog=this._getConfig("showLog");var t=this._getConfig("send_method");"image"!==t&&"ajax"!==t&&"beacon"!==t&&(Log.i("send_method",t,"is not supported. Changed to image as default value"),this._setConfig({send_method:"image"}))}else Log.i("The ThinkingData libraray has been initialized.")},ThinkingDataAnalyticsLib.prototype.initInstance=function(e,t){if(!_.check.isString(e)||!_.check.isUndefined(t)&&!_.check.isObject(t))return Log.w("invalid parameter of initInstance(string, object)."),null;if(this._getConfig("_name")!==MASTER_INSTANCE_NAME)return Log.w("This function is allowed for master instance only"),null;if(e===MASTER_INSTANCE_NAME||this[e])return Log.w("The name ",e," couldn't be used for create new instance."),null;_.check.isUndefined(t)&&(t={});var r=new ThinkingDataAnalyticsLib,n=_.extend({},this.config,{_name:e,persistenceEnabled:!1,uuid:this.getDeviceId()},t);n.persistenceEnabled&&(n.persistencePrefix=n.persistencePrefix+"_"+e),r.init(n),this[e]=r};var td=initAsModule();module.exports=td;