jf-gamekit 1.0.10 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/ttSdk.es.js +3 -3
- package/es/wxSdk.es.js +2 -2
- package/index.d.ts +2 -18
- package/lib/ttSdk.js +3 -3
- package/lib/wxSdk.js +2 -2
- package/package.json +1 -1
- package/umd/ttSdk.umd.js +3 -3
- package/umd/wxSdk.umd.js +2 -2
package/umd/wxSdk.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jfGamekitSDK={})}(this,function(e){"use strict";function t(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach(function(n){t(e,n,o[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var i,a,u=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2e3,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;wx.showToast({title:e,icon:t,duration:n,mask:!0,success:r})},c="
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jfGamekitSDK={})}(this,function(e){"use strict";function t(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach(function(n){t(e,n,o[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var i,a,u=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2e3,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;wx.showToast({title:e,icon:t,duration:n,mask:!0,success:r})},c="wxgame";var s=(a||(a=1,i={md5:function(e){function t(e,t){return e<<t|e>>>32-t}function n(e,t){var n,r,o,i,a;return o=2147483648&e,i=2147483648&t,a=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(r=1073741824&t)?2147483648^a^o^i:n|r?1073741824&a?3221225472^a^o^i:1073741824^a^o^i:a^o^i}function r(e,r,o,i,a,u,c){return e=n(e,n(n(function(e,t,n){return e&t|~e&n}(r,o,i),a),c)),n(t(e,u),r)}function o(e,r,o,i,a,u,c){return e=n(e,n(n(function(e,t,n){return e&n|t&~n}(r,o,i),a),c)),n(t(e,u),r)}function i(e,r,o,i,a,u,c){return e=n(e,n(n(function(e,t,n){return e^t^n}(r,o,i),a),c)),n(t(e,u),r)}function a(e,r,o,i,a,u,c){return e=n(e,n(n(function(e,t,n){return t^(e|~n)}(r,o,i),a),c)),n(t(e,u),r)}function u(e){var t,n="",r="";for(t=0;t<=3;t++)n+=(r="0"+(e>>>8*t&255).toString(16)).substr(r.length-2,2);return n}var c,s,l,f,d,p,v,g,h,m=Array();for(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e),m=function(e){for(var t,n=e.length,r=n+8,o=16*((r-r%64)/64+1),i=Array(o-1),a=0,u=0;u<n;)a=u%4*8,i[t=(u-u%4)/4]=i[t]|e.charCodeAt(u)<<a,u++;return a=u%4*8,i[t=(u-u%4)/4]=i[t]|128<<a,i[o-2]=n<<3,i[o-1]=n>>>29,i}(e),p=1732584193,v=4023233417,g=2562383102,h=271733878,c=0;c<m.length;c+=16)s=p,l=v,f=g,d=h,p=r(p,v,g,h,m[c+0],7,3614090360),h=r(h,p,v,g,m[c+1],12,3905402710),g=r(g,h,p,v,m[c+2],17,606105819),v=r(v,g,h,p,m[c+3],22,3250441966),p=r(p,v,g,h,m[c+4],7,4118548399),h=r(h,p,v,g,m[c+5],12,1200080426),g=r(g,h,p,v,m[c+6],17,2821735955),v=r(v,g,h,p,m[c+7],22,4249261313),p=r(p,v,g,h,m[c+8],7,1770035416),h=r(h,p,v,g,m[c+9],12,2336552879),g=r(g,h,p,v,m[c+10],17,4294925233),v=r(v,g,h,p,m[c+11],22,2304563134),p=r(p,v,g,h,m[c+12],7,1804603682),h=r(h,p,v,g,m[c+13],12,4254626195),g=r(g,h,p,v,m[c+14],17,2792965006),p=o(p,v=r(v,g,h,p,m[c+15],22,1236535329),g,h,m[c+1],5,4129170786),h=o(h,p,v,g,m[c+6],9,3225465664),g=o(g,h,p,v,m[c+11],14,643717713),v=o(v,g,h,p,m[c+0],20,3921069994),p=o(p,v,g,h,m[c+5],5,3593408605),h=o(h,p,v,g,m[c+10],9,38016083),g=o(g,h,p,v,m[c+15],14,3634488961),v=o(v,g,h,p,m[c+4],20,3889429448),p=o(p,v,g,h,m[c+9],5,568446438),h=o(h,p,v,g,m[c+14],9,3275163606),g=o(g,h,p,v,m[c+3],14,4107603335),v=o(v,g,h,p,m[c+8],20,1163531501),p=o(p,v,g,h,m[c+13],5,2850285829),h=o(h,p,v,g,m[c+2],9,4243563512),g=o(g,h,p,v,m[c+7],14,1735328473),p=i(p,v=o(v,g,h,p,m[c+12],20,2368359562),g,h,m[c+5],4,4294588738),h=i(h,p,v,g,m[c+8],11,2272392833),g=i(g,h,p,v,m[c+11],16,1839030562),v=i(v,g,h,p,m[c+14],23,4259657740),p=i(p,v,g,h,m[c+1],4,2763975236),h=i(h,p,v,g,m[c+4],11,1272893353),g=i(g,h,p,v,m[c+7],16,4139469664),v=i(v,g,h,p,m[c+10],23,3200236656),p=i(p,v,g,h,m[c+13],4,681279174),h=i(h,p,v,g,m[c+0],11,3936430074),g=i(g,h,p,v,m[c+3],16,3572445317),v=i(v,g,h,p,m[c+6],23,76029189),p=i(p,v,g,h,m[c+9],4,3654602809),h=i(h,p,v,g,m[c+12],11,3873151461),g=i(g,h,p,v,m[c+15],16,530742520),p=a(p,v=i(v,g,h,p,m[c+2],23,3299628645),g,h,m[c+0],6,4096336452),h=a(h,p,v,g,m[c+7],10,1126891415),g=a(g,h,p,v,m[c+14],15,2878612391),v=a(v,g,h,p,m[c+5],21,4237533241),p=a(p,v,g,h,m[c+12],6,1700485571),h=a(h,p,v,g,m[c+3],10,2399980690),g=a(g,h,p,v,m[c+10],15,4293915773),v=a(v,g,h,p,m[c+1],21,2240044497),p=a(p,v,g,h,m[c+8],6,1873313359),h=a(h,p,v,g,m[c+15],10,4264355552),g=a(g,h,p,v,m[c+6],15,2734768916),v=a(v,g,h,p,m[c+13],21,1309151649),p=a(p,v,g,h,m[c+4],6,4149444226),h=a(h,p,v,g,m[c+11],10,3174756917),g=a(g,h,p,v,m[c+2],15,718787259),v=a(v,g,h,p,m[c+9],21,3951481745),p=n(p,s),v=n(v,l),g=n(g,f),h=n(h,d);return(u(p)+u(v)+u(g)+u(h)).toLowerCase()}}),i),l=["event_params"];function f(e){for(var t=Object.keys(e).sort(),n={},r=0;r<t.length;r++){var o=t[r];n[o]=e[o]}return n}function d(e){var t="";for(var n in e){var r="";null!=e[n]?r=e[n]:e[n]="",t+=n+"="+r+"&"}return t=t.slice(0,t.length-1)}function p(e){e.time=parseInt(Date.parse(new Date)/1e3);var t=f(e);return e.sign||(e.sign=s.md5(d(t)+"WvgAUx8i0JeG5aaF")),e}function v(e){var t=e.map(function(e){e.event_params;var t=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,l);return d(f(t))}).join("&");return s.md5(t+"&key=gorkj:aaQTkvGAfLlDCjJo&1bS202401")}function g(e){var t;if("object"===o(e))if(Array.isArray(e))for(var n in t=[],e)t.push(g(e[n]));else if(null===e)t=null;else if(e.constructor===RegExp)t=e;else for(var r in t={},e)t[r]=g(e[r]);else t=e;return t}var h="POST";function m(e,t,n){return new Promise(function(r,o){wx.request({url:"https://page.hurricanegame.cn"+t,method:e,data:e===h?JSON.stringify(n):n,header:{"content-type":"application/json"},success:function(e){200===e.statusCode?e.data.state?r(e.data):o("request interface error"):console.error("Network Error!")}})})}function y(e,t,n){return new Promise(function(r,o){var i=wx.getStorageSync("jfGamekitSSToken"),a={"content-type":"application/json"};if(i)a.Authorization="Bearer ".concat(i);else{var u=JSON.parse(JSON.stringify(n)).body;a.sign=v(u)}wx.request({url:"https://common-set-api.topspinup.com"+t,method:e,data:e===h?JSON.stringify(n):n,header:a,success:function(e){200===e.statusCode?0==e.data.code?r(e.data):o("request interface error"):console.error("Network Error!")}})})}var _={mac:"",imei:"",oaid:"",androidid:"",idfa:"",idfv:"",sdkver:"1.0"},A=0,k=function(){var e={duid:""},t=wx.getStorageSync("duid");if(t)e.duid=t,A=0;else{console.log(A);var n=function(){for(var e="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",t="",n=0;n<32;n++)t+=e.charAt(Math.floor(48*Math.random()));return t}();wx.setStorageSync("duid",n),e.duid=n,A=1}return e},S=function(){var e={client:"",brand:"",resolution:"",model:"",sysver:""};try{var t=wx.getSystemInfoSync();e.sysver=t.system,e.resolution=t.screenWidth+"*"+t.screenHeight,e.model=t.model,e.client=t.platform,e.brand=t.brand}catch(e){console.log("【获取设备系统信息失败】",e)}return e},b=function(){return r(r(r(r({},k()),S()),_),{},{install:A,ntype:""})};
|
|
2
2
|
/**
|
|
3
3
|
* @dn-sdk/minigame v1.5.5
|
|
4
4
|
* (c) 2025
|
|
5
5
|
* @license ISC
|
|
6
6
|
*/
|
|
7
|
-
function _(e,t,n){return(t=P(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function A(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||k(e)||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 k(e,t){if(e){if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&w(e,t)}function w(e,t){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},w(e,t)}function T(e){var t=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(e){return!1}}();return function(){var n,r=E(e);if(t){var o=E(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return R(this,n)}}function R(e,t){if(t&&("object"===I(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return O(e)}function O(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,P(r.key),r)}}function N(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function P(e){var t=function(e){if("object"!==I(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==I(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===I(t)?t:String(t)}var L,M,D="LOCAL_ID",j="CLICK_ID",q="QUEUE_LOST_MAP",U="REMOTE_CONFIG",F="REMOTE_COMMON_CONFIG",B="OPENID",V={init:"init",reporting:"reporting",fail:"fail"},K={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"]},G="JS_RUN_ERROR",J="REQUEST_ERROR",W="REQUEST_CONFIG_ERROR",H="JS_QUEUE_LOG",Y="PROXY_ERROR",Q="QUEUE_LOST_NUM",z="SIGN_ERROR",$="UNKNOWN",Z="TRUE",X="FALSE",ee="TICKET_INTERVAL_CHANGE",te=(M=function(e){return"".concat("@dn-sdk/minigame","_").concat("production","_").concat(e)},{getSync:function(e){var t;try{t=wx.getStorageSync(M(e))}catch(e){return console.error("storage get error",e),t}return t},setSync:function(e,t){try{wx.setStorageSync(M(e),t)}catch(e){return console.error("storage set error",e),!1}return!0}}),ne=function(){var e;return function(){if(!e){var t=function(){if(L)return L;try{return L=wx.getSystemInfoSync()}catch(e){return{}}}(),n=t.system,r=void 0===n?"":n,o=(null==r?void 0:r.split(" "))||[],i=function(e){if(!e)return $;var t=(null==e?void 0:e.toUpperCase())||"";return t.indexOf("ANDROID")>-1?"ANDROID":t.indexOf("IOS")>-1?"IOS":t.indexOf("MAC")>-1?"OSX":t.indexOf("WINDOWS")>-1?"WINDOWS":$}(o[0]),a=function(e){return!e||e.length<=0?"":2===e.length?e[1]:3===e.length&&"Windows"===e[0]?"".concat(e[1]," ").concat(e[2]):e[e.length-1]}(o);e={benchmark_level:t.benchmarkLevel,device_brand:t.brand,screen_height:Math.floor(t.screenHeight),screen_width:Math.floor(t.screenWidth),wx_lib_version:t.SDKVersion,wx_version:t.version,wx_platform:t.platform,device_model:t.model,os:i,os_version:a}}return e}}(),re=function(){var e;return function(){try{if(e)return e;e||(e=te.getSync(D)||""),e||(e=_e(),te.setSync(D,e))}catch(e){}return e}}(),oe=function(){var e="unknown",t=!1;return function(){if(!t)try{wx.getNetworkType({success:function(t){e=t.networkType},fail:function(){e="unknown"}}),wx.onNetworkStatusChange(function(t){e=t.networkType}),t=!0}catch(e){}return e}}();oe();var ie=function(){var e="";return function(){return e||(e=te.getSync(B)||""),e}}(),ae=function(){var e;return function(){if(e)return e;try{var t=wx.getAccountInfoSync();return he(t.miniProgram)?e=t.miniProgram:{}}catch(t){return{}}}}();function ue(e){var t=null==e?void 0:e.query;if(!he(t))return"";var n="";return t.gdt_vid||[1045,1046,1084].indexOf(null==e?void 0:e.scene)>-1?n="TENCENT":t.clue_token||t.clickid&&t.item_id?n="BYTEDANCE":t.callback&&"kuaishou"===t.ksChannel?n="KUAISHOU":t.bd_vid||t.ai&&t.d&&t.q&&t.c?n="BAIDU":t.uctrackid?n="ALIBABA":(t.trackid||t.imp||[1065,1069,1194].indexOf(null==e?void 0:e.scene)>-1&&(t.callback||t.u))&&(n="OTHERS"),n}function ce(e,t){try{var n=ne(),r=ae(),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:re(),env_version:null==r?void 0:r.envVersion,appid:null==r?void 0:r.appId},i=Object.assign(o,e);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:i,method:"POST",timeout:K.requestTimeout,success:function(e){"function"==typeof t&&200===(null==e?void 0:e.statusCode)&&t()}})}catch(n){xe.error(n)}}var se=function(){function e(){x(this,e)}return N(e,null,[{key:"revise",value:function(e){e>0&&!this.isRevised&&(this.offsetTime=e-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){return this.isRevised?Date.now()+this.offsetTime:-1}}]),e}();function le(e){return new Promise(function(t,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:e,timeout:K.requestTimeout,success:function(e){fe(e,t,"config/get",n),pe(e)},fail:function(e){de(e,"config/get",n)}})})}function fe(e,t,n,r){var o,i,a,u,c=null==e?void 0:e.statusCode,s=null==(o=null==e?void 0:e.data)?void 0:o.code;if(200!==c||0!==s){var l=s;200!==c&&(l="number"==typeof c?-1*c:-888),ce({log_type:W,message:"cgiName: ".concat(n,", statusCode: ").concat(c,", code: ").concat(s,", traceid: ").concat(null==(a=null==e?void 0:e.data)?void 0:a.trace_id),code:l}),null==r||r(null==(u=null==e?void 0:e.data)?void 0:u.data)}else t(null==(i=e.data)?void 0:i.data)}function de(e,t,n){ce({log_type:W,message:"cgiName: ".concat(t," , message: ").concat(null==e?void 0:e.errMsg," "),code:"number"==typeof(null==e?void 0:e.errno)?-1*e.errno:-999}),null==n||n(e)}function pe(e){var t,n=1*(null==(t=null==e?void 0:e.header)?void 0:t["Server-Time"]);n>17266752e5&&se.revise(n)}se.offsetTime=0,se.isRevised=!1;var ve=Object.prototype.toString,he=function(e){return"[object Object]"===ve.call(e)},ge=function(e){return"[object Array]"===ve.call(e)},ye=function(e){return"[object Function]"===ve.call(e)},me=(new Date).getTime();function _e(){var e=(new Date).getTime(),t=Math.abs(1e3*(e-me));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".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).replace(/-/g,"")})}var Ae=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,ke=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");if(!Ae.test(e))throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"))},Se=function(e){return isNaN(Number(e))?e:Number(e)},be=function(e){var t=e.replace(/^v/,"").replace(/\+.*$/,""),n=function(e){return-1===e.indexOf("-")?e.length:e.indexOf("-")}(t),r=t.substring(0,n).split(".");return r.push(t.substring(n+1)),r},we=function(e,t){[e,t].forEach(ke);for(var n=be(e),r=be(t),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(Se),l=c.split(".").map(Se),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};function Te(e){return Re()[e]}function Re(){return K}function Oe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ee=function(e){try{return e&&"string"==typeof e?-1===(e=e.replace(/\s/g,"")).indexOf(".")?e:e.split(".").slice(0,2).join("."):""}catch(t){return e}},Ie=function(){function e(){x(this,e)}return N(e,null,[{key:"error",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(t=console).error.apply(t,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(r))}},{key:"info",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.debug&&(n=console).info.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}},{key:"log",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.debug&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}},{key:"warn",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(t=console).warn.apply(t,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(r))}},{key:"devLog",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.isDev&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}}]),e}(),xe=Ie;xe.debug=!1,xe.isDev=!1;var Ce=function(){var e;return function(){if(!e)try{var t=wx.getLaunchOptionsSync(),n=t.query.gdt_vid||"";n?te.setSync(j,n):n=te.getSync(j)||"";var r=JSON.stringify(t);r.length>1e4&&(r=JSON.stringify({cut:1,scene:t.scene})),e={source_scene:t.scene,pkg_channel_id:t.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:ue(t)}}catch(t){e={},xe.log("获取场景值和渠道号失败",t)}return e}}();function Ne(e,t,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{xe.error.apply(xe,["calling ".concat(e.constructor.name,".").concat(t," error with arguments")].concat(o)),xe.error(n);var a={log_type:G,message:"[safeExcutable] ".concat(e.constructor.name,".").concat(t,": ").concat(null==n?void 0:n.message),err_stack:null==n?void 0:n.stack};ye(this.reportLog)?this.reportLog(a):ce(a)}catch(a){}}},n}var Pe=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,Me=function(e,t,n,r){for(var o,i=r>1?void 0:r?Le(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Pe(t,n,i),i},De=function(){function e(t){var n=t.userActionSetId,r=t.maxLength,o=void 0===r?500:r;x(this,e),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat("QUEUE_ACTIONS","_").concat(null==n?void 0:n.toString()),this.maxLength=o,this.userActionSetId=n,this.setTimeStamp(),this.init()}return N(e,[{key:"getItems",value:function(){return this.stack}},{key:"getStorage",value:function(){var e,t=(null==(e=te)?void 0:e.getSync(this.localStorageKey))||"[]";return JSON.parse(t)}},{key:"reportLostNum",value:function(){var e=this,t=Object.assign({},this.lostActionMaps),n=[];for(var r in t){var o=null==r?void 0:r.split("_");n.push({queue_lost_session_id:o[0],queue_lost_timestamp:o[1],queue_lost_num:t[r]})}n.length&&(this.setTimeStamp(),n.forEach(function(t){var n=Object.assign({},{user_action_set_id:e.userActionSetId,log_type:Q},t),r=null==t?void 0:t.queue_lost_session_id,o=null==t?void 0:t.queue_lost_timestamp,i="".concat(r,"_").concat(o);ce(n,function(){Oe(e.lostActionMaps,i)&&(delete e.lostActionMaps[i],te.setSync(q,JSON.stringify(e.lostActionMaps)))})}))}},{key:"getLostMaps",value:function(){return this.lostActionMaps}},{key:"init",value:function(){var e=this,t=this.getStorage(),n=null==t?void 0:t.map(function(e){var t,n;return e.inner_status===(null==(t=V)?void 0:t.reporting)?Object.assign({},e,{inner_status:null==(n=V)?void 0:n.fail,is_retry:!0,retry_count:e.retry_count+1}):e});this.stack=n,this.lostActionMaps=JSON.parse(te.getSync(q)||"{}"),setTimeout(function(){e.reportLostNum()},1e3)}},{key:"addItem",value:function(e){var t;null==(t=null==this?void 0:this.stack)||t.push(e)}},{key:"removeItems",value:function(e){var t,n=null==(t=null==this?void 0:this.stack)?void 0:t.filter(function(t){return!(null!=e&&e.includes(null==t?void 0:t.action_id))});this.stack=n}},{key:"updateForReportFail",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map(function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=V)?void 0:n.fail,retry_count:t.retry_count+1,is_retry:!0}):t})}},{key:"updateForReporting",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map(function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=V)?void 0:n.reporting}):t})}},{key:"updateAllStack",value:function(e){this.stack=e}},{key:"updateToStorage",value:function(){te.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(e){if(e){var t="".concat(e,"_").concat(this.timeStamp),n=this.lostActionMaps[t]||0;this.lostActionMaps[t]=n+1,te.setSync(q,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),e}();Me([Ne],De.prototype,"getItems",1),Me([Ne],De.prototype,"getStorage",1),Me([Ne],De.prototype,"reportLostNum",1),Me([Ne],De.prototype,"getLostMaps",1),Me([Ne],De.prototype,"init",1),Me([Ne],De.prototype,"addItem",1),Me([Ne],De.prototype,"removeItems",1),Me([Ne],De.prototype,"updateForReportFail",1),Me([Ne],De.prototype,"updateForReporting",1),Me([Ne],De.prototype,"updateAllStack",1),Me([Ne],De.prototype,"updateToStorage",1),Me([Ne],De.prototype,"updateLostAction",1);var je=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Ue=function(e,t,n,r){for(var o,i=r>1?void 0:r?qe(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&je(t,n,i),i},Fe=function(){b(t,De);var e=T(t);function t(n){var r,o=n.userActionSetId,i=n.maxLength,a=void 0===i?500:i,u=n.ogEvents,c=void 0===u?[]:u;return x(this,t),(r=e.call(this,{userActionSetId:o,maxLength:a})).ogEvents=c,r}return N(t,[{key:"getReportableActions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,t=this.getItems(),n=[];return null==t||t.forEach(function(t){var r;(null==n?void 0:n.length)<e&&(null==t?void 0:t.inner_status)!==(null==(r=V)?void 0:r.reporting)&&(null==n||n.push(t))}),n}},{key:"addAction",value:function(e){var t={code:0,message:"成功",actionId:e.action_id},n=this.getItems();if((null==n?void 0:n.length)>=this.maxLength){var r="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");xe.warn(r),ce({user_action_set_id:this.userActionSetId,log_type:H,message:"队列长度超过限制"});var o=this.sortQueue(e,n);xe.debug&&xe.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)===e.action_id&&(t={code:103,message:"缓存队列已满,主动丢弃行为"})}else this.addItem(e);return this.updateToStorage(),t}},{key:"removeActions",value:function(e){this.removeItems(e),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(e){this.updateForReportFail(e),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(e){this.updateForReporting(e),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){var e=this.getItems().filter(function(e){var t;return(null==e?void 0:e.inner_status)!==(null==(t=V)?void 0:t.reporting)});return null==e?void 0:e.length}},{key:"sortQueue",value:function(e,t){var n=this,r={},o=null==e?void 0:e.action_time,i=t.concat([e]),a=function(e){return r[e.action_id]||(r[e.action_id]=n.caculateWeight(o,e)),r[e.action_id]};return i.sort(function(e,t){return a(t)-a(e)})}},{key:"caculateWeight",value:function(e,t){var n,r=0,o=this.formatWeight(e,null==t?void 0:t.action_time),i=o.ogWeight,a=o.sdkWeight,u=o.userWeight;null!=(n=this.ogEvents)&&n.includes(null==t?void 0:t.action_type)&&(r+=i),null!=t&&t.is_sdk_auto_track?r+=a:r+=u;var c=e-(null==t?void 0:t.action_time)+1;return c>0?r+1/c:r}},{key:"formatWeight",value:function(e,t){var n=1e3,r=10,o=100;return e-t>2592e6&&(n/=100,r/=100,o/=100),{ogWeight:n,sdkWeight:r,userWeight:o}}}]),t}();Ue([Ne],Fe.prototype,"getReportableActions",1),Ue([Ne],Fe.prototype,"addAction",1),Ue([Ne],Fe.prototype,"removeActions",1),Ue([Ne],Fe.prototype,"updateActionsForReportFail",1),Ue([Ne],Fe.prototype,"updateActionsForReporting",1),Ue([Ne],Fe.prototype,"getReportableActionsLength",1),Ue([Ne],Fe.prototype,"sortQueue",1),Ue([Ne],Fe.prototype,"caculateWeight",1),Ue([Ne],Fe.prototype,"formatWeight",1);var Be=function(){function e(){x(this,e),this.events={}}return N(e,[{key:"subscribe",value:function(t,n){e.checkCallback(n),ge(this.events[t])?this.events[t].push(n):this.events[t]=[n]}},{key:"once",value:function(t,n){e.checkCallback(n),this.subscribe(this.onceEventName(t),n)}},{key:"unsubscribe",value:function(t,n){e.checkCallback(n),ge(this.events[t])&&(this.events[t]=this.events[t].filter(function(e){return e!==n})),ge(this.events[this.onceEventName(t)])&&(this.events[this.onceEventName(t)]=this.events[this.onceEventName(t)].filter(function(e){return e!==n}))}},{key:"publish",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=Date.now();ge(this.events[e])&&this.events[e].forEach(function(e){return e.apply(void 0,[o].concat(n))}),ge(this.events[this.onceEventName(e)])&&(this.events[this.onceEventName(e)].forEach(function(e){return e.apply(void 0,[o].concat(n))}),this.events[this.onceEventName(e)]=[])}},{key:"onceEventName",value:function(e){return"once_event_prefix_".concat(e)}}],[{key:"checkCallback",value:function(t){ye(t)||xe.error(e.ERROR_CALLBACK_IS_NOT_A_FUNCTION)}}]),e}(),Ve=Be;Ve.ERROR_CALLBACK_IS_NOT_A_FUNCTION="callback 不是函数";var Ke=new Ve,Ge=["REGISTER","VIEW_CONTENT","ADD_TO_CART","PURCHASE","COMPLETE_ORDER","ADD_TO_WISHLIST","START_APP","CREATE_ROLE","AUTHORIZE","TUTORIAL_FINISH","START_PAY","FINISH_PAY"],Je="START_APP",We="TICKET",He="ENTER_FOREGROUND",Ye="ENTER_BACKGROUND",Qe="LOGIN",ze="SHARE",$e="TAP_GAME_CLUB",Ze="CREATE_GAME_CLUB",Xe="JOIN_GAME_ROOM",et="FINISH_PAY",tt="START_PAY",nt="ADD_TO_WISHLIST",rt=["REGISTER","START_APP","RE_ACTIVE"],ot=["TICKET","ENTER_FOREGROUND","ENTER_BACKGROUND"],it=function(){function e(){x(this,e),this.channelClaimActionList=rt,this.noClaimActionList=ot,this.realTimeActionList=K.realTimeActionList,this.ticketInterval=60,this.requestTimeout=K.requestTimeout,this.loadConfig()}return N(e,[{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 e=this;try{if("undefined"==typeof wx)return;var t=te.getSync(F);t&&this.updateConfig(t),le({conf_name:"mini_game_sdk_common",conf_key:"config"}).then(function(t){t&&he(t)&&(e.updateConfig(t),te.setSync(F,t))})}catch(t){console.error(t)}}},{key:"updateConfig",value:function(e){e.channelClaimActionList&&ge(e.channelClaimActionList)&&(this.channelClaimActionList=e.channelClaimActionList),e.noClaimActionList&&ge(e.noClaimActionList)&&(this.noClaimActionList=e.noClaimActionList),e.realTimeActionList&&ge(e.realTimeActionList)&&(this.realTimeActionList=e.realTimeActionList),e.ticketInterval&&"number"==typeof e.ticketInterval&&e.ticketInterval>1&&e.ticketInterval!==this.ticketInterval&&(this.ticketInterval=e.ticketInterval,Ke.publish(ee)),e.requestTimeout&&"number"==typeof e.requestTimeout&&e.requestTimeout>5e3&&(this.requestTimeout=e.requestTimeout)}}]),e}(),at=new it,ut=Je,ct=We,st=He,lt=Ye,ft=function(){var e=!1,t=!1,n=!0,r=!0,o=!0,i=!1;return function(){if(!i){i=!0;var a=te.getSync(U);if((null==a?void 0:a.bg)===Z?e=!0:(null==a?void 0:a.bg)===X&&(e=!1),(null==a?void 0:a.fg)===Z?t=!0:(null==a?void 0:a.fg)===X&&(t=!1),(null==a?void 0:a.st)===Z?n=!0:(null==a?void 0:a.st)===X&&(n=!1),(null==a?void 0:a.ti)===Z?r=!0:(null==a?void 0:a.ti)===X&&(r=!1),xe.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",e,t,n,r),n&&Ke.publish(ut),r){var u=function(){o&&Ke.publish(ct)},c=setInterval(u,1e3*at.getTicketInterval());Ke.subscribe(ee,function(){c&&clearInterval(c),c=setInterval(u,1e3*at.getTicketInterval())})}wx.onShow(function(e){if(o=!0,t){var n="";try{(n=JSON.stringify(e)).length>1e4&&(n=JSON.stringify({cut:1,scene:e.scene}))}catch(e){}Ke.publish(st,{enter_options:n})}}),wx.onHide(function(){o=!1,e&&Ke.publish(lt)})}}}(),dt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function pt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vt,ht=pt(function(){var e,t=null;function n(e){return!!e&&("object"==I(e)||"function"==typeof e)}function r(e){if(null!==e&&!n(e))throw new TypeError("Object prototype may only be an Object or null: "+e)}var o=Object,i=!(!o.create&&{__proto__:null}instanceof o),a=o.create||(i?function(e){return r(e),{__proto__:e}}:function(e){if(r(e),null===e)throw new SyntaxError("Native Object.create is required to create objects with null prototype");var t=function(){};return t.prototype=e,new t}),u=function(){return null},c=o.getPrototypeOf||([].__proto__===Array.prototype?function(e){var t=e.__proto__;return n(t)?t:null}:u);return e=function(s,l){if(void 0===(this&&this instanceof e?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(){};t=function(){s=null,f=function(e){throw new TypeError("Cannot perform '".concat(e,"' on a proxy that has been revoked"))}},setTimeout(function(){t=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),g=!1,y=!1;"function"==typeof s?(v=function(){var e=this&&this.constructor===v,t=Array.prototype.slice.call(arguments);return f(e?"construct":"apply"),e&&l.construct?l.construct.call(this,s,t):!e&&l.apply?l.apply(s,this,t):e?(t.unshift(s),new(s.bind.apply(s,t))):s.apply(this,t)},g=!0):s instanceof Array?(v=[],y=!0):v=i||null!==h?a(h):{};var m=l.get?function(e){return f("get"),l.get(this,e,v)}:function(e){return f("get"),this[e]},_=l.set?function(e,t){f("set"),l.set(this,e,t,v)}:function(e,t){f("set"),this[e]=t},A=o.getOwnPropertyNames(s),k={};A.forEach(function(e){if(!g&&!y||!(e in v)){var t={enumerable:!!o.getOwnPropertyDescriptor(s,e).enumerable,get:m.bind(s,e),set:_.bind(s,e)};o.defineProperty(v,e,t),k[e]=!0}});var S=!0;if(g||y){var b=o.setPrototypeOf||([].__proto__===Array.prototype?function(e,t){return r(t),e.__proto__=t,e}:u);h&&b(v,h)||(S=!1)}if(l.get||!S)for(var w in s)k[w]||o.defineProperty(v,w,{get:m.bind(s,w)});return o.seal(s),o.seal(v),v},e.revocable=function(n,r){return{proxy:new e(n,r),revoke:t}},e}),gt={};try{vt||(vt=ht())}catch(L){kt(L)}function yt(e,t,n,r){try{if(!vt||null==e||!e[t])return;e[t]=new vt(e[t],{apply:function(e,t,o){var i,a;r&&At(function(){return r.apply(void 0,A(o))});var u=!!(null!=(i=o[0])&&i.success||null!=(a=o[0])&&a.fail);u&&["success","fail"].forEach(function(e){if(o[0][e])try{o[0][e]=new vt(o[0][e],{apply:function(t,r,i){return At(function(){return n.apply(void 0,[e,o[0]].concat(A(i)))}),t.apply(r,i)}})}catch(e){kt(e)}});var c=e.apply(t,o);return!u&&c&&"[object Promise]"===Object.prototype.toString.call(c)?c.then(function(e){return At(function(){return n("success",o[0],e)}),e}).catch(function(e){throw At(function(){return n("fail",o[0],e)}),e}):c}})}catch(e){kt(e)}}function mt(e,t,n){try{if(!vt||null==e||!e[t])return;e[t]=new vt(e[t],{apply:function(e,t,r){var o="function"==typeof r[0];if(o)try{r[0]=new vt(r[0],{apply:function(e,t,r){var o=e.call.apply(e,[t].concat(A(r)));return At(function(){return n(o)}),o}})}catch(e){kt(e)}var i=e.call.apply(e,[t].concat(A(r)));return o||At(function(){return n(i)}),i}})}catch(e){kt(e)}}function _t(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4?arguments[4]:void 0;try{if(!vt||null==e||!e[t])return;e[t]=new vt(e[t],{apply:function(e,i,a){var u=e.call.apply(e,[i].concat(A(a)));return(!n||!gt[t])&&(At(function(){return null==o?void 0:o(u)}),r.forEach(function(e){var t=e.eventName,n=e.isAsync,r=e.proxyEvent;n?yt(u,t,r):mt(u,t,r)})),n&&(gt[t]=!0),u}})}catch(e){kt(e)}}function At(e){try{e()}catch(e){kt(e)}}function kt(e){ce({log_type:Y,message:null==e?void 0:e.message,err_stack:null==e?void 0:e.stack})}var St=Qe,bt=nt,wt=ze,Tt=$e,Rt=Ze,Ot=Xe,Et=tt,It=et,xt=function(){var e=!1;return function(){e||(e=!0,yt(wx,"login",function(e){"success"===e&&Ke.publish(St)}),mt(wx,"onAddToFavorites",function(){Ke.publish(bt)}),mt(wx,"onShareTimeline",function(){Ke.publish(wt,{target:"TIME_LINE",trigger:"MENU"})}),mt(wx,"onShareAppMessage",function(){Ke.publish(wt,{target:"APP_MESSAGE",trigger:"MENU"})}),mt(wx,"shareAppMessage",function(){Ke.publish(wt,{target:"APP_MESSAGE",trigger:"BUTTON"})}),_t(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){Ke.publish(Tt)}}],function(){Ke.publish(Rt)}),_t(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(e){"success"===e&&Ke.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(e){"success"===e&&Ke.publish(Ot)}}]),yt(wx,"requestMidasPayment",function(e,t){Ke.publish(It,{status:"success"===e?"SUCCESS":"FAIL",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"})},function(e){Ke.publish(Et,{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"})}),yt(wx,"requestMidasPaymentGameItem",function(e,t){var n=(t||{}).signData;Ke.publish(It,{status:"success"===e?"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(e){var t=(e||{}).signData;Ke.publish(Et,{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)||"",p:(null==t?void 0:t.goodsPrice)||0,productId:(null==t?void 0:t.productId)||"",payType:"MidasGameItem"})}))}}(),Ct=function(){function e(){x(this,e)}return N(e,null,[{key:"isEmpty",value:function(e){return null==e||"string"==typeof e&&""===e.trim()}},{key:"format",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.replace(/\${(\d+)}/g,function(e,t){return n[t]})}},{key:"customStringify",value:function(e){var t=[];try{return JSON.stringify(e,function(e,n){if(void 0===n)return"undefined";if("object"==I(n)&&null!==n){if(-1!==t.indexOf(n))return"[Circular]";t.push(n)}return"bigint"==typeof n?n.toString():n})}catch(e){return"[Param Error]"}}}]),e}(),Nt=/^([a-zA-Z][a-zA-Z\d_]{0,63})$/i,Pt=/^ams_reserved_(.*)/i,Lt=function(){function e(){x(this,e)}return N(e,null,[{key:"validateActionType",value:function(t){return Ct.isEmpty(t)?(xe.error(e.ERROR_ACTION_TYPE_NULL),!1):!!Nt.test(t)||(xe.error(e.ERROR_ACTION_TYPE_INVALID),!1)}},{key:"validateActionParam",value:function(t){if(!t)return!0;if(!he(t))return xe.error(e.ERROR_ACTION_PARAM_IS_NOT_OBJECT),!1;for(var n in t){if(Ct.isEmpty(n))return xe.error(e.ERROR_ACTION_PARAM_KEY_NULL),!1;if(!Nt.test(n))return xe.error(e.ERROR_ACTION_PARAM_KEY_INVALID),!1;Pt.test(n)&&xe.warn(e.WARN_ACTION_PARAM_KEY_RESERVED);var r=t[n];if(!e.isValidValue(r))return xe.error(Ct.format(e.ERROR_ACTION_PARAM_VALUE_INVALID,n,r)),!1;if(ge(r)){if(!e.isValidArrayValue(r)){for(var o=0;o<r.length;o++)xe.error(Ct.format(e.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID,n,Ct.customStringify(r),o,r[o]));return!1}if(!e.checkArrayElementTypes(r))return xe.error(e.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE),!1}}return!0}},{key:"isValidValue",value:function(e){return null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||ge(e)}},{key:"isValidArrayValue",value:function(e){for(var t=0;t<e.length;t++){var n=e[t];if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return!1}return!0}},{key:"checkArrayElementTypes",value:function(e){if(!e||e.length<=1)return!0;for(var t=I(e[0]),n=1;n<e.length;n++)if(I(e[n])!==t)return!1;return!0}}]),e}(),Mt=Lt;Mt.ERROR_ACTION_TYPE_NULL="在track方法中,action_type参数不能为空!",Mt.ERROR_ACTION_TYPE_INVALID="在track方法中,action_type参数只能包含字母、数字和下划线,且只能以字母开头,长度不能超过64个字符!",Mt.ERROR_ACTION_PARAM_KEY_NULL="在track方法中,action_param参数的key不能为空!",Mt.ERROR_ACTION_PARAM_KEY_INVALID="在track方法中,action_param参数的key只能包含字母、数字和下划线,且不能以数字开头,长度不能超过64个字符!",Mt.WARN_ACTION_PARAM_KEY_RESERVED="SDK内部预留参数的key均以'ams_reserved_'开头,该参数的值会被SDK内部覆盖,请不要使用!",Mt.ERROR_ACTION_PARAM_VALUE_INVALID="在track方法中,action_param参数的value必须是String/Number/Boolean/Array中的一种![key=${0}, value=${1}]",Mt.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中的每个元素必须是String/Number/Boolean中的一种![key=${0}, value=${1}, 数组的第${2}个元素为${3}]",Mt.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中所有元素的类型必须是同一种!",Mt.ERROR_ACTION_PARAM_IS_NOT_OBJECT="action_param 参数不是Object";var Dt={exports:{}};!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,o,i,a){return n(function(e,t){return e<<t|e>>>32-t}(n(n(t,e),n(o,a)),i),r)}function o(e,t,n,o,i,a,u){return r(t&n|~t&o,e,t,i,a,u)}function i(e,t,n,o,i,a,u){return r(t&o|n&~o,e,t,i,a,u)}function a(e,t,n,o,i,a,u){return r(t^n^o,e,t,i,a,u)}function u(e,t,n,o,i,a,u){return r(n^(t|~o),e,t,i,a,u)}function c(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var r,c,s,l,f,d=1732584193,p=-271733879,v=-1732584194,h=271733878;for(r=0;r<e.length;r+=16)c=d,s=p,l=v,f=h,d=o(d,p,v,h,e[r],7,-680876936),h=o(h,d,p,v,e[r+1],12,-389564586),v=o(v,h,d,p,e[r+2],17,606105819),p=o(p,v,h,d,e[r+3],22,-1044525330),d=o(d,p,v,h,e[r+4],7,-176418897),h=o(h,d,p,v,e[r+5],12,1200080426),v=o(v,h,d,p,e[r+6],17,-1473231341),p=o(p,v,h,d,e[r+7],22,-45705983),d=o(d,p,v,h,e[r+8],7,1770035416),h=o(h,d,p,v,e[r+9],12,-1958414417),v=o(v,h,d,p,e[r+10],17,-42063),p=o(p,v,h,d,e[r+11],22,-1990404162),d=o(d,p,v,h,e[r+12],7,1804603682),h=o(h,d,p,v,e[r+13],12,-40341101),v=o(v,h,d,p,e[r+14],17,-1502002290),d=i(d,p=o(p,v,h,d,e[r+15],22,1236535329),v,h,e[r+1],5,-165796510),h=i(h,d,p,v,e[r+6],9,-1069501632),v=i(v,h,d,p,e[r+11],14,643717713),p=i(p,v,h,d,e[r],20,-373897302),d=i(d,p,v,h,e[r+5],5,-701558691),h=i(h,d,p,v,e[r+10],9,38016083),v=i(v,h,d,p,e[r+15],14,-660478335),p=i(p,v,h,d,e[r+4],20,-405537848),d=i(d,p,v,h,e[r+9],5,568446438),h=i(h,d,p,v,e[r+14],9,-1019803690),v=i(v,h,d,p,e[r+3],14,-187363961),p=i(p,v,h,d,e[r+8],20,1163531501),d=i(d,p,v,h,e[r+13],5,-1444681467),h=i(h,d,p,v,e[r+2],9,-51403784),v=i(v,h,d,p,e[r+7],14,1735328473),d=a(d,p=i(p,v,h,d,e[r+12],20,-1926607734),v,h,e[r+5],4,-378558),h=a(h,d,p,v,e[r+8],11,-2022574463),v=a(v,h,d,p,e[r+11],16,1839030562),p=a(p,v,h,d,e[r+14],23,-35309556),d=a(d,p,v,h,e[r+1],4,-1530992060),h=a(h,d,p,v,e[r+4],11,1272893353),v=a(v,h,d,p,e[r+7],16,-155497632),p=a(p,v,h,d,e[r+10],23,-1094730640),d=a(d,p,v,h,e[r+13],4,681279174),h=a(h,d,p,v,e[r],11,-358537222),v=a(v,h,d,p,e[r+3],16,-722521979),p=a(p,v,h,d,e[r+6],23,76029189),d=a(d,p,v,h,e[r+9],4,-640364487),h=a(h,d,p,v,e[r+12],11,-421815835),v=a(v,h,d,p,e[r+15],16,530742520),d=u(d,p=a(p,v,h,d,e[r+2],23,-995338651),v,h,e[r],6,-198630844),h=u(h,d,p,v,e[r+7],10,1126891415),v=u(v,h,d,p,e[r+14],15,-1416354905),p=u(p,v,h,d,e[r+5],21,-57434055),d=u(d,p,v,h,e[r+12],6,1700485571),h=u(h,d,p,v,e[r+3],10,-1894986606),v=u(v,h,d,p,e[r+10],15,-1051523),p=u(p,v,h,d,e[r+1],21,-2054922799),d=u(d,p,v,h,e[r+8],6,1873313359),h=u(h,d,p,v,e[r+15],10,-30611744),v=u(v,h,d,p,e[r+6],15,-1560198380),p=u(p,v,h,d,e[r+13],21,1309151649),d=u(d,p,v,h,e[r+4],6,-145523070),h=u(h,d,p,v,e[r+11],10,-1120210379),v=u(v,h,d,p,e[r+2],15,718787259),p=u(p,v,h,d,e[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(e){var t,n="",r=32*e.length;for(t=0;t<r;t+=8)n+=String.fromCharCode(e[t>>5]>>>t%32&255);return n}function l(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t<n.length;t+=1)n[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)n[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return n}function f(e){var t,n,r="0123456789abcdef",o="";for(n=0;n<e.length;n+=1)t=e.charCodeAt(n),o+=r.charAt(t>>>4&15)+r.charAt(15&t);return o}function d(e){return unescape(encodeURIComponent(e))}function p(e){return function(e){return s(c(l(e),8*e.length))}(d(e))}function v(e,t){return function(e,t){var n,r,o=l(e),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=c(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],a[n]=1549556828^o[n];return r=c(i.concat(l(t)),512+8*t.length),s(c(a.concat(r),640))}(d(e),d(t))}function h(e,t,n){return t?n?v(t,e):function(e,t){return f(v(e,t))}(t,e):n?p(e):function(e){return f(p(e))}(e)}e.exports?e.exports=h:t.md5=h}(dt)}(Dt);var jt=pt(Dt.exports),qt="function"==typeof btoa,Ut="function"==typeof Buffer;"function"==typeof TextDecoder&&new TextDecoder;var Ft,Bt="function"==typeof TextEncoder?new TextEncoder:void 0,Vt=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");Ft={},Vt.forEach(function(e,t){return Ft[e]=t});var Kt=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);var Gt=qt?function(e){return btoa(e)}:Ut?function(e){return Buffer.from(e,"binary").toString("base64")}:function(e){for(var t,n,r,o,i="",a=e.length%3,u=0;u<e.length;){if((n=e.charCodeAt(u++))>255||(r=e.charCodeAt(u++))>255||(o=e.charCodeAt(u++))>255)throw new TypeError("invalid character found");i+=Vt[(t=n<<16|r<<8|o)>>18&63]+Vt[t>>12&63]+Vt[t>>6&63]+Vt[63&t]}return a?i.slice(0,a-3)+"===".substring(a):i},Jt=Ut?function(e){return Buffer.from(e).toString("base64")}:function(e){for(var t=[],n=0,r=e.length;n<r;n+=4096)t.push(Kt.apply(null,e.subarray(n,n+4096)));return Gt(t.join(""))},Wt=function(e){if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?Kt(192|t>>>6)+Kt(128|63&t):Kt(224|t>>>12&15)+Kt(128|t>>>6&63)+Kt(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return Kt(240|t>>>18&7)+Kt(128|t>>>12&63)+Kt(128|t>>>6&63)+Kt(128|63&t)},Ht=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Yt=Ut?function(e){return Buffer.from(e,"utf8").toString("base64")}:Bt?function(e){return Jt(Bt.encode(e))}:function(e){return Gt(function(e){return e.replace(Ht,Wt)}(e))},Qt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,$t=function(e,t,n,r){for(var o,i=r>1?void 0:r?zt(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Qt(t,n,i),i},Zt=function(){function e(t){var n=this;x(this,e),this.cgiBatchSize=K.cgiBatchSize,this.reportThreshold=K.reportThreshold,this.reportDelay=K.reportDelay,this.triggerExecuteSend=function(e){var t,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(t),t=setTimeout(function(){var t=e.apply(void 0,i);r.forEach(function(e){return e(t)}),r=[]},n),new Promise(function(e){return r.push(e)})}}(function(){n.executeSend()},1e3*this.reportDelay),this.inspectDelay=K.inspectDelay,this.inspectTimer=void 0,this.isNeedContinueSend=!1,this.getBaseInfo=t.getBaseInfo,this.reportLog=t.reportLog,this.queueManager=t.queueManager,this.configManager=t.configManager,this.onReportComplete=t.onReportComplete,this.onReportFail=t.onReportFail,this.flushSend(),this.startInspectTimer()}return N(e,[{key:"batchSend",value:function(){var e,t=this.queueManager.getReportableActions(this.reportThreshold);if(t.length>=this.reportThreshold)this.executeSend();else{var n=(null==(e=this.configManager)?void 0:e.getRealTimeActionList())||K.realTimeActionList;t.some(function(e){return n.indexOf(e.action_type)>-1&&!e.is_retry})?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){var t=this;if(e.currentRequestCount>=e.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;var n=(e.requestConcurrency-e.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),o=this.getBaseInfo();if(!o.openid&&!o.unionid&&(xe.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter(function(e){return null==e?void 0:e.ad_trace_id})),!(r.length<=0)){n<this.queueManager.getReportableActionsLength()&&(this.isNeedContinueSend=!0),e.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(e){var n=e.some(function(e){return e>=0});t.isNeedContinueSend&&n&&t.executeSend()}).catch(function(e){xe.error(e),t.reportLog({message:"executeSend catch: ".concat(e.message),log_type:G,err_stack:e.stack})})}}}},{key:"generateActionReportParams",value:function(e){var t=[],n=[],r=this.getBaseInfo();return e.forEach(function(e){n.push(e.action_id);var r=Object.assign({},e);delete r.inner_status,t.push(r)}),{data:{info:r,actions:t},actionIdList:n}}},{key:"dealSuccessData",value:function(e,t,n){[51001,51003].indexOf(null==e?void 0:e.code)>-1?this.queueManager.updateActionsForReportFail(t):this.queueManager.removeActions(t),0!==(null==e?void 0:e.code)&&(this.reportLog({log_type:J,code:null==e?void 0:e.code,message:"trace_id: ".concat(null==e?void 0:e.trace_id,",msg: ").concat(null==e?void 0:e.message)}),xe.error("上报失败:",e)),this.doTrackCallbackFn(this.onReportComplete,e,n),-1===[0,51001,51003].indexOf(null==e?void 0:e.code)&&this.doTrackCallbackFn(this.onReportFail,e,n)}},{key:"dealFailData",value:function(e,t,n){this.queueManager.updateActionsForReportFail(t),this.reportLog({log_type:J,code:e.code,message:e.message}),xe.error("上报失败:",e),this.doTrackCallbackFn(this.onReportComplete,e,n)}},{key:"report",value:function(t){var n=this,r=t.data,o=t.actionIdList;return this.queueManager.updateActionsForReporting(o),xe.debug&&(xe.info("上报行为类型: ","【".concat(r.actions.map(function(e){return e.action_type}).join("、"),"】")),xe.info("上报请求参数: ",r)),new Promise(function(t){var i,a,u,c,s,l,f,d,p=Date.now();try{var v=function(e){var t="",n=null==e?void 0:e.appid,r=null==e?void 0:e.secret_key,o=null==e?void 0:e.sdk_version,i=null==e?void 0:e.timestamp;if(!(n&&r&&o&&i&&32===r.length))return t;for(var a=jt(o+n+i),u=0;u<32;u++)t+=u%2==0?r[u]:a[u];return t}({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:p}),h=function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?function(e){return e.replace(/=/g,"").replace(/[+\/]/g,function(e){return"+"==e?"-":"_"})}(Yt(e)):Yt(e)}(JSON.stringify(r));f={"Client-Time":p,"Sign-Value":jt(h+(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)+v),"Sign-Version":K.signVersion,"content-type":"text/plain;charset=UTF-8"},d=h}catch(v){f={"Client-Time":p},d=r,n.reportLog({log_type:z,message:"sign error msg: ".concat(null==v?void 0:v.message),err_stack:null==v?void 0:v.stack}),xe.error(v)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(l=n.configManager)?void 0:l.getRequestTimeout())||K.requestTimeout,header:f,data:d,success:function(i){var a,u;xe.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(se.revise(c),e.currentRequestCount-=1,200===(null==i?void 0:i.statusCode))return n.dealSuccessData(null==i?void 0:i.data,o,r),void t((null==i?void 0:i.data).code);var s="";try{s="object"==I(null==i?void 0:i.data)?JSON.stringify(null==i?void 0:i.data):null==i?void 0:i.data}catch(e){xe.error(e)}var l={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(l,o,r),t(l.code)},fail:function(i){xe.devLog("上报失败:",i),e.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),t(a.code)}})})}},{key:"startInspectTimer",value:function(){var t=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout(function(){e.currentRequestCount>=e.requestConcurrency&&(e.currentRequestCount=e.requestConcurrency-1),t.executeSend(),t.startInspectTimer()},1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(e,t,n){if("function"==typeof e)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;e({code:null==t?void 0:t.code,message:null==t?void 0:t.message,data:{actions:r,info:{user_action_set_id:f,appid:d,openid:p,unionid:v,user_unique_id:h}}})}}catch(r){xe.error("返回上报回调数据异常:",r)}}}],[{key:"setRequestConcurrency",value:function(t){"number"==typeof t?t<1?xe.error("网络请求最大并发量不能小于1"):t>10?xe.error("网络请求最大并发量不能大于10"):e.requestConcurrency=t:xe.error("网络请求最大并发量需设置为数字")}}]),e}(),Xt=Zt;Xt.currentRequestCount=0,Xt.requestConcurrency=K.requestConcurrency,$t([Ne],Xt.prototype,"batchSend",1),$t([Ne],Xt.prototype,"flushSend",1),$t([Ne],Xt.prototype,"executeSend",1);var en=Je,tn=We,nn=He,rn=Ye,on=Qe,an=nt,un=ze,cn=$e,sn=Ze,ln=Xe,fn=tt,dn=et,pn=function(){function e(){x(this,e)}return N(e,[{key:"install",value:function(e,t){var n=function(t){Ke.subscribe(t,function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.track(t,Object.assign(n||{},o,_(_({},Rn,!0),On,r)))}}(t))};n(tn),n(en),n(nn),n(rn),"all"===t&&(n(on),n(an),n(un),n(sn),n(cn),n("CREATE_GAME_ROOM"),n(ln),n(fn),n(dn))}}]),e}(),vn=function(){function e(){x(this,e),this.special_method_symbol=Symbol("special_method_symbol")}return N(e,[{key:"onPurchase",value:function(e){return"number"!=typeof e&&xe.warn("付费金额需要为数字"),e<=0&&xe.warn("付费金额需要大于0"),this.wrapTrack("PURCHASE",{value:e})}},{key:"onEnterForeground",value:function(){return this.wrapTrack("ENTER_FOREGROUND")}},{key:"onEnterBackground",value:function(){return this.wrapTrack("ENTER_BACKGROUND")}},{key:"onAppStart",value:function(){return this.wrapTrack("START_APP")}},{key:"onAppQuit",value:function(){return this.wrapTrack("APP_QUIT")}},{key:"onAddToWishlist",value:function(){return this.wrapTrack("ADD_TO_WISHLIST")}},{key:"wrapTrack",value:function(e,t){return this.track(e,Object.assign(t||{},_({},this.special_method_symbol,1)))}}]),e}(),hn=function(){b(t,vn);var e=T(t);function t(){return x(this,t),e.apply(this,arguments)}return N(t,[{key:"onRegister",value:function(){return this.wrapTrack("REGISTER")}},{key:"onCreateRole",value:function(e){return e&&"string"!=typeof e&&xe.warn("角色名称需要为字符串"),this.wrapTrack("CREATE_ROLE",e?{name:e}:{})}},{key:"onTutorialFinish",value:function(){return this.wrapTrack("TUTORIAL_FINISH")}}]),t}(),gn="(如果确认无误,请忽略该提示)",yn=function(){var e=[];return{requestActionList:function(){try{le({conf_name:"data_nexus_common",conf_key:"action_types"}).then(function(t){ge(t)&&(e=t)})}catch(e){xe.error(e)}},getActionList:function(){return e}}}();function mn(e,t){try{e.is_sdk_auto_track||(function(e){try{var t=yn.getActionList();if(!t.includes(e)){var n,r=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=k(e))){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}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 o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(_n(o,e)<=parseInt((.3*o.length).toString())){xe.warn("通过SDK上报的".concat(e,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(gn));break}}}catch(e){r.e(e)}finally{r.f()}}}catch(t){xe.error(t)}}(e.action_type),"minigame"===t?function(e,t){var n,r,o;try{["PURCHASE","ADD_TO_CART"].includes(e.action_type)&&e.action_param&&Oe(e.action_param,"value")&&("number"!=typeof(null==(n=e.action_param)?void 0:n.value)?xe.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要为数字!")):(null==(r=e.action_param)?void 0:r.value)<=0?xe.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要大于0!")):"minigame"===t&&(null==(o=e.action_param)?void 0:o.value)<100&&xe.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(gn)))}catch(e){xe.error(e)}}(e,t):"miniprogram"===t&&function(e){try{var t=null==e?void 0:e.action_type,n=(null==e?void 0:e.action_param)||{};"PURCHASE"===t&&Oe(n,"value")&&("number"!=typeof(null==n?void 0:n.value)?xe.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要为数字!")):(null==n?void 0:n.value)<=0&&xe.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要大于0!")))}catch(t){xe.error(t)}}(e))}catch(e){xe.error(e)}}function _n(e,t){try{if(0===e.length)return t.length;if(0===t.length)return e.length;for(var n=[],r=0;r<=t.length;r++)n[r]=[r];for(var o=0;o<=e.length;o++)n[0][o]=o;for(var i=1;i<=t.length;i++)for(var a=1;a<=e.length;a++)t.charAt(i-1)===e.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[t.length][e.length]}catch(n){xe.error(n)}}function An(e){try{e&&!/^[a-zA-Z0-9_\-]+$/.test(e)&&xe.warn("通过SDK上报的openid:".concat(e,"可能有误,请检查openid是否正确!").concat(gn))}catch(e){xe.error(e)}}var kn,Sn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,wn=function(e,t,n,r){for(var o,i=r>1?void 0:r?bn(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Sn(t,n,i),i},Tn=Symbol("initializedInstance"),Rn=Symbol("autoTrack"),On=Symbol("actionTime"),En=function(){b(t,hn);var e=T(t);function t(n){var r;if(x(this,t),(r=e.call(this)).env="production",r.sdk_version="1.5.5",r.sdk_name="@dn-sdk/minigame",r.deviceInfo={},r.gameInfo={},r.session_id="",r.log_id=0,r.inited=!1,r.initErrMsg="",null==wx||!wx.createCanvas)return r.initErrMsg="不支持非微信小游戏中使用",xe.error(r.initErrMsg),R(r);var o=Re();if(t[Tn].length>=o.maxSdkInstance)return r.initErrMsg="初始化超过上限",xe.error(r.initErrMsg),R(r);var i=function(e){return he(e)?(function(e){var t=["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 e)t.includes(n)||xe.warn("Invalid property '".concat(n,"' found in config"))}(e),"number"!=typeof e.user_action_set_id?"user_action_set_id 参数需为 number 类型":e.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeof e.secret_key?"secret_key 参数需为 string 类型":""===e.secret_key.trim()?"缺少 secret_key 参数":32!==e.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeof e.appid?"appid 参数需为 string 类型":""!==e.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"}(n),a=ae();if(!0!==i)return r.initErrMsg=i,xe.error(i),R(r);var u=null==a?void 0:a.appId;if(u&&u!==n.appid)return r.initErrMsg="初始化传入的appid与当前小游戏appid不一致",xe.error(r.initErrMsg),R(r);r.config=n,Oe(n,"auto_track")||(r.config.auto_track=Te("autoTrack")),r.openid=n.openid,r.unionid=n.unionid,r.user_unique_id=n.user_unique_id,r.onReportComplete=n.on_report_complete,r.onReportFail=n.on_report_fail,r.saveValidOpenidToStorage();var c=n.user_action_set_id;return t[Tn].includes(c)?(r.initErrMsg="同个数据源[".concat(c,"]只能初始化一次"),xe.error(r.initErrMsg),r.reportLog({log_type:G,message:r.initErrMsg}),R(r)):(r.reportLog=r.reportLog.bind(O(r)),r.getTrackBaseInfo=r.getTrackBaseInfo.bind(O(r)),r.deviceInfo=ne(),r.gameInfo=Ce(),r.session_id=_e(),r.queueManage=new Fe({userActionSetId:c,maxLength:o.maxQueueLength,ogEvents:Ge}),r.actionReporter=new Xt({getBaseInfo:r.getTrackBaseInfo,reportLog:r.reportLog,queueManager:r.queueManage,configManager:at,onReportComplete:r.onReportComplete,onReportFail:r.onReportFail}),r.inited=!0,t[Tn].push(c),r.useAutoTrack(),r.doReportOnEnterBackground(),"release"===(null==a?void 0:a.envVersion)?(xe.info("初始化成功"),R(r)):(function(e){var t=e.sdk_version,n=e.default_download_url,r=e.fail_handler;le({conf_name:e.conf_name,conf_key:e.conf_key}).then(function(e){if(he(e)){var o=null==e?void 0:e.blackVersions,i=null==e?void 0:e.minVersion,a=null==e?void 0:e.bestVersion,u=null==e?void 0:e.downloadUrl,c=n;return u&&/^https/.test(u)&&(c=u),ge(o)&&(null==o?void 0:o.indexOf(t))>-1?(null==r||r(),void xe.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):i&&we(t,i)<0?(null==r||r(),void xe.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&we(t,a)<0&&xe.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),void xe.info("初始化成功"))}xe.info("初始化成功")}).catch(function(){xe.info("初始化成功")})}({conf_name:"mini_game_sdk_common",conf_key:"version",sdk_version:r.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(){r.inited=!1}}),yn.requestActionList(),An(n.openid),R(r)))}return N(t,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(e,t){var n,r;if(!this.inited||!this.queueManage)return xe.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};var o=Mt.validateActionType(e),i=Mt.validateActionParam(t);if(o&&i){!this.openid&&!this.unionid&&xe.warn("缺少 openid 或 unionid");var a=Te("actionParamMaxLength");if(JSON.stringify(t||{}).length>a)return xe.error("监测到超过".concat(a,"的上报日志:").concat(e," ").concat(t)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};var u=!(null==t||!t[Rn]),c=this.createAction(e,t||{},u);"release"!==(null==(n=ae())?void 0:n.envVersion)&&mn(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 e;null==(e=this.actionReporter)||e.flushSend()}},{key:"setOpenId",value:function(e){var t;if(e&&"string"==typeof e)return this.openid=e,this.gameInfo.ad_trace_id&&!te.getSync(B)&&Ke.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(t=ae())?void 0:t.envVersion)&&An(e),{code:0,message:"成功"};var n="openid 格式错误";return xe.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(e){if(e&&"string"==typeof e)return this.unionid=e,this.flush(),{code:0,message:"成功"};var t="unionid 格式错误";return xe.error(t),{code:101,message:t}}},{key:"setUserUniqueId",value:function(e){if(e&&"string"==typeof e)return this.user_unique_id=e,{code:0,message:"成功"};var t="user_unique_id 格式错误";return xe.error(t),{code:101,message:t}}},{key:"doReportOnEnterBackground",value:function(){var e=this;wx.onHide(function(){var t,n;null==(t=e.actionReporter)||t.flushSend(),null==(n=e.queueManage)||n.reportLostNum()})}},{key:"getTrackBaseInfo",value:function(){var e=ae();return Object.assign({},this.deviceInfo,function(e){var t={};return["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"].forEach(function(n){Oe(e,n)&&(t[n]=e[n])}),t}(this.config),{local_id:re(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||ie(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:e.envVersion,app_version:e.version}})}},{key:"createAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];null!=t&&t[Rn]&&delete t[Rn];var r=Date.now();null!=t&&t[On]&&(r=null==t?void 0:t[On],delete t[On]);var o={action_id:_e(),action_param:t,action_time:r,action_type:e,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:se.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:oe(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(e)};return null!=t&&t[this.special_method_symbol]&&(this.addActionInnerParam(o,"is_special_method",!0),delete t[this.special_method_symbol]),at.getChannelClaimActionList().indexOf(e)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(o,"launch_options",this.gameInfo.launch_options),o}},{key:"addActionInnerParam",value:function(e,t,n){e.inner_param&&he(e.inner_param)?e.inner_param[t]=n:e.inner_param=_({},t,n)}},{key:"getChannelByActionType",value:function(e){var t="";return at.getChannelClaimActionList().indexOf(e)>-1?t=this.gameInfo.channel||"":at.getNoClaimActionList().indexOf(e)>-1&&(t="UNKNOWN"),t}},{key:"reportLog",value:function(e){var t,n,r={user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,appid:null==(n=this.config)?void 0:n.appid,session_id:this.session_id};ce(Object.assign(r,e))}},{key:"useAutoTrack",value:function(){var e;if(null!=(e=this.config)&&e.auto_track){var t=!0,n=te.getSync(U);(null==n?void 0:n.ap)===Z?t=!0:(null==n?void 0:n.ap)===X&&(t=!1),"devtools"===ne().wx_platform&&(t=!0),(new pn).install(this,t?"all":"lifecycle"),ft(),t&&xt(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){var e,t,n=ne();n.os&&n.os_version&&null!=(e=this.config)&&e.user_action_set_id&&function(e){return new Promise(function(t){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:e,timeout:K.requestTimeout,success:function(e){fe(e,t,"minigame/get"),pe(e)},fail:function(e){de(e,"minigame/get")}})})}({conf_name:"MG",conf_param:{user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void 0:n.os)||"",os_version:Ee(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(e){he(e)&&te.setSync(U,e)})}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(e){return/^[a-zA-Z0-9_-]{28,30}$/.test(e)}(this.openid)&&te.setSync(B,this.openid)}}],[{key:"setRequestConcurrency",value:function(e){Xt.setRequestConcurrency(e)}},{key:"setDebug",value:function(e){xe.debug=e}}]),t}(),In=En;In[Tn]=[],wn([Ne],In.prototype,"track",1),wn([Ne,function(e,t,n){var r=n.value;return n.value=function(){if(this.inited){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(this,t)}xe.error("上报失败,请先完成初始化")},n}],In.prototype,"flush",1),wn([Ne],In.prototype,"setOpenId",1),wn([Ne],In.prototype,"setUnionId",1),wn([Ne],In.prototype,"setUserUniqueId",1),wn([Ne],In.prototype,"doReportOnEnterBackground",1),wn([Ne],In.prototype,"getTrackBaseInfo",1),wn([Ne],In.prototype,"useAutoTrack",1);var xn=0,Cn={moid:""},Nn=!1,Pn=JSON.stringify(wx.getLaunchOptionsSync()||""),Ln={token:"",uid:"",uname:"",openid:""},Mn={partner_id:"",game_id:"",pkg_name:"",version:""},Dn={doid:"",dsid:"",dsname:"",dext:"",drid:"",drname:"",drlevel:"",dmoney:"",money:""},jn="wx-adapter sdk >>>>>>>:";wx.hideShareMenu(),wx.onShow(function(e){e.query&&(Pn=JSON.stringify(e))});var qn=function(e){var t=r(r({},g()),v),n=d(r(r(r(r(r({},Dn),Ln),Mn),t),{},{launchoption:Pn,onshow:Pn}));s(c,"/wxgamemds/index/",n).then(function(t){t.state&&(t.data.balance>=e?Fn(""):Un(t.data,e))}).catch(function(e){console.log(e)})},Un=function(e,t){wx.requestMidasPayment({mode:"game",env:e.env,offerId:e.offerId,currencyType:e.currencyType,platform:e.platform,buyQuantity:e.buyQuantity,outTradeNo:Cn.moid,success:function(e){kn&&kn.onPurchase(100*t),Fn(e)},fail:function(e){console.log(e)}})},Fn=function(e){var t;xn++;var n=r(r({},g()),v);t=d(e?r(r(r(r(r(r({},Dn),Mn),Ln),n),Cn),{},{res:JSON.stringify(e),launchoption:Pn,onshow:Pn}):r(r(r(r(r(r({},Dn),Mn),Ln),Cn),n),{},{launchoption:Pn,onshow:Pn})),s(c,"/wxgamemds/send/",t).then(function(e){console.log(e)}).catch(function(t){console.log(t),xn<3&&setTimeout(function(){Fn(e)},1e3)})},Bn=function(e){return new Promise(function(t,n){var o=Ln||{},i=o.token,a=o.uid,l=o.uname;if(!(Nn&&i&&a&&l))return u("未激活或未登录,请重新进入游戏"),n({state:100001,msg:"未激活或未登录,请检查"});var f=d(r(r(r(r(r({},e),Ln),Mn),r(r({},g()),v)),{},{launchoption:Pn,onshow:Pn}));s(c,"/wxgameevent/index/",f).then(function(){t(),kn&&("create"===f.event&&kn.onCreateRole(f.drname),"levelup"===f.event&&kn.track("UPDATE_LEVEL",{level:f.drlevel,power:0}))}).catch(function(e){console.log(e),n({state:100002,msg:"角色上报失败"})})})},Vn=null,Kn=!1,Gn=!1;e.jf_SSEventReport=function(e){return new Promise(function(t,n){var r=Ln||{},o=r.token,i=r.uid,a=r.uname;return Nn&&o&&i&&a?Array.isArray(e)?e.length?void l(c,"/report/batch/event",{body:e}).then(function(){t({state:0,msg:"上报成功!"})}).catch(function(e){n({state:100004,msg:JSON.stringify(e)})}):n({state:100003,msg:"入参不能为数组空,请检查"}):n({state:100002,msg:"入参需要数组,请检查"}):(u("请先激活登录"),n({state:100001,msg:"未激活或未登录,请重新进入游戏"}))})},e.jf_SSUserPropsReport=function(e){return new Promise(function(t,n){var r=Ln||{},o=r.token,i=r.uid,a=r.uname;return Nn&&o&&i&&a?Array.isArray(e)?e.length?void l(c,"/report/batch/attribute",{body:e}).then(function(){t({state:0,msg:"上报成功!"})}).catch(function(e){n({state:100004,msg:JSON.stringify(e)})}):n({state:100003,msg:"入参不能为数组空,请检查"}):n({state:100002,msg:"入参需要数组,请检查"}):(u("请先激活登录"),n({state:100001,msg:"未激活或未登录,请重新进入游戏"}))})},e.jf_active=function(e){return new Promise(function(t,n){if(!e)return n({state:100001,msg:"激活入参缺失"});if(null==e||!e.wx)return n({state:100002,msg:"激活入参 wx 属性缺失"});var r=e.wx,o=r.game_id,i=r.version,a=r.dn_sdk_id,u=r.dn_secret_key;if(!o)return n({state:100003,msg:"激活入参 game_id 属性缺失"});Mn.game_id=o,Mn.version=i,Mn.pkg_name="wxgame",Mn.partner_id=4,Nn=!0,console.log("active 激活成功!"),a&&u&&function(e){var t=e.dn_sdk_id,n=e.dn_secret_key,r=e.app_id,o=(kn=new In({appid:r,secret_key:n,user_action_set_id:t})).getInitResult();null!=o&&o.inited||console.error("dnSdk init failed: ",o.initErrMsg),kn.onAppStart(),wx.onAddToFavorites(function(e){console.log(jn+"click onAddToFavorites"),kn&&kn.track("DD_TO_WISHLIST",{type:"default"})}),wx.onShareAppMessage(function(){console.log(jn+"click onShareAppMessage"),kn&&kn.track("SHARE",{target:"APP_MESSAGE"})}),wx.onShareTimeline(function(){console.log(jn+"click onShareTimeline"),kn&&kn.track("SHARE",{target:"TIME_LINE"})}),console.log(jn+"广点通初始化成功!")}(wx),t()})},e.jf_createRewardedVideoAd=function(e){var t=function(){return new Promise(function(t,n){if(Kn)return t();Vn&&(Vn=null),(Vn=wx.createRewardedVideoAd({adUnitId:e})).onError(function(e){Kn=!1,Vn=null,n({state:100004,msg:"广告平台异常",originalErr:e})}),Vn.load().then(function(){console.log("激励视频广告预加载成功"),Kn=!0,t()}).catch(function(e){console.error("激励视频广告预加载失败:",e),Kn=!1,Vn=null,n(e)})})},n=function(){return Gn?Promise.reject({state:100004,msg:"广告正在展示中,请稍后再试"}):Kn?Vn?(Gn=!0,new Promise(function(e,t){Vn.onClose(function(t){console.log("激励视频广告关闭,是否看完:",t.isEnded),e({isEnded:t.isEnded}),Gn=!1,Vn.offClose()}),Vn.show().then(function(){console.log("激励视频广告展示成功")}).catch(function(e){Kn=!1,Gn=!1,t({state:100003,msg:JSON.stringify(e)})})})):Promise.reject({state:100002,msg:"广告实例不存在"}):t().then(n).catch(function(e){return Promise.reject({state:100001,msg:JSON.stringify(e)})})};return{preload:t,show:n}},e.jf_customerService=function(e){wx.openCustomerServiceConversation({success:function(){Bn(r(r({},p(e)),{},{event:"kfclick"}))}})},e.jf_getUserInfo=function(){return new Promise(function(e,t){wx.getSetting({success:function(n){n.authSetting["scope.userInfo"]?wx.getUserInfo({success:function(t){return e(t.userInfo)},fail:function(e){return t({state:100001,msg:JSON.stringify(e)})}}):wx.getUserProfile({desc:"获取用户信息",success:function(t){return e(t.userInfo)},fail:function(e){return t({state:100002,msg:JSON.stringify(e)})}})}})})},e.jf_login=function(){return new Promise(function(e,t){if(!Nn)return t({state:100003,msg:"登录前请先激活"});wx.login({success:function(n){var o=d(r(r(r({code:n.code},Mn),m()),{},{launchoption:Pn,onshow:Pn}));s(c,"/wxgamelogin/initlogin/",o).then(function(n){if(1==n.state){var r=n.data,o=r.token,i=r.uid,a=r.uname,c=r.openid,s=r.show_page;if(Ln.token=o,Ln.uid=i,Ln.uname=a,Ln.openid=c,wx.setStorageSync("jfGamekitSSToken",o),e({token:o,uid:i,uname:a,partner_id:4,show_page:s}),console.log(jn+"登录成功"),c&&kn){var l=n||{},f=l.backFlowDay,d=l.isRegisterUser;!function(e){var t=e.openid,n=e.nsSdk,r=e.backFlowDay,o=e.isRegisterUser;n.setOpenId(t),o?n.onRegister():r&&r>=30&&n.track("RE_ACTIVE",{backFlowDay:30})}({openid:c,nsSdk:kn,backFlowDay:f,isRegisterUser:d})}}else u(n.msg),t({state:n.state,msg:n.msg})}).catch(function(e){u(e),t({state:100001,msg:e})})},fail:function(e){t({state:100002,msg:e})}})})},e.jf_pay=function(e){return new Promise(function(t,n){var o=Ln||{},i=o.token,a=o.uid,l=o.uname;if(!(Nn&&i&&a&&l))return u("失败!请先激活登录"),n({state:100001,msg:"未激活或未登录,请重新进入游戏"});wx.showLoading({title:"加载中"});var f=e.dmoney;(Dn=p(e)||{}).money=f;var h=d(r(r(r(r(r({},e),Mn),Ln),r(r(r({},g()),y()),v)),{},{money:f,launchoption:Pn,onshow:Pn}));s(c,"/wxgameorder/index/",h).then(function(e){var r=e||{},o=r.state,i=r.msg,a=r.data,l=void 0===a?{}:a;if(1==o){var p=l.aid,v=l.moid,h=l.thumb_url;Cn.moid=v,1==p?(qn(f),t({msg:"ok"})):2==p?wx.showModal({title:"支付提示",content:"即将打开充值入口,输入“充值”或点击右下角卡片即可充值。",showCancel:!1,confirmText:"点我充值",success:function(e){e.confirm?wx.openCustomerServiceConversation({sessionFrom:v,sendMessagePath:"/path/index/index?moid="+v,showMessageCard:!0,sendMessageImg:h,success:function(e){console.log("openCustomerServiceConversation success",e),t()},fail:function(e){console.error("openCustomerServiceConversation fail ",e),n({state:100003,msg:"支付失败"})},complete:function(e){console.log("openCustomerServiceConversation compelte: ",v),function(e){var t=m(),n=d({partner_id:Mn.partner_id,pkg_name:Mn.pkg_name,game_id:Mn.game_id,uid:Ln.uid,openid:Ln.openid,token:Ln.token,uname:Ln.uname,duid:t.duid,moid:e});s(c,"/wxgameorder/get/",n).then(function(e){1==e.data.status&&kn.onPurchase(100*e.data.money)})}(v)}}):(u("用户取消支付"),n({state:100005,msg:"取消支付"}))},fail:function(){u("用户取消支付"),n({state:100006,msg:"支付失败"})}}):(u("失败!设备未识别"),n({state:100004,msg:"支付失败"}))}else u(i),n({state:o,msg:i});wx.hideLoading()}).catch(function(e){u(e),n({state:100002,msg:"支付失败"}),wx.hideLoading()})})},e.jf_profanityCheck=function(e){return new Promise(function(t,n){var o=d(r(r(r(r(r({},e),Mn),Ln),m()),{},{launchoption:Pn,onshow:Pn,partner_id:4}));s(c,"/wxgamesafe/verify/",o).then(function(e){var r=e.data,o=r.code,i=r.msg;1==o?t():n({state:100001,msg:i})}).catch(function(e){n({state:100002,msg:e})})})},e.jf_share=function(e){wx.shareAppMessage(),Bn(r(r({},p(e)),{},{event:"fxclick"}))},e.jf_showInterstitialAd=function(e){return new Promise(function(t,n){var r=!1,o=wx.createInterstitialAd({adUnitId:e});o.onError(function(e){r=!0}),o.load().then(function(){if(!r)return o.show();n({state:100001,msg:"广告加载后发生错误"})}).then(t).catch(function(e){return n({state:100002,msg:JSON.stringify(e)})}),o.onClose(function(e){console.log("广告关闭:",e.isEnded?"正常播放完成":"用户提前关闭")})})},e.jf_trace=Bn,e.jf_tracePageView=function(e){return new Promise(function(t,n){kn?(kn.track("VIEW_CONTENT",{item:e}),t()):n({state:100001,msg:"上报失败!广点通 sdk 未初始化"})})},Object.defineProperty(e,"__esModule",{value:!0})});
|
|
7
|
+
function w(e,t,n){return(t=q(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(e){return function(e){if(Array.isArray(e))return R(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||O(e)||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 O(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(e,t):void 0}}function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function E(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&I(e,t)}function I(e,t){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},I(e,t)}function x(e){var t=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(e){return!1}}();return function(){var n,r=P(e);if(t){var o=P(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return C(this,n)}}function C(e,t){if(t&&("object"===L(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return N(e)}function N(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function P(e){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},P(e)}function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function M(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,q(r.key),r)}}function j(e,t,n){return t&&D(e.prototype,t),n&&D(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function q(e){var t=function(e){if("object"!==L(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==L(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===L(t)?t:String(t)}var U,F,B="LOCAL_ID",V="CLICK_ID",K="QUEUE_LOST_MAP",G="REMOTE_CONFIG",J="REMOTE_COMMON_CONFIG",W="OPENID",H={init:"init",reporting:"reporting",fail:"fail"},Y={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"]},Q="JS_RUN_ERROR",z="REQUEST_ERROR",$="REQUEST_CONFIG_ERROR",Z="JS_QUEUE_LOG",X="PROXY_ERROR",ee="QUEUE_LOST_NUM",te="SIGN_ERROR",ne="UNKNOWN",re="TRUE",oe="FALSE",ie="TICKET_INTERVAL_CHANGE",ae=(F=function(e){return"".concat("@dn-sdk/minigame","_").concat("production","_").concat(e)},{getSync:function(e){var t;try{t=wx.getStorageSync(F(e))}catch(e){return console.error("storage get error",e),t}return t},setSync:function(e,t){try{wx.setStorageSync(F(e),t)}catch(e){return console.error("storage set error",e),!1}return!0}}),ue=function(){var e;return function(){if(!e){var t=function(){if(U)return U;try{return U=wx.getSystemInfoSync()}catch(e){return{}}}(),n=t.system,r=void 0===n?"":n,o=(null==r?void 0:r.split(" "))||[],i=function(e){if(!e)return ne;var t=(null==e?void 0:e.toUpperCase())||"";return t.indexOf("ANDROID")>-1?"ANDROID":t.indexOf("IOS")>-1?"IOS":t.indexOf("MAC")>-1?"OSX":t.indexOf("WINDOWS")>-1?"WINDOWS":ne}(o[0]),a=function(e){return!e||e.length<=0?"":2===e.length?e[1]:3===e.length&&"Windows"===e[0]?"".concat(e[1]," ").concat(e[2]):e[e.length-1]}(o);e={benchmark_level:t.benchmarkLevel,device_brand:t.brand,screen_height:Math.floor(t.screenHeight),screen_width:Math.floor(t.screenWidth),wx_lib_version:t.SDKVersion,wx_version:t.version,wx_platform:t.platform,device_model:t.model,os:i,os_version:a}}return e}}(),ce=function(){var e;return function(){try{if(e)return e;e||(e=ae.getSync(B)||""),e||(e=we(),ae.setSync(B,e))}catch(e){}return e}}(),se=function(){var e="unknown",t=!1;return function(){if(!t)try{wx.getNetworkType({success:function(t){e=t.networkType},fail:function(){e="unknown"}}),wx.onNetworkStatusChange(function(t){e=t.networkType}),t=!0}catch(e){}return e}}();se();var le=function(){var e="";return function(){return e||(e=ae.getSync(W)||""),e}}(),fe=function(){var e;return function(){if(e)return e;try{var t=wx.getAccountInfoSync();return Ae(t.miniProgram)?e=t.miniProgram:{}}catch(t){return{}}}}();function de(e){var t=null==e?void 0:e.query;if(!Ae(t))return"";var n="";return t.gdt_vid||[1045,1046,1084].indexOf(null==e?void 0:e.scene)>-1?n="TENCENT":t.clue_token||t.clickid&&t.item_id?n="BYTEDANCE":t.callback&&"kuaishou"===t.ksChannel?n="KUAISHOU":t.bd_vid||t.ai&&t.d&&t.q&&t.c?n="BAIDU":t.uctrackid?n="ALIBABA":(t.trackid||t.imp||[1065,1069,1194].indexOf(null==e?void 0:e.scene)>-1&&(t.callback||t.u))&&(n="OTHERS"),n}function pe(e,t){try{var n=ue(),r=fe(),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:ce(),env_version:null==r?void 0:r.envVersion,appid:null==r?void 0:r.appId},i=Object.assign(o,e);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:i,method:"POST",timeout:Y.requestTimeout,success:function(e){"function"==typeof t&&200===(null==e?void 0:e.statusCode)&&t()}})}catch(n){Me.error(n)}}var ve=function(){function e(){M(this,e)}return j(e,null,[{key:"revise",value:function(e){e>0&&!this.isRevised&&(this.offsetTime=e-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){return this.isRevised?Date.now()+this.offsetTime:-1}}]),e}();function ge(e){return new Promise(function(t,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:e,timeout:Y.requestTimeout,success:function(e){he(e,t,"config/get",n),ye(e)},fail:function(e){me(e,"config/get",n)}})})}function he(e,t,n,r){var o,i,a,u,c=null==e?void 0:e.statusCode,s=null==(o=null==e?void 0:e.data)?void 0:o.code;if(200!==c||0!==s){var l=s;200!==c&&(l="number"==typeof c?-1*c:-888),pe({log_type:$,message:"cgiName: ".concat(n,", statusCode: ").concat(c,", code: ").concat(s,", traceid: ").concat(null==(a=null==e?void 0:e.data)?void 0:a.trace_id),code:l}),null==r||r(null==(u=null==e?void 0:e.data)?void 0:u.data)}else t(null==(i=e.data)?void 0:i.data)}function me(e,t,n){pe({log_type:$,message:"cgiName: ".concat(t," , message: ").concat(null==e?void 0:e.errMsg," "),code:"number"==typeof(null==e?void 0:e.errno)?-1*e.errno:-999}),null==n||n(e)}function ye(e){var t,n=1*(null==(t=null==e?void 0:e.header)?void 0:t["Server-Time"]);n>17266752e5&&ve.revise(n)}ve.offsetTime=0,ve.isRevised=!1;var _e=Object.prototype.toString,Ae=function(e){return"[object Object]"===_e.call(e)},ke=function(e){return"[object Array]"===_e.call(e)},Se=function(e){return"[object Function]"===_e.call(e)},be=(new Date).getTime();function we(){var e=(new Date).getTime(),t=Math.abs(1e3*(e-be));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".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).replace(/-/g,"")})}var Te=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Oe=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");if(!Te.test(e))throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"))},Re=function(e){return isNaN(Number(e))?e:Number(e)},Ee=function(e){var t=e.replace(/^v/,"").replace(/\+.*$/,""),n=function(e){return-1===e.indexOf("-")?e.length:e.indexOf("-")}(t),r=t.substring(0,n).split(".");return r.push(t.substring(n+1)),r},Ie=function(e,t){[e,t].forEach(Oe);for(var n=Ee(e),r=Ee(t),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(Re),l=c.split(".").map(Re),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};function xe(e){return Ce()[e]}function Ce(){return Y}function Ne(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Pe=function(e){try{return e&&"string"==typeof e?-1===(e=e.replace(/\s/g,"")).indexOf(".")?e:e.split(".").slice(0,2).join("."):""}catch(t){return e}},Le=function(){function e(){M(this,e)}return j(e,null,[{key:"error",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(t=console).error.apply(t,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(r))}},{key:"info",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.debug&&(n=console).info.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}},{key:"log",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.debug&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}},{key:"warn",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(t=console).warn.apply(t,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(e)].concat(r))}},{key:"devLog",value:function(t){for(var n,r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];e.isDev&&(n=console).log.apply(n,["".concat("[@dn-sdk/minigame v1.5.5]",": ").concat(t)].concat(o))}}]),e}(),Me=Le;Me.debug=!1,Me.isDev=!1;var De=function(){var e;return function(){if(!e)try{var t=wx.getLaunchOptionsSync(),n=t.query.gdt_vid||"";n?ae.setSync(V,n):n=ae.getSync(V)||"";var r=JSON.stringify(t);r.length>1e4&&(r=JSON.stringify({cut:1,scene:t.scene})),e={source_scene:t.scene,pkg_channel_id:t.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:de(t)}}catch(t){e={},Me.log("获取场景值和渠道号失败",t)}return e}}();function je(e,t,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{Me.error.apply(Me,["calling ".concat(e.constructor.name,".").concat(t," error with arguments")].concat(o)),Me.error(n);var a={log_type:Q,message:"[safeExcutable] ".concat(e.constructor.name,".").concat(t,": ").concat(null==n?void 0:n.message),err_stack:null==n?void 0:n.stack};Se(this.reportLog)?this.reportLog(a):pe(a)}catch(a){}}},n}var qe=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Fe=function(e,t,n,r){for(var o,i=r>1?void 0:r?Ue(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&qe(t,n,i),i},Be=function(){function e(t){var n=t.userActionSetId,r=t.maxLength,o=void 0===r?500:r;M(this,e),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat("QUEUE_ACTIONS","_").concat(null==n?void 0:n.toString()),this.maxLength=o,this.userActionSetId=n,this.setTimeStamp(),this.init()}return j(e,[{key:"getItems",value:function(){return this.stack}},{key:"getStorage",value:function(){var e,t=(null==(e=ae)?void 0:e.getSync(this.localStorageKey))||"[]";return JSON.parse(t)}},{key:"reportLostNum",value:function(){var e=this,t=Object.assign({},this.lostActionMaps),n=[];for(var r in t){var o=null==r?void 0:r.split("_");n.push({queue_lost_session_id:o[0],queue_lost_timestamp:o[1],queue_lost_num:t[r]})}n.length&&(this.setTimeStamp(),n.forEach(function(t){var n=Object.assign({},{user_action_set_id:e.userActionSetId,log_type:ee},t),r=null==t?void 0:t.queue_lost_session_id,o=null==t?void 0:t.queue_lost_timestamp,i="".concat(r,"_").concat(o);pe(n,function(){Ne(e.lostActionMaps,i)&&(delete e.lostActionMaps[i],ae.setSync(K,JSON.stringify(e.lostActionMaps)))})}))}},{key:"getLostMaps",value:function(){return this.lostActionMaps}},{key:"init",value:function(){var e=this,t=this.getStorage(),n=null==t?void 0:t.map(function(e){var t,n;return e.inner_status===(null==(t=H)?void 0:t.reporting)?Object.assign({},e,{inner_status:null==(n=H)?void 0:n.fail,is_retry:!0,retry_count:e.retry_count+1}):e});this.stack=n,this.lostActionMaps=JSON.parse(ae.getSync(K)||"{}"),setTimeout(function(){e.reportLostNum()},1e3)}},{key:"addItem",value:function(e){var t;null==(t=null==this?void 0:this.stack)||t.push(e)}},{key:"removeItems",value:function(e){var t,n=null==(t=null==this?void 0:this.stack)?void 0:t.filter(function(t){return!(null!=e&&e.includes(null==t?void 0:t.action_id))});this.stack=n}},{key:"updateForReportFail",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map(function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=H)?void 0:n.fail,retry_count:t.retry_count+1,is_retry:!0}):t})}},{key:"updateForReporting",value:function(e){var t;this.stack=null==(t=this.stack)?void 0:t.map(function(t){var n;return null!=e&&e.includes(null==t?void 0:t.action_id)?Object.assign({},t,{inner_status:null==(n=H)?void 0:n.reporting}):t})}},{key:"updateAllStack",value:function(e){this.stack=e}},{key:"updateToStorage",value:function(){ae.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(e){if(e){var t="".concat(e,"_").concat(this.timeStamp),n=this.lostActionMaps[t]||0;this.lostActionMaps[t]=n+1,ae.setSync(K,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),e}();Fe([je],Be.prototype,"getItems",1),Fe([je],Be.prototype,"getStorage",1),Fe([je],Be.prototype,"reportLostNum",1),Fe([je],Be.prototype,"getLostMaps",1),Fe([je],Be.prototype,"init",1),Fe([je],Be.prototype,"addItem",1),Fe([je],Be.prototype,"removeItems",1),Fe([je],Be.prototype,"updateForReportFail",1),Fe([je],Be.prototype,"updateForReporting",1),Fe([je],Be.prototype,"updateAllStack",1),Fe([je],Be.prototype,"updateToStorage",1),Fe([je],Be.prototype,"updateLostAction",1);var Ve=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ge=function(e,t,n,r){for(var o,i=r>1?void 0:r?Ke(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ve(t,n,i),i},Je=function(){E(t,Be);var e=x(t);function t(n){var r,o=n.userActionSetId,i=n.maxLength,a=void 0===i?500:i,u=n.ogEvents,c=void 0===u?[]:u;return M(this,t),(r=e.call(this,{userActionSetId:o,maxLength:a})).ogEvents=c,r}return j(t,[{key:"getReportableActions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,t=this.getItems(),n=[];return null==t||t.forEach(function(t){var r;(null==n?void 0:n.length)<e&&(null==t?void 0:t.inner_status)!==(null==(r=H)?void 0:r.reporting)&&(null==n||n.push(t))}),n}},{key:"addAction",value:function(e){var t={code:0,message:"成功",actionId:e.action_id},n=this.getItems();if((null==n?void 0:n.length)>=this.maxLength){var r="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");Me.warn(r),pe({user_action_set_id:this.userActionSetId,log_type:Z,message:"队列长度超过限制"});var o=this.sortQueue(e,n);Me.debug&&Me.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)===e.action_id&&(t={code:103,message:"缓存队列已满,主动丢弃行为"})}else this.addItem(e);return this.updateToStorage(),t}},{key:"removeActions",value:function(e){this.removeItems(e),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(e){this.updateForReportFail(e),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(e){this.updateForReporting(e),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){var e=this.getItems().filter(function(e){var t;return(null==e?void 0:e.inner_status)!==(null==(t=H)?void 0:t.reporting)});return null==e?void 0:e.length}},{key:"sortQueue",value:function(e,t){var n=this,r={},o=null==e?void 0:e.action_time,i=t.concat([e]),a=function(e){return r[e.action_id]||(r[e.action_id]=n.caculateWeight(o,e)),r[e.action_id]};return i.sort(function(e,t){return a(t)-a(e)})}},{key:"caculateWeight",value:function(e,t){var n,r=0,o=this.formatWeight(e,null==t?void 0:t.action_time),i=o.ogWeight,a=o.sdkWeight,u=o.userWeight;null!=(n=this.ogEvents)&&n.includes(null==t?void 0:t.action_type)&&(r+=i),null!=t&&t.is_sdk_auto_track?r+=a:r+=u;var c=e-(null==t?void 0:t.action_time)+1;return c>0?r+1/c:r}},{key:"formatWeight",value:function(e,t){var n=1e3,r=10,o=100;return e-t>2592e6&&(n/=100,r/=100,o/=100),{ogWeight:n,sdkWeight:r,userWeight:o}}}]),t}();Ge([je],Je.prototype,"getReportableActions",1),Ge([je],Je.prototype,"addAction",1),Ge([je],Je.prototype,"removeActions",1),Ge([je],Je.prototype,"updateActionsForReportFail",1),Ge([je],Je.prototype,"updateActionsForReporting",1),Ge([je],Je.prototype,"getReportableActionsLength",1),Ge([je],Je.prototype,"sortQueue",1),Ge([je],Je.prototype,"caculateWeight",1),Ge([je],Je.prototype,"formatWeight",1);var We=function(){function e(){M(this,e),this.events={}}return j(e,[{key:"subscribe",value:function(t,n){e.checkCallback(n),ke(this.events[t])?this.events[t].push(n):this.events[t]=[n]}},{key:"once",value:function(t,n){e.checkCallback(n),this.subscribe(this.onceEventName(t),n)}},{key:"unsubscribe",value:function(t,n){e.checkCallback(n),ke(this.events[t])&&(this.events[t]=this.events[t].filter(function(e){return e!==n})),ke(this.events[this.onceEventName(t)])&&(this.events[this.onceEventName(t)]=this.events[this.onceEventName(t)].filter(function(e){return e!==n}))}},{key:"publish",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=Date.now();ke(this.events[e])&&this.events[e].forEach(function(e){return e.apply(void 0,[o].concat(n))}),ke(this.events[this.onceEventName(e)])&&(this.events[this.onceEventName(e)].forEach(function(e){return e.apply(void 0,[o].concat(n))}),this.events[this.onceEventName(e)]=[])}},{key:"onceEventName",value:function(e){return"once_event_prefix_".concat(e)}}],[{key:"checkCallback",value:function(t){Se(t)||Me.error(e.ERROR_CALLBACK_IS_NOT_A_FUNCTION)}}]),e}(),He=We;He.ERROR_CALLBACK_IS_NOT_A_FUNCTION="callback 不是函数";var Ye=new He,Qe=["REGISTER","VIEW_CONTENT","ADD_TO_CART","PURCHASE","COMPLETE_ORDER","ADD_TO_WISHLIST","START_APP","CREATE_ROLE","AUTHORIZE","TUTORIAL_FINISH","START_PAY","FINISH_PAY"],ze="START_APP",$e="TICKET",Ze="ENTER_FOREGROUND",Xe="ENTER_BACKGROUND",et="LOGIN",tt="SHARE",nt="TAP_GAME_CLUB",rt="CREATE_GAME_CLUB",ot="JOIN_GAME_ROOM",it="FINISH_PAY",at="START_PAY",ut="ADD_TO_WISHLIST",ct=["REGISTER","START_APP","RE_ACTIVE"],st=["TICKET","ENTER_FOREGROUND","ENTER_BACKGROUND"],lt=function(){function e(){M(this,e),this.channelClaimActionList=ct,this.noClaimActionList=st,this.realTimeActionList=Y.realTimeActionList,this.ticketInterval=60,this.requestTimeout=Y.requestTimeout,this.loadConfig()}return j(e,[{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 e=this;try{if("undefined"==typeof wx)return;var t=ae.getSync(J);t&&this.updateConfig(t),ge({conf_name:"mini_game_sdk_common",conf_key:"config"}).then(function(t){t&&Ae(t)&&(e.updateConfig(t),ae.setSync(J,t))})}catch(t){console.error(t)}}},{key:"updateConfig",value:function(e){e.channelClaimActionList&&ke(e.channelClaimActionList)&&(this.channelClaimActionList=e.channelClaimActionList),e.noClaimActionList&&ke(e.noClaimActionList)&&(this.noClaimActionList=e.noClaimActionList),e.realTimeActionList&&ke(e.realTimeActionList)&&(this.realTimeActionList=e.realTimeActionList),e.ticketInterval&&"number"==typeof e.ticketInterval&&e.ticketInterval>1&&e.ticketInterval!==this.ticketInterval&&(this.ticketInterval=e.ticketInterval,Ye.publish(ie)),e.requestTimeout&&"number"==typeof e.requestTimeout&&e.requestTimeout>5e3&&(this.requestTimeout=e.requestTimeout)}}]),e}(),ft=new lt,dt=ze,pt=$e,vt=Ze,gt=Xe,ht=function(){var e=!1,t=!1,n=!0,r=!0,o=!0,i=!1;return function(){if(!i){i=!0;var a=ae.getSync(G);if((null==a?void 0:a.bg)===re?e=!0:(null==a?void 0:a.bg)===oe&&(e=!1),(null==a?void 0:a.fg)===re?t=!0:(null==a?void 0:a.fg)===oe&&(t=!1),(null==a?void 0:a.st)===re?n=!0:(null==a?void 0:a.st)===oe&&(n=!1),(null==a?void 0:a.ti)===re?r=!0:(null==a?void 0:a.ti)===oe&&(r=!1),Me.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",e,t,n,r),n&&Ye.publish(dt),r){var u=function(){o&&Ye.publish(pt)},c=setInterval(u,1e3*ft.getTicketInterval());Ye.subscribe(ie,function(){c&&clearInterval(c),c=setInterval(u,1e3*ft.getTicketInterval())})}wx.onShow(function(e){if(o=!0,t){var n="";try{(n=JSON.stringify(e)).length>1e4&&(n=JSON.stringify({cut:1,scene:e.scene}))}catch(e){}Ye.publish(vt,{enter_options:n})}}),wx.onHide(function(){o=!1,e&&Ye.publish(gt)})}}}(),mt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function yt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _t,At=yt(function(){var e,t=null;function n(e){return!!e&&("object"==L(e)||"function"==typeof e)}function r(e){if(null!==e&&!n(e))throw new TypeError("Object prototype may only be an Object or null: "+e)}var o=Object,i=!(!o.create&&{__proto__:null}instanceof o),a=o.create||(i?function(e){return r(e),{__proto__:e}}:function(e){if(r(e),null===e)throw new SyntaxError("Native Object.create is required to create objects with null prototype");var t=function(){};return t.prototype=e,new t}),u=function(){return null},c=o.getPrototypeOf||([].__proto__===Array.prototype?function(e){var t=e.__proto__;return n(t)?t:null}:u);return e=function(s,l){if(void 0===(this&&this instanceof e?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(){};t=function(){s=null,f=function(e){throw new TypeError("Cannot perform '".concat(e,"' on a proxy that has been revoked"))}},setTimeout(function(){t=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,g=c(s),h=!1,m=!1;"function"==typeof s?(v=function(){var e=this&&this.constructor===v,t=Array.prototype.slice.call(arguments);return f(e?"construct":"apply"),e&&l.construct?l.construct.call(this,s,t):!e&&l.apply?l.apply(s,this,t):e?(t.unshift(s),new(s.bind.apply(s,t))):s.apply(this,t)},h=!0):s instanceof Array?(v=[],m=!0):v=i||null!==g?a(g):{};var y=l.get?function(e){return f("get"),l.get(this,e,v)}:function(e){return f("get"),this[e]},_=l.set?function(e,t){f("set"),l.set(this,e,t,v)}:function(e,t){f("set"),this[e]=t},A=o.getOwnPropertyNames(s),k={};A.forEach(function(e){if(!h&&!m||!(e in v)){var t={enumerable:!!o.getOwnPropertyDescriptor(s,e).enumerable,get:y.bind(s,e),set:_.bind(s,e)};o.defineProperty(v,e,t),k[e]=!0}});var S=!0;if(h||m){var b=o.setPrototypeOf||([].__proto__===Array.prototype?function(e,t){return r(t),e.__proto__=t,e}:u);g&&b(v,g)||(S=!1)}if(l.get||!S)for(var w in s)k[w]||o.defineProperty(v,w,{get:y.bind(s,w)});return o.seal(s),o.seal(v),v},e.revocable=function(n,r){return{proxy:new e(n,r),revoke:t}},e}),kt={};try{_t||(_t=At())}catch(U){Ot(U)}function St(e,t,n,r){try{if(!_t||null==e||!e[t])return;e[t]=new _t(e[t],{apply:function(e,t,o){var i,a;r&&Tt(function(){return r.apply(void 0,T(o))});var u=!!(null!=(i=o[0])&&i.success||null!=(a=o[0])&&a.fail);u&&["success","fail"].forEach(function(e){if(o[0][e])try{o[0][e]=new _t(o[0][e],{apply:function(t,r,i){return Tt(function(){return n.apply(void 0,[e,o[0]].concat(T(i)))}),t.apply(r,i)}})}catch(e){Ot(e)}});var c=e.apply(t,o);return!u&&c&&"[object Promise]"===Object.prototype.toString.call(c)?c.then(function(e){return Tt(function(){return n("success",o[0],e)}),e}).catch(function(e){throw Tt(function(){return n("fail",o[0],e)}),e}):c}})}catch(e){Ot(e)}}function bt(e,t,n){try{if(!_t||null==e||!e[t])return;e[t]=new _t(e[t],{apply:function(e,t,r){var o="function"==typeof r[0];if(o)try{r[0]=new _t(r[0],{apply:function(e,t,r){var o=e.call.apply(e,[t].concat(T(r)));return Tt(function(){return n(o)}),o}})}catch(e){Ot(e)}var i=e.call.apply(e,[t].concat(T(r)));return o||Tt(function(){return n(i)}),i}})}catch(e){Ot(e)}}function wt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4?arguments[4]:void 0;try{if(!_t||null==e||!e[t])return;e[t]=new _t(e[t],{apply:function(e,i,a){var u=e.call.apply(e,[i].concat(T(a)));return(!n||!kt[t])&&(Tt(function(){return null==o?void 0:o(u)}),r.forEach(function(e){var t=e.eventName,n=e.isAsync,r=e.proxyEvent;n?St(u,t,r):bt(u,t,r)})),n&&(kt[t]=!0),u}})}catch(e){Ot(e)}}function Tt(e){try{e()}catch(e){Ot(e)}}function Ot(e){pe({log_type:X,message:null==e?void 0:e.message,err_stack:null==e?void 0:e.stack})}var Rt=et,Et=ut,It=tt,xt=nt,Ct=rt,Nt=ot,Pt=at,Lt=it,Mt=function(){var e=!1;return function(){e||(e=!0,St(wx,"login",function(e){"success"===e&&Ye.publish(Rt)}),bt(wx,"onAddToFavorites",function(){Ye.publish(Et)}),bt(wx,"onShareTimeline",function(){Ye.publish(It,{target:"TIME_LINE",trigger:"MENU"})}),bt(wx,"onShareAppMessage",function(){Ye.publish(It,{target:"APP_MESSAGE",trigger:"MENU"})}),bt(wx,"shareAppMessage",function(){Ye.publish(It,{target:"APP_MESSAGE",trigger:"BUTTON"})}),wt(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){Ye.publish(xt)}}],function(){Ye.publish(Ct)}),wt(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(e){"success"===e&&Ye.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(e){"success"===e&&Ye.publish(Nt)}}]),St(wx,"requestMidasPayment",function(e,t){Ye.publish(Lt,{status:"success"===e?"SUCCESS":"FAIL",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"})},function(e){Ye.publish(Pt,{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"})}),St(wx,"requestMidasPaymentGameItem",function(e,t){var n=(t||{}).signData;Ye.publish(Lt,{status:"success"===e?"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(e){var t=(e||{}).signData;Ye.publish(Pt,{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)||"",p:(null==t?void 0:t.goodsPrice)||0,productId:(null==t?void 0:t.productId)||"",payType:"MidasGameItem"})}))}}(),Dt=function(){function e(){M(this,e)}return j(e,null,[{key:"isEmpty",value:function(e){return null==e||"string"==typeof e&&""===e.trim()}},{key:"format",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.replace(/\${(\d+)}/g,function(e,t){return n[t]})}},{key:"customStringify",value:function(e){var t=[];try{return JSON.stringify(e,function(e,n){if(void 0===n)return"undefined";if("object"==L(n)&&null!==n){if(-1!==t.indexOf(n))return"[Circular]";t.push(n)}return"bigint"==typeof n?n.toString():n})}catch(e){return"[Param Error]"}}}]),e}(),jt=/^([a-zA-Z][a-zA-Z\d_]{0,63})$/i,qt=/^ams_reserved_(.*)/i,Ut=function(){function e(){M(this,e)}return j(e,null,[{key:"validateActionType",value:function(t){return Dt.isEmpty(t)?(Me.error(e.ERROR_ACTION_TYPE_NULL),!1):!!jt.test(t)||(Me.error(e.ERROR_ACTION_TYPE_INVALID),!1)}},{key:"validateActionParam",value:function(t){if(!t)return!0;if(!Ae(t))return Me.error(e.ERROR_ACTION_PARAM_IS_NOT_OBJECT),!1;for(var n in t){if(Dt.isEmpty(n))return Me.error(e.ERROR_ACTION_PARAM_KEY_NULL),!1;if(!jt.test(n))return Me.error(e.ERROR_ACTION_PARAM_KEY_INVALID),!1;qt.test(n)&&Me.warn(e.WARN_ACTION_PARAM_KEY_RESERVED);var r=t[n];if(!e.isValidValue(r))return Me.error(Dt.format(e.ERROR_ACTION_PARAM_VALUE_INVALID,n,r)),!1;if(ke(r)){if(!e.isValidArrayValue(r)){for(var o=0;o<r.length;o++)Me.error(Dt.format(e.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID,n,Dt.customStringify(r),o,r[o]));return!1}if(!e.checkArrayElementTypes(r))return Me.error(e.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE),!1}}return!0}},{key:"isValidValue",value:function(e){return null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||ke(e)}},{key:"isValidArrayValue",value:function(e){for(var t=0;t<e.length;t++){var n=e[t];if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return!1}return!0}},{key:"checkArrayElementTypes",value:function(e){if(!e||e.length<=1)return!0;for(var t=L(e[0]),n=1;n<e.length;n++)if(L(e[n])!==t)return!1;return!0}}]),e}(),Ft=Ut;Ft.ERROR_ACTION_TYPE_NULL="在track方法中,action_type参数不能为空!",Ft.ERROR_ACTION_TYPE_INVALID="在track方法中,action_type参数只能包含字母、数字和下划线,且只能以字母开头,长度不能超过64个字符!",Ft.ERROR_ACTION_PARAM_KEY_NULL="在track方法中,action_param参数的key不能为空!",Ft.ERROR_ACTION_PARAM_KEY_INVALID="在track方法中,action_param参数的key只能包含字母、数字和下划线,且不能以数字开头,长度不能超过64个字符!",Ft.WARN_ACTION_PARAM_KEY_RESERVED="SDK内部预留参数的key均以'ams_reserved_'开头,该参数的值会被SDK内部覆盖,请不要使用!",Ft.ERROR_ACTION_PARAM_VALUE_INVALID="在track方法中,action_param参数的value必须是String/Number/Boolean/Array中的一种![key=${0}, value=${1}]",Ft.ERROR_ACTION_PARAM_VALUE_ARRAY_INVALID="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中的每个元素必须是String/Number/Boolean中的一种![key=${0}, value=${1}, 数组的第${2}个元素为${3}]",Ft.ERROR_ACTION_PARAM_VALUE_ARRAY_TYPE_UNUNIQUE="在track方法中,如果action_param参数中的某个元素的value是Array,那么这个Array中所有元素的类型必须是同一种!",Ft.ERROR_ACTION_PARAM_IS_NOT_OBJECT="action_param 参数不是Object";var Bt={exports:{}};!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,o,i,a){return n(function(e,t){return e<<t|e>>>32-t}(n(n(t,e),n(o,a)),i),r)}function o(e,t,n,o,i,a,u){return r(t&n|~t&o,e,t,i,a,u)}function i(e,t,n,o,i,a,u){return r(t&o|n&~o,e,t,i,a,u)}function a(e,t,n,o,i,a,u){return r(t^n^o,e,t,i,a,u)}function u(e,t,n,o,i,a,u){return r(n^(t|~o),e,t,i,a,u)}function c(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var r,c,s,l,f,d=1732584193,p=-271733879,v=-1732584194,g=271733878;for(r=0;r<e.length;r+=16)c=d,s=p,l=v,f=g,d=o(d,p,v,g,e[r],7,-680876936),g=o(g,d,p,v,e[r+1],12,-389564586),v=o(v,g,d,p,e[r+2],17,606105819),p=o(p,v,g,d,e[r+3],22,-1044525330),d=o(d,p,v,g,e[r+4],7,-176418897),g=o(g,d,p,v,e[r+5],12,1200080426),v=o(v,g,d,p,e[r+6],17,-1473231341),p=o(p,v,g,d,e[r+7],22,-45705983),d=o(d,p,v,g,e[r+8],7,1770035416),g=o(g,d,p,v,e[r+9],12,-1958414417),v=o(v,g,d,p,e[r+10],17,-42063),p=o(p,v,g,d,e[r+11],22,-1990404162),d=o(d,p,v,g,e[r+12],7,1804603682),g=o(g,d,p,v,e[r+13],12,-40341101),v=o(v,g,d,p,e[r+14],17,-1502002290),d=i(d,p=o(p,v,g,d,e[r+15],22,1236535329),v,g,e[r+1],5,-165796510),g=i(g,d,p,v,e[r+6],9,-1069501632),v=i(v,g,d,p,e[r+11],14,643717713),p=i(p,v,g,d,e[r],20,-373897302),d=i(d,p,v,g,e[r+5],5,-701558691),g=i(g,d,p,v,e[r+10],9,38016083),v=i(v,g,d,p,e[r+15],14,-660478335),p=i(p,v,g,d,e[r+4],20,-405537848),d=i(d,p,v,g,e[r+9],5,568446438),g=i(g,d,p,v,e[r+14],9,-1019803690),v=i(v,g,d,p,e[r+3],14,-187363961),p=i(p,v,g,d,e[r+8],20,1163531501),d=i(d,p,v,g,e[r+13],5,-1444681467),g=i(g,d,p,v,e[r+2],9,-51403784),v=i(v,g,d,p,e[r+7],14,1735328473),d=a(d,p=i(p,v,g,d,e[r+12],20,-1926607734),v,g,e[r+5],4,-378558),g=a(g,d,p,v,e[r+8],11,-2022574463),v=a(v,g,d,p,e[r+11],16,1839030562),p=a(p,v,g,d,e[r+14],23,-35309556),d=a(d,p,v,g,e[r+1],4,-1530992060),g=a(g,d,p,v,e[r+4],11,1272893353),v=a(v,g,d,p,e[r+7],16,-155497632),p=a(p,v,g,d,e[r+10],23,-1094730640),d=a(d,p,v,g,e[r+13],4,681279174),g=a(g,d,p,v,e[r],11,-358537222),v=a(v,g,d,p,e[r+3],16,-722521979),p=a(p,v,g,d,e[r+6],23,76029189),d=a(d,p,v,g,e[r+9],4,-640364487),g=a(g,d,p,v,e[r+12],11,-421815835),v=a(v,g,d,p,e[r+15],16,530742520),d=u(d,p=a(p,v,g,d,e[r+2],23,-995338651),v,g,e[r],6,-198630844),g=u(g,d,p,v,e[r+7],10,1126891415),v=u(v,g,d,p,e[r+14],15,-1416354905),p=u(p,v,g,d,e[r+5],21,-57434055),d=u(d,p,v,g,e[r+12],6,1700485571),g=u(g,d,p,v,e[r+3],10,-1894986606),v=u(v,g,d,p,e[r+10],15,-1051523),p=u(p,v,g,d,e[r+1],21,-2054922799),d=u(d,p,v,g,e[r+8],6,1873313359),g=u(g,d,p,v,e[r+15],10,-30611744),v=u(v,g,d,p,e[r+6],15,-1560198380),p=u(p,v,g,d,e[r+13],21,1309151649),d=u(d,p,v,g,e[r+4],6,-145523070),g=u(g,d,p,v,e[r+11],10,-1120210379),v=u(v,g,d,p,e[r+2],15,718787259),p=u(p,v,g,d,e[r+9],21,-343485551),d=n(d,c),p=n(p,s),v=n(v,l),g=n(g,f);return[d,p,v,g]}function s(e){var t,n="",r=32*e.length;for(t=0;t<r;t+=8)n+=String.fromCharCode(e[t>>5]>>>t%32&255);return n}function l(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t<n.length;t+=1)n[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)n[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return n}function f(e){var t,n,r="0123456789abcdef",o="";for(n=0;n<e.length;n+=1)t=e.charCodeAt(n),o+=r.charAt(t>>>4&15)+r.charAt(15&t);return o}function d(e){return unescape(encodeURIComponent(e))}function p(e){return function(e){return s(c(l(e),8*e.length))}(d(e))}function v(e,t){return function(e,t){var n,r,o=l(e),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=c(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],a[n]=1549556828^o[n];return r=c(i.concat(l(t)),512+8*t.length),s(c(a.concat(r),640))}(d(e),d(t))}function g(e,t,n){return t?n?v(t,e):function(e,t){return f(v(e,t))}(t,e):n?p(e):function(e){return f(p(e))}(e)}e.exports?e.exports=g:t.md5=g}(mt)}(Bt);var Vt=yt(Bt.exports),Kt="function"==typeof btoa,Gt="function"==typeof Buffer;"function"==typeof TextDecoder&&new TextDecoder;var Jt,Wt="function"==typeof TextEncoder?new TextEncoder:void 0,Ht=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");Jt={},Ht.forEach(function(e,t){return Jt[e]=t});var Yt=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);var Qt=Kt?function(e){return btoa(e)}:Gt?function(e){return Buffer.from(e,"binary").toString("base64")}:function(e){for(var t,n,r,o,i="",a=e.length%3,u=0;u<e.length;){if((n=e.charCodeAt(u++))>255||(r=e.charCodeAt(u++))>255||(o=e.charCodeAt(u++))>255)throw new TypeError("invalid character found");i+=Ht[(t=n<<16|r<<8|o)>>18&63]+Ht[t>>12&63]+Ht[t>>6&63]+Ht[63&t]}return a?i.slice(0,a-3)+"===".substring(a):i},zt=Gt?function(e){return Buffer.from(e).toString("base64")}:function(e){for(var t=[],n=0,r=e.length;n<r;n+=4096)t.push(Yt.apply(null,e.subarray(n,n+4096)));return Qt(t.join(""))},$t=function(e){if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?Yt(192|t>>>6)+Yt(128|63&t):Yt(224|t>>>12&15)+Yt(128|t>>>6&63)+Yt(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return Yt(240|t>>>18&7)+Yt(128|t>>>12&63)+Yt(128|t>>>6&63)+Yt(128|63&t)},Zt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Xt=Gt?function(e){return Buffer.from(e,"utf8").toString("base64")}:Wt?function(e){return zt(Wt.encode(e))}:function(e){return Qt(function(e){return e.replace(Zt,$t)}(e))},en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=function(e,t,n,r){for(var o,i=r>1?void 0:r?tn(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&en(t,n,i),i},rn=function(){function e(t){var n=this;M(this,e),this.cgiBatchSize=Y.cgiBatchSize,this.reportThreshold=Y.reportThreshold,this.reportDelay=Y.reportDelay,this.triggerExecuteSend=function(e){var t,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(t),t=setTimeout(function(){var t=e.apply(void 0,i);r.forEach(function(e){return e(t)}),r=[]},n),new Promise(function(e){return r.push(e)})}}(function(){n.executeSend()},1e3*this.reportDelay),this.inspectDelay=Y.inspectDelay,this.inspectTimer=void 0,this.isNeedContinueSend=!1,this.getBaseInfo=t.getBaseInfo,this.reportLog=t.reportLog,this.queueManager=t.queueManager,this.configManager=t.configManager,this.onReportComplete=t.onReportComplete,this.onReportFail=t.onReportFail,this.flushSend(),this.startInspectTimer()}return j(e,[{key:"batchSend",value:function(){var e,t=this.queueManager.getReportableActions(this.reportThreshold);if(t.length>=this.reportThreshold)this.executeSend();else{var n=(null==(e=this.configManager)?void 0:e.getRealTimeActionList())||Y.realTimeActionList;t.some(function(e){return n.indexOf(e.action_type)>-1&&!e.is_retry})?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){var t=this;if(e.currentRequestCount>=e.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;var n=(e.requestConcurrency-e.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),o=this.getBaseInfo();if(!o.openid&&!o.unionid&&(Me.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter(function(e){return null==e?void 0:e.ad_trace_id})),!(r.length<=0)){n<this.queueManager.getReportableActionsLength()&&(this.isNeedContinueSend=!0),e.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(e){var n=e.some(function(e){return e>=0});t.isNeedContinueSend&&n&&t.executeSend()}).catch(function(e){Me.error(e),t.reportLog({message:"executeSend catch: ".concat(e.message),log_type:Q,err_stack:e.stack})})}}}},{key:"generateActionReportParams",value:function(e){var t=[],n=[],r=this.getBaseInfo();return e.forEach(function(e){n.push(e.action_id);var r=Object.assign({},e);delete r.inner_status,t.push(r)}),{data:{info:r,actions:t},actionIdList:n}}},{key:"dealSuccessData",value:function(e,t,n){[51001,51003].indexOf(null==e?void 0:e.code)>-1?this.queueManager.updateActionsForReportFail(t):this.queueManager.removeActions(t),0!==(null==e?void 0:e.code)&&(this.reportLog({log_type:z,code:null==e?void 0:e.code,message:"trace_id: ".concat(null==e?void 0:e.trace_id,",msg: ").concat(null==e?void 0:e.message)}),Me.error("上报失败:",e)),this.doTrackCallbackFn(this.onReportComplete,e,n),-1===[0,51001,51003].indexOf(null==e?void 0:e.code)&&this.doTrackCallbackFn(this.onReportFail,e,n)}},{key:"dealFailData",value:function(e,t,n){this.queueManager.updateActionsForReportFail(t),this.reportLog({log_type:z,code:e.code,message:e.message}),Me.error("上报失败:",e),this.doTrackCallbackFn(this.onReportComplete,e,n)}},{key:"report",value:function(t){var n=this,r=t.data,o=t.actionIdList;return this.queueManager.updateActionsForReporting(o),Me.debug&&(Me.info("上报行为类型: ","【".concat(r.actions.map(function(e){return e.action_type}).join("、"),"】")),Me.info("上报请求参数: ",r)),new Promise(function(t){var i,a,u,c,s,l,f,d,p=Date.now();try{var v=function(e){var t="",n=null==e?void 0:e.appid,r=null==e?void 0:e.secret_key,o=null==e?void 0:e.sdk_version,i=null==e?void 0:e.timestamp;if(!(n&&r&&o&&i&&32===r.length))return t;for(var a=Vt(o+n+i),u=0;u<32;u++)t+=u%2==0?r[u]:a[u];return t}({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:p}),g=function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?function(e){return e.replace(/=/g,"").replace(/[+\/]/g,function(e){return"+"==e?"-":"_"})}(Xt(e)):Xt(e)}(JSON.stringify(r));f={"Client-Time":p,"Sign-Value":Vt(g+(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)+v),"Sign-Version":Y.signVersion,"content-type":"text/plain;charset=UTF-8"},d=g}catch(v){f={"Client-Time":p},d=r,n.reportLog({log_type:te,message:"sign error msg: ".concat(null==v?void 0:v.message),err_stack:null==v?void 0:v.stack}),Me.error(v)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(l=n.configManager)?void 0:l.getRequestTimeout())||Y.requestTimeout,header:f,data:d,success:function(i){var a,u;Me.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(ve.revise(c),e.currentRequestCount-=1,200===(null==i?void 0:i.statusCode))return n.dealSuccessData(null==i?void 0:i.data,o,r),void t((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(e){Me.error(e)}var l={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(l,o,r),t(l.code)},fail:function(i){Me.devLog("上报失败:",i),e.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),t(a.code)}})})}},{key:"startInspectTimer",value:function(){var t=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout(function(){e.currentRequestCount>=e.requestConcurrency&&(e.currentRequestCount=e.requestConcurrency-1),t.executeSend(),t.startInspectTimer()},1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(e,t,n){if("function"==typeof e)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,g=l.user_unique_id;e({code:null==t?void 0:t.code,message:null==t?void 0:t.message,data:{actions:r,info:{user_action_set_id:f,appid:d,openid:p,unionid:v,user_unique_id:g}}})}}catch(r){Me.error("返回上报回调数据异常:",r)}}}],[{key:"setRequestConcurrency",value:function(t){"number"==typeof t?t<1?Me.error("网络请求最大并发量不能小于1"):t>10?Me.error("网络请求最大并发量不能大于10"):e.requestConcurrency=t:Me.error("网络请求最大并发量需设置为数字")}}]),e}(),on=rn;on.currentRequestCount=0,on.requestConcurrency=Y.requestConcurrency,nn([je],on.prototype,"batchSend",1),nn([je],on.prototype,"flushSend",1),nn([je],on.prototype,"executeSend",1);var an=ze,un=$e,cn=Ze,sn=Xe,ln=et,fn=ut,dn=tt,pn=nt,vn=rt,gn=ot,hn=at,mn=it,yn=function(){function e(){M(this,e)}return j(e,[{key:"install",value:function(e,t){var n=function(t){Ye.subscribe(t,function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.track(t,Object.assign(n||{},o,w(w({},Cn,!0),Nn,r)))}}(t))};n(un),n(an),n(cn),n(sn),"all"===t&&(n(ln),n(fn),n(dn),n(vn),n(pn),n("CREATE_GAME_ROOM"),n(gn),n(hn),n(mn))}}]),e}(),_n=function(){function e(){M(this,e),this.special_method_symbol=Symbol("special_method_symbol")}return j(e,[{key:"onPurchase",value:function(e){return"number"!=typeof e&&Me.warn("付费金额需要为数字"),e<=0&&Me.warn("付费金额需要大于0"),this.wrapTrack("PURCHASE",{value:e})}},{key:"onEnterForeground",value:function(){return this.wrapTrack("ENTER_FOREGROUND")}},{key:"onEnterBackground",value:function(){return this.wrapTrack("ENTER_BACKGROUND")}},{key:"onAppStart",value:function(){return this.wrapTrack("START_APP")}},{key:"onAppQuit",value:function(){return this.wrapTrack("APP_QUIT")}},{key:"onAddToWishlist",value:function(){return this.wrapTrack("ADD_TO_WISHLIST")}},{key:"wrapTrack",value:function(e,t){return this.track(e,Object.assign(t||{},w({},this.special_method_symbol,1)))}}]),e}(),An=function(){E(t,_n);var e=x(t);function t(){return M(this,t),e.apply(this,arguments)}return j(t,[{key:"onRegister",value:function(){return this.wrapTrack("REGISTER")}},{key:"onCreateRole",value:function(e){return e&&"string"!=typeof e&&Me.warn("角色名称需要为字符串"),this.wrapTrack("CREATE_ROLE",e?{name:e}:{})}},{key:"onTutorialFinish",value:function(){return this.wrapTrack("TUTORIAL_FINISH")}}]),t}(),kn="(如果确认无误,请忽略该提示)",Sn=function(){var e=[];return{requestActionList:function(){try{ge({conf_name:"data_nexus_common",conf_key:"action_types"}).then(function(t){ke(t)&&(e=t)})}catch(e){Me.error(e)}},getActionList:function(){return e}}}();function bn(e,t){try{e.is_sdk_auto_track||(function(e){try{var t=Sn.getActionList();if(!t.includes(e)){var n,r=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=O(e))){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}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 o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(t);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(wn(o,e)<=parseInt((.3*o.length).toString())){Me.warn("通过SDK上报的".concat(e,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(kn));break}}}catch(e){r.e(e)}finally{r.f()}}}catch(t){Me.error(t)}}(e.action_type),"minigame"===t?function(e,t){var n,r,o;try{["PURCHASE","ADD_TO_CART"].includes(e.action_type)&&e.action_param&&Ne(e.action_param,"value")&&("number"!=typeof(null==(n=e.action_param)?void 0:n.value)?Me.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要为数字!")):(null==(r=e.action_param)?void 0:r.value)<=0?Me.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数需要大于0!")):"minigame"===t&&(null==(o=e.action_param)?void 0:o.value)<100&&Me.warn("通过SDK上报的".concat(e.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(kn)))}catch(e){Me.error(e)}}(e,t):"miniprogram"===t&&function(e){try{var t=null==e?void 0:e.action_type,n=(null==e?void 0:e.action_param)||{};"PURCHASE"===t&&Ne(n,"value")&&("number"!=typeof(null==n?void 0:n.value)?Me.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要为数字!")):(null==n?void 0:n.value)<=0&&Me.warn("通过SDK上报的".concat(t,"行为携带的金额参数需要大于0!")))}catch(t){Me.error(t)}}(e))}catch(e){Me.error(e)}}function wn(e,t){try{if(0===e.length)return t.length;if(0===t.length)return e.length;for(var n=[],r=0;r<=t.length;r++)n[r]=[r];for(var o=0;o<=e.length;o++)n[0][o]=o;for(var i=1;i<=t.length;i++)for(var a=1;a<=e.length;a++)t.charAt(i-1)===e.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[t.length][e.length]}catch(n){Me.error(n)}}function Tn(e){try{e&&!/^[a-zA-Z0-9_\-]+$/.test(e)&&Me.warn("通过SDK上报的openid:".concat(e,"可能有误,请检查openid是否正确!").concat(kn))}catch(e){Me.error(e)}}var On,Rn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,In=function(e,t,n,r){for(var o,i=r>1?void 0:r?En(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Rn(t,n,i),i},xn=Symbol("initializedInstance"),Cn=Symbol("autoTrack"),Nn=Symbol("actionTime"),Pn=function(){E(t,An);var e=x(t);function t(n){var r;if(M(this,t),(r=e.call(this)).env="production",r.sdk_version="1.5.5",r.sdk_name="@dn-sdk/minigame",r.deviceInfo={},r.gameInfo={},r.session_id="",r.log_id=0,r.inited=!1,r.initErrMsg="",null==wx||!wx.createCanvas)return r.initErrMsg="不支持非微信小游戏中使用",Me.error(r.initErrMsg),C(r);var o=Ce();if(t[xn].length>=o.maxSdkInstance)return r.initErrMsg="初始化超过上限",Me.error(r.initErrMsg),C(r);var i=function(e){return Ae(e)?(function(e){var t=["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 e)t.includes(n)||Me.warn("Invalid property '".concat(n,"' found in config"))}(e),"number"!=typeof e.user_action_set_id?"user_action_set_id 参数需为 number 类型":e.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeof e.secret_key?"secret_key 参数需为 string 类型":""===e.secret_key.trim()?"缺少 secret_key 参数":32!==e.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeof e.appid?"appid 参数需为 string 类型":""!==e.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"}(n),a=fe();if(!0!==i)return r.initErrMsg=i,Me.error(i),C(r);var u=null==a?void 0:a.appId;if(u&&u!==n.appid)return r.initErrMsg="初始化传入的appid与当前小游戏appid不一致",Me.error(r.initErrMsg),C(r);r.config=n,Ne(n,"auto_track")||(r.config.auto_track=xe("autoTrack")),r.openid=n.openid,r.unionid=n.unionid,r.user_unique_id=n.user_unique_id,r.onReportComplete=n.on_report_complete,r.onReportFail=n.on_report_fail,r.saveValidOpenidToStorage();var c=n.user_action_set_id;return t[xn].includes(c)?(r.initErrMsg="同个数据源[".concat(c,"]只能初始化一次"),Me.error(r.initErrMsg),r.reportLog({log_type:Q,message:r.initErrMsg}),C(r)):(r.reportLog=r.reportLog.bind(N(r)),r.getTrackBaseInfo=r.getTrackBaseInfo.bind(N(r)),r.deviceInfo=ue(),r.gameInfo=De(),r.session_id=we(),r.queueManage=new Je({userActionSetId:c,maxLength:o.maxQueueLength,ogEvents:Qe}),r.actionReporter=new on({getBaseInfo:r.getTrackBaseInfo,reportLog:r.reportLog,queueManager:r.queueManage,configManager:ft,onReportComplete:r.onReportComplete,onReportFail:r.onReportFail}),r.inited=!0,t[xn].push(c),r.useAutoTrack(),r.doReportOnEnterBackground(),"release"===(null==a?void 0:a.envVersion)?(Me.info("初始化成功"),C(r)):(function(e){var t=e.sdk_version,n=e.default_download_url,r=e.fail_handler;ge({conf_name:e.conf_name,conf_key:e.conf_key}).then(function(e){if(Ae(e)){var o=null==e?void 0:e.blackVersions,i=null==e?void 0:e.minVersion,a=null==e?void 0:e.bestVersion,u=null==e?void 0:e.downloadUrl,c=n;return u&&/^https/.test(u)&&(c=u),ke(o)&&(null==o?void 0:o.indexOf(t))>-1?(null==r||r(),void Me.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):i&&Ie(t,i)<0?(null==r||r(),void Me.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&Ie(t,a)<0&&Me.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),void Me.info("初始化成功"))}Me.info("初始化成功")}).catch(function(){Me.info("初始化成功")})}({conf_name:"mini_game_sdk_common",conf_key:"version",sdk_version:r.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(){r.inited=!1}}),Sn.requestActionList(),Tn(n.openid),C(r)))}return j(t,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(e,t){var n,r;if(!this.inited||!this.queueManage)return Me.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};var o=Ft.validateActionType(e),i=Ft.validateActionParam(t);if(o&&i){!this.openid&&!this.unionid&&Me.warn("缺少 openid 或 unionid");var a=xe("actionParamMaxLength");if(JSON.stringify(t||{}).length>a)return Me.error("监测到超过".concat(a,"的上报日志:").concat(e," ").concat(t)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};var u=!(null==t||!t[Cn]),c=this.createAction(e,t||{},u);"release"!==(null==(n=fe())?void 0:n.envVersion)&&bn(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 e;null==(e=this.actionReporter)||e.flushSend()}},{key:"setOpenId",value:function(e){var t;if(e&&"string"==typeof e)return this.openid=e,this.gameInfo.ad_trace_id&&!ae.getSync(W)&&Ye.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(t=fe())?void 0:t.envVersion)&&Tn(e),{code:0,message:"成功"};var n="openid 格式错误";return Me.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(e){if(e&&"string"==typeof e)return this.unionid=e,this.flush(),{code:0,message:"成功"};var t="unionid 格式错误";return Me.error(t),{code:101,message:t}}},{key:"setUserUniqueId",value:function(e){if(e&&"string"==typeof e)return this.user_unique_id=e,{code:0,message:"成功"};var t="user_unique_id 格式错误";return Me.error(t),{code:101,message:t}}},{key:"doReportOnEnterBackground",value:function(){var e=this;wx.onHide(function(){var t,n;null==(t=e.actionReporter)||t.flushSend(),null==(n=e.queueManage)||n.reportLostNum()})}},{key:"getTrackBaseInfo",value:function(){var e=fe();return Object.assign({},this.deviceInfo,function(e){var t={};return["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"].forEach(function(n){Ne(e,n)&&(t[n]=e[n])}),t}(this.config),{local_id:ce(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||le(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:e.envVersion,app_version:e.version}})}},{key:"createAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];null!=t&&t[Cn]&&delete t[Cn];var r=Date.now();null!=t&&t[Nn]&&(r=null==t?void 0:t[Nn],delete t[Nn]);var o={action_id:we(),action_param:t,action_time:r,action_type:e,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:ve.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:se(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(e)};return null!=t&&t[this.special_method_symbol]&&(this.addActionInnerParam(o,"is_special_method",!0),delete t[this.special_method_symbol]),ft.getChannelClaimActionList().indexOf(e)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(o,"launch_options",this.gameInfo.launch_options),o}},{key:"addActionInnerParam",value:function(e,t,n){e.inner_param&&Ae(e.inner_param)?e.inner_param[t]=n:e.inner_param=w({},t,n)}},{key:"getChannelByActionType",value:function(e){var t="";return ft.getChannelClaimActionList().indexOf(e)>-1?t=this.gameInfo.channel||"":ft.getNoClaimActionList().indexOf(e)>-1&&(t="UNKNOWN"),t}},{key:"reportLog",value:function(e){var t,n,r={user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,appid:null==(n=this.config)?void 0:n.appid,session_id:this.session_id};pe(Object.assign(r,e))}},{key:"useAutoTrack",value:function(){var e;if(null!=(e=this.config)&&e.auto_track){var t=!0,n=ae.getSync(G);(null==n?void 0:n.ap)===re?t=!0:(null==n?void 0:n.ap)===oe&&(t=!1),"devtools"===ue().wx_platform&&(t=!0),(new yn).install(this,t?"all":"lifecycle"),ht(),t&&Mt(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){var e,t,n=ue();n.os&&n.os_version&&null!=(e=this.config)&&e.user_action_set_id&&function(e){return new Promise(function(t){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:e,timeout:Y.requestTimeout,success:function(e){he(e,t,"minigame/get"),ye(e)},fail:function(e){me(e,"minigame/get")}})})}({conf_name:"MG",conf_param:{user_action_set_id:null==(t=this.config)?void 0:t.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void 0:n.os)||"",os_version:Pe(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(e){Ae(e)&&ae.setSync(G,e)})}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(e){return/^[a-zA-Z0-9_-]{28,30}$/.test(e)}(this.openid)&&ae.setSync(W,this.openid)}}],[{key:"setRequestConcurrency",value:function(e){on.setRequestConcurrency(e)}},{key:"setDebug",value:function(e){Me.debug=e}}]),t}(),Ln=Pn;Ln[xn]=[],In([je],Ln.prototype,"track",1),In([je,function(e,t,n){var r=n.value;return n.value=function(){if(this.inited){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(this,t)}Me.error("上报失败,请先完成初始化")},n}],Ln.prototype,"flush",1),In([je],Ln.prototype,"setOpenId",1),In([je],Ln.prototype,"setUnionId",1),In([je],Ln.prototype,"setUserUniqueId",1),In([je],Ln.prototype,"doReportOnEnterBackground",1),In([je],Ln.prototype,"getTrackBaseInfo",1),In([je],Ln.prototype,"useAutoTrack",1);var Mn=0,Dn={moid:""},jn=!1,qn=JSON.stringify(wx.getLaunchOptionsSync()||""),Un={token:"",uid:"",uname:"",openid:""},Fn={partner_id:"",game_id:"",pkg_name:"",version:""},Bn={doid:"",dsid:"",dsname:"",dext:"",drid:"",drname:"",drlevel:"",dmoney:"",money:""},Vn="wx-adapter sdk >>>>>>>:";wx.hideShareMenu(),wx.onShow(function(e){e.query&&(qn=JSON.stringify(e))});var Kn=function(e){var t=r(r({},k()),_),n=p(r(r(r(r(r({},Bn),Un),Fn),t),{},{launchoption:qn,onshow:qn}));m(h,"/wxgamemds/index/",n).then(function(t){t.state&&(t.data.balance>=e?Jn(""):Gn(t.data,e))}).catch(function(e){console.log(e)})},Gn=function(e,t){wx.requestMidasPayment({mode:"game",env:e.env,offerId:e.offerId,currencyType:e.currencyType,platform:e.platform,buyQuantity:e.buyQuantity,outTradeNo:Dn.moid,success:function(e){On&&On.onPurchase(100*t),Jn(e)},fail:function(e){console.log(e)}})},Jn=function(e){var t;Mn++;var n=r(r({},k()),_);t=p(e?r(r(r(r(r(r({},Bn),Fn),Un),n),Dn),{},{res:JSON.stringify(e),launchoption:qn,onshow:qn}):r(r(r(r(r(r({},Bn),Fn),Un),Dn),n),{},{launchoption:qn,onshow:qn})),m(h,"/wxgamemds/send/",t).then(function(e){console.log(e)}).catch(function(t){console.log(t),Mn<3&&setTimeout(function(){Jn(e)},1e3)})},Wn=function(e){return new Promise(function(t,n){var o=Un||{},i=o.token,a=o.uid,c=o.uname;if(!(jn&&i&&a&&c))return u("未激活或未登录,请重新进入游戏"),n({state:100001,msg:"未激活或未登录,请检查"});var s=p(r(r(r(r(r({},e),Un),Fn),r(r({},k()),_)),{},{launchoption:qn,onshow:qn}));m(h,"/wxgameevent/index/",s).then(function(){t(),On&&("create"===s.event&&On.onCreateRole(s.drname),"levelup"===s.event&&On.track("UPDATE_LEVEL",{level:s.drlevel,power:0}))}).catch(function(e){console.log(e),n({state:100002,msg:"角色上报失败"})})})},Hn=null,Yn=!1,Qn=!1,zn=function(e){return new Promise(function(t,n){if(!jn)return n({state:100001,msg:"上报前请先激活"});if(!Array.isArray(e))return n({state:100002,msg:"入参需要数组,请检查"});if(!e.length)return n({state:100003,msg:"入参不能为数组空,请检查"});var r=e.map(function(e){return{package:c,partner_id:4,game_id:Fn.game_id,event_name:e.event_name,game_name:Fn.game_name,account_id:Un.uid||"",app_version:Fn.version,distinct_id:b().duid,event_params:e.event_params,event_time:(t=new Date,n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),u=String(t.getSeconds()).padStart(2,"0"),"".concat(n,"-").concat(r,"-").concat(o," ").concat(i,":").concat(a,":").concat(u))};var t,n,r,o,i,a,u});y(h,"/report/batch/event",{body:r}).then(function(){t({state:0,msg:"上报成功!"})}).catch(function(e){n({state:100004,msg:JSON.stringify(e)})})})};e.jf_SSEventReport=zn,e.jf_SSUserPropsReport=function(e){return new Promise(function(t,n){if(!jn)return n({state:100001,msg:"上报前请先激活"});if(!Array.isArray(e))return n({state:100002,msg:"入参需要数组,请检查"});if(!e.length)return n({state:100003,msg:"入参不能为数组空,请检查"});var r=e.map(function(e){return{partner_id:4,game_id:Fn.game_id,distinct_id:b().duid,account_id:Un.uid||"",game_name:Fn.game_name,event_params:e.event_params}});y(h,"/report/batch/attribute",{body:r}).then(function(){t({state:0,msg:"上报成功!"})}).catch(function(e){n({state:100004,msg:JSON.stringify(e)})})})},e.jf_active=function(e){return new Promise(function(t,n){if(!e)return n({state:100001,msg:"激活入参缺失"});if(null==e||!e.wx)return n({state:100002,msg:"激活入参 wx 属性缺失"});var r=e.wx,o=r.game_id,i=r.version,a=r.dn_sdk_id,u=r.dn_secret_key,s=r.game_name;if(!o)return n({state:100003,msg:"激活入参 game_id 属性缺失"});Fn.game_id=o,Fn.game_name=s,Fn.version=i,Fn.pkg_name=c,Fn.partner_id=4,jn=!0,console.log("active 激活成功!"),a&&u&&function(e){var t=e.dn_sdk_id,n=e.dn_secret_key,r=e.app_id,o=(On=new Ln({appid:r,secret_key:n,user_action_set_id:t})).getInitResult();null!=o&&o.inited||console.error("dnSdk init failed: ",o.initErrMsg),On.onAppStart(),wx.onAddToFavorites(function(e){console.log(Vn+"click onAddToFavorites"),On&&On.track("DD_TO_WISHLIST",{type:"default"})}),wx.onShareAppMessage(function(){console.log(Vn+"click onShareAppMessage"),On&&On.track("SHARE",{target:"APP_MESSAGE"})}),wx.onShareTimeline(function(){console.log(Vn+"click onShareTimeline"),On&&On.track("SHARE",{target:"TIME_LINE"})}),console.log(Vn+"广点通初始化成功!")}(wx),t(),zn([{event_name:"game_open",event_params:{}}])})},e.jf_createRewardedVideoAd=function(e){var t=function(){return new Promise(function(t,n){if(Yn)return t();Hn&&(Hn=null),(Hn=wx.createRewardedVideoAd({adUnitId:e})).onError(function(e){Yn=!1,Hn=null,n({state:100004,msg:"广告平台异常",originalErr:e})}),Hn.load().then(function(){console.log("激励视频广告预加载成功"),Yn=!0,t()}).catch(function(e){console.error("激励视频广告预加载失败:",e),Yn=!1,Hn=null,n(e)})})},n=function(){return Qn?Promise.reject({state:100004,msg:"广告正在展示中,请稍后再试"}):Yn?Hn?(Qn=!0,new Promise(function(e,t){Hn.onClose(function(t){console.log("激励视频广告关闭,是否看完:",t.isEnded),e({isEnded:t.isEnded}),Qn=!1,Hn.offClose()}),Hn.show().then(function(){console.log("激励视频广告展示成功")}).catch(function(e){Yn=!1,Qn=!1,t({state:100003,msg:JSON.stringify(e)})})})):Promise.reject({state:100002,msg:"广告实例不存在"}):t().then(n).catch(function(e){return Promise.reject({state:100001,msg:JSON.stringify(e)})})};return{preload:t,show:n}},e.jf_customerService=function(e){wx.openCustomerServiceConversation({success:function(){Wn(r(r({},g(e)),{},{event:"kfclick"}))}})},e.jf_getUserInfo=function(){return new Promise(function(e,t){wx.getSetting({success:function(n){n.authSetting["scope.userInfo"]?wx.getUserInfo({success:function(t){return e(t.userInfo)},fail:function(e){return t({state:100001,msg:JSON.stringify(e)})}}):wx.getUserProfile({desc:"获取用户信息",success:function(t){return e(t.userInfo)},fail:function(e){return t({state:100002,msg:JSON.stringify(e)})}})}})})},e.jf_login=function(){return new Promise(function(e,t){if(!jn)return t({state:100003,msg:"登录前请先激活"});wx.login({success:function(n){var o=p(r(r(r({code:n.code},Fn),b()),{},{launchoption:qn,onshow:qn}));m(h,"/wxgamelogin/initlogin/",o).then(function(n){if(1==n.state){var r=n.data,o=r.token,i=r.uid,a=r.uname,c=r.openid,s=r.show_page;if(Un.token=o,Un.uid=i,Un.uname=a,Un.openid=c,wx.setStorageSync("jfGamekitSSToken",o),e({token:o,uid:i,uname:a,partner_id:4,show_page:s}),console.log(Vn+"登录成功"),c&&On){var l=n||{},f=l.backFlowDay,d=l.isRegisterUser;!function(e){var t=e.openid,n=e.nsSdk,r=e.backFlowDay,o=e.isRegisterUser;n.setOpenId(t),o?n.onRegister():r&&r>=30&&n.track("RE_ACTIVE",{backFlowDay:30})}({openid:c,nsSdk:On,backFlowDay:f,isRegisterUser:d})}zn([{event_name:"account_login",event_params:{}}])}else u(n.msg),t({state:n.state,msg:n.msg})}).catch(function(e){u(e),t({state:100001,msg:e})})},fail:function(e){t({state:100002,msg:e})}})})},e.jf_pay=function(e){return new Promise(function(t,n){var o=Un||{},i=o.token,a=o.uid,c=o.uname;if(!(jn&&i&&a&&c))return u("失败!请先激活登录"),n({state:100001,msg:"未激活或未登录,请重新进入游戏"});wx.showLoading({title:"加载中"});var s=e.dmoney;(Bn=g(e)||{}).money=s;var l=p(r(r(r(r(r({},e),Fn),Un),r(r(r({},k()),S()),_)),{},{money:s,launchoption:qn,onshow:qn}));m(h,"/wxgameorder/index/",l).then(function(e){var r=e||{},o=r.state,i=r.msg,a=r.data,c=void 0===a?{}:a;if(1==o){var l=c.aid,f=c.moid,d=c.thumb_url;Dn.moid=f,1==l?(Kn(s),t({msg:"ok"})):2==l?wx.showModal({title:"支付提示",content:"即将打开充值入口,输入“充值”或点击右下角卡片即可充值。",showCancel:!1,confirmText:"点我充值",success:function(e){e.confirm?wx.openCustomerServiceConversation({sessionFrom:f,sendMessagePath:"/path/index/index?moid="+f,showMessageCard:!0,sendMessageImg:d,success:function(e){console.log("openCustomerServiceConversation success",e),t()},fail:function(e){console.error("openCustomerServiceConversation fail ",e),n({state:100003,msg:"支付失败"})},complete:function(e){console.log("openCustomerServiceConversation compelte: ",f),function(e){var t=b(),n=p({partner_id:Fn.partner_id,pkg_name:Fn.pkg_name,game_id:Fn.game_id,uid:Un.uid,openid:Un.openid,token:Un.token,uname:Un.uname,duid:t.duid,moid:e});m(h,"/wxgameorder/get/",n).then(function(e){1==e.data.status&&On.onPurchase(100*e.data.money)})}(f)}}):(u("用户取消支付"),n({state:100005,msg:"取消支付"}))},fail:function(){u("用户取消支付"),n({state:100006,msg:"支付失败"})}}):(u("失败!设备未识别"),n({state:100004,msg:"支付失败"}))}else u(i),n({state:o,msg:i});wx.hideLoading()}).catch(function(e){u(e),n({state:100002,msg:"支付失败"}),wx.hideLoading()})})},e.jf_profanityCheck=function(e){return new Promise(function(t,n){var o=p(r(r(r(r(r({},e),Fn),Un),b()),{},{launchoption:qn,onshow:qn,partner_id:4}));m(h,"/wxgamesafe/verify/",o).then(function(e){var r=e.data,o=r.code,i=r.msg;1==o?t():n({state:100001,msg:i})}).catch(function(e){n({state:100002,msg:e})})})},e.jf_share=function(e){wx.shareAppMessage(),Wn(r(r({},g(e)),{},{event:"fxclick"}))},e.jf_showInterstitialAd=function(e){return new Promise(function(t,n){var r=!1,o=wx.createInterstitialAd({adUnitId:e});o.onError(function(e){r=!0}),o.load().then(function(){if(!r)return o.show();n({state:100001,msg:"广告加载后发生错误"})}).then(t).catch(function(e){return n({state:100002,msg:JSON.stringify(e)})}),o.onClose(function(e){console.log("广告关闭:",e.isEnded?"正常播放完成":"用户提前关闭")})})},e.jf_trace=Wn,e.jf_tracePageView=function(e){return new Promise(function(t,n){On?(On.track("VIEW_CONTENT",{item:e}),t()):n({state:100001,msg:"上报失败!广点通 sdk 未初始化"})})},Object.defineProperty(e,"__esModule",{value:!0})});
|