module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1704883497559, function(require, module, exports) {
/**
 *  ================================================================
 * aegis-mp-sdk@1.36.7 (c) 2023 TencentCloud Real User Monitoring.
 * Author pumpkincai.
 * Last Release Time Tue Feb 21 2023 18:54:30 GMT+0800 (中国标准时间).
 * Released under the MIT License.
 * Thanks for supporting RUM & Aegis!
 * ================================================================
 **/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Aegis=t()}(this,function(){var j=function(e,t){return(j=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}))(e,t)};function e(e,t){function n(){this.constructor=e}j(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var f=function(){return(f=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function H(i,o){var r,a,s,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(n){return function(e){var t=[n,e];if(r)throw new TypeError("Generator is already executing.");for(;l;)try{if(r=1,a&&(s=2&t[0]?a.return:t[0]?a.throw||((s=a.return)&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch(a=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return l.label++,{value:t[1],done:!1};case 5:l.label++,a=t[1],t=[0];continue;case 7:t=l.ops.pop(),l.trys.pop();continue;default:if(!((s=0<(s=l.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){l=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3]))l.label=t[1];else if(6===t[0]&&l.label<s[1])l.label=s[1],s=t;else{if(!(s&&l.label<s[2])){s[2]&&l.ops.pop(),l.trys.pop();continue}l.label=s[2],l.ops.push(t)}}t=o.call(i,l)}catch(e){t=[6,e],a=0}finally{r=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function a(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var i=Array(e),o=0,t=0;t<n;t++)for(var r=arguments[t],a=0,s=r.length;a<s;a++,o++)i[o]=r[a];return i}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++)if(null!=(i=arguments[n]))for(var i=Object(i),o=Object.keys(Object(i)),r=0,a=o.length;r<a;r++){var s=o[r],l=Object.getOwnPropertyDescriptor(i,s);null!=l&&l.enumerable&&(t[s]=i[s])}return t}});var I=["ext1","ext2","ext3","level","trace","tag","seq","code"],D=(t.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},t.prototype.on=function(e,t,n){var i;if(void 0===n&&(n=0),this)return(i=this.eventsList[e])||(this.eventsList[e]=[],i=this.eventsList[e]),-1===this.indexOf(i,t)&&i.push({name:e,type:n||0,callback:t}),this},t.prototype.one=function(e,t){this.on(e,t,1)},t.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(n){if(t)return n.length&&(t=this.indexOf(n,t),n.splice(t,1)),this;try{delete this.eventsList[e]}catch(e){}}return null}},t.prototype.clear=function(){this.eventsList={}},t),F=function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={},i=(t.forEach(function(t){n[t]=e.map(function(e){return e[t]})}),n.count=e.length,n);if("string"==typeof i)return i;try{return JSON.stringify(i,ee())||"undefined"}catch(i){return"error happen when aegis stringify: \n "+i.message+" \n "+i.stack}};function t(){var a=this;this.emit=function(e,t){if(a){var n;if(null!=(i=a.eventsList[e])&&i.length)for(var i=i.slice(),o=0;o<i.length;o++){n=i[o];try{var r=n.callback.apply(a,[t]);if(1===n.type&&a.remove(e,n.callback),!1===r)break}catch(e){throw e}}return a}},this.eventsList={}}function p(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function M(e){return"string"==typeof e&&e.startsWith("/")?"https:"===(null===location||void 0===location?void 0:location.protocol):/^https/.test(e)}function d(e,t,n){var i,o;try{if("function"==typeof(null==t?void 0:t.retCodeHandler))return{code:void 0===(r=(o=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx,null==n?void 0:n.payload)||{}).code)?"unknown":r,isErr:o.isErr};"string"==typeof e&&(e=JSON.parse(e)),"function"==typeof(null==(i=null==t?void 0:t.ret)?void 0:i.join)&&(Z=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var r,a=Object.getOwnPropertyNames(e).filter(function(e){return-1!==Z.indexOf(e.toLowerCase())});return a.length?{code:""+(r=e[a[0]]),isErr:0!==r&&"0"!==r}:{code:"unknown",isErr:!1}}catch(e){return{code:"unknown",isErr:!1}}}function h(e,t,n){try{var i="function"==typeof t?t(e,null==n?void 0:n.url)||"":e;return te(i).slice(0,102400)}catch(e){return""}}function y(n,i){var o,r=[],a=n.config;return n.lifeCycle.on("destroy",function(){r.length=0}),function(e,t){Array.isArray(e)?r=r.concat(e):r.push(e),i&&r.length>=i||n.sendNow&&0<r.length?(r=oe(r),t(r.splice(0,r.length)),o&&clearTimeout(o)):(o&&clearTimeout(o),o=setTimeout(function(){o=null,0<(r=oe(r)).length&&t(r.splice(0,r.length))},a.delay))}}function B(e,t){return Array.isArray(e)?t(e.map(function(e){return t=f(f({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(R).join(" ")}),I.forEach(function(e){t[e]||delete t[e]}),t;var t})):t([f(f({},e),{msg:"string"==typeof e.msg?e.msg:R(e.msg)})])}function J(l,u){return function(e,t){var n,i,o,r=Array.isArray(e),a=r?e:[e],s=(l.lifeCycle.emit("beforeRequest",e),l.config.beforeRequest);(a="function"==typeof s?a.map(function(t){try{var e=s({logs:t,logType:u});return(null==e?void 0:e.logType)===u&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):a).length&&(n=a,e=I,!Array.isArray(n)||n.length<=1||(i=[],o=[],!(o="string"==typeof e?[e]:e))||o.length<=0||(o.forEach(function(t){n.forEach(function(e){null!=e&&e[t]&&i.push(t)})}),0<i.length&&(n=n.map(function(e){var t={};return i.forEach(function(e){t[e]=""}),f(f({},t),e)}))),a=n,t(r?a:a[0]))}}function V(o){return function(e,t){o.lifeCycle.emit("modifyRequest",e);var n=o.config.modifyRequest;if("function"==typeof n)try{var i=n(e);"object"==typeof i&&"url"in i&&(e=i)}catch(e){console.error(e)}t(e)}}function W(i){return function(e,t){null!=(n=i.lifeCycle)&&n.emit("afterRequest",e);var n=(i.config||{}).afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function v(n){if(n&&n.reduce&&n.length)return 1===n.length?function(e,t){n[0](e,t||le)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=le),n(e,function(e){return null==i?void 0:i(e,t)})}});throw new TypeError("createPipeline need at least one function param")}function s(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function i(e){try{var t,n,i,o="";return o=e.pageUrl||(n=(t=getCurrentPages())[t.length-1]||{},r=n.options,i=Object.keys(r).length?"?"+Object.keys(r).map(function(e){return e+"="+r[e]}).join("&"):"",n.route?n.route+i:""),(o="function"==typeof e.urlHandler?e.urlHandler():o).slice(0,2048)}catch(e){return""}var r}function G(e,t){if("string"==typeof e&&"string"==typeof t){if(e===t)return 1;for(var n=e.split("."),i=t.split("."),o=Math.max(n.length,i.length),r=0;r<o;r++){var a=~~n[r],s=~~i[r];if(a<s)return;if(s<a)return 1}}}function K(e,t){var n=this;this.taskQueue=[],this.count=1,this.maxCount=2,this.addTask=function(e){n.taskQueue.push(e)},this.fireTask=function(){var e=n.taskQueue.length;n.count>n.maxCount||0===e||(n.count=n.count+1,(e=n.taskQueue.shift())&&n.sendRequest(e.options,null==e?void 0:e.success,null==e?void 0:e.fail))},this.complete=function(){1<n.count&&(n.count=n.count-1),n.fireTask()},t&&(this.maxCount=t),this.sendRequest=e}function l(e){return ue=ue||w.getSystemInfoSync().SDKVersion,G(ue,"1.1.1")&&w.canIUse?w.canIUse(e):!!w[e]}function u(e){for(var t,n={unknown:/unknown|none/i,wifi:/wifi/i,net2g:/2g/i,net3g:/3g/i,net4g:/4g/i,net5g:/5g/i,net6g:/6g/i},i=m.unknown,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!=(t=n[r])&&t.test(e)){i=m[r];break}}return i}function c(e){var t=e.apiName,n=S[t];n?n.hackCloudReq.addCallback(e):(n=P.cloud[t],S[t]={hackCloudReq:new ge(e),originApi:n}),S[t]}function $(e){var t=e.apiName,n=T[t];n?n.hackReq.addCallback(e):(n=wx[t],T[t]={hackReq:new ye(e),originApi:n}),T[t]}var b,g,m,O,E,X,z,Q,Y,Z=["ret","retcode","code","errcode"],ee=function(){var n=new WeakSet;return function(e,t){if(t instanceof Error)return"Error.message: "+t.message+" \n  Error.stack: "+t.stack;if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular "+(e||"root")+"]";n.add(t)}return t}},R=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,ee(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,ee(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},te=function(n,i){void 0===i&&(i=3);var o,r,a,s="";return Array.isArray(n)?(s+="[",o=n.length,n.forEach(function(e,t){s=(s+="object"==typeof e&&1<i?te(e,i-1):ie(e))+(t===o-1?"":",")}),s+="]"):n instanceof Object?(s="{",r=Object.keys(n),a=r.length,r.forEach(function(e,t){"object"==typeof n[e]&&1<i?s+='"'+e+'":'+te(n[e],i-1):s+=ne(e,n[e]),s+=t===a-1||t<a-1&&void 0===n[r[t+1]]?"":","}),s+="}"):s+=n,s},ne=function(e,t){var n=typeof t,i="";return"string"==n||"object"==n?i+='"'+e+'":"'+t+'"':"function"==typeof t?i+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?i+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(i+='"'+e+'": '+t),i},ie=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},oe=((n=b=b||{}).INFO_ALL="-1",n.API_RESPONSE="1",n.INFO="2",n.ERROR="4",n.PROMISE_ERROR="8",n.AJAX_ERROR="16",n.SCRIPT_ERROR="32",n.IMAGE_ERROR="64",n.CSS_ERROR="128",n.CONSOLE_ERROR="256",n.MEDIA_ERROR="512",n.RET_ERROR="1024",n.REPORT="2048",n.PV="4096",n.EVENT="8192",n.PAGE_NOT_FOUND_ERROR="16384",n.WEBSOCKET_ERROR="32768",n.BRIDGE_ERROR="65536",(n=g=g||{})[n.android=1]="android",n[n.ios=2]="ios",n[n.windows=3]="windows",n[n.macos=4]="macos",n[n.linux=5]="linux",n[n.devtools=6]="devtools",n[n.other=100]="other",(n=m=m||{})[n.unknown=100]="unknown",n[n.wifi=1]="wifi",n[n.net2g=2]="net2g",n[n.net3g=3]="net3g",n[n.net4g=4]="net4g",n[n.net5g=5]="net5g",n[n.net6g=6]="net6g",(n=O=O||{}).LOG="log",n.SPEED="speed",n.PERFORMANCE="performance",n.OFFLINE="offline",n.WHITE_LIST="whiteList",n.VITALS="vitals",n.PV="pv",n.CUSTOM_PV="customPV",n.EVENT="event",n.CUSTOM="custom",n.SDK_ERROR="sdkError",n.SET_DATA="setData",n.LOAD_PACKAGE="loadPackage",(n=E=E||{}).production="production",n.development="development",n.gray="gray",n.pre="pre",n.daily="daily",n.local="local",n.test="test",n.others="others",function(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&i<t})})}),re=function(e){e.level===b.INFO_ALL&&(e.level=b.INFO)},ae=function(e){return(Array.isArray(e)?e:[e]).map(function(n){return Object.getOwnPropertyNames(n).reduce(function(e,t){return"ctx"!==t&&(e[t]=n[t]),e},{level:b.INFO,msg:""})})},se=function(i){return function(e){return i.sendPipeline([function(e,n){return n({url:i.config.url||"",data:F(ae(e)),method:"post",contentType:"application/json",type:O.LOG,log:e,requestConfig:{timeout:5e3},success:function(){var t=i.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])}})}],O.LOG)(e)}},le=function(){},n=(Object.defineProperty(A.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.36.7"},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),b},enumerable:!1,configurable:!0}),A.prototype.init=function(e){this.setConfig(e);for(var t=0;t<A.installedPlugins.length;t++)try{A.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},A.prototype.setConfig=function(e){Object.assign(this.config,e);var e=this.config,t=e.id,n=e.uin,i=e.version,o=e.ext1,r=e.ext2,a=e.ext3,s=e.aid,l=e.env,u=void 0===l?"production":l,l=e.pageUrl,e=this.bean.id!==t||this.bean.uin!==n||this.bean.aid!==s;return this.bean.id=t||"",this.bean.uin=n||"",this.bean.version=i||"1.36.7",this.bean.aid=s||"",this.bean.env=function(){switch(u){case E.production:case E.development:case E.gray:case E.pre:case E.daily:case E.local:case E.test:case E.others:return 1;default:return}}()?u:E.others,l&&this.extendBean("from",encodeURIComponent(l.slice(0,2048))),o&&this.extendBean("ext1",encodeURIComponent(o)),r&&this.extendBean("ext2",encodeURIComponent(r)),a&&this.extendBean("ext3",encodeURIComponent(a)),e&&this.lifeCycle.emit("onConfigChange",this.config),this.config},A.use=function(e){-1===A.installedPlugins.indexOf(e)&&e.aegisPlugin&&A.installedPlugins.push(e)},A.unuse=function(e){e=A.installedPlugins.indexOf(e);-1!==e&&A.installedPlugins.splice(e,1)},A.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:b.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:b.INFO}),this.normalLogPipeline(n)},A.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:b.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:b.INFO_ALL}),this.normalLogPipeline(n)},A.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:b.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0])),this.normalLogPipeline(n)},A.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:b.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:b.ERROR}),this.normalLogPipeline(n)},A.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},A.prototype.reportPv=function(n){var i,o=this;n&&(console.warn("reportPv is deprecated, please use reportEvent"),i=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+o.bean[e]}).join("&"),this.sendPipeline([function(e,t){t({url:o.config.url+"/"+n+"?"+i,addBean:!1,type:O.CUSTOM_PV})}],O.CUSTOM_PV)(null))},A.prototype.reportEvent=function(e){e&&((e="string"==typeof e?{name:e,ext1:this.config.ext1||"",ext2:this.config.ext2||"",ext3:this.config.ext3||""}:e).name?this.eventPipeline(e):console.warn("reportEvent params error"))},A.prototype.reportTime=function(e,t){if("object"==typeof e)return this.reportT(e);"string"==typeof e?"number"==typeof t?t<0||6e4<t?console.warn("reportTime: duration must between 0 and 60000"):this.submitCustomTime(e,t):console.warn("reportTime: second param must be number"):console.warn("reportTime: first param must be a string")},A.prototype.reportT=function(e){var t=e.name,n=e.duration,i=e.ext1,i=void 0===i?"":i,o=e.ext2,o=void 0===o?"":o,r=e.ext3,r=void 0===r?"":r,e=e.from;if("string"==typeof t&&"number"==typeof n&&"string"==typeof i&&"string"==typeof o&&"string"==typeof r){if(!(n<0||6e4<n))return this.submitCustomTime(t,n,i,o,r,void 0===e?"":e);console.warn("reportTime: duration must between 0 and 60000")}else console.warn("reportTime: params error")},A.prototype.time=function(e){"string"==typeof e?this.timeMap[e]?console.warn("Timer "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("time: first param must be a string")},A.prototype.timeEnd=function(e){"string"==typeof e?this.timeMap[e]?(this.submitCustomTime(e,Date.now()-this.timeMap[e]),delete this.timeMap[e]):console.warn("Timer "+e+" does not exist"):console.warn("timeEnd: first param must be a string")},A.prototype.submitCustomTime=function(e,t,n,i,o,r){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:i||this.config.ext2,ext3:o||this.config.ext3,from:r||void 0})},A.prototype.extendBean=function(e,t){this.bean[e]=t},A.prototype.sendPipeline=function(e,t){var n,r=this;return v(a([function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)n.isHidden||t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}},J(n=this,t)],e,[V(this),function(i,o){r.request(i,function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.failRequestCount=0,o({isErr:!1,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null!=(e=null==i?void 0:i.success)&&e.call.apply(e,a([i],t))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];10<=++r.failRequestCount&&r.destroy(),-1<(""+t[0]).indexOf("403 forbidden")&&r.destroy(),o({isErr:!0,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null!=(e=null==i?void 0:i.fail)&&e.call.apply(e,a([i],t))})},W(this)]))},A.prototype.send=function(e,o,r){var t=this;return v([V(this),function(n,i){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!1,result:e,logType:n.type,logs:n.log}),null!=o&&o.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!0,result:e,logType:n.type,logs:n.log}),null!=r&&r.apply(void 0,e)})},W(this)])(e)},A.prototype.ready=function(e,t,n){throw new Error('You need to override "ready" method')},A.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},A.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(R(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.36.7)",addBean:!1,method:"get",type:O.SDK_ERROR,log:e})}],O.SDK_ERROR)(e)},A.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=A.instances.indexOf(this);-1!==i&&A.instances.splice(i,1);for(var o=A.installedPlugins.length-1;0<=o;o--)try{A.installedPlugins[o].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),e)t=this,n=Object.getOwnPropertyDescriptors(t),Object.keys(n).forEach(function(e){n[e].writable&&(t[e]=null)}),Object.setPrototypeOf(this,null);else{for(var r=this;r.constructor!==Object&&s(r,this),r=Object.getPrototypeOf(r););0===A.instances.length&&(i=Object.getPrototypeOf(this).constructor,s(i),s(A))}},A.version="1.36.7",A.instances=[],A.logType=b,A.environment=E,A.installedPlugins=[],A),o=(L.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},L.prototype.unpatch=function(e){var t=this.instances.indexOf(e);-1!==t&&(this.instances.splice(t,1),0===this.instances.length)&&this.uninstall(e)},L.prototype.countInstance=function(){return this.instances.length},L.prototype.uninstall=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.destroy)&&t.apply(this,[e])},L.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},L.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},L.prototype.getConfig=function(e){return null==(e=e.config)?void 0:e[this.name]},L.prototype.exist=function(e){return-1===this.instances.indexOf(e)},L.prototype.triggerInit=function(e){var t;this.inited||(this.inited=!0,null==(t=null==(t=this.option)?void 0:t.init))||t.call(this.option,this.getConfig(e))},L.prototype.triggerOnNewAegis=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.onNewAegis)&&t.call(this.option,e,this.getConfig(e))},L),w=wx||qq,ue="",ce=new o({name:"offlineLog",onNewAegis:function(o){if(w.getFileSystemManager)try{var e=o.config,t=e.id,r=void 0===t?"":t,n=e.uin,a=void 0===n?0:n,i=e.offlineUrl,s=void 0===i?"":i,l=e.offlineLogLimit,u=new fe({limit:l});o.lifeCycle.on("beforeWrite",function(e){u.save2Offline(e=void 0===e?[]:e,o.config)}),u.ready(function(t){var e=(o.bean||{}).aid,i=void 0===e?"":e;!t&&r&&(a||i)&&o.send({url:s+"/offlineAuto",type:O.OFFLINE,log:O.OFFLINE},function(e){var n=(null==e?void 0:e.data).secretKey;n&&!t&&u.getLogs({id:r,uin:a},function(e,t){e?console.error(e):o.send({url:s+"/offlineLog",data:{logs:t,secretKey:n,id:r,uin:a,aid:i},method:"post",type:O.OFFLINE,log:t},function(){u.clearLogs()})})})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),fe=(Oe.prototype.getLogs=function(e,t){var n=this.fileSystem,i=this.filePath;n.readFile({filePath:i,encoding:"utf8",fail:function(e){console.error(e)},success:function(e){e=e.data,e=(void 0===e?"":e).toString().split("\n").filter(function(e){return e}).map(function(e){return JSON.parse(e)});t(null,e)}})},Oe.prototype.checkLimit=function(o,r){void 0===r&&(r=function(){});var a=this.fileSystem,s=this.filePath,l=this.limitSize;a.readFile({filePath:s,encoding:"utf8",success:function(e){e=e.data,e=void 0===e?"":e;if((e=e.toString()+o).length>l){for(var t=e.split("\n"),n="",i=t.length-1;0<=i&&!(t[i]&&(n=t[i]+"\n"+n).length>l);i--);a.writeFile({filePath:s,data:n,success:r})}else a.appendFile({data:o,filePath:s,encoding:"utf8",success:r,fail:function(e){console.error(e)}})}})},Oe),pe=new o({name:"device",onNewAegis:function(t){return e=this,l=function(){return H(this,function(e){return this.setSystemInfo(t),this.refreshNetwork(t),this.setNetworkChange(t),[2]})},new(s=(s=a=void 0)||Promise)(function(n,t){function i(e){try{r(l.next(e))}catch(e){t(e)}}function o(e){try{r(l.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(i,o)}r((l=l.apply(e,a||[])).next())});var e,a,s,l},setSystemInfo:function(a){var s=this;try{l("getSystemInfo")&&w.getSystemInfo({success:function(e){var t=e.platform,n=e.model,i=e.windowHeight,o=e.windowWidth,r=e.screenWidth,r=void 0===r?0:r,e=e.screenHeight,e=void 0===e?0:e;a.extendBean("platform",s.getPlatFormType(t)),a.extendBean("model",n),a.extendBean("vp",Math.round(o)+" * "+Math.round(i)),a.extendBean("sr",Math.round(r)+" * "+Math.round(e))}})}catch(a){}},getPlatFormType:function(e){for(var t,n={android:/android/i,ios:/ios/i,windows:/windows/i,macos:/mac/i,devtools:/devtools/i},i=g.other,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!=(t=n[r])&&t.test(e)){i=g[r];break}}return i},setNetworkChange:function(t){l("onNetworkStatusChange")&&w.onNetworkStatusChange(function(e){e=u(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){l("getNetworkType")&&w.getNetworkType({success:function(e){e=u(e.networkType);t.extendBean("netType",e)}})},refreshNetwork:function(e){var t=this;this.timer&&clearTimeout(this.timer),this.setNetworkType(e),this.timer=setTimeout(function(){t.refreshNetwork(e)},1e4)}}),de=w.request,n=(e(N,Q=n),Object.defineProperty(N.prototype,"getBean",{get:function(){var t=this;return this.bean?Object.getOwnPropertyNames(this.bean).map(function(e){return e+"="+t.bean[e]}).join("&")+"&from="+encodeURIComponent(i(this.config)):"from="+encodeURIComponent(i(this.config))},enumerable:!1,configurable:!0}),N.prototype.initOfflineLog=function(){N.use(ce)},N.prototype.initRequestSchedule=function(){this.requestSchedule=new K(this.sendRequest)},N.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},N.prototype.reportPv=function(e){var t,n=this;e&&(t=Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+n.bean[e]}).join("&")+"&from="+encodeURIComponent(i(this.config)),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:O.CUSTOM_PV,log:O.CUSTOM_PV},function(){},function(){}))},N.sessionID="session-"+Date.now(),N.asyncPluginIndex=0,N),he=new o({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){w.getStorage({key:"AEGIS_ID",success:function(e){t(e.data)},fail:function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});w.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),r=(C.prototype.addCallback=function(e){e&&this.callbacks.push(e)},C.prototype.prefixHandler=function(e){return f(f({},e),{aegisRequestStartTime:+new Date})},C.prototype.successHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.success)&&t.call(e,n,i)}catch(e){}}),null!=(e=i.success)&&e.call(i,n,i)},C.prototype.failHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.fail)&&t.call(e,n,i)}catch(e){}}),null!=(e=i.fail)&&e.call(i,n,i)},C.prototype.completeHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null!=(t=e.complete)&&t.call(e,n,i)}catch(e){}}),null!=(e=i.complete)&&e.call(i,n,i)},C.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},C),P=wx||qq,S={},ge=(e(x,z=r),x.prototype.defineApiProperty=function(){var e=this;P.cloud&&P.cloud[this.apiName]&&Object.defineProperty(P.cloud,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},x.prototype.hackHandler=function(e){var i=this,o=this.prefixHandler(e);return new Promise(function(t,n){var e=null==(e=S[i.apiName])?void 0:e.originApi;null!=e&&e(f(f({},o),{success:function(e){i.successHandler(e,o),t(e)},fail:function(e){i.failHandler(e,o),n(e)},complete:function(e){i.completeHandler(e,o)}}))})},x),me=wx||qq,T={},ye=(e(k,X=r),k.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(me,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},k.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=null==(e=T[this.apiName])?void 0:e.originApi;return null==e?void 0:e(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))},k),ve=wx||qq,be=ve.request;function k(){return null!==X&&X.apply(this,arguments)||this}function x(){return null!==z&&z.apply(this,arguments)||this}function C(e){this.callbacks=[],this.isOverride=!1;var t=e.apiName;this.apiName=t,this.isOverride||this.override(),this.callbacks.push(e)}function N(e){var i,o,r,c=Q.call(this,e)||this;c.originRequest=de,c.speedLogPipeline=v([(o=c.config,r={},function(e,t){var n,i;o.speedSample?(i="object"==typeof o.repeat?o.repeat:{repeat:o.repeat},n=+i.speed||+i.repeat||5,Array.isArray(e)?(i=e.filter(function(e){var t=!r[e.url]||r[e.url]<n;return r[e.url]=1+~~r[e.url],t})).length&&t(i):(!r[e.url]||r[e.url]<n)&&(r[e.url]=1+~~r[e.url],t(e))):t(e)}),y(c),function(t,n){l("getNetworkType")?w.getNetworkType({success:function(e){e=u(e.networkType);i.extendBean("netType",e),n(t)}}):n(t)},function(e,t){c.lifeCycle.emit("beforeReportSpeed",e);var n=c.config.beforeReportSpeed;if((e="function"==typeof n?e.filter(function(e){return!1!==n(e)}):e).length)return t(e)},J(i=c,O.SPEED),function(e){var t,n,i,o;c.send({url:""+c.config.speedUrl,method:"post",data:(e=e,t=c.bean,i={fetch:[],static:[],bridge:[]},o={},Array.isArray(e)?e.forEach(function(e){var t;null!=(t=i[e.type])&&t.push(e)}):null!=(n=i[e.type])&&n.push(e),o.payload=JSON.stringify(f({duration:i},t)),o)})}]),c.request=function(e,t,n){e.url&&c.bean.id&&(!/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(String(c.bean.aid))||l("getNetworkType")&&void 0===c.bean.netType?c.requestSchedule.addTask({options:e,success:t,fail:n}):(c.requestSchedule.addTask({options:e,success:t,fail:n}),c.requestSchedule.fireTask()))},c.sendRequest=function(e,t,n){var i,o,r,a=e.url,s=(c.config.whiteListUrl===a&&(i=t,t=function(e){null!=i&&i(JSON.stringify(e.data))}),e.method),s=void 0===s?"get":s,l=(!1!==e.addBean&&(a=a+(-1===(null==a?void 0:a.indexOf("?"))?"?":"&")+c.getBean),e),u=c.config.onBeforeRequest;return(l=u?u(e,c):l)&&l.url?(u=c.config.enableHttp2||!1,"get"===s?(s=a,o=l.data,a="string"!=typeof s?"":"object"==typeof o&&o?(r=Object.getOwnPropertyNames(o).map(function(e){var t=o[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI"),s+(-1===s.indexOf("?")?"?":"&")+r):s,c.originRequest(f({url:a,enableHttp2:u,success:t,fail:n,complete:c.requestSchedule.complete},e.requestConfig))):("string"==typeof l.data&&(l.data=l.data.replace(/eval/gi,"evaI")),c.originRequest(f({url:a,enableHttp2:u,header:l.contentType?{"content-type":l.contentType}:void 0,method:"POST",data:l.data,success:t,fail:n,complete:c.requestSchedule.complete},e.requestConfig))),!0):(r="",l&&l.url||(r="Sending request blocked. Please handle the parameters reasonably, options.url is necessary",console.log(r)),null!=n&&n(r),c.requestSchedule.complete(),!1)};try{e.offlineLog&&c.initOfflineLog(),c.initRequestSchedule(),c.init(e),c.extendBean("sessionId",N.sessionID),c.extendBean("referer",(l("getLaunchOptionsSync")?w.getLaunchOptionsSync():{scene:""}).scene||"")}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing Aegis, which will affect your normal use of Aegis.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),c.sendSDKError(e)}return c}function Oe(e){var o,r,a=this,e=void 0===e?{}:e,t=e.path,t=void 0===t?"/.aegis.offline.log":t,e=e.limit,e=void 0===e?2e4:e;this.offlineBuffer=[],this.insertLog=(o=null,r=[],function(e){r=r.concat(e),o=o||setTimeout(function(){o=null;var e,t=a.fileSystem,n=a.filePath,i=r.map(function(e){return JSON.stringify(e)}).join("\n")+"\n";i&&(e=function(e){e?a.checkLimit(i,function(){r=[]}):t.writeFile({data:i,filePath:n,encoding:"utf8",fail:function(e){console.error(e)},success:function(){r=[]}})},t.access({path:n,success:function(){e(!0)},fail:function(){e()}}))},2e3)}),this.ready=function(e){a.fileSystem?setTimeout(function(){e(null)},0):(e(new Error("getFileSystemManager file")),a.offlineLog=!1)},this.clearLogs=function(){var e=a.fileSystem,t=a.filePath;e.writeFile({filePath:t,data:"",fail:function(){e.unlinkSync(t)}})},this.save2Offline=function(e,t){e=(e=Array.isArray(e)?e:[e]).map(function(e){return"string"==typeof e&&(e={msg:e}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e[0]),i=1;i<e.length;i++){var o=e[i];if(null!==o)for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])}return n}({id:t.id,uin:t.uin,time:+Date.now(),version:t.version,from:i(t)},e)});a.fileSystem?a.insertLog(e):(a.fileSystem||a.offlineBuffer.length||a.ready(function(e){e?console.error(e):a.offlineBuffer.length&&(a.addLogs(a.offlineBuffer),a.offlineBuffer=[])}),a.offlineBuffer=a.offlineBuffer.concat(e))},this.addLogs=function(e){a.fileSystem&&a.insertLog(e)},this.filePath=w.env.USER_DATA_PATH+t,this.fileSystem=w.getFileSystemManager(),this.limitSize=e}function L(e){this.aegisPlugin=!0,this.name="",this.instances=[],this.inited=!1,e.$walk=this.walk.bind(this),e.$getConfig=this.getConfig.bind(this),this.option=e,this.name=e.name}function A(e){var n,t,i,o,a,r,s,l,u,c,f,p,d,h,g,m=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:5,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,reportLoadPackageSpeed:!0,hostUrl:"https://aegis.qq.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:"",reportImmediately:!0},this.isWhiteList=!1,this.lifeCycle=new D,this.bean={},this.originFireUrl="",this.normalLogPipeline=v([y(this,5),B,function(e,t){var i=n.config;t(e=e.map(function(e){var t,n=i.maxLength||102400;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null==(t=e.msg)?void 0:t.substring(0,n)}catch(t){e.msg=R(e.msg).substring(0,i.maxLength)}return e}))},(h=(n=this).config,g={},function(e,t){var n="number"==typeof h.repeat?h.repeat:5;if(0===n)return t(e);t(e.filter(function(e){return e.level!==b.ERROR&&e.level!==b.PROMISE_ERROR&&e.level!==b.AJAX_ERROR&&e.level!==b.SCRIPT_ERROR&&e.level!==b.IMAGE_ERROR&&e.level!==b.CSS_ERROR&&e.level!==b.MEDIA_ERROR||(g[e.msg]=g[e.msg]||0,g[e.msg]+=1,!(g[e.msg]>n))}))}),(p=this.lifeCycle.emit,d=this.config,function(e,t){var n,i=d.logCreated;return"function"==typeof i?(n=e.filter(function(e){return!1!==i(e)}),p("beforeWrite",n),t(n)):(p("beforeWrite",e),t(e))}),(f=this,setTimeout(function(){var e=f.config.pvUrl,n=void 0===e?"":e,e="undefined"!=typeof location?(null===location||void 0===location?void 0:location.pathname)+(null===location||void 0===location?void 0:location.hash):void 0;n&&e!==f.originFireUrl&&(f.sendPipeline([function(e,t){t({url:n,type:O.PV})}],O.PV)(null),e)&&location&&(f.originFireUrl=e)},100),function(e,t){t(e)}),(u=l=s=!1,c=[],(a=this).lifeCycle.on("onConfigChange",function(){r&&clearTimeout(r),r=setTimeout(function(){var e,n;!u&&a.config&&(u=!0,e=a.config.whiteListUrl,(n=void 0===e?"":e)&&a.sendPipeline([function(e,t){t({url:n,type:O.WHITE_LIST,success:function(e){l=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,i=t.result,o=void 0===i?{}:i,r=(0===n&&(s=o.is_in_white_list,a.isWhiteList=s,0<=o.rate)&&o.rate<=1&&(a.config.random=o.rate,a.isGetSample=!1),a.isWhiteList&&c.length?se(a)(c.splice(0),function(){}):!a.isWhiteList&&c.length&&(c.length=0),a.config.onWhitelist);"function"==typeof r&&r(s)}catch(e){}},fail:function(){l=!0}})}],O.WHITE_LIST)(null),u=!1)},a.config.uin?50:500)}),a.lifeCycle.on("destroy",function(){c.length=0}),function(e,t){var n;s||null!=(n=null==(n=a.config)?void 0:n.api)&&n.reportRequest?t(e.concat(c.splice(0)).map(function(e){return re(e),e})):(n=e.filter(function(e){return e.level!==b.INFO&&e.level!==b.API_RESPONSE?(re(e),!0):(l||(c.push(e),200<=c.length&&(c.length=200)),!1)})).length&&t(n)}),function(e,t){try{var n=JSON.parse(JSON.stringify(e)),i=(m.lifeCycle.emit("beforeReport",n),m.config.beforeReport);(e="function"==typeof i?e.filter(function(e){return!1!==i(e)}):e).length&&t(e)}catch(e){}},se(this)]),this.eventPipeline=v([y(this,10),(o=this,function(e){o.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||o.config.ext1||"",ext2:e.ext2||o.config.ext2||"",ext3:e.ext3||o.config.ext3||""}});t({url:o.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:O.EVENT,log:e})}],O.EVENT)(e)})]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=v([y(this,10),(i=this,function(e){return i.sendPipeline([function(e,t){t({url:i.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:O.CUSTOM,log:e})}],O.CUSTOM)(e)})]),this.config=(t=this.config,void 0===(e=e.hostUrl)&&(e="https://aegis.qq.com"),t.url=t.url||e+"/collect",t.offlineUrl=t.offlineUrl||e+"/offline",t.whiteListUrl=t.whiteListUrl||e+"/collect/whitelist",t.pvUrl=t.pvUrl||e+"/collect/pv",t.eventUrl=t.eventUrl||e+"/collect/events",t.speedUrl=t.speedUrl||e+"/speed",t.customTimeUrl=t.customTimeUrl||e+"/speed/custom",t.performanceUrl=t.performanceUrl||e+"/speed/performance",t.webVitalsUrl=t.webVitalsUrl||e+"/speed/webvitals",t.setDataReportUrl=t.SetDataReportUrl||e+"/speed/miniProgramData",t),A.instances.push(this)}function Ee(){return null!==Y&&Y.apply(this,arguments)||this}e(Ee,Y=r),Ee.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(ve,"request",{get:function(){return e.hackHandler.bind(e)}})};function q(i,e,o){return null!=e&&e.length&&"object"==typeof i?e.reduce(function(e,t){var n=i[t];return n?e+(""===e?"\n":"\n\n")+o+" header "+t+": "+n:e},""):""}var U,Re,we=new o({name:"reportApiSpeed",override:!(Ee.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e);return be(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))}),onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config),this.overrideCallContainer(e.config))},hackRequest:function(u){var c=this;$({apiName:"request",success:function(e,t){var n,i,o,r,a,s,l;u.hostUrl&&-1<t.url.indexOf(u.hostUrl)||(n={method:t.method||"get",url:p(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,nextHopProtocol:"",isHttps:M(t.url),type:"fetch"},r=null==(r=u.api)?void 0:r.apiDetail,i=(o=d(e.data,u.api,{url:t.url,ctx:e,payload:t.data})||{}).code,o=o.isErr,l=r?h(t.data,null==(l=u.api)?void 0:l.reqParamHandler,{url:t.url}):"",r=r?h(e.data,null==(r=u.api)?void 0:r.resBodyHandler,{url:t.url}):"",a=(null==(a=u.api)?void 0:a.reqHeaders)||[],a=q(null==t?void 0:t.header,a,"req"),s=(null==(s=u.api)?void 0:s.resHeaders)||[],s=q(null==e?void 0:e.header,s,"res"),l="req url: "+n.url+" \n                        \nres status: "+(e.statusCode||0)+" \n                        \nres duration: "+n.duration+"ms \n                        \nreq method: "+n.method+" \n                        \nreq param: "+l+"  \n                        \nres retcode: "+i+" \n                        \nres data: "+r+"\n                        "+a+"\n                        "+s,c.publishNormalLog({msg:l,level:b.API_RESPONSE,ctx:e}),n.ret=i,n.isErr=+o,n.payload=t.data,c.publishSpeedLog(n),o&&c.publishNormalLog({msg:l,level:b.RET_ERROR,ctx:e}))},fail:function(e,t){u.hostUrl&&-1<t.url.indexOf(u.hostUrl)||(t={method:t.method||"get",url:p(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",isHttps:M(t.url),type:"fetch"},c.publishSpeedLog(t))}})},overrideCallFunction:function(n){var i=this;c({apiName:"callFunction",success:function(e,t){i.cloudSuccessCallback(n,t,e,"callFunction")},fail:function(e,t){t={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",type:"fetch",errMsg:e.errMsg,isHttps:!0};i.publishSpeedLog(t)}})},overrideCallContainer:function(n){var i=this;c({apiName:"callContainer",success:function(e,t){i.cloudSuccessCallback(n,t,e,"callContainer")},fail:function(e,t){t={method:"call",url:"wx.cloud.callContainer."+t.path,duration:Date.now()-t.aegisRequestStartTime,status:0,nextHopProtocol:"",type:"fetch",errMsg:e.errMsg,isHttps:!0};i.publishSpeedLog(t)}})},cloudSuccessCallback:function(e,n,t,i){var o="callFunction"===i?n.name:n.path,r="callFunction"===i?t.result:t.data,o={method:"call",url:"wx.cloud."+i+"."+o,duration:Date.now()-n.aegisRequestStartTime,status:200,nextHopProtocol:"",type:"fetch",isHttps:!0},a=["apiName","aegisRequestStartTime","config","success","fail","complete"],s=Object.keys(n).reduce(function(e,t){return a.includes(t)||(e[t]=n[t]),e},{}),i="callFunction"===i?(null==(i=t.data)?void 0:i.code)||0:t.statusCode,l=d(r,e.api,{url:o.url,ctx:t,payload:s})||{},u=l.code,l=l.isErr,l=void 0!==l&&l,u=(o.ret=u,o.isErr=+l,o.payload=s,null==(u=e.api)?void 0:u.apiDetail),s=u?h(s,null==(s=e.api)?void 0:s.reqParamHandler,{url:o.url}):"",r=u?h(r,null==(u=e.api)?void 0:u.resBodyHandler,{url:o.url}):"",u=(null==(u=e.api)?void 0:u.reqHeaders)||[],u=q(null==n?void 0:n.header,u,"req"),e=(null==(e=e.api)?void 0:e.resHeaders)||[],e=q(null==t?void 0:t.header,e,"res"),i="req url: "+o.url+"\n                    \nres status: "+i+"\n                    \nres duration: "+o.duration+"ms \n                    \nreq type: "+o.type+"\n                    \nreq params: "+s+"\n                    \nres retcode: "+o.ret+"\n                    \nres data: "+r+"\n                    "+u+"\n                    "+e;this.publishNormalLog({msg:i,level:b.API_RESPONSE,ctx:t}),this.publishSpeedLog(o),l&&this.publishNormalLog({msg:i,level:b.RET_ERROR,ctx:t})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),Pe=wx||qq,Se=Pe.connectSocket,Te=(Le.prototype.addConfig=function(e){var t=e.send,e=e.onError;t&&this.sends.push(t),e&&this.onErrors.push(e)},Le.prototype.toHack=function(t){var o=this,n=(this.onErrors.forEach(function(e){t.onError(e)}),t.send);return Object.defineProperty(t,"send",{get:function(){return function(i){return new Promise(function(e){n.call(t,f(f({},i),{fail:function(n){o.sends.forEach(function(e){var t;null!=(t=e.fail)&&t.call(e,n,i)}),e(n)}}))})}}}),t},Le),ke=(e(_,Re=r),_.prototype.addTaskConf=function(e){this.taskHack.addConfig(e)},_.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(Pe,"connectSocket",{get:function(){return e.hackHandler.bind(e)}})},_.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=Se(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}));return this.taskHack.toHack(e),e},_),r=new o({name:"onError",onNewAegis:function(e){var t=w.getSystemInfoSync().SDKVersion;this.listenError(),this.hackNetWork(e),this.hackCloud(e),e.config.websocketHack&&G(t,"1.7.0")&&this.hackWsConnect()},listenError:function(){var t=this;"function"==typeof w.onError&&w.onError(function(e){e&&t.publishErrorLog({msg:e,level:b.ERROR})}),l("onUnhandledRejection")&&w.onUnhandledRejection(function(e){e=e.reason;!e||-1<JSON.stringify(e).indexOf("request:fail")||t.publishErrorLog({msg:e,level:b.PROMISE_ERROR})}),l("onPageNotFound")&&w.onPageNotFound(function(e){e&&t.publishErrorLog({msg:e,level:b.PAGE_NOT_FOUND_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackNetWork:function(e){for(var n=this,i=e.config,t=0,o=[{apiName:"request",complete:function(e,t){return n.requestCompleteError(e,t,i)}},{apiName:"uploadFile",complete:function(e,t){return n.uploadFileCompleteError(e,t,i)}},{apiName:"downloadFile",complete:function(e,t){return n.downloadFileCompleteError(e,t,i)}}];t<o.length;t++){var r=o[t],a=r.apiName,r=r.complete;$({apiName:a,complete:r})}},requestCompleteError:function(e,t,n){var i,o=e.errMsg,r=e.statusCode;n.hostUrl&&-1<(null==(i=t.url)?void 0:i.indexOf(n.hostUrl))||(i=this.getErrorType({errMsg:o,statusCode:r}))&&this.publishNetWorkError({apiName:"request",opts:t,res:e,config:n,type:i})},downloadFileCompleteError:function(e,t,n){var i,o=e.errMsg,r=e.statusCode,a=e.filePath,e=e.tempFilePath,s=this.getErrorType({errMsg:o,statusCode:r});s&&(n=null!=(i=n.api)&&i.apiDetail?h(t.data,null==(i=n.api)?void 0:i.reqParamHandler,{url:t.url}):"",this.publishErrorLog({msg:"AJAX_ERROR: downloadFile "+s+"\n                  \nreq url: "+t.url+"\n                  \nres status: "+(r||0)+"\n                  \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"ms\n                  \nres filePath: "+a+"\n                  \nres tempFilePath: "+e+"\n                  \nreq method: "+(t.method||"get")+"\n                  \nreq param: "+n+"\n                  \nerrMsg: "+o.slice(0,1e3),level:b.AJAX_ERROR}))},uploadFileCompleteError:function(e,t,n){var i=e.errMsg,o=e.statusCode,i=this.getErrorType({errMsg:i,statusCode:o});i&&this.publishNetWorkError({apiName:"uploadFile",opts:t,res:e,config:n,type:i})},hackCloud:function(e){for(var n=this,i=e.config,t=0,o=[{apiName:"callFunction",complete:function(e,t){return n.callFunctionCompleteError(e,t,i)}},{apiName:"callContainer",complete:function(e,t){return n.callContainerCompleteError(e,t,i)}}];t<o.length;t++){var r=o[t],a=r.apiName,r=r.complete;c({apiName:a,complete:r})}},callFunctionCompleteError:function(e,t,n){var i,o;(-1<e.errMsg.indexOf("fail")||-1<e.errMsg.indexOf("timeout"))&&(o=(i=null==(i=n.api)?void 0:i.apiDetail)?h(t.data,null==(o=n.api)?void 0:o.reqParamHandler,{url:null==t?void 0:t.url}):"",n=i?h(e,null==(i=n.api)?void 0:i.resBodyHandler,{url:null==t?void 0:t.url}):"",this.publishErrorLog({msg:"AJAX_ERROR: cloud.callFunction:fail\n                    \nreq url: cloud.callFunction."+t.name+"\n                    \nres status: 0\n                    \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"ms\n                    \nres data: "+n+"\n                    \nreq method: POST\n                    \nreq param: "+o+"\n                    \nerrMsg: "+e.errMsg.slice(0,1e3),level:b.AJAX_ERROR}))},callContainerCompleteError:function(e,t,n){var i,o,r,a=e.errMsg,s=e.statusCode;(400<=s||-1<a.indexOf("fail")||-1<a.indexOf("timeout"))&&(i=(o=null==(o=n.api)?void 0:o.apiDetail)?h(t.data,null==(i=n.api)?void 0:i.reqParamHandler,{url:null==t?void 0:t.url}):"",o=o?h(e,null==(o=n.api)?void 0:o.resBodyHandler,{url:null==t?void 0:t.url}):"",r=(null==(r=n.api)?void 0:r.reqHeaders)||[],r=q(null==t?void 0:t.header,r,"req"),n=(null==(n=n.api)?void 0:n.resHeaders)||[],e=q(null==e?void 0:e.header,n,"res"),this.publishErrorLog({msg:"AJAX_ERROR: cloud.callContainer:fail\n                    \nreq url: "+t.path+"\n                    \nres status: "+(s||0)+"\n                    \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"ms\n                    \nreq method: "+(t.method||"POST")+"\n                    \nreq param: "+i+"\n                    \nres data: "+o+"\n                    \nerrMsg: "+a.slice(0,1e3)+"\n                    "+r+"\n                    "+e,level:b.AJAX_ERROR}))},publishNetWorkError:function(e){var t=e.apiName,n=e.opts,i=e.res,o=e.config,e=e.type,r=i.errMsg,a=i.statusCode,s=i.data,l="wx.cloud.callFunction."+n.url,u=d(s,o.api,{url:l,ctx:i,payload:n.data}).code,c=null==(c=o.api)?void 0:c.apiDetail,f=c?h(n.data,null==(f=o.api)?void 0:f.reqParamHandler,{url:l}):"",s=c?h(s,null==(c=o.api)?void 0:c.resBodyHandler,{url:l}):"",l=(null==(c=o.api)?void 0:c.reqHeaders)||[],c=q(null==n?void 0:n.header,l,"req"),o=(null==(l=o.api)?void 0:l.resHeaders)||[],l=q(null==i?void 0:i.header,o,"res");this.publishErrorLog({msg:"AJAX_ERROR: "+t+" "+e+"\n                  \nreq url: "+n.url+"\n                  \nres status: "+(a||0)+"\n                  \nres duration: "+(Date.now()-n.aegisRequestStartTime)+"ms\n                  \nreq method: "+(n.method||"get")+"\n                  \nreq param: "+f+"\n                  \nres retcode: "+u+"\n                  \nres data: "+s+"\n                  \nerrMsg: "+r.slice(0,1e3)+"\n                  "+c+"\n                  "+l,level:b.AJAX_ERROR})},getErrorType:function(e){var t=e.errMsg,e=e.statusCode,n="",i=t;return["timeout","time out","ERR_CONNECTION_TIMED_OUT","ERR_TIMED_OUT","超时"].some(function(e){return String(i||"").includes(e)})?n="timeout":400<=e?n="error":(-1<t.indexOf("fail")||!e||e<0)&&(n="failed"),n},hackWsConnect:function(){var e,t,n=this;$({apiName:"sendSocketMessage",fail:function(e){n.publishSocketError(e)}}),e=(t={connectCallback:{fail:function(e){n.publishSocketError(e)}},taskOpt:{onError:function(e){n.publishSocketError(e)},send:{fail:function(e){n.publishSocketError(e)}}}}).connectCallback,t=t.taskOpt,U?U.addCallback(e):U=new ke(e),t&&U.addTaskConf(t)},publishSocketError:function(e){e&&this.publishErrorLog({msg:e.errMsg,level:b.WEBSOCKET_ERROR})}}),xe=new o({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;w.getPerformance&&w.getPerformance().createObserver(function(e){e=e.getEntries();null!=e&&e.forEach(function(e){"number"!=typeof e.duration||e.duration<=0||t.publishAssetLog(e)})}).observe({entryTypes:["resource"]})},generateLog:function(e){return{url:(t=e.uri,void 0===n&&(n=2048),String(t).slice(0,n)),method:"get",duration:Math.round(100*e.duration)/100,status:200,type:"static",isHttps:!0,urlQuery:p(e.uri,!0),nextHopProtocol:"",domainLookup:0,connectTime:0};var t,n},publishAssetLog:function(t){var n=this;this.$walk(function(e){e.speedLogPipeline(n.generateLog(t))})}}),Ce=["onLaunch","onHide","onError","onLoad","onReady","onShow","onUnload"],Ne=new o({name:"pagePerformance",pageNavigationStartTime:{},onNewAegis:function(e){try{l("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(u){var c=this,e=w.getPerformance(),e=null==e?void 0:e.createObserver(function(e){var t={},n=null==(n=e.getEntriesByName("appLaunch"))?void 0:n[0],i=null==(i=e.getEntriesByName("firstRender"))?void 0:i[0],o=null==(o=e.getEntriesByName("evaluateScript"))?void 0:o[0],r=null==(r=e.getEntriesByName("route"))?void 0:r[0],a=null==(a=null==(a=e.getEntriesByName("firstPaint"))?void 0:a[0])?void 0:a.startTime,s=null==(s=(null==(s=e.getEntriesByName("firstPaint"))?void 0:s[0])||(null==(s=e.getEntriesByName("route"))?void 0:s[0])||(null==(s=e.getEntriesByName("appLaunch"))?void 0:s[0]))?void 0:s.pageId,l=null==(e=(null==(l=e.getEntriesByName("route"))?void 0:l[0])||(null==(l=e.getEntriesByName("appLaunch"))?void 0:l[0]))?void 0:e.startTime;s&&(c.pageNavigationStartTime[s]=null,l)&&(c.pageNavigationStartTime[s]=l),n&&(t.appLaunch=n.duration),i&&(t.firstScreenTiming=i.duration),o&&(t.scriptEvaluateTiming=o.duration),r&&(t.pageRouteTiming=r.duration),a&&l?t.firstPaintTiming=Math.max(a-l,0):a&&c.pageNavigationStartTime[s]&&(t.firstPaintTiming=Math.max(a-c.pageNavigationStartTime[s],0)),c.publish(t,u)});null!=e&&e.observe({entryTypes:["navigation","render","script"]})},publish:function(t,n){var e,i,o,r=[],a=n.config,s=-1===(null==(e=n.config.performanceUrl)?void 0:e.indexOf("?"))?"?":"&";for(i in t)r.push(i+"="+t[i]);"function"==typeof a.urlHandler?(o=a.urlHandler()||window.location.href,this.$walk(function(e){e.send({url:n.config.performanceUrl+s+r.join("&")+"&from="+encodeURIComponent(o),beanFilter:["from"],type:O.PERFORMANCE,log:t})})):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+r.join("&"),type:O.PERFORMANCE,log:t})})},setPagePV:function(e){var t=this;w.onAppRoute&&w.onAppRoute(function(e){"appLaunch"!==e.openType&&(t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:O.PV})}),t.reportPageLoaded(e))})},reportPageLoaded:function(e){e="infoType: behaviorBacktracking\ndataType: pageLoadAndRoute\npageLoadedPath: "+e.path+"\nopenType: "+e.openType;this.publishNormalLog({msg:e,level:b.INFO})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},reportSetDataTiming:function(t){var e,o,r,a,n,s,l,u,c,f=this,i=t.config.setDataReportConfig,i=void 0===i?{}:i;!0!==i.disabled&&(e=i.timeThreshold,o=!1!==i.withDataPaths,r=e&&0<+e?+e:30,a=v([y(t,10),function(e){e=e.map(function(e){return{type:O.SET_DATA,component:e.from,duration:e.duration,fields:e.dataPaths&&e.dataPaths.length?e.dataPaths.sort().join(";"):void 0,size:e.size}});t.send({url:t.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:e})),type:O.SET_DATA,log:e})}]),n=Page,s=Component,l=function(r,e){var a=0;return null!=r&&r.data?(e.forEach(function(e){for(var t=r.data[e[0]],n=1,i=e.length;n<i;n++)t[e[n]]&&(t=t[e[n]]);var o="";try{o=JSON.stringify(t)}catch(e){o=""}a+=2*(void 0===o?"":o).replace(/[\u4e00-\u9fa5]/g,"aa").length}),a=Math.min(a,10485760)):a},u=function(e,t){var n=t.updateStartTimestamp,i=t.updateEndTimestamp,t=t.dataPaths,t=void 0===t?[]:t,i=i-n;isNaN(i)||i<r||(n={from:e.is,duration:i},o&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30),size:l(e,t)}),a(n))},c=function(i){var e="infoType: behaviorBacktracking\ndataType: tapEvent"+Object.keys(i[0]).reduce(function(e,t){var n="";try{n=t+": "+JSON.stringify(i[0][t])}catch(e){n=""}return e+"\n"+n},"");f.publishNormalLog({msg:e,level:b.INFO})},Page=function(t){var e=t.onReady;return t.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){u(t,e)}),null==e?void 0:e.call(this)},Object.keys(t).forEach(function(e){var n;"function"!=typeof t[e]||Ce.includes(e)||(n=t[e],t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null!=e&&e[0]&&"tap"===e[0].type&&c(e),null==n?void 0:n.apply(this,e)})}),n(t)},Component=function(e){e.lifetimes&&e.lifetimes.attached?(n=e.lifetimes.attached,e.lifetimes.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){u(t,e)}),null==n?void 0:n.call(this)}):(i=e.attached,e.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){u(t,e)}),null==i?void 0:i.call(this)});var n,i,t=e.methods;return t&&"[object Object]"===Object.prototype.toString.call(t)&&Object.keys(t).forEach(function(e){var n;"function"==typeof t[e]&&(n=t[e],t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null!=e&&e[0]&&"tap"===e[0].type&&c(e),null==n?void 0:n.apply(this,e)})}),s(e)})}}),o=new o({name:"reportLoadPackageSpeed",isLoaded:!1,onNewAegis:function(e){this.isLoaded||(this.isLoaded=!0,this.start(e))},start:function(){var t=this;w.getPerformance&&w.getPerformance().createObserver(function(e){e=e.getEntries();null!=e&&e.forEach(function(e){"number"!=typeof e.duration||e.duration<=0||t.publishPackageLog(e)})}).observe({entryTypes:["loadPackage"]})},generateLog:function(e){return[{type:O.LOAD_PACKAGE,packageName:e.packageName,size:Math.round(100*e.packageSize)/100,duration:Math.round(100*e.duration)/100}]},publishPackageLog:function(n){var i=this;this.$walk(function(e){var t=i.generateLog(n);e.send({url:e.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:t})),type:O.LOAD_PACKAGE,log:t})})}});function _(e){e=Re.call(this,e)||this;return e.taskHack=new Te,e}function Le(){this.onErrors=[],this.sends=[]}return n.use(r),n.use(we),n.use(he),n.use(xe),n.use(Ne),n.use(o),n.use(pe),n});

}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1704883497559);
})()
//miniprogram-npm-outsideDeps=[]
//# sourceMappingURL=index.js.map