/** * minitt-cn-sesdk-umd.prod.js * version: 1.2.4 * LastModified: 12/10/2024 15:32:34 GMT+0800 */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SESDK=t()}(this,(function(){"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t needs to be passed!",440117:"Illegal parameter format, need to pass parameter value ({#1})!",440119:"Failed to obtain device information!",440120:"Illegal parameter format, Object needs to be passed!",440122:"Illegal parameter format Requires the correct preconfigured event type ({#1}) or all!",440123:"The maximum length of data that can be stored by a single key must be less than 1MB. And the upper limit of all data stores is 10MB",440124:"setStorage error {#1}",440125:"The mini program openid has not been obtained.",440126:"Currently loaded plugin does not match the main SDK runtime environment",440127:"Plugin version must be the same as the main SDK version (plugin version {#1}, main SDK version {#2})",440601:"error: {#1}. The custom event name must be string type.",440602:'error: {#1}. The custom event name must start with a lowercase letter but cannot start with an underscore. Other characters can contain numbers, lowercase letters, and underscores "_".',440603:"error: {#1}. The custom event name must contain a maximum of 40 characters.",440604:"Call eventStart first to record the start time.",440605:"error: {#1}. The key of custom properties must be string type",440606:'error: {#1}. The key of custom properties must start with a lowercase letter but cannot start with an underscore. Other characters can contain numbers, lowercase letters, and underscores "_".',440607:"error: {#1}. The key of custom properties must contain a maximum of 40 characters.",440610:"error: {#1}. The value of each key must be string, number or boolean.",440666:"error: reportingToTencentSdk is required, please pass 1, 2 or 3.",440667:"error: Lack of required parameters to initialize Tencent Ads SDK.",440668:"error: Lack of required Tencent Ads SDK."};function s(e,t,n){var i,o,s=t;!isNaN(t)&&a[t]&&(s="[CODE: "+t+"] "+a[t],n&&(i=n,o=function(e,t){s=s.replace(new RegExp(t,"g"),e)},Object.keys(i).forEach((function(e){return o(i[e],e)})))),e||(r.$emit("assertMsg",s),console.warn("SolarEngineSDK "+s))}var u=console;function c(e,t,n){var r='SolarEngineSDK (The "'+e+'" method parameters passed by the developer):';n?u.log(r,t,",",n):u.log(r,t)}function p(e,t,r){n.getStateData("logEnabled")&&c(e,t,r)}function l(e){return!!o(e)||(s(!1,440120),!1)}function d(){if("object"==typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues&&"function"==typeof Uint8Array)return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(function(e){var t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))}var e=(new Date).getTime(),t="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:3&r|8).toString(16)}))}function g(e){return null==e?void 0:e.replace(/^\s+|\s+$/g,"")}var f=function(){return n.getStateData("systemEnv")},_=function(){return 1===f()},v=function(){return 0===f()},m=function(){return 2===f()};function y(e,t){void 0===e&&(e=new Date),void 0===t&&(t="YYYYMMDD");var n={"M+":(e=new Date(e)).getMonth()+1,"D+":e.getDate(),"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()},r=/(Y+)/;if(r.test(t)){var i=r.exec(t)[1];t=t.replace(i,(e.getFullYear()+"").substring(4-i.length))}for(var o in n){var a=new RegExp("("+o+")");if(a.test(t)){var s=a.exec(t)[1];t=t.replace(s,1==s.length?n[o]:("00"+n[o]).substring((""+n[o]).length))}}return t}n.extend({infoLog:c,checkLogEnabled:p,deepCopy:function e(t,n){if(void 0===n&&(n=[]),null===t||"object"!=typeof t)return t;var r,i=(r=function(e){return e.original===t},n.find(r));if(i)return i.copy;var o=Array.isArray(t)?[]:{};return n.push({original:t,copy:o}),Object.keys(t).forEach((function(r){o[r]=e(t[r],n)})),o},stringLikeJsonToObject:function(e){var t,n,r={};return e?r=null==(t=e.replace(/(\s*\{)|(\}\s*)/g,""))||null==(n=t.split(","))?void 0:n.reduce((function(e,t){var n=t.split(":"),r=n[0].replace(/^\s*|\s*$/g,""),i=n[1].replace(/^\s*|\s*$/g,"").replace(/^(\"|\')|(\"|\')$/g,"");try{i=JSON.parse(i)}catch(e){i=i}return e[r]=i,e}),{}):r},isObject:o,checkObject:l,getType:i,limitParamType:function(e,t){return!!["string","number","boolean"].includes(typeof t)||(s(!1,440610,{"{#1}":e}),!1)},assert:s,generateUUID:d,trimStr:g,isWeb:v,isXcxEnv:_});var h={getCurDate:function(e){return e?y(e):y()},dateFormat:y};n.extend({seDate:h});var S=["_appInstall","_appStart","_appPur","_appImp"],k=["_web","_mp","_mp"],D=function(){return[n.getCurEnvEventName("_appInstall"),"_mpInstall"]};n.extend({STORAGE_INSTALL_SEND:"_log_install_send",STORAGE_IS_FIRST_DAY:"_first_day_time",STORAGE_EVENT_QUEUE:"_event_queue"}),n.extend({createStorageKey:function(e){return"sesdk_config_"+e}});var I=new(function(e){var t,n;function r(){var t;return(t=e.call(this)||this).settingHost=void 0,t.receiverSDKLogDomain=void 0,t.receiverSDKLogAppkey=void 0,t.receiverSDKLogTenantId=void 0,t}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,r}((function(){this.isPrivate=!1,this.receiverDomain=void 0,this.ruleDomain=void 0,this.openidDomain=void 0,this.packageType=void 0})));I.receiverDomain="api-receiver.detailroi.com",I.ruleDomain="rule.detailroi.com",I.settingHost="rule.detailroi.com",I.openidDomain="api-receiver.detailroi.com",I.packageType=1,I.receiverSDKLogDomain="api-receiver.detailroi.com",I.receiverSDKLogAppkey="e3517aa324f39da3",I.receiverSDKLogTenantId="147e6f0c65160558";var b={get:function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),n.requestHandle({url:e,method:"get",params:t},r)},post:function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),n.requestHandle({url:e,method:"post",data:t},r)}};n.extend({HttpHelper:b});var T={isInMultilinkTest:!1,isInApp:!1,appData:{outlayerData:{},properties:{}},externalReportData:{superProperties:{},appInstall:{},appStart:{},appEnd:{}},pluginProperties:{},reportData:{_package_type:I.packageType,_tenant_id:"",_appkey:"",_source_type:"sdk",_event_name:"",_session_id:"",_type:"event",_event_id:"",_ts:0,_ua:"",_distinct_id:"",_distinct_id_type:1001,custom_properties:{},properties:{_platform:0,_os_version:"",_screen_width:0,_screen_height:0,_device_model:"",_device_type:0,_network_type:1,_lib:0,_lib_version:"1.2.4",_browser:"",_browser_version:"",_is_first_day:!1,_is_first_time:!1,_log_count:0}},isHasOpenId:!1,systemEnv:0,debugModel:!1,logEnabled:!1,isSendSDKLog:!0,quickAppAllowToSendEvents:!0};function P(e){if(l(e)){var t="boolean"==typeof e.delete&&e.delete;delete e.delete,Object.keys(e).forEach((function(n){var r=T,i=n.split(".");i.length>1?i.forEach((function(o,a){a=0:t>0;"number"===i(t)&&r&&(A[e]=t)}function O(){A.isSass&&b.post("//"+I.settingHost+"/rule/config/global/info",{_appKey:E("reportData._appkey"),_distinct_id:E("reportData._distinct_id")},{timeout:1e3*A.settingTimeout}).then((function(e){if(0===(null==e?void 0:e.code)){var t=(null==e?void 0:e.data)||{},r=t.receiverSDKLogDomain,o=t.settingPolingMinRange,a=t.settingPolingMaxRange,s=t.settingInterval,u=t.receiverDomain,c=t.ruleDomain,p=t.rulePolingMinRange,l=t.rulePolingMaxRange,d=t.ruleInterval;w.filter((function(e){return!e.condition})).forEach((function(e){return R(e.key,t[e.key],e.zero)})),r&&(A.receiverSDKLogDomain=j(r)),"number"===i(o)&&"number"===i(a)&&o0&&(A.settingPolingMinRange=o),a>0&&(A.settingPolingMaxRange=a)),"number"===i(s)&&(sA.settingPolingMaxRange&&(s=A.settingPolingMaxRange),A.settingInterval=s),u&&(A.receiverDomain=j(u)),c&&(A.ruleDomain=j(c)),"number"===i(p)&&"number"===i(l)&&p0&&(A.rulePolingMinRange=p),l>0&&(A.rulePolingMaxRange=l)),"number"===i(d)&&(dA.rulePolingMaxRange&&(d=A.rulePolingMaxRange),A.ruleInterval=d),g=w.reduce((function(e,t){return e[t.skey]=A[t.key],e}),{}),n.Storage.setItem("_setting_host",Object.assign({rcdm:A.receiverDomain,rdm:A.ruleDomain,oidm:A.openIdDomain},g))}var g;L()})).catch((function(){L()}))}function L(){clearTimeout(A.intervalTimer),A.intervalTimer=setTimeout((function(){return O()}),1e3*A.settingInterval)}function j(e){return e.replace(/^\s+|\s+$/g,"").replace(/^(http:\/\/|https:\/\/)/g,"").replace(/\/+$/g,"")}function C(e){void 0===e&&(e=!1);var t="//"+(e?A.receiverSDKLogDomain:A.receiverDomain)+"/datareceiver/receive",r=n.isKS?t+"/v3/debugObjApi":t+"/v1/debugApi",i=n.isKS?t+"/v3/objApi":t+"/v1/api";return E("debugModel")&&!e?r:i}function M(e){E("isInMultilinkTest")?r.$on("multilinkTestResponse",(function(){"function"==typeof e&&e()})):"function"==typeof e&&e()}n.extend({settingData:A}),n.extend({waitToSendEvent:M});var N,V="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},q=(function(e){!function(t){function n(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function r(e,t,r,i,o,a){return n((a=n(n(t,e),n(i,a)))<>>32-o,r)}function i(e,t,n,i,o,a,s){return r(t&n|~t&i,e,t,o,a,s)}function o(e,t,n,i,o,a,s){return r(t&i|n&~i,e,t,o,a,s)}function a(e,t,n,i,o,a,s){return r(t^n^i,e,t,o,a,s)}function s(e,t,n,i,o,a,s){return r(n^(t|~i),e,t,o,a,s)}function u(e,t){var r,u,c,p;e[t>>5]|=128<>>9<<4)]=t;for(var l=1732584193,d=-271733879,g=-1732584194,f=271733878,_=0;_>5]>>>r%32&255);return t}function p(e){var t=[];for(t[(e.length>>2)-1]=void 0,r=0;r>5]|=(255&e.charCodeAt(r/8))<>>4&15)+n.charAt(15&t);return r}function d(e){return unescape(encodeURIComponent(e))}function g(e){return c(u(p(e=d(e)),8*e.length))}function f(e,t){return function(e,t){var n,r=p(e),i=[],o=[];for(i[15]=o[15]=void 0,16=n}function ee(e,t){if(Z(e,1024e3)){var n,r,i=e.pop();D().includes(i.eventName)&&1===(null==(n=i.params)||null==(r=n[0])?void 0:r._event_type)?e.splice(1,0,i):t.push(i),ee(e,t)}return e}function te(e){var t,r,i,o=(r=null==(t=n.Storage.getItem("_log_count"))?void 0:t.split("_")[0],i=h.getCurDate(),null===t||+r!=+i?0:Number(t.split("_")[1])+1);return e[0].properties._log_count=o,o}function ne(e,t,r){if(t||!D().includes(e)||1!==r||n.Storage.getItem("_event_queue",!0,[]).filter((function(e){var t,n;return D().includes(e.eventName)&&1===(null==(t=e.params)||null==(n=t[0])?void 0:n._event_type)})).length){var i="_event_"+e;n.Storage.setItem(i,e)}}function re(e,t,r){var i,o;void 0===e&&(e=""),void 0===r&&(r=!0),r&&(o=te(t));var a={eventName:e,params:t,status:"toSubmit"},s=n.Storage.getItem("_event_queue",!0,[]);s.unshift(a);var u=[];ee(s,u),u.length&&n.trackLogEvent({state:2,message:"Events deleted when local storage is low",event_name:u.map((function(e){return e.eventName})).join(","),log_count:u.map((function(e){var t,n,r;return null==(t=e.params)||null==(n=t[0])||null==(r=n.properties)?void 0:r._log_count})).join(",")});var c=!1;n.Storage.setItem("_event_queue",s,(function(){c=!0}));var p,l=null==(i=t[0])?void 0:i._event_type;return D().includes(e)&&1===l&&(n.Storage.setItem("_log_install_insert",1),n.trackLogEvent({state:c?201:101,is_success:!c,message:e+" store local",event_name:e,log_count:null==(p=t[0])?void 0:p.properties._log_count})),e&&ne(e,!1,l),r&&X(o),c}function ie(e){var t=Number(f()),n=k[t];return E("isInApp")?e:e.replace(/^_app/,n)}function oe(t){if(void 0===t&&(t={}),A.isSass&&E("isSendSDKLog")&&(!E("debugModel")||[202,6,101,201].includes(t.state))){n.isXcxEnv()&&(t.env_version=null==n.getEnvVersion?void 0:n.getEnvVersion());var r=E("reportData"),i=[e({},r,{_ts:Date.now(),_event_id:d(),_appkey:I.receiverSDKLogAppkey,_tenant_id:I.receiverSDKLogTenantId,_type:"event",_event_name:"sesdk_recordLog",_event_type:-1,properties:e({},r.properties),custom_properties:e({user_appkey:r._appkey,user_tenantId:r._tenant_id,user_debugModel:E("debugModel"),user_domain:A.receiverDomain,isInApp:E("isInApp"),installInsert:"1"===n.Storage.getItem("_log_install_insert"),installSend:"1"===n.Storage.getItem("_log_install_send")},t)})];i[0].properties._si=$(i[0]);var o=n.Storage.getItem("_log_event_queue",!0,[]);o.length&&(i=i.concat(o),n.Storage.deleteItem("_log_event_queue")),ae(i)}}function ae(e,t){void 0===t&&(t=A.receivertRetryTimes);var r=n.isKS?{list:e}:e;b.post(C(!0),r,{timeout:1e3*A.receiverTimeout}).then((function(n){void 0===n.status&&se(e,t)})).catch((function(n){se(e,t)}))}function se(e,t){t>0?ae(e,--t):(e.length>99&&(e=e.slice(0,99)),n.Storage.setItem("_log_event_queue",e,null,!0))}function ue(e,t){void 0===t&&(t=!1);var r=n.Storage.getItem("_log_count_send",!0,{}),i=h.getCurDate(),o=Object.keys(r).filter((function(e){return e!==i}));o.length&&o.forEach((function(e){oe({message:"non-same-day _log_count",log_date:e,log_count_list:r[e]}),delete r[e]})),Array.isArray(e)&&(e=e.sort((function(e,t){return e-t})),r[i]||(r[i]=[]),e.length&&r[i].push(e.length>1?e.join(","):e[0]),r[i].length&&((r[i].reduce((function(e,t){return e+String(t).split(",").length}),0)>=100||t)&&(oe({message:"same-day _log_count",log_date:i,log_count_list:r[i]}),t||delete r[i]),n.Storage.setItem("_log_count_send",r)))}function ce(){ue(),pe([6e4,3e5,18e5],0)}function pe(e,t){t>2||setTimeout((function(){ue([],!0),pe(e,t+1)}),e[t])}function le(t,r,i,o){void 0===i&&(i={}),void 0===o&&(o={}),n.NATIVE.ready((function(){try{var a=ie(t);!function(e,t,r){if(E("debugModel"))return P({"reportData.properties._is_first_day":!0,"reportData.properties._is_first_time":!0});var i=h.getCurDate(),o=n.Storage.getItem("_first_day_time"),a=i===h.getCurDate(+o);if(S.includes(t)&&4!==r&&o>0){var s=o-o%36e5,u=+new Date;a=u>=s-864e5&&u<=s+9e7}P({"reportData.properties._is_first_day":a});var c="_event_"+e;P({"reportData.properties._is_first_time":null===n.Storage.getItem(c)})}(a,t,o._event_type);var s=E("reportData"),u=E("externalReportData"),c=u[t.replace(/_/,"")]||{},p=i.isSendByBeacon;delete i.isSendByBeacon;var l=[e({},s,o,{_ts:Date.now(),_event_id:d(),_type:"event",_event_name:a,_event_type:o._event_type||3,properties:e({},s.properties,r),custom_properties:e({},s.custom_properties,u.superProperties,i,c)})],g=v()&&p;if(g&&(X(te(l)),n.sendBeacon({url:C(),data:ge(l)})),v()&&E("debugModel"))return ne(a,!0),me(ge(l,!1));var _=[1,2].includes(f())&&E("debugModel");if(re(a,l,-1!==o._event_type&&!_&&!g)||E("isInMultilinkTest"))return l[0].properties._si=$(l[0]),fe(C(),ge(l));de()}catch(e){oe({state:999,message:"report errors",error_message:JSON.stringify(e)})}}))}function de(){var e=n.Storage.getItem("_event_queue",!0,[]);if(0!==e.length&&(!m()||E("quickAppAllowToSendEvents"))&&0!=(t=e,_()&&!E("isHasOpenId")?(s(!1,440125),!1):!(void 0!==t.find((function(e){return"submitting"===e.status}))))){var t,r=e.splice(0,100),i=[],o=r.map((function(e){e.status="submitting",i.push(e.params[0]._event_id);var t=e.params[0];return(n.isXcxEnv()||m())&&n.setXcxEventData(t),t._visitor_id=E("reportData._visitor_id"),"userset"!==t._type&&(t.properties._group_id_list=E("reportData.properties._group_id_list"),t.properties._experiment_group_id_list=E("reportData.properties._experiment_group_id_list"),t.properties._combination_id=E("reportData.properties._combination_id")),t.properties._si=$(t),t}));e.unshift.apply(e,r),n.Storage.setItem("_event_queue",e),fe(C(),ge(o))}}function ge(e,t){void 0===t&&(t=!0);var n=E("isInApp"),r=E("appData.outlayerData"),i=E("appData.properties");return n&&e.length?e.map((function(e){if("userset"!==e._type)return e.properties._primitive_attribute=JSON.stringify(e),(e=Object.assign(e,r)).properties=Object.assign(e.properties,i),t&&(e.properties._si=$(e)),e})):e}function fe(e,t,i){void 0===i&&(i=A.receivertRetryTimes),i===A.receivertRetryTimes&&p("report data list",t);var o=n.isKS?{list:t}:t;b.post(e,o,{timeout:1e3*A.receiverTimeout}).then((function(o){if(void 0!==o.status){var a=t.findIndex((function(e){return D().includes(e._event_name)}));if(a>-1){var s=t[a]._event_name,u=t[a].properties._log_count;n.Storage.setItem("_log_install_send",1),n.trackLogEvent({state:202,is_success:!1,message:s+" report success",event_name:s,log_count:u}),r.$emit("install_event_send")}ue(t.map((function(e){return e.properties._log_count})));var c=n.Storage.getItem("_event_queue",!0,[]),p=t.map((function(e){return e._event_id})),l=c.filter((function(e){return"toSubmit"===e.status})).filter((function(e){return!p.includes(e.params[0]._event_id)}));if(n.Storage.setItem("_event_queue",l),E("isInMultilinkTest"))return;de()}else _e(e,t,i,o.msg,o.status)})).catch((function(n){_e(e,t,i,(null==n?void 0:n.message)||n,(null==n?void 0:n.errorCode)||"timeout")}))}function _e(e,t,r,i,o){if(r>0)fe(e,t,--r);else{var a=n.Storage.getItem("_event_queue",!0,[]);a.forEach((function(e){e.status="toSubmit"})),n.Storage.setItem("_event_queue",a),oe({state:3,code:o,message:"failed to report",error_message:i,event_name:null==t?void 0:t.map((function(e){return e._event_name})).join(","),log_count:null==t?void 0:t.map((function(e){var t;return null==(t=e.properties)?void 0:t._log_count})).join(",")})}}function ve(e,t,n,r){void 0===r&&(r=!0),D().includes(e)&&oe({state:6,code:n,message:"debug _webInstall report",is_success:r,error_message:t,event_name:e})}function me(e,t){var n;void 0===t&&(t=A.receivertRetryTimes);var r=null==(n=e[0])?void 0:n._event_name;b.post(C(),e,{timeout:1e3*A.receiverTimeout}).then((function(e){ve(r,e.msg,e.status)})).catch((function(n){t>0?(t--,me(e,t)):ve(r,(null==n?void 0:n.message)||n,(null==n?void 0:n.errorCode)||"timeout",!1)}))}n.extend({valueToStr:Q,getCurEnvEventName:ie,isValueExceedLimit:Z,filterCustomProperties:function(e){var t=Object.create(null);if(!l(e))return t;var n="",r="",o="",a="";return function(e){if("object"!==i(e))return[];var t=Object.keys(e);if("function"!==i(Reflect.ownKeys))return t;var n=Object.getOwnPropertyNames(e),r=Reflect.ownKeys(e),o=n.filter((function(e){return!t.includes(e)}));return r.filter((function(e){return!o.includes(e)}))}(e).forEach((function(s){"string"!==i(s)&&(n+=String(s)+", "),"string"!==i(s)||/^[a-z][a-z0-9_]*$/.test(s)||(r+=String(s)+", "),"string"===i(s)&&s.length>40&&(o+=String(s)+", "),["number","string","boolean","array"].includes(i(e[s]))||(a+=String(s)+", "),t[s]=e[s]})),n.length&&s(!1,440605,{"{#1}":n.slice(0,n.length-2)}),r.length&&s(!1,440606,{"{#1}":r.slice(0,r.length-2)}),o.length&&s(!1,440607,{"{#1}":o.slice(0,o.length-2)}),a.length&&s(!1,440610,{"{#1}":a.slice(0,o.length-2)}),t},getPredefineEventFormattedData:Y}),n.extend({trackLogEvent:oe});var ye=void 0;function he(e){void 0===e&&(e=A.eventPollingMaxCount),clearTimeout(ye),ye=setTimeout((function(){--e>0&&(de(),he(e))}),1e3*A.eventPollingInterval)}n.extend({trackEvent:le,postEvent:de});var Se=!1,ke=!1;function De(e,t,n){if(null==e?void 0:e.enable){if("function"!=typeof(null==t?void 0:t.init)&&n)return s(!1,n);t.init(e)}}var Ie={prevInit:function(e){void 0!==e&&""!==e&&(ke=!0,n.Storage.setItem("_is_prev_init",1))},init:function(e){var t,o,a,u;if(!ke&&!n.Storage.getItem("_is_prev_init"))return s(!1,440100);if(l(e)){if((null==(t=e.config)?void 0:t.logEnabled)&&c("init",e),!e.appKey||!e.userId)return s(!1,440101);var p=(null==(o=e.config)?void 0:o.autoTrackConfig)||{},d=p.autoTrack,g=p.autoTrackPageClick;_()&&d&&g&&r.$emit("xcx_proxy_click");var f={};f._appkey=e.appKey,f._tenant_id=e.userId,P({"reportData._appkey":f._appkey}),x(),_()&&(null==n.somePrevInit||n.somePrevInit(e),n.getOpenId(e));var y=!!v()&&(null==(a=e.config)?void 0:a.isInApp),h=e.config||{},S=h.debugModel,k=h.logEnabled,D=h.disableRecordLog,I=h.remoteConfig,b=h.multilinkTestConfig,T=h.getQuickQueryWaitTime,E="number"===i(T)&&T>0;P({isInMultilinkTest:(null==b?void 0:b.enable)&&(null==(u=n.multilinkTest)?void 0:u.runtime),isInApp:!!y,debugModel:!!S,logEnabled:!!k,isSendSDKLog:!D,quickAppAllowToSendEvents:!E}),m()?(n.allowToSendEvents(E,T),n.sdkInitData().then((function(e){return A(e)}))):"promise"===i(n.sdkInitData)?n.sdkInitData.then((function(e){return A(e)})):Promise.resolve(n.sdkInitData).then((function(e){return A(e)}))}function A(e){var t=Object.assign(e,f);n.init({reportData:t}),y&&"function"==typeof n.initNativeApp&&n.initNativeApp(),_()?r.$on("ready_to_create_distinct",(function(){De(I,n.abtest,440107),w(),O()})):(De(I,n.abtest,440107),w(),O()),ce(),v()&&De(b,n.multilinkTest),he()}function w(){Se=e,r.$emit("isReady",e)}},ready:function(e){if("function"==typeof e)return Se?e.call(this,Se):void r.$on("isReady",(function(t){return e(t)}))},use:function(e){if("function"!=typeof(null==e?void 0:e.init))return s(!1,440109);if(e.env!==f())return s(!1,440126);var t=E("reportData.properties._lib_version");if(e.version!==t)return s(!1,440127,{"{#1}":e.version,"{#2}":t});e.init(n)}},be={login:function(e){p("login",e),P({"reportData._account_id":e}),n.Storage.setItem("_account_id",e)},getAccountId:function(){var e=E("reportData");return null==e?void 0:e._account_id},logout:function(){P({"reportData._account_id":""}),n.Storage.deleteItem("_account_id")}},Te={setVisitorId:function(e){p("setVisitorId",e),P({"reportData._visitor_id":e}),n.Storage.setItem("_visitor_id",e)},getVisitorId:function(){var e=E("reportData");return null==e?void 0:e._visitor_id}};function Pe(e,t,r){if(void 0===r&&(r=!1),!e||!g(e))return s(!1,440106);var i,o=E("externalReportData.superProperties");P("all"===e?{"externalReportData.superProperties":Object.assign(o,t)}:((i={delete:r})["externalReportData.superProperties."+e]=t,i));var a=n.Storage.getItem("superProperties",!0);"all"===e?n.Storage.setItem("superProperties",Object.assign(a,t)):(delete a[e],n.Storage.setItem("superProperties",a))}var Ee={setSuperProperties:function(e){p("setSuperProperties",e),l(e)&&Pe("all",e)},unsetSuperProperty:function(e){p("unsetSuperProperty",e),Pe(e,"",!0)},clearSuperProperties:function(){P({"externalReportData.superProperties":{}}),n.Storage.deleteItem("superProperties")}},Ae=["appInstall","appStart","appEnd","all"];function xe(e,t){var n=E("externalReportData");if(e===Ae[Ae.length-1])Ae.slice(0,Ae.length-1).forEach((function(e){var r,i=null===t?{}:Object.assign(n[e],t);P(((r={})["externalReportData."+e]=i,r))}));else{var r,i=null===t?{}:Object.assign(n[e],t);P(((r={})["externalReportData."+e]=i,r))}}var we={setPresetEvent:function(e,t){var n,r;p("setPresetEvent",e,t);var i=Number(f()),o=k[i].replace("_","");if(e=null==(n=e)||null==(r=n.replace(/(mp|web)Install/,Ae[0]))?void 0:r.replace(/(mp|web)Start/,Ae[1]),v()&&Ae.includes("appEnd")&&Ae.splice(2,1),!Ae.includes(e))return s(!1,440122,{"{#1}":Ae.map((function(e){return e.replace("app",o)})).slice(0,Ae.length-1).join(",")});t?l(t)&&xe(e,t):xe(e,null)}};function Re(e,t){void 0===t&&(t=!0),t&&p("eventStart",e),G[e+(t?4:1)]=Date.now()}function Oe(e,t,n){if(void 0===t&&(t={}),void 0===n&&(n=!0),n&&p("eventFinish",e,t),l(t)){var r=n?4:1,i=e+r;if(void 0===G[i])return s(!1,440604);var o=G[i];le(e,{_duration:Date.now()-o},t,{_event_type:r})}}var Le={eventStart:Re,eventFinish:Oe};function je(){Oe("_appEnd",E("externalReportData").appEnd,!1)}function Ce(t,r){void 0===r&&(r={}),p(t,r),n.NATIVE.ready((function(){var n=[e({},E("reportData"),{_ts:Date.now(),_type:"userset",_userset_type:t,properties:{},custom_properties:r||{}})];if(v()&&E("debugModel"))return me(n);re("",n),de()}))}n.extend({trackAppInstall:function(){var e="_event_"+ie("_appInstall");n.Storage.getItem(e)||le("_appInstall",{},E("externalReportData").appInstall,{_event_type:1})},trackAppStart:function(e){void 0===e&&(e={}),Re("_appEnd",!1),le("_appStart",e,E("externalReportData").appStart,{_event_type:1})},trackAppEnd:je});var Me=["userDeleteByAccountId","userDeleteByVisitorId"],Ne=e({},Ie,be,Te,Ee,we,{trackAppEnd:je},Le,{track:function(e,t){void 0===t&&(t={}),p("track",e,t),l(t)&&M((function(){le(e,{},t,{_event_type:4})}))}},{trackAdImpression:function(e){p("trackAdImpression",e);var t=Y(["adNetworkPlatform","adType","adNetworkAppID","adId","mediationPlatform","ecpm","currency","rendered"],e);le("_appImp",t.properties,t.customProperties)},trackAdClick:function(e){p("trackAdClick",e);var t=Y(["adNetworkPlatform","mediationPlatform","adType","adId"],e);le("_appClick",t.properties,t.customProperties)},trackIAP:function(e){p("trackIAP",e);var t=Y(["orderId","payAmount","currencyType","payType","productID","productName","productCount","payStatus","failReason"],e),r=t.properties,i=t.customProperties;"function"==typeof n.checkTencentEvents?n.checkTencentEvents(e,r,"_mpPur").then((function(e){le("_appPur",r,i)})):le("_appPur",r,i)},trackAppAttr:function(e){p("trackAppAttr",e);var t=Y(["adNetwork","subChannel","adAccountID","adAccountName","adCampaignID","adCampaignName","adOfferID","adOfferName","adCreativeID","adCreativeName","attributionPlatform"],e);le("_appAttr",t.properties,t.customProperties)},trackOrder:function(e){p("trackOrder",e);var t=Y(["orderId","payAmount","currencyType","payType","status"],e);le("_appOrder",t.properties,t.customProperties)},trackRegister:function(e){p("trackRegister",e);var t=Y(["regType","registerStatus"],e),r=t.properties,i=t.customProperties;"function"==typeof n.checkTencentEvents?n.checkTencentEvents(e,r,"_mpReg").then((function(e){le("_appReg",r,i)})):le("_appReg",r,i)},trackLogin:function(e){p("trackLogin",e);var t=Y(["loginType","loginStatus"],e);le("_appLogin",t.properties,t.customProperties)}},{userInit:function(e){Ce("userInit",e)},userUpdate:function(e){Ce("userUpdate",e)},userAdd:function(e){Ce("userAdd",e)},userUnset:function(e){var t={};Array.isArray(e)&&e.forEach((function(e){t[e]=""})),Ce("userUnset",t)},userAppend:function(e){Ce("userAppend",e)},userDelete:function(e){if(!Me.includes(e))return s(!1,440117,{"{#1}":Me.join(" or ")});Ce(e)}},{setChannel:function(e){p("setChannel",e),P({"reportData.properties._channel":e})},setReferrerTitle:function(e){p("setReferrerTitle",e),P({"reportData.properties._referrer_title":e})},listenErrorMessage:function(e){r.$on("assertMsg",e)}}),Ve=e({version:"1.2.4"},Ne);n.extend({NATIVE:Ve});var qe={identifier:"undefined"!=typeof tt&&tt,mpType:"douyin"},Ke=qe.mpType,Ue=1e3,He="undefined"==typeof App,$e="douyin"===Ke,ze="kwai"===Ke,Be=qe.identifier||{},Fe={mpType:Ke};function Je(e){if("object"!==n.getType(e)||!Object.keys(e).length)return e;var t={};return Object.keys(e).forEach((function(n){t[n]=""+e[n]})),t}function We(e){return He&&ze?(e.from||Ue)+"":(e.scene||Ue)+""}function Ye(){var e={};return He&&$e?Be.getLaunchOptionsSync&&(e=Be.getLaunchOptionsSync()||{}):Be.getEnterOptionsSync&&(e=Be.getEnterOptionsSync()||{}),{scene:We(e),path:e.path||"",queryInfo:Je(e.query||{}),referrerInfo:e.referrerInfo||e.refererInfo||{}}}function Ge(e){var t={},r={"reportData.properties._launch_scene":(t=e||Ye()).scene,"reportData.properties._path":t.path,"reportData.properties._referrer_info":t.referrerInfo};Object.keys(t.queryInfo||{}).length&&(r["reportData.properties._query_info"]=t.queryInfo),n.setStateData(r)}var Xe=["_openid","_unionid","_launch_scene","_path","_query_info","_referrer_info"];var Qe=n.createStorageKey,Ze={setItem:function(e,t,r,i){void 0===i&&(i=!1),t=n.valueToStr(t);try{var o=null==Be.getStorageInfoSync?void 0:Be.getStorageInfoSync(),a=1024*(o.limitSize-o.currentSize-24);if(n.isValueExceedLimit(t)||n.valueToStr(t).length>a)return"function"===n.getType(r)&&r(),!i&&et(e),n.assert(!1,440123)}catch(t){return!i&&et(e),n.assert(!1,440124,{"{#1}":t})}null==Be.setStorageSync||Be.setStorageSync(Qe(e),t)},getItem:function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var r=null==Be.getStorageSync?void 0:Be.getStorageSync(Qe(e));""===r&&(r=null);var i=r;if(t)try{i=JSON.parse(r)||n}catch(e){i=n}return i},deleteItem:function(e){null==Be.removeStorageSync||Be.removeStorageSync(Qe(e))},clear:function(){null==Be.clearStorage||Be.clearStorage()}};function et(e){n.trackLogEvent({state:4,message:"lack local storage",stroage_key:e})}function nt(){return(nt=Object.assign||function(e){for(var t=1;t0?(r--,setTimeout((function(){rt(e,t,r)}),1e3*n.settingData.attDataInterval)):("function"==typeof t&&t({result:i||null}),n.trackLogEvent({state:13,message:"att_fail",isListen:e,retry:n.settingData.attRetryLimit-r,error_message:i}))}function ot(e){return new Promise((function(t){var r=n.Storage.getItem("attr_res",!0,null);return 0===(null==r?void 0:r.s)?t(r.r):"1"===n.Storage.getItem(n.STORAGE_INSTALL_SEND)?rt(e,(function(e){t(e)})):void n.customEvents.$on("install_event_send",(function(){setTimeout((function(){rt(e,(function(e){t(e)}))}),1e3*n.settingData.attDataInterval)}))}))}function at(){var e=n.getDistinctId();n.setStateData({"reportData._distinct_id":e.id,"reportData._distinct_id_type":e.type}),n.customEvents.$emit("ready_to_create_distinct")}n.extend({Storage:Ze}),n.extend({requestHandle:function(e,t){return new Promise((function(r,i){var o={url:"https:"+e.url,method:e.method.toUpperCase(),data:"get"===e.method?e.params:e.data,timeout:t.timeout||6e4,success:function(e){var t=(null==e?void 0:e.data)||{};r(t)},fail:function(e,t){i(e),n.assert&&n.assert(!1,440108,{"{#1}":"code = "+t+" data = "+e})}};(null==t?void 0:t.headers)&&(o.header=t.headers),null==Be.request||Be.request(o)}))}});var st={config:{},customConfig:[]};function ut(){var e,t,n,r,i,o=(i=getCurrentPages(),null==(r=i[i.length-1])?void 0:r.route),a="";return(null==(e=st.customConfig)||null==(t=e.filter((function(e){var t;return a=null==(t=Object.keys(e))?void 0:t[0],null==o?void 0:o.includes(a)})))||null==(n=t[0])?void 0:n[a])||{}}var ct={trackPageView:function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t={}),n.checkObject(t)){var r=ut();(e||!st.config.autoTrackPageView||r.ignoreTrack)&&n.trackEvent("_mpViewScreen",{},t,{_event_type:e?2:3})}},setTrackPageView:function(e){if(n.checkLogEnabled("setTrackPageView",e),!Array.isArray(e)||e.filter((function(e){return!n.isObject(e)})).length)return n.assert(!1,440116);st.customConfig=e},setAutoTrack:function(e){n.checkLogEnabled("setAutoTrack",e),n.checkObject(e)&&("boolean"==typeof e.autoTrack&&(st.config.autoTrackPageView=e.autoTrack,st.config.autoTrackPageClick=e.autoTrack),"boolean"==typeof e.autoTrackPageView&&("boolean"==typeof e.autoTrack?st.config.autoTrackPageView=e.autoTrack&&e.autoTrackPageView:st.config.autoTrackPageView=e.autoTrackPageView),"boolean"==typeof e.autoTrackPageClick&&("boolean"==typeof e.autoTrack?st.config.autoTrackPageClick=e.autoTrack&&e.autoTrackPageClick:st.config.autoTrackPageClick=e.autoTrackPageClick))},trackPageClick:function(e,t){void 0===t&&(t=!1);var r=null==e?void 0:e.currentTarget;if(!r)return n.assert(!1,440102);var i=r.dataset||{},o=ut();if(t||!st.config.allowTrackPageClick||o.ignoreTrack||"true"===i.ignoreTrack){var a=n.stringLikeJsonToObject(null==i?void 0:i.customProperty),s={};s._element_id=i.elementId||r.id,s._element_content=i.content,s._element_name=i.name,s._element_class_name=i.className,s._element_type=i.type,s._element_target_url=i.targetUrl,n.trackEvent("_mpElementClick",s,a,{_event_type:t?2:3})}}},pt=nt({},{setXcxPageTitle:function(e){if(n.checkLogEnabled("setXcxPageTitle",e),!e||"string"!=typeof e||!n.trimStr(e))return n.assert(!1,440105);n.setStateData({"reportData.properties._page_title":e})},getDistinct:function(){return new Promise((function(e){var t=!1,r=n.Storage.getItem("_distinct",!0,null);(null==r?void 0:r.id)?(t=!0,e({result:{distinct_id:r.id,distinct_id_type:r.type}})):n.customEvents.$on("ready_to_create_distinct",(function(){t=!0;var r=n.getDistinctId();e({result:{distinct_id:r.id,distinct_id_type:r.type}})})),setTimeout((function(){t||e({msg:"failed to get distinct",result:null})}),1e3*n.settingData.distinctWaitTime)}))},setOnAttributionListener:function(){return ot(!0)},getAttribution:function(){return ot(!1)},setPluginProperties:function(e){if("[object Object]"===Object.prototype.toString.call(e)){var t=n.getStateData("pluginProperties");n.setStateData({pluginProperties:Object.assign({},t,e)})}}});function lt(e,t){void 0===t&&(t=[]);for(var n=function(e,t){var n=[];for(var r in e)"function"!=typeof e[r]||dt[r]||t.includes(r)||n.push(r);return n}(e,t),r=0;r1&&n.setStateData({"reportData.properties._referrer_name":(null==(t=r[r.length-2])?void 0:t.route)||""}),n.NATIVE.ready((function(e){!function(){var e=st.config.autoTrackPageView,t=ut();if(e&&!t.ignoreTrack){var r=n.filterCustomProperties(t.customProperty||{});ct.trackPageView(!0,r)}}()}))},onReady:function(){},onHide:function(){},onUnload:function(){}};function mt(e,t,n){if(e[t]){var r=e[t];e[t]=function(e){n.call(this,e,t),r.call(this,e)}}else e[t]=function(e){n.call(this,e,t)}}function yt(){var e,t,r;e=App,App=function(t){t.SESDK=n.NATIVE,mt(t,"onShow",_t.onShow),mt(t,"onHide",_t.onHide),mt(t,"onLaunch",_t.onLaunch),e(t)},t=Page,Page=function(e){e||(e={});try{n.customEvents.$on("xcx_proxy_click",(function(){lt(e)}))}catch(e){console.error("proxy event failed")}mt(e,"onLoad",vt.onLoad),mt(e,"onShow",vt.onShow),mt(e,"onReady",vt.onReady),mt(e,"onHide",vt.onHide),mt(e,"onUnload",vt.onUnload),t(e)},r=Component,Component=function(e){e||(e={}),e.methods||(e.methods={}),n.customEvents.$on("xcx_proxy_click",(function(){lt(e.methods)})),mt(e.methods,"onLoad",(function(e){var t;null==(t=getCurrentPages())||t[0],vt.onLoad(e)})),mt(e.methods,"onShow",vt.onShow),r(e)}}function ht(){var e,t,r={_device_type:0,_platform:0,_app_platform:He?"minigame":"miniprogram"},i=null;try{i=Be.getSystemInfoSync()}catch(e){n.assert(!1,440119)}if(i){var o;r._manufacturer=i.brand,r._device_model=i.model,r._device_type=(e=i.platform,(t={other:0,"android phone":1,"android pad":2,ios:3,ipad:4,mac:5,windows:6,devtools:7})[Object.keys(t).find((function(t){return t.indexOf(e)>-1}))||"other"]),r._platform=function(e){var t={other:0,android:1,ios:2,windows:3,mac:4,devtools:8};return t[Object.keys(t).find((function(t){return t.indexOf(e)>-1}))||"other"]}(i.platform);var a=(null==(o=i.system)?void 0:o.split(" "))||[];r._os_version=a.length>1?a[1]:i.system,r._screen_height=i.screenHeight,r._screen_width=i.screenWidth,r._language=i.language,r._app_version=i.version,r._mp_version=i.SDKVersion,r._browser_version=i.version,r._app_name=i.appName}return r}function St(){var e={_launch_scene:Ue,_network_type:1},t=Ye();return e._launch_scene=t.scene,e._path=t.path,e._query_info=t.queryInfo,e._referrer_info=t.referrerInfo,new Promise((function(t){var n;(n={none:0,unknown:1,"2g":2,"3g":3,"4g":4,"5g":5,wifi:9},new Promise((function(e){Be.getNetworkType?Be.getNetworkType({success:function(t){e(n[null==t?void 0:t.networkType]||1)},fail:function(){e(1)}}):e(1)}))).then((function(n){e._network_type=n,t(e)}))}))}function kt(e,t,r,i){void 0===i&&(i=n.settingData.openIdRetryTimes),null==Be.login||Be.login({success:function(o){var a=o||{},s=a.code,u=void 0===s?"":s,c=a.anonymousCode,p=void 0===c?"":c,l={appCode:e,code:u,mpType:t};p&&(l.anonymousCode=p),n.HttpHelper.get("//"+n.settingData.openIdDomain+"/receiver/api/public/openid",l,{timeout:1e3*n.settingData.openIdTimeout}).then((function(n){var o=(null==n?void 0:n.data)||{};o.openid||o.anonymous_openid?"function"==typeof r&&r(o):Dt(e,t,r,i)})).catch((function(){Dt(e,t,r,i)}))},fail:function(){Dt(e,t,r,i)}})}function Dt(e,t,r,i){var o;i>0?kt(e,t,r,--i):((o=n.Storage.getItem("_uuid"))||(o=n.generateUUID(),n.Storage.setItem("_uuid",o),n.setStateData({"reportData._uuid":o})),"function"==typeof r&&r())}var It,bt,Tt=null;function Pt(){var e;if(Tt||(Tt=n.Storage.getItem("_distinct",!0,null)),null==(e=Tt)?void 0:e.id)return Tt;var t=n.getStateData("reportData.properties._openid"),r=n.getStateData("reportData.properties._anonymous_openid"),i=n.getStateData("reportData._uuid"),o={id:t||r||i,type:t?1101:r?1102:1103};return n.Storage.setItem("_distinct",o),o}return n.setStateData({systemEnv:1}),He?(n.trackAppInstall(),null==Be.onShow||Be.onShow((function(e){Ge({scene:We(e),path:e.path||"",queryInfo:Je(e.query||{}),referrerInfo:e.refererInfo||{}}),n.trackAppStart()})),void 0!==(null==globalThis?void 0:globalThis.CocosEngine)&&(Ge(),n.trackAppStart()),null==Be.onHide||Be.onHide((function(){n.trackAppEnd()}))):yt(),n.extend({sdkInitData:(It={_uuid:n.Storage.getItem("_uuid")||""},bt=function(){var e,t=n.Storage.getItem("_system_info",!0);return(null==(e=t)?void 0:e._app_version)||(t=ht(),n.Storage.setItem("_system_info",t)),t}(),bt._mp_type=Fe.mpType,new Promise((function(e){St().then((function(t){var n=Object.assign(bt,t);It.properties=n,It.properties._lib=He?5:4,e(It)}))}))),getOpenId:function(e){var t=e.openid,r=e.anonymous_openid,i=e.unionid,o=void 0===i?"":i,a=t||r;if(n.setStateData({"reportData.properties._openid_type":a?"0":"1","reportData.properties._unionid":o}),a)n.setStateData({isHasOpenId:!0,"reportData.properties._openid":t||"","reportData.properties._anonymous_openid":r||""}),at();else{var s=n.Storage.getItem("_login_info",!0,{})||{},u=s.openid,c=s.unionid,p=s.anonymous_openid;if(u||p)return n.setStateData({isHasOpenId:!0,"reportData.properties._openid":u,"reportData.properties._unionid":o||c,"reportData.properties._anonymous_openid":p}),at();kt(e.appKey,Fe.mpType,(function(e){var t=e||{},r=t.openid,i=void 0===r?"":r,a=t.unionid,s=void 0===a?"":a,u=t.anonymous_openid,c=void 0===u?"":u;(i||c)&&n.Storage.setItem("_login_info",{openid:i,unionid:s,anonymous_openid:c}),n.setStateData({isHasOpenId:!0,"reportData.properties._openid":i,"reportData.properties._unionid":o||s,"reportData.properties._anonymous_openid":c}),at(),n.postEvent()}))}},getDistinctId:Pt,getEnvVersion:function(){var e,t;return Be.getEnvInfoSync&&(null==(e=Be.getEnvInfoSync())||null==(t=e.microapp)?void 0:t.envType)||""},setXcxEventData:function(e){!function(e,t){if(e._distinct_id=t.id,e._distinct_id_type=t.type,e._uuid=n.getStateData("reportData._uuid"),"userset"!==e._type&&Xe.forEach((function(t){e.properties[t]=n.getStateData("reportData.properties."+t)})),He){var r=n.getStateData("pluginProperties");Object.keys(r).forEach((function(t){e.properties[t]=r[t]}))}}(e,Pt()),"userset"!==e._type&&(e.properties._anonymous_openid=n.getStateData("reportData.properties._anonymous_openid"))}}),n.NATIVE}));