szdl-utils-kit 0.3.15 → 0.3.16

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/index.js CHANGED
@@ -1,54 +1,54 @@
1
- var zt = Object.defineProperty;
2
- var Zt = (S, r, e) => r in S ? zt(S, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : S[r] = e;
3
- var w = (S, r, e) => (Zt(S, typeof r != "symbol" ? r + "" : r, e), e), Bt = (S, r, e) => {
4
- if (!r.has(S))
1
+ var ie = Object.defineProperty;
2
+ var ne = (p, t, e) => t in p ? ie(p, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[t] = e;
3
+ var C = (p, t, e) => (ne(p, typeof t != "symbol" ? t + "" : t, e), e), wt = (p, t, e) => {
4
+ if (!t.has(p))
5
5
  throw TypeError("Cannot " + e);
6
6
  };
7
- var R = (S, r, e) => (Bt(S, r, "read from private field"), e ? e.call(S) : r.get(S)), I = (S, r, e) => {
8
- if (r.has(S))
7
+ var S = (p, t, e) => (wt(p, t, "read from private field"), e ? e.call(p) : t.get(p)), D = (p, t, e) => {
8
+ if (t.has(p))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
- r instanceof WeakSet ? r.add(S) : r.set(S, e);
11
- }, J = (S, r, e, s) => (Bt(S, r, "write to private field"), s ? s.call(S, e) : r.set(S, e), e);
12
- var E = (S, r, e) => (Bt(S, r, "access private method"), e);
13
- var Vt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
14
- function $t(S) {
15
- return S && S.__esModule && Object.prototype.hasOwnProperty.call(S, "default") ? S.default : S;
10
+ t instanceof WeakSet ? t.add(p) : t.set(p, e);
11
+ }, J = (p, t, e, s) => (wt(p, t, "write to private field"), s ? s.call(p, e) : t.set(p, e), e);
12
+ var E = (p, t, e) => (wt(p, t, "access private method"), e);
13
+ var oe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
14
+ function ae(p) {
15
+ return p && p.__esModule && Object.prototype.hasOwnProperty.call(p, "default") ? p.default : p;
16
16
  }
17
- var Ct = { exports: {} };
18
- (function(S, r) {
17
+ var Ht = { exports: {} };
18
+ (function(p, t) {
19
19
  (function(e) {
20
- Array.prototype.indexOf || (Array.prototype.indexOf = function(t, a) {
20
+ Array.prototype.indexOf || (Array.prototype.indexOf = function(r, o) {
21
21
  var d, g;
22
- for (d = a || 0, g = this.length; d < g; d += 1)
23
- if (this[d] === t)
22
+ for (d = o || 0, g = this.length; d < g; d += 1)
23
+ if (this[d] === r)
24
24
  return d;
25
25
  return -1;
26
26
  });
27
- var s = this, n = function(t, a) {
28
- for (var d = t.toString(); d.length < a; )
27
+ var s = this, i = function(r, o) {
28
+ for (var d = r.toString(); d.length < o; )
29
29
  d = "0" + d;
30
30
  return d;
31
- }, o = function(t, a) {
32
- return a !== e ? (t.year(a.year() || a.year), t.month(a.month() || a.month), t.day(a.day() || a.day), t.hours(a.hours() || a.hours), t.minutes(a.minutes() || a.minutes), t.seconds(a.seconds() || a.seconds), t.milliseconds(a.milliseconds() || a.milliseconds), t) : e;
33
- }, h = function(t, a) {
31
+ }, a = function(r, o) {
32
+ return o !== e ? (r.year(o.year() || o.year), r.month(o.month() || o.month), r.day(o.day() || o.day), r.hours(o.hours() || o.hours), r.minutes(o.minutes() || o.minutes), r.seconds(o.seconds() || o.seconds), r.milliseconds(o.milliseconds() || o.milliseconds), r) : e;
33
+ }, l = function(r, o) {
34
34
  var d, g = "";
35
- return d = t.slice(a, a + 1), d !== "" && !isNaN(Number(d)) && (g += "%H"), d = t.charAt(a + 2), d !== "" && d === ":" && (g += d), d = t.slice(a + 3, a + 4), d !== "" && !isNaN(Number(d)) && (g += "%M"), d = t.charAt(a + 5), d !== "" && d === ":" && (g += d), d = t.slice(a + 6, a + 7), d !== "" && !isNaN(Number(d)) && (g += "%S"), g;
36
- }, A = function(t, a) {
35
+ return d = r.slice(o, o + 1), d !== "" && !isNaN(Number(d)) && (g += "%H"), d = r.charAt(o + 2), d !== "" && d === ":" && (g += d), d = r.slice(o + 3, o + 4), d !== "" && !isNaN(Number(d)) && (g += "%M"), d = r.charAt(o + 5), d !== "" && d === ":" && (g += d), d = r.slice(o + 6, o + 7), d !== "" && !isNaN(Number(d)) && (g += "%S"), g;
36
+ }, A = function(r, o) {
37
37
  var d, g = [
38
- t.slice(a, a + 1),
39
- t.charAt(a + 2),
40
- t.slice(a + 3, a + 4),
41
- t.charAt(a + 5),
42
- t.slice(a + 6, a + 9)
43
- ], D;
44
- return !isNaN(Number(g[0])) && !isNaN(Number(g[2])) && !isNaN(Number(g[4])) ? (g[1] === "." && g[3] === "." ? d = "%d.%m.%Y" : g[1] === "-" && g[3] === "-" ? d = "%m-%d-%Y" : g[1] === "/" && g[3] === "/" && (d = "%m/%d/%Y"), d) : (D = [
45
- t.slice(a, a + 3),
46
- t.charAt(a + 4),
47
- t.slice(a + 5, a + 6),
48
- t.charAt(a + 7),
49
- t.slice(a + 8, a + 9)
50
- ], !isNaN(Number(D[0])) && !isNaN(Number(D[2])) && !isNaN(Number(D[4])) ? (D[1] === "-" && D[3] === "-" && (d = "%Y-%m-%d"), d) : "");
51
- }, l = s.tempus, i, u, y = s.navigator || {}, c = "en", f = {
38
+ r.slice(o, o + 1),
39
+ r.charAt(o + 2),
40
+ r.slice(o + 3, o + 4),
41
+ r.charAt(o + 5),
42
+ r.slice(o + 6, o + 9)
43
+ ], w;
44
+ return !isNaN(Number(g[0])) && !isNaN(Number(g[2])) && !isNaN(Number(g[4])) ? (g[1] === "." && g[3] === "." ? d = "%d.%m.%Y" : g[1] === "-" && g[3] === "-" ? d = "%m-%d-%Y" : g[1] === "/" && g[3] === "/" && (d = "%m/%d/%Y"), d) : (w = [
45
+ r.slice(o, o + 3),
46
+ r.charAt(o + 4),
47
+ r.slice(o + 5, o + 6),
48
+ r.charAt(o + 7),
49
+ r.slice(o + 8, o + 9)
50
+ ], !isNaN(Number(w[0])) && !isNaN(Number(w[2])) && !isNaN(Number(w[4])) ? (w[1] === "-" && w[3] === "-" && (d = "%Y-%m-%d"), d) : "");
51
+ }, h = s.tempus, n, u, m = s.navigator || {}, c = "en", f = {
52
52
  en: {
53
53
  JANUARY_SHORT: "Jan",
54
54
  FEBRUARY_SHORT: "Feb",
@@ -224,7 +224,7 @@ var Ct = { exports: {} };
224
224
  f[c].NOVEMBER_LONG,
225
225
  f[c].DECEMBER_LONG
226
226
  ];
227
- }, _ = function() {
227
+ }, T = function() {
228
228
  return [
229
229
  f[c].JANUARY_SHORT,
230
230
  f[c].FEBRUARY_SHORT,
@@ -239,7 +239,7 @@ var Ct = { exports: {} };
239
239
  f[c].NOVEMBER_SHORT,
240
240
  f[c].DECEMBER_SHORT
241
241
  ];
242
- }, m = function() {
242
+ }, _ = function() {
243
243
  return [
244
244
  f[c].SUNDAY_LONG,
245
245
  f[c].MONDAY_LONG,
@@ -249,7 +249,7 @@ var Ct = { exports: {} };
249
249
  f[c].FRIDAY_LONG,
250
250
  f[c].SATURDAY_LONG
251
251
  ];
252
- }, N = function() {
252
+ }, R = function() {
253
253
  return [
254
254
  f[c].SUNDAY_SHORT,
255
255
  f[c].MONDAY_SHORT,
@@ -259,52 +259,52 @@ var Ct = { exports: {} };
259
259
  f[c].FRIDAY_SHORT,
260
260
  f[c].SATURDAY_SHORT
261
261
  ];
262
- }, p, T, k, C, U = function(t, a, d) {
262
+ }, N, y, L, I, H = function(r, o, d) {
263
263
  var g;
264
264
  s.XMLHttpRequest ? g = new XMLHttpRequest() : g = new ActiveXObject("Microsoft.XMLHTTP"), g.onreadystatechange = function() {
265
- g.readyState === 4 && (g.status === 200 ? a && (s.JSON === e ? alert(`Please, include json2 into your project if you want use old browsers!
266
- https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.parse(g.responseText))) : d && d(g));
267
- }, g.open("GET", t, !1), g.send();
268
- }, M = {
265
+ g.readyState === 4 && (g.status === 200 ? o && (s.JSON === e ? alert(`Please, include json2 into your project if you want use old browsers!
266
+ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(g.responseText))) : d && d(g));
267
+ }, g.open("GET", r, !1), g.send();
268
+ }, k = {
269
269
  "%d": {
270
- format: function(t) {
271
- return n(t.day() || i.MIN_DAY, 2);
270
+ format: function(r) {
271
+ return i(r.day() || n.MIN_DAY, 2);
272
272
  },
273
- parse: function(t) {
274
- var a = Number(t);
275
- return { day: isNaN(a) ? e : a };
273
+ parse: function(r) {
274
+ var o = Number(r);
275
+ return { day: isNaN(o) ? e : o };
276
276
  },
277
277
  minLength: 2,
278
278
  maxLength: 2,
279
279
  type: "number"
280
280
  },
281
281
  "%m": {
282
- format: function(t) {
283
- return n(t.month() || i.MIN_MONTH, 2);
282
+ format: function(r) {
283
+ return i(r.month() || n.MIN_MONTH, 2);
284
284
  },
285
- parse: function(t) {
286
- var a = Number(t);
287
- return { month: isNaN(a) ? e : a };
285
+ parse: function(r) {
286
+ var o = Number(r);
287
+ return { month: isNaN(o) ? e : o };
288
288
  },
289
289
  minLength: 2,
290
290
  maxLength: 2,
291
291
  type: "number"
292
292
  },
293
293
  "%Y": {
294
- format: function(t) {
295
- return n(t.year() || i.MIN_YEAR, 4);
294
+ format: function(r) {
295
+ return i(r.year() || n.MIN_YEAR, 4);
296
296
  },
297
- parse: function(t) {
298
- var a = Number(t);
299
- return { year: isNaN(a) ? e : a };
297
+ parse: function(r) {
298
+ var o = Number(r);
299
+ return { year: isNaN(o) ? e : o };
300
300
  },
301
301
  minLength: 4,
302
302
  maxLength: 4,
303
303
  type: "number"
304
304
  },
305
305
  "%w": {
306
- format: function(t) {
307
- return t.dayOfWeek() || i.MIN_DAY_OF_WEEK;
306
+ format: function(r) {
307
+ return r.dayOfWeek() || n.MIN_DAY_OF_WEEK;
308
308
  },
309
309
  parse: function() {
310
310
  return {};
@@ -314,9 +314,9 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
314
314
  type: "number"
315
315
  },
316
316
  "%a": {
317
- format: function(t) {
318
- var a = t.dayOfWeek();
319
- return C[a !== e ? a : i.MIN_DAY_OF_WEEK];
317
+ format: function(r) {
318
+ var o = r.dayOfWeek();
319
+ return I[o !== e ? o : n.MIN_DAY_OF_WEEK];
320
320
  },
321
321
  parse: function() {
322
322
  return {};
@@ -326,9 +326,9 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
326
326
  type: "word"
327
327
  },
328
328
  "%A": {
329
- format: function(t) {
330
- var a = t.dayOfWeek();
331
- return k[a !== e ? a : i.MIN_DAY_OF_WEEK];
329
+ format: function(r) {
330
+ var o = r.dayOfWeek();
331
+ return L[o !== e ? o : n.MIN_DAY_OF_WEEK];
332
332
  },
333
333
  parse: function() {
334
334
  return {};
@@ -338,86 +338,86 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
338
338
  type: "word"
339
339
  },
340
340
  "%b": {
341
- format: function(t) {
342
- var a = i.options("monthFromZero") ? t.month() : t.month() - 1;
343
- return T[a !== e ? a : i.MIN_MONTH];
341
+ format: function(r) {
342
+ var o = n.options("monthFromZero") ? r.month() : r.month() - 1;
343
+ return y[o !== e ? o : n.MIN_MONTH];
344
344
  },
345
- parse: function(t) {
346
- var a = i.monthNames().indexOf(t) + (i.options("monthFromZero") ? 0 : 1);
347
- return { month: a !== -1 ? a : e };
345
+ parse: function(r) {
346
+ var o = n.monthNames().indexOf(r) + (n.options("monthFromZero") ? 0 : 1);
347
+ return { month: o !== -1 ? o : e };
348
348
  },
349
349
  minLength: 1,
350
350
  maxLength: 999,
351
351
  type: "word"
352
352
  },
353
353
  "%B": {
354
- format: function(t) {
355
- var a = i.options("monthFromZero") ? t.month() : t.month() - 1;
356
- return p[a !== e ? a : i.MIN_MONTH];
354
+ format: function(r) {
355
+ var o = n.options("monthFromZero") ? r.month() : r.month() - 1;
356
+ return N[o !== e ? o : n.MIN_MONTH];
357
357
  },
358
- parse: function(t) {
359
- var a = i.monthNames(!0).indexOf(t) + (i.options("monthFromZero") ? 0 : 1);
360
- return { month: a !== -1 ? a : e };
358
+ parse: function(r) {
359
+ var o = n.monthNames(!0).indexOf(r) + (n.options("monthFromZero") ? 0 : 1);
360
+ return { month: o !== -1 ? o : e };
361
361
  },
362
362
  minLength: 1,
363
363
  maxLength: 999,
364
364
  type: "word"
365
365
  },
366
366
  "%H": {
367
- format: function(t) {
368
- return n(t.hours() || i.MIN_HOURS, 2);
367
+ format: function(r) {
368
+ return i(r.hours() || n.MIN_HOURS, 2);
369
369
  },
370
- parse: function(t) {
371
- var a = Number(t);
372
- return { hours: isNaN(a) ? e : a };
370
+ parse: function(r) {
371
+ var o = Number(r);
372
+ return { hours: isNaN(o) ? e : o };
373
373
  },
374
374
  minLength: 2,
375
375
  maxLength: 2,
376
376
  type: "number"
377
377
  },
378
378
  "%M": {
379
- format: function(t) {
380
- return n(t.minutes() || i.MIN_MINUTES, 2);
379
+ format: function(r) {
380
+ return i(r.minutes() || n.MIN_MINUTES, 2);
381
381
  },
382
- parse: function(t) {
383
- var a = Number(t);
384
- return { minutes: isNaN(a) ? e : a };
382
+ parse: function(r) {
383
+ var o = Number(r);
384
+ return { minutes: isNaN(o) ? e : o };
385
385
  },
386
386
  minLength: 2,
387
387
  maxLength: 2,
388
388
  type: "number"
389
389
  },
390
390
  "%S": {
391
- format: function(t) {
392
- return n(t.seconds() || i.MIN_SECONDS, 2);
391
+ format: function(r) {
392
+ return i(r.seconds() || n.MIN_SECONDS, 2);
393
393
  },
394
- parse: function(t) {
395
- var a = Number(t);
396
- return { seconds: isNaN(a) ? e : a };
394
+ parse: function(r) {
395
+ var o = Number(r);
396
+ return { seconds: isNaN(o) ? e : o };
397
397
  },
398
398
  minLength: 2,
399
399
  maxLength: 2,
400
400
  type: "number"
401
401
  },
402
402
  "%s": {
403
- format: function(t) {
404
- return t.timestamp();
403
+ format: function(r) {
404
+ return r.timestamp();
405
405
  },
406
- parse: function(t) {
407
- return isNaN(Number(t)) ? {} : i(Number(t)).get();
406
+ parse: function(r) {
407
+ return isNaN(Number(r)) ? {} : n(Number(r)).get();
408
408
  },
409
409
  minLength: 1,
410
410
  maxLength: 20,
411
411
  type: "number"
412
412
  },
413
413
  "%F": {
414
- format: function(t) {
415
- return n(t.year() || i.MIN_YEAR, 4) + "-" + n(t.month() || i.MIN_MONTH, 2) + "-" + n(t.day() || i.MIN_DAY, 2);
414
+ format: function(r) {
415
+ return i(r.year() || n.MIN_YEAR, 4) + "-" + i(r.month() || n.MIN_MONTH, 2) + "-" + i(r.day() || n.MIN_DAY, 2);
416
416
  },
417
- parse: function(t) {
418
- var a = Number(t.slice(0, 4)), d = Number(t.slice(5, 7)), g = Number(t.slice(8, 10));
417
+ parse: function(r) {
418
+ var o = Number(r.slice(0, 4)), d = Number(r.slice(5, 7)), g = Number(r.slice(8, 10));
419
419
  return {
420
- year: a,
420
+ year: o,
421
421
  month: d,
422
422
  day: g
423
423
  };
@@ -427,14 +427,14 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
427
427
  type: "string"
428
428
  },
429
429
  "%D": {
430
- format: function(t) {
431
- return n(t.month() || i.MIN_MONTH, 2) + "/" + n(t.day() || i.MIN_DAY, 2) + "/" + n(t.year() || i.MIN_YEAR, 4);
430
+ format: function(r) {
431
+ return i(r.month() || n.MIN_MONTH, 2) + "/" + i(r.day() || n.MIN_DAY, 2) + "/" + i(r.year() || n.MIN_YEAR, 4);
432
432
  },
433
- parse: function(t) {
434
- var a = Number(t.slice(0, 2)), d = Number(t.slice(3, 5)), g = Number(t.slice(6, 10));
433
+ parse: function(r) {
434
+ var o = Number(r.slice(0, 2)), d = Number(r.slice(3, 5)), g = Number(r.slice(6, 10));
435
435
  return {
436
436
  year: g,
437
- month: a,
437
+ month: o,
438
438
  day: d
439
439
  };
440
440
  },
@@ -442,11 +442,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
442
442
  maxLength: 10,
443
443
  type: "string"
444
444
  }
445
- }, H = {
445
+ }, U = {
446
446
  useMilliseconds: !1,
447
447
  monthFromZero: !1
448
- }, b;
449
- b = function(t, a, d) {
448
+ }, M;
449
+ M = function(r, o, d) {
450
450
  return this._d = /* @__PURE__ */ new Date(), this._i = {
451
451
  year: !1,
452
452
  month: !1,
@@ -455,56 +455,56 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
455
455
  minutes: !1,
456
456
  seconds: !1,
457
457
  milliseconds: !1
458
- }, t !== e && this.set(t, a, d), this;
459
- }, b.fn = b.prototype, b.fn.dayCount = function() {
460
- var t = this.month(), a = i.MAX_DAY_IN_MONTHS[t - (i.options("monthFromZero") ? 0 : 1)];
461
- return this.leapYear() && t === (i.options("monthFromZero") ? 1 : 2) && (a += 1), a;
462
- }, b.fn.year = function(t) {
458
+ }, r !== e && this.set(r, o, d), this;
459
+ }, M.fn = M.prototype, M.fn.dayCount = function() {
460
+ var r = this.month(), o = n.MAX_DAY_IN_MONTHS[r - (n.options("monthFromZero") ? 0 : 1)];
461
+ return this.leapYear() && r === (n.options("monthFromZero") ? 1 : 2) && (o += 1), o;
462
+ }, M.fn.year = function(r) {
463
463
  if (arguments.length !== 0)
464
- (typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= i.MIN_YEAR && Number(t) <= i.MAX_YEAR ? (this._d.setFullYear(Number(t)), this._i.year = !1) : this._i.year = Number(t) : (this._d.setFullYear(i.MIN_YEAR), this._i.year = !1);
464
+ (typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_YEAR && Number(r) <= n.MAX_YEAR ? (this._d.setFullYear(Number(r)), this._i.year = !1) : this._i.year = Number(r) : (this._d.setFullYear(n.MIN_YEAR), this._i.year = !1);
465
465
  else
466
466
  return this._i.year === !1 ? this._d.getFullYear() : this._i.year;
467
467
  return this;
468
- }, b.fn.month = function(t) {
468
+ }, M.fn.month = function(r) {
469
469
  if (arguments.length !== 0)
470
- (typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= i.MIN_MONTH && Number(t) <= i.MAX_MONTH ? (this._d.setMonth(i.options("monthFromZero") ? Number(t) : Number(t) - 1), this._i.month = !1) : this._i.month = Number(t) : (this._d.setMonth(i.options("monthFromZero") ? i.MIN_MONTH : i.MIN_MONTH - 1), this._i.month = !1);
470
+ (typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_MONTH && Number(r) <= n.MAX_MONTH ? (this._d.setMonth(n.options("monthFromZero") ? Number(r) : Number(r) - 1), this._i.month = !1) : this._i.month = Number(r) : (this._d.setMonth(n.options("monthFromZero") ? n.MIN_MONTH : n.MIN_MONTH - 1), this._i.month = !1);
471
471
  else
472
- return this._i.month === !1 ? i.options("monthFromZero") ? this._d.getMonth() : this._d.getMonth() + 1 : this._i.month;
472
+ return this._i.month === !1 ? n.options("monthFromZero") ? this._d.getMonth() : this._d.getMonth() + 1 : this._i.month;
473
473
  return this;
474
- }, b.fn.day = function(t) {
474
+ }, M.fn.day = function(r) {
475
475
  if (arguments.length !== 0)
476
- (typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= i.MIN_DAY && Number(t) <= this.dayCount() ? (this._d.setDate(Number(t)), this._i.day = !1) : this._i.day = Number(t) : (this._d.setDate(i.MIN_DAY), this._i.day = !1);
476
+ (typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_DAY && Number(r) <= this.dayCount() ? (this._d.setDate(Number(r)), this._i.day = !1) : this._i.day = Number(r) : (this._d.setDate(n.MIN_DAY), this._i.day = !1);
477
477
  else
478
478
  return this._i.day === !1 ? this._d.getDate() : this._i.day;
479
479
  return this;
480
- }, b.fn.hours = function(t) {
480
+ }, M.fn.hours = function(r) {
481
481
  if (arguments.length !== 0)
482
- (typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= i.MIN_HOURS && Number(t) <= i.MAX_HOURS ? (this._d.setHours(Number(t)), this._i.hours = !1) : this._i.hours = Number(t) : (this._d.setHours(i.MIN_HOURS), this._i.hours = !1);
482
+ (typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_HOURS && Number(r) <= n.MAX_HOURS ? (this._d.setHours(Number(r)), this._i.hours = !1) : this._i.hours = Number(r) : (this._d.setHours(n.MIN_HOURS), this._i.hours = !1);
483
483
  else
484
484
  return this._i.hours === !1 ? this._d.getHours() : this._i.hours;
485
485
  return this;
486
- }, b.fn.minutes = function(t) {
486
+ }, M.fn.minutes = function(r) {
487
487
  if (arguments.length !== 0)
488
- (typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= i.MIN_MINUTES && Number(t) <= i.MAX_MINUTES ? (this._d.setMinutes(Number(t)), this._i.minutes = !1) : this._i.minutes = Number(t) : (this._d.setMinutes(i.MIN_MINUTES), this._i.minutes = !1);
488
+ (typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_MINUTES && Number(r) <= n.MAX_MINUTES ? (this._d.setMinutes(Number(r)), this._i.minutes = !1) : this._i.minutes = Number(r) : (this._d.setMinutes(n.MIN_MINUTES), this._i.minutes = !1);
489
489
  else
490
490
  return this._i.minutes === !1 ? this._d.getMinutes() : this._i.minutes;
491
491
  return this;
492
- }, b.fn.seconds = function(t) {
492
+ }, M.fn.seconds = function(r) {
493
493
  if (arguments.length !== 0)
494
- (typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= i.MIN_SECONDS && Number(t) <= i.MAX_SECONDS ? (this._d.setSeconds(Number(t)), this._i.seconds = !1) : this._i.seconds = Number(t) : (this._d.setSeconds(i.MIN_SECONDS), this._i.seconds = !1);
494
+ (typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_SECONDS && Number(r) <= n.MAX_SECONDS ? (this._d.setSeconds(Number(r)), this._i.seconds = !1) : this._i.seconds = Number(r) : (this._d.setSeconds(n.MIN_SECONDS), this._i.seconds = !1);
495
495
  else
496
496
  return this._i.seconds === !1 ? this._d.getSeconds() : this._i.seconds;
497
497
  return this;
498
- }, b.fn.milliseconds = function(t) {
498
+ }, M.fn.milliseconds = function(r) {
499
499
  if (arguments.length !== 0)
500
- (typeof t == "number" || typeof t == "string") && !isNaN(Number(t)) ? Number(t) >= i.MIN_MILLISECONDS && Number(t) <= i.MAX_MILLISECONDS ? (this._d.setMilliseconds(Number(t)), this._i.milliseconds = !1) : this._i.milliseconds = Number(t) : (this._d.setMilliseconds(i.MIN_MILLISECONDS), this._i.milliseconds = !1);
500
+ (typeof r == "number" || typeof r == "string") && !isNaN(Number(r)) ? Number(r) >= n.MIN_MILLISECONDS && Number(r) <= n.MAX_MILLISECONDS ? (this._d.setMilliseconds(Number(r)), this._i.milliseconds = !1) : this._i.milliseconds = Number(r) : (this._d.setMilliseconds(n.MIN_MILLISECONDS), this._i.milliseconds = !1);
501
501
  else
502
502
  return this._i.milliseconds === !1 ? this._d.getMilliseconds() : this._i.milliseconds;
503
503
  return this;
504
- }, b.fn.week = function() {
505
- var t = new Date(this.year(), 0, 1), a = i(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
506
- return Math.ceil(((a - t.getTime()) / 864e5 + t.getDay() + 1) / 7);
507
- }, b.fn.set = function(t, a, d) {
504
+ }, M.fn.week = function() {
505
+ var r = new Date(this.year(), 0, 1), o = n(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
506
+ return Math.ceil(((o - r.getTime()) / 864e5 + r.getDay() + 1) / 7);
507
+ }, M.fn.set = function(r, o, d) {
508
508
  if (this._i = {
509
509
  year: !1,
510
510
  month: !1,
@@ -513,16 +513,16 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
513
513
  minutes: !1,
514
514
  seconds: !1,
515
515
  milliseconds: !1
516
- }, t === e)
516
+ }, r === e)
517
517
  return this._d = /* @__PURE__ */ new Date(), this;
518
- if (t instanceof Date)
519
- return this._d = t, this;
520
- if (typeof t == "number")
521
- return this._d = new Date(t * (i.options("useMilliseconds") ? 1 : 1e3)), this;
522
- if (typeof t == "object" && (t instanceof Array ? (this.day(i.MIN_DAY), this.year(t[0]), this.month(t[1]), this.day(t[2]), this.hours(t[3]), this.minutes(t[4]), this.seconds(t[5]), this.milliseconds(t[6])) : (this.day(i.MIN_DAY), this.year(t.year), this.month(t.month), this.day(t.day), this.hours(t.hours), this.minutes(t.minutes), this.seconds(t.seconds), this.milliseconds(t.milliseconds))), typeof t == "string") {
523
- var g, D = [], L, B, Q = [], W = 0, x = 0, P, X, Y = {}, G;
524
- if (t === e)
525
- return L = o(this, d), L === e && (this._i = {
518
+ if (r instanceof Date)
519
+ return this._d = r, this;
520
+ if (typeof r == "number")
521
+ return this._d = new Date(r * (n.options("useMilliseconds") ? 1 : 1e3)), this;
522
+ if (typeof r == "object" && (r instanceof Array ? (this.day(n.MIN_DAY), this.year(r[0]), this.month(r[1]), this.day(r[2]), this.hours(r[3]), this.minutes(r[4]), this.seconds(r[5]), this.milliseconds(r[6])) : (this.day(n.MIN_DAY), this.year(r.year), this.month(r.month), this.day(r.day), this.hours(r.hours), this.minutes(r.minutes), this.seconds(r.seconds), this.milliseconds(r.milliseconds))), typeof r == "string") {
523
+ var g, w = [], b, B, z = [], W = 0, x = 0, Y, X, G = {}, P;
524
+ if (r === e)
525
+ return b = a(this, d), b === e && (this._i = {
526
526
  year: -1,
527
527
  month: -1,
528
528
  day: -1,
@@ -530,26 +530,26 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
530
530
  minutes: -1,
531
531
  seconds: -1,
532
532
  milliseconds: -1
533
- }), L;
534
- for (a === e && (a = i.detectFormat(t)); W < a.length; ) {
535
- if (a.charAt(W) === "%") {
536
- if (B = a.charAt(W) + a.charAt(W + 1), M[B] !== e) {
537
- switch (P = 0, X = "", M[B].type) {
533
+ }), b;
534
+ for (o === e && (o = n.detectFormat(r)); W < o.length; ) {
535
+ if (o.charAt(W) === "%") {
536
+ if (B = o.charAt(W) + o.charAt(W + 1), k[B] !== e) {
537
+ switch (Y = 0, X = "", k[B].type) {
538
538
  case "number":
539
- for (; P < M[B].maxLength && x + P < t.length && !isNaN(Number(t.charAt(x + P))); )
540
- X += t.charAt(x + P), P += 1;
539
+ for (; Y < k[B].maxLength && x + Y < r.length && !isNaN(Number(r.charAt(x + Y))); )
540
+ X += r.charAt(x + Y), Y += 1;
541
541
  break;
542
542
  case "word":
543
- for (; P < M[B].maxLength && x + P < t.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(x + P)); )
544
- X += t.charAt(x + P), P += 1;
543
+ for (; Y < k[B].maxLength && x + Y < r.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(r.charAt(x + Y)); )
544
+ X += r.charAt(x + Y), Y += 1;
545
545
  break;
546
546
  case "string":
547
- for (; P < M[B].maxLength && x + P < t.length; )
548
- X += t.charAt(x + P), P += 1;
547
+ for (; Y < k[B].maxLength && x + Y < r.length; )
548
+ X += r.charAt(x + Y), Y += 1;
549
549
  break;
550
550
  }
551
- if (P < M[B].minLength)
552
- return L = o(this, d), L === e && (this._i = {
551
+ if (Y < k[B].minLength)
552
+ return b = a(this, d), b === e && (this._i = {
553
553
  year: -1,
554
554
  month: -1,
555
555
  day: -1,
@@ -557,11 +557,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
557
557
  minutes: -1,
558
558
  seconds: -1,
559
559
  milliseconds: -1
560
- }), L;
561
- D.push(B), Q.push(X), P -= 1, x += P, W += 1;
560
+ }), b;
561
+ w.push(B), z.push(X), Y -= 1, x += Y, W += 1;
562
562
  }
563
- } else if (t.charAt(x) !== a.charAt(W))
564
- return L = o(this, d), L === e && (this._i = {
563
+ } else if (r.charAt(x) !== o.charAt(W))
564
+ return b = a(this, d), b === e && (this._i = {
565
565
  year: -1,
566
566
  month: -1,
567
567
  day: -1,
@@ -569,51 +569,51 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
569
569
  minutes: -1,
570
570
  seconds: -1,
571
571
  milliseconds: -1
572
- }), L;
572
+ }), b;
573
573
  W += 1, x += 1;
574
574
  }
575
- for (g in D)
576
- D.hasOwnProperty(g) && M.hasOwnProperty(D[g]) && (G = M[D[g]].parse(Q[g]), Y = {
577
- year: G.year !== e ? G.year : Y.year,
578
- month: G.month !== e ? G.month : Y.month,
579
- day: G.day !== e ? G.day : Y.day,
580
- hours: G.hours !== e ? G.hours : Y.hours,
581
- minutes: G.minutes !== e ? G.minutes : Y.minutes,
582
- seconds: G.seconds !== e ? G.seconds : Y.seconds
575
+ for (g in w)
576
+ w.hasOwnProperty(g) && k.hasOwnProperty(w[g]) && (P = k[w[g]].parse(z[g]), G = {
577
+ year: P.year !== e ? P.year : G.year,
578
+ month: P.month !== e ? P.month : G.month,
579
+ day: P.day !== e ? P.day : G.day,
580
+ hours: P.hours !== e ? P.hours : G.hours,
581
+ minutes: P.minutes !== e ? P.minutes : G.minutes,
582
+ seconds: P.seconds !== e ? P.seconds : G.seconds
583
583
  });
584
- this.day(i.MIN_DAY), this.year(Y.year), this.month(Y.month), this.day(Y.day), this.hours(Y.hours), this.minutes(Y.minutes), this.seconds(Y.seconds), this.milliseconds(Y.milliseconds);
584
+ this.day(n.MIN_DAY), this.year(G.year), this.month(G.month), this.day(G.day), this.hours(G.hours), this.minutes(G.minutes), this.seconds(G.seconds), this.milliseconds(G.milliseconds);
585
585
  }
586
586
  return this;
587
- }, b.fn.leapYear = function() {
588
- var t = this.year();
589
- return t % 4 === 0 ? t % 100 === 0 ? t % 400 === 0 : !0 : !1;
590
- }, b.fn.timestamp = function(t) {
591
- return arguments.length !== 0 ? (this._d = new Date(Number(t) * (i.options("useMilliseconds") ? 1 : 1e3) + this._d.getTimezoneOffset() * 6e4), this) : i.options("useMilliseconds") ? this._d.getTime() - this._d.getTimezoneOffset() * 6e4 : Math.floor(this._d.getTime() / 1e3) - this._d.getTimezoneOffset() * 60;
592
- }, b.fn.utc = function(t) {
593
- return arguments.length !== 0 ? (this._d = new Date(Number(t) * (i.options("useMilliseconds") ? 1 : 1e3)), this) : i.options("useMilliseconds") ? this._d.getTime() : Math.floor(this._d.getTime() / 1e3);
594
- }, b.fn.dayOfWeek = function(t) {
595
- if (t === "long")
596
- return k[this._d.getDay()];
597
- if (t === "short")
598
- return C[this._d.getDay()];
599
- if (t === e)
587
+ }, M.fn.leapYear = function() {
588
+ var r = this.year();
589
+ return r % 4 === 0 ? r % 100 === 0 ? r % 400 === 0 : !0 : !1;
590
+ }, M.fn.timestamp = function(r) {
591
+ return arguments.length !== 0 ? (this._d = new Date(Number(r) * (n.options("useMilliseconds") ? 1 : 1e3) + this._d.getTimezoneOffset() * 6e4), this) : n.options("useMilliseconds") ? this._d.getTime() - this._d.getTimezoneOffset() * 6e4 : Math.floor(this._d.getTime() / 1e3) - this._d.getTimezoneOffset() * 60;
592
+ }, M.fn.utc = function(r) {
593
+ return arguments.length !== 0 ? (this._d = new Date(Number(r) * (n.options("useMilliseconds") ? 1 : 1e3)), this) : n.options("useMilliseconds") ? this._d.getTime() : Math.floor(this._d.getTime() / 1e3);
594
+ }, M.fn.dayOfWeek = function(r) {
595
+ if (r === "long")
596
+ return L[this._d.getDay()];
597
+ if (r === "short")
598
+ return I[this._d.getDay()];
599
+ if (r === e)
600
600
  return this._d.getDay();
601
- if (t === 0 || t === "Sunday")
601
+ if (r === 0 || r === "Sunday")
602
602
  return this.calc({ day: -this.dayOfWeek() });
603
- if (t === 1 || t === "Monday")
603
+ if (r === 1 || r === "Monday")
604
604
  return this.calc({ day: (this.dayOfWeek() === 0 ? -6 : 1) - this.dayOfWeek() });
605
- if (t === 2 || t === "Tuesday")
605
+ if (r === 2 || r === "Tuesday")
606
606
  return this.calc({ day: (this.dayOfWeek() === 0 ? -5 : 2) - this.dayOfWeek() });
607
- if (t === 3 || t === "Wednesday")
607
+ if (r === 3 || r === "Wednesday")
608
608
  return this.calc({ day: (this.dayOfWeek() === 0 ? -4 : 3) - this.dayOfWeek() });
609
- if (t === 4 || t === "Thursday")
609
+ if (r === 4 || r === "Thursday")
610
610
  return this.calc({ day: (this.dayOfWeek() === 0 ? -3 : 4) - this.dayOfWeek() });
611
- if (t === 5 || t === "Friday")
611
+ if (r === 5 || r === "Friday")
612
612
  return this.calc({ day: (this.dayOfWeek() === 0 ? -2 : 5) - this.dayOfWeek() });
613
- if (t === 6 || t === "Saturday")
613
+ if (r === 6 || r === "Saturday")
614
614
  return this.calc({ day: (this.dayOfWeek() === 0 ? -1 : 6) - this.dayOfWeek() });
615
- }, b.fn.timezone = function(t) {
616
- switch (t) {
615
+ }, M.fn.timezone = function(r) {
616
+ switch (r) {
617
617
  case "hours":
618
618
  return Math.floor(this._d.getTimezoneOffset() / 60);
619
619
  case "minutes":
@@ -621,12 +621,12 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
621
621
  default:
622
622
  return this._d.getTimezoneOffset() * 60;
623
623
  }
624
- }, b.fn.get = function(t) {
625
- switch (t) {
624
+ }, M.fn.get = function(r) {
625
+ switch (r) {
626
626
  case "Date":
627
627
  return new Date(
628
628
  this.year(),
629
- this.month() - (i.options("monthFromZero") ? 0 : 1),
629
+ this.month() - (n.options("monthFromZero") ? 0 : 1),
630
630
  this.day(),
631
631
  this.hours(),
632
632
  this.minutes(),
@@ -636,7 +636,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
636
636
  case "DateUTC":
637
637
  return new Date(Date.UTC(
638
638
  this.year(),
639
- this.month() - (i.options("monthFromZero") ? 0 : 1),
639
+ this.month() - (n.options("monthFromZero") ? 0 : 1),
640
640
  this.day(),
641
641
  this.hours(),
642
642
  this.minutes(),
@@ -670,17 +670,17 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
670
670
  timestamp: this.timestamp()
671
671
  };
672
672
  }
673
- }, b.fn.format = function(t) {
674
- for (var a = 0, d = "", g; a < t.length; )
675
- t.charAt(a) === "%" ? (g = t.charAt(a) + t.charAt(a + 1), M[g] !== e ? (d += M[g].format(this), a += 1) : d += "%") : d += t.charAt(a), a += 1;
673
+ }, M.fn.format = function(r) {
674
+ for (var o = 0, d = "", g; o < r.length; )
675
+ r.charAt(o) === "%" ? (g = r.charAt(o) + r.charAt(o + 1), k[g] !== e ? (d += k[g].format(this), o += 1) : d += "%") : d += r.charAt(o), o += 1;
676
676
  return d;
677
- }, b.fn.valid = function() {
677
+ }, M.fn.valid = function() {
678
678
  return this._i.year === !1 && this._i.month === !1 && this._i.day === !1 && this._i.hours === !1 && this._i.minutes === !1 && this._i.seconds === !1 && this._i.milliseconds === !1;
679
- }, b.fn.errors = function() {
679
+ }, M.fn.errors = function() {
680
680
  return this._i;
681
- }, b.fn.between = function(t, a) {
682
- var d = this.timestamp(), g = t.timestamp();
683
- switch (a) {
681
+ }, M.fn.between = function(r, o) {
682
+ var d = this.timestamp(), g = r.timestamp();
683
+ switch (o) {
684
684
  case "year":
685
685
  return Math.floor((g - d) / 31556952);
686
686
  case "month":
@@ -696,149 +696,149 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : a(JSON.pars
696
696
  default:
697
697
  return e;
698
698
  }
699
- }, b.fn.calc = function(t) {
700
- return t.year !== e && this._d.setFullYear(this._d.getFullYear() + t.year), t.month !== e && this._d.setMonth(this._d.getMonth() + t.month), t.day !== e && this._d.setDate(this._d.getDate() + t.day), t.hours !== e && this._d.setHours(this._d.getHours() + t.hours), t.minutes !== e && this._d.setMinutes(this._d.getMinutes() + t.minutes), t.seconds !== e && this._d.setSeconds(this._d.getSeconds() + t.seconds), t.milliseconds !== e && this._d.setMilliseconds(this._d.getMilliseconds() + t.milliseconds), this;
701
- }, i = function(t, a, d) {
702
- return new b(t, a, d);
703
- }, i.MIN_YEAR = 1e3, i.MAX_YEAR = 3e3, i.MIN_MONTH = 1, i.MAX_MONTH = 12, i.MIN_DAY = 1, i.MAX_DAY_IN_MONTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], i.MIN_DAY_OF_WEEK = 0, i.MAX_DAY_OF_WEEK = 6, i.MIN_HOURS = 0, i.MAX_HOURS = 23, i.MIN_MINUTES = 0, i.MAX_MINUTES = 59, i.MIN_SECONDS = 0, i.MAX_SECONDS = 59, i.MIN_MILLISECONDS = 0, i.MAX_MILLISECONDS = 999, i.VERSION = "0.2.18", i.options = function(t, a) {
704
- if (t === e)
705
- return H;
706
- if (H.hasOwnProperty(t)) {
707
- if (a === e)
708
- return H[t];
709
- H[t] = a, t === "monthFromZero" && (i.MIN_MONTH = a ? 0 : 1, i.MAX_MONTH = a ? 11 : 12);
699
+ }, M.fn.calc = function(r) {
700
+ return r.year !== e && this._d.setFullYear(this._d.getFullYear() + r.year), r.month !== e && this._d.setMonth(this._d.getMonth() + r.month), r.day !== e && this._d.setDate(this._d.getDate() + r.day), r.hours !== e && this._d.setHours(this._d.getHours() + r.hours), r.minutes !== e && this._d.setMinutes(this._d.getMinutes() + r.minutes), r.seconds !== e && this._d.setSeconds(this._d.getSeconds() + r.seconds), r.milliseconds !== e && this._d.setMilliseconds(this._d.getMilliseconds() + r.milliseconds), this;
701
+ }, n = function(r, o, d) {
702
+ return new M(r, o, d);
703
+ }, n.MIN_YEAR = 1e3, n.MAX_YEAR = 3e3, n.MIN_MONTH = 1, n.MAX_MONTH = 12, n.MIN_DAY = 1, n.MAX_DAY_IN_MONTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], n.MIN_DAY_OF_WEEK = 0, n.MAX_DAY_OF_WEEK = 6, n.MIN_HOURS = 0, n.MAX_HOURS = 23, n.MIN_MINUTES = 0, n.MAX_MINUTES = 59, n.MIN_SECONDS = 0, n.MAX_SECONDS = 59, n.MIN_MILLISECONDS = 0, n.MAX_MILLISECONDS = 999, n.VERSION = "0.2.18", n.options = function(r, o) {
704
+ if (r === e)
705
+ return U;
706
+ if (U.hasOwnProperty(r)) {
707
+ if (o === e)
708
+ return U[r];
709
+ U[r] = o, r === "monthFromZero" && (n.MIN_MONTH = o ? 0 : 1, n.MAX_MONTH = o ? 11 : 12);
710
710
  }
711
711
  return e;
712
- }, i.noConflict = function() {
713
- return s.tempus = l, i;
714
- }, i.generate = function(t) {
715
- var a, d, g, D, L, B, Q, W;
716
- if (typeof t.dateFrom != "number" && (t.dateFrom instanceof b ? a = t.dateFrom.utc() : a = i(t.dateFrom, t.formatFrom).utc()), typeof t.dateTo != "number" && (t.dateTo instanceof b ? d = t.dateTo.utc() : d = i(t.dateTo, t.formatTo !== e ? t.formatTo : t.formatFrom).utc()), typeof t.period == "number" ? L = {
712
+ }, n.noConflict = function() {
713
+ return s.tempus = h, n;
714
+ }, n.generate = function(r) {
715
+ var o, d, g, w, b, B, z, W;
716
+ if (typeof r.dateFrom != "number" && (r.dateFrom instanceof M ? o = r.dateFrom.utc() : o = n(r.dateFrom, r.formatFrom).utc()), typeof r.dateTo != "number" && (r.dateTo instanceof M ? d = r.dateTo.utc() : d = n(r.dateTo, r.formatTo !== e ? r.formatTo : r.formatFrom).utc()), typeof r.period == "number" ? b = {
717
717
  year: 0,
718
718
  month: 0,
719
719
  day: 0,
720
720
  hours: 0,
721
721
  minutes: 0,
722
- seconds: t.period
723
- } : typeof t.period == "string" ? L = {
724
- year: t.period === "year" ? 1 : 0,
725
- month: t.period === "month" ? 1 : 0,
726
- day: t.period === "day" ? 1 : 0,
727
- hours: t.period === "hours" ? 1 : 0,
728
- minutes: t.period === "minutes" ? 1 : 0,
729
- seconds: t.period === "seconds" ? 1 : 0
730
- } : typeof t.period == "object" && (L = {
731
- year: t.period.year !== e ? t.period.year : 0,
732
- month: t.period.month !== e ? t.period.month : 0,
733
- day: t.period.day !== e ? t.period.day : 0,
734
- hours: t.period.hours !== e ? t.period.hours : 0,
735
- minutes: t.period.minutes !== e ? t.period.minutes : 0,
736
- seconds: t.period.seconds !== e ? t.period.seconds : 0
737
- }), t.groupBy === e ? B = t.asObject === !0 ? {} : [] : (B = [], B.push([]), Q = i(a).get()[t.groupBy]), W = function(X, Y, G) {
738
- return t.asObject === !0 ? t.format !== e ? X[i(Y).format(t.format)] = {} : X[i(Y).format("%F %H:%M:%S")] = {} : t.format !== e ? X.push(G ? null : i(Y).format(t.format)) : X.push(G ? null : i(Y)), X;
739
- }, t.groupBy !== e && t.fillNulls) {
722
+ seconds: r.period
723
+ } : typeof r.period == "string" ? b = {
724
+ year: r.period === "year" ? 1 : 0,
725
+ month: r.period === "month" ? 1 : 0,
726
+ day: r.period === "day" ? 1 : 0,
727
+ hours: r.period === "hours" ? 1 : 0,
728
+ minutes: r.period === "minutes" ? 1 : 0,
729
+ seconds: r.period === "seconds" ? 1 : 0
730
+ } : typeof r.period == "object" && (b = {
731
+ year: r.period.year !== e ? r.period.year : 0,
732
+ month: r.period.month !== e ? r.period.month : 0,
733
+ day: r.period.day !== e ? r.period.day : 0,
734
+ hours: r.period.hours !== e ? r.period.hours : 0,
735
+ minutes: r.period.minutes !== e ? r.period.minutes : 0,
736
+ seconds: r.period.seconds !== e ? r.period.seconds : 0
737
+ }), r.groupBy === e ? B = r.asObject === !0 ? {} : [] : (B = [], B.push([]), z = n(o).get()[r.groupBy]), W = function(X, G, P) {
738
+ return r.asObject === !0 ? r.format !== e ? X[n(G).format(r.format)] = {} : X[n(G).format("%F %H:%M:%S")] = {} : r.format !== e ? X.push(P ? null : n(G).format(r.format)) : X.push(P ? null : n(G)), X;
739
+ }, r.groupBy !== e && r.fillNulls) {
740
740
  var x = {
741
- year: L.year ? -L.year : e,
742
- month: L.month ? -L.month : e,
743
- day: L.day ? -L.day : e,
744
- hours: L.hours ? -L.hours : e,
745
- minutes: L.minutes ? -L.minutes : e,
746
- seconds: L.seconds ? -L.seconds : e,
747
- milliseconds: L.milliseconds ? -L.milliseconds : e
741
+ year: b.year ? -b.year : e,
742
+ month: b.month ? -b.month : e,
743
+ day: b.day ? -b.day : e,
744
+ hours: b.hours ? -b.hours : e,
745
+ minutes: b.minutes ? -b.minutes : e,
746
+ seconds: b.seconds ? -b.seconds : e,
747
+ milliseconds: b.milliseconds ? -b.milliseconds : e
748
748
  };
749
- for (g = i(a).calc(x).utc(); i(g).get()[t.groupBy] === Q; )
750
- W(B[B.length - 1], g, !0), g = i(g).calc(x).utc();
751
- if (t.groupBy === "week") {
752
- var P = i(a).dayOfWeek();
753
- for (g = i(a).dayOfWeek(0).utc(); B[0].length < P && g < a; )
754
- W(B[B.length - 1], g, !0), g = i(g).calc(L).utc();
749
+ for (g = n(o).calc(x).utc(); n(g).get()[r.groupBy] === z; )
750
+ W(B[B.length - 1], g, !0), g = n(g).calc(x).utc();
751
+ if (r.groupBy === "week") {
752
+ var Y = n(o).dayOfWeek();
753
+ for (g = n(o).dayOfWeek(0).utc(); B[0].length < Y && g < o; )
754
+ W(B[B.length - 1], g, !0), g = n(g).calc(b).utc();
755
755
  }
756
756
  }
757
- for (; a <= d; )
758
- t.groupBy === e ? W(B, a) : i(a).get()[t.groupBy] === Q ? W(B[B.length - 1], a) : (B.push([]), W(B[B.length - 1], a), Q = i(a).get()[t.groupBy]), a = i(a).calc(L).utc();
759
- if (t.groupBy !== e && t.fillNulls)
760
- for (D = i(d).calc(L).utc(); i(D).get()[t.groupBy] === Q; )
761
- W(B[B.length - 1], D, !0), D = i(D).calc(L).utc();
757
+ for (; o <= d; )
758
+ r.groupBy === e ? W(B, o) : n(o).get()[r.groupBy] === z ? W(B[B.length - 1], o) : (B.push([]), W(B[B.length - 1], o), z = n(o).get()[r.groupBy]), o = n(o).calc(b).utc();
759
+ if (r.groupBy !== e && r.fillNulls)
760
+ for (w = n(d).calc(b).utc(); n(w).get()[r.groupBy] === z; )
761
+ W(B[B.length - 1], w, !0), w = n(w).calc(b).utc();
762
762
  return B;
763
- }, i.monthNames = function(t) {
764
- switch (t) {
763
+ }, n.monthNames = function(r) {
764
+ switch (r) {
765
765
  case "long":
766
- return p;
766
+ return N;
767
767
  default:
768
- return T;
768
+ return y;
769
769
  }
770
- }, i.dayNames = function(t) {
771
- switch (t) {
770
+ }, n.dayNames = function(r) {
771
+ switch (r) {
772
772
  case "long":
773
- return k;
773
+ return L;
774
774
  default:
775
- return C;
775
+ return I;
776
776
  }
777
- }, i.lang = function(t) {
778
- if (t !== e)
779
- c = t, f[c] === e && (c = "en"), p = O(), T = _(), k = m(), C = N();
777
+ }, n.lang = function(r) {
778
+ if (r !== e)
779
+ c = r, f[c] === e && (c = "en"), N = O(), y = T(), L = _(), I = R();
780
780
  else
781
781
  return c;
782
782
  return e;
783
- }, i.availableLangs = function() {
783
+ }, n.availableLangs = function() {
784
784
  return Object.keys(f);
785
- }, i.registerFormat = function(t, a, d, g, D, L) {
786
- M[t] = {
787
- format: a,
785
+ }, n.registerFormat = function(r, o, d, g, w, b) {
786
+ k[r] = {
787
+ format: o,
788
788
  parse: d,
789
789
  minLength: g,
790
- maxLength: D,
791
- type: L
790
+ maxLength: w,
791
+ type: b
792
792
  };
793
- }, i.unregisterFormat = function(t) {
794
- delete M[t];
795
- }, i.detectFormat = function(t) {
796
- var a, d, g;
797
- return a = A(t, 0), a !== "" && (g = 10), d = t.charAt(g), (d === "T" || d === " ") && (a += d, g += 1), a += h(t, g), a;
793
+ }, n.unregisterFormat = function(r) {
794
+ delete k[r];
795
+ }, n.detectFormat = function(r) {
796
+ var o, d, g;
797
+ return o = A(r, 0), o !== "" && (g = 10), d = r.charAt(g), (d === "T" || d === " ") && (o += d, g += 1), o += l(r, g), o;
798
798
  }, u = {
799
- TempusDate: b
800
- }, i.classes = function(t, a) {
801
- if (a === e)
802
- return u[t];
803
- u[t] = a;
804
- }, i.loadTranslations = function(t) {
805
- typeof t == "object" ? f = t : typeof t == "string" && U(t, function(a) {
806
- f = a;
807
- }, function(a) {
799
+ TempusDate: M
800
+ }, n.classes = function(r, o) {
801
+ if (o === e)
802
+ return u[r];
803
+ u[r] = o;
804
+ }, n.loadTranslations = function(r) {
805
+ typeof r == "object" ? f = r : typeof r == "string" && H(r, function(o) {
806
+ f = o;
807
+ }, function(o) {
808
808
  });
809
- }, c = (y.language || y.systemLanguage || y.userLanguage || "en").substr(0, 2).toLowerCase(), f[c] === e && (c = "en"), p = O(), T = _(), k = m(), C = N(), S.exports && (r = S.exports = i), r.tempus = i;
810
- }).call(Vt);
811
- })(Ct, Ct.exports);
812
- var te = Ct.exports;
813
- const mt = /* @__PURE__ */ $t(te);
814
- var gt, Yt, yt, pt, Nt, Ot, it, dt, _t, Gt, Tt, Wt, q, st, Z, ot, V, At, Et, xt, ht, kt;
809
+ }, c = (m.language || m.systemLanguage || m.userLanguage || "en").substr(0, 2).toLowerCase(), f[c] === e && (c = "en"), N = O(), y = T(), L = _(), I = R(), p.exports && (t = p.exports = n), t.tempus = n;
810
+ }).call(oe);
811
+ })(Ht, Ht.exports);
812
+ var Ae = Ht.exports;
813
+ const dt = /* @__PURE__ */ ae(Ae);
814
+ var yt, Jt, pt, Nt, Ot, _t, it, gt, Tt, jt, Et, Kt, Q, st, Z, at, V, At, Lt, vt, lt, Ut;
815
815
  const j = class j {
816
- constructor(r) {
816
+ constructor(t) {
817
817
  /**
818
818
  * Режим «прогресс по доле завершённых подкоманд» — только когда пачка похожа на
819
819
  * много параллельных list (crm.deal.list × N и т.п.). Иначе сохраняется старая
820
820
  * формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
821
821
  * @returns {boolean}
822
822
  */
823
- I(this, gt);
823
+ D(this, yt);
824
824
  /**
825
825
  * Одно обновление колбэка прогресса, если снимок изменился.
826
826
  * @returns {void}
827
827
  */
828
- I(this, it);
828
+ D(this, it);
829
829
  /**
830
830
  * Проверяет, изменились ли метрики прогресса относительно предыдущей отправки.
831
831
  *
832
832
  * @param {{percent: number, allCount: number, allTotal: number}} snapshot - Текущий снимок прогресса.
833
833
  * @returns {boolean} `true`, если нужно отправить callback прогресса.
834
834
  */
835
- I(this, _t);
835
+ D(this, Tt);
836
836
  /**
837
837
  * Уведомляет подписчиков о текущем состоянии лимита.
838
838
  *
839
839
  * @returns {void}
840
840
  */
841
- I(this, Tt);
841
+ D(this, Et);
842
842
  /**
843
843
  * Включает состояние лимита, выдерживает паузу и затем выключает лимит.
844
844
  * Используется как единый "cooldown" перед повторной отправкой chunk.
@@ -846,7 +846,7 @@ const j = class j {
846
846
  * @param {number} [pauseMs=this.defaultPauseMs] - Длительность паузы; для batch по умолчанию 120 с, для `call()` — `callLimitPauseMs` (30 с).
847
847
  * @returns {Promise<void>}
848
848
  */
849
- I(this, q);
849
+ D(this, Q);
850
850
  /**
851
851
  * Проверяет operating-time в результате batch и ставит паузу,
852
852
  * если сервер приблизился к лимиту выполнения.
@@ -854,7 +854,7 @@ const j = class j {
854
854
  * @param {Object} result - Результат текущего batch-запроса.
855
855
  * @returns {Promise<number>} Максимальный operating-time среди команд.
856
856
  */
857
- I(this, Z);
857
+ D(this, Z);
858
858
  /**
859
859
  * Выполняет один chunk с автоматическим повтором после лимит-паузы.
860
860
  * Повтор запускается при ошибках QUERY_LIMIT_EXCEEDED, OPERATION_TIME_LIMIT или TIMEOUT.
@@ -863,7 +863,7 @@ const j = class j {
863
863
  * @param {(result: Object) => Promise<void>} processResult - Обработчик успешного результата chunk.
864
864
  * @returns {Promise<void>}
865
865
  */
866
- I(this, V);
866
+ D(this, V);
867
867
  /**
868
868
  * Выполняет BX24.callMethod с таймаутом ожидания ответа.
869
869
  *
@@ -871,14 +871,14 @@ const j = class j {
871
871
  * @param {Object} params - Параметры REST-метода.
872
872
  * @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
873
873
  */
874
- I(this, Et);
874
+ D(this, Lt);
875
875
  /**
876
876
  * Resets mutable runtime state before each public batch run.
877
877
  * @param {Function} progressCall - Progress callback for current run.
878
878
  * @returns {void}
879
879
  */
880
- I(this, ht);
881
- typeof r == "function" ? (this.callBatch = r, this.callMethod = null) : (this.callBatch = (r == null ? void 0 : r.callBatch) || null, this.callMethod = (r == null ? void 0 : r.callMethod) || null), this.result = {}, this.errors = {}, this.timeLimit = {
880
+ D(this, lt);
881
+ typeof t == "function" ? (this.callBatch = t, this.callMethod = null) : (this.callBatch = (t == null ? void 0 : t.callBatch) || null, this.callMethod = (t == null ? void 0 : t.callMethod) || null), this.result = {}, this.errors = {}, this.timeLimit = {
882
882
  limit: !1,
883
883
  date: void 0,
884
884
  pauseMs: void 0
@@ -891,31 +891,31 @@ const j = class j {
891
891
  get progressPercent() {
892
892
  if (!this.progressData)
893
893
  return { percent: 0, allCount: 0, allTotal: 0 };
894
- const r = this.totalBatchCommands || 0;
895
- if (r > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && E(this, gt, Yt).call(this)) {
894
+ const t = this.totalBatchCommands || 0;
895
+ if (t > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && E(this, yt, Jt).call(this)) {
896
896
  let A = 0;
897
897
  for (const c of this.batchCommandKeyOrder) {
898
898
  const f = this.progressData[c];
899
899
  if (!f)
900
900
  continue;
901
- const O = Number(f.total) || 0, _ = Number(f.count) || 0;
902
- O === 0 && _ === 0 ? A += 1 : O > 0 && (A += Math.min(1, _ / O));
901
+ const O = Number(f.total) || 0, T = Number(f.count) || 0;
902
+ O === 0 && T === 0 ? A += 1 : O > 0 && (A += Math.min(1, T / O));
903
903
  }
904
- const l = A / r * 100;
905
- let i = Math.max(0, Math.min(100, Math.floor(l)));
906
- const u = r, y = Math.min(r, Math.floor(A));
907
- return { percent: i, allCount: y, allTotal: u };
904
+ const h = A / t * 100;
905
+ let n = Math.max(0, Math.min(100, Math.floor(h)));
906
+ const u = t, m = Math.min(t, Math.floor(A));
907
+ return { percent: n, allCount: m, allTotal: u };
908
908
  }
909
909
  let e = 0, s = 0;
910
910
  for (const A of Object.values(this.progressData)) {
911
- const { total: l, count: i } = A;
912
- e += l ?? 0, s += i ?? 0;
911
+ const { total: h, count: n } = A;
912
+ e += h ?? 0, s += n ?? 0;
913
913
  }
914
- const n = Number(this.chunkRate) || 0;
915
- let o = 0;
916
- e ? o = s / e * 100 * n + this.totalProgress : s === 0 && e === 0 ? o = 100 * n + this.totalProgress : o = 100, o = Math.max(0, Math.min(o, 100));
917
- let h = Math.floor(o);
918
- return e > 0 && s >= e && (h = 100), { percent: h, allCount: s, allTotal: e };
914
+ const i = Number(this.chunkRate) || 0;
915
+ let a = 0;
916
+ e ? a = s / e * 100 * i + this.totalProgress : s === 0 && e === 0 ? a = 100 * i + this.totalProgress : a = 100, a = Math.max(0, Math.min(a, 100));
917
+ let l = Math.floor(a);
918
+ return e > 0 && s >= e && (l = 100), { percent: l, allCount: s, allTotal: e };
919
919
  }
920
920
  /**
921
921
  * Обновление данных прогресса выполнения
@@ -924,38 +924,38 @@ const j = class j {
924
924
  * @param {Object} params.value - Значение ответа от API
925
925
  * @param {string} params.type - Тип обработки ('count' или undefined)
926
926
  */
927
- setProgressData({ key: r, value: e, type: s }) {
927
+ setProgressData({ key: t, value: e, type: s }) {
928
928
  var f, O;
929
929
  if (!this.progressCall)
930
930
  return;
931
- const n = this.getData(e.data()), o = Array.isArray(n) ? n.length : 0;
932
- let h = o;
931
+ const i = this.getData(e.data()), a = Array.isArray(i) ? i.length : 0;
932
+ let l = a;
933
933
  if (typeof e.total == "function") {
934
- const _ = e.total();
935
- if (_ != null && _ !== "") {
936
- const m = Number(_);
937
- Number.isFinite(m) && (h = m);
934
+ const T = e.total();
935
+ if (T != null && T !== "") {
936
+ const _ = Number(T);
937
+ Number.isFinite(_) && (l = _);
938
938
  }
939
939
  }
940
- s === "count" && (h = o);
940
+ s === "count" && (l = a);
941
941
  let A = 1;
942
- n && (A = o), this.progressData || (this.progressData = {});
943
- const l = ((f = this.progressData[r]) == null ? void 0 : f.total) ?? 0, i = ((O = this.progressData[r]) == null ? void 0 : O.count) ?? 0, u = A + i, y = Math.max(l, h ?? 0, u);
944
- if (this.progressData[r] = {
945
- total: y,
946
- count: Math.min(u, y)
942
+ i && (A = a), this.progressData || (this.progressData = {});
943
+ const h = ((f = this.progressData[t]) == null ? void 0 : f.total) ?? 0, n = ((O = this.progressData[t]) == null ? void 0 : O.count) ?? 0, u = A + n, m = Math.max(h, l ?? 0, u);
944
+ if (this.progressData[t] = {
945
+ total: m,
946
+ count: Math.min(u, m)
947
947
  }, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
948
- E(this, it, dt).call(this);
948
+ E(this, it, gt).call(this);
949
949
  return;
950
950
  }
951
- E(this, it, dt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
951
+ E(this, it, gt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
952
952
  if (!this.progressCall) {
953
953
  this.clearProgressData();
954
954
  return;
955
955
  }
956
- E(this, it, dt).call(this);
957
- const { percent: _ } = this.progressPercent;
958
- _ >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
956
+ E(this, it, gt).call(this);
957
+ const { percent: T } = this.progressPercent;
958
+ T >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
959
959
  }, this.progressDelay));
960
960
  }
961
961
  /**
@@ -963,10 +963,10 @@ const j = class j {
963
963
  * @param {Object} data - Ответ от API
964
964
  * @returns {any} Данные из ответа
965
965
  */
966
- getData(r) {
967
- if (r == null)
968
- return r;
969
- let e = (r == null ? void 0 : r.items) ?? (r == null ? void 0 : r.tasks) ?? (r == null ? void 0 : r.types) ?? (r == null ? void 0 : r.type) ?? (r == null ? void 0 : r.fields) ?? (r == null ? void 0 : r.workgroups) ?? r;
966
+ getData(t) {
967
+ if (t == null)
968
+ return t;
969
+ let e = (t == null ? void 0 : t.items) ?? (t == null ? void 0 : t.tasks) ?? (t == null ? void 0 : t.types) ?? (t == null ? void 0 : t.type) ?? (t == null ? void 0 : t.fields) ?? (t == null ? void 0 : t.workgroups) ?? t;
970
970
  return e && typeof e == "object" && !Array.isArray(e) && Array.isArray(e.result) && (e = e.result), e;
971
971
  }
972
972
  /**
@@ -977,8 +977,8 @@ const j = class j {
977
977
  * @param {number|undefined} pauseMs - Длительность текущей лимит-паузы (мс); при снятии лимита не передаётся.
978
978
  * @returns {void}
979
979
  */
980
- setTimeLimitState(r, e, s) {
981
- this.timeLimit.limit = !!r, this.timeLimit.date = r ? e : void 0, r && typeof s == "number" && s > 0 ? this.timeLimit.pauseMs = s : this.timeLimit.pauseMs = void 0, E(this, Tt, Wt).call(this);
980
+ setTimeLimitState(t, e, s) {
981
+ this.timeLimit.limit = !!t, this.timeLimit.date = t ? e : void 0, t && typeof s == "number" && s > 0 ? this.timeLimit.pauseMs = s : this.timeLimit.pauseMs = void 0, E(this, Et, Kt).call(this);
982
982
  }
983
983
  /**
984
984
  * Подписывает внешний код на изменения состояния лимита.
@@ -987,14 +987,14 @@ const j = class j {
987
987
  * @param {(state: {limit: boolean, date?: string, pauseMs?: number}) => void} callback - Обработчик состояния лимита.
988
988
  * @returns {() => void} Функция отписки.
989
989
  */
990
- subscribeTimeLimit(r) {
991
- return typeof r != "function" ? () => {
992
- } : (this.timeLimitListeners.add(r), r({
990
+ subscribeTimeLimit(t) {
991
+ return typeof t != "function" ? () => {
992
+ } : (this.timeLimitListeners.add(t), t({
993
993
  limit: this.timeLimit.limit,
994
994
  date: this.timeLimit.date,
995
995
  pauseMs: this.timeLimit.pauseMs
996
996
  }), () => {
997
- this.timeLimitListeners.delete(r);
997
+ this.timeLimitListeners.delete(t);
998
998
  });
999
999
  }
1000
1000
  /**
@@ -1004,29 +1004,29 @@ const j = class j {
1004
1004
  * @param {Object} request - Объект запроса {method, params}
1005
1005
  * @returns {Array} Массив запросов (может быть один или несколько)
1006
1006
  */
1007
- splitLargeFilters(r, e) {
1008
- const { method: s, params: n } = e;
1009
- if (!n)
1010
- return [{ key: r, request: e }];
1011
- const o = n.filter || n.FILTER;
1012
- if (!o || typeof o != "object" || Array.isArray(o))
1013
- return [{ key: r, request: e }];
1014
- for (const [h, A] of Object.entries(o))
1015
- if (!String(h).trim().startsWith("!") && Array.isArray(A) && A.length > this.filterChunkSize) {
1016
- const l = [];
1017
- for (let i = 0; i < A.length; i += this.filterChunkSize) {
1018
- const u = A.slice(i, i + this.filterChunkSize), y = i === 0 ? r : `${r}__chunk_${Math.floor(i / this.filterChunkSize)}`, c = { ...n };
1019
- n.filter ? (c.filter = { ...o }, c.filter[h] = u) : n.FILTER && (c.FILTER = { ...o }, c.FILTER[h] = u), l.push({
1020
- key: y,
1007
+ splitLargeFilters(t, e) {
1008
+ const { method: s, params: i } = e;
1009
+ if (!i)
1010
+ return [{ key: t, request: e }];
1011
+ const a = i.filter || i.FILTER;
1012
+ if (!a || typeof a != "object" || Array.isArray(a))
1013
+ return [{ key: t, request: e }];
1014
+ for (const [l, A] of Object.entries(a))
1015
+ if (!String(l).trim().startsWith("!") && Array.isArray(A) && A.length > this.filterChunkSize) {
1016
+ const h = [];
1017
+ for (let n = 0; n < A.length; n += this.filterChunkSize) {
1018
+ const u = A.slice(n, n + this.filterChunkSize), m = n === 0 ? t : `${t}__chunk_${Math.floor(n / this.filterChunkSize)}`, c = { ...i };
1019
+ i.filter ? (c.filter = { ...a }, c.filter[l] = u) : i.FILTER && (c.FILTER = { ...a }, c.FILTER[l] = u), h.push({
1020
+ key: m,
1021
1021
  request: { method: s, params: c },
1022
- originalKey: r,
1023
- filterKey: h,
1024
- chunkIndex: Math.floor(i / this.filterChunkSize)
1022
+ originalKey: t,
1023
+ filterKey: l,
1024
+ chunkIndex: Math.floor(n / this.filterChunkSize)
1025
1025
  });
1026
1026
  }
1027
- return l;
1027
+ return h;
1028
1028
  }
1029
- return [{ key: r, request: e }];
1029
+ return [{ key: t, request: e }];
1030
1030
  }
1031
1031
  /**
1032
1032
  * Объединяет результаты разбитых запросов обратно в один результат
@@ -1034,14 +1034,14 @@ const j = class j {
1034
1034
  * @param {string} originalKey - Оригинальный ключ запроса
1035
1035
  * @returns {Array} Объединенный массив результатов
1036
1036
  */
1037
- mergeSplitResults(r, e) {
1038
- const s = [], n = String(e).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = new RegExp(`^${n}(?:__chunk_\\d+)?$`), h = Object.keys(r).filter((A) => o.test(A)).sort((A, l) => {
1039
- const i = A.match(/__chunk_(\d+)$/), u = l.match(/__chunk_(\d+)$/);
1040
- return i ? u ? parseInt(i[1]) - parseInt(u[1]) : 1 : -1;
1037
+ mergeSplitResults(t, e) {
1038
+ const s = [], i = String(e).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), l = Object.keys(t).filter((A) => a.test(A)).sort((A, h) => {
1039
+ const n = A.match(/__chunk_(\d+)$/), u = h.match(/__chunk_(\d+)$/);
1040
+ return n ? u ? parseInt(n[1]) - parseInt(u[1]) : 1 : -1;
1041
1041
  });
1042
- for (const A of h) {
1043
- const l = r[A];
1044
- Array.isArray(l) ? s.push(...l) : l && s.push(l);
1042
+ for (const A of l) {
1043
+ const h = t[A];
1044
+ Array.isArray(h) ? s.push(...h) : h && s.push(h);
1045
1045
  }
1046
1046
  return s;
1047
1047
  }
@@ -1060,26 +1060,26 @@ const j = class j {
1060
1060
  * @param {Function} callback - Callback функция для обработки результата
1061
1061
  * @returns {Promise<void>}
1062
1062
  */
1063
- callBatchWithTimeout(r, e) {
1064
- return new Promise((s, n) => {
1065
- let o = !1, h = null;
1066
- const A = async (i) => {
1067
- if (!o) {
1068
- o = !0, h && clearTimeout(h);
1063
+ callBatchWithTimeout(t, e) {
1064
+ return new Promise((s, i) => {
1065
+ let a = !1, l = null;
1066
+ const A = async (n) => {
1067
+ if (!a) {
1068
+ a = !0, l && clearTimeout(l);
1069
1069
  try {
1070
- await Promise.resolve(e(i)), s();
1070
+ await Promise.resolve(e(n)), s();
1071
1071
  } catch (u) {
1072
- console.error("Error in callBatch callback:", u), n(u);
1072
+ console.error("Error in callBatch callback:", u), i(u);
1073
1073
  }
1074
1074
  }
1075
- }, l = async () => {
1076
- if (!o) {
1077
- o = !0, h && clearTimeout(h), console.warn(
1075
+ }, h = async () => {
1076
+ if (!a) {
1077
+ a = !0, l && clearTimeout(l), console.warn(
1078
1078
  `Batch request timeout after ${this.requestTimeoutMs}ms. This may indicate a CORS or network error.`
1079
1079
  );
1080
- const i = {};
1081
- Object.keys(r).forEach((u) => {
1082
- i[u] = {
1080
+ const n = {};
1081
+ Object.keys(t).forEach((u) => {
1082
+ n[u] = {
1083
1083
  error: () => ({
1084
1084
  ex: {
1085
1085
  error: "TIMEOUT",
@@ -1091,23 +1091,23 @@ const j = class j {
1091
1091
  };
1092
1092
  });
1093
1093
  try {
1094
- await Promise.resolve(e(i)), s();
1094
+ await Promise.resolve(e(n)), s();
1095
1095
  } catch (u) {
1096
1096
  console.error("Error in timeout callback:", u), s();
1097
1097
  }
1098
1098
  }
1099
1099
  };
1100
1100
  try {
1101
- this.callBatch(r, async (i) => {
1102
- await A(i);
1101
+ this.callBatch(t, async (n) => {
1102
+ await A(n);
1103
1103
  });
1104
- } catch (i) {
1105
- o || console.error("Error calling callBatch:", i);
1104
+ } catch (n) {
1105
+ a || console.error("Error calling callBatch:", n);
1106
1106
  }
1107
- h = setTimeout(async () => {
1108
- o || (console.warn(
1107
+ l = setTimeout(async () => {
1108
+ a || (console.warn(
1109
1109
  `Batch request attempt timeout after ${this.requestTimeoutMs}ms. Switching to timeout fallback result.`
1110
- ), await l());
1110
+ ), await h());
1111
1111
  }, this.requestTimeoutMs);
1112
1112
  });
1113
1113
  }
@@ -1129,35 +1129,35 @@ const j = class j {
1129
1129
  * @param {{oneBatch?: boolean}} [options] - Опции выполнения.
1130
1130
  * @returns {Promise<Object>}
1131
1131
  */
1132
- async batch(r, e, s = {}) {
1133
- E(this, ht, kt).call(this, e);
1134
- const n = {}, o = {}, h = {};
1135
- for (const [u, y] of Object.entries(r)) {
1136
- const c = this.arrayChunk(y);
1132
+ async batch(t, e, s = {}) {
1133
+ E(this, lt, Ut).call(this, e);
1134
+ const i = {}, a = {}, l = {};
1135
+ for (const [u, m] of Object.entries(t)) {
1136
+ const c = this.arrayChunk(m);
1137
1137
  if (!c)
1138
1138
  continue;
1139
1139
  const f = this.splitLargeFilters(u, c);
1140
1140
  if (f.length === 1)
1141
- o[u] = c;
1141
+ a[u] = c;
1142
1142
  else {
1143
- h[u] = [];
1143
+ l[u] = [];
1144
1144
  for (const O of f)
1145
- o[O.key] = O.request, h[u].push(O.key);
1145
+ a[O.key] = O.request, l[u].push(O.key);
1146
1146
  }
1147
1147
  }
1148
- this.batchCommandKeyOrder = Object.keys(o), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
1148
+ this.batchCommandKeyOrder = Object.keys(a), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
1149
1149
  (u) => {
1150
- var y;
1151
- return String(((y = o[u]) == null ? void 0 : y.method) || "");
1150
+ var m;
1151
+ return String(((m = a[u]) == null ? void 0 : m.method) || "");
1152
1152
  }
1153
- ), this.chunkRate = (1 / Math.ceil(Object.keys(o).length / this.limit)).toFixed(5);
1154
- let A = {}, l = 0;
1155
- const i = Object.keys(o).length;
1156
- for (const [u, y] of Object.entries(o)) {
1153
+ ), this.chunkRate = (1 / Math.ceil(Object.keys(a).length / this.limit)).toFixed(5);
1154
+ let A = {}, h = 0;
1155
+ const n = Object.keys(a).length;
1156
+ for (const [u, m] of Object.entries(a)) {
1157
1157
  if (!this.canContinue)
1158
1158
  break;
1159
- if (A[u] = y, Object.keys(A).length >= this.limit || l + 1 === i) {
1160
- const c = l + 1 === i;
1159
+ if (A[u] = m, Object.keys(A).length >= this.limit || h + 1 === n) {
1160
+ const c = h + 1 === n;
1161
1161
  await this.batchChunk(
1162
1162
  A,
1163
1163
  void 0,
@@ -1167,21 +1167,21 @@ const j = class j {
1167
1167
  oneBatch: !!(s != null && s.oneBatch)
1168
1168
  }
1169
1169
  ), Object.entries(this.result).forEach(([f, O]) => {
1170
- n[f] = O;
1170
+ i[f] = O;
1171
1171
  }), this.totalProgress = Math.round(
1172
- l / i * 100
1172
+ h / n * 100
1173
1173
  ), A = {};
1174
1174
  }
1175
- l++;
1175
+ h++;
1176
1176
  }
1177
- for (const [u, y] of Object.entries(h))
1178
- if (y && y.length > 0) {
1179
- const c = this.mergeSplitResults(n, u);
1180
- for (const f of y)
1181
- delete n[f];
1182
- n[u] = c;
1177
+ for (const [u, m] of Object.entries(l))
1178
+ if (m && m.length > 0) {
1179
+ const c = this.mergeSplitResults(i, u);
1180
+ for (const f of m)
1181
+ delete i[f];
1182
+ i[u] = c;
1183
1183
  }
1184
- return Object.entries(this.errors).length && (n.errorsList = this.errors), e && e({ percent: 100 }), Promise.resolve(n);
1184
+ return Object.entries(this.errors).length && (i.errorsList = this.errors), e && e({ percent: 100 }), Promise.resolve(i);
1185
1185
  }
1186
1186
  /**
1187
1187
  * Выполняет батч-запрос и возвращает только количество элементов для каждой команды.
@@ -1192,60 +1192,60 @@ const j = class j {
1192
1192
  * @param {Function} progressCall - Callback для отслеживания прогресса
1193
1193
  * @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
1194
1194
  */
1195
- async batchTotalCount(r, e) {
1196
- E(this, ht, kt).call(this, e);
1197
- const s = {}, n = {}, o = {};
1198
- for (const [l, i] of Object.entries(r)) {
1199
- const u = this.arrayChunk(i);
1195
+ async batchTotalCount(t, e) {
1196
+ E(this, lt, Ut).call(this, e);
1197
+ const s = {}, i = {}, a = {};
1198
+ for (const [h, n] of Object.entries(t)) {
1199
+ const u = this.arrayChunk(n);
1200
1200
  if (!u)
1201
1201
  continue;
1202
- const y = this.splitLargeFilters(l, u);
1203
- if (y.length === 1)
1204
- n[l] = u;
1202
+ const m = this.splitLargeFilters(h, u);
1203
+ if (m.length === 1)
1204
+ i[h] = u;
1205
1205
  else {
1206
- o[l] = [];
1207
- for (const c of y)
1208
- n[c.key] = c.request, o[l].push(c.key);
1206
+ a[h] = [];
1207
+ for (const c of m)
1208
+ i[c.key] = c.request, a[h].push(c.key);
1209
1209
  }
1210
1210
  }
1211
- const h = [], A = Object.entries(n);
1212
- for (let l = 0; l < A.length; l += this.limit) {
1213
- const i = A.slice(l, l + this.limit), u = {};
1214
- for (const [y, c] of i) {
1211
+ const l = [], A = Object.entries(i);
1212
+ for (let h = 0; h < A.length; h += this.limit) {
1213
+ const n = A.slice(h, h + this.limit), u = {};
1214
+ for (const [m, c] of n) {
1215
1215
  if (!this.canContinue)
1216
1216
  break;
1217
- u[y] = c;
1217
+ u[m] = c;
1218
1218
  }
1219
- Object.keys(u).length > 0 && h.push(u);
1219
+ Object.keys(u).length > 0 && l.push(u);
1220
1220
  }
1221
- this.chunkRate = (1 / h.length).toFixed(5);
1222
- for (const [l, i] of Object.entries(h)) {
1221
+ this.chunkRate = (1 / l.length).toFixed(5);
1222
+ for (const [h, n] of Object.entries(l)) {
1223
1223
  if (!this.canContinue)
1224
1224
  break;
1225
- this.totalProgress = Math.round(Number(l) / h.length * 100);
1226
- const u = Number(l) === h.length - 1;
1227
- await E(this, V, At).call(this, i, async (y) => {
1228
- var c, f, O, _, m;
1229
- for (const [N, p] of Object.entries(y)) {
1225
+ this.totalProgress = Math.round(Number(h) / l.length * 100);
1226
+ const u = Number(h) === l.length - 1;
1227
+ await E(this, V, At).call(this, n, async (m) => {
1228
+ var c, f, O, T, _;
1229
+ for (const [R, N] of Object.entries(m)) {
1230
1230
  if (!this.canContinue)
1231
1231
  return;
1232
- if (p.error()) {
1233
- const M = (f = (c = p.error()) == null ? void 0 : c.ex) == null ? void 0 : f.error, H = (_ = (O = p.error()) == null ? void 0 : O.ex) == null ? void 0 : _.error_description;
1234
- this.errors[N] = M && M.trim() || H && H.trim() || ((m = p.error()) == null ? void 0 : m.toString()) || "Неизвестная ошибка", s[N] = 0;
1232
+ if (N.error()) {
1233
+ const k = (f = (c = N.error()) == null ? void 0 : c.ex) == null ? void 0 : f.error, U = (T = (O = N.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
1234
+ this.errors[R] = k && k.trim() || U && U.trim() || ((_ = N.error()) == null ? void 0 : _.toString()) || "Неизвестная ошибка", s[R] = 0;
1235
1235
  continue;
1236
1236
  }
1237
- const T = this.getData(p.data()), k = Array.isArray(T) ? T.length : 0, U = typeof p.total == "function" && p.total() !== void 0 ? p.total() : k;
1238
- s[N] = U, this.setProgressData({ key: N, value: p, type: "count" });
1237
+ const y = this.getData(N.data()), L = Array.isArray(y) ? y.length : 0, H = typeof N.total == "function" && N.total() !== void 0 ? N.total() : L;
1238
+ s[R] = H, this.setProgressData({ key: R, value: N, type: "count" });
1239
1239
  }
1240
- await E(this, Z, ot).call(this, y, !u);
1240
+ await E(this, Z, at).call(this, m, !u);
1241
1241
  });
1242
1242
  }
1243
- for (const [l, i] of Object.entries(o))
1244
- if (i && i.length > 0) {
1243
+ for (const [h, n] of Object.entries(a))
1244
+ if (n && n.length > 0) {
1245
1245
  let u = 0;
1246
- for (const y of i)
1247
- s[y] !== void 0 && (u += s[y] || 0), delete s[y];
1248
- s[l] = u;
1246
+ for (const m of n)
1247
+ s[m] !== void 0 && (u += s[m] || 0), delete s[m];
1248
+ s[h] = u;
1249
1249
  }
1250
1250
  return Object.entries(this.errors).length && (s.errorsList = this.errors, this.errorLogger()), e && e({ percent: 100 }), Promise.resolve(s);
1251
1251
  }
@@ -1256,29 +1256,29 @@ const j = class j {
1256
1256
  * @param {{method: string, params?: Object}} request - Описание REST-вызова.
1257
1257
  * @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
1258
1258
  */
1259
- async call({ method: r, params: e = {} }) {
1260
- var s, n, o, h, A, l, i;
1259
+ async call({ method: t, params: e = {} }) {
1260
+ var s, i, a, l, A, h, n;
1261
1261
  for (; ; ) {
1262
- const u = await E(this, Et, xt).call(this, r, e);
1262
+ const u = await E(this, Lt, vt).call(this, t, e);
1263
1263
  if (!u) {
1264
- await E(this, q, st).call(this, this.callLimitPauseMs);
1264
+ await E(this, Q, st).call(this, this.callLimitPauseMs);
1265
1265
  continue;
1266
1266
  }
1267
- const y = {};
1267
+ const m = {};
1268
1268
  if (u != null && u.answer)
1269
1269
  for (const [f, O] of Object.entries(u.answer))
1270
- f !== "result" && O && (y[f] = O);
1270
+ f !== "result" && O && (m[f] = O);
1271
1271
  if (u.error()) {
1272
- const f = ((n = (s = u.error()) == null ? void 0 : s.ex) == null ? void 0 : n.error) ?? "";
1272
+ const f = ((i = (s = u.error()) == null ? void 0 : s.ex) == null ? void 0 : i.error) ?? "";
1273
1273
  if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(f)) {
1274
- await E(this, q, st).call(this, this.callLimitPauseMs);
1274
+ await E(this, Q, st).call(this, this.callLimitPauseMs);
1275
1275
  continue;
1276
1276
  }
1277
- const O = ((o = u.error()) == null ? void 0 : o.toString()) || ((A = (h = u.error()) == null ? void 0 : h.ex) == null ? void 0 : A.error_description) || ((i = (l = u.error()) == null ? void 0 : l.ex) == null ? void 0 : i.error) || "Неизвестная ошибка";
1277
+ const O = ((a = u.error()) == null ? void 0 : a.toString()) || ((A = (l = u.error()) == null ? void 0 : l.ex) == null ? void 0 : A.error_description) || ((n = (h = u.error()) == null ? void 0 : h.ex) == null ? void 0 : n.error) || "Неизвестная ошибка";
1278
1278
  return {
1279
1279
  success: !1,
1280
1280
  data: !1,
1281
- answer: y,
1281
+ answer: m,
1282
1282
  error: O
1283
1283
  };
1284
1284
  }
@@ -1286,7 +1286,7 @@ const j = class j {
1286
1286
  return c != null && c.items && (c = c.items), {
1287
1287
  success: !0,
1288
1288
  data: c,
1289
- answer: y,
1289
+ answer: m,
1290
1290
  error: null
1291
1291
  };
1292
1292
  }
@@ -1296,18 +1296,18 @@ const j = class j {
1296
1296
  * Так же переделываем некоторые запросы в нужный вид (Для task-методов)
1297
1297
  * @param {Array/Object} request - Массив/объект методов
1298
1298
  */
1299
- arrayChunk(r) {
1299
+ arrayChunk(t) {
1300
1300
  let e = "", s = {};
1301
- if (Array.isArray(r) ? [e] = r : (e = r.method, s = r.params), (e.includes("list") || e === "user.get" || e === "entity.item.get") && e !== "task.item.list") {
1301
+ if (Array.isArray(t) ? [e] = t : (e = t.method, s = t.params), (e.includes("list") || e === "user.get" || e === "entity.item.get") && e !== "task.item.list") {
1302
1302
  if (!s)
1303
1303
  s = e === "entity.item.get" ? { SORT: { ID: "ASC" } } : {
1304
1304
  order: { ID: "ASC", id: "ASC" }
1305
1305
  };
1306
1306
  else {
1307
1307
  e === "entity.item.get" ? (s.SORT || (s.SORT = { ID: "ASC" }), Array.isArray(s.select) ? s.select.includes("ID") || s.select.push("ID") : s.select = ["ID"]) : e === "tasks.task.list" ? (s.order || (s.order = {}), s.order.ID = "asc") : e === "user.get" ? (s.sort || (s.sort = "ID"), s.order || (s.order = "ASC")) : s.order = { ID: "ASC", id: "ASC" }, Array.isArray(s.select) && !s.select.includes("ID") && s.select.push("ID");
1308
- const n = e === "user.get" || e === "entity.item.get" ? s.FILTER : s.filter;
1309
- typeof n == "object" && n !== null && !Array.isArray(n) && Object.entries(n).forEach(([o, h]) => {
1310
- (s.start === void 0 || s.start !== -1) && ["id", "ID"].includes(o) && (typeof h == "string" || Array.isArray(h) && h.length <= 50) && (s.start = -1);
1308
+ const i = e === "user.get" || e === "entity.item.get" ? s.FILTER : s.filter;
1309
+ typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a, l]) => {
1310
+ (s.start === void 0 || s.start !== -1) && ["id", "ID"].includes(a) && (typeof l == "string" || Array.isArray(l) && l.length <= 50) && (s.start = -1);
1311
1311
  });
1312
1312
  }
1313
1313
  e === "crm.type.list" && s.order && delete s.order.ID;
@@ -1317,8 +1317,8 @@ const j = class j {
1317
1317
  s = [{ ID: "ASC" }, [""], [""], ["ID"]];
1318
1318
  else {
1319
1319
  Array.isArray(s[0]) && (s[0] = {});
1320
- const [n, o, h, A] = s;
1321
- n.ID = "ASC", A[0] !== "" && A.includes("ID") || A.push("ID");
1320
+ const [i, a, l, A] = s;
1321
+ i.ID = "ASC", A[0] !== "" && A.includes("ID") || A.push("ID");
1322
1322
  }
1323
1323
  return { method: e, params: s };
1324
1324
  }
@@ -1328,46 +1328,46 @@ const j = class j {
1328
1328
  * @param {Array} query - Тот же массив с методами
1329
1329
  * @returns {Object} Объект с результатами запросов
1330
1330
  */
1331
- async batchChunk(r, e, s = !0, n = {}) {
1332
- return new Promise((o) => {
1333
- const h = [];
1331
+ async batchChunk(t, e, s = !0, i = {}) {
1332
+ return new Promise((a) => {
1333
+ const l = [];
1334
1334
  let A;
1335
- const l = !!(n != null && n.disablePagination);
1335
+ const h = !!(i != null && i.disablePagination);
1336
1336
  (async () => {
1337
- await E(this, V, At).call(this, r, async (u) => {
1338
- var c, f, O, _, m;
1339
- for (const [N, p] of Object.entries(u)) {
1337
+ await E(this, V, At).call(this, t, async (u) => {
1338
+ var c, f, O, T, _;
1339
+ for (const [R, N] of Object.entries(u)) {
1340
1340
  if (!this.canContinue)
1341
1341
  return;
1342
- if (p.error()) {
1343
- const g = (f = (c = p.error()) == null ? void 0 : c.ex) == null ? void 0 : f.error, D = (_ = (O = p.error()) == null ? void 0 : O.ex) == null ? void 0 : _.error_description;
1344
- this.errors[N] = g && g.trim() || D && D.trim() || ((m = p.error()) == null ? void 0 : m.toString()) || "Неизвестная ошибка", A = !0;
1342
+ if (N.error()) {
1343
+ const g = (f = (c = N.error()) == null ? void 0 : c.ex) == null ? void 0 : f.error, w = (T = (O = N.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
1344
+ this.errors[R] = g && g.trim() || w && w.trim() || ((_ = N.error()) == null ? void 0 : _.toString()) || "Неизвестная ошибка", A = !0;
1345
1345
  }
1346
- const T = this.getData(p.data()), k = Array.isArray(T) ? T.length : 0, C = typeof p.total == "function" && p.total() !== void 0, U = C ? p.total() : k;
1347
- e === "count" ? this.result[N] ? this.result[N] += k : this.result[N] = U : this.result[N] = T, this.setProgressData({ key: N, value: p, type: e });
1348
- const M = r[N], H = Array.isArray(M) ? M[0] : M == null ? void 0 : M.method, b = typeof H == "string" && (H.includes(".list") || H === "user.get" || H === "entity.item.get"), t = e === "count" ? !C && k === this.limit : b ? k === this.limit : U > this.limit && U > k, a = e !== "count" && H === "entity.item.get" && k === this.limit && !t, d = t || a;
1349
- if (!l && (!this.canContinue || d)) {
1350
- let g = r[N];
1346
+ const y = this.getData(N.data()), L = Array.isArray(y) ? y.length : 0, I = typeof N.total == "function" && N.total() !== void 0, H = I ? N.total() : L;
1347
+ e === "count" ? this.result[R] ? this.result[R] += L : this.result[R] = H : this.result[R] = y, this.setProgressData({ key: R, value: N, type: e });
1348
+ const k = t[R], U = Array.isArray(k) ? k[0] : k == null ? void 0 : k.method, M = typeof U == "string" && (U.includes(".list") || U === "user.get" || U === "entity.item.get"), r = e === "count" ? !I && L === this.limit : M ? L === this.limit : H > this.limit && H > L, o = e !== "count" && U === "entity.item.get" && L === this.limit && !r, d = r || o;
1349
+ if (!h && (!this.canContinue || d)) {
1350
+ let g = t[R];
1351
1351
  if (Array.isArray(g)) {
1352
- const [D, L = {}] = g;
1353
- g = [D, L];
1352
+ const [w, b = {}] = g;
1353
+ g = [w, b];
1354
1354
  } else {
1355
- const { method: D, params: L = {} } = g;
1356
- g = [D, L];
1355
+ const { method: w, params: b = {} } = g;
1356
+ g = [w, b];
1357
1357
  }
1358
- h.push([
1359
- N,
1358
+ l.push([
1359
+ R,
1360
1360
  g,
1361
- U,
1362
- { entityItemGetScan: a }
1361
+ H,
1362
+ { entityItemGetScan: o }
1363
1363
  ]);
1364
1364
  }
1365
1365
  }
1366
1366
  A > 0 && this.errorLogger();
1367
- const y = h.length > 0 || s;
1368
- await E(this, Z, ot).call(this, u, y), h.length ? await this.batchPayload(h, e, n).then(
1369
- () => o(this.result)
1370
- ) : o(this.result);
1367
+ const m = l.length > 0 || s;
1368
+ await E(this, Z, at).call(this, u, m), l.length ? await this.batchPayload(l, e, i).then(
1369
+ () => a(this.result)
1370
+ ) : a(this.result);
1371
1371
  });
1372
1372
  })();
1373
1373
  });
@@ -1377,97 +1377,97 @@ const j = class j {
1377
1377
  * @param {String} type - Тип обработки результатов ('count' или undefined)
1378
1378
  * @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
1379
1379
  */
1380
- async batchPayload(r, e, s = {}) {
1381
- const n = !!(s != null && s.oneBatch), o = (O, _, m, N) => {
1382
- let p = "ID";
1383
- this.result[O][this.result[O].length - 1].ID || (p = "id");
1384
- let T = `${p}`;
1385
- if (JSON.stringify(N[1]).toLocaleLowerCase().includes('"id":"desc"') ? T = "<" + T : T = ">" + T, _ === 1 || m.length === 0)
1380
+ async batchPayload(t, e, s = {}) {
1381
+ const i = !!(s != null && s.oneBatch), a = (O, T, _, R) => {
1382
+ let N = "ID";
1383
+ this.result[O][this.result[O].length - 1].ID || (N = "id");
1384
+ let y = `${N}`;
1385
+ if (JSON.stringify(R[1]).toLocaleLowerCase().includes('"id":"desc"') ? y = "<" + y : y = ">" + y, T === 1 || _.length === 0)
1386
1386
  return {
1387
- field: T,
1388
- id: this.result[O][this.result[O].length - 1][p]
1387
+ field: y,
1388
+ id: this.result[O][this.result[O].length - 1][N]
1389
1389
  };
1390
- let C = "";
1391
- const [U, M] = N;
1392
- return (U === "tasks.task.list" || U === "task.item.list") && (C = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(U) && (C = "[items]"), U === "crm.type.list" && (C = "[types]"), U === "socialnetwork.api.workgroup.list" && (C = "[workgroups]"), {
1393
- field: T,
1394
- id: `$result[${[O, _ - 1].join("__")}]${C}[49][${p}]`
1390
+ let I = "";
1391
+ const [H, k] = R;
1392
+ return (H === "tasks.task.list" || H === "task.item.list") && (I = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(H) && (I = "[items]"), H === "crm.type.list" && (I = "[types]"), H === "socialnetwork.api.workgroup.list" && (I = "[workgroups]"), {
1393
+ field: y,
1394
+ id: `$result[${[O, T - 1].join("__")}]${I}[49][${N}]`
1395
1395
  };
1396
- }, h = (O, _) => {
1397
- const [m, N] = O;
1398
- let p = JSON.parse(JSON.stringify(N)), T;
1399
- if (m === "task.item.list") {
1400
- p = [...p];
1401
- const [k, C, U, M] = p;
1402
- return C[_.field] = _.id, [m, p];
1396
+ }, l = (O, T) => {
1397
+ const [_, R] = O;
1398
+ let N = JSON.parse(JSON.stringify(R)), y;
1399
+ if (_ === "task.item.list") {
1400
+ N = [...N];
1401
+ const [L, I, H, k] = N;
1402
+ return I[T.field] = T.id, [_, N];
1403
1403
  }
1404
- return ["user.get"].includes(m) || p.FILTER ? (p.FILTER || (p.FILTER = {}), T = p.FILTER) : (p.filter || (p.filter = {}), T = p.filter), [
1404
+ return ["user.get"].includes(_) || N.FILTER ? (N.FILTER || (N.FILTER = {}), y = N.FILTER) : (N.filter || (N.filter = {}), y = N.filter), [
1405
1405
  "socialnetwork.api.workgroup.list",
1406
1406
  "tasks.task.list"
1407
- ].includes(m) ? T[">ID"] = _.id : T[_.field] = _.id, [m, { ...p, start: -1 }];
1407
+ ].includes(_) ? y[">ID"] = T.id : y[T.field] = T.id, [_, { ...N, start: -1 }];
1408
1408
  }, A = (O) => {
1409
- Object.entries(O).forEach(([_, m]) => {
1410
- var T, k, C, U, M;
1411
- const [N] = _.split("__"), p = this.getData(m.data());
1412
- if (Array.isArray(p) && (e === "count" ? this.result[N] += p.length : this.result[N].push(...p)), m.error()) {
1413
- const H = (k = (T = m.error()) == null ? void 0 : T.ex) == null ? void 0 : k.error, b = (U = (C = m.error()) == null ? void 0 : C.ex) == null ? void 0 : U.error_description;
1414
- this.errors[N] = H && H.trim() || b && b.trim() || ((M = m.error()) == null ? void 0 : M.toString()) || "Неизвестная ошибка";
1409
+ Object.entries(O).forEach(([T, _]) => {
1410
+ var y, L, I, H, k;
1411
+ const [R] = T.split("__"), N = this.getData(_.data());
1412
+ if (Array.isArray(N) && (e === "count" ? this.result[R] += N.length : this.result[R].push(...N)), _.error()) {
1413
+ const U = (L = (y = _.error()) == null ? void 0 : y.ex) == null ? void 0 : L.error, M = (H = (I = _.error()) == null ? void 0 : I.ex) == null ? void 0 : H.error_description;
1414
+ this.errors[R] = U && U.trim() || M && M.trim() || ((k = _.error()) == null ? void 0 : k.toString()) || "Неизвестная ошибка";
1415
1415
  }
1416
- this.setProgressData({ key: N, value: m, type: e });
1416
+ this.setProgressData({ key: R, value: _, type: e });
1417
1417
  });
1418
- }, l = (O, _) => {
1418
+ }, h = (O, T) => {
1419
1419
  if (!Array.isArray(O) || O.length === 0)
1420
1420
  return null;
1421
- const m = O[O.length - 1];
1422
- let N = "ID";
1423
- m.ID || (N = "id");
1424
- let p = N;
1425
- return JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? p = "<" + p : p = ">" + p, { field: p, id: m[N] };
1426
- }, i = 1e4, u = async (O, _) => {
1427
- var N, p;
1428
- let m = this.limit;
1429
- for (let T = 1; this.canContinue && m === this.limit && T <= i; T++) {
1430
- const k = this.result[O], C = l(k, _);
1431
- if (!C)
1421
+ const _ = O[O.length - 1];
1422
+ let R = "ID";
1423
+ _.ID || (R = "id");
1424
+ let N = R;
1425
+ return JSON.stringify(T[1]).toLocaleLowerCase().includes('"id":"desc"') ? N = "<" + N : N = ">" + N, { field: N, id: _[R] };
1426
+ }, n = 1e4, u = async (O, T) => {
1427
+ var R, N;
1428
+ let _ = this.limit;
1429
+ for (let y = 1; this.canContinue && _ === this.limit && y <= n; y++) {
1430
+ const L = this.result[O], I = h(L, T);
1431
+ if (!I)
1432
1432
  break;
1433
- const U = `${O}__eiscan_${T}`, M = h(_, C);
1434
- let H = null;
1435
- await E(this, V, At).call(this, { [U]: M }, async (d) => {
1436
- H = d, A(d);
1433
+ const H = `${O}__eiscan_${y}`, k = l(T, I);
1434
+ let U = null;
1435
+ await E(this, V, At).call(this, { [H]: k }, async (d) => {
1436
+ U = d, A(d);
1437
1437
  });
1438
- const b = T < i;
1439
- await E(this, Z, ot).call(this, H, b), await this.delay();
1440
- const t = H == null ? void 0 : H[U];
1441
- if ((N = t == null ? void 0 : t.error) != null && N.call(t)) {
1442
- m = 0;
1438
+ const M = y < n;
1439
+ await E(this, Z, at).call(this, U, M), await this.delay();
1440
+ const r = U == null ? void 0 : U[H];
1441
+ if ((R = r == null ? void 0 : r.error) != null && R.call(r)) {
1442
+ _ = 0;
1443
1443
  break;
1444
1444
  }
1445
- const a = this.getData((p = t == null ? void 0 : t.data) == null ? void 0 : p.call(t));
1446
- m = Array.isArray(a) ? a.length : 0;
1445
+ const o = this.getData((N = r == null ? void 0 : r.data) == null ? void 0 : N.call(r));
1446
+ _ = Array.isArray(o) ? o.length : 0;
1447
1447
  }
1448
1448
  };
1449
- let y = [], c = 0;
1450
- const f = async (O = !0) => y.length ? (await E(this, V, At).call(this, Object.fromEntries(y), async (_) => {
1451
- A(_), await E(this, Z, ot).call(this, _, O);
1452
- }), c++, y = [], n && c >= 1 ? !0 : (await this.delay(), !1)) : !1;
1453
- for await (const O of r) {
1449
+ let m = [], c = 0;
1450
+ const f = async (O = !0) => m.length ? (await E(this, V, At).call(this, Object.fromEntries(m), async (T) => {
1451
+ A(T), await E(this, Z, at).call(this, T, O);
1452
+ }), c++, m = [], i && c >= 1 ? !0 : (await this.delay(), !1)) : !1;
1453
+ for await (const O of t) {
1454
1454
  if (!this.canContinue)
1455
1455
  return;
1456
- const [_, m, N, p = {}] = O;
1457
- if (p.entityItemGetScan) {
1456
+ const [T, _, R, N = {}] = O;
1457
+ if (N.entityItemGetScan) {
1458
1458
  if (await f(!0))
1459
1459
  return;
1460
- if (n)
1460
+ if (i)
1461
1461
  continue;
1462
- await u(_, m);
1462
+ await u(T, _);
1463
1463
  continue;
1464
1464
  }
1465
- let T = 1;
1466
- for (; N > T * this.limit; ) {
1467
- const k = [_, T].join("__"), C = o(_, T, y, m);
1468
- if (y.push([k, h(m, C)]), n && y.length === 49 && await f(!0) || y.length % 50 === 0 && await f(!0))
1465
+ let y = 1;
1466
+ for (; R > y * this.limit; ) {
1467
+ const L = [T, y].join("__"), I = a(T, y, m, _);
1468
+ if (m.push([L, l(_, I)]), i && m.length === 49 && await f(!0) || m.length % 50 === 0 && await f(!0))
1469
1469
  return;
1470
- T++;
1470
+ y++;
1471
1471
  }
1472
1472
  }
1473
1473
  await f(!1);
@@ -1476,127 +1476,127 @@ const j = class j {
1476
1476
  * Вывод ошибок в консоль в группированном виде
1477
1477
  */
1478
1478
  errorLogger() {
1479
- console.group(`${this.constructor.name}: Ошибки в методах!`), Object.entries(this.errors).forEach(([r, e]) => {
1480
- e && console.log(`[${r}]`, e.toString());
1479
+ console.group(`${this.constructor.name}: Ошибки в методах!`), Object.entries(this.errors).forEach(([t, e]) => {
1480
+ e && console.log(`[${t}]`, e.toString());
1481
1481
  }), console.groupEnd();
1482
1482
  }
1483
1483
  };
1484
- gt = new WeakSet(), Yt = function() {
1485
- const r = this.totalBatchCommands || 0, e = this.batchCommandMethods;
1486
- if (r < R(j, yt) || !Array.isArray(e) || e.length !== r)
1484
+ yt = new WeakSet(), Jt = function() {
1485
+ const t = this.totalBatchCommands || 0, e = this.batchCommandMethods;
1486
+ if (t < S(j, pt) || !Array.isArray(e) || e.length !== t)
1487
1487
  return !1;
1488
- if (e.filter((o) => o === "crm.deal.list").length >= R(j, pt))
1488
+ if (e.filter((a) => a === "crm.deal.list").length >= S(j, Nt))
1489
1489
  return !0;
1490
- const n = e.filter(
1491
- (o) => typeof o == "string" && o.includes(".list")
1490
+ const i = e.filter(
1491
+ (a) => typeof a == "string" && a.includes(".list")
1492
1492
  ).length;
1493
- return n >= R(j, Nt) && n / r >= R(j, Ot);
1494
- }, yt = new WeakMap(), pt = new WeakMap(), Nt = new WeakMap(), Ot = new WeakMap(), it = new WeakSet(), dt = function() {
1493
+ return i >= S(j, Ot) && i / t >= S(j, _t);
1494
+ }, pt = new WeakMap(), Nt = new WeakMap(), Ot = new WeakMap(), _t = new WeakMap(), it = new WeakSet(), gt = function() {
1495
1495
  if (!this.progressCall || !this.progressData)
1496
1496
  return;
1497
- const { percent: r, allCount: e, allTotal: s } = this.progressPercent, n = { percent: r, allCount: e, allTotal: s };
1498
- E(this, _t, Gt).call(this, n) && (this.progressCall({
1497
+ const { percent: t, allCount: e, allTotal: s } = this.progressPercent, i = { percent: t, allCount: e, allTotal: s };
1498
+ E(this, Tt, jt).call(this, i) && (this.progressCall({
1499
1499
  data: this.progressData,
1500
- percent: r,
1500
+ percent: t,
1501
1501
  allCount: e,
1502
1502
  allTotal: s
1503
- }), this.lastProgressSnapshot = n);
1504
- }, _t = new WeakSet(), Gt = function(r) {
1505
- return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== r.percent || this.lastProgressSnapshot.allCount !== r.allCount || this.lastProgressSnapshot.allTotal !== r.allTotal : !0;
1506
- }, Tt = new WeakSet(), Wt = function() {
1507
- const r = {
1503
+ }), this.lastProgressSnapshot = i);
1504
+ }, Tt = new WeakSet(), jt = function(t) {
1505
+ return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== t.percent || this.lastProgressSnapshot.allCount !== t.allCount || this.lastProgressSnapshot.allTotal !== t.allTotal : !0;
1506
+ }, Et = new WeakSet(), Kt = function() {
1507
+ const t = {
1508
1508
  limit: this.timeLimit.limit,
1509
1509
  date: this.timeLimit.date,
1510
1510
  pauseMs: this.timeLimit.pauseMs
1511
1511
  };
1512
1512
  for (const e of this.timeLimitListeners)
1513
1513
  try {
1514
- e(r);
1514
+ e(t);
1515
1515
  } catch (s) {
1516
1516
  console.warn("Batch timeLimit listener error:", s);
1517
1517
  }
1518
- }, q = new WeakSet(), st = async function(r = this.defaultPauseMs) {
1519
- this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), r), await new Promise((e) => setTimeout(e, r)), this.setTimeLimitState(!1, void 0);
1520
- }, Z = new WeakSet(), ot = async function(r, e = !0) {
1518
+ }, Q = new WeakSet(), st = async function(t = this.defaultPauseMs) {
1519
+ this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), t), await new Promise((e) => setTimeout(e, t)), this.setTimeLimitState(!1, void 0);
1520
+ }, Z = new WeakSet(), at = async function(t, e = !0) {
1521
1521
  if (!e)
1522
1522
  return 0;
1523
1523
  let s = 0;
1524
- if (!r || typeof r != "object")
1524
+ if (!t || typeof t != "object")
1525
1525
  return 0;
1526
- for (const n of Object.values(r))
1527
- if (!(!n || typeof n != "object"))
1526
+ for (const i of Object.values(t))
1527
+ if (!(!i || typeof i != "object"))
1528
1528
  try {
1529
- if (typeof n.time == "function") {
1530
- const o = n.time();
1531
- o && typeof o.operating == "number" && (s = Math.max(s, o.operating));
1529
+ if (typeof i.time == "function") {
1530
+ const a = i.time();
1531
+ a && typeof a.operating == "number" && (s = Math.max(s, a.operating));
1532
1532
  }
1533
1533
  } catch {
1534
1534
  }
1535
- s >= this.operatingThreshold && await E(this, q, st).call(this);
1536
- }, V = new WeakSet(), At = async function(r, e) {
1537
- let s = !1, n = r;
1535
+ s >= this.operatingThreshold && await E(this, Q, st).call(this);
1536
+ }, V = new WeakSet(), At = async function(t, e) {
1537
+ let s = !1, i = t;
1538
1538
  do
1539
- s = !1, await this.callBatchWithTimeout(n, async (o) => {
1540
- var l, i;
1541
- let h = !1;
1539
+ s = !1, await this.callBatchWithTimeout(i, async (a) => {
1540
+ var h, n;
1541
+ let l = !1;
1542
1542
  const A = /* @__PURE__ */ new Set();
1543
- for (const [u, y] of Object.entries(o || {})) {
1544
- if (!(y != null && y.error) || !y.error())
1543
+ for (const [u, m] of Object.entries(a || {})) {
1544
+ if (!(m != null && m.error) || !m.error())
1545
1545
  continue;
1546
- const c = ((i = (l = y.error()) == null ? void 0 : l.ex) == null ? void 0 : i.error) ?? "";
1546
+ const c = ((n = (h = m.error()) == null ? void 0 : h.ex) == null ? void 0 : n.error) ?? "";
1547
1547
  if (c === "TIMEOUT") {
1548
- h = !0;
1548
+ l = !0;
1549
1549
  break;
1550
1550
  }
1551
1551
  ["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(c) && A.add(u);
1552
1552
  }
1553
- if (h) {
1554
- s = !0, await E(this, q, st).call(this);
1553
+ if (l) {
1554
+ s = !0, await E(this, Q, st).call(this);
1555
1555
  return;
1556
1556
  }
1557
1557
  if (A.size > 0) {
1558
1558
  const u = {};
1559
- for (const [c, f] of Object.entries(o || {}))
1559
+ for (const [c, f] of Object.entries(a || {}))
1560
1560
  A.has(c) || (u[c] = f);
1561
1561
  Object.keys(u).length && await e(u);
1562
- const y = {};
1562
+ const m = {};
1563
1563
  for (const c of A)
1564
- n[c] && (y[c] = n[c]);
1565
- n = y, Object.keys(n).length && (s = !0, await E(this, q, st).call(this));
1564
+ i[c] && (m[c] = i[c]);
1565
+ i = m, Object.keys(i).length && (s = !0, await E(this, Q, st).call(this));
1566
1566
  return;
1567
1567
  }
1568
- await e(o);
1568
+ await e(a);
1569
1569
  });
1570
1570
  while (s);
1571
- }, Et = new WeakSet(), xt = function(r, e) {
1571
+ }, Lt = new WeakSet(), vt = function(t, e) {
1572
1572
  return new Promise((s) => {
1573
1573
  if (typeof this.callMethod != "function") {
1574
1574
  s(null);
1575
1575
  return;
1576
1576
  }
1577
- let n = !1;
1578
- const o = setTimeout(() => {
1579
- n || (n = !0, s(null));
1577
+ let i = !1;
1578
+ const a = setTimeout(() => {
1579
+ i || (i = !0, s(null));
1580
1580
  }, this.requestTimeoutMs);
1581
1581
  try {
1582
- this.callMethod(r, e, (h) => {
1583
- n || (n = !0, clearTimeout(o), s(h));
1582
+ this.callMethod(t, e, (l) => {
1583
+ i || (i = !0, clearTimeout(a), s(l));
1584
1584
  });
1585
1585
  } catch {
1586
- n || (n = !0, clearTimeout(o), s(null));
1586
+ i || (i = !0, clearTimeout(a), s(null));
1587
1587
  }
1588
1588
  });
1589
- }, ht = new WeakSet(), kt = function(r) {
1590
- this.clearProgressData(), this.progressCall = typeof r == "function" ? r : "", this.canContinue = !0, this.result = {}, this.errors = {}, this.chunkRate = 1, this.totalProgress = 0, this.batchCommandKeyOrder = [], this.totalBatchCommands = 0, this.batchCommandMethods = [], this.setTimeLimitState(!1, void 0);
1589
+ }, lt = new WeakSet(), Ut = function(t) {
1590
+ this.clearProgressData(), this.progressCall = typeof t == "function" ? t : "", this.canContinue = !0, this.result = {}, this.errors = {}, this.chunkRate = 1, this.totalProgress = 0, this.batchCommandKeyOrder = [], this.totalBatchCommands = 0, this.batchCommandMethods = [], this.setTimeLimitState(!1, void 0);
1591
1591
  }, /** Не включать вес по командам для совсем маленьких batch. */
1592
- I(j, yt, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
1593
- I(j, pt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
1594
- I(j, Nt, 8), I(j, Ot, 0.65);
1592
+ D(j, pt, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
1593
+ D(j, Nt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
1594
+ D(j, Ot, 8), D(j, _t, 0.65);
1595
1595
  let v = j;
1596
1596
  var $;
1597
- class Ft {
1597
+ class zt {
1598
1598
  constructor() {
1599
- I(this, $, {});
1599
+ D(this, $, {});
1600
1600
  }
1601
1601
  /**
1602
1602
  * Получить случайный хеш-код длиной 8 символов
@@ -1610,10 +1610,10 @@ class Ft {
1610
1610
  * @param {number} length - Длина генерируемого хеша
1611
1611
  * @returns {string}
1612
1612
  */
1613
- createHash(r) {
1613
+ createHash(t) {
1614
1614
  let e = "abcdefghijklmnopqrstuvwxyz0123456789", s = "";
1615
- r = r || 6;
1616
- for (let n = 0; n < r; n++)
1615
+ t = t || 6;
1616
+ for (let i = 0; i < t; i++)
1617
1617
  s += e.charAt(Math.floor(Math.random() * e.length));
1618
1618
  return s;
1619
1619
  }
@@ -1624,8 +1624,8 @@ class Ft {
1624
1624
  * @param {number} params.duration - Задержка в миллисекундах (по умолчанию 10)
1625
1625
  * @param {Function} params.action - Функция для выполнения
1626
1626
  */
1627
- actionFilter({ keyTimer: r, duration: e = 10, action: s }) {
1628
- R(this, $)[r] && (clearTimeout(R(this, $)[r]), R(this, $)[r] = null), s && (R(this, $)[r] = setTimeout(() => {
1627
+ actionFilter({ keyTimer: t, duration: e = 10, action: s }) {
1628
+ S(this, $)[t] && (clearTimeout(S(this, $)[t]), S(this, $)[t] = null), s && (S(this, $)[t] = setTimeout(() => {
1629
1629
  s();
1630
1630
  }, e));
1631
1631
  }
@@ -1634,88 +1634,88 @@ class Ft {
1634
1634
  * Создает невидимое видео, которое циклически воспроизводится
1635
1635
  */
1636
1636
  async noSleep() {
1637
- let r = document.createElement("video");
1638
- r.classList.add("no-sleep"), r.muted = !0, r.autoplay = !0, r.setAttribute("playsinline", ""), r.addEventListener("loadeddata", () => {
1639
- r.style.position = "fixed", r.style.left = "-9999px", document.querySelector("body").append(r), r.play().catch((e) => {
1637
+ let t = document.createElement("video");
1638
+ t.classList.add("no-sleep"), t.muted = !0, t.autoplay = !0, t.setAttribute("playsinline", ""), t.addEventListener("loadeddata", () => {
1639
+ t.style.position = "fixed", t.style.left = "-9999px", document.querySelector("body").append(t), t.play().catch((e) => {
1640
1640
  console.warn("noSleep: autoplay prevented", e);
1641
1641
  });
1642
- }), r.addEventListener("ended", () => {
1642
+ }), t.addEventListener("ended", () => {
1643
1643
  this.actionFilter({
1644
1644
  keyTimer: "no-sleep",
1645
1645
  duration: 5e3,
1646
1646
  action: () => {
1647
- r.play().catch((e) => {
1647
+ t.play().catch((e) => {
1648
1648
  console.warn("noSleep: replay prevented", e);
1649
1649
  });
1650
1650
  }
1651
1651
  });
1652
- }), r.src = "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAP5tZGF0AAAAAQYAAADlZYiEE28FmH9jNWDBjI+Z/1tIBZsjfhbmcNNUpBFej0U3p+zhaJ3eemJRL2LUMa5tkidy6bp+eatLE3jBIY864TvaAmqEFCgLMTCwVbem1n3myAw9yDXQdR5HfU/8iYf+eneVnRf7Qx9M70XDUuPx1MJX671XJwAE0VAMpnhbcUDx0pTldvUX9KQPhkZNH3eyZHmObkAeyEJ2tl+BEBJIGc90BiqKL60+5EA6fXB6iG5UU/M5KsW8BNAAUw5CbRJIqohNk10fwKbUXwya03rqGkE8+wuYGtEbrVYXb+iOl1mHHVPLYQbIAAcGyAAHAAAFNG1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAAAAvAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAIldHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAFAAAAA8AAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAAAAAAAAAAAQAAAAABnW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAAAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAUhtaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAEIc3RibAAAAKRzdHNkAAAAAAAAAAEAAACUYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAFAAPAASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAAC5hdmNDAU1AC//hABZnTUAL2wUH7ARAAAADAEAAAAQDxQq4AQAFaOrAZXIAAAAQcGFzcAAAAAEAAAABAAAAGHN0dHMAAAAAAAAAAQAAAAEAAAAAAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAABAAAAAQAAABRzdHN6AAAAAAAAAO4AAAABAAAAFHN0Y28AAAAAAAAAAQAAADAAAAIadHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAAAvAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAALwAAAAAAAQAAAAABkm1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAArEQAAAgAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAT1taW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAQFzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAAC7gAAAAViBYCAgAISCAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAACAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAgAAAAEAAAAUc3RzegAAAAAAAAAEAAAAAgAAABRzdGNvAAAAAAAAAAEAAAEeAAAAGnNncGQBAAAAcm9sbAAAAAIAAAAB//8AAAAcc2JncAAAAAByb2xsAAAAAQAAAAIAAAABAAAAgXVkdGEAAAB5bWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWR0YQAAAAAAAAAAAAAAAAAAAAAfa2V5cwAAAAAAAAABAAAAD21kdGFlbmNvZGVyAAAALWlsc3QAAAAlAAAAAQAAAB1kYXRhAAAAAQAAAABMYXZmNTguMTIuMTAw";
1652
+ }), t.src = "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAP5tZGF0AAAAAQYAAADlZYiEE28FmH9jNWDBjI+Z/1tIBZsjfhbmcNNUpBFej0U3p+zhaJ3eemJRL2LUMa5tkidy6bp+eatLE3jBIY864TvaAmqEFCgLMTCwVbem1n3myAw9yDXQdR5HfU/8iYf+eneVnRf7Qx9M70XDUuPx1MJX671XJwAE0VAMpnhbcUDx0pTldvUX9KQPhkZNH3eyZHmObkAeyEJ2tl+BEBJIGc90BiqKL60+5EA6fXB6iG5UU/M5KsW8BNAAUw5CbRJIqohNk10fwKbUXwya03rqGkE8+wuYGtEbrVYXb+iOl1mHHVPLYQbIAAcGyAAHAAAFNG1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAAAAvAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAIldHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAFAAAAA8AAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAAAAAAAAAAAQAAAAABnW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAAAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAUhtaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAEIc3RibAAAAKRzdHNkAAAAAAAAAAEAAACUYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAFAAPAASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAAC5hdmNDAU1AC//hABZnTUAL2wUH7ARAAAADAEAAAAQDxQq4AQAFaOrAZXIAAAAQcGFzcAAAAAEAAAABAAAAGHN0dHMAAAAAAAAAAQAAAAEAAAAAAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAABAAAAAQAAABRzdHN6AAAAAAAAAO4AAAABAAAAFHN0Y28AAAAAAAAAAQAAADAAAAIadHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAAAvAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAALwAAAAAAAQAAAAABkm1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAArEQAAAgAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAT1taW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAQFzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAAC7gAAAAViBYCAgAISCAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAACAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAgAAAAEAAAAUc3RzegAAAAAAAAAEAAAAAgAAABRzdGNvAAAAAAAAAAEAAAEeAAAAGnNncGQBAAAAcm9sbAAAAAIAAAAB//8AAAAcc2JncAAAAAByb2xsAAAAAQAAAAIAAAABAAAAgXVkdGEAAAB5bWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWR0YQAAAAAAAAAAAAAAAAAAAAAfa2V5cwAAAAAAAAABAAAAD21kdGFlbmNvZGVyAAAALWlsc3QAAAAlAAAAAQAAAB1kYXRhAAAAAQAAAABMYXZmNTguMTIuMTAw";
1653
1653
  }
1654
1654
  /**
1655
1655
  * Скачать данные в JSON-файл
1656
1656
  * @param {any} data - Данные для сохранения
1657
1657
  * @param {string} filename - Имя файла без расширения
1658
1658
  */
1659
- downloadFileJson(r, e) {
1660
- let s = new Blob([JSON.stringify(r)], { type: "application/json" }), n = URL.createObjectURL(s), o = document.createElement("a");
1661
- o.style.display = "none", o.href = n, o.download = `${e}.json`, document.body.appendChild(o), o.click(), setTimeout(() => {
1662
- document.body.removeChild(o), URL.revokeObjectURL(n);
1659
+ downloadFileJson(t, e) {
1660
+ let s = new Blob([JSON.stringify(t)], { type: "application/json" }), i = URL.createObjectURL(s), a = document.createElement("a");
1661
+ a.style.display = "none", a.href = i, a.download = `${e}.json`, document.body.appendChild(a), a.click(), setTimeout(() => {
1662
+ document.body.removeChild(a), URL.revokeObjectURL(i);
1663
1663
  }, 200);
1664
1664
  }
1665
1665
  }
1666
1666
  $ = new WeakMap();
1667
- const wt = new Ft();
1668
- var K, z, tt, nt, F, et, at, Lt, Xt, lt, Ht, Rt, Jt, bt, jt, St, Kt;
1669
- class ee {
1667
+ const Bt = new zt();
1668
+ var K, q, tt, nt, F, et, ot, Rt, Qt, ht, Yt, bt, qt, St, Zt, It, Vt;
1669
+ class ce {
1670
1670
  constructor() {
1671
- I(this, Lt);
1671
+ D(this, Rt);
1672
1672
  /** Вывод ошибок логера
1673
1673
  * @param {'entity'} type - тип ошибки
1674
1674
  */
1675
- I(this, lt);
1676
- I(this, Rt);
1677
- I(this, bt);
1678
- I(this, St);
1679
- I(this, K, "logger");
1680
- I(this, z, !1);
1681
- I(this, tt, /* @__PURE__ */ new Map());
1682
- I(this, nt, {});
1683
- I(this, F, null);
1684
- I(this, et, !1);
1685
- I(this, at, !1);
1675
+ D(this, ht);
1676
+ D(this, bt);
1677
+ D(this, St);
1678
+ D(this, It);
1679
+ D(this, K, "logger");
1680
+ D(this, q, !1);
1681
+ D(this, tt, /* @__PURE__ */ new Map());
1682
+ D(this, nt, {});
1683
+ D(this, F, null);
1684
+ D(this, et, !1);
1685
+ D(this, ot, !1);
1686
1686
  /** Очистка хранилища элементов старше 'N' месяцев */
1687
- w(this, "periodClear", 3);
1688
- E(this, Lt, Xt).call(this);
1687
+ C(this, "periodClear", 3);
1688
+ E(this, Rt, Qt).call(this);
1689
1689
  }
1690
1690
  /** Инициализация логера */
1691
1691
  async init() {
1692
1692
  try {
1693
- let r = new v(BX24.callBatch), { entityList: e } = await r.batch({
1693
+ let t = new v(BX24.callBatch), { entityList: e } = await t.batch({
1694
1694
  entityList: { method: "entity.get" }
1695
1695
  });
1696
1696
  if (e && Array.isArray(e))
1697
1697
  if (e.find(
1698
- (n) => n.ENTITY == R(this, K)
1698
+ (i) => i.ENTITY == S(this, K)
1699
1699
  ))
1700
- J(this, z, !0);
1700
+ J(this, q, !0);
1701
1701
  else {
1702
- let { entityAdd: n } = await r.batch({
1702
+ let { entityAdd: i } = await t.batch({
1703
1703
  entityAdd: {
1704
1704
  method: "entity.add",
1705
1705
  params: {
1706
- ENTITY: R(this, K),
1707
- NAME: R(this, K),
1706
+ ENTITY: S(this, K),
1707
+ NAME: S(this, K),
1708
1708
  ACCESS: { AU: "X" }
1709
1709
  }
1710
1710
  }
1711
1711
  });
1712
- n && J(this, z, !0);
1712
+ i && J(this, q, !0);
1713
1713
  }
1714
- return E(this, bt, jt).call(this).catch((s) => {
1714
+ return E(this, St, Zt).call(this).catch((s) => {
1715
1715
  console.error("Ошибка при проверке периода очистки:", s);
1716
- }), R(this, z);
1717
- } catch (r) {
1718
- return console.error("Ошибка при инициализации логера:", r), !1;
1716
+ }), S(this, q);
1717
+ } catch (t) {
1718
+ return console.error("Ошибка при инициализации логера:", t), !1;
1719
1719
  }
1720
1720
  }
1721
1721
  /**
@@ -1727,21 +1727,21 @@ class ee {
1727
1727
  * }; }}
1728
1728
  * @returns {string|null}
1729
1729
  */
1730
- start({ type: r, data: e }) {
1731
- if (!R(this, z))
1732
- return E(this, lt, Ht).call(this, "entity"), null;
1733
- if (!r || !e)
1734
- return console.error("Невалидные данные для логирования:", { type: r, data: e }), null;
1735
- const s = wt.hash, n = {
1736
- type: r,
1730
+ start({ type: t, data: e }) {
1731
+ if (!S(this, q))
1732
+ return E(this, ht, Yt).call(this, "entity"), null;
1733
+ if (!t || !e)
1734
+ return console.error("Невалидные данные для логирования:", { type: t, data: e }), null;
1735
+ const s = Bt.hash, i = {
1736
+ type: t,
1737
1737
  data: e,
1738
- userInfo: R(this, nt),
1738
+ userInfo: S(this, nt),
1739
1739
  errorList: {},
1740
1740
  status: "",
1741
1741
  answer: null,
1742
1742
  date: (/* @__PURE__ */ new Date()).getTime()
1743
1743
  };
1744
- return R(this, tt).set(s, n), J(this, at, !0), s;
1744
+ return S(this, tt).set(s, i), J(this, ot, !0), s;
1745
1745
  }
1746
1746
  /**
1747
1747
  * @param {{
@@ -1750,56 +1750,56 @@ class ee {
1750
1750
  * status: 'success'|'fail'|'fail-runtime',
1751
1751
  * answer: { [key]: unknown } }}
1752
1752
  */
1753
- async stop({ key: r, errorList: e, status: s, answer: n }) {
1754
- var h;
1755
- if (!R(this, at))
1753
+ async stop({ key: t, errorList: e, status: s, answer: i }) {
1754
+ var l;
1755
+ if (!S(this, ot))
1756
1756
  return;
1757
- if (!R(this, z)) {
1758
- E(this, lt, Ht).call(this, "entity");
1757
+ if (!S(this, q)) {
1758
+ E(this, ht, Yt).call(this, "entity");
1759
1759
  return;
1760
1760
  }
1761
- let o = R(this, tt).get(r);
1762
- if (!o) {
1763
- console.error(`Не найдены данные логирования для ключа: ${r}`);
1761
+ let a = S(this, tt).get(t);
1762
+ if (!a) {
1763
+ console.error(`Не найдены данные логирования для ключа: ${t}`);
1764
1764
  return;
1765
1765
  }
1766
- e && (o.errorList = e), s && (o.status = s), n && (o.answer = n), await E(this, Rt, Jt).call(this), (h = o == null ? void 0 : o.data) != null && h.updateList && J(this, et, !0), J(this, at, !1);
1766
+ e && (a.errorList = e), s && (a.status = s), i && (a.answer = i), await E(this, bt, qt).call(this), (l = a == null ? void 0 : a.data) != null && l.updateList && J(this, et, !0), J(this, ot, !1);
1767
1767
  }
1768
1768
  /**
1769
1769
  * @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
1770
1770
  */
1771
- async getEntityList(r) {
1771
+ async getEntityList(t) {
1772
1772
  var e;
1773
1773
  try {
1774
- if ((e = R(this, F)) != null && e.length && !R(this, et))
1775
- return R(this, F);
1776
- let s = new v(BX24.callBatch), { entityList: n } = await s.batch(
1774
+ if ((e = S(this, F)) != null && e.length && !S(this, et))
1775
+ return S(this, F);
1776
+ let s = new v(BX24.callBatch), { entityList: i } = await s.batch(
1777
1777
  {
1778
1778
  entityList: {
1779
1779
  method: "entity.item.get",
1780
1780
  params: {
1781
- ENTITY: R(this, K),
1781
+ ENTITY: S(this, K),
1782
1782
  SORT: { ID: "DESC" }
1783
1783
  }
1784
1784
  }
1785
1785
  },
1786
- r
1786
+ t
1787
1787
  );
1788
- return !n || !Array.isArray(n) ? (console.warn("Получен невалидный список записей"), []) : (n = n.map((o) => {
1788
+ return !i || !Array.isArray(i) ? (console.warn("Получен невалидный список записей"), []) : (i = i.map((a) => {
1789
1789
  try {
1790
- const { ID: h, DATE_CREATE: A, DETAIL_TEXT: l } = o;
1790
+ const { ID: l, DATE_CREATE: A, DETAIL_TEXT: h } = a;
1791
1791
  return {
1792
- ...JSON.parse(l),
1793
- id: h,
1792
+ ...JSON.parse(h),
1793
+ id: l,
1794
1794
  dateCreate: A
1795
1795
  };
1796
- } catch (h) {
1796
+ } catch (l) {
1797
1797
  return console.error(
1798
- `Ошибка парсинга записи ${o.ID}:`,
1799
- h
1798
+ `Ошибка парсинга записи ${a.ID}:`,
1799
+ l
1800
1800
  ), null;
1801
1801
  }
1802
- }).filter((o) => o !== null), J(this, et, !1), J(this, F, n), n);
1802
+ }).filter((a) => a !== null), J(this, et, !1), J(this, F, i), i);
1803
1803
  } catch (s) {
1804
1804
  return console.error("Ошибка при получении списка записей:", s), [];
1805
1805
  }
@@ -1807,132 +1807,160 @@ class ee {
1807
1807
  /** Выгрузка всех данных из хранилища в JSON-файл */
1808
1808
  async downAllEntityJson() {
1809
1809
  try {
1810
- if (R(this, F) || await this.getEntityList(), !R(this, F) || R(this, F).length === 0)
1810
+ if (S(this, F) || await this.getEntityList(), !S(this, F) || S(this, F).length === 0)
1811
1811
  return console.warn("Нет данных для выгрузки"), !1;
1812
- let r = mt().format("%Y-%m-%d");
1813
- return wt.downloadFileJson(
1814
- R(this, F),
1815
- `sdklogger-entity-data__${r}`
1812
+ let t = dt().format("%Y-%m-%d");
1813
+ return Bt.downloadFileJson(
1814
+ S(this, F),
1815
+ `sdklogger-entity-data__${t}`
1816
1816
  ), !0;
1817
- } catch (r) {
1818
- return console.error("Ошибка при выгрузке данных в JSON:", r), !1;
1817
+ } catch (t) {
1818
+ return console.error("Ошибка при выгрузке данных в JSON:", t), !1;
1819
1819
  }
1820
1820
  }
1821
1821
  }
1822
- K = new WeakMap(), z = new WeakMap(), tt = new WeakMap(), nt = new WeakMap(), F = new WeakMap(), et = new WeakMap(), at = new WeakMap(), Lt = new WeakSet(), Xt = async function() {
1822
+ K = new WeakMap(), q = new WeakMap(), tt = new WeakMap(), nt = new WeakMap(), F = new WeakMap(), et = new WeakMap(), ot = new WeakMap(), Rt = new WeakSet(), Qt = async function() {
1823
1823
  try {
1824
- const r = new v(BX24.callBatch), e = BX24.isAdmin(), { curUser: s } = await r.batch({
1824
+ const t = new v(BX24.callBatch), e = BX24.isAdmin(), { curUser: s } = await t.batch({
1825
1825
  curUser: { method: "user.current" }
1826
1826
  });
1827
1827
  J(this, nt, { isAdmin: e, curUser: s });
1828
- } catch (r) {
1828
+ } catch (t) {
1829
1829
  console.error(
1830
1830
  "Ошибка при получении информации о пользователе:",
1831
- r
1831
+ t
1832
1832
  ), J(this, nt, { isAdmin: !1, curUser: null });
1833
1833
  }
1834
- }, lt = new WeakSet(), Ht = function(r) {
1835
- r == "entity" && wt.actionFilter({
1834
+ }, ht = new WeakSet(), Yt = function(t) {
1835
+ t == "entity" && Bt.actionFilter({
1836
1836
  keyTimer: "error.logger.entity",
1837
1837
  duration: 500,
1838
1838
  action: () => {
1839
1839
  console.error("Хранилище для логгера не инициализировано");
1840
1840
  }
1841
1841
  });
1842
- }, Rt = new WeakSet(), Jt = async function() {
1842
+ }, bt = new WeakSet(), qt = async function() {
1843
1843
  try {
1844
- let r = {}, e = new v(BX24.callBatch);
1845
- for (let [s, n] of R(this, tt).entries())
1846
- if (n.status) {
1847
- const o = JSON.stringify(n);
1848
- r[s] = {
1844
+ let t = {}, e = new v(BX24.callBatch);
1845
+ for (let [s, i] of S(this, tt).entries())
1846
+ if (i.status) {
1847
+ const a = JSON.stringify(i);
1848
+ t[s] = {
1849
1849
  method: "entity.item.add",
1850
1850
  params: {
1851
- ENTITY: R(this, K),
1852
- NAME: R(this, K),
1853
- DETAIL_TEXT: o
1851
+ ENTITY: S(this, K),
1852
+ NAME: S(this, K),
1853
+ DETAIL_TEXT: a
1854
1854
  }
1855
1855
  };
1856
1856
  }
1857
- if (Object.keys(r).length) {
1858
- let s = await e.batch(r), { errors: n } = e;
1859
- for (let [o, h] of Object.entries({ ...s, ...n }))
1860
- R(this, tt).delete(o);
1857
+ if (Object.keys(t).length) {
1858
+ let s = await e.batch(t), { errors: i } = e;
1859
+ for (let [a, l] of Object.entries({ ...s, ...i }))
1860
+ S(this, tt).delete(a);
1861
1861
  return !0;
1862
1862
  }
1863
1863
  return !1;
1864
- } catch (r) {
1865
- return console.error("Ошибка при добавлении записей в хранилище:", r), !1;
1864
+ } catch (t) {
1865
+ return console.error("Ошибка при добавлении записей в хранилище:", t), !1;
1866
1866
  }
1867
- }, bt = new WeakSet(), jt = async function() {
1867
+ }, St = new WeakSet(), Zt = async function() {
1868
1868
  try {
1869
- let r = new v(BX24.callBatch), { serverTime: e } = await r.batch({
1869
+ let t = new v(BX24.callBatch), { serverTime: e } = await t.batch({
1870
1870
  serverTime: { method: "server.time" }
1871
1871
  });
1872
1872
  if (!e) {
1873
1873
  console.error("Не удалось получить время сервера");
1874
1874
  return;
1875
1875
  }
1876
- if (R(this, F) || await this.getEntityList(), !R(this, F) || R(this, F).length === 0)
1876
+ if (S(this, F) || await this.getEntityList(), !S(this, F) || S(this, F).length === 0)
1877
1877
  return;
1878
- let s = R(this, F).filter((n) => {
1878
+ let s = S(this, F).filter((i) => {
1879
1879
  try {
1880
- let { dateCreate: o } = n;
1881
- return o ? mt(new Date(o)).between(
1882
- mt(new Date(e)),
1880
+ let { dateCreate: a } = i;
1881
+ return a ? dt(new Date(a)).between(
1882
+ dt(new Date(e)),
1883
1883
  "month"
1884
1884
  ) >= this.periodClear : !1;
1885
- } catch (o) {
1886
- return console.error("Ошибка при проверке даты записи:", o), !1;
1885
+ } catch (a) {
1886
+ return console.error("Ошибка при проверке даты записи:", a), !1;
1887
1887
  }
1888
1888
  });
1889
1889
  s.length > 0 && (console.log(
1890
1890
  `Найдено ${s.length} записей для очистки (старше ${this.periodClear} месяцев)`
1891
- ), await E(this, St, Kt).call(this, s));
1892
- } catch (r) {
1893
- console.error("Ошибка при проверке периода очистки:", r);
1891
+ ), await E(this, It, Vt).call(this, s));
1892
+ } catch (t) {
1893
+ console.error("Ошибка при проверке периода очистки:", t);
1894
1894
  }
1895
- }, St = new WeakSet(), Kt = async function(r) {
1895
+ }, It = new WeakSet(), Vt = async function(t) {
1896
1896
  try {
1897
- if (!r || r.length === 0)
1897
+ if (!t || t.length === 0)
1898
1898
  return !1;
1899
- let e = new v(BX24.callBatch), s = r.filter((o) => o && o.id).map((o) => {
1900
- let { id: h } = o;
1899
+ let e = new v(BX24.callBatch), s = t.filter((a) => a && a.id).map((a) => {
1900
+ let { id: l } = a;
1901
1901
  return {
1902
1902
  method: "entity.item.delete",
1903
1903
  params: {
1904
- ENTITY: R(this, K),
1905
- ID: h
1904
+ ENTITY: S(this, K),
1905
+ ID: l
1906
1906
  }
1907
1907
  };
1908
1908
  });
1909
1909
  if (s.length === 0)
1910
1910
  return !1;
1911
- const n = await e.batch(s);
1912
- return console.log(`Успешно удалено ${s.length} записей`), J(this, et, !0), n;
1911
+ const i = await e.batch(s);
1912
+ return console.log(`Успешно удалено ${s.length} записей`), J(this, et, !0), i;
1913
1913
  } catch (e) {
1914
1914
  return console.error("Ошибка при очистке устаревших записей:", e), !1;
1915
1915
  }
1916
1916
  };
1917
- var rt, ct, It, vt, Mt, Qt, ut, Ut, ft, Pt, Dt, qt;
1918
- class se {
1917
+ function Ft(p) {
1918
+ if (!p || typeof p != "string")
1919
+ return "";
1920
+ try {
1921
+ const t = new URL(p);
1922
+ t.search = "", t.hash = "";
1923
+ let e = t.toString();
1924
+ return e.endsWith("/") && t.pathname !== "/" && (e = e.slice(0, -1)), e;
1925
+ } catch {
1926
+ return p.split("?")[0].split("#")[0].replace(/\/$/, "");
1927
+ }
1928
+ }
1929
+ function $t(p) {
1930
+ return !p || typeof p != "string" ? !1 : p.toLowerCase().includes("/marketplace/app");
1931
+ }
1932
+ function le() {
1933
+ var t;
1934
+ if (typeof window > "u" || !((t = window.location) != null && t.href))
1935
+ return "";
1936
+ const p = Ft(window.location.href);
1937
+ return $t(p) ? "" : p;
1938
+ }
1939
+ function Gt(p) {
1940
+ if (!(p != null && p.appConst) || typeof p.appConst != "object")
1941
+ return "";
1942
+ const t = le();
1943
+ return t ? (p.appConst.pathApp = t, t) : Ft(p.appConst.pathApp ?? "");
1944
+ }
1945
+ var rt, ct, Mt, te, Dt, ee, ut, Pt, ft, Wt, kt, re;
1946
+ class ge {
1919
1947
  /**
1920
1948
  * @param {Object} appConst - Константы приложения
1921
1949
  * @param {string} appConst.appName - Название приложения
1922
1950
  * @param {string} appConst.pathApp - Путь к приложению
1923
1951
  */
1924
- constructor(r) {
1952
+ constructor(t) {
1925
1953
  /**
1926
1954
  * Returns shared Batch instance for all batch operations.
1927
1955
  * Keeps a single stateful Batch (including timeLimit) within current BxBoot lifecycle.
1928
1956
  *
1929
1957
  * @returns {Batch} Shared Batch instance.
1930
1958
  */
1931
- I(this, rt);
1959
+ D(this, rt);
1932
1960
  /** Запрос данных о приложении */
1933
- I(this, It);
1961
+ D(this, Mt);
1934
1962
  /** Запрос данных о текущем пользователе */
1935
- I(this, Mt);
1963
+ D(this, Dt);
1936
1964
  /**
1937
1965
  * Расширяет errorList для случаев TIMEOUT и LIMIT
1938
1966
  * Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
@@ -1942,32 +1970,32 @@ class se {
1942
1970
  * @param {Array} updateList - Список обновлений для логирования (опционально)
1943
1971
  * @returns {Object} Расширенный список ошибок
1944
1972
  */
1945
- I(this, ut);
1973
+ D(this, ut);
1946
1974
  /**
1947
1975
  * Нормализует входные данные в массив объектов {placement, handler?}
1948
1976
  * @private
1949
1977
  */
1950
- I(this, ft);
1978
+ D(this, ft);
1951
1979
  /**
1952
1980
  * Находит встройки с устаревшим handler (не содержащим текущий pathApp)
1953
1981
  * @private
1954
1982
  */
1955
- I(this, Dt);
1956
- w(this, "domain", "");
1957
- w(this, "isAdmin", !1);
1958
- w(this, "appInfo", null);
1959
- w(this, "appConst", null);
1960
- w(this, "userInfo", null);
1961
- w(this, "placeData", null);
1962
- w(this, "placeInfo", null);
1963
- w(this, "logger", !1);
1964
- w(this, "timeLimit", {
1983
+ D(this, kt);
1984
+ C(this, "domain", "");
1985
+ C(this, "isAdmin", !1);
1986
+ C(this, "appInfo", null);
1987
+ C(this, "appConst", null);
1988
+ C(this, "userInfo", null);
1989
+ C(this, "placeData", null);
1990
+ C(this, "placeInfo", null);
1991
+ C(this, "logger", !1);
1992
+ C(this, "timeLimit", {
1965
1993
  limit: !1,
1966
1994
  date: void 0,
1967
1995
  pauseMs: void 0
1968
1996
  });
1969
- w(this, "batchClient", null);
1970
- this.appConst = r;
1997
+ C(this, "batchClient", null);
1998
+ this.appConst = t;
1971
1999
  }
1972
2000
  /**
1973
2001
  * Подписывает внешний код на изменения состояния timeLimit в Batch.
@@ -1975,8 +2003,8 @@ class se {
1975
2003
  * @param {(state: {limit: boolean, date?: string, pauseMs?: number}) => void} callback - Обработчик состояния лимита.
1976
2004
  * @returns {() => void} Функция отписки.
1977
2005
  */
1978
- subscribeTimeLimit(r) {
1979
- return E(this, rt, ct).call(this).subscribeTimeLimit(r);
2006
+ subscribeTimeLimit(t) {
2007
+ return E(this, rt, ct).call(this).subscribeTimeLimit(t);
1980
2008
  }
1981
2009
  /**
1982
2010
  * Инициализация Bitrix24 SDK
@@ -1984,10 +2012,10 @@ class se {
1984
2012
  * @throws {Error} Если BX24 не загружен в течение 30 секунд
1985
2013
  */
1986
2014
  init() {
1987
- return new Promise((r, e) => {
1988
- let n = setInterval(() => {
2015
+ return new Promise((t, e) => {
2016
+ let i = setInterval(() => {
1989
2017
  window.BX24 && BX24.init(async () => {
1990
- console.info("init BX24"), clearInterval(n), clearTimeout(o), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info(), this.logger ? (this.logger = new ee(), await this.logger.init()) : this.logger = {
2018
+ console.info("init BX24"), clearInterval(i), clearTimeout(a), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info(), this.logger ? (this.logger = new ce(), await this.logger.init()) : this.logger = {
1991
2019
  start: () => {
1992
2020
  },
1993
2021
  stop: () => {
@@ -1995,29 +2023,29 @@ class se {
1995
2023
  getEntityList: () => {
1996
2024
  }
1997
2025
  };
1998
- const [h, A] = await Promise.all([
1999
- E(this, It, vt).call(this),
2000
- E(this, Mt, Qt).call(this)
2026
+ const [l, A] = await Promise.all([
2027
+ E(this, Mt, te).call(this),
2028
+ E(this, Dt, ee).call(this)
2001
2029
  ]);
2002
- this.appInfo = h, this.userInfo = A;
2003
- let l = new Ft();
2030
+ this.appInfo = l, this.userInfo = A, Gt(this);
2031
+ let h = new zt();
2004
2032
  try {
2005
- l.noSleep();
2006
- } catch (i) {
2033
+ h.noSleep();
2034
+ } catch (n) {
2007
2035
  console.warn(
2008
2036
  "Failed to initialize noSleep:",
2009
- i
2037
+ n
2010
2038
  );
2011
2039
  }
2012
- r(!0);
2040
+ t(!0);
2013
2041
  });
2014
2042
  }, 100);
2015
- const o = setTimeout(() => {
2016
- clearInterval(n);
2017
- const h = new Error(
2043
+ const a = setTimeout(() => {
2044
+ clearInterval(i);
2045
+ const l = new Error(
2018
2046
  "BX24 initialization timeout: BX24 object not found within 30 seconds"
2019
2047
  );
2020
- console.error(h), e(h);
2048
+ console.error(l), e(l);
2021
2049
  }, 3e4);
2022
2050
  });
2023
2051
  }
@@ -2027,23 +2055,23 @@ class se {
2027
2055
  * @param {any} value - Значение для установки (если не указано, метод вернет текущее значение)
2028
2056
  * @returns {any}
2029
2057
  */
2030
- userOption(r, e) {
2058
+ userOption(t, e) {
2031
2059
  if (typeof BX24 > "u" || !BX24.userOption) {
2032
2060
  console.warn(
2033
2061
  "BX24.userOption is not available. Make sure BX24 is initialized."
2034
2062
  );
2035
2063
  return;
2036
2064
  }
2037
- return e !== void 0 ? BX24.userOption.set(r, e) : BX24.userOption.get(r);
2065
+ return e !== void 0 ? BX24.userOption.set(t, e) : BX24.userOption.get(t);
2038
2066
  }
2039
- appOption(r, e) {
2067
+ appOption(t, e) {
2040
2068
  if (typeof BX24 > "u" || !BX24.appOption) {
2041
2069
  console.warn(
2042
2070
  "BX24.appOption is not available. Make sure BX24 is initialized."
2043
2071
  );
2044
2072
  return;
2045
2073
  }
2046
- return e !== void 0 ? BX24.appOption.set(r, e) : BX24.appOption.get(r);
2074
+ return e !== void 0 ? BX24.appOption.set(t, e) : BX24.appOption.get(t);
2047
2075
  }
2048
2076
  /**
2049
2077
  * @param {{
@@ -2063,41 +2091,41 @@ class se {
2063
2091
  * }[]
2064
2092
  * }[]
2065
2093
  */
2066
- async call({ method: r, params: e, updateList: s }) {
2067
- let n;
2068
- if (s && (n = this.logger.start({
2094
+ async call({ method: t, params: e, updateList: s }) {
2095
+ let i;
2096
+ if (s && (i = this.logger.start({
2069
2097
  type: "call",
2070
- data: { method: r, params: e, updateList: s }
2098
+ data: { method: t, params: e, updateList: s }
2071
2099
  })), e || (e = {}), typeof BX24 > "u" || !BX24.callMethod) {
2072
2100
  const A = new Error("BX24 is not initialized");
2073
2101
  throw console.error(A), A;
2074
2102
  }
2075
- const h = await E(this, rt, ct).call(this).call({ method: r, params: e });
2076
- if (!h.success) {
2077
- if (console.error(h.error), n)
2103
+ const l = await E(this, rt, ct).call(this).call({ method: t, params: e });
2104
+ if (!l.success) {
2105
+ if (console.error(l.error), i)
2078
2106
  try {
2079
2107
  await this.logger.stop({
2080
- answer: h.answer,
2081
- key: n,
2108
+ answer: l.answer,
2109
+ key: i,
2082
2110
  status: "fail",
2083
- errorList: { 0: h.error || "Unknown call error" }
2111
+ errorList: { 0: l.error || "Unknown call error" }
2084
2112
  });
2085
2113
  } catch (A) {
2086
2114
  console.error("Logger error:", A);
2087
2115
  }
2088
2116
  return !1;
2089
2117
  }
2090
- if (n)
2118
+ if (i)
2091
2119
  try {
2092
2120
  await this.logger.stop({
2093
- answer: h.answer,
2094
- key: n,
2121
+ answer: l.answer,
2122
+ key: i,
2095
2123
  status: "success"
2096
2124
  });
2097
2125
  } catch (A) {
2098
2126
  console.error("Logger error:", A);
2099
2127
  }
2100
- return h.data;
2128
+ return l.data;
2101
2129
  }
2102
2130
  /**
2103
2131
  * @param commandList - объект/массив команд
@@ -2118,31 +2146,31 @@ class se {
2118
2146
  * }[]
2119
2147
  * }}
2120
2148
  */
2121
- async batch(r, e, { errorCall: s, updateList: n, batchOptions: o } = {}) {
2149
+ async batch(t, e, { errorCall: s, updateList: i, batchOptions: a } = {}) {
2122
2150
  if (typeof BX24 > "u" || !BX24.callBatch) {
2123
- const l = new Error("BX24 is not initialized");
2124
- return console.error(l), !1;
2151
+ const h = new Error("BX24 is not initialized");
2152
+ return console.error(h), !1;
2125
2153
  }
2126
- const h = E(this, rt, ct).call(this);
2154
+ const l = E(this, rt, ct).call(this);
2127
2155
  let A;
2128
- n && (A = this.logger.start({
2156
+ i && (A = this.logger.start({
2129
2157
  type: "batch",
2130
- data: { commandList: r, updateList: n }
2158
+ data: { commandList: t, updateList: i }
2131
2159
  }));
2132
2160
  try {
2133
- let l = await h.batch(
2134
- r,
2161
+ let h = await l.batch(
2162
+ t,
2135
2163
  e,
2136
- o
2164
+ a
2137
2165
  );
2138
- const i = E(this, ut, Ut).call(this, h, l, r, n);
2139
- if (Object.keys(i).length) {
2140
- if (s && s(i), A)
2166
+ const n = E(this, ut, Pt).call(this, l, h, t, i);
2167
+ if (Object.keys(n).length) {
2168
+ if (s && s(n), A)
2141
2169
  try {
2142
2170
  await this.logger.stop({
2143
2171
  key: A,
2144
2172
  status: "fail",
2145
- errorList: i
2173
+ errorList: n
2146
2174
  });
2147
2175
  } catch (u) {
2148
2176
  console.error("Logger error:", u);
@@ -2156,19 +2184,19 @@ class se {
2156
2184
  } catch (u) {
2157
2185
  console.error("Logger error:", u);
2158
2186
  }
2159
- return l;
2160
- } catch (l) {
2187
+ return h;
2188
+ } catch (h) {
2161
2189
  if (A)
2162
2190
  try {
2163
2191
  await this.logger.stop({
2164
2192
  key: A,
2165
2193
  status: "fail-runtime",
2166
- errorList: { 0: l == null ? void 0 : l.toString() }
2194
+ errorList: { 0: h == null ? void 0 : h.toString() }
2167
2195
  });
2168
- } catch (i) {
2169
- console.error("Logger error:", i);
2196
+ } catch (n) {
2197
+ console.error("Logger error:", n);
2170
2198
  }
2171
- return console.error(l), !1;
2199
+ return console.error(h), !1;
2172
2200
  }
2173
2201
  }
2174
2202
  /**
@@ -2193,105 +2221,105 @@ class se {
2193
2221
  * }}
2194
2222
  * @returns {Promise<Object|false>}
2195
2223
  */
2196
- async batchTotalCount(r, e, { errorCall: s, updateList: n } = {}) {
2224
+ async batchTotalCount(t, e, { errorCall: s, updateList: i } = {}) {
2197
2225
  if (typeof BX24 > "u" || !BX24.callBatch) {
2198
2226
  const A = new Error("BX24 is not initialized");
2199
2227
  return console.error(A), !1;
2200
2228
  }
2201
- const o = E(this, rt, ct).call(this);
2202
- let h;
2203
- n && (h = this.logger.start({
2229
+ const a = E(this, rt, ct).call(this);
2230
+ let l;
2231
+ i && (l = this.logger.start({
2204
2232
  type: "batch-total-count",
2205
- data: { commandList: r }
2233
+ data: { commandList: t }
2206
2234
  }));
2207
2235
  try {
2208
- let A = await o.batchTotalCount(
2209
- r,
2236
+ let A = await a.batchTotalCount(
2237
+ t,
2210
2238
  e
2211
2239
  );
2212
- const l = E(this, ut, Ut).call(this, o, A, r, n);
2213
- if (Object.keys(l).length) {
2214
- if (s && s(l), h)
2240
+ const h = E(this, ut, Pt).call(this, a, A, t, i);
2241
+ if (Object.keys(h).length) {
2242
+ if (s && s(h), l)
2215
2243
  try {
2216
2244
  await this.logger.stop({
2217
- key: h,
2245
+ key: l,
2218
2246
  status: "fail",
2219
- errorList: l
2247
+ errorList: h
2220
2248
  });
2221
- } catch (i) {
2222
- console.error("Logger error:", i);
2249
+ } catch (n) {
2250
+ console.error("Logger error:", n);
2223
2251
  }
2224
- } else if (h)
2252
+ } else if (l)
2225
2253
  try {
2226
2254
  await this.logger.stop({
2227
- key: h,
2255
+ key: l,
2228
2256
  status: "success"
2229
2257
  });
2230
- } catch (i) {
2231
- console.error("Logger error:", i);
2258
+ } catch (n) {
2259
+ console.error("Logger error:", n);
2232
2260
  }
2233
2261
  return A;
2234
2262
  } catch (A) {
2235
- if (h)
2263
+ if (l)
2236
2264
  try {
2237
2265
  await this.logger.stop({
2238
- key: h,
2266
+ key: l,
2239
2267
  status: "fail-runtime",
2240
2268
  errorList: { 0: A == null ? void 0 : A.toString() }
2241
2269
  });
2242
- } catch (l) {
2243
- console.error("Logger error:", l);
2270
+ } catch (h) {
2271
+ console.error("Logger error:", h);
2244
2272
  }
2245
2273
  return console.error(A), !1;
2246
2274
  }
2247
2275
  }
2248
2276
  /** Запрос данных о местах встройки приложения */
2249
2277
  async getPlacement() {
2250
- return await this.call({ method: "placement.get" }).then((r) => (this.placeData || (this.placeData = r), r));
2278
+ return await this.call({ method: "placement.get" }).then((t) => (this.placeData || (this.placeData = t), t));
2251
2279
  }
2252
2280
  /**
2253
2281
  * Встройка приложения в указанные места
2254
2282
  * @param {string|string[]|Object|Object[]} place - Место или массив мест для встройки
2255
2283
  */
2256
- async placementBind(r) {
2257
- var y;
2284
+ async placementBind(t) {
2285
+ var m;
2258
2286
  if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
2259
2287
  return;
2260
2288
  const { appName: e, pathApp: s } = this.appConst;
2261
- let n = E(this, ft, Pt).call(this, r);
2262
- n = n.filter(
2289
+ let i = E(this, ft, Wt).call(this, t);
2290
+ i = i.filter(
2263
2291
  (c) => c.placement !== "PAGE_BACKGROUND_WORKER" && c.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2264
2292
  );
2265
- const o = E(this, Dt, qt).call(this, s), h = new Set(n.map((c) => c.placement));
2266
- for (const c of o)
2267
- h.has(c.placement) || n.push({ placement: c.placement });
2268
- if (n.length === 0)
2293
+ const a = E(this, kt, re).call(this, s), l = new Set(i.map((c) => c.placement));
2294
+ for (const c of a)
2295
+ l.has(c.placement) || i.push({ placement: c.placement });
2296
+ if (i.length === 0)
2269
2297
  return;
2270
2298
  let A = e;
2271
- this.domain === "szdl.bitrix24.ru" && ((y = this.appInfo) != null && y.ID) && (A = `${e}: #${this.appInfo.ID}`);
2272
- const l = A.replace(" CRM", ""), i = {}, u = [];
2273
- for (let c = 0; c < n.length; c++) {
2274
- const f = n[c].placement;
2299
+ this.domain === "szdl.bitrix24.ru" && ((m = this.appInfo) != null && m.ID) && (A = `${e}: #${this.appInfo.ID}`);
2300
+ const h = A.replace(" CRM", ""), n = {}, u = [];
2301
+ for (let c = 0; c < i.length; c++) {
2302
+ const f = i[c].placement;
2275
2303
  if (this.placeData.find(
2276
- (m) => m.placement === f && m.handler === s
2304
+ (_) => _.placement === f && _.handler === s
2277
2305
  ))
2278
2306
  continue;
2279
- const _ = this.placeData.filter(
2280
- (m) => m.placement === f && m.handler !== s
2307
+ const T = this.placeData.filter(
2308
+ (_) => _.placement === f && _.handler !== s
2281
2309
  );
2282
- for (const m of _)
2310
+ for (const _ of T)
2283
2311
  u.push({
2284
2312
  placement: f,
2285
- handler: m.handler
2313
+ handler: _.handler
2286
2314
  });
2287
- i[`bind_${c}`] = {
2315
+ n[`bind_${c}`] = {
2288
2316
  method: "placement.bind",
2289
2317
  params: {
2290
2318
  PLACEMENT: f,
2291
2319
  HANDLER: s,
2292
2320
  LANG_ALL: {
2293
2321
  ru: {
2294
- TITLE: f === "USER_PROFILE_TOOLBAR" ? l : A
2322
+ TITLE: f === "USER_PROFILE_TOOLBAR" ? h : A
2295
2323
  }
2296
2324
  },
2297
2325
  OPTIONS: {
@@ -2300,7 +2328,7 @@ class se {
2300
2328
  }
2301
2329
  };
2302
2330
  }
2303
- u.length > 0 && await this.placementUnBind(u), Object.keys(i).length > 0 && (await this.batch(i), this.placeData = await this.getPlacement(), Object.values(i).forEach((c) => {
2331
+ u.length > 0 && await this.placementUnBind(u), Object.keys(n).length > 0 && (await this.batch(n), this.placeData = await this.getPlacement(), Object.values(n).forEach((c) => {
2304
2332
  console.log("Приложение успешно встроено в", c.params.PLACEMENT);
2305
2333
  }));
2306
2334
  }
@@ -2308,24 +2336,24 @@ class se {
2308
2336
  * Отвязка встройки из указанных мест
2309
2337
  * @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
2310
2338
  */
2311
- async placementUnBind(r) {
2312
- let e = E(this, ft, Pt).call(this, r);
2339
+ async placementUnBind(t) {
2340
+ let e = E(this, ft, Wt).call(this, t);
2313
2341
  if (e = e.filter(
2314
- (n) => n.placement !== "PAGE_BACKGROUND_WORKER" && n.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2342
+ (i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2315
2343
  ), e.length === 0)
2316
2344
  return;
2317
2345
  const s = {};
2318
- for (let n = 0; n < e.length; n++) {
2319
- const o = {
2320
- PLACEMENT: e[n].placement
2346
+ for (let i = 0; i < e.length; i++) {
2347
+ const a = {
2348
+ PLACEMENT: e[i].placement
2321
2349
  };
2322
- e[n].handler && (o.HANDLER = e[n].handler), s[`unbind_${n}`] = {
2350
+ e[i].handler && (a.HANDLER = e[i].handler), s[`unbind_${i}`] = {
2323
2351
  method: "placement.unbind",
2324
- params: o
2352
+ params: a
2325
2353
  };
2326
2354
  }
2327
- await this.batch(s), e.forEach((n) => {
2328
- console.log("Встройка отвязана", n.placement);
2355
+ await this.batch(s), e.forEach((i) => {
2356
+ console.log("Встройка отвязана", i.placement);
2329
2357
  });
2330
2358
  }
2331
2359
  /** Чат-бот */
@@ -2334,22 +2362,22 @@ class se {
2334
2362
  return this.call({
2335
2363
  method: "imbot.bot.list",
2336
2364
  params: {}
2337
- }).then((r) => {
2338
- let e = Object.values(r);
2365
+ }).then((t) => {
2366
+ let e = Object.values(t);
2339
2367
  return console.log("chat-bot list:", e), e;
2340
2368
  });
2341
2369
  }
2342
2370
  /* регистрация бота */
2343
- regBot({ code: r, type: e, name: s }) {
2344
- const { appName: n, pathApp: o, chatBotLogo: h } = this.appConst, A = this.appInfo.ID;
2371
+ regBot({ code: t, type: e, name: s }) {
2372
+ const { appName: i, pathApp: a, chatBotLogo: l } = this.appConst, A = this.appInfo.ID;
2345
2373
  return this.call({
2346
2374
  method: "imbot.register",
2347
2375
  params: {
2348
- CODE: r ?? this.appInfo.CODE,
2376
+ CODE: t ?? this.appInfo.CODE,
2349
2377
  // Строковой идентификатор бота, уникальный в рамках вашего приложения (обяз.)
2350
2378
  TYPE: e ?? "O",
2351
2379
  // Тип бота, B - чат-бот, ответы поступают сразу, H - человек, ответы поступают с задержкой от 2-х до 10 секунд, O - чат-бот для Открытых линий, S - чат-бот с повышенными привилегиями (supervisor)
2352
- EVENT_HANDLER: o,
2380
+ EVENT_HANDLER: a,
2353
2381
  // Ссылка на обработчик событий, поступивших от сервера - см. Обработчики событий ниже (обяз).
2354
2382
  OPENLINE: "Y",
2355
2383
  // Включение режима поддержки Открытых линий, можно не указывать, если TYPE = 'O'
@@ -2357,7 +2385,7 @@ class se {
2357
2385
  // строковый идентификатор чат-бота, используется только в режиме Вебхуков
2358
2386
  PROPERTIES: {
2359
2387
  // Личные данные чат-бота (обяз.)
2360
- NAME: `${s ?? n} - бот #${A}`,
2388
+ NAME: `${s ?? i} - бот #${A}`,
2361
2389
  // Имя чат-бота (обязательное одно из полей NAME или LAST_NAME)
2362
2390
  LAST_NAME: "",
2363
2391
  // Фамилия чат-бота (обязательное одно из полей NAME или LAST_NAME)
@@ -2365,7 +2393,7 @@ class se {
2365
2393
  // Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
2366
2394
  EMAIL: "",
2367
2395
  // E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
2368
- PERSONAL_BIRTHDAY: mt().format("%Y-%m-%d"),
2396
+ PERSONAL_BIRTHDAY: dt().format("%Y-%m-%d"),
2369
2397
  // День рождения в формате YYYY-mm-dd
2370
2398
  WORK_POSITION: "Почтальон",
2371
2399
  // Занимаемая должность, используется как описание чат-бота
@@ -2373,24 +2401,24 @@ class se {
2373
2401
  // Ссылка на сайт
2374
2402
  PERSONAL_GENDER: "M",
2375
2403
  // Пол чат-бота, допустимые значения M - мужской, F - женский, пусто, если не требуется указывать
2376
- PERSONAL_PHOTO: h ?? ""
2404
+ PERSONAL_PHOTO: l ?? ""
2377
2405
  // Аватар чат-бота - base64
2378
2406
  }
2379
2407
  }
2380
- }).then((l) => (console.log("Чат-бот добавлен", l), l));
2408
+ }).then((h) => (console.log("Чат-бот добавлен", h), h));
2381
2409
  }
2382
2410
  /* Убрать регистрацию бота */
2383
- unRegBot(r) {
2411
+ unRegBot(t) {
2384
2412
  return this.call({
2385
2413
  method: "imbot.unregister",
2386
2414
  params: {
2387
- BOT_ID: r
2415
+ BOT_ID: t
2388
2416
  }
2389
2417
  }).then((e) => (console.log("чат-бот удален", e), e));
2390
2418
  }
2391
2419
  /* Получение данных логера */
2392
- getLoggerList(r) {
2393
- return this.logger.getEntityList(r);
2420
+ getLoggerList(t) {
2421
+ return this.logger.getEntityList(t);
2394
2422
  }
2395
2423
  }
2396
2424
  rt = new WeakSet(), ct = function() {
@@ -2398,75 +2426,129 @@ rt = new WeakSet(), ct = function() {
2398
2426
  callBatch: BX24.callBatch,
2399
2427
  callMethod: BX24.callMethod
2400
2428
  }), this.timeLimit = this.batchClient.timeLimit), this.batchClient;
2401
- }, It = new WeakSet(), vt = function() {
2429
+ }, Mt = new WeakSet(), te = function() {
2402
2430
  return this.call({ method: "app.info" });
2403
- }, Mt = new WeakSet(), Qt = function() {
2431
+ }, Dt = new WeakSet(), ee = function() {
2404
2432
  return this.call({ method: "user.current" });
2405
- }, ut = new WeakSet(), Ut = function(r, e, s, n) {
2406
- let o = { ...r.errors };
2407
- if (Object.values(r.errors).some(
2433
+ }, ut = new WeakSet(), Pt = function(t, e, s, i) {
2434
+ let a = { ...t.errors };
2435
+ if (Object.values(t.errors).some(
2408
2436
  (A) => {
2409
2437
  if (typeof A != "string")
2410
2438
  return !1;
2411
- const l = A.toUpperCase();
2412
- return l === "TIMEOUT" || l === "OPERATION_TIME_LIMIT" || l.includes("TIMEOUT") || l.includes("OPERATION_TIME_LIMIT");
2439
+ const h = A.toUpperCase();
2440
+ return h === "TIMEOUT" || h === "OPERATION_TIME_LIMIT" || h.includes("TIMEOUT") || h.includes("OPERATION_TIME_LIMIT");
2413
2441
  }
2414
- ) && n) {
2415
- const A = e ? Object.keys(e).filter((y) => y !== "errorsList") : [], l = new Set(Object.keys(r.errors || {})), i = /* @__PURE__ */ new Set();
2442
+ ) && i) {
2443
+ const A = e ? Object.keys(e).filter((m) => m !== "errorsList") : [], h = new Set(Object.keys(t.errors || {})), n = /* @__PURE__ */ new Set();
2416
2444
  if (e) {
2417
- for (const y of A)
2418
- if (!l.has(y)) {
2419
- const c = e[y];
2420
- c != null && i.add(y);
2445
+ for (const m of A)
2446
+ if (!h.has(m)) {
2447
+ const c = e[m];
2448
+ c != null && n.add(m);
2421
2449
  }
2422
2450
  }
2423
- const u = Object.values(r.errors).find(
2424
- (y) => {
2425
- if (typeof y != "string")
2451
+ const u = Object.values(t.errors).find(
2452
+ (m) => {
2453
+ if (typeof m != "string")
2426
2454
  return !1;
2427
- const c = y.toUpperCase();
2455
+ const c = m.toUpperCase();
2428
2456
  return c === "TIMEOUT" || c === "OPERATION_TIME_LIMIT" || c.includes("TIMEOUT") || c.includes("OPERATION_TIME_LIMIT");
2429
2457
  }
2430
2458
  );
2431
- for (const y of Object.keys(s))
2432
- !i.has(y) && !r.errors[y] && (o[y] = u || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
2459
+ for (const m of Object.keys(s))
2460
+ !n.has(m) && !t.errors[m] && (a[m] = u || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
2433
2461
  }
2434
- return o;
2435
- }, ft = new WeakSet(), Pt = function(r) {
2436
- if (!r)
2462
+ return a;
2463
+ }, ft = new WeakSet(), Wt = function(t) {
2464
+ if (!t)
2437
2465
  return [];
2438
2466
  let e = [];
2439
- return Array.isArray(r) ? e = r.map(
2467
+ return Array.isArray(t) ? e = t.map(
2440
2468
  (s) => typeof s == "string" ? { placement: s } : s
2441
- ) : typeof r == "string" ? e = [{ placement: r }] : e = [r], e;
2442
- }, Dt = new WeakSet(), qt = function(r) {
2443
- return this.placeData ? this.placeData.filter((e) => !(e.placement === "PAGE_BACKGROUND_WORKER" || !e.handler || e.handler.includes(r))) : [];
2469
+ ) : typeof t == "string" ? e = [{ placement: t }] : e = [t], e;
2470
+ }, kt = new WeakSet(), re = function(t) {
2471
+ return this.placeData ? this.placeData.filter((e) => !(e.placement === "PAGE_BACKGROUND_WORKER" || !e.handler || e.handler.includes(t))) : [];
2444
2472
  };
2445
- class ie {
2446
- constructor(r) {
2447
- w(this, "entityName", "tabs");
2448
- w(this, "maxTabs", 20);
2449
- w(this, "tabList", []);
2450
- w(this, "id", 0);
2451
- w(this, "hasStarted", !1);
2452
- w(this, "heartbeat");
2453
- w(this, "runHeartbeat");
2454
- w(this, "random", this.getRandomNum());
2455
- w(this, "activeMaxPause", 5 * 60 * 1e3 + this.random);
2456
- w(this, "quickCleanupThreshold", 2 * 60 * 1e3);
2473
+ const se = "szdl-utils-kit|";
2474
+ function he() {
2475
+ if (typeof sessionStorage > "u")
2476
+ return `ephemeral-${Date.now()}-${Math.random().toString(16).slice(2)}`;
2477
+ let p = sessionStorage.getItem("szdl-cross-tab-instance-id");
2478
+ return p || (p = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", p)), p;
2479
+ }
2480
+ function ue() {
2481
+ return typeof navigator < "u" && typeof navigator.locks < "u" && typeof navigator.locks.request == "function";
2482
+ }
2483
+ const Ct = /* @__PURE__ */ new Map();
2484
+ function fe(p = "default") {
2485
+ if (typeof BroadcastChannel > "u")
2486
+ return null;
2487
+ const t = `${se}bc:${p}`;
2488
+ return Ct.has(t) || Ct.set(t, new BroadcastChannel(t)), Ct.get(t);
2489
+ }
2490
+ function Xt(p, t) {
2491
+ const e = fe(p);
2492
+ if (e)
2493
+ try {
2494
+ const s = t && typeof t == "object" && !Array.isArray(t) ? t : { data: t };
2495
+ e.postMessage({
2496
+ ...s,
2497
+ tabId: he(),
2498
+ ts: Date.now()
2499
+ });
2500
+ } catch {
2501
+ }
2502
+ }
2503
+ async function me(p, t, e = {}) {
2504
+ const { ifAvailable: s = !1 } = e, i = typeof p == "string" && p.length > 0 ? p : "default", a = `${se}${i}`;
2505
+ return ue() ? navigator.locks.request(
2506
+ a,
2507
+ { mode: "exclusive", ifAvailable: !!s },
2508
+ async (l) => {
2509
+ if (s && l == null)
2510
+ return { skipped: !0, coordination: "locks" };
2511
+ Xt(i, { type: "lock-acquired", resource: i });
2512
+ try {
2513
+ return { skipped: !1, result: await t(), coordination: "locks" };
2514
+ } finally {
2515
+ Xt(i, { type: "lock-released", resource: i });
2516
+ }
2517
+ }
2518
+ ) : { skipped: !1, result: await t(), coordination: "none" };
2519
+ }
2520
+ var mt, xt;
2521
+ class ye {
2522
+ constructor(t) {
2523
+ /**
2524
+ * Канонический base URL для placement (без завершающего `/`).
2525
+ * Пустая строка — не биндить (некорректный или marketplace URL).
2526
+ */
2527
+ D(this, mt);
2528
+ C(this, "entityName", "tabs");
2529
+ C(this, "maxTabs", 20);
2530
+ C(this, "tabList", []);
2531
+ C(this, "id", 0);
2532
+ C(this, "hasStarted", !1);
2533
+ C(this, "heartbeat");
2534
+ C(this, "runHeartbeat");
2535
+ /** Вкладка считается «мёртвой», если нет обновления lastActive дольше этого (см. refreshTabs). */
2536
+ C(this, "activeMaxPause", 10 * 1e3);
2537
+ C(this, "quickCleanupThreshold", 2 * 60 * 1e3);
2457
2538
  // агрессивная очистка при переполнении
2458
- w(this, "pollInterval", (60 + this.random) * 1e3);
2459
- // 30-90 cек для выбора лидера
2460
- w(this, "sessionId", `${Date.now()}-${Math.random().toString(16).slice(2)}`);
2461
- w(this, "continueCondition");
2462
- w(this, "defaultContinueBackground", () => !0);
2463
- var h, A, l;
2464
- if (!r) {
2539
+ /** Должен быть заметно меньше activeMaxPause: иначе «живые» вкладки успеют удалиться до следующего тика. */
2540
+ C(this, "pollInterval", 6 * 1e3 + Math.floor(Math.random() * 2e3));
2541
+ // ~6–8 с + размазать одновременные запросы
2542
+ C(this, "sessionId", `${Date.now()}-${Math.random().toString(16).slice(2)}`);
2543
+ C(this, "continueCondition");
2544
+ C(this, "defaultContinueBackground", () => !0);
2545
+ var l, A, h;
2546
+ if (!t) {
2465
2547
  console.error("BackgroundWorker: Нет опций конструктора");
2466
2548
  return;
2467
2549
  }
2468
- const { appFunc: e, bx: s, users: n, continueBackground: o } = r;
2469
- this.bx = s, this.appInit = e, this.users = n, this.appPath = ((h = s == null ? void 0 : s.appConst) == null ? void 0 : h.pathApp) ?? "", this.appName = ((A = s == null ? void 0 : s.appConst) == null ? void 0 : A.appName) ?? "", this.appCodeName = ((l = s == null ? void 0 : s.appConst) == null ? void 0 : l.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof o == "function" ? o : this.defaultContinueBackground;
2550
+ const { appFunc: e, bx: s, users: i, continueBackground: a } = t;
2551
+ this.bx = s, this.appInit = e, this.users = i, Gt(s), this.appPath = E(this, mt, xt).call(this, ((l = s == null ? void 0 : s.appConst) == null ? void 0 : l.pathApp) ?? ""), this.appName = ((A = s == null ? void 0 : s.appConst) == null ? void 0 : A.appName) ?? "", this.appCodeName = ((h = s == null ? void 0 : s.appConst) == null ? void 0 : h.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
2470
2552
  }
2471
2553
  async init() {
2472
2554
  if (!this.appInit) {
@@ -2498,30 +2580,30 @@ class ie {
2498
2580
  }
2499
2581
  await this.refreshTabs(!0), await this.ensureTabRegistered();
2500
2582
  const e = this.selectLeaderId(), s = e && +this.id == +e;
2501
- await this.updateTabState(s), s && !this.hasStarted && (this.hasStarted = !0, await this.runAsLeader());
2583
+ await this.updateTabState(s), s && !this.hasStarted && await this.runAsLeader();
2502
2584
  }
2503
2585
  stopTimers() {
2504
2586
  this.heartbeat && (clearInterval(this.heartbeat), this.heartbeat = void 0), this.runHeartbeat && (clearInterval(this.runHeartbeat), this.runHeartbeat = void 0);
2505
2587
  }
2506
2588
  isAppPage() {
2507
- var r;
2508
- if (typeof BX24 > "u" || !((r = BX24.placement) != null && r.info))
2589
+ var t;
2590
+ if (typeof BX24 > "u" || !((t = BX24.placement) != null && t.info))
2509
2591
  return !1;
2510
2592
  try {
2511
- const e = BX24.placement.info(), s = e == null ? void 0 : e.placement, n = (e == null ? void 0 : e.options) || {}, o = (n == null ? void 0 : n.URI) || "", h = s === "PAGE_BACKGROUND_WORKER" || (n == null ? void 0 : n.ID) === "PAGE_BACKGROUND_WORKER", A = typeof o == "string" && (o.includes("marketplace/app") || o.includes("marketplace/apps") || o.includes("placement") || o.includes("sozdavatel" + this.appCodeName));
2512
- return !h || A;
2593
+ const e = BX24.placement.info(), s = e == null ? void 0 : e.placement, i = (e == null ? void 0 : e.options) || {}, a = (i == null ? void 0 : i.URI) || "", l = s === "PAGE_BACKGROUND_WORKER" || (i == null ? void 0 : i.ID) === "PAGE_BACKGROUND_WORKER", A = typeof a == "string" && (a.includes("marketplace/app") || a.includes("marketplace/apps") || a.includes("placement") || a.includes("sozdavatel" + this.appCodeName));
2594
+ return !l || A;
2513
2595
  } catch {
2514
2596
  return !1;
2515
2597
  }
2516
2598
  }
2517
2599
  async checkEntity() {
2518
2600
  var s;
2519
- const r = await this.safeCall(
2601
+ const t = await this.safeCall(
2520
2602
  () => this.bx.call({ method: "entity.get" })
2521
2603
  );
2522
- ((s = r == null ? void 0 : r.find) == null ? void 0 : s.call(
2523
- r,
2524
- (n) => n.ENTITY === this.entityName
2604
+ ((s = t == null ? void 0 : t.find) == null ? void 0 : s.call(
2605
+ t,
2606
+ (i) => i.ENTITY === this.entityName
2525
2607
  )) || await this.safeCall(
2526
2608
  () => this.bx.call({
2527
2609
  method: "entity.add",
@@ -2534,7 +2616,7 @@ class ie {
2534
2616
  );
2535
2617
  }
2536
2618
  async getTabs() {
2537
- const r = await this.safeCall(
2619
+ const t = await this.safeCall(
2538
2620
  () => {
2539
2621
  var e;
2540
2622
  return this.bx.call({
@@ -2547,7 +2629,7 @@ class ie {
2547
2629
  });
2548
2630
  }
2549
2631
  );
2550
- return !Array.isArray(r) || !r.length ? [] : r.map((e) => {
2632
+ return !Array.isArray(t) || !t.length ? [] : t.map((e) => {
2551
2633
  if (!e)
2552
2634
  return { id: void 0, data: void 0 };
2553
2635
  try {
@@ -2565,7 +2647,7 @@ class ie {
2565
2647
  return console.log(
2566
2648
  "BackgroundWorker: Достигнут лимит вкладок даже после быстрой очистки, не регистрируемся"
2567
2649
  ), 0;
2568
- const r = {
2650
+ const t = {
2569
2651
  lastActive: (/* @__PURE__ */ new Date()).toISOString(),
2570
2652
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2571
2653
  start: !1,
@@ -2578,20 +2660,20 @@ class ie {
2578
2660
  params: {
2579
2661
  ENTITY: this.entityName,
2580
2662
  NAME: (s = this.bx.userInfo) == null ? void 0 : s.ID,
2581
- DETAIL_TEXT: JSON.stringify(r)
2663
+ DETAIL_TEXT: JSON.stringify(t)
2582
2664
  }
2583
2665
  });
2584
2666
  }
2585
2667
  ) || 0;
2586
2668
  return this.id = +e || 0, this.id;
2587
2669
  }
2588
- async updateTabState(r) {
2670
+ async updateTabState(t) {
2589
2671
  if (!this.id)
2590
2672
  return;
2591
2673
  const e = {
2592
2674
  lastActive: (/* @__PURE__ */ new Date()).toISOString(),
2593
2675
  createdAt: this.start.toISOString(),
2594
- start: r,
2676
+ start: t,
2595
2677
  sessionId: this.sessionId
2596
2678
  };
2597
2679
  await this.safeCall(
@@ -2609,21 +2691,17 @@ class ie {
2609
2691
  }
2610
2692
  );
2611
2693
  }
2612
- async deleteTabs(r = []) {
2613
- if (!r.length)
2694
+ async deleteTabs(t = []) {
2695
+ if (!t.length)
2614
2696
  return;
2615
- const e = r.map((s) => ({
2697
+ const e = t.map((s) => ({
2616
2698
  method: "entity.item.delete",
2617
2699
  params: { ENTITY: this.entityName, ID: s.id }
2618
2700
  }));
2619
2701
  await this.safeCall(() => this.bx.batch(e));
2620
2702
  }
2621
- getRandomNum() {
2622
- const r = Math.round(Number(Math.random().toFixed(2)) * 30);
2623
- return Math.round(Math.random()) ? r : -r;
2624
- }
2625
2703
  async checkPlacementType() {
2626
- var r;
2704
+ var t;
2627
2705
  try {
2628
2706
  const e = await this.safeCall(
2629
2707
  () => this.bx.getPlacement()
@@ -2632,24 +2710,24 @@ class ie {
2632
2710
  return console.log(
2633
2711
  "BackgroundWorker: Не получили список размещений, продолжаем"
2634
2712
  ), !0;
2635
- const s = +(((r = this.bx.userInfo) == null ? void 0 : r.ID) ?? 0), n = this.isIndividualPlacement(
2713
+ const s = +(((t = this.bx.userInfo) == null ? void 0 : t.ID) ?? 0), i = this.isIndividualPlacement(
2636
2714
  typeof window < "u" ? window.location.href : ""
2637
- ), o = !n;
2715
+ ), a = !i;
2638
2716
  if (!s)
2639
2717
  return !0;
2640
- let h = !1;
2718
+ let l = !1;
2641
2719
  for (const A of e) {
2642
2720
  if (A.placement !== "PAGE_BACKGROUND_WORKER" || !(A.userId || A.handler && A.handler.includes("USER_ID=")))
2643
2721
  continue;
2644
- const i = A.userId || (A.handler ? this.extractUserIdFromHandler(A.handler) : null);
2645
- if (i && +i === s) {
2646
- h = !0;
2722
+ const n = A.userId || (A.handler ? this.extractUserIdFromHandler(A.handler) : null);
2723
+ if (n && +n === s) {
2724
+ l = !0;
2647
2725
  break;
2648
2726
  }
2649
2727
  }
2650
- return n ? (console.log(
2728
+ return i ? (console.log(
2651
2729
  "BackgroundWorker: Индивидуальная встройка - разрешено"
2652
- ), !0) : o && h ? (console.log(
2730
+ ), !0) : a && l ? (console.log(
2653
2731
  "BackgroundWorker: Есть личная встройка, общую не запускаем"
2654
2732
  ), !1) : (console.log(
2655
2733
  "BackgroundWorker: Проверка типа встройки пройдена, продолжаем"
@@ -2661,13 +2739,13 @@ class ie {
2661
2739
  ), !0;
2662
2740
  }
2663
2741
  }
2664
- isIndividualPlacement(r) {
2665
- return !r || typeof r != "string" ? !1 : r.includes("USER_ID=");
2742
+ isIndividualPlacement(t) {
2743
+ return !t || typeof t != "string" ? !1 : t.includes("USER_ID=");
2666
2744
  }
2667
- extractUserIdFromHandler(r) {
2668
- if (!r || typeof r != "string")
2745
+ extractUserIdFromHandler(t) {
2746
+ if (!t || typeof t != "string")
2669
2747
  return null;
2670
- const e = r.match(/USER_ID=(\d+)/);
2748
+ const e = t.match(/USER_ID=(\d+)/);
2671
2749
  return e ? +e[1] : null;
2672
2750
  }
2673
2751
  async continueBackground() {
@@ -2676,209 +2754,231 @@ class ie {
2676
2754
  this.continueCondition(this)
2677
2755
  );
2678
2756
  return console.log(e ? "BackgroundWorker: Условие продолжения выполнено" : "BackgroundWorker: continueBackground вернул false"), e;
2679
- } catch (r) {
2757
+ } catch (t) {
2680
2758
  return console.error(
2681
2759
  "BackgroundWorker: Ошибка в continueCondition",
2682
- r
2760
+ t
2683
2761
  ), !1;
2684
2762
  }
2685
2763
  }
2686
- async refreshTabs(r = !1, e = this.activeMaxPause) {
2687
- const s = [], n = [], o = Date.now(), h = await this.getTabs();
2688
- for (const A of h) {
2764
+ async refreshTabs(t = !1, e = this.activeMaxPause) {
2765
+ const s = [], i = [], a = Date.now(), l = await this.getTabs();
2766
+ for (const A of l) {
2689
2767
  if (!(A != null && A.data)) {
2690
2768
  s.push(A);
2691
2769
  continue;
2692
2770
  }
2693
- if (o - new Date(A.data.lastActive || 0).getTime() > e) {
2771
+ if (a - new Date(A.data.lastActive || 0).getTime() > e) {
2694
2772
  s.push(A);
2695
2773
  continue;
2696
2774
  }
2697
- n.push(A);
2775
+ i.push(A);
2698
2776
  }
2699
- return r && s.length && await this.deleteTabs(s), this.tabList = n, n;
2777
+ return t && s.length && await this.deleteTabs(s), this.tabList = i, i;
2700
2778
  }
2701
2779
  selectLeaderId() {
2702
2780
  var e;
2703
- return this.tabList.length && +((e = [...this.tabList].sort((s, n) => {
2704
- var A, l, i, u;
2705
- const o = new Date(
2706
- ((A = s.data) == null ? void 0 : A.createdAt) || ((l = s.data) == null ? void 0 : l.lastActive) || 0
2707
- ).getTime(), h = new Date(
2708
- ((i = n.data) == null ? void 0 : i.createdAt) || ((u = n.data) == null ? void 0 : u.lastActive) || 0
2781
+ return this.tabList.length && +((e = [...this.tabList].sort((s, i) => {
2782
+ var A, h, n, u;
2783
+ const a = new Date(
2784
+ ((A = s.data) == null ? void 0 : A.createdAt) || ((h = s.data) == null ? void 0 : h.lastActive) || 0
2785
+ ).getTime(), l = new Date(
2786
+ ((n = i.data) == null ? void 0 : n.createdAt) || ((u = i.data) == null ? void 0 : u.lastActive) || 0
2709
2787
  ).getTime();
2710
- return o === h ? (+s.id || 0) - (+n.id || 0) : o - h;
2788
+ return a === l ? (+s.id || 0) - (+i.id || 0) : a - l;
2711
2789
  })[0]) == null ? void 0 : e.id) || 0;
2712
2790
  }
2713
2791
  async runAsLeader() {
2714
- this.runHeartbeat = setInterval(
2715
- () => {
2716
- this.updateTabState(!0).catch(
2717
- (r) => console.error(
2718
- "BackgroundWorker: heartbeat update failed",
2719
- r
2720
- )
2792
+ var i, a;
2793
+ const t = String(((a = (i = this.bx) == null ? void 0 : i.userInfo) == null ? void 0 : a.ID) ?? "0"), e = `background-worker:${this.entityName}:${t}`;
2794
+ (await me(
2795
+ e,
2796
+ async () => {
2797
+ this.hasStarted = !0;
2798
+ const l = Math.min(
2799
+ this.activeMaxPause - 1500,
2800
+ Math.max(2500, Math.floor(this.pollInterval / 2))
2721
2801
  );
2802
+ this.runHeartbeat = setInterval(
2803
+ () => {
2804
+ this.updateTabState(!0).catch(
2805
+ (A) => console.error(
2806
+ "BackgroundWorker: heartbeat update failed",
2807
+ A
2808
+ )
2809
+ );
2810
+ },
2811
+ l
2812
+ );
2813
+ try {
2814
+ await this.appInit();
2815
+ } catch (A) {
2816
+ console.error("BackgroundWorker: appInit failed", A);
2817
+ }
2818
+ this.stopTimers(), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
2722
2819
  },
2723
- Math.max(20 * 1e3, Math.floor(this.pollInterval / 2))
2820
+ { ifAvailable: !0 }
2821
+ )).skipped && console.log(
2822
+ "BackgroundWorker: runAsLeader пропущен — Web Lock у другой вкладки (тот же фоновый воркер)"
2724
2823
  );
2725
- try {
2726
- await this.appInit();
2727
- } catch (r) {
2728
- console.error("BackgroundWorker: appInit failed", r);
2729
- }
2730
- this.stopTimers(), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
2731
2824
  }
2732
2825
  async setBackgroundWorkerAll() {
2733
- var O, _;
2734
- if (!((O = this.bx) != null && O.isAdmin)) {
2826
+ var T, _, R, N;
2827
+ if (!((T = this.bx) != null && T.isAdmin)) {
2735
2828
  console.log(
2736
2829
  "BackgroundWorker: setBackgroundWorkerAll доступен только админам"
2737
2830
  );
2738
2831
  return;
2739
2832
  }
2740
- (_ = this.users) != null && _.length || await this.getEntityData();
2741
- const r = await this.safeCall(
2833
+ (_ = this.users) != null && _.length || await this.getEntityData(), Gt(this.bx);
2834
+ const t = E(this, mt, xt).call(this, ((N = (R = this.bx) == null ? void 0 : R.appConst) == null ? void 0 : N.pathApp) ?? "");
2835
+ if (!t) {
2836
+ console.error(
2837
+ "BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
2838
+ );
2839
+ return;
2840
+ }
2841
+ const e = await this.safeCall(
2742
2842
  () => this.bx.getPlacement()
2743
- ), e = /* @__PURE__ */ new Map();
2744
- let s = null;
2745
- (r || []).forEach((m) => {
2746
- if (m.placement !== "PAGE_BACKGROUND_WORKER")
2843
+ ), s = /* @__PURE__ */ new Map();
2844
+ let i = null;
2845
+ (e || []).forEach((y) => {
2846
+ if (y.placement !== "PAGE_BACKGROUND_WORKER")
2747
2847
  return;
2748
- if (m.userId || m.handler && m.handler.includes("USER_ID=")) {
2749
- const p = m.userId || (m.handler ? this.extractUserIdFromHandler(m.handler) : null);
2750
- p && e.set(+p, m);
2848
+ if (y.userId || y.handler && y.handler.includes("USER_ID=")) {
2849
+ const I = y.userId || (y.handler ? this.extractUserIdFromHandler(y.handler) : null);
2850
+ I && s.set(+I, y);
2751
2851
  } else
2752
- s = m;
2852
+ i = y;
2753
2853
  });
2754
- const n = await this.resolveAdmins(), o = await this.getEligibleUsersForBackgroundWorker(n);
2755
- o.sort((m, N) => {
2756
- const p = m.LAST_LOGIN ? new Date(m.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
2757
- return (N.LAST_LOGIN ? new Date(N.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - p;
2854
+ const a = await this.resolveAdmins(), l = await this.getEligibleUsersForBackgroundWorker(a);
2855
+ l.sort((y, L) => {
2856
+ const I = y.LAST_LOGIN ? new Date(y.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
2857
+ return (L.LAST_LOGIN ? new Date(L.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - I;
2758
2858
  });
2759
- const h = 10, A = o.slice(0, h), l = A.filter((m) => {
2760
- const N = e.get(+m.ID);
2761
- if (!N)
2859
+ const A = 10, h = l.slice(0, A), n = h.filter((y) => {
2860
+ const L = s.get(+y.ID);
2861
+ if (!L)
2762
2862
  return !0;
2763
- const p = `${this.appPath}?USER_ID=${m.ID}/`;
2764
- return N.handler !== p;
2765
- }), i = [];
2766
- for (const [m] of e) {
2767
- const N = +m || 0;
2768
- o.find((T) => +T.ID === N) || i.push(N);
2863
+ const I = `${t}?USER_ID=${y.ID}/`;
2864
+ return L.handler !== I;
2865
+ }), u = [];
2866
+ for (const [y] of s) {
2867
+ const L = +y || 0;
2868
+ l.find((H) => +H.ID === L) || u.push(L);
2769
2869
  }
2770
- for (const m of A) {
2771
- const N = e.get(+m.ID);
2772
- if (!N)
2870
+ for (const y of h) {
2871
+ const L = s.get(+y.ID);
2872
+ if (!L)
2773
2873
  continue;
2774
- const p = `${this.appPath}?USER_ID=${m.ID}/`;
2775
- N.handler !== p && i.push(+m.ID);
2874
+ const I = `${t}?USER_ID=${y.ID}/`;
2875
+ L.handler !== I && u.push(+y.ID);
2776
2876
  }
2777
- const u = [];
2778
- for (const m of i)
2779
- this.appPath && u.push({
2877
+ const m = [];
2878
+ for (const y of u)
2879
+ m.push({
2780
2880
  method: "placement.unbind",
2781
2881
  params: {
2782
2882
  PLACEMENT: "PAGE_BACKGROUND_WORKER",
2783
- HANDLER: `${this.appPath}?USER_ID=${m}/`
2883
+ HANDLER: `${t}?USER_ID=${y}/`
2784
2884
  }
2785
2885
  });
2786
- const y = s && (l.length > 0 || s.handler !== `${this.appPath}`);
2787
- y && this.appPath && u.push({
2886
+ const c = i && (n.length > 0 || i.handler !== `${t}`);
2887
+ c && m.push({
2788
2888
  method: "placement.unbind",
2789
2889
  params: {
2790
2890
  PLACEMENT: "PAGE_BACKGROUND_WORKER",
2791
- HANDLER: s.handler || `${this.appPath}`
2891
+ HANDLER: i.handler || `${t}`
2792
2892
  }
2793
2893
  });
2794
- for (const m of l)
2795
- this.appPath && u.push({
2894
+ for (const y of n)
2895
+ m.push({
2796
2896
  method: "placement.bind",
2797
2897
  params: {
2798
2898
  PLACEMENT: "PAGE_BACKGROUND_WORKER",
2799
- HANDLER: `${this.appPath}?USER_ID=${m.ID}/`,
2899
+ HANDLER: `${t}?USER_ID=${y.ID}/`,
2800
2900
  LANG_ALL: { ru: { TITLE: this.appName } },
2801
2901
  OPTIONS: {
2802
- errorHandlerUrl: `${this.appPath}?USER_ID=${m.ID}/`
2902
+ errorHandlerUrl: `${t}?USER_ID=${y.ID}/`
2803
2903
  },
2804
- USER_ID: m.ID
2904
+ USER_ID: y.ID
2805
2905
  }
2806
2906
  });
2807
- (!s || y) && this.appPath && u.push({
2907
+ (!i || c) && m.push({
2808
2908
  method: "placement.bind",
2809
2909
  params: {
2810
2910
  PLACEMENT: "PAGE_BACKGROUND_WORKER",
2811
- HANDLER: `${this.appPath}`,
2911
+ HANDLER: `${t}`,
2812
2912
  LANG_ALL: { ru: { TITLE: this.appName } },
2813
- OPTIONS: { errorHandlerUrl: `${this.appPath}` }
2913
+ OPTIONS: { errorHandlerUrl: `${t}` }
2814
2914
  }
2815
2915
  });
2816
- const c = u.filter(
2817
- (m) => m.method === "placement.unbind"
2818
- ), f = u.filter(
2819
- (m) => m.method === "placement.bind"
2916
+ const f = m.filter(
2917
+ (y) => y.method === "placement.unbind"
2918
+ ), O = m.filter(
2919
+ (y) => y.method === "placement.bind"
2820
2920
  );
2821
- c.length && await this.safeCall(
2921
+ f.length && await this.safeCall(
2822
2922
  () => this.bx.batch(
2823
2923
  Object.fromEntries(
2824
- c.map((m, N) => [`unbind_${N}`, m])
2924
+ f.map((y, L) => [`unbind_${L}`, y])
2825
2925
  )
2826
2926
  )
2827
- ), f.length && await this.safeCall(
2927
+ ), O.length && await this.safeCall(
2828
2928
  () => this.bx.batch(
2829
2929
  Object.fromEntries(
2830
- f.map((m, N) => [`bind_${N}`, m])
2930
+ O.map((y, L) => [`bind_${L}`, y])
2831
2931
  )
2832
2932
  )
2833
- ), u.length || console.log("setBackgroundWorkerAll: Нет операций");
2933
+ ), m.length || console.log("setBackgroundWorkerAll: Нет операций");
2834
2934
  }
2835
2935
  async resolveAdmins() {
2836
- var r, e;
2936
+ var t, e;
2837
2937
  try {
2838
- const s = +(((r = this.bx.userInfo) == null ? void 0 : r.ID) ?? 0), n = !!((e = this.bx) != null && e.isAdmin), o = await this.getAdminsList() || [];
2839
- if (!n) {
2840
- if (s && o.includes(+s)) {
2841
- const l = o.filter(
2842
- (i) => +i != +s
2938
+ const s = +(((t = this.bx.userInfo) == null ? void 0 : t.ID) ?? 0), i = !!((e = this.bx) != null && e.isAdmin), a = await this.getAdminsList() || [];
2939
+ if (!i) {
2940
+ if (s && a.includes(+s)) {
2941
+ const h = a.filter(
2942
+ (n) => +n != +s
2843
2943
  );
2844
- return await this.saveAdminsList(l), l;
2944
+ return await this.saveAdminsList(h), h;
2845
2945
  }
2846
- return o;
2946
+ return a;
2847
2947
  }
2848
- const h = /* @__PURE__ */ new Set([...o || []]);
2849
- s && h.add(+s);
2850
- const A = [...h].filter(Boolean);
2948
+ const l = /* @__PURE__ */ new Set([...a || []]);
2949
+ s && l.add(+s);
2950
+ const A = [...l].filter(Boolean);
2851
2951
  return await this.saveAdminsList(A), A;
2852
2952
  } catch (s) {
2853
2953
  return console.error("BackgroundWorker: resolveAdmins error", s), [];
2854
2954
  }
2855
2955
  }
2856
- async getEligibleUsersForBackgroundWorker(r = []) {
2956
+ async getEligibleUsersForBackgroundWorker(t = []) {
2857
2957
  const e = (this.users ?? []).filter(
2858
- (n) => n.ACTIVE === "Y" || n.ACTIVE === !0
2859
- ), s = r.map((n) => +n || 0).filter(Boolean);
2860
- return e.filter((n) => s.includes(+n.ID || 0));
2958
+ (i) => i.ACTIVE === "Y" || i.ACTIVE === !0
2959
+ ), s = t.map((i) => +i || 0).filter(Boolean);
2960
+ return e.filter((i) => s.includes(+i.ID || 0));
2861
2961
  }
2862
- async saveAdminsList(r = []) {
2962
+ async saveAdminsList(t = []) {
2863
2963
  try {
2864
- BX24.appOption.set("adminsList", JSON.stringify(r));
2964
+ BX24.appOption.set("adminsList", JSON.stringify(t));
2865
2965
  } catch (e) {
2866
2966
  console.error("BackgroundWorker: saveAdminsList error", e);
2867
2967
  }
2868
2968
  }
2869
2969
  async getAdminsList() {
2870
2970
  try {
2871
- const r = BX24.appOption.get("adminsList"), e = r ? JSON.parse(r) : [];
2971
+ const t = BX24.appOption.get("adminsList"), e = t ? JSON.parse(t) : [];
2872
2972
  return Array.isArray(e) ? e.map((s) => +s || 0).filter(Boolean) : [];
2873
- } catch (r) {
2874
- return console.error("BackgroundWorker: getAdminsList error", r), [];
2973
+ } catch (t) {
2974
+ return console.error("BackgroundWorker: getAdminsList error", t), [];
2875
2975
  }
2876
2976
  }
2877
2977
  async getEntityData() {
2878
- const r = {
2978
+ const t = {
2879
2979
  users: { method: "user.get", params: { filter: { ACTIVE: "Y" } } }
2880
2980
  }, { users: e } = await this.safeCall(
2881
- () => this.bx.batch(r).then((s) => s ? (Array.isArray(s.users) || (s.users = []), s) : { users: [] })
2981
+ () => this.bx.batch(t).then((s) => s ? (Array.isArray(s.users) || (s.users = []), s) : { users: [] })
2882
2982
  );
2883
2983
  this.users = e;
2884
2984
  }
@@ -2887,30 +2987,38 @@ class ie {
2887
2987
  * (общая и индивидуальные) и что список пользователей подгружен.
2888
2988
  */
2889
2989
  async ensureAdminPlacements() {
2890
- var r, e;
2891
- (r = this.bx) != null && r.isAdmin && ((e = this.users) != null && e.length || await this.getEntityData(), await this.setBackgroundWorkerAll());
2990
+ var t, e;
2991
+ (t = this.bx) != null && t.isAdmin && ((e = this.users) != null && e.length || await this.getEntityData(), await this.setBackgroundWorkerAll());
2892
2992
  }
2893
- pause(r = 500, e) {
2993
+ pause(t = 500, e) {
2894
2994
  return new Promise((s) => {
2895
2995
  setTimeout(() => {
2896
2996
  e && e(), s(!0);
2897
- }, r);
2997
+ }, t);
2898
2998
  });
2899
2999
  }
2900
- async safeCall(r) {
3000
+ async safeCall(t) {
2901
3001
  try {
2902
- return await r();
3002
+ return await t();
2903
3003
  } catch (e) {
2904
3004
  console.error("BackgroundWorker: safeCall error", e);
2905
3005
  return;
2906
3006
  }
2907
3007
  }
2908
3008
  }
3009
+ mt = new WeakSet(), xt = function(t) {
3010
+ if (!t || typeof t != "string")
3011
+ return "";
3012
+ const e = Ft(t).replace(/\/+$/, "");
3013
+ return e ? $t(e) ? (console.error(
3014
+ "BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
3015
+ ), "") : e : "";
3016
+ };
2909
3017
  export {
2910
- ie as BackgroundWorker,
3018
+ ye as BackgroundWorker,
2911
3019
  v as Batch,
2912
- se as BxBoot,
2913
- Ft as BxHelper,
2914
- ee as BxLogger,
2915
- mt as tempus
3020
+ ge as BxBoot,
3021
+ zt as BxHelper,
3022
+ ce as BxLogger,
3023
+ dt as tempus
2916
3024
  };