var mtjwxsdk=function(e){"use strict";var o,t,g={logServerUrl:"https://hmma.baidu.com/mini.gif",maxRequestRetryCount:5,requestRetryFirstDelay:1e3,requestRetryMultiple:4,maxRequestDataLength:204800,maxUserPropertyCount:100,maxUserPropertyKeyValueLength:256,maxUint8:255,maxUint32:4294967295,enabledEvents:{app:["onShow","onHide","onError"],page:["onShow","onHide"]},storageKeys:{uuid:"mtj_uuid",userInfo:"mtj_user",userProperty:"mtj_user_property",shareCount:"mtj_scnt"}},p={type:1},h={aso:{}},r=function(){return"undefined"!=typeof crypto&&crypto.getRandomValues?crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*g.maxUint32)},a=function(e,t){return"[object "+t+"]"==={}.toString.call(e)},n=function n(r){return(a(r,"Object")||a(r,"Array"))&&Object.keys(r).forEach(function(e){var t=r[e];a(t,"Object")||a(t,"Array")?r[e]=n(t):r[e]=""+t}),r},u=function(e){return a(e,"String")&&/^\d{11}$/.test(e)},i=function(e){return a(e,"String")&&28===e.length},s=0,c=function(r){return new Promise(function(t,n){if(r.data=r.data||{},r.data.v="1.8.14",r.data.rqc=++s,e=r.data,!(JSON.stringify(e).length<=g.maxRequestDataLength))return s--,n(new Error("invalid data"));var e;r.success=function(e){return t(e)},r.fail=function(e){return n(e)},function t(n){var r=1>e/4).toString(16)}),m(g.storageKeys.uuid,e)),e})},v=function(){return t||(p.sid=r(),p.rqc=0,t=Promise.all([l(),new Promise(function(t){o.getSystemInfo({success:function(e){delete e.errMsg,t(e)},fail:function(){t({})}})}),new Promise(function(t){o.getNetworkType({success:function(e){delete e.errMsg,t(e)},fail:function(){t({})}})}),Promise.resolve().then(function(){var e=y(g.storageKeys.userInfo),n=a(e,"Object")?e:{};return new Promise(function(t){o.getSetting({success:function(e){e.authSetting&&e.authSetting["scope.userInfo"]?o.getUserInfo({success:function(e){delete e.userInfo.errMsg,t(Object.assign(n,e.userInfo))},fail:function(){t(n)}}):t(n)},fail:function(){t(n)}})})}),new Promise(function(t){if(!g.getLocation)return t({});o.getLocation({type:"wgs84",success:function(e){delete e.errMsg,t(e)},fail:function(){t({})}})}),Promise.resolve().then(function(){var e=y(g.storageKeys.userProperty);return a(e,"Object")?e:{}})]).then(function(e){p.uuid=e[0],h.system=n(e[1]),h.network=n(e[2]),0g.maxUserPropertyKeyValueLength||(""+t).length>g.maxUserPropertyKeyValueLength||!n[e]&&r>=g.maxUserPropertyCount||(n[e]||r++,n[e]=[t,"1"]))}),m(g.storageKeys.userProperty,n),h.userProperty=JSON.stringify(n)})}},O=App,I=Page,k=function(e,t,n){var r=t[e];t[e]=function(e){n.call(this,e),r&&r.call(this,e)}},w=function(t){g.enabledEvents.app.forEach(function(e){k(e,t,j[e])}),t.mtj=P,O(t)},U=function(a){g.enabledEvents.page.forEach(function(e){k(e,a,b[e])}),["onShareAppMessage"].forEach(function(e){var t,n,r,o;r=b[t=e],o=(n=a)[t],n[t]=function(e){var t=o&&o.call(this,e);return r.call(this,e,t)}}),I(a)},x=function(){var e,t;e=wx,o=e;try{t=require("./mtj-wx-sdk.config")}catch(e){return void console.error("请把mtj-wx-sdk.config.js文件拷贝到utils目录中")}t&&t.appKey?(p.key=t.appKey,g.getLocation=t.getLocation||!1,t.hasPlugin?module.exports={App:w,Page:U}:(App=w,Page=U)):console.error("请设置mtj-wx-sdk.config.js文件中的appKey字段")};return x(),e.init=x,e}({});