@noah-libjs/utils 0.0.4 → 0.0.6

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/dist/lib.js ADDED
@@ -0,0 +1,2670 @@
1
+ 'use strict';
2
+
3
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
+ var _createClass = require("@babel/runtime/helpers/createClass");
5
+ var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
6
+ var _possibleConstructorReturn = require("@babel/runtime/helpers/possibleConstructorReturn");
7
+ var _getPrototypeOf = require("@babel/runtime/helpers/getPrototypeOf");
8
+ var _inherits = require("@babel/runtime/helpers/inherits");
9
+ var _wrapNativeSuper = require("@babel/runtime/helpers/wrapNativeSuper");
10
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
11
+ var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
12
+ var _regeneratorRuntime = require("@babel/runtime/regenerator");
13
+ var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
14
+ var _typeof = require("@babel/runtime/helpers/typeof");
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
18
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
20
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
21
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
22
+ Object.defineProperty(exports, '__esModule', {
23
+ value: true
24
+ });
25
+ var dayjs = require('dayjs');
26
+ function _interopDefaultLegacy(e) {
27
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
28
+ 'default': e
29
+ };
30
+ }
31
+ var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
32
+ var isSymbol = function isSymbol(value) {
33
+ return !!value && value.constructor === Symbol;
34
+ };
35
+ var isArray = Array.isArray;
36
+ var isObject = function isObject(value) {
37
+ return !!value && value.constructor === Object;
38
+ };
39
+ var isPrimitive = function isPrimitive(value) {
40
+ return value === void 0 || value === null || _typeof(value) !== "object" && typeof value !== "function";
41
+ };
42
+ var isFunction = function isFunction(value) {
43
+ return !!(value && value.constructor && value.call && value.apply);
44
+ };
45
+ var isString = function isString(value) {
46
+ return typeof value === "string" || value instanceof String;
47
+ };
48
+ var isInt = function isInt(value) {
49
+ return isNumber(value) && value % 1 === 0;
50
+ };
51
+ var isFloat = function isFloat(value) {
52
+ return isNumber(value) && value % 1 !== 0;
53
+ };
54
+ var isNumber = function isNumber(value) {
55
+ try {
56
+ return Number(value) === value;
57
+ } catch (_unused) {
58
+ return false;
59
+ }
60
+ };
61
+ var isDate = function isDate(value) {
62
+ return Object.prototype.toString.call(value) === "[object Date]";
63
+ };
64
+ var isPromise = function isPromise(value) {
65
+ if (!value) return false;
66
+ if (!value.then) return false;
67
+ if (!isFunction(value.then)) return false;
68
+ return true;
69
+ };
70
+ var isEmpty = function isEmpty(value) {
71
+ if (value === true || value === false) return true;
72
+ if (value === null || value === void 0) return true;
73
+ if (isNumber(value)) return value === 0;
74
+ if (isDate(value)) return isNaN(value.getTime());
75
+ if (isFunction(value)) return false;
76
+ if (isSymbol(value)) return false;
77
+ var length = value.length;
78
+ if (isNumber(length)) return length === 0;
79
+ var size = value.size;
80
+ if (isNumber(size)) return size === 0;
81
+ var keys = Object.keys(value).length;
82
+ return keys === 0;
83
+ };
84
+ var _isEqual = function isEqual(x, y) {
85
+ if (Object.is(x, y)) return true;
86
+ if (x instanceof Date && y instanceof Date) {
87
+ return x.getTime() === y.getTime();
88
+ }
89
+ if (x instanceof RegExp && y instanceof RegExp) {
90
+ return x.toString() === y.toString();
91
+ }
92
+ if (_typeof(x) !== "object" || x === null || _typeof(y) !== "object" || y === null) {
93
+ return false;
94
+ }
95
+ var keysX = Reflect.ownKeys(x);
96
+ var keysY = Reflect.ownKeys(y);
97
+ if (keysX.length !== keysY.length) return false;
98
+ for (var i = 0; i < keysX.length; i++) {
99
+ if (!Reflect.has(y, keysX[i])) return false;
100
+ if (!_isEqual(x[keysX[i]], y[keysX[i]])) return false;
101
+ }
102
+ return true;
103
+ };
104
+ var group = function group(array, getGroupId) {
105
+ return array.reduce(function (acc, item) {
106
+ var groupId = getGroupId(item);
107
+ if (!acc[groupId]) acc[groupId] = [];
108
+ acc[groupId].push(item);
109
+ return acc;
110
+ }, {});
111
+ };
112
+ function zip() {
113
+ for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) {
114
+ arrays[_key] = arguments[_key];
115
+ }
116
+ if (!arrays || !arrays.length) return [];
117
+ return new Array(Math.max.apply(Math, _toConsumableArray(arrays.map(function (_ref) {
118
+ var length = _ref.length;
119
+ return length;
120
+ })))).fill([]).map(function (_, idx) {
121
+ return arrays.map(function (array) {
122
+ return array[idx];
123
+ });
124
+ });
125
+ }
126
+ function zipToObject(keys, values) {
127
+ if (!keys || !keys.length) {
128
+ return {};
129
+ }
130
+ var getValue = isFunction(values) ? values : isArray(values) ? function (_k, i) {
131
+ return values[i];
132
+ } : function (_k, _i) {
133
+ return values;
134
+ };
135
+ return keys.reduce(function (acc, key, idx) {
136
+ acc[key] = getValue(key, idx);
137
+ return acc;
138
+ }, {});
139
+ }
140
+ var boil = function boil(array, compareFunc) {
141
+ var _array$length;
142
+ if (!array || ((_array$length = array.length) !== null && _array$length !== void 0 ? _array$length : 0) === 0) return null;
143
+ return array.reduce(compareFunc);
144
+ };
145
+ function sum(array, fn) {
146
+ return (array || []).reduce(function (acc, item) {
147
+ return acc + (fn ? fn(item) : item);
148
+ }, 0);
149
+ }
150
+ var first = function first(array) {
151
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
152
+ return (array === null || array === void 0 ? void 0 : array.length) > 0 ? array[0] : defaultValue;
153
+ };
154
+ var last = function last(array) {
155
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
156
+ return (array === null || array === void 0 ? void 0 : array.length) > 0 ? array[array.length - 1] : defaultValue;
157
+ };
158
+ var sort = function sort(array, getter) {
159
+ var desc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
160
+ if (!array) return [];
161
+ var asc = function asc(a, b) {
162
+ return getter(a) - getter(b);
163
+ };
164
+ var dsc = function dsc(a, b) {
165
+ return getter(b) - getter(a);
166
+ };
167
+ return array.slice().sort(desc === true ? dsc : asc);
168
+ };
169
+ var alphabetical = function alphabetical(array, getter) {
170
+ var dir = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "asc";
171
+ if (!array) return [];
172
+ var asc = function asc(a, b) {
173
+ return "".concat(getter(a)).localeCompare(getter(b));
174
+ };
175
+ var dsc = function dsc(a, b) {
176
+ return "".concat(getter(b)).localeCompare(getter(a));
177
+ };
178
+ return array.slice().sort(dir === "desc" ? dsc : asc);
179
+ };
180
+ var counting = function counting(list2, identity) {
181
+ if (!list2) return {};
182
+ return list2.reduce(function (acc, item) {
183
+ var _acc$id;
184
+ var id = identity(item);
185
+ acc[id] = ((_acc$id = acc[id]) !== null && _acc$id !== void 0 ? _acc$id : 0) + 1;
186
+ return acc;
187
+ }, {});
188
+ };
189
+ var replace = function replace(list2, newItem, match) {
190
+ if (!list2) return [];
191
+ if (newItem === void 0) return _toConsumableArray(list2);
192
+ for (var idx = 0; idx < list2.length; idx++) {
193
+ var item = list2[idx];
194
+ if (match(item, idx)) {
195
+ return [].concat(_toConsumableArray(list2.slice(0, idx)), [newItem], _toConsumableArray(list2.slice(idx + 1, list2.length)));
196
+ }
197
+ }
198
+ return _toConsumableArray(list2);
199
+ };
200
+ var objectify = function objectify(array, getKey) {
201
+ var getValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (item) {
202
+ return item;
203
+ };
204
+ return array.reduce(function (acc, item) {
205
+ acc[getKey(item)] = getValue(item);
206
+ return acc;
207
+ }, {});
208
+ };
209
+ var select = function select(array, mapper, condition) {
210
+ if (!array) return [];
211
+ return array.reduce(function (acc, item, index) {
212
+ if (!condition(item, index)) return acc;
213
+ acc.push(mapper(item, index));
214
+ return acc;
215
+ }, []);
216
+ };
217
+ function max(array, getter) {
218
+ var get = getter !== null && getter !== void 0 ? getter : function (v) {
219
+ return v;
220
+ };
221
+ return boil(array, function (a, b) {
222
+ return get(a) > get(b) ? a : b;
223
+ });
224
+ }
225
+ function min(array, getter) {
226
+ var get = getter !== null && getter !== void 0 ? getter : function (v) {
227
+ return v;
228
+ };
229
+ return boil(array, function (a, b) {
230
+ return get(a) < get(b) ? a : b;
231
+ });
232
+ }
233
+ var cluster = function cluster(list2) {
234
+ var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
235
+ var clusterCount = Math.ceil(list2.length / size);
236
+ return new Array(clusterCount).fill(null).map(function (_c, i) {
237
+ return list2.slice(i * size, i * size + size);
238
+ });
239
+ };
240
+ var unique = function unique(array, toKey) {
241
+ var valueMap = array.reduce(function (acc, item) {
242
+ var key = toKey ? toKey(item) : item;
243
+ if (acc[key]) return acc;
244
+ acc[key] = item;
245
+ return acc;
246
+ }, {});
247
+ return Object.values(valueMap);
248
+ };
249
+ function range(startOrLength, end) {
250
+ var valueOrMapper = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (i) {
251
+ return i;
252
+ };
253
+ var step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
254
+ return /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
255
+ var mapper, start, _final, i;
256
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
257
+ while (1) switch (_context.prev = _context.next) {
258
+ case 0:
259
+ mapper = isFunction(valueOrMapper) ? valueOrMapper : function () {
260
+ return valueOrMapper;
261
+ };
262
+ start = end ? startOrLength : 0;
263
+ _final = end !== null && end !== void 0 ? end : startOrLength;
264
+ i = start;
265
+ case 4:
266
+ if (!(i <= _final)) {
267
+ _context.next = 12;
268
+ break;
269
+ }
270
+ _context.next = 7;
271
+ return mapper(i);
272
+ case 7:
273
+ if (!(i + step > _final)) {
274
+ _context.next = 9;
275
+ break;
276
+ }
277
+ return _context.abrupt("break", 12);
278
+ case 9:
279
+ i += step;
280
+ _context.next = 4;
281
+ break;
282
+ case 12:
283
+ case "end":
284
+ return _context.stop();
285
+ }
286
+ }, _callee);
287
+ })();
288
+ }
289
+ var list = function list(startOrLength, end, valueOrMapper, step) {
290
+ return Array.from(range(startOrLength, end, valueOrMapper, step));
291
+ };
292
+ var flat = function flat(lists) {
293
+ return lists.reduce(function (acc, list2) {
294
+ acc.push.apply(acc, _toConsumableArray(list2));
295
+ return acc;
296
+ }, []);
297
+ };
298
+ var intersects = function intersects(listA, listB, identity) {
299
+ if (!listA || !listB) return false;
300
+ var ident = identity !== null && identity !== void 0 ? identity : function (x) {
301
+ return x;
302
+ };
303
+ var dictB = listB.reduce(function (acc, item) {
304
+ acc[ident(item)] = true;
305
+ return acc;
306
+ }, {});
307
+ return listA.some(function (value) {
308
+ return dictB[ident(value)];
309
+ });
310
+ };
311
+ var fork = function fork(list2, condition) {
312
+ if (!list2) return [[], []];
313
+ return list2.reduce(function (acc, item) {
314
+ var _acc = _slicedToArray(acc, 2),
315
+ a = _acc[0],
316
+ b = _acc[1];
317
+ if (condition(item)) {
318
+ return [[].concat(_toConsumableArray(a), [item]), b];
319
+ } else {
320
+ return [a, [].concat(_toConsumableArray(b), [item])];
321
+ }
322
+ }, [[], []]);
323
+ };
324
+ var merge = function merge(root, others, matcher) {
325
+ if (!others && !root) return [];
326
+ if (!others) return root;
327
+ if (!root) return [];
328
+ if (!matcher) return root;
329
+ return root.reduce(function (acc, r) {
330
+ var matched = others.find(function (o) {
331
+ return matcher(r) === matcher(o);
332
+ });
333
+ if (matched) acc.push(matched);else acc.push(r);
334
+ return acc;
335
+ }, []);
336
+ };
337
+ var replaceOrAppend = function replaceOrAppend(list2, newItem, match) {
338
+ if (!list2 && !newItem) return [];
339
+ if (!newItem) return _toConsumableArray(list2);
340
+ if (!list2) return [newItem];
341
+ for (var idx = 0; idx < list2.length; idx++) {
342
+ var item = list2[idx];
343
+ if (match(item, idx)) {
344
+ return [].concat(_toConsumableArray(list2.slice(0, idx)), [newItem], _toConsumableArray(list2.slice(idx + 1, list2.length)));
345
+ }
346
+ }
347
+ return [].concat(_toConsumableArray(list2), [newItem]);
348
+ };
349
+ var toggle = function toggle(list2, item, toKey, options) {
350
+ var _options$strategy;
351
+ if (!list2 && !item) return [];
352
+ if (!list2) return [item];
353
+ if (!item) return _toConsumableArray(list2);
354
+ var matcher = toKey ? function (x, idx) {
355
+ return toKey(x, idx) === toKey(item, idx);
356
+ } : function (x) {
357
+ return x === item;
358
+ };
359
+ var existing = list2.find(matcher);
360
+ if (existing) return list2.filter(function (x, idx) {
361
+ return !matcher(x, idx);
362
+ });
363
+ var strategy = (_options$strategy = options === null || options === void 0 ? void 0 : options.strategy) !== null && _options$strategy !== void 0 ? _options$strategy : "append";
364
+ if (strategy === "append") return [].concat(_toConsumableArray(list2), [item]);
365
+ return [item].concat(_toConsumableArray(list2));
366
+ };
367
+ var sift = function sift(list2) {
368
+ var _list2$filter;
369
+ return (_list2$filter = list2 === null || list2 === void 0 ? void 0 : list2.filter(function (x) {
370
+ return !!x;
371
+ })) !== null && _list2$filter !== void 0 ? _list2$filter : [];
372
+ };
373
+ var iterate = function iterate(count, func, initValue) {
374
+ var value = initValue;
375
+ for (var i = 1; i <= count; i++) {
376
+ value = func(value, i);
377
+ }
378
+ return value;
379
+ };
380
+ var diff = function diff(root, other) {
381
+ var identity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (t) {
382
+ return t;
383
+ };
384
+ if (!(root !== null && root !== void 0 && root.length) && !(other !== null && other !== void 0 && other.length)) return [];
385
+ if ((root === null || root === void 0 ? void 0 : root.length) === void 0) return _toConsumableArray(other);
386
+ if (!(other !== null && other !== void 0 && other.length)) return _toConsumableArray(root);
387
+ var bKeys = other.reduce(function (acc, item) {
388
+ acc[identity(item)] = true;
389
+ return acc;
390
+ }, {});
391
+ return root.filter(function (a) {
392
+ return !bKeys[identity(a)];
393
+ });
394
+ };
395
+ function shift(arr, n) {
396
+ if (arr.length === 0) return arr;
397
+ var shiftNumber = n % arr.length;
398
+ if (shiftNumber === 0) return arr;
399
+ return [].concat(_toConsumableArray(arr.slice(-shiftNumber, arr.length)), _toConsumableArray(arr.slice(0, -shiftNumber)));
400
+ }
401
+ var reduce = /*#__PURE__*/function () {
402
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(array, asyncReducer, initValue) {
403
+ var initProvided, iter, value, _iterator, _step, _step$value, i, item;
404
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
405
+ while (1) switch (_context2.prev = _context2.next) {
406
+ case 0:
407
+ initProvided = initValue !== void 0;
408
+ if (!(!initProvided && (array === null || array === void 0 ? void 0 : array.length) < 1)) {
409
+ _context2.next = 3;
410
+ break;
411
+ }
412
+ throw new Error("Cannot reduce empty array with no init value");
413
+ case 3:
414
+ iter = initProvided ? array : array.slice(1);
415
+ value = initProvided ? initValue : array[0];
416
+ _iterator = _createForOfIteratorHelper(iter.entries());
417
+ _context2.prev = 6;
418
+ _iterator.s();
419
+ case 8:
420
+ if ((_step = _iterator.n()).done) {
421
+ _context2.next = 15;
422
+ break;
423
+ }
424
+ _step$value = _slicedToArray(_step.value, 2), i = _step$value[0], item = _step$value[1];
425
+ _context2.next = 12;
426
+ return asyncReducer(value, item, i);
427
+ case 12:
428
+ value = _context2.sent;
429
+ case 13:
430
+ _context2.next = 8;
431
+ break;
432
+ case 15:
433
+ _context2.next = 20;
434
+ break;
435
+ case 17:
436
+ _context2.prev = 17;
437
+ _context2.t0 = _context2["catch"](6);
438
+ _iterator.e(_context2.t0);
439
+ case 20:
440
+ _context2.prev = 20;
441
+ _iterator.f();
442
+ return _context2.finish(20);
443
+ case 23:
444
+ return _context2.abrupt("return", value);
445
+ case 24:
446
+ case "end":
447
+ return _context2.stop();
448
+ }
449
+ }, _callee2, null, [[6, 17, 20, 23]]);
450
+ }));
451
+ return function reduce(_x, _x2, _x3) {
452
+ return _ref2.apply(this, arguments);
453
+ };
454
+ }();
455
+ var map = /*#__PURE__*/function () {
456
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(array, asyncMapFunc) {
457
+ var result, index, _iterator2, _step2, value, newValue;
458
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
459
+ while (1) switch (_context3.prev = _context3.next) {
460
+ case 0:
461
+ if (array) {
462
+ _context3.next = 2;
463
+ break;
464
+ }
465
+ return _context3.abrupt("return", []);
466
+ case 2:
467
+ result = [];
468
+ index = 0;
469
+ _iterator2 = _createForOfIteratorHelper(array);
470
+ _context3.prev = 5;
471
+ _iterator2.s();
472
+ case 7:
473
+ if ((_step2 = _iterator2.n()).done) {
474
+ _context3.next = 15;
475
+ break;
476
+ }
477
+ value = _step2.value;
478
+ _context3.next = 11;
479
+ return asyncMapFunc(value, index++);
480
+ case 11:
481
+ newValue = _context3.sent;
482
+ result.push(newValue);
483
+ case 13:
484
+ _context3.next = 7;
485
+ break;
486
+ case 15:
487
+ _context3.next = 20;
488
+ break;
489
+ case 17:
490
+ _context3.prev = 17;
491
+ _context3.t0 = _context3["catch"](5);
492
+ _iterator2.e(_context3.t0);
493
+ case 20:
494
+ _context3.prev = 20;
495
+ _iterator2.f();
496
+ return _context3.finish(20);
497
+ case 23:
498
+ return _context3.abrupt("return", result);
499
+ case 24:
500
+ case "end":
501
+ return _context3.stop();
502
+ }
503
+ }, _callee3, null, [[5, 17, 20, 23]]);
504
+ }));
505
+ return function map(_x4, _x5) {
506
+ return _ref3.apply(this, arguments);
507
+ };
508
+ }();
509
+ var defer = /*#__PURE__*/function () {
510
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(func) {
511
+ var callbacks, register, _yield$tryit, _yield$tryit2, err, response, _i2, _callbacks, _callbacks$_i, fn, rethrow, _yield$tryit3, _yield$tryit4, rethrown;
512
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
513
+ while (1) switch (_context4.prev = _context4.next) {
514
+ case 0:
515
+ callbacks = [];
516
+ register = function register(fn, options) {
517
+ var _options$rethrow;
518
+ return callbacks.push({
519
+ fn: fn,
520
+ rethrow: (_options$rethrow = options === null || options === void 0 ? void 0 : options.rethrow) !== null && _options$rethrow !== void 0 ? _options$rethrow : false
521
+ });
522
+ };
523
+ _context4.next = 4;
524
+ return tryit(func)(register);
525
+ case 4:
526
+ _yield$tryit = _context4.sent;
527
+ _yield$tryit2 = _slicedToArray(_yield$tryit, 2);
528
+ err = _yield$tryit2[0];
529
+ response = _yield$tryit2[1];
530
+ _i2 = 0, _callbacks = callbacks;
531
+ case 9:
532
+ if (!(_i2 < _callbacks.length)) {
533
+ _context4.next = 21;
534
+ break;
535
+ }
536
+ _callbacks$_i = _callbacks[_i2], fn = _callbacks$_i.fn, rethrow = _callbacks$_i.rethrow;
537
+ _context4.next = 13;
538
+ return tryit(fn)(err);
539
+ case 13:
540
+ _yield$tryit3 = _context4.sent;
541
+ _yield$tryit4 = _slicedToArray(_yield$tryit3, 1);
542
+ rethrown = _yield$tryit4[0];
543
+ if (!(rethrown && rethrow)) {
544
+ _context4.next = 18;
545
+ break;
546
+ }
547
+ throw rethrown;
548
+ case 18:
549
+ _i2++;
550
+ _context4.next = 9;
551
+ break;
552
+ case 21:
553
+ if (!err) {
554
+ _context4.next = 23;
555
+ break;
556
+ }
557
+ throw err;
558
+ case 23:
559
+ return _context4.abrupt("return", response);
560
+ case 24:
561
+ case "end":
562
+ return _context4.stop();
563
+ }
564
+ }, _callee4);
565
+ }));
566
+ return function defer(_x6) {
567
+ return _ref4.apply(this, arguments);
568
+ };
569
+ }();
570
+ var AggregateError = /*#__PURE__*/function (_Error) {
571
+ function AggregateError() {
572
+ var _errors$find$name, _errors$find, _errors$find$stack, _errors$find2;
573
+ var _this;
574
+ var errors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
575
+ _classCallCheck(this, AggregateError);
576
+ _this = _callSuper(this, AggregateError);
577
+ var name = (_errors$find$name = (_errors$find = errors.find(function (e) {
578
+ return e.name;
579
+ })) === null || _errors$find === void 0 ? void 0 : _errors$find.name) !== null && _errors$find$name !== void 0 ? _errors$find$name : "";
580
+ _this.name = "AggregateError(".concat(name, "...)");
581
+ _this.message = "AggregateError with ".concat(errors.length, " errors");
582
+ _this.stack = (_errors$find$stack = (_errors$find2 = errors.find(function (e) {
583
+ return e.stack;
584
+ })) === null || _errors$find2 === void 0 ? void 0 : _errors$find2.stack) !== null && _errors$find$stack !== void 0 ? _errors$find$stack : _this.stack;
585
+ _this.errors = errors;
586
+ return _this;
587
+ }
588
+ _inherits(AggregateError, _Error);
589
+ return _createClass(AggregateError);
590
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
591
+ var parallel = /*#__PURE__*/function () {
592
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(limit, array, func) {
593
+ var work, processor, queues, itemResults, _fork, _fork2, errors, results;
594
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
595
+ while (1) switch (_context6.prev = _context6.next) {
596
+ case 0:
597
+ work = array.map(function (item, index) {
598
+ return {
599
+ index: index,
600
+ item: item
601
+ };
602
+ });
603
+ processor = /*#__PURE__*/function () {
604
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(res) {
605
+ var results2, next, _yield$tryit5, _yield$tryit6, error, result;
606
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
607
+ while (1) switch (_context5.prev = _context5.next) {
608
+ case 0:
609
+ results2 = [];
610
+ case 1:
611
+ if (!true) {
612
+ _context5.next = 14;
613
+ break;
614
+ }
615
+ next = work.pop();
616
+ if (next) {
617
+ _context5.next = 5;
618
+ break;
619
+ }
620
+ return _context5.abrupt("return", res(results2));
621
+ case 5:
622
+ _context5.next = 7;
623
+ return tryit(func)(next.item);
624
+ case 7:
625
+ _yield$tryit5 = _context5.sent;
626
+ _yield$tryit6 = _slicedToArray(_yield$tryit5, 2);
627
+ error = _yield$tryit6[0];
628
+ result = _yield$tryit6[1];
629
+ results2.push({
630
+ error: error,
631
+ result: result,
632
+ index: next.index
633
+ });
634
+ _context5.next = 1;
635
+ break;
636
+ case 14:
637
+ case "end":
638
+ return _context5.stop();
639
+ }
640
+ }, _callee5);
641
+ }));
642
+ return function processor(_x10) {
643
+ return _ref6.apply(this, arguments);
644
+ };
645
+ }();
646
+ queues = list(1, limit).map(function () {
647
+ return new Promise(processor);
648
+ });
649
+ _context6.next = 5;
650
+ return Promise.all(queues);
651
+ case 5:
652
+ itemResults = _context6.sent;
653
+ _fork = fork(sort(itemResults.flat(), function (r) {
654
+ return r.index;
655
+ }), function (x) {
656
+ return !!x.error;
657
+ }), _fork2 = _slicedToArray(_fork, 2), errors = _fork2[0], results = _fork2[1];
658
+ if (!(errors.length > 0)) {
659
+ _context6.next = 9;
660
+ break;
661
+ }
662
+ throw new AggregateError(errors.map(function (error) {
663
+ return error.error;
664
+ }));
665
+ case 9:
666
+ return _context6.abrupt("return", results.map(function (r) {
667
+ return r.result;
668
+ }));
669
+ case 10:
670
+ case "end":
671
+ return _context6.stop();
672
+ }
673
+ }, _callee6);
674
+ }));
675
+ return function parallel(_x7, _x8, _x9) {
676
+ return _ref5.apply(this, arguments);
677
+ };
678
+ }();
679
+ function all(_x11) {
680
+ return _all.apply(this, arguments);
681
+ }
682
+ function _all() {
683
+ _all = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(promises) {
684
+ var entries, results, exceptions;
685
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
686
+ while (1) switch (_context11.prev = _context11.next) {
687
+ case 0:
688
+ entries = isArray(promises) ? promises.map(function (p) {
689
+ return [null, p];
690
+ }) : Object.entries(promises);
691
+ _context11.next = 3;
692
+ return Promise.all(entries.map(function (_ref19) {
693
+ var _ref20 = _slicedToArray(_ref19, 2),
694
+ key = _ref20[0],
695
+ value = _ref20[1];
696
+ return value.then(function (result) {
697
+ return {
698
+ result: result,
699
+ exc: null,
700
+ key: key
701
+ };
702
+ })["catch"](function (exc) {
703
+ return {
704
+ result: null,
705
+ exc: exc,
706
+ key: key
707
+ };
708
+ });
709
+ }));
710
+ case 3:
711
+ results = _context11.sent;
712
+ exceptions = results.filter(function (r) {
713
+ return r.exc;
714
+ });
715
+ if (!(exceptions.length > 0)) {
716
+ _context11.next = 7;
717
+ break;
718
+ }
719
+ throw new AggregateError(exceptions.map(function (e) {
720
+ return e.exc;
721
+ }));
722
+ case 7:
723
+ if (!isArray(promises)) {
724
+ _context11.next = 9;
725
+ break;
726
+ }
727
+ return _context11.abrupt("return", results.map(function (r) {
728
+ return r.result;
729
+ }));
730
+ case 9:
731
+ return _context11.abrupt("return", results.reduce(function (acc, item) {
732
+ return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, item.key, item.result));
733
+ }, {}));
734
+ case 10:
735
+ case "end":
736
+ return _context11.stop();
737
+ }
738
+ }, _callee11);
739
+ }));
740
+ return _all.apply(this, arguments);
741
+ }
742
+ var retry = /*#__PURE__*/function () {
743
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(options, func) {
744
+ var _options$times, _options$backoff;
745
+ var times, delay, backoff, _iterator3, _step3, i, _yield$tryit7, _yield$tryit8, err, result;
746
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
747
+ while (1) switch (_context7.prev = _context7.next) {
748
+ case 0:
749
+ times = (_options$times = options === null || options === void 0 ? void 0 : options.times) !== null && _options$times !== void 0 ? _options$times : 3;
750
+ delay = options === null || options === void 0 ? void 0 : options.delay;
751
+ backoff = (_options$backoff = options === null || options === void 0 ? void 0 : options.backoff) !== null && _options$backoff !== void 0 ? _options$backoff : null;
752
+ _iterator3 = _createForOfIteratorHelper(range(1, times));
753
+ _context7.prev = 4;
754
+ _iterator3.s();
755
+ case 6:
756
+ if ((_step3 = _iterator3.n()).done) {
757
+ _context7.next = 28;
758
+ break;
759
+ }
760
+ i = _step3.value;
761
+ _context7.next = 10;
762
+ return tryit(func)(function (err2) {
763
+ throw {
764
+ _exited: err2
765
+ };
766
+ });
767
+ case 10:
768
+ _yield$tryit7 = _context7.sent;
769
+ _yield$tryit8 = _slicedToArray(_yield$tryit7, 2);
770
+ err = _yield$tryit8[0];
771
+ result = _yield$tryit8[1];
772
+ if (err) {
773
+ _context7.next = 16;
774
+ break;
775
+ }
776
+ return _context7.abrupt("return", result);
777
+ case 16:
778
+ if (!err._exited) {
779
+ _context7.next = 18;
780
+ break;
781
+ }
782
+ throw err._exited;
783
+ case 18:
784
+ if (!(i === times)) {
785
+ _context7.next = 20;
786
+ break;
787
+ }
788
+ throw err;
789
+ case 20:
790
+ if (!delay) {
791
+ _context7.next = 23;
792
+ break;
793
+ }
794
+ _context7.next = 23;
795
+ return sleep(delay);
796
+ case 23:
797
+ if (!backoff) {
798
+ _context7.next = 26;
799
+ break;
800
+ }
801
+ _context7.next = 26;
802
+ return sleep(backoff(i));
803
+ case 26:
804
+ _context7.next = 6;
805
+ break;
806
+ case 28:
807
+ _context7.next = 33;
808
+ break;
809
+ case 30:
810
+ _context7.prev = 30;
811
+ _context7.t0 = _context7["catch"](4);
812
+ _iterator3.e(_context7.t0);
813
+ case 33:
814
+ _context7.prev = 33;
815
+ _iterator3.f();
816
+ return _context7.finish(33);
817
+ case 36:
818
+ return _context7.abrupt("return", void 0);
819
+ case 37:
820
+ case "end":
821
+ return _context7.stop();
822
+ }
823
+ }, _callee7, null, [[4, 30, 33, 36]]);
824
+ }));
825
+ return function retry(_x12, _x13) {
826
+ return _ref7.apply(this, arguments);
827
+ };
828
+ }();
829
+ var sleep = function sleep(milliseconds) {
830
+ return new Promise(function (res) {
831
+ return setTimeout(res, milliseconds);
832
+ });
833
+ };
834
+ var tryit = function tryit(func) {
835
+ return function () {
836
+ try {
837
+ var result = func.apply(void 0, arguments);
838
+ if (isPromise(result)) {
839
+ return result.then(function (value) {
840
+ return [void 0, value];
841
+ })["catch"](function (err) {
842
+ return [err, void 0];
843
+ });
844
+ }
845
+ return [void 0, result];
846
+ } catch (err) {
847
+ return [err, void 0];
848
+ }
849
+ };
850
+ };
851
+ var guard = function guard(func, shouldGuard) {
852
+ var _guard = function _guard(err) {
853
+ if (shouldGuard && !shouldGuard(err)) throw err;
854
+ return void 0;
855
+ };
856
+ var isPromise2 = function isPromise2(result) {
857
+ return result instanceof Promise;
858
+ };
859
+ try {
860
+ var result = func();
861
+ return isPromise2(result) ? result["catch"](_guard) : result;
862
+ } catch (err) {
863
+ return _guard(err);
864
+ }
865
+ };
866
+ function chain() {
867
+ for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
868
+ funcs[_key2] = arguments[_key2];
869
+ }
870
+ return function () {
871
+ return funcs.slice(1).reduce(function (acc, fn) {
872
+ return fn(acc);
873
+ }, funcs[0].apply(funcs, arguments));
874
+ };
875
+ }
876
+ function compose() {
877
+ for (var _len3 = arguments.length, funcs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
878
+ funcs[_key3] = arguments[_key3];
879
+ }
880
+ return funcs.reverse().reduce(function (acc, fn) {
881
+ return fn(acc);
882
+ });
883
+ }
884
+ var partial = function partial(fn) {
885
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
886
+ args[_key4 - 1] = arguments[_key4];
887
+ }
888
+ return function () {
889
+ for (var _len5 = arguments.length, rest = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
890
+ rest[_key5] = arguments[_key5];
891
+ }
892
+ return fn.apply(void 0, [].concat(args, rest));
893
+ };
894
+ };
895
+ var partob = function partob(fn, argobj) {
896
+ return function (restobj) {
897
+ return fn(_objectSpread(_objectSpread({}, argobj), restobj));
898
+ };
899
+ };
900
+ var proxied = function proxied(handler) {
901
+ return new Proxy({}, {
902
+ get: function get(target, propertyName) {
903
+ return handler(propertyName);
904
+ }
905
+ });
906
+ };
907
+ var memoize = function memoize(cache, func, keyFunc, ttl) {
908
+ return function callWithMemo() {
909
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
910
+ args[_key6] = arguments[_key6];
911
+ }
912
+ var key = keyFunc ? keyFunc.apply(void 0, args) : JSON.stringify({
913
+ args: args
914
+ });
915
+ var existing = cache[key];
916
+ if (existing !== void 0) {
917
+ if (!existing.exp) return existing.value;
918
+ if (existing.exp > new Date().getTime()) {
919
+ return existing.value;
920
+ }
921
+ }
922
+ var result = func.apply(void 0, args);
923
+ cache[key] = {
924
+ exp: ttl ? new Date().getTime() + ttl : null,
925
+ value: result
926
+ };
927
+ return result;
928
+ };
929
+ };
930
+ var memo = function memo(func) {
931
+ var _options$key, _options$ttl;
932
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
933
+ return memoize({}, func, (_options$key = options.key) !== null && _options$key !== void 0 ? _options$key : null, (_options$ttl = options.ttl) !== null && _options$ttl !== void 0 ? _options$ttl : null);
934
+ };
935
+ var debounce = function debounce(_ref8, func) {
936
+ var delay = _ref8.delay;
937
+ var timer = void 0;
938
+ var active = true;
939
+ var debounced = function debounced() {
940
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
941
+ args[_key7] = arguments[_key7];
942
+ }
943
+ if (active) {
944
+ clearTimeout(timer);
945
+ timer = setTimeout(function () {
946
+ active && func.apply(void 0, args);
947
+ timer = void 0;
948
+ }, delay);
949
+ } else {
950
+ func.apply(void 0, args);
951
+ }
952
+ };
953
+ debounced.isPending = function () {
954
+ return timer !== void 0;
955
+ };
956
+ debounced.cancel = function () {
957
+ active = false;
958
+ };
959
+ debounced.flush = function () {
960
+ return func.apply(void 0, arguments);
961
+ };
962
+ return debounced;
963
+ };
964
+ var throttle = function throttle(_ref9, func) {
965
+ var interval = _ref9.interval;
966
+ var ready = true;
967
+ var timer = void 0;
968
+ var throttled = function throttled() {
969
+ if (!ready) return;
970
+ func.apply(void 0, arguments);
971
+ ready = false;
972
+ timer = setTimeout(function () {
973
+ ready = true;
974
+ timer = void 0;
975
+ }, interval);
976
+ };
977
+ throttled.isThrottled = function () {
978
+ return timer !== void 0;
979
+ };
980
+ return throttled;
981
+ };
982
+ var callable = function callable(obj, fn) {
983
+ var FUNC = function FUNC() {};
984
+ return new Proxy(Object.assign(FUNC, obj), {
985
+ get: function get(target, key) {
986
+ return target[key];
987
+ },
988
+ set: function set(target, key, value) {
989
+ target[key] = value;
990
+ return true;
991
+ },
992
+ apply: function apply(target, self, args) {
993
+ return fn(Object.assign({}, target)).apply(void 0, _toConsumableArray(args));
994
+ }
995
+ });
996
+ };
997
+ function inRange(number, start, end) {
998
+ var isTypeSafe = typeof number === "number" && typeof start === "number" && (typeof end === "undefined" || typeof end === "number");
999
+ if (!isTypeSafe) {
1000
+ return false;
1001
+ }
1002
+ if (typeof end === "undefined") {
1003
+ end = start;
1004
+ start = 0;
1005
+ }
1006
+ return number >= Math.min(start, end) && number < Math.max(start, end);
1007
+ }
1008
+ var toFloat = function toFloat(value, defaultValue) {
1009
+ var def = defaultValue === void 0 ? 0 : defaultValue;
1010
+ if (value === null || value === void 0) {
1011
+ return def;
1012
+ }
1013
+ var result = parseFloat(value);
1014
+ return isNaN(result) ? def : result;
1015
+ };
1016
+ var toInt = function toInt(value, defaultValue) {
1017
+ var def = defaultValue === void 0 ? 0 : defaultValue;
1018
+ if (value === null || value === void 0) {
1019
+ return def;
1020
+ }
1021
+ var result = parseInt(value);
1022
+ return isNaN(result) ? def : result;
1023
+ };
1024
+ var shake = function shake(obj) {
1025
+ var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) {
1026
+ return x === void 0;
1027
+ };
1028
+ if (!obj) return {};
1029
+ var keys2 = Object.keys(obj);
1030
+ return keys2.reduce(function (acc, key) {
1031
+ if (filter(obj[key])) {
1032
+ return acc;
1033
+ } else {
1034
+ acc[key] = obj[key];
1035
+ return acc;
1036
+ }
1037
+ }, {});
1038
+ };
1039
+ var mapKeys = function mapKeys(obj, mapFunc) {
1040
+ var keys2 = Object.keys(obj);
1041
+ return keys2.reduce(function (acc, key) {
1042
+ acc[mapFunc(key, obj[key])] = obj[key];
1043
+ return acc;
1044
+ }, {});
1045
+ };
1046
+ var mapValues = function mapValues(obj, mapFunc) {
1047
+ var keys2 = Object.keys(obj);
1048
+ return keys2.reduce(function (acc, key) {
1049
+ acc[key] = mapFunc(obj[key], key);
1050
+ return acc;
1051
+ }, {});
1052
+ };
1053
+ var mapEntries = function mapEntries(obj, toEntry) {
1054
+ if (!obj) return {};
1055
+ return Object.entries(obj).reduce(function (acc, _ref10) {
1056
+ var _ref11 = _slicedToArray(_ref10, 2),
1057
+ key = _ref11[0],
1058
+ value = _ref11[1];
1059
+ var _toEntry = toEntry(key, value),
1060
+ _toEntry2 = _slicedToArray(_toEntry, 2),
1061
+ newKey = _toEntry2[0],
1062
+ newValue = _toEntry2[1];
1063
+ acc[newKey] = newValue;
1064
+ return acc;
1065
+ }, {});
1066
+ };
1067
+ var invert = function invert(obj) {
1068
+ if (!obj) return {};
1069
+ var keys2 = Object.keys(obj);
1070
+ return keys2.reduce(function (acc, key) {
1071
+ acc[obj[key]] = key;
1072
+ return acc;
1073
+ }, {});
1074
+ };
1075
+ var lowerize = function lowerize(obj) {
1076
+ return mapKeys(obj, function (k) {
1077
+ return k.toLowerCase();
1078
+ });
1079
+ };
1080
+ var upperize = function upperize(obj) {
1081
+ return mapKeys(obj, function (k) {
1082
+ return k.toUpperCase();
1083
+ });
1084
+ };
1085
+ var clone = function clone(obj) {
1086
+ if (isPrimitive(obj)) {
1087
+ return obj;
1088
+ }
1089
+ if (typeof obj === "function") {
1090
+ return obj.bind({});
1091
+ }
1092
+ var newObj = new obj.constructor();
1093
+ Object.getOwnPropertyNames(obj).forEach(function (prop) {
1094
+ newObj[prop] = obj[prop];
1095
+ });
1096
+ return newObj;
1097
+ };
1098
+ var listify = function listify(obj, toItem) {
1099
+ if (!obj) return [];
1100
+ var entries = Object.entries(obj);
1101
+ if (entries.length === 0) return [];
1102
+ return entries.reduce(function (acc, entry) {
1103
+ acc.push(toItem(entry[0], entry[1]));
1104
+ return acc;
1105
+ }, []);
1106
+ };
1107
+ var pick = function pick(obj, keys2) {
1108
+ if (!obj) return {};
1109
+ return keys2.reduce(function (acc, key) {
1110
+ if (Object.prototype.hasOwnProperty.call(obj, key)) acc[key] = obj[key];
1111
+ return acc;
1112
+ }, {});
1113
+ };
1114
+ var omit = function omit(obj, keys2) {
1115
+ if (!obj) return {};
1116
+ if (!keys2 || keys2.length === 0) return obj;
1117
+ return keys2.reduce(function (acc, key) {
1118
+ delete acc[key];
1119
+ return acc;
1120
+ }, _objectSpread({}, obj));
1121
+ };
1122
+ var get$1 = function get$1(value, path, defaultValue) {
1123
+ var segments = path.split(/[\.\[\]]/g);
1124
+ var current = value;
1125
+ var _iterator4 = _createForOfIteratorHelper(segments),
1126
+ _step4;
1127
+ try {
1128
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1129
+ var key = _step4.value;
1130
+ if (current === null) return defaultValue;
1131
+ if (current === void 0) return defaultValue;
1132
+ var dequoted = key.replace(/['"]/g, "");
1133
+ if (dequoted.trim() === "") continue;
1134
+ current = current[dequoted];
1135
+ }
1136
+ } catch (err) {
1137
+ _iterator4.e(err);
1138
+ } finally {
1139
+ _iterator4.f();
1140
+ }
1141
+ if (current === void 0) return defaultValue;
1142
+ return current;
1143
+ };
1144
+ var set = function set(initial, path, value) {
1145
+ if (!initial) return {};
1146
+ if (!path || value === void 0) return initial;
1147
+ var segments = path.split(/[\.\[\]]/g).filter(function (x) {
1148
+ return !!x.trim();
1149
+ });
1150
+ var _set2 = function _set(node) {
1151
+ if (segments.length > 1) {
1152
+ var key = segments.shift();
1153
+ var nextIsNum = toInt(segments[0], null) === null ? false : true;
1154
+ node[key] = node[key] === void 0 ? nextIsNum ? [] : {} : node[key];
1155
+ _set2(node[key]);
1156
+ } else {
1157
+ node[segments[0]] = value;
1158
+ }
1159
+ };
1160
+ var cloned = clone(initial);
1161
+ _set2(cloned);
1162
+ return cloned;
1163
+ };
1164
+ var _assign = function assign(initial, override) {
1165
+ var _ref12;
1166
+ if (!initial || !override) return (_ref12 = initial !== null && initial !== void 0 ? initial : override) !== null && _ref12 !== void 0 ? _ref12 : {};
1167
+ return Object.entries(_objectSpread(_objectSpread({}, initial), override)).reduce(function (acc, _ref13) {
1168
+ var _ref14 = _slicedToArray(_ref13, 2),
1169
+ key = _ref14[0],
1170
+ value = _ref14[1];
1171
+ return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, function () {
1172
+ if (isObject(initial[key])) return _assign(initial[key], value);
1173
+ return value;
1174
+ }()));
1175
+ }, {});
1176
+ };
1177
+ var keys = function keys(value) {
1178
+ if (!value) return [];
1179
+ var _getKeys = function getKeys(nested, paths) {
1180
+ if (isObject(nested)) {
1181
+ return Object.entries(nested).flatMap(function (_ref15) {
1182
+ var _ref16 = _slicedToArray(_ref15, 2),
1183
+ k = _ref16[0],
1184
+ v = _ref16[1];
1185
+ return _getKeys(v, [].concat(_toConsumableArray(paths), [k]));
1186
+ });
1187
+ }
1188
+ if (isArray(nested)) {
1189
+ return nested.flatMap(function (item, i) {
1190
+ return _getKeys(item, [].concat(_toConsumableArray(paths), ["".concat(i)]));
1191
+ });
1192
+ }
1193
+ return [paths.join(".")];
1194
+ };
1195
+ return _getKeys(value, []);
1196
+ };
1197
+ var crush = function crush(value) {
1198
+ if (!value) return {};
1199
+ return objectify(keys(value), function (k) {
1200
+ return k;
1201
+ }, function (k) {
1202
+ return get$1(value, k);
1203
+ });
1204
+ };
1205
+ var construct = function construct(obj) {
1206
+ if (!obj) return {};
1207
+ return Object.keys(obj).reduce(function (acc, path) {
1208
+ return set(acc, path, obj[path]);
1209
+ }, {});
1210
+ };
1211
+ var random = function random(min, max) {
1212
+ return Math.floor(Math.random() * (max - min + 1) + min);
1213
+ };
1214
+ var draw = function draw(array) {
1215
+ var max = array.length;
1216
+ if (max === 0) {
1217
+ return null;
1218
+ }
1219
+ var index = random(0, max - 1);
1220
+ return array[index];
1221
+ };
1222
+ var shuffle = function shuffle(array) {
1223
+ return array.map(function (a) {
1224
+ return {
1225
+ rand: Math.random(),
1226
+ value: a
1227
+ };
1228
+ }).sort(function (a, b) {
1229
+ return a.rand - b.rand;
1230
+ }).map(function (a) {
1231
+ return a.value;
1232
+ });
1233
+ };
1234
+ var uid = function uid(length) {
1235
+ var specials = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
1236
+ var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + specials;
1237
+ return iterate(length, function (acc) {
1238
+ return acc + characters.charAt(random(0, characters.length - 1));
1239
+ }, "");
1240
+ };
1241
+ var series = function series(items) {
1242
+ var toKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (item) {
1243
+ return "".concat(item);
1244
+ };
1245
+ var _items$reduce = items.reduce(function (acc, item, idx) {
1246
+ return {
1247
+ indexesByKey: _objectSpread(_objectSpread({}, acc.indexesByKey), {}, _defineProperty({}, toKey(item), idx)),
1248
+ itemsByIndex: _objectSpread(_objectSpread({}, acc.itemsByIndex), {}, _defineProperty({}, idx, item))
1249
+ };
1250
+ }, {
1251
+ indexesByKey: {},
1252
+ itemsByIndex: {}
1253
+ }),
1254
+ indexesByKey = _items$reduce.indexesByKey,
1255
+ itemsByIndex = _items$reduce.itemsByIndex;
1256
+ var min = function min(a, b) {
1257
+ return indexesByKey[toKey(a)] < indexesByKey[toKey(b)] ? a : b;
1258
+ };
1259
+ var max = function max(a, b) {
1260
+ return indexesByKey[toKey(a)] > indexesByKey[toKey(b)] ? a : b;
1261
+ };
1262
+ var first = function first() {
1263
+ return itemsByIndex[0];
1264
+ };
1265
+ var last = function last() {
1266
+ return itemsByIndex[items.length - 1];
1267
+ };
1268
+ var next = function next(current, defaultValue) {
1269
+ var _ref17, _itemsByIndex;
1270
+ return (_ref17 = (_itemsByIndex = itemsByIndex[indexesByKey[toKey(current)] + 1]) !== null && _itemsByIndex !== void 0 ? _itemsByIndex : defaultValue) !== null && _ref17 !== void 0 ? _ref17 : first();
1271
+ };
1272
+ var previous = function previous(current, defaultValue) {
1273
+ var _ref18, _itemsByIndex2;
1274
+ return (_ref18 = (_itemsByIndex2 = itemsByIndex[indexesByKey[toKey(current)] - 1]) !== null && _itemsByIndex2 !== void 0 ? _itemsByIndex2 : defaultValue) !== null && _ref18 !== void 0 ? _ref18 : last();
1275
+ };
1276
+ var spin = function spin(current, num) {
1277
+ if (num === 0) return current;
1278
+ var abs = Math.abs(num);
1279
+ var rel = abs > items.length ? abs % items.length : abs;
1280
+ return list(0, rel - 1).reduce(function (acc) {
1281
+ return num > 0 ? next(acc) : previous(acc);
1282
+ }, current);
1283
+ };
1284
+ return {
1285
+ min: min,
1286
+ max: max,
1287
+ first: first,
1288
+ last: last,
1289
+ next: next,
1290
+ previous: previous,
1291
+ spin: spin
1292
+ };
1293
+ };
1294
+ var capitalize = function capitalize(str) {
1295
+ if (!str || str.length === 0) return "";
1296
+ var lower = str.toLowerCase();
1297
+ return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length);
1298
+ };
1299
+ var camel = function camel(str) {
1300
+ var _str$replace$split$ma, _str$replace;
1301
+ var parts = (_str$replace$split$ma = str === null || str === void 0 || (_str$replace = str.replace(/([A-Z])+/g, capitalize)) === null || _str$replace === void 0 ? void 0 : _str$replace.split(/(?=[A-Z])|[\.\-\s_]/).map(function (x) {
1302
+ return x.toLowerCase();
1303
+ })) !== null && _str$replace$split$ma !== void 0 ? _str$replace$split$ma : [];
1304
+ if (parts.length === 0) return "";
1305
+ if (parts.length === 1) return parts[0];
1306
+ return parts.reduce(function (acc, part) {
1307
+ return "".concat(acc).concat(part.charAt(0).toUpperCase()).concat(part.slice(1));
1308
+ });
1309
+ };
1310
+ var snake = function snake(str, options) {
1311
+ var _str$replace$split$ma2;
1312
+ var parts = (_str$replace$split$ma2 = str === null || str === void 0 ? void 0 : str.replace(/([A-Z])+/g, capitalize).split(/(?=[A-Z])|[\.\-\s_]/).map(function (x) {
1313
+ return x.toLowerCase();
1314
+ })) !== null && _str$replace$split$ma2 !== void 0 ? _str$replace$split$ma2 : [];
1315
+ if (parts.length === 0) return "";
1316
+ if (parts.length === 1) return parts[0];
1317
+ var result = parts.reduce(function (acc, part) {
1318
+ return "".concat(acc, "_").concat(part.toLowerCase());
1319
+ });
1320
+ return (options === null || options === void 0 ? void 0 : options.splitOnNumber) === false ? result : result.replace(/([A-Za-z]{1}[0-9]{1})/, function (val) {
1321
+ return "".concat(val[0], "_").concat(val[1]);
1322
+ });
1323
+ };
1324
+ var dash = function dash(str) {
1325
+ var _str$replace$split$ma3, _str$replace2;
1326
+ var parts = (_str$replace$split$ma3 = str === null || str === void 0 || (_str$replace2 = str.replace(/([A-Z])+/g, capitalize)) === null || _str$replace2 === void 0 ? void 0 : _str$replace2.split(/(?=[A-Z])|[\.\-\s_]/).map(function (x) {
1327
+ return x.toLowerCase();
1328
+ })) !== null && _str$replace$split$ma3 !== void 0 ? _str$replace$split$ma3 : [];
1329
+ if (parts.length === 0) return "";
1330
+ if (parts.length === 1) return parts[0];
1331
+ return parts.reduce(function (acc, part) {
1332
+ return "".concat(acc, "-").concat(part.toLowerCase());
1333
+ });
1334
+ };
1335
+ var pascal = function pascal(str) {
1336
+ var _str$split$map;
1337
+ var parts = (_str$split$map = str === null || str === void 0 ? void 0 : str.split(/[\.\-\s_]/).map(function (x) {
1338
+ return x.toLowerCase();
1339
+ })) !== null && _str$split$map !== void 0 ? _str$split$map : [];
1340
+ if (parts.length === 0) return "";
1341
+ return parts.map(function (str2) {
1342
+ return str2.charAt(0).toUpperCase() + str2.slice(1);
1343
+ }).join("");
1344
+ };
1345
+ var title = function title(str) {
1346
+ if (!str) return "";
1347
+ return str.split(/(?=[A-Z])|[\.\-\s_]/).map(function (s) {
1348
+ return s.trim();
1349
+ }).filter(function (s) {
1350
+ return !!s;
1351
+ }).map(function (s) {
1352
+ return capitalize(s.toLowerCase());
1353
+ }).join(" ");
1354
+ };
1355
+ var template = function template(str, data) {
1356
+ var regex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : /\{\{(.+?)\}\}/g;
1357
+ return Array.from(str.matchAll(regex)).reduce(function (acc, match) {
1358
+ return acc.replace(match[0], data[match[1]]);
1359
+ }, str);
1360
+ };
1361
+ var trim = function trim(str) {
1362
+ var charsToTrim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : " ";
1363
+ if (!str) return "";
1364
+ var toTrim = charsToTrim.replace(/[\W]{1}/g, "\\$&");
1365
+ var regex = new RegExp("^[".concat(toTrim, "]+|[").concat(toTrim, "]+$"), "g");
1366
+ return str.replace(regex, "");
1367
+ };
1368
+ function get(value, path, defaultValue) {
1369
+ //@ts-ignore
1370
+ var direct_value = value === null || value === void 0 ? void 0 : value[path];
1371
+ if (direct_value) return direct_value;
1372
+ return get$1(value, path, defaultValue);
1373
+ }
1374
+ function identity(value) {
1375
+ return value;
1376
+ }
1377
+ var symbolProto = Symbol ? Symbol.prototype : undefined;
1378
+ var symbolToString = symbolProto ? symbolProto.toString : undefined;
1379
+ var INFINITY = 1 / 0;
1380
+ function isBoolean(value) {
1381
+ return value === true || value === false;
1382
+ }
1383
+ function isObjectLike(value) {
1384
+ return value != null && _typeof(value) == 'object';
1385
+ }
1386
+ function isNull(value) {
1387
+ return value === null;
1388
+ }
1389
+ function size(value) {
1390
+ if (isString(value) || isArray(value)) return value.length;
1391
+ if (isObject(value)) return Object.keys(value).length;
1392
+ return 0;
1393
+ }
1394
+ function isNil(value) {
1395
+ return value == null;
1396
+ }
1397
+ function toString(value) {
1398
+ return value == null ? '' : baseToString(value);
1399
+ }
1400
+ function baseToString(value) {
1401
+ // Exit early for strings to avoid a performance hit in some environments.
1402
+ if (typeof value == 'string') {
1403
+ return value;
1404
+ }
1405
+ if (isArray(value)) {
1406
+ // Recursively convert values (susceptible to call stack limits).
1407
+ return arrayMap(value, baseToString) + '';
1408
+ }
1409
+ if (isSymbol(value)) {
1410
+ return symbolToString ? symbolToString.call(value) : '';
1411
+ }
1412
+ var result = value + '';
1413
+ return result == '0' && 1 / value == -INFINITY ? '-0' : result;
1414
+ }
1415
+ function arrayMap(array, iteratee) {
1416
+ var index = -1,
1417
+ length = array == null ? 0 : array.length,
1418
+ result = Array(length);
1419
+ while (++index < length) {
1420
+ result[index] = iteratee(array[index], index, array);
1421
+ }
1422
+ return result;
1423
+ }
1424
+ function cloneDeep(value) {
1425
+ try {
1426
+ return JSON.parse(JSON.stringify(value));
1427
+ } catch (error) {
1428
+ return null;
1429
+ }
1430
+ }
1431
+ function safe_json_parse(str) {
1432
+ var retOnErr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1433
+ if (!str) return retOnErr;
1434
+ if (_typeof(str) === 'object') return str;
1435
+ if (!isString(str)) return retOnErr;
1436
+ try {
1437
+ var v = JSON.parse(str);
1438
+ return isObject(v) || Array.isArray(v) ? v : retOnErr;
1439
+ } catch (error) {
1440
+ return retOnErr;
1441
+ }
1442
+ }
1443
+ function safe_json_stringify(obj) {
1444
+ if (isString(obj) && safe_json_parse(obj)) {
1445
+ return obj;
1446
+ }
1447
+ return JSON.stringify(obj);
1448
+ }
1449
+ function safe_json_parse_arr(str) {
1450
+ var retOnErr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1451
+ if (!str) return retOnErr;
1452
+ if (Array.isArray(str)) return str;
1453
+ if (!isString(str)) return retOnErr;
1454
+ try {
1455
+ var v = JSON.parse(str);
1456
+ return Array.isArray(v) ? v : retOnErr;
1457
+ } catch (error) {
1458
+ return retOnErr;
1459
+ }
1460
+ }
1461
+
1462
+ /******************************************************************************
1463
+ Copyright (c) Microsoft Corporation.
1464
+
1465
+ Permission to use, copy, modify, and/or distribute this software for any
1466
+ purpose with or without fee is hereby granted.
1467
+
1468
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1469
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1470
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1471
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1472
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1473
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1474
+ PERFORMANCE OF THIS SOFTWARE.
1475
+ ***************************************************************************** */
1476
+ function __awaiter(thisArg, _arguments, P, generator) {
1477
+ function adopt(value) {
1478
+ return value instanceof P ? value : new P(function (resolve) {
1479
+ resolve(value);
1480
+ });
1481
+ }
1482
+ return new (P || (P = Promise))(function (resolve, reject) {
1483
+ function fulfilled(value) {
1484
+ try {
1485
+ step(generator.next(value));
1486
+ } catch (e) {
1487
+ reject(e);
1488
+ }
1489
+ }
1490
+ function rejected(value) {
1491
+ try {
1492
+ step(generator["throw"](value));
1493
+ } catch (e) {
1494
+ reject(e);
1495
+ }
1496
+ }
1497
+ function step(result) {
1498
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1499
+ }
1500
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1501
+ });
1502
+ }
1503
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1504
+ var e = new Error(message);
1505
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1506
+ };
1507
+
1508
+ // export function sleep(sec: number) {
1509
+ // return new Promise<void>((resolve) => setTimeout(resolve, sec * 1000))
1510
+ // }
1511
+ function get_global() {
1512
+ var _a;
1513
+ return (_a = window !== null && window !== void 0 ? window : globalThis) !== null && _a !== void 0 ? _a : global;
1514
+ }
1515
+ function getSearchParamsValue(key) {
1516
+ var _a, _b;
1517
+ var url = new URL(location.toString());
1518
+ return (_b = (_a = url === null || url === void 0 ? void 0 : url.searchParams) === null || _a === void 0 ? void 0 : _a.get(key)) !== null && _b !== void 0 ? _b : null;
1519
+ }
1520
+ function getSearchParamsAll(url) {
1521
+ var _url = url !== null && url !== void 0 ? url : new URL(location.href);
1522
+ var searchParams = _url ? _toConsumableArray(_url.searchParams.entries()).reduce(function (a, b) {
1523
+ return Object.assign(a, _defineProperty({}, b[0], b[1]));
1524
+ }, {}) : {};
1525
+ return searchParams;
1526
+ }
1527
+ function setSearchParamsValue(key, value) {
1528
+ var _a;
1529
+ var url = new URL(location.toString());
1530
+ (_a = url === null || url === void 0 ? void 0 : url.searchParams) === null || _a === void 0 ? void 0 : _a.set(key, "".concat(value));
1531
+ return url;
1532
+ }
1533
+ function setSearchParamsAll(data) {
1534
+ var _url = new URL(location.href);
1535
+ Object.keys(data).forEach(function (k) {
1536
+ var _a;
1537
+ (_a = _url === null || _url === void 0 ? void 0 : _url.searchParams) === null || _a === void 0 ? void 0 : _a.set(k, "".concat(data[k]));
1538
+ });
1539
+ return _url;
1540
+ }
1541
+ function scrollIntoView(symbol) {
1542
+ var finder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.querySelector.bind(document);
1543
+ var dom = finder(symbol);
1544
+ var scrollIntoViewIfNeeded = dom === null || dom === void 0 ? void 0 : dom.scrollIntoViewIfNeeded;
1545
+ if (scrollIntoViewIfNeeded) {
1546
+ scrollIntoViewIfNeeded.call(dom);
1547
+ } else {
1548
+ dom === null || dom === void 0 ? void 0 : dom.scrollIntoView({
1549
+ behavior: 'smooth'
1550
+ });
1551
+ }
1552
+ }
1553
+ function base64ToBinary(data, type) {
1554
+ var raw = get_global().atob(data);
1555
+ var uInt8Array = new Uint8Array(raw.length);
1556
+ for (var i = 0; i < raw.length; i++) {
1557
+ uInt8Array[i] = raw.charCodeAt(i);
1558
+ }
1559
+ return new Blob([uInt8Array], {
1560
+ type: type
1561
+ });
1562
+ }
1563
+ function downloadFile(content) {
1564
+ var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '问卷答题情况.xlsx';
1565
+ var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'application/vnd.ms-excel';
1566
+ var isBase64 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1567
+ var eleLink = document.createElement('a');
1568
+ eleLink.download = filename;
1569
+ eleLink.style.display = 'none';
1570
+ var blob = typeof content === 'string' ? isBase64 ? base64ToBinary(content, type) : new Blob([content], {
1571
+ type: type
1572
+ }) : content;
1573
+ eleLink.href = URL.createObjectURL(blob);
1574
+ document.body.appendChild(eleLink);
1575
+ eleLink.click();
1576
+ document.body.removeChild(eleLink);
1577
+ }
1578
+ function uuid() {
1579
+ var temp_url = URL.createObjectURL(new Blob());
1580
+ var uuid = temp_url.toString();
1581
+ URL.revokeObjectURL(temp_url);
1582
+ return uuid.slice(uuid.lastIndexOf("/") + 1);
1583
+ }
1584
+ function randomHex() {
1585
+ var hex = ~~(Math.random() * 16);
1586
+ return hex;
1587
+ }
1588
+ function charToUTF8(_char) {
1589
+ var encoder = new TextEncoder();
1590
+ var uint8Array = encoder.encode(_char[0]);
1591
+ return Array.from(uint8Array);
1592
+ }
1593
+ function charToUnicode(_char2) {
1594
+ // ES6 之后可以用 String.prototype.codePointAt() 从字符返回对应的码点
1595
+ var u = _char2.charCodeAt(0);
1596
+ var u1 = _char2.charCodeAt(0);
1597
+ var u2 = _char2.charCodeAt(1);
1598
+ if (u1 >= 0xD800 && u1 <= 0xDBFF && u2 >= 0xDC00 && u2 <= 0xDFFF) {
1599
+ u = (u1 - 0xD800 << 10 | u2 - 0xDC00) + 0x10000;
1600
+ }
1601
+ return u;
1602
+ }
1603
+ // 先转 utf-8 再 decode
1604
+ function unicodeToChar(u) {
1605
+ var arr = unicode_to_UTF8(u);
1606
+ if (!arr) return null;
1607
+ var decoder = new TextDecoder();
1608
+ var ui8 = new Uint8Array(arr);
1609
+ return decoder.decode(ui8);
1610
+ }
1611
+ function unicode_to_UTF8(u) {
1612
+ var arr = null; //utf8;
1613
+ if (u <= 0x7F) {
1614
+ arr = [u & 0xFF];
1615
+ } else if (u <= 0x07FF) {
1616
+ arr = [u >> 6 & 0x1F | 0xC0, u & 0x3F | 0x80];
1617
+ } else if (u <= 0xFFFF) {
1618
+ arr = [u >> 12 & 0x0F | 0xE0, u >> 6 & 0x3F | 0x80, u & 0x3F | 0x80];
1619
+ } else if (u <= 0x10FFFF) {
1620
+ arr = [u >> 18 & 0x07 | 0xF0, u >> 12 & 0x3F | 0x80, u >> 6 & 0x3F | 0x80, u & 0x3F | 0x80];
1621
+ }
1622
+ if (!arr) return null;
1623
+ return arr;
1624
+ }
1625
+ function getFilledArray(n) {
1626
+ return Array(n).fill(0);
1627
+ }
1628
+ function copyText(text) {
1629
+ var textareaC = document.createElement('textarea');
1630
+ textareaC.setAttribute('readonly', 'readonly');
1631
+ textareaC.value = text;
1632
+ document.body.appendChild(textareaC);
1633
+ textareaC.select();
1634
+ var res = document.execCommand('copy');
1635
+ document.body.removeChild(textareaC);
1636
+ return res;
1637
+ }
1638
+ function safeExec(fn) {
1639
+ for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
1640
+ args[_key8 - 1] = arguments[_key8];
1641
+ }
1642
+ return isFunction(fn) ? fn.apply(void 0, args) : null;
1643
+ }
1644
+ function safeGetFromFuncOrData(fn) {
1645
+ var _a;
1646
+ return (_a = safeExec(fn)) !== null && _a !== void 0 ? _a : fn;
1647
+ }
1648
+ function numberLikeCompare(a, b) {
1649
+ if (a === b) return true;
1650
+ if (isString(a) && isString(b)) {
1651
+ return a === b;
1652
+ }
1653
+ if (isNil(a) || isNil(b)) return false;
1654
+ if (isObject(a) || isObject(b)) return false;
1655
+ if (isBoolean(a) && !isBoolean(b)) return false;
1656
+ if (isBoolean(b) && !isBoolean(a)) return false;
1657
+ if (toInt(a, NaN) === toInt(b, NaN)) return true;
1658
+ if (toFloat(a, NaN) === toFloat(b, NaN)) return true;
1659
+ if (toString(a) === toString(b)) return true;
1660
+ return false;
1661
+ }
1662
+ function warpBase64Type(str, type) {
1663
+ if (!str) return str;
1664
+ if (type === 'img') {
1665
+ return str.startsWith('data:image/png;base64,') ? str : "data:image/png;base64,".concat(str);
1666
+ }
1667
+ if (type === 'pdf') {
1668
+ return str.startsWith('data:application/json;base64,') ? str : "data:application/json;base64,".concat(str);
1669
+ }
1670
+ return str;
1671
+ }
1672
+ function safe_number_parse(value) {
1673
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NaN;
1674
+ if (isNumber(value) && !isNaN(value)) return value;
1675
+ var rawParse = Number(value);
1676
+ return isNaN(rawParse) ? defaultValue : rawParse;
1677
+ }
1678
+ function expect_array(value) {
1679
+ var default_v = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1680
+ if (!Array.isArray(value)) {
1681
+ if (Array.isArray(default_v)) return default_v;
1682
+ return [];
1683
+ }
1684
+ return value;
1685
+ }
1686
+ // 生成包含字符的 svg 转义字符串
1687
+ function gen_encoded_char_svg(props) {
1688
+ var _char3 = props["char"],
1689
+ _props$size = props.size,
1690
+ size = _props$size === void 0 ? 12 : _props$size,
1691
+ _props$color = props.color,
1692
+ color = _props$color === void 0 ? 'cc0000' : _props$color;
1693
+ var _color = (color === null || color === void 0 ? void 0 : color.startsWith('#')) ? color.slice(1) : color;
1694
+ return "data:image/svg+xml,%3Csvg \n width='".concat(size + 2, "' height='").concat(size + 2, "' \n xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='50%25' y='50%25' \n font-size='").concat(size, "' \n fill='%23").concat(_color, "' \n font-weight='bold'\n text-anchor='middle' \n dominant-baseline='middle'%3E").concat(_char3, "%3C/text%3E%3C/svg%3E");
1695
+ }
1696
+ function base64_to_image(base64img) {
1697
+ return new Promise(function (res, rej) {
1698
+ if (!base64img) res(null);
1699
+ var img = new Image();
1700
+ img.onload = function () {
1701
+ res(img);
1702
+ };
1703
+ img.src = base64img;
1704
+ });
1705
+ }
1706
+ function image_to_base64(img_el) {
1707
+ if (!img_el) return null;
1708
+ var c = document.createElement('canvas');
1709
+ c.width = img_el.width;
1710
+ c.height = img_el.height;
1711
+ var ctx = c.getContext('2d');
1712
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(img_el, 0, 0, img_el.width, img_el.height);
1713
+ var base64 = c.toDataURL('image/png');
1714
+ return base64;
1715
+ }
1716
+ function filter_obj_to_url_search(obj) {
1717
+ if (!obj) return {};
1718
+ var clone_one = {};
1719
+ keys(obj).forEach(function (k) {
1720
+ var v = obj[k];
1721
+ if (isNumber(v) || isBoolean(v) || isString(v) || isNull(v)) {
1722
+ clone_one[k] = v;
1723
+ }
1724
+ });
1725
+ return clone_one;
1726
+ }
1727
+ function safe_async_call(cb) {
1728
+ for (var _len9 = arguments.length, args = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) {
1729
+ args[_key9 - 1] = arguments[_key9];
1730
+ }
1731
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
1732
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
1733
+ while (1) switch (_context8.prev = _context8.next) {
1734
+ case 0:
1735
+ if (isFunction(cb)) {
1736
+ _context8.next = 2;
1737
+ break;
1738
+ }
1739
+ return _context8.abrupt("return", null);
1740
+ case 2:
1741
+ _context8.next = 4;
1742
+ return Promise.resolve(cb.apply(void 0, args));
1743
+ case 4:
1744
+ return _context8.abrupt("return", _context8.sent);
1745
+ case 5:
1746
+ case "end":
1747
+ return _context8.stop();
1748
+ }
1749
+ }, _callee8);
1750
+ }));
1751
+ }
1752
+ get_global().safe_async_call = safe_async_call;
1753
+ var global_cache_map = {};
1754
+ function cache_fetch(key, cb) {
1755
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
1756
+ var _a, conf;
1757
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
1758
+ while (1) switch (_context9.prev = _context9.next) {
1759
+ case 0:
1760
+ conf = global_cache_map[key] = (_a = global_cache_map[key]) !== null && _a !== void 0 ? _a : {};
1761
+ if (!conf.cache) {
1762
+ _context9.next = 3;
1763
+ break;
1764
+ }
1765
+ return _context9.abrupt("return", conf.cache);
1766
+ case 3:
1767
+ if (!conf.cache_promise) {
1768
+ _context9.next = 5;
1769
+ break;
1770
+ }
1771
+ return _context9.abrupt("return", conf.cache_promise);
1772
+ case 5:
1773
+ return _context9.abrupt("return", conf.cache_promise = cb().then(function (r) {
1774
+ return conf.cache = r;
1775
+ }));
1776
+ case 6:
1777
+ case "end":
1778
+ return _context9.stop();
1779
+ }
1780
+ }, _callee9);
1781
+ }));
1782
+ }
1783
+ function speculate_on_display(value) {
1784
+ if (!value) return '';
1785
+ if (isNumber(value)) return value + '';
1786
+ if (Array.isArray(value)) {
1787
+ var item0 = value[0];
1788
+ return (item0 === null || item0 === void 0 ? void 0 : item0.label) || (item0 === null || item0 === void 0 ? void 0 : item0.value);
1789
+ }
1790
+ if (isObjectLike(value)) {
1791
+ return value.label || value.value;
1792
+ }
1793
+ if (isString(value)) {
1794
+ var obj = safe_json_parse(value);
1795
+ return speculate_on_display(obj) || value;
1796
+ }
1797
+ return '';
1798
+ }
1799
+ // 00:00 00:05 ... 23:55
1800
+ function getFuckTimeInterval() {
1801
+ var star_hour = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1802
+ var end_hour = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 24;
1803
+ var min_interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5;
1804
+ return Array(end_hour - star_hour).fill(0).map(function (_, hour) {
1805
+ var hour_str = (hour + star_hour).toString().padStart(2, '0');
1806
+ var min_counts = 60 / min_interval;
1807
+ return Array(min_counts).fill(0).map(function (_, min) {
1808
+ var min_str = (min * min_interval).toString().padStart(2, '0');
1809
+ return "".concat(hour_str, ":").concat(min_str);
1810
+ });
1811
+ }).flat();
1812
+ }
1813
+ // export function getTimeSlice(hour = 24, isShowSecond = false) {
1814
+ // const hourArr = Array(hour).fill(0) as number[]
1815
+ // const minuteArr = Array(60).fill(0) as number[]
1816
+ // return hourArr.reduce((sum, h, hIdx) => {
1817
+ // return [...sum, ...minuteArr.map((m, mIdx) => `${hIdx}:${mIdx}`)]
1818
+ // }, [] as string[])
1819
+ // }
1820
+ var word = [['abundant', ' 丰富的', '/əˈbʌndənt/'], ['eloquent', ' 雄辩的', '/ˈeləkwənt/'], ['meticulous', ' 细致的', '/məˈtɪkjʊləs/'], ['resilient', ' 有韧性的', '/rɪˈzɪliənt/'], ['versatile', ' 多才多艺的', '/ˈvɜːsətaɪl/'], ['pragmatic', ' 务实的', '/præɡˈmætɪk/'], ['inevitable', ' 不可避免的', '/ɪˈnevɪtəbl/'], ['ambiguous', ' 模棱两可的', '/æmˈbɪɡjuəs/'], ['spontaneous', ' 自发的', '/spɒnˈteɪniəs/'], ['conscientious', ' 认真的', '/ˌkɒnʃiˈenʃəs/'], ['impeccable', ' 无瑕疵的', '/ɪmˈpekəbl/'], ['tenacious', ' 顽强的', '/təˈneɪʃəs/'], ['prolific', ' 多产的', '/prəˈlɪfɪk/']];
1821
+ function random_word() {
1822
+ return word[Math.random() * word.length | 0];
1823
+ }
1824
+ function confirm_operation() {
1825
+ var word = random_word();
1826
+ return prompt("\u8BF7\u8F93\u5165 ".concat(word[0], "\uFF08").concat(word[2], " adj.").concat(word[1], "\uFF09 \u4EE5\u786E\u8BA4\u4F60\u7684\u64CD\u4F5C")) === word[0];
1827
+ }
1828
+ // ES6 新增的方法
1829
+ // '😎'.charCodeAt(0).toString(16) == 'd83d' // UTF-16 码元
1830
+ // '😎'.charCodeAt(1).toString(16) == 'de0e'
1831
+ // '😎'.codePointAt(0)?.toString(16) == '1f60e'// Unicode 码点
1832
+ function simple_encrypt(data) {
1833
+ if (!data) return null;
1834
+ return JSON.stringify(data).split('').map(function (_, idx) {
1835
+ return ~_.charCodeAt(0) + idx * 119;
1836
+ });
1837
+ }
1838
+ function simple_decrypt(code) {
1839
+ if (!code) return null;
1840
+ var str = expect_array(code).map(function (_, idx) {
1841
+ return String.fromCharCode(~(_ - idx * 119));
1842
+ }).join('');
1843
+ return safe_json_parse(str);
1844
+ }
1845
+ function simple_encrypt_str(data) {
1846
+ if (!data || !isString(data)) return null;
1847
+ return data.split('').map(function (_, idx) {
1848
+ return ~_.charCodeAt(0) + idx * 119;
1849
+ }).join('@@');
1850
+ }
1851
+ function simple_decrypt_str(code) {
1852
+ if (!code || !isString(code)) return null;
1853
+ var str = code.split('@@').map(function (_, idx) {
1854
+ return String.fromCharCode(~(+_ - idx * 119));
1855
+ }).join('');
1856
+ return str;
1857
+ }
1858
+ function getFn(format) {
1859
+ function f(s) {
1860
+ if (isFunction(s === null || s === void 0 ? void 0 : s.format)) {
1861
+ var res = s.format(format);
1862
+ if (isString(res)) return res;
1863
+ }
1864
+ var a = dayjs__default["default"](s);
1865
+ return a.isValid() ? a.format(format) : null;
1866
+ }
1867
+ return Object.assign(f, {
1868
+ format: format
1869
+ });
1870
+ }
1871
+ function getMomentObj(s) {
1872
+ return dayjs__default["default"](s);
1873
+ }
1874
+ var formatDate = getFn('YYYY-MM-DD');
1875
+ var formatDateTime = getFn('YYYY-MM-DD HH:mm:ss');
1876
+ var formatDateTimeNoSecond = getFn('YYYY-MM-DD HH:mm');
1877
+ var formatTime = getFn('HH:mm:ss');
1878
+ function start() {
1879
+ var m = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dayjs__default["default"];
1880
+ return m().set('hour', 0).set('minute', 0).set('second', 0);
1881
+ }
1882
+ function end() {
1883
+ var m = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dayjs__default["default"];
1884
+ return m().set('hour', 23).set('minute', 59).set('second', 59);
1885
+ }
1886
+ function getMomentRange() {
1887
+ var m = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dayjs__default["default"];
1888
+ return {
1889
+ 昨天: [start(m).add(-1, 'day'), end(m).add(-1, 'day')],
1890
+ 今天: [start(m), end(m)],
1891
+ 明天: [start(m).add(1, 'day'), end(m).add(1, 'day')],
1892
+ 上周: [start(m).add(-1, 'week').startOf('week'), end(m).add(-1, 'week').endOf('week')],
1893
+ // 这周: [start(m).startOf('week'), end(m).endOf('week')] as DT,
1894
+ 近一周: [start(m).add(-1, 'week').add(1, 'day'), end(m)],
1895
+ 下周: [start(m).add(1, 'week').startOf('week'), end(m).add(1, 'week').endOf('week')],
1896
+ 上月: [start(m).add(-1, 'month').startOf('month'), end(m).add(-1, 'month').endOf('month')],
1897
+ // 这月: [start(m).startOf('month'), end(m).endOf('month')] as DT,
1898
+ 近一月: [start(m).add(-1, 'month').add(1, 'day'), end(m)],
1899
+ 下月: [start(m).add(1, 'month').startOf('month'), end(m).add(1, 'month').endOf('month')],
1900
+ 近一年: [start(m).add(-1, 'year').add(1, 'day'), end(m)]
1901
+ };
1902
+ }
1903
+ function presets_date() {
1904
+ return [{
1905
+ label: '一月前',
1906
+ value: start().add(-1, 'month')
1907
+ }, {
1908
+ label: '一周前',
1909
+ value: start().add(-1, 'week')
1910
+ }, {
1911
+ label: '一天前',
1912
+ value: start().add(-1, 'day')
1913
+ }, {
1914
+ label: '一天后',
1915
+ value: start().add(1, 'day')
1916
+ }, {
1917
+ label: '两天后',
1918
+ value: start().add(2, 'day')
1919
+ }, {
1920
+ label: '三天后',
1921
+ value: start().add(3, 'day')
1922
+ }, {
1923
+ label: '一周后',
1924
+ value: start().add(1, 'week')
1925
+ }, {
1926
+ label: '两周后',
1927
+ value: start().add(2, 'week')
1928
+ }, {
1929
+ label: '一月后',
1930
+ value: start().add(1, 'month')
1931
+ }, {
1932
+ label: '两月后',
1933
+ value: start().add(2, 'month')
1934
+ }, {
1935
+ label: '半年后',
1936
+ value: start().add(6, 'month')
1937
+ }];
1938
+ }
1939
+ function isMoment(m) {
1940
+ return isFunction(m.format);
1941
+ }
1942
+ /**
1943
+ * 获取若干天后的日期
1944
+ */
1945
+ function getFutureDate(num) {
1946
+ return dayjs__default["default"]().add(num, 'days').format('YYYY-MM-DD');
1947
+ }
1948
+ function dayjs_quarter(input, which_quarter) {
1949
+ if (typeof which_quarter !== 'undefined') {
1950
+ // 设置季度:调整月份至目标季度的第一个月,并保持其他部分不变
1951
+ var targetMonth = (which_quarter - 1) * 3;
1952
+ var adjustedDate = input.month(targetMonth);
1953
+ return [adjustedDate, which_quarter];
1954
+ } else {
1955
+ // 获取当前季度:根据月份计算季度(1-4)
1956
+ var currentMonth = input.month(); // 0-11
1957
+ var currentQuarter = Math.floor(currentMonth / 3) + 1;
1958
+ return [input, currentQuarter];
1959
+ }
1960
+ }
1961
+ function diff_between(a, b, unit) {
1962
+ var _float = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
1963
+ return dayjs__default["default"](a).diff(dayjs__default["default"](b), unit, _float);
1964
+ }
1965
+ var colorMap = {
1966
+ 'log': '#1475b2',
1967
+ 'warn': '#f89c1e',
1968
+ 'error': '#ed7961'
1969
+ };
1970
+ var big_txt_style = 'color:#1772F6;font-weight:bold;font-size:6em;padding:10px 20%;text-shadow:0.7px -1px 0 rgb(255 255 255 / 100%),1.4px -2px 0 rgb(255 255 255 / 96%),2px -3px 0 rgb(255 255 255 / 92%),2.8px -4px 0 rgb(255 255 255 / 88%),-1px 1px 2px rgb(0 0 0 / 70%),-2px 2px 4px rgb(0 0 0 / 70%),-3px 3px 6px rgb(0 0 0 / 70%);background: linear-gradient(to right top,oklab(58.2% -0.04 -0.21),oklab(58.2% -0.376 -0.21));';
1971
+ var MyLog = /*#__PURE__*/function () {
1972
+ function MyLog(e) {
1973
+ _classCallCheck(this, MyLog);
1974
+ Object.defineProperty(this, "env", {
1975
+ enumerable: true,
1976
+ configurable: true,
1977
+ writable: true,
1978
+ value: void 0
1979
+ });
1980
+ this.env = e;
1981
+ }
1982
+ return _createClass(MyLog, [{
1983
+ key: "_logMsg",
1984
+ value: function _logMsg() {
1985
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'log';
1986
+ var _a;
1987
+ var fn = (_a = MyLog._handler) === null || _a === void 0 ? void 0 : _a[type];
1988
+ if (!fn || !isFunction(fn)) return;
1989
+ for (var _len10 = arguments.length, msg = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
1990
+ msg[_key10 - 1] = arguments[_key10];
1991
+ }
1992
+ fn.apply(void 0, ["%c ".concat(this.env, " %c ").concat(formatDateTime(), " "), "padding: 1px; border-radius:3px 0 0 3px; color: #fff; background: ".concat(colorMap[type], ";"), "padding: 1px; border-radius: 0 3px 3px 0; color: #fff; background: #606060;"].concat(msg));
1993
+ }
1994
+ }, {
1995
+ key: "logBig",
1996
+ value: function logBig(t) {
1997
+ var _a;
1998
+ var fn = (_a = MyLog._handler) === null || _a === void 0 ? void 0 : _a.log;
1999
+ if (!fn || !isFunction(fn)) return;
2000
+ fn("%c".concat(t), big_txt_style);
2001
+ }
2002
+ }, {
2003
+ key: "log",
2004
+ value: function log() {
2005
+ for (var _len11 = arguments.length, msg = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
2006
+ msg[_key11] = arguments[_key11];
2007
+ }
2008
+ this._logMsg.apply(this, ['log'].concat(msg));
2009
+ }
2010
+ }, {
2011
+ key: "warn",
2012
+ value: function warn() {
2013
+ for (var _len12 = arguments.length, msg = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
2014
+ msg[_key12] = arguments[_key12];
2015
+ }
2016
+ this._logMsg.apply(this, ['warn'].concat(msg));
2017
+ }
2018
+ }, {
2019
+ key: "error",
2020
+ value: function error() {
2021
+ for (var _len13 = arguments.length, msg = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
2022
+ msg[_key13] = arguments[_key13];
2023
+ }
2024
+ this._logMsg.apply(this, ['error'].concat(msg));
2025
+ }
2026
+ }], [{
2027
+ key: "handler",
2028
+ set: function set(v) {
2029
+ if (!v) return;
2030
+ MyLog._handler = Object.assign(Object.assign({}, MyLog._handler), v);
2031
+ }
2032
+ }]);
2033
+ }();
2034
+ Object.defineProperty(MyLog, "_handler", {
2035
+ enumerable: true,
2036
+ configurable: true,
2037
+ writable: true,
2038
+ value: console
2039
+ });
2040
+ MyLog.handler = console;
2041
+ var EventEmitter = /*#__PURE__*/function () {
2042
+ function EventEmitter() {
2043
+ _classCallCheck(this, EventEmitter);
2044
+ Object.defineProperty(this, "events", {
2045
+ enumerable: true,
2046
+ configurable: true,
2047
+ writable: true,
2048
+ value: {}
2049
+ });
2050
+ }
2051
+ return _createClass(EventEmitter, [{
2052
+ key: "addListener",
2053
+ value: function addListener(event, listener) {
2054
+ var existing = this.events[event];
2055
+ if (!existing) {
2056
+ this.events[event] = existing = [];
2057
+ }
2058
+ existing.includes(listener) || existing.push(listener);
2059
+ return this;
2060
+ }
2061
+ }, {
2062
+ key: "on",
2063
+ value: function on(event, listener) {
2064
+ // this.off(event, listener)
2065
+ return this.addListener(event, listener);
2066
+ }
2067
+ }, {
2068
+ key: "on_cb",
2069
+ value: function on_cb(event, listener) {
2070
+ // this.off(event, listener)
2071
+ this.addListener(event, listener);
2072
+ return listener;
2073
+ }
2074
+ }, {
2075
+ key: "on_rm",
2076
+ value: function on_rm(event, listener) {
2077
+ var _this2 = this;
2078
+ // this.off(event, listener)
2079
+ this.addListener(event, listener);
2080
+ return function () {
2081
+ _this2.off(event, listener);
2082
+ };
2083
+ }
2084
+ }, {
2085
+ key: "emit",
2086
+ value: function emit(event) {
2087
+ for (var _len14 = arguments.length, args = new Array(_len14 > 1 ? _len14 - 1 : 0), _key14 = 1; _key14 < _len14; _key14++) {
2088
+ args[_key14 - 1] = arguments[_key14];
2089
+ }
2090
+ var existing = this.events[event];
2091
+ // EventEmitter.logger.log({ event, args })
2092
+ if (!existing) {
2093
+ return false;
2094
+ }
2095
+ existing.forEach(function (fn) {
2096
+ fn.apply(void 0, args);
2097
+ });
2098
+ return true;
2099
+ }
2100
+ }, {
2101
+ key: "removeAllListeners",
2102
+ value: function removeAllListeners(event) {
2103
+ this.events[event] = [];
2104
+ return this;
2105
+ }
2106
+ }, {
2107
+ key: "off",
2108
+ value: function off(event, listener) {
2109
+ var existing = this.events[event];
2110
+ if (!existing) {
2111
+ return this;
2112
+ }
2113
+ var index = existing.findIndex(function (_) {
2114
+ return _ === listener;
2115
+ });
2116
+ if (index < 0) {
2117
+ return this;
2118
+ }
2119
+ existing.splice(index, 1);
2120
+ return this;
2121
+ }
2122
+ }, {
2123
+ key: "once",
2124
+ value: function once(event, listener) {
2125
+ var _this3 = this;
2126
+ var _fn = function fn() {
2127
+ listener.apply(void 0, arguments);
2128
+ _this3.off(event, _fn);
2129
+ };
2130
+ this.on(event, _fn);
2131
+ return this;
2132
+ }
2133
+ }, {
2134
+ key: "prependListener",
2135
+ value: function prependListener(event, listener) {
2136
+ return this;
2137
+ }
2138
+ }, {
2139
+ key: "prependOnceListener",
2140
+ value: function prependOnceListener(event, listener) {
2141
+ return this;
2142
+ }
2143
+ }, {
2144
+ key: "removeListener",
2145
+ value: function removeListener(event, listener) {
2146
+ return this;
2147
+ }
2148
+ }, {
2149
+ key: "setMaxListeners",
2150
+ value: function setMaxListeners(n) {
2151
+ return this;
2152
+ }
2153
+ }, {
2154
+ key: "getMaxListeners",
2155
+ value: function getMaxListeners() {
2156
+ return 0;
2157
+ }
2158
+ }, {
2159
+ key: "listeners",
2160
+ value: function listeners(event) {
2161
+ return [];
2162
+ }
2163
+ }, {
2164
+ key: "rawListeners",
2165
+ value: function rawListeners(event) {
2166
+ return [];
2167
+ }
2168
+ }, {
2169
+ key: "eventNames",
2170
+ value: function eventNames() {
2171
+ return [];
2172
+ }
2173
+ }, {
2174
+ key: "listenerCount",
2175
+ value: function listenerCount(type) {
2176
+ return 0;
2177
+ }
2178
+ }]);
2179
+ }();
2180
+ Object.defineProperty(EventEmitter, "logger", {
2181
+ enumerable: true,
2182
+ configurable: true,
2183
+ writable: true,
2184
+ value: new MyLog('EventEmitter')
2185
+ });
2186
+ var EMPTY_PLACEHOLDER = '-';
2187
+ var TOKEN_KEY = 'Σ(っ °Д °;)っ';
2188
+ var ARG_URS1_KEY = 'usr1';
2189
+ var ARG_URS2_KEY = 'usr2';
2190
+ var noop = function noop() {};
2191
+ var ROMAN_NUMERALS = {
2192
+ 1: 'Ⅰ',
2193
+ 2: 'Ⅱ',
2194
+ 3: 'Ⅲ',
2195
+ 4: 'Ⅳ',
2196
+ 5: 'Ⅴ',
2197
+ 6: 'Ⅵ',
2198
+ 7: 'Ⅶ',
2199
+ 8: 'Ⅷ',
2200
+ 9: 'Ⅷ',
2201
+ 10: 'Ⅹ'
2202
+ };
2203
+ var selectOptionMap = {};
2204
+ var REGE_AutoComplete = /\<(.*)\>a$/;
2205
+ var REGE_MyCheckbox = /\<(.*)\>c$/;
2206
+ var REGE_MySelect = /\<(.*)\>s$/;
2207
+ var REGE_EXCLUSIVE = /^(.*)\<(.*)\>(.*)#$/;
2208
+ var optionKey其他 = 99;
2209
+ var optionKey不详 = 100;
2210
+ var optionKey否 = 0;
2211
+ var defalutSp = [{
2212
+ label: '不详',
2213
+ value: optionKey不详
2214
+ }, {
2215
+ label: '其他',
2216
+ value: optionKey其他,
2217
+ inputType: 'MyInput'
2218
+ }, {
2219
+ label: '其它',
2220
+ value: optionKey其他,
2221
+ inputType: 'MyInput'
2222
+ }, {
2223
+ label: '无',
2224
+ value: optionKey否,
2225
+ exclusive: true
2226
+ }, {
2227
+ label: '否',
2228
+ value: optionKey否,
2229
+ exclusive: true
2230
+ }];
2231
+ function _getSimpleOptions(_arr) {
2232
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2233
+ var arr = parseList(_arr);
2234
+ var _options$sp = options.sp,
2235
+ sp = _options$sp === void 0 ? [] : _options$sp,
2236
+ _options$start = options.start,
2237
+ start = _options$start === void 0 ? 1 : _options$start,
2238
+ _options$useDefault = options.useDefault,
2239
+ useDefault = _options$useDefault === void 0 ? true : _options$useDefault,
2240
+ useString = options.useString;
2241
+ var index = start;
2242
+ var opt = arr.map(function (_label, idx) {
2243
+ var _a, _b;
2244
+ var preset = presetInput(_label);
2245
+ var label = (_a = preset.label) !== null && _a !== void 0 ? _a : _label;
2246
+ var _defaultSpItem = useDefault ? defalutSp.find(function (s) {
2247
+ return label === s.label;
2248
+ }) : null;
2249
+ var _spItem = sp.find(function (s) {
2250
+ return label === s.label;
2251
+ });
2252
+ var spItem = (_b = _spItem !== null && _spItem !== void 0 ? _spItem : _defaultSpItem) !== null && _b !== void 0 ? _b : {};
2253
+ if (spItem.value && useString) {
2254
+ spItem.value = spItem.value.toString();
2255
+ }
2256
+ var _value = _defaultSpItem ? index : index++;
2257
+ return Object.assign({
2258
+ label: label,
2259
+ value: useString ? _value.toString() : _value,
2260
+ inputType: preset.inputType,
2261
+ props: preset.props,
2262
+ exclusive: preset.exclusive,
2263
+ parentheses: preset.parentheses,
2264
+ prefix: preset.prefix,
2265
+ suffix: preset.suffix
2266
+ }, spItem);
2267
+ });
2268
+ return opt;
2269
+ }
2270
+ function getSimpleOptions(_arr) {
2271
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2272
+ var ret = typeof _arr === 'function' ? function () {
2273
+ return _getSimpleOptions(_arr(), options);
2274
+ } : _getSimpleOptions(_arr, options);
2275
+ return ret;
2276
+ }
2277
+ function _getSameOptions(_arr) {
2278
+ var arr = parseList(_arr);
2279
+ return arr.map(function (label) {
2280
+ return {
2281
+ label: label,
2282
+ value: label
2283
+ };
2284
+ });
2285
+ }
2286
+ function getSameOptions(_arr) {
2287
+ var ret = typeof _arr === 'function' ? function () {
2288
+ return _getSameOptions(_arr());
2289
+ } : _getSameOptions(_arr);
2290
+ return ret;
2291
+ }
2292
+ function getDualModeOptions(arr, options) {
2293
+ return [getSimpleOptions(arr, options), getSameOptions(arr)];
2294
+ }
2295
+ function parseList(arr) {
2296
+ if (!arr) return [];
2297
+ var _arr = [];
2298
+ var split1 = [];
2299
+ if (Array.isArray(arr)) {
2300
+ _arr = arr;
2301
+ } else if ((split1 = arr.split(',')) && split1.length > 1) {
2302
+ _arr = split1;
2303
+ } else if ((split1 = arr.split('、')) && split1.length > 1) {
2304
+ _arr = split1;
2305
+ }
2306
+ return _arr;
2307
+ }
2308
+ function presetInput(_label) {
2309
+ if (!_label) return {
2310
+ label: _label
2311
+ };
2312
+ var withInput = (_label === null || _label === void 0 ? void 0 : _label.endsWith('|i')) || (_label === null || _label === void 0 ? void 0 : _label.endsWith('i'));
2313
+ if (withInput) {
2314
+ return {
2315
+ inputType: 'Input',
2316
+ label: _label.slice(0, -1)
2317
+ };
2318
+ }
2319
+ var useAuto = REGE_AutoComplete.exec(_label);
2320
+ if (useAuto) {
2321
+ return {
2322
+ inputType: 'MA',
2323
+ label: _label.slice(0, useAuto.index),
2324
+ props: {
2325
+ options: useAuto[1]
2326
+ }
2327
+ };
2328
+ }
2329
+ var useCheckbox = REGE_MyCheckbox.exec(_label);
2330
+ if (useCheckbox) {
2331
+ var config = useCheckbox[1];
2332
+ var arr = config.split('|');
2333
+ var options = arr[0];
2334
+ var marshal = arr[1] ? Number(arr[1]) : undefined;
2335
+ var type = arr[2] || undefined;
2336
+ return {
2337
+ inputType: 'MC',
2338
+ label: _label.slice(0, useCheckbox.index),
2339
+ props: {
2340
+ options: options,
2341
+ marshal: marshal,
2342
+ type: type
2343
+ }
2344
+ };
2345
+ }
2346
+ var useSelect = REGE_MySelect.exec(_label);
2347
+ if (useSelect) {
2348
+ var _config = useSelect[1];
2349
+ var _arr2 = _config.split('|');
2350
+ var _options = _arr2[0];
2351
+ var _marshal = _arr2[1] ? Number(_arr2[1]) : undefined;
2352
+ var mode = _arr2[2] || undefined;
2353
+ return {
2354
+ inputType: 'MS',
2355
+ label: _label.slice(0, useSelect.index),
2356
+ props: {
2357
+ options: _options,
2358
+ marshal: _marshal,
2359
+ mode: mode
2360
+ }
2361
+ };
2362
+ }
2363
+ // 文字<exclusive|parentheses|prefix|suffix>MyInput#
2364
+ var useExclusive = REGE_EXCLUSIVE.exec(_label);
2365
+ if (useExclusive) {
2366
+ var label = useExclusive[1];
2367
+ var _config2 = useExclusive[2];
2368
+ var _arr3 = _config2.split('|');
2369
+ var inputType = useExclusive[3];
2370
+ var exclusive = _arr3[0] ? Boolean(_arr3[0]) : undefined;
2371
+ var parentheses = _arr3[1] ? Boolean(_arr3[1]) : undefined;
2372
+ var prefix = _arr3[2];
2373
+ var suffix = _arr3[3];
2374
+ // mchcLogger.log('useExclusive', { useExclusive, exclusive, parentheses, prefix, suffix, inputType, label, _label })
2375
+ return {
2376
+ exclusive: exclusive,
2377
+ parentheses: parentheses,
2378
+ prefix: prefix,
2379
+ suffix: suffix,
2380
+ inputType: inputType,
2381
+ label: label
2382
+ };
2383
+ }
2384
+ return {
2385
+ label: _label
2386
+ };
2387
+ }
2388
+ function safe_fetch_options(cb) {
2389
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
2390
+ var arr;
2391
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
2392
+ while (1) switch (_context10.prev = _context10.next) {
2393
+ case 0:
2394
+ _context10.next = 2;
2395
+ return safe_async_call(cb);
2396
+ case 2:
2397
+ arr = _context10.sent;
2398
+ return _context10.abrupt("return", expect_array(arr));
2399
+ case 4:
2400
+ case "end":
2401
+ return _context10.stop();
2402
+ }
2403
+ }, _callee10);
2404
+ }));
2405
+ }
2406
+ function getPresetOptions(key) {
2407
+ var pure = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2408
+ var _a, _b;
2409
+ var options = (_b = (_a = selectOptionMap[key]) === null || _a === void 0 ? void 0 : _a.call(selectOptionMap)) !== null && _b !== void 0 ? _b : [];
2410
+ return pure ? options.map(function (_) {
2411
+ return Object.assign(Object.assign({}, _), {
2412
+ inputType: undefined
2413
+ });
2414
+ }) : options;
2415
+ }
2416
+ function getOptionLabel(k, value) {
2417
+ var defaultLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
2418
+ var _a, _b, _c, _d;
2419
+ var options = (_b = (_a = selectOptionMap[k]) === null || _a === void 0 ? void 0 : _a.call(selectOptionMap)) !== null && _b !== void 0 ? _b : [];
2420
+ return (_d = (_c = options.find(function (_) {
2421
+ return _.value === value;
2422
+ })) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : defaultLabel;
2423
+ }
2424
+ function getOptionValue(k, label) {
2425
+ var _a, _b, _c;
2426
+ var options = (_b = (_a = selectOptionMap[k]) === null || _a === void 0 ? void 0 : _a.call(selectOptionMap)) !== null && _b !== void 0 ? _b : [];
2427
+ return (_c = options.find(function (_) {
2428
+ return _.label === label;
2429
+ })) === null || _c === void 0 ? void 0 : _c.value;
2430
+ }
2431
+ // merge options
2432
+ function merge_preset_options(ops) {
2433
+ Object.assign(selectOptionMap, ops);
2434
+ }
2435
+ var dic_map = {};
2436
+ function getDictionaries() {
2437
+ return dic_map;
2438
+ }
2439
+ /**
2440
+ *
2441
+ * @param value 枚举值value
2442
+ * @param type string 字典类型
2443
+ */
2444
+ function getDictionariesEnumerations(type) {
2445
+ var _a;
2446
+ var dictionaries = getDictionaries();
2447
+ var object = dictionaries === null || dictionaries === void 0 ? void 0 : dictionaries[type];
2448
+ if (!object) {
2449
+ console.warn("\u5B57\u5178 ".concat(type, " \u4E0D\u5B58\u5728!"));
2450
+ return [];
2451
+ }
2452
+ var enumerations = (_a = object === null || object === void 0 ? void 0 : object.enumerations) !== null && _a !== void 0 ? _a : [];
2453
+ return enumerations;
2454
+ }
2455
+ /**
2456
+ *
2457
+ * @param value 枚举值value
2458
+ * @param type string 字典类型
2459
+ */
2460
+ function getDictionaryLabel(type, value) {
2461
+ var enumerations = getDictionariesEnumerations(type);
2462
+ var item = enumerations.find(function (_) {
2463
+ return _.value === +value;
2464
+ });
2465
+ if (!item) {
2466
+ return null;
2467
+ }
2468
+ return item.label;
2469
+ }
2470
+ /**
2471
+ *
2472
+ * @param label 枚举值value
2473
+ * @param type string 字典类型
2474
+ */
2475
+ function getDictionaryValue(type, label) {
2476
+ var enumerations = getDictionariesEnumerations(type);
2477
+ var item = enumerations.find(function (_) {
2478
+ return _.label === label;
2479
+ });
2480
+ if (!item) {
2481
+ return null;
2482
+ }
2483
+ return item.value;
2484
+ }
2485
+ // merge dic
2486
+ function merge_dict(ops) {
2487
+ Object.assign(dic_map, ops);
2488
+ }
2489
+ Object.defineProperty(exports, 'dayjs', {
2490
+ enumerable: true,
2491
+ get: function get() {
2492
+ return dayjs__default["default"];
2493
+ }
2494
+ });
2495
+ exports.ARG_URS1_KEY = ARG_URS1_KEY;
2496
+ exports.ARG_URS2_KEY = ARG_URS2_KEY;
2497
+ exports.EMPTY_PLACEHOLDER = EMPTY_PLACEHOLDER;
2498
+ exports.EventEmitter = EventEmitter;
2499
+ exports.MyLog = MyLog;
2500
+ exports.ROMAN_NUMERALS = ROMAN_NUMERALS;
2501
+ exports.TOKEN_KEY = TOKEN_KEY;
2502
+ exports.all = all;
2503
+ exports.alphabetical = alphabetical;
2504
+ exports.assign = _assign;
2505
+ exports.base64ToBinary = base64ToBinary;
2506
+ exports.base64_to_image = base64_to_image;
2507
+ exports.boil = boil;
2508
+ exports.cache_fetch = cache_fetch;
2509
+ exports.callable = callable;
2510
+ exports.camel = camel;
2511
+ exports.capitalize = capitalize;
2512
+ exports.chain = chain;
2513
+ exports.charToUTF8 = charToUTF8;
2514
+ exports.charToUnicode = charToUnicode;
2515
+ exports.clone = clone;
2516
+ exports.cloneDeep = cloneDeep;
2517
+ exports.cluster = cluster;
2518
+ exports.compose = compose;
2519
+ exports.confirm_operation = confirm_operation;
2520
+ exports.construct = construct;
2521
+ exports.copyText = copyText;
2522
+ exports.counting = counting;
2523
+ exports.crush = crush;
2524
+ exports.dash = dash;
2525
+ exports.dayjs_quarter = dayjs_quarter;
2526
+ exports.debounce = debounce;
2527
+ exports.defer = defer;
2528
+ exports.diff = diff;
2529
+ exports.diff_between = diff_between;
2530
+ exports.downloadFile = downloadFile;
2531
+ exports.draw = draw;
2532
+ exports.expect_array = expect_array;
2533
+ exports.filter_obj_to_url_search = filter_obj_to_url_search;
2534
+ exports.first = first;
2535
+ exports.flat = flat;
2536
+ exports.fork = fork;
2537
+ exports.formatDate = formatDate;
2538
+ exports.formatDateTime = formatDateTime;
2539
+ exports.formatDateTimeNoSecond = formatDateTimeNoSecond;
2540
+ exports.formatTime = formatTime;
2541
+ exports.gen_encoded_char_svg = gen_encoded_char_svg;
2542
+ exports.get = get;
2543
+ exports.getDictionaries = getDictionaries;
2544
+ exports.getDictionariesEnumerations = getDictionariesEnumerations;
2545
+ exports.getDictionaryLabel = getDictionaryLabel;
2546
+ exports.getDictionaryValue = getDictionaryValue;
2547
+ exports.getDualModeOptions = getDualModeOptions;
2548
+ exports.getFilledArray = getFilledArray;
2549
+ exports.getFuckTimeInterval = getFuckTimeInterval;
2550
+ exports.getFutureDate = getFutureDate;
2551
+ exports.getMomentObj = getMomentObj;
2552
+ exports.getMomentRange = getMomentRange;
2553
+ exports.getOptionLabel = getOptionLabel;
2554
+ exports.getOptionValue = getOptionValue;
2555
+ exports.getPresetOptions = getPresetOptions;
2556
+ exports.getSameOptions = getSameOptions;
2557
+ exports.getSearchParamsAll = getSearchParamsAll;
2558
+ exports.getSearchParamsValue = getSearchParamsValue;
2559
+ exports.getSimpleOptions = getSimpleOptions;
2560
+ exports.get_global = get_global;
2561
+ exports.group = group;
2562
+ exports.guard = guard;
2563
+ exports.identity = identity;
2564
+ exports.image_to_base64 = image_to_base64;
2565
+ exports.inRange = inRange;
2566
+ exports.intersects = intersects;
2567
+ exports.invert = invert;
2568
+ exports.isArray = isArray;
2569
+ exports.isBoolean = isBoolean;
2570
+ exports.isDate = isDate;
2571
+ exports.isEmpty = isEmpty;
2572
+ exports.isEqual = _isEqual;
2573
+ exports.isFloat = isFloat;
2574
+ exports.isFunction = isFunction;
2575
+ exports.isInt = isInt;
2576
+ exports.isMoment = isMoment;
2577
+ exports.isNil = isNil;
2578
+ exports.isNull = isNull;
2579
+ exports.isNumber = isNumber;
2580
+ exports.isObject = isObject;
2581
+ exports.isObjectLike = isObjectLike;
2582
+ exports.isPrimitive = isPrimitive;
2583
+ exports.isPromise = isPromise;
2584
+ exports.isString = isString;
2585
+ exports.isSymbol = isSymbol;
2586
+ exports.iterate = iterate;
2587
+ exports.keys = keys;
2588
+ exports.last = last;
2589
+ exports.list = list;
2590
+ exports.listify = listify;
2591
+ exports.lowerize = lowerize;
2592
+ exports.map = map;
2593
+ exports.mapEntries = mapEntries;
2594
+ exports.mapKeys = mapKeys;
2595
+ exports.mapValues = mapValues;
2596
+ exports.max = max;
2597
+ exports.memo = memo;
2598
+ exports.merge = merge;
2599
+ exports.merge_dict = merge_dict;
2600
+ exports.merge_preset_options = merge_preset_options;
2601
+ exports.min = min;
2602
+ exports.noop = noop;
2603
+ exports.numberLikeCompare = numberLikeCompare;
2604
+ exports.objectify = objectify;
2605
+ exports.omit = omit;
2606
+ exports["optionKey不详"] = optionKey不详;
2607
+ exports["optionKey其他"] = optionKey其他;
2608
+ exports["optionKey否"] = optionKey否;
2609
+ exports.parallel = parallel;
2610
+ exports.partial = partial;
2611
+ exports.partob = partob;
2612
+ exports.pascal = pascal;
2613
+ exports.pick = pick;
2614
+ exports.presets_date = presets_date;
2615
+ exports.proxied = proxied;
2616
+ exports.random = random;
2617
+ exports.randomHex = randomHex;
2618
+ exports.random_word = random_word;
2619
+ exports.range = range;
2620
+ exports.reduce = reduce;
2621
+ exports.replace = replace;
2622
+ exports.replaceOrAppend = replaceOrAppend;
2623
+ exports.retry = retry;
2624
+ exports.safeExec = safeExec;
2625
+ exports.safeGetFromFuncOrData = safeGetFromFuncOrData;
2626
+ exports.safe_async_call = safe_async_call;
2627
+ exports.safe_fetch_options = safe_fetch_options;
2628
+ exports.safe_json_parse = safe_json_parse;
2629
+ exports.safe_json_parse_arr = safe_json_parse_arr;
2630
+ exports.safe_json_stringify = safe_json_stringify;
2631
+ exports.safe_number_parse = safe_number_parse;
2632
+ exports.scrollIntoView = scrollIntoView;
2633
+ exports.select = select;
2634
+ exports.series = series;
2635
+ exports.set = set;
2636
+ exports.setSearchParamsAll = setSearchParamsAll;
2637
+ exports.setSearchParamsValue = setSearchParamsValue;
2638
+ exports.shake = shake;
2639
+ exports.shift = shift;
2640
+ exports.shuffle = shuffle;
2641
+ exports.sift = sift;
2642
+ exports.simple_decrypt = simple_decrypt;
2643
+ exports.simple_decrypt_str = simple_decrypt_str;
2644
+ exports.simple_encrypt = simple_encrypt;
2645
+ exports.simple_encrypt_str = simple_encrypt_str;
2646
+ exports.size = size;
2647
+ exports.sleep = sleep;
2648
+ exports.snake = snake;
2649
+ exports.sort = sort;
2650
+ exports.speculate_on_display = speculate_on_display;
2651
+ exports.sum = sum;
2652
+ exports.template = template;
2653
+ exports.throttle = throttle;
2654
+ exports.title = title;
2655
+ exports.toFloat = toFloat;
2656
+ exports.toInt = toInt;
2657
+ exports.toString = toString;
2658
+ exports.toggle = toggle;
2659
+ exports.trim = trim;
2660
+ exports["try"] = tryit;
2661
+ exports.tryit = tryit;
2662
+ exports.uid = uid;
2663
+ exports.unicodeToChar = unicodeToChar;
2664
+ exports.unicode_to_UTF8 = unicode_to_UTF8;
2665
+ exports.unique = unique;
2666
+ exports.upperize = upperize;
2667
+ exports.uuid = uuid;
2668
+ exports.warpBase64Type = warpBase64Type;
2669
+ exports.zip = zip;
2670
+ exports.zipToObject = zipToObject;