| 123456 |
- /**
- * @dn-sdk/minigame v1.5.5
- * (c) 2025
- * @license ISC
- */
- function t(t,e,n){return(e=v(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||n(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function a(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=s(t);if(e){var o=s(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}function u(t,e){if(e&&("object"===l(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function f(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,v(r.key),r)}}function p(t,e,n){return e&&d(t.prototype,e),n&&d(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function v(t){var e=function(t,e){if("object"!==l(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===l(e)?e:String(e)}var h,_,y="LOCAL_ID",g="QUEUE_ACTIONS",m="CLICK_ID",A="QUEUE_LOST_MAP",R="REMOTE_CONFIG",k="REMOTE_COMMON_CONFIG",T="OPENID",E={init:"init",reporting:"reporting",fail:"fail"},S={maxSdkInstance:4,maxQueueLength:500,actionParamMaxLength:1e4,autoTrack:!0,reportThreshold:5,reportDelay:1,inspectDelay:30,cgiBatchSize:50,requestConcurrency:4,requestTimeout:1e4,signVersion:"1.0",realTimeActionList:["START_APP","REGISTER","PURCHASE"]},b={JS_RUN_ERROR:"JS_RUN_ERROR",REQUEST_ERROR:"REQUEST_ERROR",REQUEST_CONFIG_ERROR:"REQUEST_CONFIG_ERROR",JS_QUEUE_LOG:"JS_QUEUE_LOG",PROXY_ERROR:"PROXY_ERROR",PROXY_POLYFILL:"PROXY_POLYFILL",QUEUE_LOST_NUM:"QUEUE_LOST_NUM",REQ_TOTAL:"REQ_TOTAL",SIGN_ERROR:"SIGN_ERROR"},O="ANDROID",I="IOS",w="WINDOWS",C="OSX",x="UNKNOWN",N=1e3,L=100,P=10,M="START_APP",q="ENTER_FOREGROUND",U="ENTER_BACKGROUND",D="ADD_TO_WISHLIST",F="PURCHASE",j="APP_QUIT",B="REGISTER",V="CREATE_ROLE",G="TUTORIAL_FINISH",K="TRUE",Q="FALSE",Y="TENCENT",W="BYTEDANCE",J="KUAISHOU",H="ALIBABA",z="BAIDU",$="OTHERS",X="UNKNOWN",Z="TICKET_INTERVAL_CHANGE",tt=(_=function(t){return"".concat("@dn-sdk/minigame","_").concat("production","_").concat(t)},{getSync:function(t){var e;try{e=wx.getStorageSync(_(t))}catch(t){return console.error("storage get error",t),e}return e},setSync:function(t,e){try{wx.setStorageSync(_(t),e)}catch(t){return console.error("storage set error",t),!1}return!0}}),et=function(){if(h)return h;try{return h=wx.getSystemInfoSync()}catch(t){return{}}},nt=function(){var t;return function(){if(!t){var e=et(),n=e.system,r=void 0===n?"":n,o=(null==r?void 0:r.split(" "))||[],i=function(t){if(!t)return x;var e=(null==t?void 0:t.toUpperCase())||"";return e.indexOf("ANDROID")>-1?O:e.indexOf("IOS")>-1?I:e.indexOf("MAC")>-1?C:e.indexOf("WINDOWS")>-1?w:x}(o[0]),a=function(t){return!t||t.length<=0?"":2===t.length?t[1]:3===t.length&&"Windows"===t[0]?"".concat(t[1]," ").concat(t[2]):t[t.length-1]}(o);t={benchmark_level:e.benchmarkLevel,device_brand:e.brand,screen_height:Math.floor(e.screenHeight),screen_width:Math.floor(e.screenWidth),wx_lib_version:e.SDKVersion,wx_version:e.version,wx_platform:e.platform,device_model:e.model,os:i,os_version:a}}return t}}(),rt=function(){var t;return function(){try{if(t)return t;t||(t=tt.getSync(y)||""),t||(t=mt(),tt.setSync(y,t))}catch(t){}return t}}();var ot=function(){var t="unknown",e=!1;return function(){if(!e)try{wx.getNetworkType({success:function(e){t=e.networkType},fail:function(){t="unknown"}}),wx.onNetworkStatusChange((function(e){t=e.networkType})),e=!0}catch(t){}return t}}();ot();var it=function(){var t="";return function(){return t||(t=tt.getSync(T)||""),t}}(),at=function(){var t;return function(){if(t)return t;try{var e=wx.getAccountInfoSync();return ht(e.miniProgram)?t=e.miniProgram:{}}catch(e){return{}}}}();function ut(t){var e=null==t?void 0:t.query;if(!ht(e))return"";var n="";return e.gdt_vid||[1045,1046,1084].indexOf(null==t?void 0:t.scene)>-1?n=Y:e.clue_token||e.clickid&&e.item_id?n=W:e.callback&&"kuaishou"===e.ksChannel?n=J:e.bd_vid||e.ai&&e.d&&e.q&&e.c?n=z:e.uctrackid?n=H:(e.trackid||e.imp||[1065,1069,1194].indexOf(null==t?void 0:t.scene)>-1&&(e.callback||e.u))&&(n=$),n}function ct(t,e){try{var n=nt(),r=at(),o={sdk_version:"1.5.5",sdk_name:"@dn-sdk/minigame",device_brand:null==n?void 0:n.device_brand,device_model:null==n?void 0:n.device_model,wx_version:null==n?void 0:n.wx_version,wx_lib_version:null==n?void 0:n.wx_lib_version,wx_platform:null==n?void 0:n.wx_platform,os:null==n?void 0:n.os,os_version:null==n?void 0:n.os_version,local_id:rt(),env_version:null==r?void 0:r.envVersion,appid:null==r?void 0:r.appId},i=Object.assign(o,t);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:i,method:"POST",timeout:S.requestTimeout,success:function(t){"function"==typeof e&&200===(null==t?void 0:t.statusCode)&&e()}})}catch(n){xt.error(n)}}var st=function(){function t(){f(this,t)}return p(t,null,[{key:"revise",value:function(t){t>0&&!this.isRevised&&(this.offsetTime=t-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){return this.isRevised?Date.now()+this.offsetTime:-1}}]),t}();function lt(t){return new Promise((function(e,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:t,timeout:S.requestTimeout,success:function(t){ft(t,e,"config/get",n),pt(t)},fail:function(t){dt(t,"config/get",n)}})}))}function ft(t,e,n,r){var o,i,a,u,c=null==t?void 0:t.statusCode,s=null==(o=null==t?void 0:t.data)?void 0:o.code;if(200!==c||0!==s){var l=s;200!==c&&(l="number"==typeof c?-1*c:-888),ct({log_type:b.REQUEST_CONFIG_ERROR,message:"cgiName: ".concat(n,", statusCode: ").concat(c,", code: ").concat(s,", traceid: ").concat(null==(a=null==t?void 0:t.data)?void 0:a.trace_id),code:l}),null==r||r(null==(u=null==t?void 0:t.data)?void 0:u.data)}else e(null==(i=t.data)?void 0:i.data)}function dt(t,e,n){ct({log_type:b.REQUEST_CONFIG_ERROR,message:"cgiName: ".concat(e," , message: ").concat(null==t?void 0:t.errMsg," "),code:"number"==typeof(null==t?void 0:t.errno)?-1*t.errno:-999}),null==n||n(t)}function pt(t){var e,n=1*(null==(e=null==t?void 0:t.header)?void 0:e["Server-Time"]);n>17266752e5&&st.revise(n)}st.offsetTime=0,st.isRevised=!1;var vt=Object.prototype.toString,ht=function(t){return"[object Object]"===vt.call(t)},_t=function(t){return"[object Array]"===vt.call(t)},yt=function(t){return"[object Function]"===vt.call(t)},gt=(new Date).getTime();function mt(){var t=(new Date).getTime(),e=Math.abs(1e3*(t-gt));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(n){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:3&r|8).toString(16).replace(/-/g,"")}))}var At=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Rt=function(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!At.test(t))throw new Error("Invalid argument not valid semver ('".concat(t,"' received)"))},kt=function(t){return isNaN(Number(t))?t:Number(t)},Tt=function(t){var e=t.replace(/^v/,"").replace(/\+.*$/,""),n=function(t,e){return-1===t.indexOf(e)?t.length:t.indexOf(e)}(e,"-"),r=e.substring(0,n).split(".");return r.push(e.substring(n+1)),r},Et=function(t,e){[t,e].forEach(Rt);for(var n=Tt(t),r=Tt(e),o=0;o<Math.max(n.length-1,r.length-1);o++){var i=parseInt(n[o]||"0",10),a=parseInt(r[o]||"0",10);if(i>a)return 1;if(a>i)return-1}var u=n[n.length-1],c=r[r.length-1];if(u&&c)for(var s=u.split(".").map(kt),l=c.split(".").map(kt),f=0;f<Math.max(s.length,l.length);f++){if(void 0===s[f]||"string"==typeof l[f]&&"number"==typeof s[f])return-1;if(void 0===l[f]||"string"==typeof s[f]&&"number"==typeof l[f]||s[f]>l[f])return 1;if(l[f]>s[f])return-1}else if(u||c)return u?-1:1;return 0},St=function(t){return ht(t)?(function(t){var e=["user_action_set_id","secret_key","appid","openid","unionid","user_unique_id","auto_track","auto_attr","on_report_fail","on_report_complete"];for(var n in t)e.includes(n)||xt.warn("Invalid property '".concat(n,"' found in config"))}(t),"number"!=typeof t.user_action_set_id?"user_action_set_id 参数需为 number 类型":t.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeof t.secret_key?"secret_key 参数需为 string 类型":""===t.secret_key.trim()?"缺少 secret_key 参数":32!==t.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeof t.appid?"appid 参数需为 string 类型":""!==t.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"};function bt(t){return Ot()[t]}function Ot(){return S}function It(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var wt=function(t){try{return t&&"string"==typeof t?-1===(t=t.replace(/\s/g,"")).indexOf(".")?t:t.split(".").slice(0,2).join("."):""}catch(e){return t}},Ct=function(){function t(){f(this,t)}return p(t,null,[{key:"error",value:function(t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).error.apply(e,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(r))}},{key:"info",value:function(e){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];t.debug&&(n=console).info.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(o))}},{key:"log",value:function(e){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];t.debug&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(o))}},{key:"warn",value:function(t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console).warn.apply(e,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(r))}},{key:"devLog",value:function(e){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];t.isDev&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(o))}}]),t}(),xt=Ct;xt.debug=!1,xt.isDev=!1;var Nt=function(){var t;return function(){if(!t)try{var e=wx.getLaunchOptionsSync(),n=e.query.gdt_vid||"";n?tt.setSync(m,n):n=tt.getSync(m)||"";var r=JSON.stringify(e);r.length>1e4&&(r=JSON.stringify({cut:1,scene:e.scene})),t={source_scene:e.scene,pkg_channel_id:e.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:ut(e)}}catch(e){t={},xt.log("获取场景值和渠道号失败",e)}return t}}();function Lt(t,e,n){var r=n.value;return n.value=function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];try{return r.apply(this,o)}catch(n){try{xt.error.apply(xt,["calling ".concat(t.constructor.name,".").concat(e," error with arguments")].concat(o)),xt.error(n);var a={log_type:b.JS_RUN_ERROR,message:"[safeExcutable] ".concat(t.constructor.name,".").concat(e,": ").concat(null==n?void 0:n.message),err_stack:null==n?void 0:n.stack};yt(this.reportLog)?this.reportLog(a):ct(a)}catch(a){}}},n}var Pt=Object.defineProperty,Mt=Object.getOwnPropertyDescriptor,qt=function(t,e,n,r){for(var o,i=r>1?void 0:r?Mt(e,n):e,a=t.length-1;a>=0;a--)(o=t[a])&&(i=(r?o(e,n,i):o(i))||i);return r&&i&&Pt(e,n,i),i},Ut=function(){function t(e){var n=e.userActionSetId,r=e.maxLength,o=void 0===r?500:r;f(this,t),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat(g,"_").concat(null==n?void 0:n.toString()),this.maxLength=o,this.userActionSetId=n,this.setTimeStamp(),this.init()}return p(t,[{key:"getItems",value:function(){return this.stack}},{key:"getStorage",value:function(){var t,e=(null==(t=tt)?void 0:t.getSync(this.localStorageKey))||"[]";return JSON.parse(e)}},{key:"reportLostNum",value:function(){var t=this,e=Object.assign({},this.lostActionMaps),n=[];for(var r in e){var o=null==r?void 0:r.split("_");n.push({queue_lost_session_id:o[0],queue_lost_timestamp:o[1],queue_lost_num:e[r]})}n.length&&(this.setTimeStamp(),n.forEach((function(e){var n=Object.assign({},{user_action_set_id:t.userActionSetId,log_type:b.QUEUE_LOST_NUM},e),r=null==e?void 0:e.queue_lost_session_id,o=null==e?void 0:e.queue_lost_timestamp,i="".concat(r,"_").concat(o);ct(n,(function(){It(t.lostActionMaps,i)&&(delete t.lostActionMaps[i],tt.setSync(A,JSON.stringify(t.lostActionMaps)))}))})))}},{key:"getLostMaps",value:function(){return this.lostActionMaps}},{key:"init",value:function(){var t=this,e=this.getStorage(),n=null==e?void 0:e.map((function(t){var e,n;return t.inner_status===(null==(e=E)?void 0:e.reporting)?Object.assign({},t,{inner_status:null==(n=E)?void 0:n.fail,is_retry:!0,retry_count:t.retry_count+1}):t}));this.stack=n,this.lostActionMaps=JSON.parse(tt.getSync(A)||"{}"),setTimeout((function(){t.reportLostNum()}),1e3)}},{key:"addItem",value:function(t){var e;null==(e=null==this?void 0:this.stack)||e.push(t)}},{key:"removeItems",value:function(t){var e,n=null==(e=null==this?void 0:this.stack)?void 0:e.filter((function(e){return!(null!=t&&t.includes(null==e?void 0:e.action_id))}));this.stack=n}},{key:"updateForReportFail",value:function(t){var e;this.stack=null==(e=this.stack)?void 0:e.map((function(e){var n;return null!=t&&t.includes(null==e?void 0:e.action_id)?Object.assign({},e,{inner_status:null==(n=E)?void 0:n.fail,retry_count:e.retry_count+1,is_retry:!0}):e}))}},{key:"updateForReporting",value:function(t){var e;this.stack=null==(e=this.stack)?void 0:e.map((function(e){var n;return null!=t&&t.includes(null==e?void 0:e.action_id)?Object.assign({},e,{inner_status:null==(n=E)?void 0:n.reporting}):e}))}},{key:"updateAllStack",value:function(t){this.stack=t}},{key:"updateToStorage",value:function(){tt.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(t){if(t){var e="".concat(t,"_").concat(this.timeStamp),n=this.lostActionMaps[e]||0;this.lostActionMaps[e]=n+1,tt.setSync(A,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),t}();qt([Lt],Ut.prototype,"getItems",1),qt([Lt],Ut.prototype,"getStorage",1),qt([Lt],Ut.prototype,"reportLostNum",1),qt([Lt],Ut.prototype,"getLostMaps",1),qt([Lt],Ut.prototype,"init",1),qt([Lt],Ut.prototype,"addItem",1),qt([Lt],Ut.prototype,"removeItems",1),qt([Lt],Ut.prototype,"updateForReportFail",1),qt([Lt],Ut.prototype,"updateForReporting",1),qt([Lt],Ut.prototype,"updateAllStack",1),qt([Lt],Ut.prototype,"updateToStorage",1),qt([Lt],Ut.prototype,"updateLostAction",1);var Dt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,jt=function(t,e,n,r){for(var o,i=r>1?void 0:r?Ft(e,n):e,a=t.length-1;a>=0;a--)(o=t[a])&&(i=(r?o(e,n,i):o(i))||i);return r&&i&&Dt(e,n,i),i},Bt=function(t){o(n,Ut);var e=a(n);function n(t){var r,o=t.userActionSetId,i=t.maxLength,a=void 0===i?500:i,u=t.ogEvents,c=void 0===u?[]:u;return f(this,n),(r=e.call(this,{userActionSetId:o,maxLength:a})).ogEvents=c,r}return p(n,[{key:"getReportableActions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=this.getItems(),n=[];return null==e||e.forEach((function(e){var r;(null==n?void 0:n.length)<t&&(null==e?void 0:e.inner_status)!==(null==(r=E)?void 0:r.reporting)&&(null==n||n.push(e))})),n}},{key:"addAction",value:function(t){var e={code:0,message:"成功",actionId:t.action_id},n=this.getItems();if((null==n?void 0:n.length)>=this.maxLength){var r="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");xt.warn(r),ct({user_action_set_id:this.userActionSetId,log_type:b.JS_QUEUE_LOG,message:"队列长度超过限制"});var o=this.sortQueue(t,n);xt.debug&&xt.info("超过".concat(this.maxLength,"条按优先级排序的队列:"),o.concat([]));var i=o.pop();this.updateAllStack(o),this.updateLostAction((null==i?void 0:i.session_id)||""),(null==i?void 0:i.action_id)===t.action_id&&(e={code:103,message:"缓存队列已满,主动丢弃行为"})}else this.addItem(t);return this.updateToStorage(),e}},{key:"removeActions",value:function(t){this.removeItems(t),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(t){this.updateForReportFail(t),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(t){this.updateForReporting(t),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){var t=this.getItems().filter((function(t){var e;return(null==t?void 0:t.inner_status)!==(null==(e=E)?void 0:e.reporting)}));return null==t?void 0:t.length}},{key:"sortQueue",value:function(t,e){var n=this,r={},o=null==t?void 0:t.action_time,i=e.concat([t]),a=function(t){return r[t.action_id]||(r[t.action_id]=n.caculateWeight(o,t)),r[t.action_id]};return i.sort((function(t,e){return a(e)-a(t)}))}},{key:"caculateWeight",value:function(t,e){var n,r=0,o=this.formatWeight(t,null==e?void 0:e.action_time),i=o.ogWeight,a=o.sdkWeight,u=o.userWeight;null!=(n=this.ogEvents)&&n.includes(null==e?void 0:e.action_type)&&(r+=i),null!=e&&e.is_sdk_auto_track?r+=a:r+=u;var c=t-(null==e?void 0:e.action_time)+1;return r=c>0?r+1/c:r}},{key:"formatWeight",value:function(t,e){var n=N,r=P,o=L;return t-e>2592e6&&(n/=100,r/=100,o/=100),{ogWeight:n,sdkWeight:r,userWeight:o}}}]),n}();jt([Lt],Bt.prototype,"getReportableActions",1),jt([Lt],Bt.prototype,"addAction",1),jt([Lt],Bt.prototype,"removeActions",1),jt([Lt],Bt.prototype,"updateActionsForReportFail",1),jt([Lt],Bt.prototype,"updateActionsForReporting",1),jt([Lt],Bt.prototype,"getReportableActionsLength",1),jt([Lt],Bt.prototype,"sortQueue",1),jt([Lt],Bt.prototype,"caculateWeight",1),jt([Lt],Bt.prototype,"formatWeight",1);var Vt=function(){function t(){f(this,t),this.events={}}return p(t,[{key:"subscribe",value:function(e,n){t.checkCallback(n),_t(this.events[e])?this.events[e].push(n):this.events[e]=[n]}},{key:"once",value:function(e,n){t.checkCallback(n),this.subscribe(this.onceEventName(e),n)}},{key:"unsubscribe",value:function(e,n){t.checkCallback(n),_t(this.events[e])&&(this.events[e]=this.events[e].filter((function(t){return t!==n}))),_t(this.events[this.onceEventName(e)])&&(this.events[this.onceEventName(e)]=this.events[this.onceEventName(e)].filter((function(t){return t!==n})))}},{key:"publish",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var o=Date.now();_t(this.events[t])&&this.events[t].forEach((function(t){return t.apply(void 0,[o].concat(n))})),_t(this.events[this.onceEventName(t)])&&(this.events[this.onceEventName(t)].forEach((function(t){return t.apply(void 0,[o].concat(n))})),this.events[this.onceEventName(t)]=[])}},{key:"onceEventName",value:function(t){return"once_event_prefix_".concat(t)}}],[{key:"checkCallback",value:function(e){yt(e)||xt.error(t.ERROR_CALLBACK_IS_NOT_A_FUNCTION)}}]),t}(),Gt=Vt;Gt.ERROR_CALLBACK_IS_NOT_A_FUNCTION="callback 不是函数";var Kt=new Gt,Qt=["REGISTER","VIEW_CONTENT","ADD_TO_CART","PURCHASE","COMPLETE_ORDER","ADD_TO_WISHLIST","START_APP","CREATE_ROLE","AUTHORIZE","TUTORIAL_FINISH","START_PAY","FINISH_PAY"],Yt="START_APP",Wt="TICKET",Jt="ENTER_FOREGROUND",Ht="ENTER_BACKGROUND",zt="LOGIN",$t="SHARE",Xt="TAP_GAME_CLUB",Zt="CREATE_GAME_CLUB",te="CREATE_GAME_ROOM",ee="JOIN_GAME_ROOM",ne="FINISH_PAY",re="START_PAY",oe="ADD_TO_WISHLIST",ie=["REGISTER","START_APP","RE_ACTIVE"],ae=["TICKET","ENTER_FOREGROUND","ENTER_BACKGROUND"],ue=function(){function t(){f(this,t),this.channelClaimActionList=ie,this.noClaimActionList=ae,this.realTimeActionList=S.realTimeActionList,this.ticketInterval=60,this.requestTimeout=S.requestTimeout,this.loadConfig()}return p(t,[{key:"getChannelClaimActionList",value:function(){return this.channelClaimActionList}},{key:"getNoClaimActionList",value:function(){return this.noClaimActionList}},{key:"getRealTimeActionList",value:function(){return this.realTimeActionList}},{key:"getTicketInterval",value:function(){return this.ticketInterval}},{key:"getRequestTimeout",value:function(){return this.requestTimeout}},{key:"loadConfig",value:function(){var t=this;try{if("undefined"==typeof wx)return;var e=tt.getSync(k);e&&this.updateConfig(e),lt({conf_name:"mini_game_sdk_common",conf_key:"config"}).then((function(e){e&&ht(e)&&(t.updateConfig(e),tt.setSync(k,e))}))}catch(e){console.error(e)}}},{key:"updateConfig",value:function(t){t.channelClaimActionList&&_t(t.channelClaimActionList)&&(this.channelClaimActionList=t.channelClaimActionList),t.noClaimActionList&&_t(t.noClaimActionList)&&(this.noClaimActionList=t.noClaimActionList),t.realTimeActionList&&_t(t.realTimeActionList)&&(this.realTimeActionList=t.realTimeActionList),t.ticketInterval&&"number"==typeof t.ticketInterval&&t.ticketInterval>1&&t.ticketInterval!==this.ticketInterval&&(this.ticketInterval=t.ticketInterval,Kt.publish(Z)),t.requestTimeout&&"number"==typeof t.requestTimeout&&t.requestTimeout>5e3&&(this.requestTimeout=t.requestTimeout)}}]),t}(),ce=new ue,se=Yt,le=Wt,fe=Jt,de=Ht,pe=function(){var t=!1,e=!1,n=!0,r=!0,o=!0,i=!1;return function(){if(!i){i=!0;var a=tt.getSync(R);if((null==a?void 0:a.bg)===K?t=!0:(null==a?void 0:a.bg)===Q&&(t=!1),(null==a?void 0:a.fg)===K?e=!0:(null==a?void 0:a.fg)===Q&&(e=!1),(null==a?void 0:a.st)===K?n=!0:(null==a?void 0:a.st)===Q&&(n=!1),(null==a?void 0:a.ti)===K?r=!0:(null==a?void 0:a.ti)===Q&&(r=!1),xt.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",t,e,n,r),n&&Kt.publish(se),r){var u=function(){o&&Kt.publish(le)},c=setInterval(u,1e3*ce.getTicketInterval());Kt.subscribe(Z,(function(){c&&clearInterval(c),c=setInterval(u,1e3*ce.getTicketInterval())}))}wx.onShow((function(t){if(o=!0,e){var n="";try{(n=JSON.stringify(t)).length>1e4&&(n=JSON.stringify({cut:1,scene:t.scene}))}catch(t){}Kt.publish(fe,{enter_options:n})}})),wx.onHide((function(){o=!1,t&&Kt.publish(de)}))}}}(),ve="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function he(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _e,ye=he((function(){var t,e=null;function n(t){return!!t&&("object"==l(t)||"function"==typeof t)}function r(t){if(null!==t&&!n(t))throw new TypeError("Object prototype may only be an Object or null: "+t)}var o=Object,i=!(!o.create&&{__proto__:null}instanceof o),a=o.create||(i?function(t){return r(t),{__proto__:t}}:function(t){if(r(t),null===t)throw new SyntaxError("Native Object.create is required to create objects with null prototype");var e=function(){};return e.prototype=t,new e}),u=function(){return null},c=o.getPrototypeOf||([].__proto__===Array.prototype?function(t){var e=t.__proto__;return n(e)?e:null}:u);return t=function(s,l){if(void 0===(this&&this instanceof t?this.constructor:void 0))throw new TypeError("Constructor Proxy requires 'new'");if(!n(s)||!n(l))throw new TypeError("Cannot create proxy with a non-object as target or handler");var f=function(){};e=function(){s=null,f=function(t){throw new TypeError("Cannot perform '".concat(t,"' on a proxy that has been revoked"))}},setTimeout((function(){e=null}),0);var d=l;for(var p in l={get:null,set:null,apply:null,construct:null},d){if(!(p in l))throw new TypeError("Proxy polyfill does not support trap '".concat(p,"'"));l[p]=d[p]}"function"==typeof d&&(l.apply=d.apply.bind(d));var v,h=c(s),_=!1,y=!1;"function"==typeof s?(v=function(){var t=this&&this.constructor===v,e=Array.prototype.slice.call(arguments);return f(t?"construct":"apply"),t&&l.construct?l.construct.call(this,s,e):!t&&l.apply?l.apply(s,this,e):t?(e.unshift(s),new(s.bind.apply(s,e))):s.apply(this,e)},_=!0):s instanceof Array?(v=[],y=!0):v=i||null!==h?a(h):{};var g=l.get?function(t){return f("get"),l.get(this,t,v)}:function(t){return f("get"),this[t]},m=l.set?function(t,e){f("set"),l.set(this,t,e,v)}:function(t,e){f("set"),this[t]=e},A=o.getOwnPropertyNames(s),R={};A.forEach((function(t){if(!_&&!y||!(t in v)){var e={enumerable:!!o.getOwnPropertyDescriptor(s,t).enumerable,get:g.bind(s,t),set:m.bind(s,t)};o.defineProperty(v,t,e),R[t]=!0}}));var k=!0;if(_||y){var T=o.setPrototypeOf||([].__proto__===Array.prototype?function(t,e){return r(e),t.__proto__=e,t}:u);h&&T(v,h)||(k=!1)}if(l.get||!k)for(var E in s)R[E]||o.defineProperty(v,E,{get:g.bind(s,E)});return o.seal(s),o.seal(v),v},t.revocable=function(n,r){return{proxy:new t(n,r),revoke:e}},t})),ge={};try{_e||(_e=ye())}catch(h){Te(h)}function me(t,n,r,o){try{if(!_e||null==t||!t[n])return;t[n]=new _e(t[n],{apply:function(t,n,i){var a,u;o&&ke((function(){return o.apply(void 0,e(i))}));var c=!!(null!=(a=i[0])&&a.success||null!=(u=i[0])&&u.fail);c&&["success","fail"].forEach((function(t){if(i[0][t])try{i[0][t]=new _e(i[0][t],{apply:function(n,o,a){return ke((function(){return r.apply(void 0,[t,i[0]].concat(e(a)))})),n.apply(o,a)}})}catch(t){Te(t)}}));var s=t.apply(n,i);return!c&&s&&"[object Promise]"===Object.prototype.toString.call(s)?s.then((function(t){return ke((function(){return r("success",i[0],t)})),t})).catch((function(t){throw ke((function(){return r("fail",i[0],t)})),t})):s}})}catch(t){Te(t)}}function Ae(t,n,r){try{if(!_e||null==t||!t[n])return;t[n]=new _e(t[n],{apply:function(t,n,o){var i="function"==typeof o[0];if(i)try{o[0]=new _e(o[0],{apply:function(t,n,o){var i=t.call.apply(t,[n].concat(e(o)));return ke((function(){return r(i)})),i}})}catch(t){Te(t)}var a=t.call.apply(t,[n].concat(e(o)));return i||ke((function(){return r(a)})),a}})}catch(t){Te(t)}}function Re(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4?arguments[4]:void 0;try{if(!_e||null==t||!t[n])return;t[n]=new _e(t[n],{apply:function(t,a,u){var c=t.call.apply(t,[a].concat(e(u)));return(!r||!ge[n])&&(ke((function(){return null==i?void 0:i(c)})),o.forEach((function(t){var e=t.eventName,n=t.isAsync,r=t.proxyEvent;n?me(c,e,r):Ae(c,e,r)}))),r&&(ge[n]=!0),c}})}catch(t){Te(t)}}function ke(t){try{t()}catch(t){Te(t)}}function Te(t){ct({log_type:b.PROXY_ERROR,message:null==t?void 0:t.message,err_stack:null==t?void 0:t.stack})}var Ee=zt,Se=oe,be=$t,Oe=Xt,Ie=Zt,we=ee,Ce=re,xe=ne,Ne=function(){var t=!1;return function(){t||(t=!0,me(wx,"login",(function(t){"success"===t&&Kt.publish(Ee)})),Ae(wx,"onAddToFavorites",(function(){Kt.publish(Se)})),Ae(wx,"onShareTimeline",(function(){Kt.publish(be,{target:"TIME_LINE",trigger:"MENU"})})),Ae(wx,"onShareAppMessage",(function(){Kt.publish(be,{target:"APP_MESSAGE",trigger:"MENU"})})),Ae(wx,"shareAppMessage",(function(){Kt.publish(be,{target:"APP_MESSAGE",trigger:"BUTTON"})})),Re(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){Kt.publish(Oe)}}],(function(){Kt.publish(Ie)})),Re(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(t){"success"===t&&Kt.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(t){"success"===t&&Kt.publish(we)}}]),me(wx,"requestMidasPayment",(function(t,e){Kt.publish(xe,{status:"success"===t?"SUCCESS":"FAIL",quantity:(null==e?void 0:e.buyQuantity)||0,mode:(null==e?void 0:e.mode)||"",platform:(null==e?void 0:e.platform)||"",no:(null==e?void 0:e.outTradeNo)||"",payType:"Midas"})}),(function(t){Kt.publish(Ce,{quantity:(null==t?void 0:t.buyQuantity)||0,mode:(null==t?void 0:t.mode)||"",platform:(null==t?void 0:t.platform)||"",no:(null==t?void 0:t.outTradeNo)||"",payType:"Midas"})})),me(wx,"requestMidasPaymentGameItem",(function(t,e){var n=(e||{}).signData;Kt.publish(xe,{status:"success"===t?"SUCCESS":"FAIL",quantity:(null==n?void 0:n.buyQuantity)||0,mode:(null==n?void 0:n.mode)||"",platform:(null==n?void 0:n.platform)||"",no:(null==n?void 0:n.outTradeNo)||"",p:(null==n?void 0:n.goodsPrice)||0,productId:(null==n?void 0:n.productId)||"",payType:"MidasGameItem"})}),(function(t){var e=(t||{}).signData;Kt.publish(Ce,{quantity:(null==e?void 0:e.buyQuantity)||0,mode:(null==e?void 0:e.mode)||"",platform:(null==e?void 0:e.platform)||"",no:(null==e?void 0:e.outTradeNo)||"",p:(null==e?void 0:e.goodsPrice)||0,productId:(null==e?void 0:e.productId)||"",payType:"MidasGameItem"})})))}}(),Le=function(){function t(){f(this,t)}return p(t,null,[{key:"isEmpty",value:function(t){return null==t||"string"==typeof t&&""===t.trim()}},{key:"format",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.replace(/\${(\d+)}/g,(function(t,e){return n[e]}))}},{key:"customStringify",value:function(t){var e=[];try{return JSON.stringify(t,(function(t,n){if(void 0===n)return"undefined";if("object"==l(n)&&null!==n){if(-1!==e.indexOf(n))return"[Circular]";e.push(n)}return"bigint"==typeof n?n.toString():n}))}catch(t){return"[Param Error]"}}}]),t}(),Pe=/^([a-zA-Z][a-zA-Z\d_]{0,63})$/i,Me=/^ams_reserved_(.*)/i,qe=function(){function t(){f(this,t)}return p(t,null,[{key:"validateActionType",value:function(e){return Le.isEmpty(e)?(xt.error(t.ERROR_ACTION_TYPE_NULL),!1):!!Pe.test(e)||(xt.error(t.ERROR_ACTION_TYPE_INVALID),!1)}},{key:"validateActionParam",value:function(e){if(!e)return!0;if(!ht(e))return xt.error(t.ERROR_ACTION_PARAM_IS_NOT_OBJECT),!1;for(var n in e){if(Le.isEmpty(n))return xt.error(t.ERROR_ACTION_PARAM_KEY_NULL),!1;if(!Pe.test(n))return xt.error(t.ERROR_ACTION_PARAM_KEY_INVALID),!1;Me.test(n)&&xt.warn(t.WARN_ACTION_PARAM_KEY_RESERVED);var r=e[n];if(!t.isValidValue(r))return xt.error(Le.format(t.ERROR_ACTION_PARAM_VALUE_INVALID,n,r)),!1;if(_t(r)){if(!t.isValidArrayValue(r)){for(var o=0;o<r.length;o++)xt.error(Le.format(t.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID,n,Le.customStringify(r),o,r[o]));return!1}if(!t.checkArrayElementTypes(r))return xt.error(t.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE),!1}}return!0}},{key:"isValidValue",value:function(t){return null==t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||_t(t))}},{key:"isValidArrayValue",value:function(t){for(var e=0;e<t.length;e++){var n=t[e];if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return!1}return!0}},{key:"checkArrayElementTypes",value:function(t){if(!t||t.length<=1)return!0;for(var e=l(t[0]),n=1;n<t.length;n++)if(l(t[n])!==e)return!1;return!0}}]),t}(),Ue=qe;Ue.ERROR_ACTION_TYPE_NULL="在track方法中,action_type参数不能为空!",Ue.ERROR_ACTION_TYPE_INVALID="在track方法中,action_type参数只能包含字母、数字和下划线,且只能以字母开头,长度不能超过64个字符!",Ue.ERROR_ACTION_PARAM_KEY_NULL="在track方法中,action_param参数的key不能为空!",Ue.ERROR_ACTION_PARAM_KEY_INVALID="在track方法中,action_param参数的key只能包含字母、数字和下划线,且不能以数字开头,长度不能超过64个字符!",Ue.WARN_ACTION_PARAM_KEY_RESERVED="SDK内部预留参数的key均以'ams_reserved_'开头,该参数的值会被SDK内部覆盖,请不要使用!",Ue.ERROR_ACTION_PARAM_VALUE_INVALID="在track方法中,action_param参数的value必须是String/Number/Boolean/Array中的一种![key=${0}, value=${1}]",Ue.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中的每个元素必须是String/Number/Boolean中的一种![key=${0}, value=${1}, 数组的第${2}个元素为${3}]",Ue.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中所有元素的类型必须是同一种!",Ue.ERROR_ACTION_PARAM_IS_NOT_OBJECT="action_param 参数不是Object";var De={exports:{}};!function(t){!function(e){function n(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function r(t,e,r,o,i,a){return n(function(t,e){return t<<e|t>>>32-e}(n(n(e,t),n(o,a)),i),r)}function o(t,e,n,o,i,a,u){return r(e&n|~e&o,t,e,i,a,u)}function i(t,e,n,o,i,a,u){return r(e&o|n&~o,t,e,i,a,u)}function a(t,e,n,o,i,a,u){return r(e^n^o,t,e,i,a,u)}function u(t,e,n,o,i,a,u){return r(n^(e|~o),t,e,i,a,u)}function c(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var r,c,s,l,f,d=1732584193,p=-271733879,v=-1732584194,h=271733878;for(r=0;r<t.length;r+=16)c=d,s=p,l=v,f=h,d=o(d,p,v,h,t[r],7,-680876936),h=o(h,d,p,v,t[r+1],12,-389564586),v=o(v,h,d,p,t[r+2],17,606105819),p=o(p,v,h,d,t[r+3],22,-1044525330),d=o(d,p,v,h,t[r+4],7,-176418897),h=o(h,d,p,v,t[r+5],12,1200080426),v=o(v,h,d,p,t[r+6],17,-1473231341),p=o(p,v,h,d,t[r+7],22,-45705983),d=o(d,p,v,h,t[r+8],7,1770035416),h=o(h,d,p,v,t[r+9],12,-1958414417),v=o(v,h,d,p,t[r+10],17,-42063),p=o(p,v,h,d,t[r+11],22,-1990404162),d=o(d,p,v,h,t[r+12],7,1804603682),h=o(h,d,p,v,t[r+13],12,-40341101),v=o(v,h,d,p,t[r+14],17,-1502002290),d=i(d,p=o(p,v,h,d,t[r+15],22,1236535329),v,h,t[r+1],5,-165796510),h=i(h,d,p,v,t[r+6],9,-1069501632),v=i(v,h,d,p,t[r+11],14,643717713),p=i(p,v,h,d,t[r],20,-373897302),d=i(d,p,v,h,t[r+5],5,-701558691),h=i(h,d,p,v,t[r+10],9,38016083),v=i(v,h,d,p,t[r+15],14,-660478335),p=i(p,v,h,d,t[r+4],20,-405537848),d=i(d,p,v,h,t[r+9],5,568446438),h=i(h,d,p,v,t[r+14],9,-1019803690),v=i(v,h,d,p,t[r+3],14,-187363961),p=i(p,v,h,d,t[r+8],20,1163531501),d=i(d,p,v,h,t[r+13],5,-1444681467),h=i(h,d,p,v,t[r+2],9,-51403784),v=i(v,h,d,p,t[r+7],14,1735328473),d=a(d,p=i(p,v,h,d,t[r+12],20,-1926607734),v,h,t[r+5],4,-378558),h=a(h,d,p,v,t[r+8],11,-2022574463),v=a(v,h,d,p,t[r+11],16,1839030562),p=a(p,v,h,d,t[r+14],23,-35309556),d=a(d,p,v,h,t[r+1],4,-1530992060),h=a(h,d,p,v,t[r+4],11,1272893353),v=a(v,h,d,p,t[r+7],16,-155497632),p=a(p,v,h,d,t[r+10],23,-1094730640),d=a(d,p,v,h,t[r+13],4,681279174),h=a(h,d,p,v,t[r],11,-358537222),v=a(v,h,d,p,t[r+3],16,-722521979),p=a(p,v,h,d,t[r+6],23,76029189),d=a(d,p,v,h,t[r+9],4,-640364487),h=a(h,d,p,v,t[r+12],11,-421815835),v=a(v,h,d,p,t[r+15],16,530742520),d=u(d,p=a(p,v,h,d,t[r+2],23,-995338651),v,h,t[r],6,-198630844),h=u(h,d,p,v,t[r+7],10,1126891415),v=u(v,h,d,p,t[r+14],15,-1416354905),p=u(p,v,h,d,t[r+5],21,-57434055),d=u(d,p,v,h,t[r+12],6,1700485571),h=u(h,d,p,v,t[r+3],10,-1894986606),v=u(v,h,d,p,t[r+10],15,-1051523),p=u(p,v,h,d,t[r+1],21,-2054922799),d=u(d,p,v,h,t[r+8],6,1873313359),h=u(h,d,p,v,t[r+15],10,-30611744),v=u(v,h,d,p,t[r+6],15,-1560198380),p=u(p,v,h,d,t[r+13],21,1309151649),d=u(d,p,v,h,t[r+4],6,-145523070),h=u(h,d,p,v,t[r+11],10,-1120210379),v=u(v,h,d,p,t[r+2],15,718787259),p=u(p,v,h,d,t[r+9],21,-343485551),d=n(d,c),p=n(p,s),v=n(v,l),h=n(h,f);return[d,p,v,h]}function s(t){var e,n="",r=32*t.length;for(e=0;e<r;e+=8)n+=String.fromCharCode(t[e>>5]>>>e%32&255);return n}function l(t){var e,n=[];for(n[(t.length>>2)-1]=void 0,e=0;e<n.length;e+=1)n[e]=0;var r=8*t.length;for(e=0;e<r;e+=8)n[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return n}function f(t){var e,n,r="0123456789abcdef",o="";for(n=0;n<t.length;n+=1)e=t.charCodeAt(n),o+=r.charAt(e>>>4&15)+r.charAt(15&e);return o}function d(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return s(c(l(t),8*t.length))}(d(t))}function v(t,e){return function(t,e){var n,r,o=l(t),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=c(o,8*t.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],a[n]=1549556828^o[n];return r=c(i.concat(l(e)),512+8*e.length),s(c(a.concat(r),640))}(d(t),d(e))}function h(t,e,n){return e?n?v(e,t):function(t,e){return f(v(t,e))}(e,t):n?p(t):function(t){return f(p(t))}(t)}t.exports?t.exports=h:e.md5=h}(ve)}(De);var Fe=he(De.exports),je="function"==typeof btoa,Be="function"==typeof Buffer;"function"==typeof TextDecoder&&new TextDecoder;var Ve,Ge="function"==typeof TextEncoder?new TextEncoder:void 0,Ke=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");Ve={},Ke.forEach((function(t,e){return Ve[t]=e}));var Qe=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);var Ye=je?function(t){return btoa(t)}:Be?function(t){return Buffer.from(t,"binary").toString("base64")}:function(t){for(var e,n,r,o,i="",a=t.length%3,u=0;u<t.length;){if((n=t.charCodeAt(u++))>255||(r=t.charCodeAt(u++))>255||(o=t.charCodeAt(u++))>255)throw new TypeError("invalid character found");i+=Ke[(e=n<<16|r<<8|o)>>18&63]+Ke[e>>12&63]+Ke[e>>6&63]+Ke[63&e]}return a?i.slice(0,a-3)+"===".substring(a):i},We=Be?function(t){return Buffer.from(t).toString("base64")}:function(t){for(var e=[],n=0,r=t.length;n<r;n+=4096)e.push(Qe.apply(null,t.subarray(n,n+4096)));return Ye(e.join(""))},Je=function(t){if(t.length<2)return(e=t.charCodeAt(0))<128?t:e<2048?Qe(192|e>>>6)+Qe(128|63&e):Qe(224|e>>>12&15)+Qe(128|e>>>6&63)+Qe(128|63&e);var e=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return Qe(240|e>>>18&7)+Qe(128|e>>>12&63)+Qe(128|e>>>6&63)+Qe(128|63&e)},He=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,ze=Be?function(t){return Buffer.from(t,"utf8").toString("base64")}:Ge?function(t){return We(Ge.encode(t))}:function(t){return Ye(function(t){return t.replace(He,Je)}(t))};var $e=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,Ze=function(t,e,n,r){for(var o,i=r>1?void 0:r?Xe(e,n):e,a=t.length-1;a>=0;a--)(o=t[a])&&(i=(r?o(e,n,i):o(i))||i);return r&&i&&$e(e,n,i),i},tn=function(){function t(e){var n=this;f(this,t),this.cgiBatchSize=S.cgiBatchSize,this.reportThreshold=S.reportThreshold,this.reportDelay=S.reportDelay,this.triggerExecuteSend=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return clearTimeout(e),e=setTimeout((function(){var e=t.apply(void 0,i);r.forEach((function(t){return t(e)})),r=[]}),n),new Promise((function(t){return r.push(t)}))}}((function(){n.executeSend()}),1e3*this.reportDelay),this.inspectDelay=S.inspectDelay,this.inspectTimer=void 0,this.isNeedContinueSend=!1,this.getBaseInfo=e.getBaseInfo,this.reportLog=e.reportLog,this.queueManager=e.queueManager,this.configManager=e.configManager,this.onReportComplete=e.onReportComplete,this.onReportFail=e.onReportFail,this.flushSend(),this.startInspectTimer()}return p(t,[{key:"batchSend",value:function(){var t,e=this.queueManager.getReportableActions(this.reportThreshold);if(e.length>=this.reportThreshold)this.executeSend();else{var n=(null==(t=this.configManager)?void 0:t.getRealTimeActionList())||S.realTimeActionList;e.some((function(t){return n.indexOf(t.action_type)>-1&&!t.is_retry}))?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){var e=this;if(t.currentRequestCount>=t.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;var n=(t.requestConcurrency-t.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),o=this.getBaseInfo();if(!o.openid&&!o.unionid&&(xt.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter((function(t){return null==t?void 0:t.ad_trace_id}))),!(r.length<=0)){n<this.queueManager.getReportableActionsLength()&&(this.isNeedContinueSend=!0),t.currentRequestCount+=Math.ceil(r.length/this.cgiBatchSize);for(var i=[],a=0;a<r.length;a+=this.cgiBatchSize){var u=this.generateActionReportParams(r.slice(a,a+this.cgiBatchSize));i.push(this.report(u))}Promise.all(i).then((function(t){var n=t.some((function(t){return t>=0}));e.isNeedContinueSend&&n&&e.executeSend()})).catch((function(t){xt.error(t),e.reportLog({message:"executeSend catch: ".concat(t.message),log_type:b.JS_RUN_ERROR,err_stack:t.stack})}))}}}},{key:"generateActionReportParams",value:function(t){var e=[],n=[],r=this.getBaseInfo();return t.forEach((function(t){n.push(t.action_id);var r=Object.assign({},t);delete r.inner_status,e.push(r)})),{data:{info:r,actions:e},actionIdList:n}}},{key:"dealSuccessData",value:function(t,e,n){[51001,51003].indexOf(null==t?void 0:t.code)>-1?this.queueManager.updateActionsForReportFail(e):this.queueManager.removeActions(e),0!==(null==t?void 0:t.code)&&(this.reportLog({log_type:b.REQUEST_ERROR,code:null==t?void 0:t.code,message:"trace_id: ".concat(null==t?void 0:t.trace_id,",msg: ").concat(null==t?void 0:t.message)}),xt.error("上报失败:",t)),this.doTrackCallbackFn(this.onReportComplete,t,n),-1===[0,51001,51003].indexOf(null==t?void 0:t.code)&&this.doTrackCallbackFn(this.onReportFail,t,n)}},{key:"dealFailData",value:function(t,e,n){this.queueManager.updateActionsForReportFail(e),this.reportLog({log_type:b.REQUEST_ERROR,code:t.code,message:t.message}),xt.error("上报失败:",t),this.doTrackCallbackFn(this.onReportComplete,t,n)}},{key:"report",value:function(e){var n=this,r=e.data,o=e.actionIdList;return this.queueManager.updateActionsForReporting(o),xt.debug&&(xt.info("上报行为类型: ","【".concat(r.actions.map((function(t){return t.action_type})).join("、"),"】")),xt.info("上报请求参数: ",r)),new Promise((function(e){var i,a,u,c,s,f,d,p,v=Date.now();try{var h=function(t){var e="",n=null==t?void 0:t.appid,r=null==t?void 0:t.secret_key,o=null==t?void 0:t.sdk_version,i=null==t?void 0:t.timestamp;if(!(n&&r&&o&&i&&32===r.length))return e;for(var a=Fe(o+n+i),u=0;u<32;u++)e+=u%2==0?r[u]:a[u];return e}({appid:null==(i=null==r?void 0:r.info)?void 0:i.appid,secret_key:null==(a=null==r?void 0:r.info)?void 0:a.secret_key,sdk_version:null==(u=null==r?void 0:r.info)?void 0:u.sdk_version,timestamp:v}),_=function(t){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?function(t){return t.replace(/=/g,"").replace(/[+\/]/g,(function(t){return"+"==t?"-":"_"}))}(ze(t)):ze(t)}(JSON.stringify(r));d={"Client-Time":v,"Sign-Value":Fe(_+(null==(c=null==r?void 0:r.info)?void 0:c.user_action_set_id)+(null==(s=null==r?void 0:r.info)?void 0:s.secret_key)+h),"Sign-Version":S.signVersion,"content-type":"text/plain;charset=UTF-8"},p=_}catch(h){d={"Client-Time":v},p=r,n.reportLog({log_type:b.SIGN_ERROR,message:"sign error msg: ".concat(null==h?void 0:h.message),err_stack:null==h?void 0:h.stack}),xt.error(h)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(f=n.configManager)?void 0:f.getRequestTimeout())||S.requestTimeout,header:d,data:p,success:function(i){var a,u;xt.devLog("上报接口返回码:",null==(a=null==i?void 0:i.data)?void 0:a.code);var c=(null==(u=null==i?void 0:i.header)?void 0:u["Server-Time"])||-1;if(st.revise(c),t.currentRequestCount-=1,200===(null==i?void 0:i.statusCode))return n.dealSuccessData(null==i?void 0:i.data,o,r),void e((null==i?void 0:i.data).code);var s="";try{s="object"==l(null==i?void 0:i.data)?JSON.stringify(null==i?void 0:i.data):null==i?void 0:i.data}catch(t){xt.error(t)}var f={code:"number"==typeof(null==i?void 0:i.statusCode)?-1*i.statusCode:-888,message:"statusCode: ".concat(null==i?void 0:i.statusCode,", data: ").concat(s)};n.dealFailData(f,o,r),e(f.code)},fail:function(i){xt.devLog("上报失败:",i),t.currentRequestCount-=1;var a={code:"number"==typeof(null==i?void 0:i.errno)?-1*i.errno:-999,message:null==i?void 0:i.errMsg};n.dealFailData(a,o,r),e(a.code)}})}))}},{key:"startInspectTimer",value:function(){var e=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout((function(){t.currentRequestCount>=t.requestConcurrency&&(t.currentRequestCount=t.requestConcurrency-1),e.executeSend(),e.startInspectTimer()}),1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(t,e,n){if("function"==typeof t)try{for(var r=[],o=0;o<n.actions.length;o++)if(!n.actions[o].is_sdk_auto_track){var i=n.actions[o],a=i.action_type,u=i.action_param,c=i.action_id,s=i.action_time;r.push({action_type:a,action_param:u,action_id:c,action_time:s})}if(r.length){var l=n.info,f=l.user_action_set_id,d=l.appid,p=l.openid,v=l.unionid,h=l.user_unique_id;t({code:null==e?void 0:e.code,message:null==e?void 0:e.message,data:{actions:r,info:{user_action_set_id:f,appid:d,openid:p,unionid:v,user_unique_id:h}}})}}catch(r){xt.error("返回上报回调数据异常:",r)}}}],[{key:"setRequestConcurrency",value:function(e){"number"==typeof e?e<1?xt.error("网络请求最大并发量不能小于1"):e>10?xt.error("网络请求最大并发量不能大于10"):t.requestConcurrency=e:xt.error("网络请求最大并发量需设置为数字")}}]),t}(),en=tn;en.currentRequestCount=0,en.requestConcurrency=S.requestConcurrency,Ze([Lt],en.prototype,"batchSend",1),Ze([Lt],en.prototype,"flushSend",1),Ze([Lt],en.prototype,"executeSend",1);var nn=Yt,rn=Wt,on=Jt,an=Ht,un=zt,cn=oe,sn=$t,ln=Xt,fn=Zt,dn=ee,pn=re,vn=ne,hn=te,_n=function(){function e(){f(this,e)}return p(e,[{key:"install",value:function(e,n){var r=function(n){Kt.subscribe(n,function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.track(n,Object.assign(r||{},i,t(t({},In,!0),wn,o)))}}(n))};r(rn),r(nn),r(on),r(an),"all"===n&&(r(un),r(cn),r(sn),r(fn),r(ln),r(hn),r(dn),r(pn),r(vn))}}]),e}(),yn=function(){function e(){f(this,e),this.special_method_symbol=Symbol("special_method_symbol")}return p(e,[{key:"onPurchase",value:function(t){return"number"!=typeof t&&xt.warn("付费金额需要为数字"),t<=0&&xt.warn("付费金额需要大于0"),this.wrapTrack(F,{value:t})}},{key:"onEnterForeground",value:function(){return this.wrapTrack(q)}},{key:"onEnterBackground",value:function(){return this.wrapTrack(U)}},{key:"onAppStart",value:function(){return this.wrapTrack(M)}},{key:"onAppQuit",value:function(){return this.wrapTrack(j)}},{key:"onAddToWishlist",value:function(){return this.wrapTrack(D)}},{key:"wrapTrack",value:function(e,n){return this.track(e,Object.assign(n||{},t({},this.special_method_symbol,1)))}}]),e}(),gn=function(t){o(n,yn);var e=a(n);function n(){return f(this,n),e.apply(this,arguments)}return p(n,[{key:"onRegister",value:function(){return this.wrapTrack(B)}},{key:"onCreateRole",value:function(t){return t&&"string"!=typeof t&&xt.warn("角色名称需要为字符串"),this.wrapTrack(V,t?{name:t}:{})}},{key:"onTutorialFinish",value:function(){return this.wrapTrack(G)}}]),n}(),mn="(如果确认无误,请忽略该提示)",An=function(){var t=[];return{requestActionList:function(){try{lt({conf_name:"data_nexus_common",conf_key:"action_types"}).then((function(e){_t(e)&&(t=e)}))}catch(t){xt.error(t)}},getActionList:function(){return t}}}();function Rn(t,e){try{t.is_sdk_auto_track||(function(t){try{var e=An.getActionList();if(!e.includes(t)){var r,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}(e);try{for(o.s();!(r=o.n()).done;){var i=r.value;if(kn(i,t)<=parseInt((.3*i.length).toString())){xt.warn("通过SDK上报的".concat(t,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(mn));break}}}catch(t){o.e(t)}finally{o.f()}}}catch(e){xt.error(e)}}(t.action_type),"minigame"===e?function(t,e){var n,r,o;try{["PURCHASE","ADD_TO_CART"].includes(t.action_type)&&t.action_param&&It(t.action_param,"value")&&("number"!=typeof(null==(n=t.action_param)?void 0:n.value)?xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数需要为数字!")):(null==(r=t.action_param)?void 0:r.value)<=0?xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数需要大于0!")):"minigame"===e&&(null==(o=t.action_param)?void 0:o.value)<100&&xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(mn)))}catch(t){xt.error(t)}}(t,e):"miniprogram"===e&&function(t){try{var e=null==t?void 0:t.action_type,n=(null==t?void 0:t.action_param)||{};"PURCHASE"===e&&It(n,"value")&&("number"!=typeof(null==n?void 0:n.value)?xt.warn("通过SDK上报的".concat(e,"行为携带的金额参数需要为数字!")):(null==n?void 0:n.value)<=0&&xt.warn("通过SDK上报的".concat(e,"行为携带的金额参数需要大于0!")))}catch(e){xt.error(e)}}(t))}catch(t){xt.error(t)}}function kn(t,e){try{if(0===t.length)return e.length;if(0===e.length)return t.length;for(var n=[],r=0;r<=e.length;r++)n[r]=[r];for(var o=0;o<=t.length;o++)n[0][o]=o;for(var i=1;i<=e.length;i++)for(var a=1;a<=t.length;a++)e.charAt(i-1)===t.charAt(a-1)?n[i][a]=n[i-1][a-1]:n[i][a]=Math.min(n[i-1][a-1]+1,n[i][a-1]+1,n[i-1][a]+1);return n[e.length][t.length]}catch(n){xt.error(n)}}function Tn(t){try{t&&!/^[a-zA-Z0-9_\-]+$/.test(t)&&xt.warn("通过SDK上报的openid:".concat(t,"可能有误,请检查openid是否正确!").concat(mn))}catch(t){xt.error(t)}}var En=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,bn=function(t,e,n,r){for(var o,i=r>1?void 0:r?Sn(e,n):e,a=t.length-1;a>=0;a--)(o=t[a])&&(i=(r?o(e,n,i):o(i))||i);return r&&i&&En(e,n,i),i},On=Symbol("initializedInstance"),In=Symbol("autoTrack"),wn=Symbol("actionTime"),Cn=function(e){o(r,gn);var n=a(r);function r(t){var e;if(f(this,r),(e=n.call(this)).env="production",e.sdk_version="1.5.5",e.sdk_name="@dn-sdk/minigame",e.deviceInfo={},e.gameInfo={},e.session_id="",e.log_id=0,e.inited=!1,e.initErrMsg="",null==wx||!wx.createCanvas)return e.initErrMsg="不支持非微信小游戏中使用",xt.error(e.initErrMsg),u(e);var o=Ot();if(r[On].length>=o.maxSdkInstance)return e.initErrMsg="初始化超过上限",xt.error(e.initErrMsg),u(e);var i=St(t),a=at();if(!0!==i)return e.initErrMsg=i,xt.error(i),u(e);var s=null==a?void 0:a.appId;if(s&&s!==t.appid)return e.initErrMsg="初始化传入的appid与当前小游戏appid不一致",xt.error(e.initErrMsg),u(e);e.config=t,It(t,"auto_track")||(e.config.auto_track=bt("autoTrack")),e.openid=t.openid,e.unionid=t.unionid,e.user_unique_id=t.user_unique_id,e.onReportComplete=t.on_report_complete,e.onReportFail=t.on_report_fail,e.saveValidOpenidToStorage();var l=t.user_action_set_id;return r[On].includes(l)?(e.initErrMsg="同个数据源[".concat(l,"]只能初始化一次"),xt.error(e.initErrMsg),e.reportLog({log_type:b.JS_RUN_ERROR,message:e.initErrMsg}),u(e)):(e.reportLog=e.reportLog.bind(c(e)),e.getTrackBaseInfo=e.getTrackBaseInfo.bind(c(e)),e.deviceInfo=nt(),e.gameInfo=Nt(),e.session_id=mt(),e.queueManage=new Bt({userActionSetId:l,maxLength:o.maxQueueLength,ogEvents:Qt}),e.actionReporter=new en({getBaseInfo:e.getTrackBaseInfo,reportLog:e.reportLog,queueManager:e.queueManage,configManager:ce,onReportComplete:e.onReportComplete,onReportFail:e.onReportFail}),e.inited=!0,r[On].push(l),e.useAutoTrack(),e.doReportOnEnterBackground(),"release"===(null==a?void 0:a.envVersion)?(xt.info("初始化成功"),u(e)):(function(t){var e=t.conf_name,n=t.conf_key,r=t.sdk_version,o=t.default_download_url,i=t.fail_handler;lt({conf_name:e,conf_key:n}).then((function(t){if(ht(t)){var e=null==t?void 0:t.blackVersions,n=null==t?void 0:t.minVersion,a=null==t?void 0:t.bestVersion,u=null==t?void 0:t.downloadUrl,c=o;return u&&/^https/.test(u)&&(c=u),_t(e)&&(null==e?void 0:e.indexOf(r))>-1?(null==i||i(),void xt.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):n&&Et(r,n)<0?(null==i||i(),void xt.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&Et(r,a)<0&&xt.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),void xt.info("初始化成功"))}xt.info("初始化成功")})).catch((function(){xt.info("初始化成功")}))}({conf_name:"mini_game_sdk_common",conf_key:"version",sdk_version:e.sdk_version,default_download_url:"https://sr-home-1257214331.cos.ap-guangzhou.myqcloud.com/sdk/dn-sdk-minigame/dn-sdk-minigame.zip",fail_handler:function(){e.inited=!1}}),An.requestActionList(),Tn(t.openid),u(e)))}return p(r,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(t,e){var n,r;if(!this.inited||!this.queueManage)return xt.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};var o=Ue.validateActionType(t),i=Ue.validateActionParam(e);if(o&&i){!this.openid&&!this.unionid&&xt.warn("缺少 openid 或 unionid");var a=bt("actionParamMaxLength");if(JSON.stringify(e||{}).length>a)return xt.error("监测到超过".concat(a,"的上报日志:").concat(t," ").concat(e)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};var u=!(null==e||!e[In]),c=this.createAction(t,e||{},u);"release"!==(null==(n=at())?void 0:n.envVersion)&&Rn(c,"minigame");var s=this.queueManage.addAction(c);return null==(r=this.actionReporter)||r.batchSend(),s}return{code:101,message:"action_type 或 action_param 参数错误"}}},{key:"flush",value:function(){var t;null==(t=this.actionReporter)||t.flushSend()}},{key:"setOpenId",value:function(t){var e;if(t&&"string"==typeof t)return this.openid=t,this.gameInfo.ad_trace_id&&!tt.getSync(T)&&Kt.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(e=at())?void 0:e.envVersion)&&Tn(t),{code:0,message:"成功"};var n="openid 格式错误";return xt.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(t){if(t&&"string"==typeof t)return this.unionid=t,this.flush(),{code:0,message:"成功"};var e="unionid 格式错误";return xt.error(e),{code:101,message:e}}},{key:"setUserUniqueId",value:function(t){if(t&&"string"==typeof t)return this.user_unique_id=t,{code:0,message:"成功"};var e="user_unique_id 格式错误";return xt.error(e),{code:101,message:e}}},{key:"doReportOnEnterBackground",value:function(){var t=this;wx.onHide((function(){var e,n;null==(e=t.actionReporter)||e.flushSend(),null==(n=t.queueManage)||n.reportLostNum()}))}},{key:"getTrackBaseInfo",value:function(){var t=at();return Object.assign({},this.deviceInfo,function(t,e){var n={};return e.forEach((function(e){It(t,e)&&(n[e]=t[e])})),n}(this.config,["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"]),{local_id:rt(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||it(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:t.envVersion,app_version:t.version}})}},{key:"createAction",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];null!=e&&e[In]&&delete e[In];var r=Date.now();null!=e&&e[wn]&&(r=null==e?void 0:e[wn],delete e[wn]);var o={action_id:mt(),action_param:e,action_time:r,action_type:t,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:st.getRevisedcurrentTimeMillis(),log_id:++this.log_id,session_id:this.session_id,pkg_channel_id:this.gameInfo.pkg_channel_id,source_scene:this.gameInfo.source_scene,network_type:ot(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(t)};return null!=e&&e[this.special_method_symbol]&&(this.addActionInnerParam(o,"is_special_method",!0),delete e[this.special_method_symbol]),ce.getChannelClaimActionList().indexOf(t)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(o,"launch_options",this.gameInfo.launch_options),o}},{key:"addActionInnerParam",value:function(e,n,r){e.inner_param&&ht(e.inner_param)?e.inner_param[n]=r:e.inner_param=t({},n,r)}},{key:"getChannelByActionType",value:function(t){var e="";return ce.getChannelClaimActionList().indexOf(t)>-1?e=this.gameInfo.channel||"":ce.getNoClaimActionList().indexOf(t)>-1&&(e=X),e}},{key:"reportLog",value:function(t){var e,n,r={user_action_set_id:null==(e=this.config)?void 0:e.user_action_set_id,appid:null==(n=this.config)?void 0:n.appid,session_id:this.session_id};ct(Object.assign(r,t))}},{key:"useAutoTrack",value:function(){var t;if(null!=(t=this.config)&&t.auto_track){var e=!0,n=tt.getSync(R);(null==n?void 0:n.ap)===K?e=!0:(null==n?void 0:n.ap)===Q&&(e=!1),"devtools"===nt().wx_platform&&(e=!0),(new _n).install(this,e?"all":"lifecycle"),pe(),e&&Ne(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){var t,e,n=nt();n.os&&n.os_version&&null!=(t=this.config)&&t.user_action_set_id&&function(t){return new Promise((function(e){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:t,timeout:S.requestTimeout,success:function(t){ft(t,e,"minigame/get"),pt(t)},fail:function(t){dt(t,"minigame/get")}})}))}({conf_name:"MG",conf_param:{user_action_set_id:null==(e=this.config)?void 0:e.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void 0:n.os)||"",os_version:wt(n.os_version),device_brand:(null==n?void 0:n.device_brand)||"",weixin_lib_version:(null==n?void 0:n.wx_lib_version)||"",weixin_version:(null==n?void 0:n.wx_version)||""}}).then((function(t){ht(t)&&tt.setSync(R,t)}))}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(t){return/^[a-zA-Z0-9_-]{28,30}$/.test(t)}(this.openid)&&tt.setSync(T,this.openid)}}],[{key:"setRequestConcurrency",value:function(t){en.setRequestConcurrency(t)}},{key:"setDebug",value:function(t){xt.debug=t}}]),r}(),xn=Cn;xn[On]=[],bn([Lt],xn.prototype,"track",1),bn([Lt,function(t,e,n){var r=n.value;return n.value=function(){if(this.inited){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return r.apply(this,e)}xt.error("上报失败,请先完成初始化")},n}],xn.prototype,"flush",1),bn([Lt],xn.prototype,"setOpenId",1),bn([Lt],xn.prototype,"setUnionId",1),bn([Lt],xn.prototype,"setUserUniqueId",1),bn([Lt],xn.prototype,"doReportOnEnterBackground",1),bn([Lt],xn.prototype,"getTrackBaseInfo",1),bn([Lt],xn.prototype,"useAutoTrack",1);export{xn as SDK};
|