anys-web 1.3.0 → 1.4.1
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/cjs/index.js +32 -8
- package/cjs/recorder-plugin.js +45 -38
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/index.js +11 -1
- package/src/recorder-plugin.js +1 -5
package/cjs/index.js
CHANGED
|
@@ -6,13 +6,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.create = void 0;
|
|
7
7
|
var _anys = require("anys");
|
|
8
8
|
var _recorderPlugin = require("./recorder-plugin.js");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
|
15
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
+
let RecorderAnys = /*#__PURE__*/function (_Anys) {
|
|
17
|
+
_inheritsLoose(RecorderAnys, _Anys);
|
|
18
|
+
function RecorderAnys() {
|
|
19
|
+
return _Anys.apply(this, arguments) || this;
|
|
16
20
|
}
|
|
17
|
-
|
|
21
|
+
var _proto = RecorderAnys.prototype;
|
|
22
|
+
/**
|
|
23
|
+
* patch auth info into reportParams
|
|
24
|
+
* @param {object} info
|
|
25
|
+
*/
|
|
26
|
+
_proto.auth = function auth(info) {
|
|
27
|
+
this.options.reportParams = Object.assign(this.options.reportParams || {}, info);
|
|
28
|
+
};
|
|
29
|
+
return RecorderAnys;
|
|
30
|
+
}(_anys.Anys);
|
|
31
|
+
const create = function () {
|
|
32
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
33
|
+
return new RecorderAnys(_objectSpread(_objectSpread({
|
|
34
|
+
namespace: 'AnysTracer',
|
|
35
|
+
autoReport: false
|
|
36
|
+
}, options), {}, {
|
|
37
|
+
plugins: _objectSpread(_objectSpread({}, options.plugins || {}), {}, {
|
|
38
|
+
recorder: _recorderPlugin.AnysRecorderPlugin
|
|
39
|
+
})
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
18
42
|
exports.create = create;
|
package/cjs/recorder-plugin.js
CHANGED
|
@@ -16,12 +16,16 @@ var _anysWebPluginStoreOffline = require("anys-web-plugin-store-offline");
|
|
|
16
16
|
var _anysWebPluginMonitorDomMutation = require("anys-web-plugin-monitor-dom-mutation");
|
|
17
17
|
var _anysWebPluginMonitorWindowSize = require("anys-web-plugin-monitor-window-size");
|
|
18
18
|
var _anysWebPluginMonitorScrollEvent = require("anys-web-plugin-monitor-scroll-event");
|
|
19
|
+
const _excluded = ["_id"];
|
|
20
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
19
22
|
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
|
20
23
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
24
|
let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
22
25
|
_inheritsLoose(AnysRecorderPlugin, _AnysPlugin);
|
|
23
|
-
function AnysRecorderPlugin(anys,
|
|
26
|
+
function AnysRecorderPlugin(anys, _ref) {
|
|
24
27
|
var _this;
|
|
28
|
+
let [offlineStore, urlMonitor, windowSizeMonitor, DOMMutationMonitor] = _ref;
|
|
25
29
|
_this = _AnysPlugin.call(this, anys) || this;
|
|
26
30
|
_this.offlineStore = offlineStore;
|
|
27
31
|
_this.urlMonitor = urlMonitor;
|
|
@@ -48,14 +52,16 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
48
52
|
};
|
|
49
53
|
};
|
|
50
54
|
_proto.registerAutoReport = function registerAutoReport() {
|
|
55
|
+
var _this2 = this;
|
|
51
56
|
const {
|
|
52
57
|
clientId
|
|
53
58
|
} = this.anys;
|
|
54
|
-
const autoReportWhenRefreshTraceId = ({
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
const autoReportWhenRefreshTraceId = function (_ref2) {
|
|
60
|
+
let {
|
|
61
|
+
prev
|
|
62
|
+
} = _ref2;
|
|
57
63
|
// report previous trace logs
|
|
58
|
-
|
|
64
|
+
_this2.anys.report([{
|
|
59
65
|
key: 'client',
|
|
60
66
|
value: clientId
|
|
61
67
|
}, {
|
|
@@ -64,44 +70,45 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
64
70
|
}]);
|
|
65
71
|
|
|
66
72
|
// clear cache
|
|
67
|
-
|
|
73
|
+
_this2.cache = {};
|
|
68
74
|
|
|
69
75
|
// record new information
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
_this2.urlMonitor.recordUrl();
|
|
77
|
+
_this2.windowSizeMonitor.recordSize();
|
|
78
|
+
_this2.DOMMutationMonitor.recordSnapshot();
|
|
73
79
|
};
|
|
74
80
|
this.anys.on('refreshTraceId', autoReportWhenRefreshTraceId);
|
|
75
|
-
const timer = setInterval(()
|
|
76
|
-
|
|
81
|
+
const timer = setInterval(function () {
|
|
82
|
+
_this2.anys.report();
|
|
77
83
|
}, this.anys.options.reportInterval);
|
|
78
84
|
let isUnloaded = 0;
|
|
79
|
-
const sendBeaconWhenBeforeUnload = ()
|
|
85
|
+
const sendBeaconWhenBeforeUnload = function () {
|
|
80
86
|
if (isUnloaded) {
|
|
81
87
|
return;
|
|
82
88
|
}
|
|
83
89
|
isUnloaded = 1;
|
|
84
|
-
const ids = Object.keys(
|
|
85
|
-
const logs = Object.values(
|
|
90
|
+
const ids = Object.keys(_this2.cache);
|
|
91
|
+
const logs = Object.values(_this2.cache);
|
|
86
92
|
if (ids.length) {
|
|
87
|
-
|
|
88
|
-
navigator.sendBeacon(
|
|
89
|
-
|
|
93
|
+
_this2.offlineStore.remove(ids); // async may not executed
|
|
94
|
+
navigator.sendBeacon(_this2.anys.options.reportUrl, JSON.stringify(logs));
|
|
95
|
+
_this2.cache = {};
|
|
90
96
|
}
|
|
91
97
|
};
|
|
92
98
|
window.addEventListener('beforeunload', sendBeaconWhenBeforeUnload);
|
|
93
99
|
window.addEventListener('pagehide', sendBeaconWhenBeforeUnload); // 兼容微信浏览器
|
|
94
100
|
window.addEventListener('unload', sendBeaconWhenBeforeUnload);
|
|
95
|
-
const addCacheWhenWriteLog = ({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
const addCacheWhenWriteLog = function (_ref3) {
|
|
102
|
+
let {
|
|
103
|
+
id,
|
|
104
|
+
data
|
|
105
|
+
} = _ref3;
|
|
106
|
+
_this2.cache[id] = data;
|
|
100
107
|
};
|
|
101
108
|
this.anys.on('writeOfflineLog', addCacheWhenWriteLog);
|
|
102
|
-
return ()
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
return function () {
|
|
110
|
+
_this2.anys.off('refreshTraceId', autoReportWhenRefreshTraceId);
|
|
111
|
+
_this2.anys.off('writeOfflineLog', addCacheWhenWriteLog);
|
|
105
112
|
// @ts-ignore
|
|
106
113
|
clearInterval(timer);
|
|
107
114
|
window.removeEventListener('beforeunload', sendBeaconWhenBeforeUnload);
|
|
@@ -117,23 +124,24 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
117
124
|
return this.offlineStore.read(message);
|
|
118
125
|
};
|
|
119
126
|
_proto.send = function send(logs) {
|
|
127
|
+
var _this3 = this;
|
|
120
128
|
const groups = [];
|
|
121
129
|
let i = 0;
|
|
122
|
-
logs.forEach(item
|
|
130
|
+
logs.forEach(function (item) {
|
|
123
131
|
groups[i] = groups[i] || [];
|
|
124
132
|
groups[i].push(item);
|
|
125
133
|
if (groups[i].length > 200) {
|
|
126
134
|
i++;
|
|
127
135
|
}
|
|
128
136
|
});
|
|
129
|
-
const defers = groups.map(data
|
|
137
|
+
const defers = groups.map(function (data) {
|
|
130
138
|
const items = [];
|
|
131
139
|
const ids = [];
|
|
132
|
-
data.forEach(item
|
|
140
|
+
data.forEach(function (item) {
|
|
133
141
|
const {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
_id
|
|
143
|
+
} = item,
|
|
144
|
+
info = _objectWithoutProperties(item, _excluded);
|
|
137
145
|
ids.push(_id);
|
|
138
146
|
items.push(info);
|
|
139
147
|
});
|
|
@@ -143,11 +151,13 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
143
151
|
const {
|
|
144
152
|
reportUrl,
|
|
145
153
|
reportParams
|
|
146
|
-
} =
|
|
154
|
+
} = _this3.anys.options;
|
|
147
155
|
const url = reportParams ? (0, _anysShared.replaceUrlSearch)(reportUrl, reportParams) : reportUrl;
|
|
148
|
-
return (0, _anysShared.ajaxPost)(url,
|
|
149
|
-
|
|
150
|
-
|
|
156
|
+
return (0, _anysShared.ajaxPost)(url, {
|
|
157
|
+
data: items
|
|
158
|
+
}).then(function () {
|
|
159
|
+
ids.forEach(function (id) {
|
|
160
|
+
delete _this3.cache[id];
|
|
151
161
|
});
|
|
152
162
|
});
|
|
153
163
|
});
|
|
@@ -156,9 +166,6 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
156
166
|
_proto.clear = function clear() {
|
|
157
167
|
this.cache = {};
|
|
158
168
|
};
|
|
159
|
-
_proto.auth = function auth(info) {
|
|
160
|
-
this.anys.options.reportParams = Object.assign(this.anys.options.reportParams || {}, info);
|
|
161
|
-
};
|
|
162
169
|
return AnysRecorderPlugin;
|
|
163
170
|
}(_anysShared.AnysPlugin);
|
|
164
171
|
exports.AnysRecorderPlugin = AnysRecorderPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";function n(e){return Array.isArray(e)}function r(e,t){return"function"==typeof e&&(!t||!function(e,t){if("function"!=typeof e)return!1;if(e===Symbol)return!1;if(!e.prototype)return!1;const n=e+"",r=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim(),o=0===n.indexOf("class "),i="[native code]"===r,s=o||i;if(t>=4)return s;const c=r.replace(/function.*?\{.*?\}/gm,"").replace(/return/gm,"").replace(/\n+/gm,";").replace(/\s+/gm,"").replace(/;;/gm,";"),a=/^_classCallCheck\(this,/.test(c),u=/^\(.*?_classCallCheck.*?\)\(this,/.test(c),h=/^[0-9a-zA-Z_;!?:]*?\(this,/.test(c),d=s||a||u||h;if(3==t)return d;const l=Object.getOwnPropertyDescriptors(e.prototype),p=!!Object.keys(l).filter((e=>"constructor"!==e)).length,f=d||p;if(2==t)return f;const m=0===c.indexOf("this.")||c.indexOf(";this.")>-1||c.indexOf("=this;")>-1,y=f||m;if(1==t)return y;return!0}(e,2))}function o(e=16){const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ";let n="";for(let r=0;r<e;r++)n+=t.charAt(Math.floor(Math.random()*t.length));return n}function i(e,t,r){return r?(()=>{const n=Object.getOwnPropertyDescriptors(e);Object.keys(n).forEach((r=>{const o=n[r],{get:i,set:s,enumerable:c,configurable:a,writable:u}=o;(c||i||s||a&&u)&&t(o,r,e)}))})():(()=>{if(n(e))e.forEach(t);else{Object.keys(e).forEach((n=>{const r=e[n];t(r,n,e)}))}})()}e.r(t),e.d(t,{create:()=>X});Symbol("Proxy");let s=function(){function e(t){this.$events=[],this.$queue=[];const s=(c=this,Object.getPrototypeOf(c).constructor);var c;const{filters:a=[],plugins:u=[],...h}={...e.defaultOptions,...s.defaultOptions||{}},{filters:d=[],plugins:l=[],defines:p=[],...f}=t||{},m={},y=[],v={},g=l&&!n(l)&&"object"==typeof l,b=g?Object.values(l):n(l)?l:[],w=g?Object.keys(l).map((e=>({key:e,value:l[e]}))):[],O=[...u,...b],E=e=>{e.forEach((e=>{const t=e.dependencies||[];t.forEach((e=>{O.unshift(e)})),E(t)}))};E(O);const _=O.filter(((e,t)=>t===O.indexOf(e))),j=[],L={};_.forEach((e=>{const t=w.find((t=>t.value===e))?.key;if(t&&L[t])return void(t=>{const n=`[Anys]: plugin named '${t}' has been registered`;L[t]instanceof e?console.debug(n,e,L):console.error(n,e,L)})(t);const n=(e.dependencies||[]).map((e=>j.find((t=>t instanceof e)))),r=new e(this,n);r.options&&Object.assign(m,r.options()),r.defines&&Object.assign(v,r.defines()),r.filters&&y.push(...r.filters()),j.push(r),t&&(L[t]=r)})),this.$plugins=j,this.plugins=L,this.options={...h,...m,...f},this.filters=[...a,...y,...d];const P=Object.values(this.options).find((e=>e&&e instanceof Error));if(P)throw P;const x={...v,...p};this.definitions=x,this.clientId=x.client?x.client():o(8),this.traceId=x.trace?x.trace():o(8),this.requestId=o(8);const I={};Object.defineProperties(I,function(e,t){if(n(e))return e.map(t);{const n={};return i(e,((r,o)=>{n[o]=t(r,o,e)})),n}}(x,(e=>({get:r(e)?e:()=>e,enumerable:!0,configurable:!0})))),Object.defineProperties(I,{client:{get:()=>this.clientId,enumerable:!0,configurable:!0},trace:{get:()=>this.traceId,enumerable:!0,configurable:!0},request:{get:()=>this.requestId,enumerable:!0,configurable:!0}}),this.$basicLog=I,this.invoke("init"),this.options.autoStart&&this.start()}var t=e.prototype;return t.define=function(e,t){Object.defineProperty(this.$basicLog,e,{get:t,enumerable:!0,configurable:!0})},t.on=function(e,t){this.$events.push([e,t])},t.off=function(e,t){this.$events.forEach(((n,r)=>{n[0]===e&&n[1]===t&&this.$events.splice(r,1)}))},t.emit=function(e,...t){this.$events.forEach((n=>{n[0]!==e&&"*"!==n[0]||n[1](...t)}))},t.invoke=function(e,...t){for(let n=0,o=this.$plugins.length;n<o;n+=1){const o=this.$plugins[n];o[e]&&(r(o[e])&&o[e](...t))}},t.refreshTraceId=function(){const e=this.traceId;this.traceId=this.definitions.trace?this.definitions.trace():o(8),this.emit("refreshTraceId",{prev:e,next:this.traceId})},t.refreshRequestId=function(){const e=this.requestId;this.requestId=o(8),this.emit("refreshRequestId",{prev:e,next:this.requestId})},t.start=function(){this.invoke("start"),this.emit("start")},t.write=function(e){setTimeout((()=>{const t={...this.$basicLog,...e},{filters:n}=this;for(let e=0,r=n.length;e<r;e+=1){if(!(0,n[e])(t))return}this.invoke("write",t),this.emit("write",t)}),0)},t.report=function(e){let t,o;const i=new Promise(((e,n)=>{t=e,o=n})),s={message:e,resolve:t,reject:o};this.$queue.push(s),this._reporting=!1;const c=()=>setTimeout((()=>{if(this._reporting)return;this._reporting=!0;const e=this.$queue.shift();if(!e)return;const{message:t,resolve:o,reject:i}=e;this.emit("report",t);const s=[];for(let e=0,t=this.$plugins.length;e<t;e+=1){const t=this.$plugins[e],n={};let o=0;r(t.read)&&(n.read=t.read.bind(t),o=1),r(t.send)&&(n.send=t.send.bind(t),o=1),r(t.clear)&&(n.clear=t.clear.bind(t),o=1),o&&s.push(n)}const a=(e,...t)=>Promise.resolve().then((()=>r(e)?e(...t):null));((...e)=>e.reduce(((e,t)=>r(t)?e.then(t):e),Promise.resolve()))((()=>Promise.all(s.map((e=>a(e.read,t).then((t=>(e.data=t,t))))))),(e=>{const t=[];return e.forEach((e=>{n(e)&&e.length&&t.push(...e)})),this.emit("read",t),t}),(e=>{if(e.length)return this.emit("send",e),Promise.all(s.map((t=>a(t.send,t.data,e)))).then((()=>e))}),(e=>{if(e)return this.emit("clear",e),Promise.all(s.map((e=>a(e.clear,e.data))))})).then(o,i).finally((()=>{this._reporting=!1,c()}))}),0);return c(),i},t.stop=function(){this.invoke("stop"),this.emit("stop")},e}();function c(e,t){if(e.indexOf("?")<0){const n=Object.keys(t).map((e=>`${e}=${t[e]}`)).join("&"),[r,o]=e.split("#");return r+"?"+n+(o?"#"+o:"")}const[n,r]=e.split("?"),[o,i]=r.split("#"),s=o.split("&").map((e=>e.split("="))).reduce(((e,[t,n])=>({...e,[t]:n})),{});Object.assign(s,t);return n+"?"+Object.keys(s).map((e=>`${e}=${s[e]}`)).join("&")+(i?"#"+i:"")}s.defaultOptions={autoStart:!0};let a=function(){function e(e){this.anys=e,this.$effects={}}var t=e.prototype;return t.start=function(){if(!this.options)return;const e=this.options(),t=Object.keys(e),n=e=>{const t=`register${e.replace(e[0],e[0].toUpperCase())}`;if(this[t]){const n=this[t]();this.$effects[e]=n}},r=this.anys.options;t.forEach((e=>{r[e]&&n(e)}))},t.stop=function(){if(!this.options)return;const e=this.options(),t=Object.keys(e),n=this.anys.options;t.forEach((e=>{const t=this.$effects[e];n[e]&&t&&t(),this.$effects[e]=null}))},e}(),u=function(){function e(){this.$events=[]}var t=e.prototype;return t.on=function(e,t){this.$events.push([e,t])},t.emit=function(e,...t){this.$events.forEach((([n,r])=>{e===n&&r(...t)}))},t.off=function(e,t){this.$events.forEach((([n,r],o)=>{e===n&&r===t&&this.$events.splice(o,1)}))},e}();function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}const d=new u;!function(){const e=window.XMLHttpRequest;window.__XMLHttpRequest=e,window.XMLHttpRequest=function(){const t=new e,n={open:t.open,send:t.send},r={name:o(4)},i=e=>{const{name:n,url:o,method:i}=r;let s,c;t.responseType&&"text"!==t.responseType?"json"===t.responseType&&(s=t.response,c="json"):(s=t.responseText.toString(),c="text"),d.emit("xhr",{type:e,time:Date.now(),name:`xhr_${n}`,url:o,detail:{status:t.status,method:i,responseType:c,response:s||void 0}})},s=()=>{4===t.readyState&&(2===Math.floor(t.status/100)?i("xhr.ok"):i("xhr.fail"))};return Object.defineProperty(t,"open",{get:()=>(e,o,i=!0,...s)=>{const c={method:e,url:o};d.emit("request",c),Object.assign(r,{...c,async:i}),t.onreadystatechange&&(n.onreadystatechange=t.onreadystatechange);const{open:a}=n;return a.call(t,c.method,c.url,i,...s)},configurable:!0}),Object.defineProperty(t,"send",{get:()=>e=>{const{send:o}=n,{async:i}=r;Object.assign(r,{body:e}),(()=>{const{name:e,url:t,method:n,async:o,body:i}=r;d.emit("xhr",{type:"xhr.req",time:Date.now(),name:`xhr_${e}`,url:t,detail:{method:n,async:o,body:i}})})();const c=o.call(t,e);return i||s(),c},configurable:!0}),t.addEventListener("error",(()=>{i("xhr.err")})),t.addEventListener("readystatechange",(e=>{s()})),t}}(),function(){const e=window.fetch;window.__fetch=e,window.fetch=function(t,n={}){const{method:r,body:i}=n,s=o(4);d.emit("fetch",{type:"fetch.init",time:Date.now(),name:`fetch_${s}`,url:t,detail:{body:i,method:r}});const c={method:r,url:t};return d.emit("request",c),Promise.resolve().then((()=>e(c.url,n))).then((e=>{const{status:n}=e;return 2===Math.floor(n/100)?new Proxy(e,{get:(o,i)=>"json"===i||"text"===i?()=>e[i]().then((e=>(d.emit("fetch",{type:"fetch.ok",time:Date.now(),name:`fetch_${s}`,url:t,detail:{status:n,data:e,method:r}}),e))):"function"==typeof e[i]?e[i].bind(e):e[i]}):(d.emit("fetch",{type:"fetch.fail",time:Date.now(),name:`fetch_${s}`,url:t,detail:{status:n,method:r}}),e)}),(e=>{let n;if(e instanceof Error){const{name:t,message:o}=e;n={method:r,type:t,err:o}}else n={method:r,err:e};d.emit("fetch",{type:"fetch.err",time:Date.now(),name:`fetch_${s}`,url:t,detail:n})}))}}();let l=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,h(t,n);var o=r.prototype;return o.options=function(){return{xhr:!0,fetch:!0,ajaxResponse:!0,patchRequestId:!0}},o.registerXhr=function(){const e=e=>{this.anys.options.ajaxResponse||"xhr.ok"!==e.type||delete e.detail.response,this.anys.write(e)};return d.on("xhr",e),()=>d.off("xhr",e)},o.registerFetch=function(){const e=e=>{this.anys.options.ajaxResponse||"fetch.ok"!==e.type||delete e.detail.data,this.anys.write(e)};return d.on("fetch",e),()=>d.off("fetch",e)},o.registerPatchRequestId=function(){const e=e=>{const{url:t}=e,{traceId:n,requestId:r}=this.anys,o=c(t,{_request_id:n+r});e.url=o};return d.on("request",e),()=>d.off("request",e)},r}(a),p=function(){function e(e){this.anys=e}var t=e.prototype;return t.options=function(){return{namespace:new Error("[Anys]: options.namespace is required!")}},t.defines=function(){return{client:this.defineClientId.bind(this),trace:this.defineTraceId.bind(this)}},t.defineClientId=function(){const{namespace:e}=this.anys.options,t=`Anys.${e}.clientId`;let n=localStorage.getItem(t);return n||(n=o(8),sessionStorage.setItem(t,n)),n},t.defineTraceId=function(){const{namespace:e}=this.anys.options,t=`Anys.${e}.traceId`,n=o(8);return sessionStorage.setItem(t,n),n},e}();function f(e,t=document.documentElement){const{nodeName:n,path:r}=e;if(r)return r;if("BODY"===n||"HTML"===n||"HEAD"===n)return n;const o=[];let i=e,s=e.parentNode;const c=e=>{const{nodeName:t,parentNode:n}=e;if(!n)return-1;return[].filter.call(n.childNodes,(e=>e.nodeName===t)).indexOf(e)};if("#"===n[0]){const t=c(e);o.push(`${n}:${t}`),i=s,s=i.parentNode}for(;s&&i!==t;){const{nodeName:e}=i;if("BODY"===e||"HTML"===e||"HEAD"===e)o.push(e);else{const t=c(i);o.push(`${e.toLowerCase()}:${t}`)}i=s,s=i.parentNode}return o.reverse(),o.join("/")}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}let y=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,m(t,n);var o=r.prototype;return o.options=function(){return{input:!0}},o.registerInput=function(){const e=e=>t=>{const{target:n,type:r,inputType:o,data:i}=t;if("insertCompositionText"===o)return;if("compositionend"===r&&!i)return;const{tagName:s,value:c}=n;if(n.getAttribute("anys-ignore"))return;const a=n.getAttribute("type"),u=e({tagName:s,value:c,type:a,target:n});if(!u)return;const h={type:"input",time:Date.now(),el:f(n),detail:u};this.anys.write(h)},t=e((({tagName:e,value:t,type:n})=>"INPUT"===e&&"radio"!==n&&"checkbox"!==n&&"password"!==n?{value:t,type:n}:"INPUT"===e&&"password"===n?{value:"***",type:n}:"TEXTAREA"===e?{value:t,type:"textarea"}:void 0)),n=e((({tagName:e,value:t,type:n})=>"SELECT"===e?{value:t,type:"select"}:"INPUT"!==e||"radio"!==n&&"checkbox"!==n?void 0:{value:t,type:n})),r=e((({tagName:e,value:t,type:n})=>"TEXTAREA"===e?{value:t,type:"textarea"}:"INPUT"===e?{value:t,type:n}:void 0));return document.addEventListener("input",t,!0),document.addEventListener("compositionend",t,!0),document.addEventListener("change",n,!0),document.addEventListener("paste",r,!0),()=>{document.removeEventListener("input",t),document.removeEventListener("compositionend",t),document.removeEventListener("change",n),document.removeEventListener("paste",r)}},r}(a);function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}let g=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,v(t,n);var o=r.prototype;return o.options=function(){return{mouse:!("ontouchend"in document),click:!0,mousemove:!1,mousedown:!1,mouseup:!1,wheel:!1,contextmenu:!1}},o.addEventListener=function(e,t){if(!this.anys.options.mouse)return;const n=this.createThrottleListener((t=>{const{innerWidth:n,innerHeight:r}=window,{target:o,button:i,pageX:s,pageY:c}=t;return{type:e,time:Date.now(),detail:{e:f(o),w:n,h:r,x:s,y:c,button:i}}}),t);return document.addEventListener(e,n,!0),()=>document.removeEventListener(e,n)},o.registerClick=function(){return this.addEventListener("click")},o.registerMouseup=function(){return this.addEventListener("mouseup")},o.registerMousedown=function(){return this.addEventListener("mousedown")},o.registerContextmenu=function(){return this.addEventListener("contextmenu")},o.registerMousemove=function(){return this.addEventListener("mousemove",100)},o.registerWheel=function(){if(!this.anys.options.mouse)return;const e="wheel",t=this.createThrottleListener((t=>{const{target:n,deltaX:r,deltaY:o,deltaZ:i,deltaMode:s}=t;return{type:e,time:Date.now(),detail:{e:f(n),deltaX:r,deltaY:o,deltaZ:i,mode:s}}}),100);return document.addEventListener(e,t),()=>document.removeEventListener(e,t)},o.createThrottleListener=function(e,t){let n=0,r=0;return o=>{if(n)return;const i=Date.now();if(t&&r+t>i)return;const s=e(o);requestAnimationFrame((()=>{this.anys.write(s),n=0,r=Date.now()})),n=1}},r}(a);function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}const w={type:"window_activity.enter",time:Date.now()};let O=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,b(t,n);var o=r.prototype;return o.options=function(){return{activity:!0,deadTimeout:0}},o.init=function(){this.anys.options.activity&&this.anys.write(w)},o.registerActivity=function(){const e=()=>{if("hidden"===document.visibilityState){const e={type:"window_activity.focusout",time:Date.now()};this.anys.write(e)}else{const e={type:"window_activity.focusin",time:Date.now()};this.anys.write(e)}},t=()=>{const e={type:"window_activity.unload",time:Date.now()};this.anys.write(e)};return window.addEventListener("beforeunload",t,!0),document.addEventListener("visibilitychange",e,!0),()=>{window.removeEventListener("beforeunload",t),document.removeEventListener("visibilitychange",e)}},o.registerDeadTimeout=function(){const{deadTimeout:e}=this.anys.options;if(!e)return;let t;const n=()=>{clearTimeout(t),t=setTimeout((()=>{const e={type:"window_activity.dead",time:Date.now()};this.anys.write(e)}),e)};return document.addEventListener("keydown",n,!0),document.addEventListener("mousedown",n,!0),document.addEventListener("touchstart",n,!0),document.addEventListener("touchmove",n,!0),document.addEventListener("mousemove",n,!0),document.addEventListener("scroll",n,!0),window.addEventListener("resize",n,!0),()=>{document.removeEventListener("keydown",n),document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n),document.removeEventListener("touchmove",n),document.removeEventListener("mousemove",n),document.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},r}(a);function E(e,t){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},E(e,t)}let _=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,E(t,n);var o=r.prototype;return o.options=function(){return{url:!0}},o.registerUrl=function(){const e=()=>{this.recordUrl()};return window.addEventListener("hashchange",e),window.addEventListener("popstate",e),this.recordUrl(),()=>{window.removeEventListener("hashchange",e),window.removeEventListener("popstate",e)}},o.recordUrl=function(){const e=window.location.href,t=new URL(e),n=t.pathname.replace(/^([^/])/,"/$1"),r={type:"url",time:Date.now(),url:e,detail:{uri:n+(t.search?`?${t.search}`:""),path:n,protocol:t.protocol.replace(":",""),host:t.hostname,port:t.port,search:t.search,hash:t.hash.replace("#","")}};this.anys.write(r)},r}(a);function j(e,t){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},j(e,t)}let L=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,j(t,n);var o=r.prototype;return o.options=function(){const e="ontouchend"in document;return{touch:e,touchstart:e,touchend:e,touchmove:e}},o.addEventListener=function(e){if(!this.anys.options.touch)return;let t=0;const n=n=>{if(t)return;const{innerWidth:r,innerHeight:o}=window,{target:i,identifier:s,force:c,pageX:a,pageY:u}=n,h={type:e,time:Date.now(),detail:{e:f(i),width:r,height:o,x:a,y:u,identifier:s,force:c}};requestAnimationFrame((()=>{this.anys.write(h),t=0})),t=1};return document.addEventListener(e,n,!0),()=>document.removeEventListener(e,n)},o.registerTouchmove=function(){return this.addEventListener("touchmove")},o.registerTouchend=function(){return this.addEventListener("touchend")},o.registerTouchstart=function(){return this.addEventListener("touchstart")},r}(a),P=function(){function e(){this.queue=[],this.status=0}return e.prototype.push=function(e){let t,n;const r=new Promise(((e,r)=>{t=e,n=r})),o={runner:e,resolve:t,reject:n};this.queue.push(o);const i=()=>{setTimeout((()=>{if(!this.queue.length)return void(this.status=0);const{runner:e,resolve:t,reject:n}=this.queue.shift();e().then(t,n).finally(i)}),0),this.status=1};return this.status||i(),r},e}(),x=function(){function e(e={}){let{name:t,version:n=1,stores:r}=e;const o=!t;t||(t="__indb__"),r&&Array.isArray(r)&&r.length||(r=[{name:"__indb__",isKv:!0}]),this.cache={},this.connection=null,this.name=t,this.version=n,this.stores=r;const i=indexedDB.open(t,n);if(i.onupgradeneeded=e=>{const t=e.target.result,n=Array.from(t.objectStoreNames),o=[];r.forEach((r=>{let i=null;if(n.indexOf(r.name)>-1)i=e.target.transaction.objectStore(r.name);else{const e=r.isKv?"key":r.primaryKeyPath,n=!r.isKv&&r.autoIncrement;i=t.createObjectStore(r.name,{keyPath:e,autoIncrement:n})}const s=i.indexNames;s&&s.length&&Array.from(s).forEach((e=>i.deleteIndex(e))),r.indexes&&r.indexes.length&&r.indexes.forEach((e=>{i.createIndex(e.name,e.keyPath||e.name,{unique:e.unique,multiEntry:Array.isArray(e.keyPath)})})),o.push(r.name)})),n&&n.forEach((e=>{-1===o.indexOf(e)&&t.deleteObjectStore(e)}))},i.onblocked=e=>{console.error(A(new Error("indexedDB "+t+" is blocked")))},o)return this.use(t)}var t=e.prototype;return t.connect=function(){return new Promise(((e,t)=>{const n=indexedDB.open(this.name,this.version);n.onerror=e=>{t(A(e))},n.onsuccess=t=>{e(t.target.result)}}))},t.use=function(e){const t=this.stores.find((t=>t.name===e));if(!t)throw new Error(`[InDB]: store ${e} is not existing.`);if(this.cache[e])return this.cache[e];const n=new I({db:this,store:t});return t.isKv&&Object.defineProperties(n,{key:{value:e=>n.keys().then((t=>t&&t[e]))},getItem:{value:e=>n.get(e).then((e=>e&&e.value))},setItem:{value:(e,t)=>n.put({key:e,value:t})},removeItem:{value:e=>n.delete(e)}}),this.cache[e]=n,n},t.close=function(){return this.cache=null,this.stores=null,this.connect().then((e=>{e.close()}))},e.deleteDatabase=function(e){return new Promise(((t,n)=>{const r=indexedDB.deleteDatabase(e);r.onsuccess=()=>{t()},r.onerror=e=>{n(e)}}))},e.databases=function(){return indexedDB.databases()},e}();let I=function(){function e(e={}){const{store:t,db:n}=e;if("object"!=typeof t||!t.name||"string"!=typeof t.name)throw new Error("[InDBStore]: options.store should be a store config object.");if(!(n instanceof x))throw new Error("[InDBStore]: options.db should be an instanceof InDB.");this.db=n,this.store=t,this.name=t.name,this.primaryKeyPath=t.isKv?"key":t.primaryKeyPath,this._queue=[]}var t=e.prototype;return t.transaction=function(e=!1){const t=()=>{const t=this.name,n=e?"readwrite":"readonly",r=this.db.connection;return(r?Promise.resolve(r):this.db.connect()).then((e=>{this.db.connection=e;const r=e.transaction(t,n),o=()=>{this.db.connection=null,this._queue.shift()};return r.oncomplete=o,r.onabort=o,r.onerror=o,r}))},n=this._queue[this._queue.length-1],r=n?n.then((()=>t())):t();return this._queue.push(r),r},t.objectStore=function(e=!1){const t=this.name;return this.transaction(e).then((e=>e.objectStore(t)))},t.cursor=function(e){const{index:t,range:n,direction:r,onTouch:o,onDone:i,onError:s,writable:c=!1}=e;return this.objectStore(c).then((e=>{const c=t?e.index(t):e,a=c.openCursor(n,r);a.onsuccess=e=>{const t=e.target.result;t?o(t,c):i(t,c)},a.onerror=e=>{s(A(e))}}))},t.request=function(e,t={}){const{writable:n=!1}=t;return new Promise(((t,r)=>{this.objectStore(n).then((n=>{const o=e(n);o.onsuccess=e=>{const n=e.target.result;t(n)},o.onerror=e=>{r(A(e))}}))}))},t.iterate=function(e,t={}){const{index:n,range:r,writable:o=!1,direction:i="next"}=t;return new Promise(((t,s)=>{this.cursor({index:n,range:r,writable:o,direction:i,onTouch:(n,r)=>{e(n,(()=>n.continue()),(()=>{r.transaction.commit(),t()}))},onDone:()=>{t()},onError:e=>{s(e)}})}))},t.batch=function(e,t={}){const{writable:n=!0}=t;return this.transaction(n).then((t=>{const n=this.name,r=[],o=t.objectStore(n);return e.forEach((e=>{const t=new Promise(((t,n)=>{const r=e(o);r.onsuccess=e=>{const n=e.target.result;t(n)},r.onerror=e=>{n(A(e))}}));r.push(t)})),Promise.all(r)}))},t.get=function(e){if(!Array.isArray(e))return this.request((t=>t.get(e)));const t=e.map((e=>t=>t.get(e)));return this.batch(t,{writable:!1})},t.keys=function(){const e=this.primaryKeyPath,t=[];return this.each((n=>{const r=q(n,e);t.push(r)})).then((()=>t))},t.all=function(){const e=[];return this.each((t=>{e.push(t)})).then((()=>e))},t.count=function(){return this.request((e=>e.count()))},t.each=function(e){return this.iterate(((t,n)=>{const r=t.value;e(r),n()}))},t.reverse=function(e){return this.iterate(((t,n)=>{const r=t.value;e(r),n()}),{direction:"prev"})},t.some=function(e=10,t=0){return new Promise(((n,r)=>{const o=[];let i,s=0,c=t,a=t+e;t<0&&(i="prev",e=Math.min(e,-t),c=-(t+e)||0,a=c+e),this.iterate(((e,t,n)=>{s<c?(s++,t()):s<a?(o.push(e.value),s++,t()):n()}),{direction:i}).then((()=>{t<0&&o.reverse(),n(o)})).catch(r)}))},t.first=function(){return this.some(1).then((e=>e[0]))},t.last=function(){return this.some(1,-1).then((e=>e[0]))},t.find=function(e,t){return this.request((n=>n.index(e).get(t)))},t.query=function(e,t,n){const r=function(){switch(n){case">":return IDBKeyRange.lowerBound(t,!0);case">=":return IDBKeyRange.lowerBound(t);case"<":return IDBKeyRange.upperBound(t,!0);case"<=":return IDBKeyRange.upperBound(t);case"%":case"!=":case"in":return;default:return IDBKeyRange.only(t)}}(),o=[];return new Promise(((i,s)=>{this.cursor({index:e,range:r,onTouch:(e,r)=>{const i=e.value,s=q(i,r.keyPath);"!="===n?s!==t&&o.push(i):"%"===n?"string"==typeof s&&s.indexOf(t)>-1&&o.push(i):"in"===n?Array.isArray(t)&&t.indexOf(s)>-1&&o.push(i):o.push(i),e.continue()},onDone:()=>{i(o)},onError:e=>{s(e)}})}))},t.select=function(...e){const t=this.store.indexes||[],n={};t.forEach((e=>{const{name:t,keyPath:r}=e;n[t]=r}));const r=function(e,t,n){if(void 0===e)return!1;switch(n){case">":return e>t;case">=":return e>=t;case"<":return e<t;case"<=":return e<=t;case"!=":return e!==t;case"%":return"string"==typeof e&&e.indexOf(t)>-1;case"in":return Array.isArray(t)&&t.indexOf(e)>-1;default:return e===t}},o=function(e,t,n){if(!t.length&&!n.length)return!1;for(let n=0,o=t.length;n<o;n++){const{keyPath:o,value:i,compare:s}=t[n],c=q(e,o);if(!r(c,i,s))return!1}if(!n.length)return!0;for(let t=0,o=n.length;t<o;t++){const{keyPath:o,value:i,compare:s}=n[t],c=q(e,o);if(r(c,i,s))return!0}return!1},i=[];e.forEach((e=>{const t=[],r=[];for(let o=0,i=e.length;o<i;o++){const{key:i,value:s,compare:c,optional:a}=e[o],u=n[i]||i;a?t.push({keyPath:u,value:s,compare:c}):r.push({keyPath:u,value:s,compare:c})}i.push([r,t])}));const s=[];return this.each((e=>{(e=>{for(let t=0,n=i.length;t<n;t++){const[n,r]=i[t];if(o(e,n,r))return!0}return!1})(e)&&s.push(e)})).then((()=>s))},t.add=function(e,t){if(Array.isArray(e)){const n=e;if(n.length<2)return this.add(e[0],t);const r=n.map((e=>n=>n.add(e,t)));return this.batch(r)}return e?this.request((n=>n.add(e,t)),{writable:!0}):Promise.resolve()},t.put=function(e,t){if(Array.isArray(e)){const n=e;if(n.length<2)return this.put(n[0],t);const r=n.map((e=>n=>n.put(e,t)));return this.batch(r)}return e?this.request((n=>n.put(e,t)),{writable:!0}):Promise.resolve()},t.delete=function(e){if(Array.isArray(e)){const t=e;if(t.length<2)return this.delete(t[0]);const n=t.map((e=>t=>t.delete(e)));return this.batch(n)}return e?this.request((t=>t.delete(e)),{writable:!0}):Promise.resolve()},t.remove=function(e){const t=this.primaryKeyPath;if(Array.isArray(e)){const n=e;if(n.length<2)return this.remove(n[0]);const r=n.map((e=>{const n=q(e,t);return e=>e.delete(n)}));return this.batch(r)}if(!e)return Promise.resolve();const n=q(e,t);return n?this.delete(n):Promise.resolve()},t.clear=function(){return this.request((e=>e.clear()),{writable:!0})},e}();function q(e,t){if(null==t)return;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++){const r=q(e,t[n]);if(void 0!==r)return r}return}let n=function(e){return e.toString().split(/\.|\[|\]/).filter((e=>!!e))}(t);if(!n.length)return e;let r=e;for(let e=0,t=n.length;e<t;e++){let t=n[e];if(void 0===r[t])return;r=r[t]}return r}function A(e){const{message:t}=e;return e.message=-1===t.indexOf("[IndexedDB]")?"[IndexedDB]: "+t:t,e}let D=function(){function e(e){this.anys=e}var t=e.prototype;return t.options=function(){return{namespace:new Error("[Anys]: options.namespace is required!"),autoReport:!1,expireTime:1728e5}},t.init=function(){const e="anyslogs",t=new x({name:this.anys.options.namespace,version:1,stores:[{name:e,primaryKeyPath:"_id",autoIncrement:!0}]});this.db=t.use(e),this.queue=new P;const{expireTime:n}=this.anys.options;if(n){let e=0;const t=setInterval((()=>{this.queue.push((()=>this.db.some(100,e))).then((r=>{if(!r.length)return void clearInterval(t);const o=Date.now(),i=[];r.forEach((e=>{const{_id:t,time:r}=e;o-r>n&&i.push(t)})),i.length&&this.queue.push((()=>this.db.delete(i))),e+=100,e-=i.length}))}),1e4)}},t.write=function(e){this.queue.push((()=>this.db.add(e))).then((t=>{this.anys.emit("writeOfflineLog",{id:t,data:e})}))},t.read=function(e){if(e){if(!Array.isArray(e))return;if(e.some((e=>!e.key)))return}else e=[{key:"client",value:this.anys.clientId},{key:"trace",value:this.anys.traceId}];return this.select(e)},t.clear=function(e){return this.queue.push((()=>this.db.remove(e))).catch((()=>{}))},t.select=function(e){return this.queue.push((()=>this.db.select(e)))},t.remove=function(e){return this.queue.push((()=>this.db.delete(e))).catch((()=>{}))},e}();function T(e,t){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},T(e,t)}let k=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,T(t,n);var o=r.prototype;return o.options=function(){return{mutation:!0}},o.registerMutation=function(){const e=this.createObserver((e=>{const t={type:"mutation",time:Date.now(),detail:e};this.anys.write(t)}));return window.addEventListener("load",(()=>{e.observe(document,{characterData:!0,attributes:!0,childList:!0,subtree:!0}),this.recordSnapshot(),$(document.documentElement)})),()=>{e.disconnect()}},o.recordSnapshot=function(){const e=function(){const{name:e,publicId:t,systemId:n}=document.doctype,r={name:e,publicId:t,systemId:n},o=S(document.documentElement.innerHTML),i={},s=document.querySelector("html");for(let{name:e,value:t}of s.attributes)i[e]=t;const c=function(){const e=document.querySelectorAll("input, textarea, select"),t=[];return Array.from(e).forEach((e=>{const n=f(e),r="password"===e.type?"***":e.value;t.push({el:n,value:r})})),t}();return{doctype:r,attrs:i,html:o,values:c}}(),t=window.location.href,n=new URL(t),r=n.pathname.replace(/^([^/])/,"/$1");this.anys.write({type:"snapshot",time:Date.now(),url:{uri:r+(n.search?`?${n.search}`:""),path:r,protocol:n.protocol.replace(":",""),host:n.hostname,port:n.port,search:n.search,hash:n.hash.replace("#","")},detail:e})},o.createObserver=function(e){const t=new MutationObserver((t=>{const n=[];[...t].reverse().forEach((e=>{const{type:t,target:r,attributeName:o,oldValue:i}=e;if(!(e=>{if(e.hasAttribute?.("anys-ignore"))return!0;let t=e.parentNode;for(;t;){if(t.hasAttribute?.("anys-ignore"))return!0;t=t.parentNode}return!1})(r)){if("attributes"===t){if(r.getAttribute(o)===i)return;if(n.find((e=>e.type===t&&e.target===r&&e.attributeName===o)))return}else if("characterData"===t){const e=r.data;if(e===i)return;if(n.find((n=>n.type===t&&n.target===r&&n.target.data===e)))return}n.push(e)}})),n.reverse();const r=[];n.forEach((e=>{const{type:t,target:n,attributeName:o,oldValue:i}=e,s=n.path||f(n),c=e=>f(e).replace(s+"/","");if("attributes"===t){const e=n.getAttribute(o),t=i;r.push({type:"attribute",target:s,name:o,next:e,prev:t})}else if("characterData"===t){const e=n.data,t=i;r.push({type:"text",target:s,next:e,prev:t})}else if("childList"===t){if("TEXTAREA"===n.nodeName)return;const{removedNodes:t,addedNodes:o,previousSibling:i,nextSibling:a}=e,u=[],h=Array.from(t).map((e=>{if(document.body.contains(e))return void u.push({node:e,path:f(e)});const t=e.path?c(e):null,n=i?f(i):null,r=a?f(a):null,o={};return t?o.node=t:(o.before=n,o.after=r),o})).filter(Boolean),d=[],l=Array.from(o).map((e=>{const t=e.nextSibling?c(e.nextSibling):null,n=u.find((t=>t.node===e));if(n)return void d.push({node:n.path,sibling:t});const r="#text"===e.nodeName,o="#comment"===e.nodeName,i=r?e.data:null,s=o?e.data:null;return{text:i,html:r||o?null:S(e.outerHTML),comment:s,sibling:t}})).filter(Boolean);r.push({type:"children",target:s,remove:h,insert:l,move:d}),$(n)}})),e(r)}));return $(document),t},r}(a);function $(e){if(e!==document){const t=f(e);e.path=t}const t=e.childNodes;Array.from(t).forEach((e=>{$(e)}))}function S(e){return e.replace(/<script([^]*?)>([^]*?)<\/script>/gm,"<noscript$1></noscript>").replace(/<noscript([^]*?)>([^]*?)<\/noscript>/gm,"<noscript$1></noscript>").replace(/<link([^]*?)as="script"([^]*?)>/g,"<link$1$2>").replace(/\n\n*\s*\n*\n/gm,"\n")}function M(e,t){return M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},M(e,t)}let N=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,M(t,n);var o=r.prototype;return o.options=function(){return{size:!0}},o.createRecordLog=function(){const{innerWidth:e,innerHeight:t}=window;return{type:"window_size",time:Date.now(),detail:{width:e,height:t}}},o.registerSize=function(){let e;const t=()=>{clearTimeout(e);const t=this.createRecordLog();e=setTimeout((()=>{this.anys.write(t)}),100)};return this.recordSize(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},o.recordSize=function(){const e=this.createRecordLog();this.anys.write(e)},r}(a);function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}let B=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,R(t,n);var o=r.prototype;return o.options=function(){return{scroll:!0}},o.registerScroll=function(){let e=0;const t=t=>{if(e)return;const{target:n,bubbles:r}=t;let o;if(r){const{scrollX:e,scrollY:t}=window;o={type:"window_scroll",time:Date.now(),detail:{scrollX:e,scrollY:t}}}else{const{scrollLeft:e,scrollTop:t}=n;o={type:"scroll",time:Date.now(),target:f(n),detail:{scrollLeft:e,scrollTop:t}}}requestAnimationFrame((()=>{this.anys.write(o),e=0})),e=1};return window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("scroll",t)}},r}(a);function K(e,t){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},K(e,t)}let U=function(e){var t,n;function r(t,[n,r,o,i]){var s;return(s=e.call(this,t)||this).offlineStore=n,s.urlMonitor=r,s.windowSizeMonitor=o,s.DOMMutationMonitor=i,s.cache={},s}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,K(t,n);var o=r.prototype;return o.options=function(){const e="ontouchend"in document;return{touch:e,mouse:!e,click:!1,mousedown:!0,mousemove:!0,mouseup:!0,autoReport:!1,reportUrl:new Error("[Anys]: options.reportUrl is required!"),reportInterval:1e4,reportParams:null}},o.registerAutoReport=function(){const{clientId:e}=this.anys,t=({prev:t})=>{this.anys.report([{key:"client",value:e},{key:"trace",value:t}]),this.cache={},this.urlMonitor.recordUrl(),this.windowSizeMonitor.recordSize(),this.DOMMutationMonitor.recordSnapshot()};this.anys.on("refreshTraceId",t);const n=setInterval((()=>{this.anys.report()}),this.anys.options.reportInterval);let r=0;const o=()=>{if(r)return;r=1;const e=Object.keys(this.cache),t=Object.values(this.cache);e.length&&(this.offlineStore.remove(e),navigator.sendBeacon(this.anys.options.reportUrl,JSON.stringify(t)),this.cache={})};window.addEventListener("beforeunload",o),window.addEventListener("pagehide",o),window.addEventListener("unload",o);const i=({id:e,data:t})=>{this.cache[e]=t};return this.anys.on("writeOfflineLog",i),()=>{this.anys.off("refreshTraceId",t),this.anys.off("writeOfflineLog",i),clearInterval(n),window.removeEventListener("beforeunload",o)}},o.read=function(e){return this.offlineStore.read(e)},o.send=function(e){const t=[];let n=0;e.forEach((e=>{t[n]=t[n]||[],t[n].push(e),t[n].length>200&&n++}));const r=t.map((e=>{const t=[],n=[];if(e.forEach((e=>{const{_id:r,...o}=e;n.push(r),t.push(o)})),!t.length)return;const{reportUrl:r,reportParams:o}=this.anys.options;return function(e,t){return new Promise(((n,r)=>{const o=new(window.__XMLHttpRequest||window.XMLHttpRequest);o.open("POST",e,!0),o.onreadystatechange=function(){4==o.readyState&&(200==o.status?n(o.responseText):r(new Error(`[Anys]: ajax post fail with status ${o.status}`)))},o.onerror=r,o.send(JSON.stringify(t))}))}(o?c(r,o):r,t).then((()=>{n.forEach((e=>{delete this.cache[e]}))}))}));return Promise.all(r)},o.clear=function(){this.cache={}},o.auth=function(e){this.anys.options.reportParams=Object.assign(this.anys.options.reportParams||{},e)},r}(a);U.dependencies=[D,_,N,k,p,l,y,g,O,L,B];const X=(e={})=>new s({namespace:"AnysTracer",autoReport:!1,...e,plugins:{...e.plugins||{},recorder:U}})})();var n=anys="undefined"==typeof anys?{}:anys;for(var r in t)n[r]=t[r];t.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";function n(t){return Array.isArray(t)}function r(t,e){return"function"==typeof t&&(!e||!function(t,e){if("function"!=typeof t)return!1;if(t===Symbol)return!1;if(!t.prototype)return!1;const n=t+"",r=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim(),o=0===n.indexOf("class "),i="[native code]"===r,c=o||i;if(e>=4)return c;const u=r.replace(/function.*?\{.*?\}/gm,"").replace(/return/gm,"").replace(/\n+/gm,";").replace(/\s+/gm,"").replace(/;;/gm,";"),s=/^_classCallCheck\(this,/.test(u),a=/^\(.*?_classCallCheck.*?\)\(this,/.test(u),f=/^[0-9a-zA-Z_;!?:]*?\(this,/.test(u),l=c||s||a||f;if(3==e)return l;const p=Object.getOwnPropertyDescriptors(t.prototype),d=!!Object.keys(p).filter((function(t){return"constructor"!==t})).length,h=l||d;if(2==e)return h;const y=0===u.indexOf("this.")||u.indexOf(";this.")>-1||u.indexOf("=this;")>-1,m=h||y;if(1==e)return m;return!0}(t,2))}function o(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16;const e="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ";let n="";for(let r=0;r<t;r++)n+=e.charAt(Math.floor(Math.random()*e.length));return n}function i(t,e,r){return r?function(){const n=Object.getOwnPropertyDescriptors(t);Object.keys(n).forEach((function(r){const o=n[r],{get:i,set:c,enumerable:u,configurable:s,writable:a}=o;(u||i||c||s&&a)&&e(o,r,t)}))}():function(){if(n(t))t.forEach(e);else{Object.keys(t).forEach((function(n){const r=t[n];e(r,n,t)}))}}()}t.r(e),t.d(e,{create:()=>lt});Symbol("Proxy");const c=["filters","plugins"],u=["filters","plugins","defines"];function s(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function f(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?f(Object(n),!0).forEach((function(e){p(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function p(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}let h=function(){function t(e){var a=this;this.$events=[],this.$queue=[];const f=(p=this,Object.getPrototypeOf(p).constructor);var p;const h=l(l({},t.defaultOptions),f.defaultOptions||{}),{filters:y=[],plugins:m=[]}=h,v=d(h,c),b=e||{},{filters:g=[],plugins:w=[],defines:O=[]}=b,j=d(b,u),P={},E=[],_={},x=w&&!n(w)&&"object"==typeof w,L=x?Object.values(w):n(w)?w:[],S=x?Object.keys(w).map((function(t){return{key:t,value:w[t]}})):[],A=[].concat(s(m),s(L)),I=function(t){t.forEach((function(t){const e=t.dependencies||[];e.forEach((function(t){A.unshift(t)})),I(e)}))};I(A);const D=A.filter((function(t,e){return e===A.indexOf(t)})),T=[],k={};D.forEach((function(t){const e=S.find((function(e){return e.value===t}))?.key;if(e&&k[e])return void function(e){const n="[Anys]: plugin named '".concat(e,"' has been registered");k[e]instanceof t?console.debug(n,t,k):console.error(n,t,k)}(e);const n=(t.dependencies||[]).map((function(t){return T.find((function(e){return e instanceof t}))})),r=new t(a,n);r.options&&Object.assign(P,r.options()),r.defines&&Object.assign(_,r.defines()),r.filters&&E.push.apply(E,s(r.filters())),T.push(r),e&&(k[e]=r)})),this.$plugins=T,this.plugins=k,this.options=l(l(l({},v),P),j),this.filters=[].concat(s(y),E,s(g));const q=Object.values(this.options).find((function(t){return t&&t instanceof Error}));if(q)throw q;const N=l(l({},_),O);this.definitions=N,this.clientId=N.client?N.client():o(8),this.traceId=N.trace?N.trace():o(8),this.requestId=o(8);const M={};Object.defineProperties(M,function(t,e){if(n(t))return t.map(e);{const n={};return i(t,(function(r,o){n[o]=e(r,o,t)})),n}}(N,(function(t){return{get:r(t)?t:function(){return t},enumerable:!0,configurable:!0}}))),Object.defineProperties(M,{client:{get:function(){return a.clientId},enumerable:!0,configurable:!0},trace:{get:function(){return a.traceId},enumerable:!0,configurable:!0},request:{get:function(){return a.requestId},enumerable:!0,configurable:!0}}),this.$basicLog=M,this.invoke("init"),this.options.autoStart&&this.start()}var e=t.prototype;return e.define=function(t,e){Object.defineProperty(this.$basicLog,t,{get:e,enumerable:!0,configurable:!0})},e.on=function(t,e){this.$events.push([t,e])},e.off=function(t,e){var n=this;this.$events.forEach((function(r,o){r[0]===t&&r[1]===e&&n.$events.splice(o,1)}))},e.emit=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];this.$events.forEach((function(e){e[0]!==t&&"*"!==e[0]||e[1].apply(e,n)}))},e.invoke=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];for(let e=0,o=this.$plugins.length;e<o;e+=1){const o=this.$plugins[e];o[t]&&(r(o[t])&&o[t].apply(o,n))}},e.refreshTraceId=function(){const t=this.traceId;this.traceId=this.definitions.trace?this.definitions.trace():o(8),this.emit("refreshTraceId",{prev:t,next:this.traceId})},e.refreshRequestId=function(){const t=this.requestId;this.requestId=o(8),this.emit("refreshRequestId",{prev:t,next:this.requestId})},e.start=function(){this.invoke("start"),this.emit("start")},e.write=function(t){var e=this;setTimeout((function(){const n=l(l({},e.$basicLog),t),{filters:r}=e;for(let t=0,e=r.length;t<e;t+=1){if(!(0,r[t])(n))return}e.invoke("write",n),e.emit("write",n)}),0)},e.report=function(t){var e=this;let o,i;const c=new Promise((function(t,e){o=t,i=e})),u={message:t,resolve:o,reject:i};this.$queue.push(u),this._reporting=!1;const a=function(){return setTimeout((function(){if(e._reporting)return;e._reporting=!0;const t=e.$queue.shift();if(!t)return;const{message:o,resolve:i,reject:c}=t;e.emit("report",o);const u=[];for(let t=0,n=e.$plugins.length;t<n;t+=1){const n=e.$plugins[t],o={};let i=0;r(n.read)&&(o.read=n.read.bind(n),i=1),r(n.send)&&(o.send=n.send.bind(n),i=1),r(n.clear)&&(o.clear=n.clear.bind(n),i=1),i&&u.push(o)}const f=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];return Promise.resolve().then((function(){return r(t)?t.apply(void 0,n):null}))};(function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduce((function(t,e){return r(e)?t.then(e):t}),Promise.resolve())})((function(){return Promise.all(u.map((function(t){return f(t.read,o).then((function(e){return t.data=e,e}))})))}),(function(t){const r=[];return t.forEach((function(t){n(t)&&t.length&&r.push.apply(r,s(t))})),e.emit("read",r),r}),(function(t){if(t.length)return e.emit("send",t),Promise.all(u.map((function(e){return f(e.send,e.data,t)}))).then((function(){return t}))}),(function(t){if(t)return e.emit("clear",t),Promise.all(u.map((function(t){return f(t.clear,t.data)})))})).then(i,c).finally((function(){e._reporting=!1,a()}))}),0)};return a(),c},e.stop=function(){this.invoke("stop"),this.emit("stop")},t}();function y(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function m(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?y(Object(n),!0).forEach((function(e){v(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function v(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b(t,e){if(t.indexOf("?")<0){const n=Object.keys(e).map((function(t){return"".concat(t,"=").concat(e[t])})).join("&"),[r,o]=t.split("#");return r+"?"+n+(o?"#"+o:"")}const[n,r]=t.split("?"),[o,i]=r.split("#"),c=o.split("&").map((function(t){return t.split("=")})).reduce((function(t,e){let[n,r]=e;return m(m({},t),{},{[n]:r})}),{});Object.assign(c,e);return n+"?"+Object.keys(c).map((function(t){return"".concat(t,"=").concat(c[t])})).join("&")+(i?"#"+i:"")}h.defaultOptions={autoStart:!0};let g=function(){function t(t){this.anys=t,this.$effects={}}var e=t.prototype;return e.start=function(){var t=this;if(!this.options)return;const e=this.options(),n=Object.keys(e),r=this.anys.options;n.forEach((function(e){r[e]&&function(e){const n="register".concat(e.replace(e[0],e[0].toUpperCase()));if(t[n]){const r=t[n]();t.$effects[e]=r}}(e)}))},e.stop=function(){var t=this;if(!this.options)return;const e=this.options(),n=Object.keys(e),r=this.anys.options;n.forEach((function(e){const n=t.$effects[e];r[e]&&n&&n(),t.$effects[e]=null}))},t}(),w=function(){function t(){this.$events=[]}var e=t.prototype;return e.on=function(t,e){this.$events.push([t,e])},e.emit=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];this.$events.forEach((function(e){let[r,o]=e;t===r&&o.apply(void 0,n)}))},e.off=function(t,e){var n=this;this.$events.forEach((function(r,o){let[i,c]=r;t===i&&c===e&&n.$events.splice(o,1)}))},t}();function O(t,e){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},O(t,e)}function j(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function P(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?j(Object(n),!0).forEach((function(e){E(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function E(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const _=new w;!function(){const t=window.XMLHttpRequest;window.__XMLHttpRequest=t,window.XMLHttpRequest=function(){const e=new t,n={open:e.open,send:e.send},r={name:o(4)},i=function(t){const{name:n,url:o,method:i}=r;let c,u;e.responseType&&"text"!==e.responseType?"json"===e.responseType&&(c=e.response,u="json"):(c=e.responseText.toString(),u="text"),_.emit("xhr",{type:t,time:Date.now(),name:"xhr_".concat(n),url:o,detail:{status:e.status,method:i,responseType:u,response:c||void 0}})},c=function(){4===e.readyState&&(2===Math.floor(e.status/100)?i("xhr.ok"):i("xhr.fail"))};return Object.defineProperty(e,"open",{get:function(){return function(t,o){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const c={method:t,url:o};_.emit("request",c),Object.assign(r,P(P({},c),{},{async:i})),e.onreadystatechange&&(n.onreadystatechange=e.onreadystatechange);const{open:u}=n;for(var s=arguments.length,a=new Array(s>3?s-3:0),f=3;f<s;f++)a[f-3]=arguments[f];return u.call.apply(u,[e,c.method,c.url,i].concat(a))}},configurable:!0}),Object.defineProperty(e,"send",{get:function(){return function(t){const{send:o}=n,{async:i}=r;Object.assign(r,{body:t}),function(){const{name:t,url:e,method:n,async:o,body:i}=r;_.emit("xhr",{type:"xhr.req",time:Date.now(),name:"xhr_".concat(t),url:e,detail:{method:n,async:o,body:i}})}();const u=o.call(e,t);return i||c(),u}},configurable:!0}),e.addEventListener("error",(function(){i("xhr.err")})),e.addEventListener("readystatechange",(function(t){c()})),e}}(),function(){const t=window.fetch;window.__fetch=t,window.fetch=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{method:r,body:i}=n,c=o(4);_.emit("fetch",{type:"fetch.init",time:Date.now(),name:"fetch_".concat(c),url:e,detail:{body:i,method:r}});const u={method:r,url:e};return _.emit("request",u),Promise.resolve().then((function(){return t(u.url,n)})).then((function(t){const{status:n}=t;return 2===Math.floor(n/100)?new Proxy(t,{get:(o,i)=>"json"===i||"text"===i?function(){return t[i]().then((function(t){return _.emit("fetch",{type:"fetch.ok",time:Date.now(),name:"fetch_".concat(c),url:e,detail:{status:n,data:t,method:r}}),t}))}:"function"==typeof t[i]?t[i].bind(t):t[i]}):(_.emit("fetch",{type:"fetch.fail",time:Date.now(),name:"fetch_".concat(c),url:e,detail:{status:n,method:r}}),t)}),(function(t){let n;if(t instanceof Error){const{name:e,message:o}=t;n={method:r,type:e,err:o}}else n={method:r,err:t};_.emit("fetch",{type:"fetch.err",time:Date.now(),name:"fetch_".concat(c),url:e,detail:n})}))}}();let x=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,O(e,n);var o=r.prototype;return o.options=function(){return{xhr:!0,fetch:!0,ajaxResponse:!0,patchRequestId:!0}},o.registerXhr=function(){var t=this;const e=function(e){t.anys.options.ajaxResponse||"xhr.ok"!==e.type||delete e.detail.response,t.anys.write(e)};return _.on("xhr",e),function(){return _.off("xhr",e)}},o.registerFetch=function(){var t=this;const e=function(e){t.anys.options.ajaxResponse||"fetch.ok"!==e.type||delete e.detail.data,t.anys.write(e)};return _.on("fetch",e),function(){return _.off("fetch",e)}},o.registerPatchRequestId=function(){var t=this;const e=function(e){const{url:n}=e,{traceId:r,requestId:o}=t.anys,i=b(n,{_request_id:r+o});e.url=i};return _.on("request",e),function(){return _.off("request",e)}},r}(g),L=function(){function t(t){this.anys=t}var e=t.prototype;return e.options=function(){return{namespace:new Error("[Anys]: options.namespace is required!")}},e.defines=function(){return{client:this.defineClientId.bind(this),trace:this.defineTraceId.bind(this)}},e.defineClientId=function(){const{namespace:t}=this.anys.options,e="Anys.".concat(t,".clientId");let n=localStorage.getItem(e);return n||(n=o(8),sessionStorage.setItem(e,n)),n},e.defineTraceId=function(){const{namespace:t}=this.anys.options,e="Anys.".concat(t,".traceId"),n=o(8);return sessionStorage.setItem(e,n),n},t}();function S(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.documentElement;const{nodeName:n,path:r}=t;if(r)return r;if("BODY"===n||"HTML"===n||"HEAD"===n)return n;const o=[];let i=t,c=t.parentNode;const u=function(t){const{nodeName:e,parentNode:n}=t;if(!n)return-1;return[].filter.call(n.childNodes,(function(t){return t.nodeName===e})).indexOf(t)};if("#"===n[0]){const e=u(t);o.push("".concat(n,":").concat(e)),i=c,c=i.parentNode}for(;c&&i!==e;){const{nodeName:t}=i;if("BODY"===t||"HTML"===t||"HEAD"===t)o.push(t);else{const e=u(i);o.push("".concat(t.toLowerCase(),":").concat(e))}i=c,c=i.parentNode}return o.reverse(),o.join("/")}function A(t,e){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},A(t,e)}let I=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,A(e,n);var o=r.prototype;return o.options=function(){return{input:!0}},o.registerInput=function(){var t=this;const e=function(e){return function(n){const{target:r,type:o,inputType:i,data:c}=n;if("insertCompositionText"===i)return;if("compositionend"===o&&!c)return;const{tagName:u,value:s}=r;if(r.getAttribute("anys-ignore"))return;const a=r.getAttribute("type"),f=e({tagName:u,value:s,type:a,target:r});if(!f)return;const l={type:"input",time:Date.now(),el:S(r),detail:f};t.anys.write(l)}},n=e((function(t){let{tagName:e,value:n,type:r}=t;return"INPUT"===e&&"radio"!==r&&"checkbox"!==r&&"password"!==r?{value:n,type:r}:"INPUT"===e&&"password"===r?{value:"***",type:r}:"TEXTAREA"===e?{value:n,type:"textarea"}:void 0})),r=e((function(t){let{tagName:e,value:n,type:r}=t;return"SELECT"===e?{value:n,type:"select"}:"INPUT"!==e||"radio"!==r&&"checkbox"!==r?void 0:{value:n,type:r}})),o=e((function(t){let{tagName:e,value:n,type:r}=t;return"TEXTAREA"===e?{value:n,type:"textarea"}:"INPUT"===e?{value:n,type:r}:void 0}));return document.addEventListener("input",n,!0),document.addEventListener("compositionend",n,!0),document.addEventListener("change",r,!0),document.addEventListener("paste",o,!0),function(){document.removeEventListener("input",n),document.removeEventListener("compositionend",n),document.removeEventListener("change",r),document.removeEventListener("paste",o)}},r}(g);function D(t,e){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},D(t,e)}let T=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,D(e,n);var o=r.prototype;return o.options=function(){return{mouse:!("ontouchend"in document),click:!0,mousemove:!1,mousedown:!1,mouseup:!1,wheel:!1,contextmenu:!1}},o.addEventListener=function(t,e){if(!this.anys.options.mouse)return;const n=this.createThrottleListener((function(e){const{innerWidth:n,innerHeight:r}=window,{target:o,button:i,pageX:c,pageY:u}=e;return{type:t,time:Date.now(),detail:{e:S(o),w:n,h:r,x:c,y:u,button:i}}}),e);return document.addEventListener(t,n,!0),function(){return document.removeEventListener(t,n)}},o.registerClick=function(){return this.addEventListener("click")},o.registerMouseup=function(){return this.addEventListener("mouseup")},o.registerMousedown=function(){return this.addEventListener("mousedown")},o.registerContextmenu=function(){return this.addEventListener("contextmenu")},o.registerMousemove=function(){return this.addEventListener("mousemove",100)},o.registerWheel=function(){if(!this.anys.options.mouse)return;const t="wheel",e=this.createThrottleListener((function(e){const{target:n,deltaX:r,deltaY:o,deltaZ:i,deltaMode:c}=e;return{type:t,time:Date.now(),detail:{e:S(n),deltaX:r,deltaY:o,deltaZ:i,mode:c}}}),100);return document.addEventListener(t,e),function(){return document.removeEventListener(t,e)}},o.createThrottleListener=function(t,e){var n=this;let r=0,o=0;return function(i){if(r)return;const c=Date.now();if(e&&o+e>c)return;const u=t(i);requestAnimationFrame((function(){n.anys.write(u),r=0,o=Date.now()})),r=1}},r}(g);function k(t,e){return k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},k(t,e)}const q={type:"window_activity.enter",time:Date.now()};let N=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,k(e,n);var o=r.prototype;return o.options=function(){return{activity:!0,deadTimeout:0}},o.init=function(){this.anys.options.activity&&this.anys.write(q)},o.registerActivity=function(){var t=this;const e=function(){if("hidden"===document.visibilityState){const e={type:"window_activity.focusout",time:Date.now()};t.anys.write(e)}else{const e={type:"window_activity.focusin",time:Date.now()};t.anys.write(e)}},n=function(){const e={type:"window_activity.unload",time:Date.now()};t.anys.write(e)};return window.addEventListener("beforeunload",n,!0),document.addEventListener("visibilitychange",e,!0),function(){window.removeEventListener("beforeunload",n),document.removeEventListener("visibilitychange",e)}},o.registerDeadTimeout=function(){var t=this;const{deadTimeout:e}=this.anys.options;if(!e)return;let n;const r=function(){clearTimeout(n),n=setTimeout((function(){const e={type:"window_activity.dead",time:Date.now()};t.anys.write(e)}),e)};return document.addEventListener("keydown",r,!0),document.addEventListener("mousedown",r,!0),document.addEventListener("touchstart",r,!0),document.addEventListener("touchmove",r,!0),document.addEventListener("mousemove",r,!0),document.addEventListener("scroll",r,!0),window.addEventListener("resize",r,!0),function(){document.removeEventListener("keydown",r),document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r),document.removeEventListener("touchmove",r),document.removeEventListener("mousemove",r),document.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},r}(g);function M(t,e){return M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},M(t,e)}let $=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,M(e,n);var o=r.prototype;return o.options=function(){return{url:!0}},o.registerUrl=function(){var t=this;const e=function(){t.recordUrl()};return window.addEventListener("hashchange",e),window.addEventListener("popstate",e),this.recordUrl(),function(){window.removeEventListener("hashchange",e),window.removeEventListener("popstate",e)}},o.recordUrl=function(){const t=window.location.href,e=new URL(t),n=e.pathname.replace(/^([^/])/,"/$1"),r={type:"url",time:Date.now(),url:t,detail:{uri:n+(e.search?"?".concat(e.search):""),path:n,protocol:e.protocol.replace(":",""),host:e.hostname,port:e.port,search:e.search,hash:e.hash.replace("#","")}};this.anys.write(r)},r}(g);function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}let B=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,R(e,n);var o=r.prototype;return o.options=function(){const t="ontouchend"in document;return{touch:t,touchstart:t,touchend:t,touchmove:t}},o.addEventListener=function(t){var e=this;if(!this.anys.options.touch)return;let n=0;const r=function(r){if(n)return;const{innerWidth:o,innerHeight:i}=window,{target:c,identifier:u,force:s,pageX:a,pageY:f}=r,l={type:t,time:Date.now(),detail:{e:S(c),width:o,height:i,x:a,y:f,identifier:u,force:s}};requestAnimationFrame((function(){e.anys.write(l),n=0})),n=1};return document.addEventListener(t,r,!0),function(){return document.removeEventListener(t,r)}},o.registerTouchmove=function(){return this.addEventListener("touchmove")},o.registerTouchend=function(){return this.addEventListener("touchend")},o.registerTouchstart=function(){return this.addEventListener("touchstart")},r}(g),U=function(){function t(){this.queue=[],this.status=0}return t.prototype.push=function(t){var e=this;let n,r;const o=new Promise((function(t,e){n=t,r=e})),i={runner:t,resolve:n,reject:r};this.queue.push(i);const c=function(){setTimeout((function(){if(!e.queue.length)return void(e.status=0);const{runner:t,resolve:n,reject:r}=e.queue.shift();t().then(n,r).finally(c)}),0),e.status=1};return this.status||c(),o},t}(),K=function(){function t(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{name:e,version:n=1,stores:r}=t;const o=!e;e||(e="__indb__"),r&&Array.isArray(r)&&r.length||(r=[{name:"__indb__",isKv:!0}]),this.cache={},this.connection=null,this.name=e,this.version=n,this.stores=r;const i=indexedDB.open(e,n);if(i.onupgradeneeded=function(t){const e=t.target.result,n=Array.from(e.objectStoreNames),o=[];r.forEach((function(r){let i=null;if(n.indexOf(r.name)>-1)i=t.target.transaction.objectStore(r.name);else{const t=r.isKv?"key":r.primaryKeyPath,n=!r.isKv&&r.autoIncrement;i=e.createObjectStore(r.name,{keyPath:t,autoIncrement:n})}const c=i.indexNames;c&&c.length&&Array.from(c).forEach((function(t){return i.deleteIndex(t)})),r.indexes&&r.indexes.length&&r.indexes.forEach((function(t){i.createIndex(t.name,t.keyPath||t.name,{unique:t.unique,multiEntry:Array.isArray(t.keyPath)})})),o.push(r.name)})),n&&n.forEach((function(t){-1===o.indexOf(t)&&e.deleteObjectStore(t)}))},i.onblocked=function(t){console.error(H(new Error("indexedDB "+e+" is blocked")))},o)return this.use(e)}var e=t.prototype;return e.connect=function(){var t=this;return new Promise((function(e,n){const r=indexedDB.open(t.name,t.version);r.onerror=function(t){n(H(t))},r.onsuccess=function(t){e(t.target.result)}}))},e.use=function(t){const e=this.stores.find((function(e){return e.name===t}));if(!e)throw new Error("[InDB]: store ".concat(t," is not existing."));if(this.cache[t])return this.cache[t];const n=new C({db:this,store:e});return e.isKv&&Object.defineProperties(n,{key:{value:function(t){return n.keys().then((function(e){return e&&e[t]}))}},getItem:{value:function(t){return n.get(t).then((function(t){return t&&t.value}))}},setItem:{value:function(t,e){return n.put({key:t,value:e})}},removeItem:{value:function(t){return n.delete(t)}}}),this.cache[t]=n,n},e.close=function(){return this.cache=null,this.stores=null,this.connect().then((function(t){t.close()}))},t.deleteDatabase=function(t){return new Promise((function(e,n){const r=indexedDB.deleteDatabase(t);r.onsuccess=function(){e()},r.onerror=function(t){n(t)}}))},t.databases=function(){return indexedDB.databases()},t}();let C=function(){function t(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{store:e,db:n}=t;if("object"!=typeof e||!e.name||"string"!=typeof e.name)throw new Error("[InDBStore]: options.store should be a store config object.");if(!(n instanceof K))throw new Error("[InDBStore]: options.db should be an instanceof InDB.");this.db=n,this.store=e,this.name=e.name,this.primaryKeyPath=e.isKv?"key":e.primaryKeyPath,this._queue=[]}var e=t.prototype;return e.transaction=function(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const n=function(){const n=t.name,r=e?"readwrite":"readonly",o=t.db.connection;return(o?Promise.resolve(o):t.db.connect()).then((function(e){t.db.connection=e;const o=e.transaction(n,r),i=function(){t.db.connection=null,t._queue.shift()};return o.oncomplete=i,o.onabort=i,o.onerror=i,o}))},r=this._queue[this._queue.length-1],o=r?r.then((function(){return n()})):n();return this._queue.push(o),o},e.objectStore=function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.name;return this.transaction(t).then((function(t){return t.objectStore(e)}))},e.cursor=function(t){const{index:e,range:n,direction:r,onTouch:o,onDone:i,onError:c,writable:u=!1}=t;return this.objectStore(u).then((function(t){const u=e?t.index(e):t,s=u.openCursor(n,r);s.onsuccess=function(t){const e=t.target.result;e?o(e,u):i(e,u)},s.onerror=function(t){c(H(t))}}))},e.request=function(t){var e=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{writable:r=!1}=n;return new Promise((function(n,o){e.objectStore(r).then((function(e){const r=t(e);r.onsuccess=function(t){const e=t.target.result;n(e)},r.onerror=function(t){o(H(t))}}))}))},e.iterate=function(t){var e=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{index:r,range:o,writable:i=!1,direction:c="next"}=n;return new Promise((function(n,u){e.cursor({index:r,range:o,writable:i,direction:c,onTouch:function(e,r){t(e,(function(){return e.continue()}),(function(){r.transaction.commit(),n()}))},onDone:function(){n()},onError:function(t){u(t)}})}))},e.batch=function(t){var e=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{writable:r=!0}=n;return this.transaction(r).then((function(n){const r=e.name,o=[],i=n.objectStore(r);return t.forEach((function(t){const e=new Promise((function(e,n){const r=t(i);r.onsuccess=function(t){const n=t.target.result;e(n)},r.onerror=function(t){n(H(t))}}));o.push(e)})),Promise.all(o)}))},e.get=function(t){if(!Array.isArray(t))return this.request((function(e){return e.get(t)}));const e=t.map((function(t){return function(e){return e.get(t)}}));return this.batch(e,{writable:!1})},e.keys=function(){const t=this.primaryKeyPath,e=[];return this.each((function(n){const r=X(n,t);e.push(r)})).then((function(){return e}))},e.all=function(){const t=[];return this.each((function(e){t.push(e)})).then((function(){return t}))},e.count=function(){return this.request((function(t){return t.count()}))},e.each=function(t){return this.iterate((function(e,n){const r=e.value;t(r),n()}))},e.reverse=function(t){return this.iterate((function(e,n){const r=e.value;t(r),n()}),{direction:"prev"})},e.some=function(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return new Promise((function(r,o){const i=[];let c,u=0,s=n,a=n+e;n<0&&(c="prev",e=Math.min(e,-n),s=-(n+e)||0,a=s+e),t.iterate((function(t,e,n){u<s?(u++,e()):u<a?(i.push(t.value),u++,e()):n()}),{direction:c}).then((function(){n<0&&i.reverse(),r(i)})).catch(o)}))},e.first=function(){return this.some(1).then((function(t){return t[0]}))},e.last=function(){return this.some(1,-1).then((function(t){return t[0]}))},e.find=function(t,e){return this.request((function(n){return n.index(t).get(e)}))},e.query=function(t,e,n){var r=this;const o=function(){switch(n){case">":return IDBKeyRange.lowerBound(e,!0);case">=":return IDBKeyRange.lowerBound(e);case"<":return IDBKeyRange.upperBound(e,!0);case"<=":return IDBKeyRange.upperBound(e);case"%":case"!=":case"in":return;default:return IDBKeyRange.only(e)}}(),i=[];return new Promise((function(c,u){r.cursor({index:t,range:o,onTouch:function(t,r){const o=t.value,c=X(o,r.keyPath);"!="===n?c!==e&&i.push(o):"%"===n?"string"==typeof c&&c.indexOf(e)>-1&&i.push(o):"in"===n?Array.isArray(e)&&e.indexOf(c)>-1&&i.push(o):i.push(o),t.continue()},onDone:function(){c(i)},onError:function(t){u(t)}})}))},e.select=function(){const t=this.store.indexes||[],e={};t.forEach((function(t){const{name:n,keyPath:r}=t;e[n]=r}));const n=function(t,e,n){if(void 0===t)return!1;switch(n){case">":return t>e;case">=":return t>=e;case"<":return t<e;case"<=":return t<=e;case"!=":return t!==e;case"%":return"string"==typeof t&&t.indexOf(e)>-1;case"in":return Array.isArray(e)&&e.indexOf(t)>-1;default:return t===e}},r=function(t,e,r){if(!e.length&&!r.length)return!1;for(let r=0,o=e.length;r<o;r++){const{keyPath:o,value:i,compare:c}=e[r],u=X(t,o);if(!n(u,i,c))return!1}if(!r.length)return!0;for(let e=0,o=r.length;e<o;e++){const{keyPath:o,value:i,compare:c}=r[e],u=X(t,o);if(n(u,i,c))return!0}return!1},o=[];for(var i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];c.forEach((function(t){const n=[],r=[];for(let o=0,i=t.length;o<i;o++){const{key:i,value:c,compare:u,optional:s}=t[o],a=e[i]||i;s?n.push({keyPath:a,value:c,compare:u}):r.push({keyPath:a,value:c,compare:u})}o.push([r,n])}));const s=[];return this.each((function(t){(function(t){for(let e=0,n=o.length;e<n;e++){const[n,i]=o[e];if(r(t,n,i))return!0}return!1})(t)&&s.push(t)})).then((function(){return s}))},e.add=function(t,e){if(Array.isArray(t)){const n=t;if(n.length<2)return this.add(t[0],e);const r=n.map((function(t){return function(n){return n.add(t,e)}}));return this.batch(r)}return t?this.request((function(n){return n.add(t,e)}),{writable:!0}):Promise.resolve()},e.put=function(t,e){if(Array.isArray(t)){const n=t;if(n.length<2)return this.put(n[0],e);const r=n.map((function(t){return function(n){return n.put(t,e)}}));return this.batch(r)}return t?this.request((function(n){return n.put(t,e)}),{writable:!0}):Promise.resolve()},e.delete=function(t){if(Array.isArray(t)){const e=t;if(e.length<2)return this.delete(e[0]);const n=e.map((function(t){return function(e){return e.delete(t)}}));return this.batch(n)}return t?this.request((function(e){return e.delete(t)}),{writable:!0}):Promise.resolve()},e.remove=function(t){const e=this.primaryKeyPath;if(Array.isArray(t)){const n=t;if(n.length<2)return this.remove(n[0]);const r=n.map((function(t){const n=X(t,e);return function(t){return t.delete(n)}}));return this.batch(r)}if(!t)return Promise.resolve();const n=X(t,e);return n?this.delete(n):Promise.resolve()},e.clear=function(){return this.request((function(t){return t.clear()}),{writable:!0})},t}();function X(t,e){if(null==e)return;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++){const r=X(t,e[n]);if(void 0!==r)return r}return}let n=function(t){return t.toString().split(/\.|\[|\]/).filter((function(t){return!!t}))}(e);if(!n.length)return t;let r=t;for(let t=0,e=n.length;t<e;t++){let e=n[t];if(void 0===r[e])return;r=r[e]}return r}function H(t){const{message:e}=t;return t.message=-1===e.indexOf("[IndexedDB]")?"[IndexedDB]: "+e:e,t}let z=function(){function t(t){this.anys=t}var e=t.prototype;return e.options=function(){return{namespace:new Error("[Anys]: options.namespace is required!"),autoReport:!1,expireTime:1728e5}},e.init=function(){var t=this;const e="anyslogs",n=new K({name:this.anys.options.namespace,version:1,stores:[{name:e,primaryKeyPath:"_id",autoIncrement:!0}]});this.db=n.use(e),this.queue=new U;const{expireTime:r}=this.anys.options;if(r){let e=0;const n=setInterval((function(){t.queue.push((function(){return t.db.some(100,e)})).then((function(o){if(!o.length)return void clearInterval(n);const i=Date.now(),c=[];o.forEach((function(t){const{_id:e,time:n}=t;i-n>r&&c.push(e)})),c.length&&t.queue.push((function(){return t.db.delete(c)})),e+=100,e-=c.length}))}),1e4)}},e.write=function(t){var e=this;this.queue.push((function(){return e.db.add(t)})).then((function(n){e.anys.emit("writeOfflineLog",{id:n,data:t})}))},e.read=function(t){if(t){if(!Array.isArray(t))return;if(t.some((function(t){return!t.key})))return}else t=[{key:"client",value:this.anys.clientId},{key:"trace",value:this.anys.traceId}];return this.select(t)},e.clear=function(t){var e=this;return this.queue.push((function(){return e.db.remove(t)})).catch((function(){}))},e.select=function(t){var e=this;return this.queue.push((function(){return e.db.select(t)}))},e.remove=function(t){var e=this;return this.queue.push((function(){return e.db.delete(t)})).catch((function(){}))},t}();function Y(t){return function(t){if(Array.isArray(t))return F(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return F(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return F(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function W(t,e){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},W(t,e)}let Z=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,W(e,n);var o=r.prototype;return o.options=function(){return{mutation:!0}},o.registerMutation=function(){var t=this;const e=this.createObserver((function(e){const n={type:"mutation",time:Date.now(),detail:e};t.anys.write(n)}));return window.addEventListener("load",(function(){e.observe(document,{characterData:!0,attributes:!0,childList:!0,subtree:!0}),t.recordSnapshot(),V(document.documentElement)})),function(){e.disconnect()}},o.recordSnapshot=function(){const t=function(){const{name:t,publicId:e,systemId:n}=document.doctype,r={name:t,publicId:e,systemId:n},o=G(document.documentElement.innerHTML),i={},c=document.querySelector("html");for(let{name:t,value:e}of c.attributes)i[t]=e;const u=function(){const t=document.querySelectorAll("input, textarea, select"),e=[];return Array.from(t).forEach((function(t){const n=S(t),r="password"===t.type?"***":t.value;e.push({el:n,value:r})})),e}();return{doctype:r,attrs:i,html:o,values:u}}(),e=window.location.href,n=new URL(e),r=n.pathname.replace(/^([^/])/,"/$1");this.anys.write({type:"snapshot",time:Date.now(),url:{uri:r+(n.search?"?".concat(n.search):""),path:r,protocol:n.protocol.replace(":",""),host:n.hostname,port:n.port,search:n.search,hash:n.hash.replace("#","")},detail:t})},o.createObserver=function(t){const e=new MutationObserver((function(e){const n=[];Y(e).reverse().forEach((function(t){const{type:e,target:r,attributeName:o,oldValue:i}=t;if(!function(t){if(t.hasAttribute?.("anys-ignore"))return!0;let e=t.parentNode;for(;e;){if(e.hasAttribute?.("anys-ignore"))return!0;e=e.parentNode}return!1}(r)){if("attributes"===e){if(r.getAttribute(o)===i)return;if(n.find((function(t){return t.type===e&&t.target===r&&t.attributeName===o})))return}else if("characterData"===e){const t=r.data;if(t===i)return;if(n.find((function(n){return n.type===e&&n.target===r&&n.target.data===t})))return}n.push(t)}})),n.reverse();const r=[];n.forEach((function(t){const{type:e,target:n,attributeName:o,oldValue:i}=t,c=n.path||S(n),u=function(t){return S(t).replace(c+"/","")};if("attributes"===e){const t=n.getAttribute(o),e=i;r.push({type:"attribute",target:c,name:o,next:t,prev:e})}else if("characterData"===e){const t=n.data,e=i;r.push({type:"text",target:c,next:t,prev:e})}else if("childList"===e){if("TEXTAREA"===n.nodeName)return;const{removedNodes:e,addedNodes:o,previousSibling:i,nextSibling:s}=t,a=[],f=Array.from(e).map((function(t){if(document.body.contains(t))return void a.push({node:t,path:S(t)});const e=t.path?u(t):null,n=i?S(i):null,r=s?S(s):null,o={};return e?o.node=e:(o.before=n,o.after=r),o})).filter(Boolean),l=[],p=Array.from(o).map((function(t){const e=t.nextSibling?u(t.nextSibling):null,n=a.find((function(e){return e.node===t}));if(n)return void l.push({node:n.path,sibling:e});const r="#text"===t.nodeName,o="#comment"===t.nodeName,i=r?t.data:null,c=o?t.data:null;return{text:i,html:r||o?null:G(t.outerHTML),comment:c,sibling:e}})).filter(Boolean);r.push({type:"children",target:c,remove:f,insert:p,move:l}),V(n)}})),t(r)}));return V(document),e},r}(g);function V(t){if(t!==document){const e=S(t);t.path=e}const e=t.childNodes;Array.from(e).forEach((function(t){V(t)}))}function G(t){return t.replace(/<script([^]*?)>([^]*?)<\/script>/gm,"<noscript$1></noscript>").replace(/<noscript([^]*?)>([^]*?)<\/noscript>/gm,"<noscript$1></noscript>").replace(/<link([^]*?)as="script"([^]*?)>/g,"<link$1$2>").replace(/\n\n*\s*\n*\n/gm,"\n")}function J(t,e){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},J(t,e)}let Q=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,J(e,n);var o=r.prototype;return o.options=function(){return{size:!0}},o.createRecordLog=function(){const{innerWidth:t,innerHeight:e}=window;return{type:"window_size",time:Date.now(),detail:{width:t,height:e}}},o.registerSize=function(){var t=this;let e;const n=function(){clearTimeout(e);const n=t.createRecordLog();e=setTimeout((function(){t.anys.write(n)}),100)};return this.recordSize(),window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}},o.recordSize=function(){const t=this.createRecordLog();this.anys.write(t)},r}(g);function tt(t,e){return tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},tt(t,e)}let et=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,tt(e,n);var o=r.prototype;return o.options=function(){return{scroll:!0}},o.registerScroll=function(){var t=this;let e=0;const n=function(n){if(e)return;const{target:r,bubbles:o}=n;let i;if(o){const{scrollX:t,scrollY:e}=window;i={type:"window_scroll",time:Date.now(),detail:{scrollX:t,scrollY:e}}}else{const{scrollLeft:t,scrollTop:e}=r;i={type:"scroll",time:Date.now(),target:S(r),detail:{scrollLeft:t,scrollTop:e}}}requestAnimationFrame((function(){t.anys.write(i),e=0})),e=1};return window.addEventListener("scroll",n,!0),function(){window.removeEventListener("scroll",n)}},r}(g);const nt=["_id"];function rt(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function ot(t,e){return ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ot(t,e)}let it=function(t){var e,n;function r(e,n){var r;let[o,i,c,u]=n;return(r=t.call(this,e)||this).offlineStore=o,r.urlMonitor=i,r.windowSizeMonitor=c,r.DOMMutationMonitor=u,r.cache={},r}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,ot(e,n);var o=r.prototype;return o.options=function(){const t="ontouchend"in document;return{touch:t,mouse:!t,click:!1,mousedown:!0,mousemove:!0,mouseup:!0,autoReport:!1,reportUrl:new Error("[Anys]: options.reportUrl is required!"),reportInterval:1e4,reportParams:null}},o.registerAutoReport=function(){var t=this;const{clientId:e}=this.anys,n=function(n){let{prev:r}=n;t.anys.report([{key:"client",value:e},{key:"trace",value:r}]),t.cache={},t.urlMonitor.recordUrl(),t.windowSizeMonitor.recordSize(),t.DOMMutationMonitor.recordSnapshot()};this.anys.on("refreshTraceId",n);const r=setInterval((function(){t.anys.report()}),this.anys.options.reportInterval);let o=0;const i=function(){if(o)return;o=1;const e=Object.keys(t.cache),n=Object.values(t.cache);e.length&&(t.offlineStore.remove(e),navigator.sendBeacon(t.anys.options.reportUrl,JSON.stringify(n)),t.cache={})};window.addEventListener("beforeunload",i),window.addEventListener("pagehide",i),window.addEventListener("unload",i);const c=function(e){let{id:n,data:r}=e;t.cache[n]=r};return this.anys.on("writeOfflineLog",c),function(){t.anys.off("refreshTraceId",n),t.anys.off("writeOfflineLog",c),clearInterval(r),window.removeEventListener("beforeunload",i)}},o.read=function(t){return this.offlineStore.read(t)},o.send=function(t){var e=this;const n=[];let r=0;t.forEach((function(t){n[r]=n[r]||[],n[r].push(t),n[r].length>200&&r++}));const o=n.map((function(t){const n=[],r=[];if(t.forEach((function(t){const{_id:e}=t,o=rt(t,nt);r.push(e),n.push(o)})),!n.length)return;const{reportUrl:o,reportParams:i}=e.anys.options;return function(t,e){return new Promise((function(n,r){const o=new(window.__XMLHttpRequest||window.XMLHttpRequest);o.open("POST",t,!0),o.onreadystatechange=function(){4==o.readyState&&(200==o.status?n(o.responseText):r(new Error("[Anys]: ajax post fail with status ".concat(o.status))))},o.onerror=r,o.send(JSON.stringify(e))}))}(i?b(o,i):o,{data:n}).then((function(){r.forEach((function(t){delete e.cache[t]}))}))}));return Promise.all(o)},o.clear=function(){this.cache={}},r}(g);function ct(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ut(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ct(Object(n),!0).forEach((function(e){st(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ct(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function st(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function at(t,e){return at=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},at(t,e)}it.dependencies=[z,$,Q,Z,L,x,I,T,N,B,et];let ft=function(t){var e,n;function r(){return t.apply(this,arguments)||this}return n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,at(e,n),r.prototype.auth=function(t){this.options.reportParams=Object.assign(this.options.reportParams||{},t)},r}(h);const lt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ft(ut(ut({namespace:"AnysTracer",autoReport:!1},t),{},{plugins:ut(ut({},t.plugins||{}),{},{recorder:it})}))}})();var n=anys="undefined"==typeof anys?{}:anys;for(var r in e)n[r]=e[r];e.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|