szdl-utils-kit 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var S = (N, e, r) => (pt(N, typeof e != "symbol" ? e + "" : e, r), r), at = (N,
4
4
  if (!e.has(N))
5
5
  throw TypeError("Cannot " + r);
6
6
  };
7
- var p = (N, e, r) => (at(N, e, "read from private field"), r ? r.call(N) : e.get(N)), H = (N, e, r) => {
7
+ var p = (N, e, r) => (at(N, e, "read from private field"), r ? r.call(N) : e.get(N)), w = (N, e, r) => {
8
8
  if (e.has(N))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
10
  e instanceof WeakSet ? e.add(N) : e.set(N, r);
@@ -18,37 +18,37 @@ var lt = { exports: {} };
18
18
  (function(N, e) {
19
19
  (function(r) {
20
20
  Array.prototype.indexOf || (Array.prototype.indexOf = function(t, n) {
21
- var l, f;
22
- for (l = n || 0, f = this.length; l < f; l += 1)
23
- if (this[l] === t)
24
- return l;
21
+ var c, f;
22
+ for (c = n || 0, f = this.length; c < f; c += 1)
23
+ if (this[c] === t)
24
+ return c;
25
25
  return -1;
26
26
  });
27
27
  var i = this, A = function(t, n) {
28
- for (var l = t.toString(); l.length < n; )
29
- l = "0" + l;
30
- return l;
28
+ for (var c = t.toString(); c.length < n; )
29
+ c = "0" + c;
30
+ return c;
31
31
  }, o = function(t, n) {
32
32
  return n !== r ? (t.year(n.year() || n.year), t.month(n.month() || n.month), t.day(n.day() || n.day), t.hours(n.hours() || n.hours), t.minutes(n.minutes() || n.minutes), t.seconds(n.seconds() || n.seconds), t.milliseconds(n.milliseconds() || n.milliseconds), t) : r;
33
33
  }, h = function(t, n) {
34
- var l, f = "";
35
- return l = t.slice(n, n + 1), l !== "" && !isNaN(Number(l)) && (f += "%H"), l = t.charAt(n + 2), l !== "" && l === ":" && (f += l), l = t.slice(n + 3, n + 4), l !== "" && !isNaN(Number(l)) && (f += "%M"), l = t.charAt(n + 5), l !== "" && l === ":" && (f += l), l = t.slice(n + 6, n + 7), l !== "" && !isNaN(Number(l)) && (f += "%S"), f;
34
+ var c, f = "";
35
+ return c = t.slice(n, n + 1), c !== "" && !isNaN(Number(c)) && (f += "%H"), c = t.charAt(n + 2), c !== "" && c === ":" && (f += c), c = t.slice(n + 3, n + 4), c !== "" && !isNaN(Number(c)) && (f += "%M"), c = t.charAt(n + 5), c !== "" && c === ":" && (f += c), c = t.slice(n + 6, n + 7), c !== "" && !isNaN(Number(c)) && (f += "%S"), f;
36
36
  }, m = function(t, n) {
37
- var l, f = [
37
+ var c, f = [
38
38
  t.slice(n, n + 1),
39
39
  t.charAt(n + 2),
40
40
  t.slice(n + 3, n + 4),
41
41
  t.charAt(n + 5),
42
42
  t.slice(n + 6, n + 9)
43
43
  ], L;
44
- return !isNaN(Number(f[0])) && !isNaN(Number(f[2])) && !isNaN(Number(f[4])) ? (f[1] === "." && f[3] === "." ? l = "%d.%m.%Y" : f[1] === "-" && f[3] === "-" ? l = "%m-%d-%Y" : f[1] === "/" && f[3] === "/" && (l = "%m/%d/%Y"), l) : (L = [
44
+ return !isNaN(Number(f[0])) && !isNaN(Number(f[2])) && !isNaN(Number(f[4])) ? (f[1] === "." && f[3] === "." ? c = "%d.%m.%Y" : f[1] === "-" && f[3] === "-" ? c = "%m-%d-%Y" : f[1] === "/" && f[3] === "/" && (c = "%m/%d/%Y"), c) : (L = [
45
45
  t.slice(n, n + 3),
46
46
  t.charAt(n + 4),
47
47
  t.slice(n + 5, n + 6),
48
48
  t.charAt(n + 7),
49
49
  t.slice(n + 8, n + 9)
50
- ], !isNaN(Number(L[0])) && !isNaN(Number(L[2])) && !isNaN(Number(L[4])) ? (L[1] === "-" && L[3] === "-" && (l = "%Y-%m-%d"), l) : "");
51
- }, u = i.tempus, s, d, g = i.navigator || {}, a = "en", c = {
50
+ ], !isNaN(Number(L[0])) && !isNaN(Number(L[2])) && !isNaN(Number(L[4])) ? (L[1] === "-" && L[3] === "-" && (c = "%Y-%m-%d"), c) : "");
51
+ }, l = i.tempus, s, d, g = i.navigator || {}, a = "en", u = {
52
52
  en: {
53
53
  JANUARY_SHORT: "Jan",
54
54
  FEBRUARY_SHORT: "Feb",
@@ -211,59 +211,59 @@ var lt = { exports: {} };
211
211
  }
212
212
  }, y = function() {
213
213
  return [
214
- c[a].JANUARY_LONG,
215
- c[a].FEBRUARY_LONG,
216
- c[a].MARCH_LONG,
217
- c[a].APRIL_LONG,
218
- c[a].MAY_LONG,
219
- c[a].JUNE_LONG,
220
- c[a].JULY_LONG,
221
- c[a].AUGUST_LONG,
222
- c[a].SEPTEMBER_LONG,
223
- c[a].OCTOBER_LONG,
224
- c[a].NOVEMBER_LONG,
225
- c[a].DECEMBER_LONG
214
+ u[a].JANUARY_LONG,
215
+ u[a].FEBRUARY_LONG,
216
+ u[a].MARCH_LONG,
217
+ u[a].APRIL_LONG,
218
+ u[a].MAY_LONG,
219
+ u[a].JUNE_LONG,
220
+ u[a].JULY_LONG,
221
+ u[a].AUGUST_LONG,
222
+ u[a].SEPTEMBER_LONG,
223
+ u[a].OCTOBER_LONG,
224
+ u[a].NOVEMBER_LONG,
225
+ u[a].DECEMBER_LONG
226
226
  ];
227
227
  }, O = function() {
228
228
  return [
229
- c[a].JANUARY_SHORT,
230
- c[a].FEBRUARY_SHORT,
231
- c[a].MARCH_SHORT,
232
- c[a].APRIL_SHORT,
233
- c[a].MAY_SHORT,
234
- c[a].JUNE_SHORT,
235
- c[a].JULY_SHORT,
236
- c[a].AUGUST_SHORT,
237
- c[a].SEPTEMBER_SHORT,
238
- c[a].OCTOBER_SHORT,
239
- c[a].NOVEMBER_SHORT,
240
- c[a].DECEMBER_SHORT
229
+ u[a].JANUARY_SHORT,
230
+ u[a].FEBRUARY_SHORT,
231
+ u[a].MARCH_SHORT,
232
+ u[a].APRIL_SHORT,
233
+ u[a].MAY_SHORT,
234
+ u[a].JUNE_SHORT,
235
+ u[a].JULY_SHORT,
236
+ u[a].AUGUST_SHORT,
237
+ u[a].SEPTEMBER_SHORT,
238
+ u[a].OCTOBER_SHORT,
239
+ u[a].NOVEMBER_SHORT,
240
+ u[a].DECEMBER_SHORT
241
241
  ];
242
242
  }, R = function() {
243
243
  return [
244
- c[a].SUNDAY_LONG,
245
- c[a].MONDAY_LONG,
246
- c[a].TUESDAY_LONG,
247
- c[a].WEDNESDAY_LONG,
248
- c[a].THURSDAY_LONG,
249
- c[a].FRIDAY_LONG,
250
- c[a].SATURDAY_LONG
244
+ u[a].SUNDAY_LONG,
245
+ u[a].MONDAY_LONG,
246
+ u[a].TUESDAY_LONG,
247
+ u[a].WEDNESDAY_LONG,
248
+ u[a].THURSDAY_LONG,
249
+ u[a].FRIDAY_LONG,
250
+ u[a].SATURDAY_LONG
251
251
  ];
252
252
  }, G = function() {
253
253
  return [
254
- c[a].SUNDAY_SHORT,
255
- c[a].MONDAY_SHORT,
256
- c[a].TUESDAY_SHORT,
257
- c[a].WEDNESDAY_SHORT,
258
- c[a].THURSDAY_SHORT,
259
- c[a].FRIDAY_SHORT,
260
- c[a].SATURDAY_SHORT
254
+ u[a].SUNDAY_SHORT,
255
+ u[a].MONDAY_SHORT,
256
+ u[a].TUESDAY_SHORT,
257
+ u[a].WEDNESDAY_SHORT,
258
+ u[a].THURSDAY_SHORT,
259
+ u[a].FRIDAY_SHORT,
260
+ u[a].SATURDAY_SHORT
261
261
  ];
262
- }, P, w, I, M, q = function(t, n, l) {
262
+ }, P, H, I, M, q = function(t, n, c) {
263
263
  var f;
264
264
  i.XMLHttpRequest ? f = new XMLHttpRequest() : f = new ActiveXObject("Microsoft.XMLHTTP"), f.onreadystatechange = function() {
265
265
  f.readyState === 4 && (f.status === 200 ? n && (i.JSON === r ? alert(`Please, include json2 into your project if you want use old browsers!
266
- https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.parse(f.responseText))) : l && l(f));
266
+ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.parse(f.responseText))) : c && c(f));
267
267
  }, f.open("GET", t, !1), f.send();
268
268
  }, B = {
269
269
  "%d": {
@@ -340,7 +340,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
340
340
  "%b": {
341
341
  format: function(t) {
342
342
  var n = s.options("monthFromZero") ? t.month() : t.month() - 1;
343
- return w[n !== r ? n : s.MIN_MONTH];
343
+ return H[n !== r ? n : s.MIN_MONTH];
344
344
  },
345
345
  parse: function(t) {
346
346
  var n = s.monthNames().indexOf(t) + (s.options("monthFromZero") ? 0 : 1);
@@ -415,10 +415,10 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
415
415
  return A(t.year() || s.MIN_YEAR, 4) + "-" + A(t.month() || s.MIN_MONTH, 2) + "-" + A(t.day() || s.MIN_DAY, 2);
416
416
  },
417
417
  parse: function(t) {
418
- var n = Number(t.slice(0, 4)), l = Number(t.slice(5, 7)), f = Number(t.slice(8, 10));
418
+ var n = Number(t.slice(0, 4)), c = Number(t.slice(5, 7)), f = Number(t.slice(8, 10));
419
419
  return {
420
420
  year: n,
421
- month: l,
421
+ month: c,
422
422
  day: f
423
423
  };
424
424
  },
@@ -431,11 +431,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
431
431
  return A(t.month() || s.MIN_MONTH, 2) + "/" + A(t.day() || s.MIN_DAY, 2) + "/" + A(t.year() || s.MIN_YEAR, 4);
432
432
  },
433
433
  parse: function(t) {
434
- var n = Number(t.slice(0, 2)), l = Number(t.slice(3, 5)), f = Number(t.slice(6, 10));
434
+ var n = Number(t.slice(0, 2)), c = Number(t.slice(3, 5)), f = Number(t.slice(6, 10));
435
435
  return {
436
436
  year: f,
437
437
  month: n,
438
- day: l
438
+ day: c
439
439
  };
440
440
  },
441
441
  minLength: 10,
@@ -446,7 +446,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
446
446
  useMilliseconds: !1,
447
447
  monthFromZero: !1
448
448
  }, E;
449
- E = function(t, n, l) {
449
+ E = function(t, n, c) {
450
450
  return this._d = /* @__PURE__ */ new Date(), this._i = {
451
451
  year: !1,
452
452
  month: !1,
@@ -455,7 +455,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
455
455
  minutes: !1,
456
456
  seconds: !1,
457
457
  milliseconds: !1
458
- }, t !== r && this.set(t, n, l), this;
458
+ }, t !== r && this.set(t, n, c), this;
459
459
  }, E.fn = E.prototype, E.fn.dayCount = function() {
460
460
  var t = this.month(), n = s.MAX_DAY_IN_MONTHS[t - (s.options("monthFromZero") ? 0 : 1)];
461
461
  return this.leapYear() && t === (s.options("monthFromZero") ? 1 : 2) && (n += 1), n;
@@ -504,7 +504,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
504
504
  }, E.fn.week = function() {
505
505
  var t = new Date(this.year(), 0, 1), n = s(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
506
506
  return Math.ceil(((n - t.getTime()) / 864e5 + t.getDay() + 1) / 7);
507
- }, E.fn.set = function(t, n, l) {
507
+ }, E.fn.set = function(t, n, c) {
508
508
  if (this._i = {
509
509
  year: !1,
510
510
  month: !1,
@@ -522,7 +522,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
522
522
  if (typeof t == "object" && (t instanceof Array ? (this.day(s.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(s.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
523
  var f, L = [], _, T, J = [], Y = 0, U = 0, b, W, D = {}, k;
524
524
  if (t === r)
525
- return _ = o(this, l), _ === r && (this._i = {
525
+ return _ = o(this, c), _ === r && (this._i = {
526
526
  year: -1,
527
527
  month: -1,
528
528
  day: -1,
@@ -549,7 +549,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
549
549
  break;
550
550
  }
551
551
  if (b < B[T].minLength)
552
- return _ = o(this, l), _ === r && (this._i = {
552
+ return _ = o(this, c), _ === r && (this._i = {
553
553
  year: -1,
554
554
  month: -1,
555
555
  day: -1,
@@ -561,7 +561,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
561
561
  L.push(T), J.push(W), b -= 1, U += b, Y += 1;
562
562
  }
563
563
  } else if (t.charAt(U) !== n.charAt(Y))
564
- return _ = o(this, l), _ === r && (this._i = {
564
+ return _ = o(this, c), _ === r && (this._i = {
565
565
  year: -1,
566
566
  month: -1,
567
567
  day: -1,
@@ -671,35 +671,35 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
671
671
  };
672
672
  }
673
673
  }, E.fn.format = function(t) {
674
- for (var n = 0, l = "", f; n < t.length; )
675
- t.charAt(n) === "%" ? (f = t.charAt(n) + t.charAt(n + 1), B[f] !== r ? (l += B[f].format(this), n += 1) : l += "%") : l += t.charAt(n), n += 1;
676
- return l;
674
+ for (var n = 0, c = "", f; n < t.length; )
675
+ t.charAt(n) === "%" ? (f = t.charAt(n) + t.charAt(n + 1), B[f] !== r ? (c += B[f].format(this), n += 1) : c += "%") : c += t.charAt(n), n += 1;
676
+ return c;
677
677
  }, E.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
679
  }, E.fn.errors = function() {
680
680
  return this._i;
681
681
  }, E.fn.between = function(t, n) {
682
- var l = this.timestamp(), f = t.timestamp();
682
+ var c = this.timestamp(), f = t.timestamp();
683
683
  switch (n) {
684
684
  case "year":
685
- return Math.floor((f - l) / 31556952);
685
+ return Math.floor((f - c) / 31556952);
686
686
  case "month":
687
- return Math.floor((f - l) / 2629746);
687
+ return Math.floor((f - c) / 2629746);
688
688
  case "day":
689
- return Math.floor((f - l) / 86400);
689
+ return Math.floor((f - c) / 86400);
690
690
  case "hours":
691
- return Math.floor((f - l) / 3600);
691
+ return Math.floor((f - c) / 3600);
692
692
  case "minutes":
693
- return Math.floor((f - l) / 60);
693
+ return Math.floor((f - c) / 60);
694
694
  case "seconds":
695
- return f - l;
695
+ return f - c;
696
696
  default:
697
697
  return r;
698
698
  }
699
699
  }, E.fn.calc = function(t) {
700
700
  return t.year !== r && this._d.setFullYear(this._d.getFullYear() + t.year), t.month !== r && this._d.setMonth(this._d.getMonth() + t.month), t.day !== r && this._d.setDate(this._d.getDate() + t.day), t.hours !== r && this._d.setHours(this._d.getHours() + t.hours), t.minutes !== r && this._d.setMinutes(this._d.getMinutes() + t.minutes), t.seconds !== r && this._d.setSeconds(this._d.getSeconds() + t.seconds), t.milliseconds !== r && this._d.setMilliseconds(this._d.getMilliseconds() + t.milliseconds), this;
701
- }, s = function(t, n, l) {
702
- return new E(t, n, l);
701
+ }, s = function(t, n, c) {
702
+ return new E(t, n, c);
703
703
  }, s.MIN_YEAR = 1e3, s.MAX_YEAR = 3e3, s.MIN_MONTH = 1, s.MAX_MONTH = 12, s.MIN_DAY = 1, s.MAX_DAY_IN_MONTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], s.MIN_DAY_OF_WEEK = 0, s.MAX_DAY_OF_WEEK = 6, s.MIN_HOURS = 0, s.MAX_HOURS = 23, s.MIN_MINUTES = 0, s.MAX_MINUTES = 59, s.MIN_SECONDS = 0, s.MAX_SECONDS = 59, s.MIN_MILLISECONDS = 0, s.MAX_MILLISECONDS = 999, s.VERSION = "0.2.18", s.options = function(t, n) {
704
704
  if (t === r)
705
705
  return tt;
@@ -710,10 +710,10 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
710
710
  }
711
711
  return r;
712
712
  }, s.noConflict = function() {
713
- return i.tempus = u, s;
713
+ return i.tempus = l, s;
714
714
  }, s.generate = function(t) {
715
- var n, l, f, L, _, T, J, Y;
716
- if (typeof t.dateFrom != "number" && (t.dateFrom instanceof E ? n = t.dateFrom.utc() : n = s(t.dateFrom, t.formatFrom).utc()), typeof t.dateTo != "number" && (t.dateTo instanceof E ? l = t.dateTo.utc() : l = s(t.dateTo, t.formatTo !== r ? t.formatTo : t.formatFrom).utc()), typeof t.period == "number" ? _ = {
715
+ var n, c, f, L, _, T, J, Y;
716
+ if (typeof t.dateFrom != "number" && (t.dateFrom instanceof E ? n = t.dateFrom.utc() : n = s(t.dateFrom, t.formatFrom).utc()), typeof t.dateTo != "number" && (t.dateTo instanceof E ? c = t.dateTo.utc() : c = s(t.dateTo, t.formatTo !== r ? t.formatTo : t.formatFrom).utc()), typeof t.period == "number" ? _ = {
717
717
  year: 0,
718
718
  month: 0,
719
719
  day: 0,
@@ -754,10 +754,10 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
754
754
  Y(T[T.length - 1], f, !0), f = s(f).calc(_).utc();
755
755
  }
756
756
  }
757
- for (; n <= l; )
757
+ for (; n <= c; )
758
758
  t.groupBy === r ? Y(T, n) : s(n).get()[t.groupBy] === J ? Y(T[T.length - 1], n) : (T.push([]), Y(T[T.length - 1], n), J = s(n).get()[t.groupBy]), n = s(n).calc(_).utc();
759
759
  if (t.groupBy !== r && t.fillNulls)
760
- for (L = s(l).calc(_).utc(); s(L).get()[t.groupBy] === J; )
760
+ for (L = s(c).calc(_).utc(); s(L).get()[t.groupBy] === J; )
761
761
  Y(T[T.length - 1], L, !0), L = s(L).calc(_).utc();
762
762
  return T;
763
763
  }, s.monthNames = function(t) {
@@ -765,7 +765,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
765
765
  case "long":
766
766
  return P;
767
767
  default:
768
- return w;
768
+ return H;
769
769
  }
770
770
  }, s.dayNames = function(t) {
771
771
  switch (t) {
@@ -776,16 +776,16 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
776
776
  }
777
777
  }, s.lang = function(t) {
778
778
  if (t !== r)
779
- a = t, c[a] === r && (a = "en"), P = y(), w = O(), I = R(), M = G();
779
+ a = t, u[a] === r && (a = "en"), P = y(), H = O(), I = R(), M = G();
780
780
  else
781
781
  return a;
782
782
  return r;
783
783
  }, s.availableLangs = function() {
784
- return Object.keys(c);
785
- }, s.registerFormat = function(t, n, l, f, L, _) {
784
+ return Object.keys(u);
785
+ }, s.registerFormat = function(t, n, c, f, L, _) {
786
786
  B[t] = {
787
787
  format: n,
788
- parse: l,
788
+ parse: c,
789
789
  minLength: f,
790
790
  maxLength: L,
791
791
  type: _
@@ -793,8 +793,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
793
793
  }, s.unregisterFormat = function(t) {
794
794
  delete B[t];
795
795
  }, s.detectFormat = function(t) {
796
- var n, l, f;
797
- return n = m(t, 0), n !== "" && (f = 10), l = t.charAt(f), (l === "T" || l === " ") && (n += l, f += 1), n += h(t, f), n;
796
+ var n, c, f;
797
+ return n = m(t, 0), n !== "" && (f = 10), c = t.charAt(f), (c === "T" || c === " ") && (n += c, f += 1), n += h(t, f), n;
798
798
  }, d = {
799
799
  TempusDate: E
800
800
  }, s.classes = function(t, n) {
@@ -802,11 +802,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : n(JSON.pars
802
802
  return d[t];
803
803
  d[t] = n;
804
804
  }, s.loadTranslations = function(t) {
805
- typeof t == "object" ? c = t : typeof t == "string" && q(t, function(n) {
806
- c = n;
805
+ typeof t == "object" ? u = t : typeof t == "string" && q(t, function(n) {
806
+ u = n;
807
807
  }, function(n) {
808
808
  });
809
- }, a = (g.language || g.systemLanguage || g.userLanguage || "en").substr(0, 2).toLowerCase(), c[a] === r && (a = "en"), P = y(), w = O(), I = R(), M = G(), N.exports && (e = N.exports = s), e.tempus = s;
809
+ }, a = (g.language || g.systemLanguage || g.userLanguage || "en").substr(0, 2).toLowerCase(), u[a] === r && (a = "en"), P = y(), H = O(), I = R(), M = G(), N.exports && (e = N.exports = s), e.tempus = s;
810
810
  }).call(yt);
811
811
  })(lt, lt.exports);
812
812
  var Tt = lt.exports;
@@ -850,13 +850,13 @@ class j {
850
850
  i === "count" && (h = o);
851
851
  let m = 1;
852
852
  A && (m = o), this.progressCall && (this.progressData || (this.progressData = {}), this.progressData[e] && this.progressData[e].count && (m += this.progressData[e].count), this.progressData[e] ? this.progressData[e].count = m : this.progressData[e] = { total: h, count: m }, this.progressTimer || (this.progressTimer = setInterval(() => {
853
- const { percent: u, allCount: s, allTotal: d } = this.progressPercent;
853
+ const { percent: l, allCount: s, allTotal: d } = this.progressPercent;
854
854
  (this.oldPercent === "no" || this.oldPercent < this.progressPercent.percent) && (this.progressCall({
855
855
  data: this.progressData,
856
- percent: u,
856
+ percent: l,
857
857
  allCount: s,
858
858
  allTotal: d
859
- }), this.oldPercent = this.progressPercent.percent), u >= 100 && this.clearProgressData();
859
+ }), this.oldPercent = this.progressPercent.percent), l >= 100 && this.clearProgressData();
860
860
  }, this.progressDelay)));
861
861
  }
862
862
  /**
@@ -888,10 +888,10 @@ class j {
888
888
  const A = {};
889
889
  this.chunkRate = (1 / Math.ceil(Object.keys(e).length / this.limit)).toFixed(5);
890
890
  let o = {}, h = 0;
891
- for (const [m, u] of Object.entries(e)) {
891
+ for (const [m, l] of Object.entries(e)) {
892
892
  if (!this.canContinue)
893
893
  break;
894
- const s = this.arrayChunk(u);
894
+ const s = this.arrayChunk(l);
895
895
  if (!s) {
896
896
  h++;
897
897
  continue;
@@ -919,10 +919,10 @@ class j {
919
919
  const A = {};
920
920
  this.chunkRate = (1 / Math.ceil(Object.keys(e).length / this.limit)).toFixed(5);
921
921
  let o = {}, h = 0;
922
- for (const [m, u] of Object.entries(e)) {
922
+ for (const [m, l] of Object.entries(e)) {
923
923
  if (!this.canContinue)
924
924
  break;
925
- const s = this.arrayChunk(u);
925
+ const s = this.arrayChunk(l);
926
926
  if (!s) {
927
927
  h++;
928
928
  continue;
@@ -979,12 +979,12 @@ class j {
979
979
  const A = [];
980
980
  let o;
981
981
  this.callBatch(e, async (h) => {
982
- var m, u, s, d, g, a, c;
982
+ var m, l, s, d, g, a, u;
983
983
  for (const [y, O] of Object.entries(h)) {
984
984
  if (!this.canContinue)
985
985
  return;
986
986
  if (O.error())
987
- switch (this.errors[y] = ((u = (m = O.error()) == null ? void 0 : m.ex) == null ? void 0 : u.error) ?? ((d = (s = O.error()) == null ? void 0 : s.ex) == null ? void 0 : d.error_description) ?? ((g = O.error()) == null ? void 0 : g.toString()) ?? "Неизвестная ошибка", o = !0, ((c = (a = O.error()) == null ? void 0 : a.ex) == null ? void 0 : c.error) ?? "") {
987
+ switch (this.errors[y] = ((l = (m = O.error()) == null ? void 0 : m.ex) == null ? void 0 : l.error) ?? ((d = (s = O.error()) == null ? void 0 : s.ex) == null ? void 0 : d.error_description) ?? ((g = O.error()) == null ? void 0 : g.toString()) ?? "Неизвестная ошибка", o = !0, ((u = (a = O.error()) == null ? void 0 : a.ex) == null ? void 0 : u.error) ?? "") {
988
988
  case "OPERATION_TIME_LIMIT":
989
989
  this.skipList.add(e[y].method), this.limitCall && this.limitCall(y);
990
990
  break;
@@ -995,9 +995,9 @@ class j {
995
995
  this.skipList.add(e[y].method);
996
996
  break;
997
997
  }
998
- const R = this.getData(O.data()), G = Array.isArray(R) ? R.length : 0, P = typeof O.total == "function" && O.total() !== void 0, w = P ? O.total() : G;
999
- r === "count" ? this.result[y] ? this.result[y] += G : this.result[y] = w : this.result[y] = R, this.setProgressData({ key: y, value: O, type: r });
1000
- const I = r === "count" ? !P && G === this.limit : w > this.limit && w > G;
998
+ const R = this.getData(O.data()), G = Array.isArray(R) ? R.length : 0, P = typeof O.total == "function" && O.total() !== void 0, H = P ? O.total() : G;
999
+ r === "count" ? this.result[y] ? this.result[y] += G : this.result[y] = H : this.result[y] = R, this.setProgressData({ key: y, value: O, type: r });
1000
+ const I = r === "count" ? !P && G === this.limit : H > this.limit && H > G;
1001
1001
  if (!this.canContinue || I) {
1002
1002
  let M = e[y];
1003
1003
  if (Array.isArray(M)) {
@@ -1007,7 +1007,7 @@ class j {
1007
1007
  const { method: q, params: B = {} } = M;
1008
1008
  M = [q, B];
1009
1009
  }
1010
- A.push([y, M, w]);
1010
+ A.push([y, M, H]);
1011
1011
  }
1012
1012
  }
1013
1013
  o > 0 && this.errorLogger(), A.length ? await this.batchPayload(A, r).then(
@@ -1021,40 +1021,40 @@ class j {
1021
1021
  * @param {String} type - Тип обработки результатов ('count' или undefined)
1022
1022
  */
1023
1023
  async batchPayload(e, r) {
1024
- const i = /* @__PURE__ */ new Map(), A = (u, s, d, g) => {
1024
+ const i = /* @__PURE__ */ new Map(), A = (l, s, d, g) => {
1025
1025
  let a = "ID";
1026
- this.result[u][this.result[u].length - 1].ID || (a = "id");
1027
- let c = `${a}`;
1028
- if (JSON.stringify(g[1]).toLocaleLowerCase().includes('"id":"desc"') ? c = "<" + c : c = ">" + c, s === 1 || d.length === 0)
1026
+ this.result[l][this.result[l].length - 1].ID || (a = "id");
1027
+ let u = `${a}`;
1028
+ if (JSON.stringify(g[1]).toLocaleLowerCase().includes('"id":"desc"') ? u = "<" + u : u = ">" + u, s === 1 || d.length === 0)
1029
1029
  return {
1030
- field: c,
1031
- id: this.result[u][this.result[u].length - 1][a]
1030
+ field: u,
1031
+ id: this.result[l][this.result[l].length - 1][a]
1032
1032
  };
1033
1033
  let O = "";
1034
1034
  const [R, G] = g;
1035
1035
  return (R === "tasks.task.list" || R === "task.item.list") && (O = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(R) && (O = "[items]"), R === "crm.type.list" && (O = "[types]"), R === "socialnetwork.api.workgroup.list" && (O = "[workgroups]"), {
1036
- field: c,
1037
- id: `$result[${[u, s - 1].join("__")}]${O}[49][${a}]`
1036
+ field: u,
1037
+ id: `$result[${[l, s - 1].join("__")}]${O}[49][${a}]`
1038
1038
  };
1039
- }, o = (u, s) => {
1040
- const [d, g] = u;
1041
- let a = JSON.parse(JSON.stringify(g)), c;
1039
+ }, o = (l, s) => {
1040
+ const [d, g] = l;
1041
+ let a = JSON.parse(JSON.stringify(g)), u;
1042
1042
  if (d === "task.item.list") {
1043
1043
  a = [...a];
1044
1044
  const [y, O, R, G] = a;
1045
1045
  return O[s.field] = s.id, [d, a];
1046
1046
  }
1047
- return ["user.get"].includes(d) || a.FILTER ? (a.FILTER || (a.FILTER = {}), c = a.FILTER) : (a.filter || (a.filter = {}), c = a.filter), [
1047
+ return ["user.get"].includes(d) || a.FILTER ? (a.FILTER || (a.FILTER = {}), u = a.FILTER) : (a.filter || (a.filter = {}), u = a.filter), [
1048
1048
  "socialnetwork.api.workgroup.list",
1049
1049
  "tasks.task.list"
1050
- ].includes(d) ? c[">ID"] = s.id : c[s.field] = s.id, [d, { ...a, start: -1 }];
1051
- }, h = (u) => {
1052
- Object.entries(u).forEach(([s, d]) => {
1053
- var c, y, O, R, G, P, w;
1050
+ ].includes(d) ? u[">ID"] = s.id : u[s.field] = s.id, [d, { ...a, start: -1 }];
1051
+ }, h = (l) => {
1052
+ Object.entries(l).forEach(([s, d]) => {
1053
+ var u, y, O, R, G, P, H;
1054
1054
  const [g] = s.split("__"), a = this.getData(d.data());
1055
1055
  if (Array.isArray(a) && (r === "count" ? this.result[g] += a.length : this.result[g].push(...a)), d.error()) {
1056
- this.errors[g] = ((y = (c = d.error()) == null ? void 0 : c.ex) == null ? void 0 : y.error) ?? ((R = (O = d.error()) == null ? void 0 : O.ex) == null ? void 0 : R.error_description) ?? ((G = d.error()) == null ? void 0 : G.toString()) ?? "Неизвестная ошибка";
1057
- const I = ((w = (P = d.error()) == null ? void 0 : P.ex) == null ? void 0 : w.error) ?? "";
1056
+ this.errors[g] = ((y = (u = d.error()) == null ? void 0 : u.ex) == null ? void 0 : y.error) ?? ((R = (O = d.error()) == null ? void 0 : O.ex) == null ? void 0 : R.error_description) ?? ((G = d.error()) == null ? void 0 : G.toString()) ?? "Неизвестная ошибка";
1057
+ const I = ((H = (P = d.error()) == null ? void 0 : P.ex) == null ? void 0 : H.error) ?? "";
1058
1058
  if (I === "OPERATION_TIME_LIMIT") {
1059
1059
  this.limitCall && this.limitCall(g);
1060
1060
  const M = i.get(g);
@@ -1075,16 +1075,16 @@ class j {
1075
1075
  });
1076
1076
  };
1077
1077
  let m = [];
1078
- for await (const [u, s, d] of e) {
1078
+ for await (const [l, s, d] of e) {
1079
1079
  if (!this.canContinue)
1080
1080
  return;
1081
1081
  const [g] = s;
1082
- if (i.set(u, g), this.skipList.has(g))
1082
+ if (i.set(l, g), this.skipList.has(g))
1083
1083
  continue;
1084
1084
  let a = 1;
1085
1085
  for (; d > a * 50 && !this.skipList.has(g); ) {
1086
- const c = [u, a].join("__"), y = A(u, a, m, s);
1087
- m.push([c, o(s, y)]), m.length % 50 === 0 && (await new Promise(
1086
+ const u = [l, a].join("__"), y = A(l, a, m, s);
1087
+ m.push([u, o(s, y)]), m.length % 50 === 0 && (await new Promise(
1088
1088
  (O) => this.callBatch(
1089
1089
  Object.fromEntries(m),
1090
1090
  (R) => {
@@ -1095,8 +1095,8 @@ class j {
1095
1095
  }
1096
1096
  }
1097
1097
  m.length && (await new Promise(
1098
- (u) => this.callBatch(Object.fromEntries(m), (s) => {
1099
- h(s), u();
1098
+ (l) => this.callBatch(Object.fromEntries(m), (s) => {
1099
+ h(s), l();
1100
1100
  })
1101
1101
  ), await this.delay());
1102
1102
  }
@@ -1112,7 +1112,7 @@ class j {
1112
1112
  var v;
1113
1113
  class ut {
1114
1114
  constructor() {
1115
- H(this, v, {});
1115
+ w(this, v, {});
1116
1116
  }
1117
1117
  /**
1118
1118
  * Получить случайный хеш-код длиной 8 символов
@@ -1184,21 +1184,21 @@ const ht = new ut();
1184
1184
  var x, Q, Z, z, C, V, K, rt, ft, $, ct, st, mt, it, dt, nt, gt;
1185
1185
  class Rt {
1186
1186
  constructor() {
1187
- H(this, rt);
1187
+ w(this, rt);
1188
1188
  /** Вывод ошибок логера
1189
1189
  * @param {'entity'} type - тип ошибки
1190
1190
  */
1191
- H(this, $);
1192
- H(this, st);
1193
- H(this, it);
1194
- H(this, nt);
1195
- H(this, x, "logger");
1196
- H(this, Q, !1);
1197
- H(this, Z, /* @__PURE__ */ new Map());
1198
- H(this, z, {});
1199
- H(this, C, null);
1200
- H(this, V, !1);
1201
- H(this, K, !1);
1191
+ w(this, $);
1192
+ w(this, st);
1193
+ w(this, it);
1194
+ w(this, nt);
1195
+ w(this, x, "logger");
1196
+ w(this, Q, !1);
1197
+ w(this, Z, /* @__PURE__ */ new Map());
1198
+ w(this, z, {});
1199
+ w(this, C, null);
1200
+ w(this, V, !1);
1201
+ w(this, K, !1);
1202
1202
  /** Очистка хранилища элементов старше 'N' месяцев */
1203
1203
  S(this, "periodClear", 3);
1204
1204
  X(this, rt, ft).call(this);
@@ -1303,9 +1303,9 @@ class Rt {
1303
1303
  );
1304
1304
  return !A || !Array.isArray(A) ? (console.warn("Получен невалидный список записей"), []) : (A = A.map((o) => {
1305
1305
  try {
1306
- const { ID: h, DATE_CREATE: m, DETAIL_TEXT: u } = o;
1306
+ const { ID: h, DATE_CREATE: m, DETAIL_TEXT: l } = o;
1307
1307
  return {
1308
- ...JSON.parse(u),
1308
+ ...JSON.parse(l),
1309
1309
  id: h,
1310
1310
  dateCreate: m
1311
1311
  };
@@ -1439,9 +1439,9 @@ class bt {
1439
1439
  */
1440
1440
  constructor(e) {
1441
1441
  /** Запрос данных о приложении */
1442
- H(this, At);
1442
+ w(this, At);
1443
1443
  /** Запрос данных о текущем пользователе */
1444
- H(this, ot);
1444
+ w(this, ot);
1445
1445
  S(this, "domain", "");
1446
1446
  S(this, "isAdmin", !1);
1447
1447
  S(this, "appInfo", null);
@@ -1474,9 +1474,9 @@ class bt {
1474
1474
  X(this, ot, Ot).call(this)
1475
1475
  ]);
1476
1476
  this.appInfo = h, this.userInfo = m;
1477
- let u = new ut();
1477
+ let l = new ut();
1478
1478
  try {
1479
- u.noSleep();
1479
+ l.noSleep();
1480
1480
  } catch (s) {
1481
1481
  console.warn(
1482
1482
  "Failed to initialize noSleep:",
@@ -1548,16 +1548,16 @@ class bt {
1548
1548
  }
1549
1549
  return new Promise((o, h) => {
1550
1550
  BX24.callMethod(e, r, async (m) => {
1551
- let u = {};
1551
+ let l = {};
1552
1552
  if (m != null && m.answer)
1553
1553
  for (let [s, d] of Object.entries(m.answer))
1554
- s !== "result" && d && (u[s] = d);
1554
+ s !== "result" && d && (l[s] = d);
1555
1555
  if (m.error()) {
1556
1556
  let s = m.error();
1557
1557
  if (console.error(s), A)
1558
1558
  try {
1559
1559
  await this.logger.stop({
1560
- answer: u,
1560
+ answer: l,
1561
1561
  key: A,
1562
1562
  status: "fail",
1563
1563
  errorList: { 0: s.toString() }
@@ -1571,7 +1571,7 @@ class bt {
1571
1571
  if (s != null && s.items && (s = s.items), A)
1572
1572
  try {
1573
1573
  await this.logger.stop({
1574
- answer: u,
1574
+ answer: l,
1575
1575
  key: A,
1576
1576
  status: "success"
1577
1577
  });
@@ -1607,8 +1607,8 @@ class bt {
1607
1607
  const s = new Error("BX24 is not initialized");
1608
1608
  return console.error(s), !1;
1609
1609
  }
1610
- let m = new j(BX24.callBatch), u;
1611
- o && (u = this.logger.start({
1610
+ let m = new j(BX24.callBatch), l;
1611
+ o && (l = this.logger.start({
1612
1612
  type: "batch",
1613
1613
  data: { commandList: e, updateList: o }
1614
1614
  })), A && console.warn(
@@ -1621,20 +1621,20 @@ class bt {
1621
1621
  h
1622
1622
  );
1623
1623
  if (Object.keys(m.errors).length) {
1624
- if (i && i(m.errors), u)
1624
+ if (i && i(m.errors), l)
1625
1625
  try {
1626
1626
  await this.logger.stop({
1627
- key: u,
1627
+ key: l,
1628
1628
  status: "fail",
1629
1629
  errorList: m.errors
1630
1630
  });
1631
1631
  } catch (d) {
1632
1632
  console.error("Logger error:", d);
1633
1633
  }
1634
- } else if (u)
1634
+ } else if (l)
1635
1635
  try {
1636
1636
  await this.logger.stop({
1637
- key: u,
1637
+ key: l,
1638
1638
  status: "success"
1639
1639
  });
1640
1640
  } catch (d) {
@@ -1642,10 +1642,10 @@ class bt {
1642
1642
  }
1643
1643
  return s;
1644
1644
  } catch (s) {
1645
- if (u)
1645
+ if (l)
1646
1646
  try {
1647
1647
  await this.logger.stop({
1648
- key: u,
1648
+ key: l,
1649
1649
  status: "fail-runtime",
1650
1650
  errorList: { 0: s == null ? void 0 : s.toString() }
1651
1651
  });
@@ -1680,8 +1680,8 @@ class bt {
1680
1680
  */
1681
1681
  async batchTotalCount(e, r, { errorCall: i, updateList: A, limitCall: o } = {}) {
1682
1682
  if (typeof BX24 > "u" || !BX24.callBatch) {
1683
- const u = new Error("BX24 is not initialized");
1684
- return console.error(u), !1;
1683
+ const l = new Error("BX24 is not initialized");
1684
+ return console.error(l), !1;
1685
1685
  }
1686
1686
  let h = new j(BX24.callBatch), m;
1687
1687
  A && (m = this.logger.start({
@@ -1689,7 +1689,7 @@ class bt {
1689
1689
  data: { commandList: e }
1690
1690
  }));
1691
1691
  try {
1692
- let u = await h.batchTotalCount(
1692
+ let l = await h.batchTotalCount(
1693
1693
  e,
1694
1694
  r,
1695
1695
  o
@@ -1714,19 +1714,19 @@ class bt {
1714
1714
  } catch (s) {
1715
1715
  console.error("Logger error:", s);
1716
1716
  }
1717
- return u;
1718
- } catch (u) {
1717
+ return l;
1718
+ } catch (l) {
1719
1719
  if (m)
1720
1720
  try {
1721
1721
  await this.logger.stop({
1722
1722
  key: m,
1723
1723
  status: "fail-runtime",
1724
- errorList: { 0: u == null ? void 0 : u.toString() }
1724
+ errorList: { 0: l == null ? void 0 : l.toString() }
1725
1725
  });
1726
1726
  } catch (s) {
1727
1727
  console.error("Logger error:", s);
1728
1728
  }
1729
- return console.error(u), !1;
1729
+ return console.error(l), !1;
1730
1730
  }
1731
1731
  }
1732
1732
  /** Запрос данных о местах встройки приложения */
@@ -1745,18 +1745,18 @@ class bt {
1745
1745
  const { appName: A, pathApp: o } = this.appConst;
1746
1746
  let h = A;
1747
1747
  this.domain === "szdl.bitrix24.ru" && ((d = this.appInfo) != null && d.ID) && (h = `${A}: #${this.appInfo.ID}`);
1748
- const m = h.replace(" CRM", ""), u = {}, s = [];
1748
+ const m = h.replace(" CRM", ""), l = {}, s = [];
1749
1749
  for (let g = 0; g < i.length; g++) {
1750
- const a = i[g], c = a.placement, y = a.userId;
1751
- let O = o, R = c;
1752
- if (c === "PAGE_BACKGROUND_WORKER") {
1750
+ const a = i[g], u = a.placement, y = a.userId;
1751
+ let O = o, R = u;
1752
+ if (u === "PAGE_BACKGROUND_WORKER") {
1753
1753
  if (!y) {
1754
- console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${c}`);
1754
+ console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${u}`);
1755
1755
  continue;
1756
1756
  }
1757
1757
  O = `${o}?USER_ID=${y}/`;
1758
1758
  }
1759
- if (c === "PAGE_BACKGROUND_WORKER_ALL" && (R = "PAGE_BACKGROUND_WORKER"), this.placeData.find(
1759
+ if (u === "PAGE_BACKGROUND_WORKER_ALL" && (R = "PAGE_BACKGROUND_WORKER"), this.placeData.find(
1760
1760
  (I) => I.placement === R && I.handler === O
1761
1761
  ))
1762
1762
  continue;
@@ -1764,7 +1764,7 @@ class bt {
1764
1764
  (I) => I.placement === R && I.handler !== O
1765
1765
  );
1766
1766
  P && s.push({ placement: R, handler: P.handler });
1767
- const w = {
1767
+ const H = {
1768
1768
  PLACEMENT: R,
1769
1769
  HANDLER: O,
1770
1770
  LANG_ALL: {
@@ -1776,12 +1776,12 @@ class bt {
1776
1776
  errorHandlerUrl: O
1777
1777
  }
1778
1778
  };
1779
- c === "PAGE_BACKGROUND_WORKER" && y && (w.USER_ID = y), u[`bind_${g}`] = {
1779
+ u === "PAGE_BACKGROUND_WORKER" && y && (H.USER_ID = y), l[`bind_${g}`] = {
1780
1780
  method: "placement.bind",
1781
- params: w
1781
+ params: H
1782
1782
  };
1783
1783
  }
1784
- s.length > 0 && await this.placementUnBind(s), Object.keys(u).length > 0 && await this.batch(u), Object.keys(u).length > 0 && (this.placeData = await this.getPlacement(), Object.values(u).forEach((g) => {
1784
+ s.length > 0 && await this.placementUnBind(s), Object.keys(l).length > 0 && await this.batch(l), Object.keys(l).length > 0 && (this.placeData = await this.getPlacement(), Object.values(l).forEach((g) => {
1785
1785
  console.log("Приложение успешно встроено в", g.params.PLACEMENT);
1786
1786
  }));
1787
1787
  }
@@ -1791,12 +1791,12 @@ class bt {
1791
1791
  Array.isArray(e) ? r = e.map((A) => typeof A == "string" ? { placement: A } : A) : typeof e == "string" ? r = [{ placement: e }] : r = [e];
1792
1792
  const i = {};
1793
1793
  for (let A = 0; A < r.length; A++) {
1794
- const o = r[A], h = o.placement, m = o.handler, u = {
1794
+ const o = r[A], h = o.placement, m = o.handler, l = {
1795
1795
  PLACEMENT: h
1796
1796
  };
1797
- m && (u.HANDLER = m), i[`unbind_${A}`] = {
1797
+ m && (l.HANDLER = m), i[`unbind_${A}`] = {
1798
1798
  method: "placement.unbind",
1799
- params: u
1799
+ params: l
1800
1800
  };
1801
1801
  }
1802
1802
  Object.keys(i).length > 0 && (await this.batch(i), r.forEach((A) => {
@@ -1865,7 +1865,7 @@ class bt {
1865
1865
  // Аватар чат-бота - base64
1866
1866
  }
1867
1867
  }
1868
- }).then((u) => (console.log("Чат-бот добавлен", u), u));
1868
+ }).then((l) => (console.log("Чат-бот добавлен", l), l));
1869
1869
  }
1870
1870
  /* Убрать регистрацию бота */
1871
1871
  unRegBot(e) {
@@ -2069,10 +2069,10 @@ class St {
2069
2069
  e.forEach((a) => {
2070
2070
  a.placement === "PAGE_BACKGROUND_WORKER" && (a.userId ? r.set(+a.userId, a) : i = a);
2071
2071
  }), console.log(`setBackgroundWorkerAll: Найдено ${r.size} индивидуальных и ${i ? 1 : 0} общих привязок PAGE_BACKGROUND_WORKER`);
2072
- const A = await this.getAdminsList(), o = await this.getEligibleUsersForBackgroundWorker(A);
2073
- o.sort((a, c) => {
2072
+ const A = await this.updateAdminsList(), o = await this.getEligibleUsersForBackgroundWorker(A);
2073
+ o.sort((a, u) => {
2074
2074
  const y = a.LAST_LOGIN ? new Date(a.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
2075
- return (c.LAST_LOGIN ? new Date(c.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - y;
2075
+ return (u.LAST_LOGIN ? new Date(u.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - y;
2076
2076
  }), console.log(`setBackgroundWorkerAll: Найдено ${o.length} подходящих пользователей (админы и руководители)`);
2077
2077
  const h = [];
2078
2078
  !i && this.appPath && (h.push({
@@ -2090,7 +2090,7 @@ class St {
2090
2090
  }
2091
2091
  }
2092
2092
  }), console.log("setBackgroundWorkerAll: Добавлен в очередь создание общего бэк-воркера"));
2093
- const m = 10, u = o.slice(0, m), s = [];
2093
+ const m = 10, l = o.slice(0, m), s = [];
2094
2094
  for (const [a] of r)
2095
2095
  o.find((y) => +y.ID === a) || s.push(a);
2096
2096
  for (const a of s)
@@ -2101,7 +2101,7 @@ class St {
2101
2101
  HANDLER: `${this.appPath}?USER_ID=${a}/`
2102
2102
  }
2103
2103
  }), console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${a}`));
2104
- for (const a of u)
2104
+ for (const a of l)
2105
2105
  r.has(+a.ID) || !this.appPath || h.push({
2106
2106
  method: "placement.bind",
2107
2107
  params: {
@@ -2129,20 +2129,13 @@ class St {
2129
2129
  async updateAdminsList() {
2130
2130
  var e, r, i;
2131
2131
  try {
2132
- const A = BX24.appOption.get("adminsList");
2133
- let o = [];
2134
- if (A)
2135
- try {
2136
- o = JSON.parse(A);
2137
- } catch {
2138
- console.log("updateAdminsList: Ошибка парсинга существующего списка админов, создаем новый"), o = [];
2139
- }
2140
- const h = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0);
2141
- (r = this.bx) != null && r.isAdmin && h && !o.includes(h) && (o.push(h), console.log(`updateAdminsList: Добавлен новый админ ${h}`)), !((i = this.bx) != null && i.isAdmin) && h && o.includes(h) && (o = o.filter((s) => s !== h), console.log(`updateAdminsList: Удален из списка админов пользователь ${h} (больше не админ)`));
2142
- const m = new Set(
2143
- (this.users ?? []).filter((s) => s.ACTIVE === "Y" || s.ACTIVE === !0).map((s) => +s.ID)
2144
- ), u = o.filter((s) => m.has(s));
2145
- return u.length !== o.length && (console.log(`updateAdminsList: Удалено ${o.length - u.length} неактивных админов`), o = u), BX24.appOption.set("adminsList", JSON.stringify(o)), console.log(`BackgroundWorker: Список админов обновлен: ${o.length} админов`), o;
2132
+ let A = await this.getAdminsList();
2133
+ const o = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0);
2134
+ (r = this.bx) != null && r.isAdmin && o && !A.includes(o) && (A.push(o), console.log(`updateAdminsList: Добавлен новый админ ${o}`)), !((i = this.bx) != null && i.isAdmin) && o && A.includes(o) && (A = A.filter((l) => l !== o), console.log(`updateAdminsList: Удален из списка админов пользователь ${o} (больше не админ)`));
2135
+ const h = new Set(
2136
+ (this.users ?? []).filter((l) => l.ACTIVE === "Y" || l.ACTIVE === !0).map((l) => +l.ID)
2137
+ ), m = A.filter((l) => h.has(l));
2138
+ return m.length !== A.length && (console.log(`updateAdminsList: Удалено ${A.length - m.length} неактивных админов`), A = m), BX24.appOption.set("adminsList", JSON.stringify(A)), console.log(`BackgroundWorker: Список админов обновлен: ${A.length} админов`), A;
2146
2139
  } catch (A) {
2147
2140
  return console.error("BackgroundWorker: Ошибка при обновлении списка админов:", A), [];
2148
2141
  }
@@ -1,2 +1,2 @@
1
- var bt=Object.defineProperty;var St=(N,E,b)=>E in N?bt(N,E,{enumerable:!0,configurable:!0,writable:!0,value:b}):N[E]=b;var M=(N,E,b)=>(St(N,typeof E!="symbol"?E+"":E,b),b),mt=(N,E,b)=>{if(!E.has(N))throw TypeError("Cannot "+b)};var _=(N,E,b)=>(mt(N,E,"read from private field"),b?b.call(N):E.get(N)),Y=(N,E,b)=>{if(E.has(N))throw TypeError("Cannot add the same private member more than once");E instanceof WeakSet?E.add(N):E.set(N,b)},J=(N,E,b,$)=>(mt(N,E,"write to private field"),$?$.call(N,b):E.set(N,b),b);var Q=(N,E,b)=>(mt(N,E,"access private method"),b);(function(N,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(N=typeof globalThis<"u"?globalThis:N||self,E(N["szdl-utils-kit"]={}))})(this,function(N){var V,j,Z,K,tt,G,q,et,nt,Nt,st,dt,At,Ot,ot,pt,at,_t,ht,yt,lt,Et;"use strict";var E=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function b(W){return W&&W.__esModule&&Object.prototype.hasOwnProperty.call(W,"default")?W.default:W}var $={exports:{}};(function(W,e){(function(r){Array.prototype.indexOf||(Array.prototype.indexOf=function(t,n){var l,f;for(l=n||0,f=this.length;l<f;l+=1)if(this[l]===t)return l;return-1});var i=this,A=function(t,n){for(var l=t.toString();l.length<n;)l="0"+l;return l},o=function(t,n){return n!==r?(t.year(n.year()||n.year),t.month(n.month()||n.month),t.day(n.day()||n.day),t.hours(n.hours()||n.hours),t.minutes(n.minutes()||n.minutes),t.seconds(n.seconds()||n.seconds),t.milliseconds(n.milliseconds()||n.milliseconds),t):r},h=function(t,n){var l,f="";return l=t.slice(n,n+1),l!==""&&!isNaN(Number(l))&&(f+="%H"),l=t.charAt(n+2),l!==""&&l===":"&&(f+=l),l=t.slice(n+3,n+4),l!==""&&!isNaN(Number(l))&&(f+="%M"),l=t.charAt(n+5),l!==""&&l===":"&&(f+=l),l=t.slice(n+6,n+7),l!==""&&!isNaN(Number(l))&&(f+="%S"),f},m=function(t,n){var l,f=[t.slice(n,n+1),t.charAt(n+2),t.slice(n+3,n+4),t.charAt(n+5),t.slice(n+6,n+9)],S;return!isNaN(Number(f[0]))&&!isNaN(Number(f[2]))&&!isNaN(Number(f[4]))?(f[1]==="."&&f[3]==="."?l="%d.%m.%Y":f[1]==="-"&&f[3]==="-"?l="%m-%d-%Y":f[1]==="/"&&f[3]==="/"&&(l="%m/%d/%Y"),l):(S=[t.slice(n,n+3),t.charAt(n+4),t.slice(n+5,n+6),t.charAt(n+7),t.slice(n+8,n+9)],!isNaN(Number(S[0]))&&!isNaN(Number(S[2]))&&!isNaN(Number(S[4]))?(S[1]==="-"&&S[3]==="-"&&(l="%Y-%m-%d"),l):"")},u=i.tempus,s,d,g=i.navigator||{},a="en",c={en:{JANUARY_SHORT:"Jan",FEBRUARY_SHORT:"Feb",MARCH_SHORT:"Mar",APRIL_SHORT:"Apr",MAY_SHORT:"May",JUNE_SHORT:"Jun",JULY_SHORT:"Jul",AUGUST_SHORT:"Aug",SEPTEMBER_SHORT:"Sep",OCTOBER_SHORT:"Oct",NOVEMBER_SHORT:"Nov",DECEMBER_SHORT:"Dec",JANUARY_LONG:"January",FEBRUARY_LONG:"February",MARCH_LONG:"March",APRIL_LONG:"April",MAY_LONG:"May",JUNE_LONG:"June",JULY_LONG:"July",AUGUST_LONG:"August",SEPTEMBER_LONG:"September",OCTOBER_LONG:"October",NOVEMBER_LONG:"November",DECEMBER_LONG:"December",SUNDAY_SHORT:"Sun",MONDAY_SHORT:"Mon",TUESDAY_SHORT:"Tue",WEDNESDAY_SHORT:"Wed",THURSDAY_SHORT:"Thu",FRIDAY_SHORT:"Fri",SATURDAY_SHORT:"Sat",SUNDAY_LONG:"Sunday",MONDAY_LONG:"Monday",TUESDAY_LONG:"Tuesday",WEDNESDAY_LONG:"Wednesday",THURSDAY_LONG:"Thursday",FRIDAY_LONG:"Friday",SATURDAY_LONG:"Saturday"},ru:{JANUARY_SHORT:"Янв",FEBRUARY_SHORT:"Фев",MARCH_SHORT:"Мар",APRIL_SHORT:"Апр",MAY_SHORT:"Май",JUNE_SHORT:"Июн",JULY_SHORT:"Июл",AUGUST_SHORT:"Авг",SEPTEMBER_SHORT:"Сен",OCTOBER_SHORT:"Окт",NOVEMBER_SHORT:"Ноя",DECEMBER_SHORT:"Дек",JANUARY_LONG:"Январь",FEBRUARY_LONG:"Февраль",MARCH_LONG:"Март",APRIL_LONG:"Апрель",MAY_LONG:"Май",JUNE_LONG:"Июнь",JULY_LONG:"Июль",AUGUST_LONG:"Август",SEPTEMBER_LONG:"Сентябрь",OCTOBER_LONG:"Октябрь",NOVEMBER_LONG:"Ноябрь",DECEMBER_LONG:"Декабрь",SUNDAY_SHORT:"Вс",MONDAY_SHORT:"Пн",TUESDAY_SHORT:"Вт",WEDNESDAY_SHORT:"Ср",THURSDAY_SHORT:"Чт",FRIDAY_SHORT:"Пт",SATURDAY_SHORT:"Сб",SUNDAY_LONG:"Воскресенье",MONDAY_LONG:"Понедельник",TUESDAY_LONG:"Вторник",WEDNESDAY_LONG:"Среда",THURSDAY_LONG:"Четверг",FRIDAY_LONG:"Пятница",SATURDAY_LONG:"Суббота"},ua:{JANUARY_SHORT:"Січ",FEBRUARY_SHORT:"Лют",MARCH_SHORT:"Берез",APRIL_SHORT:"Квіт",MAY_SHORT:"Трав",JUNE_SHORT:"Черв",JULY_SHORT:"Лип",AUGUST_SHORT:"Серп",SEPTEMBER_SHORT:"Верес",OCTOBER_SHORT:"Жовт",NOVEMBER_SHORT:"Листоп",DECEMBER_SHORT:"Груд",JANUARY_LONG:"Січень",FEBRUARY_LONG:"Лютий",MARCH_LONG:"Березень",APRIL_LONG:"Квітень",MAY_LONG:"Травень",JUNE_LONG:"Червень",JULY_LONG:"Липень",AUGUST_LONG:"Серпень",SEPTEMBER_LONG:"Вересень",OCTOBER_LONG:"Жовтень",NOVEMBER_LONG:"Листопад",DECEMBER_LONG:"Грудень",SUNDAY_SHORT:"Нд",MONDAY_SHORT:"Пн",TUESDAY_SHORT:"Вт",WEDNESDAY_SHORT:"Ср",THURSDAY_SHORT:"Чт",FRIDAY_SHORT:"Пт",SATURDAY_SHORT:"Сб",SUNDAY_LONG:"Неділя",MONDAY_LONG:"Понеділок",TUESDAY_LONG:"Вівторок",WEDNESDAY_LONG:"Середа",THURSDAY_LONG:"Четвер",FRIDAY_LONG:"П’ятниця",SATURDAY_LONG:"Субота"},de:{JANUARY_SHORT:"Jan",FEBRUARY_SHORT:"Feb",MARCH_SHORT:"März",APRIL_SHORT:"Apr",MAY_SHORT:"Mai",JUNE_SHORT:"Juni",JULY_SHORT:"Juli",AUGUST_SHORT:"Aug",SEPTEMBER_SHORT:"Sept",OCTOBER_SHORT:"Okt",NOVEMBER_SHORT:"Nov",DECEMBER_SHORT:"Dez",JANUARY_LONG:"Januar",FEBRUARY_LONG:"Februar",MARCH_LONG:"März",APRIL_LONG:"April",MAY_LONG:"Mai",JUNE_LONG:"Juni",JULY_LONG:"Juli",AUGUST_LONG:"August",SEPTEMBER_LONG:"September",OCTOBER_LONG:"Oktober",NOVEMBER_LONG:"November",DECEMBER_LONG:"Dezember",SUNDAY_SHORT:"So",MONDAY_SHORT:"Mo",TUESDAY_SHORT:"Di",WEDNESDAY_SHORT:"Mi",THURSDAY_SHORT:"Do",FRIDAY_SHORT:"Fr",SATURDAY_SHORT:"Sa",SUNDAY_LONG:"Sonntag",MONDAY_LONG:"Montag",TUESDAY_LONG:"Dienstag",WEDNESDAY_LONG:"Mittwoch",THURSDAY_LONG:"Donnerstag",FRIDAY_LONG:"Freitag",SATURDAY_LONG:"Samstag"}},y=function(){return[c[a].JANUARY_LONG,c[a].FEBRUARY_LONG,c[a].MARCH_LONG,c[a].APRIL_LONG,c[a].MAY_LONG,c[a].JUNE_LONG,c[a].JULY_LONG,c[a].AUGUST_LONG,c[a].SEPTEMBER_LONG,c[a].OCTOBER_LONG,c[a].NOVEMBER_LONG,c[a].DECEMBER_LONG]},O=function(){return[c[a].JANUARY_SHORT,c[a].FEBRUARY_SHORT,c[a].MARCH_SHORT,c[a].APRIL_SHORT,c[a].MAY_SHORT,c[a].JUNE_SHORT,c[a].JULY_SHORT,c[a].AUGUST_SHORT,c[a].SEPTEMBER_SHORT,c[a].OCTOBER_SHORT,c[a].NOVEMBER_SHORT,c[a].DECEMBER_SHORT]},L=function(){return[c[a].SUNDAY_LONG,c[a].MONDAY_LONG,c[a].TUESDAY_LONG,c[a].WEDNESDAY_LONG,c[a].THURSDAY_LONG,c[a].FRIDAY_LONG,c[a].SATURDAY_LONG]},F=function(){return[c[a].SUNDAY_SHORT,c[a].MONDAY_SHORT,c[a].TUESDAY_SHORT,c[a].WEDNESDAY_SHORT,c[a].THURSDAY_SHORT,c[a].FRIDAY_SHORT,c[a].SATURDAY_SHORT]},x,U,k,B,it=function(t,n,l){var f;i.XMLHttpRequest?f=new XMLHttpRequest:f=new ActiveXObject("Microsoft.XMLHTTP"),f.onreadystatechange=function(){f.readyState===4&&(f.status===200?n&&(i.JSON===r?alert(`Please, include json2 into your project if you want use old browsers!
2
- https://github.com/douglascrockford/JSON-js/blob/master/json2.js`):n(JSON.parse(f.responseText))):l&&l(f))},f.open("GET",t,!1),f.send()},H={"%d":{format:function(t){return A(t.day()||s.MIN_DAY,2)},parse:function(t){var n=Number(t);return{day:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%m":{format:function(t){return A(t.month()||s.MIN_MONTH,2)},parse:function(t){var n=Number(t);return{month:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%Y":{format:function(t){return A(t.year()||s.MIN_YEAR,4)},parse:function(t){var n=Number(t);return{year:isNaN(n)?r:n}},minLength:4,maxLength:4,type:"number"},"%w":{format:function(t){return t.dayOfWeek()||s.MIN_DAY_OF_WEEK},parse:function(){return{}},minLength:1,maxLength:1,type:"number"},"%a":{format:function(t){var n=t.dayOfWeek();return B[n!==r?n:s.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%A":{format:function(t){var n=t.dayOfWeek();return k[n!==r?n:s.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%b":{format:function(t){var n=s.options("monthFromZero")?t.month():t.month()-1;return U[n!==r?n:s.MIN_MONTH]},parse:function(t){var n=s.monthNames().indexOf(t)+(s.options("monthFromZero")?0:1);return{month:n!==-1?n:r}},minLength:1,maxLength:999,type:"word"},"%B":{format:function(t){var n=s.options("monthFromZero")?t.month():t.month()-1;return x[n!==r?n:s.MIN_MONTH]},parse:function(t){var n=s.monthNames(!0).indexOf(t)+(s.options("monthFromZero")?0:1);return{month:n!==-1?n:r}},minLength:1,maxLength:999,type:"word"},"%H":{format:function(t){return A(t.hours()||s.MIN_HOURS,2)},parse:function(t){var n=Number(t);return{hours:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%M":{format:function(t){return A(t.minutes()||s.MIN_MINUTES,2)},parse:function(t){var n=Number(t);return{minutes:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%S":{format:function(t){return A(t.seconds()||s.MIN_SECONDS,2)},parse:function(t){var n=Number(t);return{seconds:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%s":{format:function(t){return t.timestamp()},parse:function(t){return isNaN(Number(t))?{}:s(Number(t)).get()},minLength:1,maxLength:20,type:"number"},"%F":{format:function(t){return A(t.year()||s.MIN_YEAR,4)+"-"+A(t.month()||s.MIN_MONTH,2)+"-"+A(t.day()||s.MIN_DAY,2)},parse:function(t){var n=Number(t.slice(0,4)),l=Number(t.slice(5,7)),f=Number(t.slice(8,10));return{year:n,month:l,day:f}},minLength:10,maxLength:10,type:"string"},"%D":{format:function(t){return A(t.month()||s.MIN_MONTH,2)+"/"+A(t.day()||s.MIN_DAY,2)+"/"+A(t.year()||s.MIN_YEAR,4)},parse:function(t){var n=Number(t.slice(0,2)),l=Number(t.slice(3,5)),f=Number(t.slice(6,10));return{year:f,month:n,day:l}},minLength:10,maxLength:10,type:"string"}},ct={useMilliseconds:!1,monthFromZero:!1},T;T=function(t,n,l){return this._d=new Date,this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t!==r&&this.set(t,n,l),this},T.fn=T.prototype,T.fn.dayCount=function(){var t=this.month(),n=s.MAX_DAY_IN_MONTHS[t-(s.options("monthFromZero")?0:1)];return this.leapYear()&&t===(s.options("monthFromZero")?1:2)&&(n+=1),n},T.fn.year=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_YEAR&&Number(t)<=s.MAX_YEAR?(this._d.setFullYear(Number(t)),this._i.year=!1):this._i.year=Number(t):(this._d.setFullYear(s.MIN_YEAR),this._i.year=!1);else return this._i.year===!1?this._d.getFullYear():this._i.year;return this},T.fn.month=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_MONTH&&Number(t)<=s.MAX_MONTH?(this._d.setMonth(s.options("monthFromZero")?Number(t):Number(t)-1),this._i.month=!1):this._i.month=Number(t):(this._d.setMonth(s.options("monthFromZero")?s.MIN_MONTH:s.MIN_MONTH-1),this._i.month=!1);else return this._i.month===!1?s.options("monthFromZero")?this._d.getMonth():this._d.getMonth()+1:this._i.month;return this},T.fn.day=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_DAY&&Number(t)<=this.dayCount()?(this._d.setDate(Number(t)),this._i.day=!1):this._i.day=Number(t):(this._d.setDate(s.MIN_DAY),this._i.day=!1);else return this._i.day===!1?this._d.getDate():this._i.day;return this},T.fn.hours=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_HOURS&&Number(t)<=s.MAX_HOURS?(this._d.setHours(Number(t)),this._i.hours=!1):this._i.hours=Number(t):(this._d.setHours(s.MIN_HOURS),this._i.hours=!1);else return this._i.hours===!1?this._d.getHours():this._i.hours;return this},T.fn.minutes=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_MINUTES&&Number(t)<=s.MAX_MINUTES?(this._d.setMinutes(Number(t)),this._i.minutes=!1):this._i.minutes=Number(t):(this._d.setMinutes(s.MIN_MINUTES),this._i.minutes=!1);else return this._i.minutes===!1?this._d.getMinutes():this._i.minutes;return this},T.fn.seconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_SECONDS&&Number(t)<=s.MAX_SECONDS?(this._d.setSeconds(Number(t)),this._i.seconds=!1):this._i.seconds=Number(t):(this._d.setSeconds(s.MIN_SECONDS),this._i.seconds=!1);else return this._i.seconds===!1?this._d.getSeconds():this._i.seconds;return this},T.fn.milliseconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_MILLISECONDS&&Number(t)<=s.MAX_MILLISECONDS?(this._d.setMilliseconds(Number(t)),this._i.milliseconds=!1):this._i.milliseconds=Number(t):(this._d.setMilliseconds(s.MIN_MILLISECONDS),this._i.milliseconds=!1);else return this._i.milliseconds===!1?this._d.getMilliseconds():this._i.milliseconds;return this},T.fn.week=function(){var t=new Date(this.year(),0,1),n=s(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc()*1e3;return Math.ceil(((n-t.getTime())/864e5+t.getDay()+1)/7)},T.fn.set=function(t,n,l){if(this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t===r)return this._d=new Date,this;if(t instanceof Date)return this._d=t,this;if(typeof t=="number")return this._d=new Date(t*(s.options("useMilliseconds")?1:1e3)),this;if(typeof t=="object"&&(t instanceof Array?(this.day(s.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(s.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"){var f,S=[],p,R,z=[],C=0,P=0,D,X,I={},w;if(t===r)return p=o(this,l),p===r&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),p;for(n===r&&(n=s.detectFormat(t));C<n.length;){if(n.charAt(C)==="%"){if(R=n.charAt(C)+n.charAt(C+1),H[R]!==r){switch(D=0,X="",H[R].type){case"number":for(;D<H[R].maxLength&&P+D<t.length&&!isNaN(Number(t.charAt(P+D)));)X+=t.charAt(P+D),D+=1;break;case"word":for(;D<H[R].maxLength&&P+D<t.length&&/^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(P+D));)X+=t.charAt(P+D),D+=1;break;case"string":for(;D<H[R].maxLength&&P+D<t.length;)X+=t.charAt(P+D),D+=1;break}if(D<H[R].minLength)return p=o(this,l),p===r&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),p;S.push(R),z.push(X),D-=1,P+=D,C+=1}}else if(t.charAt(P)!==n.charAt(C))return p=o(this,l),p===r&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),p;C+=1,P+=1}for(f in S)S.hasOwnProperty(f)&&H.hasOwnProperty(S[f])&&(w=H[S[f]].parse(z[f]),I={year:w.year!==r?w.year:I.year,month:w.month!==r?w.month:I.month,day:w.day!==r?w.day:I.day,hours:w.hours!==r?w.hours:I.hours,minutes:w.minutes!==r?w.minutes:I.minutes,seconds:w.seconds!==r?w.seconds:I.seconds});this.day(s.MIN_DAY),this.year(I.year),this.month(I.month),this.day(I.day),this.hours(I.hours),this.minutes(I.minutes),this.seconds(I.seconds),this.milliseconds(I.milliseconds)}return this},T.fn.leapYear=function(){var t=this.year();return t%4===0?t%100===0?t%400===0:!0:!1},T.fn.timestamp=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(s.options("useMilliseconds")?1:1e3)+this._d.getTimezoneOffset()*6e4),this):s.options("useMilliseconds")?this._d.getTime()-this._d.getTimezoneOffset()*6e4:Math.floor(this._d.getTime()/1e3)-this._d.getTimezoneOffset()*60},T.fn.utc=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(s.options("useMilliseconds")?1:1e3)),this):s.options("useMilliseconds")?this._d.getTime():Math.floor(this._d.getTime()/1e3)},T.fn.dayOfWeek=function(t){if(t==="long")return k[this._d.getDay()];if(t==="short")return B[this._d.getDay()];if(t===r)return this._d.getDay();if(t===0||t==="Sunday")return this.calc({day:-this.dayOfWeek()});if(t===1||t==="Monday")return this.calc({day:(this.dayOfWeek()===0?-6:1)-this.dayOfWeek()});if(t===2||t==="Tuesday")return this.calc({day:(this.dayOfWeek()===0?-5:2)-this.dayOfWeek()});if(t===3||t==="Wednesday")return this.calc({day:(this.dayOfWeek()===0?-4:3)-this.dayOfWeek()});if(t===4||t==="Thursday")return this.calc({day:(this.dayOfWeek()===0?-3:4)-this.dayOfWeek()});if(t===5||t==="Friday")return this.calc({day:(this.dayOfWeek()===0?-2:5)-this.dayOfWeek()});if(t===6||t==="Saturday")return this.calc({day:(this.dayOfWeek()===0?-1:6)-this.dayOfWeek()})},T.fn.timezone=function(t){switch(t){case"hours":return Math.floor(this._d.getTimezoneOffset()/60);case"minutes":return this._d.getTimezoneOffset();default:return this._d.getTimezoneOffset()*60}},T.fn.get=function(t){switch(t){case"Date":return new Date(this.year(),this.month()-(s.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds());case"DateUTC":return new Date(Date.UTC(this.year(),this.month()-(s.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()));case"Array":return[this.year(),this.month(),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()];default:return{year:this.year(),month:this.month(),week:this.week(),day:this.day(),hours:this.hours(),minutes:this.minutes(),seconds:this.seconds(),milliseconds:this.milliseconds(),utc:this.utc(),dayOfWeek:this.dayOfWeek(),dayOfWeekShort:this.dayOfWeek("short"),dayOfWeekLong:this.dayOfWeek("long"),timestamp:this.timestamp()}}},T.fn.format=function(t){for(var n=0,l="",f;n<t.length;)t.charAt(n)==="%"?(f=t.charAt(n)+t.charAt(n+1),H[f]!==r?(l+=H[f].format(this),n+=1):l+="%"):l+=t.charAt(n),n+=1;return l},T.fn.valid=function(){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},T.fn.errors=function(){return this._i},T.fn.between=function(t,n){var l=this.timestamp(),f=t.timestamp();switch(n){case"year":return Math.floor((f-l)/31556952);case"month":return Math.floor((f-l)/2629746);case"day":return Math.floor((f-l)/86400);case"hours":return Math.floor((f-l)/3600);case"minutes":return Math.floor((f-l)/60);case"seconds":return f-l;default:return r}},T.fn.calc=function(t){return t.year!==r&&this._d.setFullYear(this._d.getFullYear()+t.year),t.month!==r&&this._d.setMonth(this._d.getMonth()+t.month),t.day!==r&&this._d.setDate(this._d.getDate()+t.day),t.hours!==r&&this._d.setHours(this._d.getHours()+t.hours),t.minutes!==r&&this._d.setMinutes(this._d.getMinutes()+t.minutes),t.seconds!==r&&this._d.setSeconds(this._d.getSeconds()+t.seconds),t.milliseconds!==r&&this._d.setMilliseconds(this._d.getMilliseconds()+t.milliseconds),this},s=function(t,n,l){return new T(t,n,l)},s.MIN_YEAR=1e3,s.MAX_YEAR=3e3,s.MIN_MONTH=1,s.MAX_MONTH=12,s.MIN_DAY=1,s.MAX_DAY_IN_MONTHS=[31,28,31,30,31,30,31,31,30,31,30,31],s.MIN_DAY_OF_WEEK=0,s.MAX_DAY_OF_WEEK=6,s.MIN_HOURS=0,s.MAX_HOURS=23,s.MIN_MINUTES=0,s.MAX_MINUTES=59,s.MIN_SECONDS=0,s.MAX_SECONDS=59,s.MIN_MILLISECONDS=0,s.MAX_MILLISECONDS=999,s.VERSION="0.2.18",s.options=function(t,n){if(t===r)return ct;if(ct.hasOwnProperty(t)){if(n===r)return ct[t];ct[t]=n,t==="monthFromZero"&&(s.MIN_MONTH=n?0:1,s.MAX_MONTH=n?11:12)}return r},s.noConflict=function(){return i.tempus=u,s},s.generate=function(t){var n,l,f,S,p,R,z,C;if(typeof t.dateFrom!="number"&&(t.dateFrom instanceof T?n=t.dateFrom.utc():n=s(t.dateFrom,t.formatFrom).utc()),typeof t.dateTo!="number"&&(t.dateTo instanceof T?l=t.dateTo.utc():l=s(t.dateTo,t.formatTo!==r?t.formatTo:t.formatFrom).utc()),typeof t.period=="number"?p={year:0,month:0,day:0,hours:0,minutes:0,seconds:t.period}:typeof t.period=="string"?p={year:t.period==="year"?1:0,month:t.period==="month"?1:0,day:t.period==="day"?1:0,hours:t.period==="hours"?1:0,minutes:t.period==="minutes"?1:0,seconds:t.period==="seconds"?1:0}:typeof t.period=="object"&&(p={year:t.period.year!==r?t.period.year:0,month:t.period.month!==r?t.period.month:0,day:t.period.day!==r?t.period.day:0,hours:t.period.hours!==r?t.period.hours:0,minutes:t.period.minutes!==r?t.period.minutes:0,seconds:t.period.seconds!==r?t.period.seconds:0}),t.groupBy===r?R=t.asObject===!0?{}:[]:(R=[],R.push([]),z=s(n).get()[t.groupBy]),C=function(X,I,w){return t.asObject===!0?t.format!==r?X[s(I).format(t.format)]={}:X[s(I).format("%F %H:%M:%S")]={}:t.format!==r?X.push(w?null:s(I).format(t.format)):X.push(w?null:s(I)),X},t.groupBy!==r&&t.fillNulls){var P={year:p.year?-p.year:r,month:p.month?-p.month:r,day:p.day?-p.day:r,hours:p.hours?-p.hours:r,minutes:p.minutes?-p.minutes:r,seconds:p.seconds?-p.seconds:r,milliseconds:p.milliseconds?-p.milliseconds:r};for(f=s(n).calc(P).utc();s(f).get()[t.groupBy]===z;)C(R[R.length-1],f,!0),f=s(f).calc(P).utc();if(t.groupBy==="week"){var D=s(n).dayOfWeek();for(f=s(n).dayOfWeek(0).utc();R[0].length<D&&f<n;)C(R[R.length-1],f,!0),f=s(f).calc(p).utc()}}for(;n<=l;)t.groupBy===r?C(R,n):s(n).get()[t.groupBy]===z?C(R[R.length-1],n):(R.push([]),C(R[R.length-1],n),z=s(n).get()[t.groupBy]),n=s(n).calc(p).utc();if(t.groupBy!==r&&t.fillNulls)for(S=s(l).calc(p).utc();s(S).get()[t.groupBy]===z;)C(R[R.length-1],S,!0),S=s(S).calc(p).utc();return R},s.monthNames=function(t){switch(t){case"long":return x;default:return U}},s.dayNames=function(t){switch(t){case"long":return k;default:return B}},s.lang=function(t){if(t!==r)a=t,c[a]===r&&(a="en"),x=y(),U=O(),k=L(),B=F();else return a;return r},s.availableLangs=function(){return Object.keys(c)},s.registerFormat=function(t,n,l,f,S,p){H[t]={format:n,parse:l,minLength:f,maxLength:S,type:p}},s.unregisterFormat=function(t){delete H[t]},s.detectFormat=function(t){var n,l,f;return n=m(t,0),n!==""&&(f=10),l=t.charAt(f),(l==="T"||l===" ")&&(n+=l,f+=1),n+=h(t,f),n},d={TempusDate:T},s.classes=function(t,n){if(n===r)return d[t];d[t]=n},s.loadTranslations=function(t){typeof t=="object"?c=t:typeof t=="string"&&it(t,function(n){c=n},function(n){})},a=(g.language||g.systemLanguage||g.userLanguage||"en").substr(0,2).toLowerCase(),c[a]===r&&(a="en"),x=y(),U=O(),k=L(),B=F(),W.exports&&(e=W.exports=s),e.tempus=s}).call(E)})($,$.exports);var Tt=$.exports;const rt=b(Tt);class v{constructor(e){this.callBatch=e,this.result={},this.errors={},this.limit=50,this.canContinue=!0,this.progressCall="",this.limitCall="",this.progressData="",this.progressTimer="",this.progressDelay=100,this.oldPercent="no",this.chunkRate=1,this.totalProgress=0,this.skipList=new Set}getData(e){return(e==null?void 0:e.items)??(e==null?void 0:e.tasks)??(e==null?void 0:e.types)??(e==null?void 0:e.type)??(e==null?void 0:e.fields)??(e==null?void 0:e.workgroups)??e}get progressPercent(){let e=0;if(!this.progressData)return{percent:Math.round(e),allCount:0,allTotal:0};let r=0,i=0;return Object.values(this.progressData).forEach(A=>{const{total:o,count:h}=A;r+=o??0,i+=h??0}),r?e=i/r*100*this.chunkRate+this.totalProgress:i===0&&r===0?e=100*this.chunkRate+this.totalProgress:e=100,{percent:Math.round(e),allCount:i,allTotal:r}}setProgressData({key:e,value:r,type:i}){const A=this.getData(r.data()),o=Array.isArray(A)?A.length:0;let h=r.total()||o;i==="count"&&(h=o);let m=1;A&&(m=o),this.progressCall&&(this.progressData||(this.progressData={}),this.progressData[e]&&this.progressData[e].count&&(m+=this.progressData[e].count),this.progressData[e]?this.progressData[e].count=m:this.progressData[e]={total:h,count:m},this.progressTimer||(this.progressTimer=setInterval(()=>{const{percent:u,allCount:s,allTotal:d}=this.progressPercent;(this.oldPercent==="no"||this.oldPercent<this.progressPercent.percent)&&(this.progressCall({data:this.progressData,percent:u,allCount:s,allTotal:d}),this.oldPercent=this.progressPercent.percent),u>=100&&this.clearProgressData()},this.progressDelay)))}delay(){return new Promise(e=>setTimeout(e,500))}stop(){this.canContinue=!1}clearProgressData(){clearInterval(this.progressTimer),this.progressTimer="",this.progressData="",this.progressCall="",this.limitCall="",this.oldPercent="no"}async batch(e,r,i){this.progressTimer&&this.clearProgressData(),r&&(this.progressCall=r),i&&(this.limitCall=i),this.canContinue=!0,this.result={},this.errors={};const A={};this.chunkRate=(1/Math.ceil(Object.keys(e).length/this.limit)).toFixed(5);let o={},h=0;for(const[m,u]of Object.entries(e)){if(!this.canContinue)break;const s=this.arrayChunk(u);if(!s){h++;continue}o[m]=s,(Object.keys(o).length>=50||h+1===Object.keys(e).length)&&(await this.batchChunk(o),Object.entries(this.result).forEach(([d,g])=>{A[d]=g}),this.totalProgress=Math.round(h/Object.keys(e).length*100),o={}),h++}return Object.entries(this.errors).length&&(A.errorsList=this.errors),r&&r({percent:100}),Promise.resolve(A)}async batchTotalCount(e,r,i){this.progressTimer&&this.clearProgressData(),r&&(this.progressCall=r),i&&(this.limitCall=i),this.canContinue=!0,this.result={},this.errors={};const A={};this.chunkRate=(1/Math.ceil(Object.keys(e).length/this.limit)).toFixed(5);let o={},h=0;for(const[m,u]of Object.entries(e)){if(!this.canContinue)break;const s=this.arrayChunk(u);if(!s){h++;continue}o[m]=s,(Object.keys(o).length>=50||h+1===Object.keys(e).length)&&(await this.batchChunk(o,"count"),Object.entries(this.result).forEach(([d,g])=>{A[d]=g}),this.totalProgress=Math.round(h/Object.keys(e).length*100),o={}),h++}return Object.entries(this.errors).length&&(A.errorsList=this.errors),r&&r({percent:100}),Promise.resolve(A)}arrayChunk(e){let r="",i={};if(Array.isArray(e)?[r]=e:(r=e.method,i=e.params),this.skipList.has(r))return!1;if((r.includes("list")||r==="user.get")&&r!=="task.item.list"){if(!i)i={order:{ID:"ASC",id:"ASC"}};else{r==="tasks.task.list"?(i.order||(i.order={}),i.order.ID="asc"):r==="user.get"?(i.sort||(i.sort="ID"),i.order||(i.order="ASC")):i.order={ID:"ASC",id:"ASC"},Array.isArray(i.select)&&!i.select.includes("ID")&&i.select.push("ID");const A=r==="user.get"?i.FILTER:i.filter;typeof A=="object"&&A!==null&&!Array.isArray(A)&&Object.entries(A).forEach(([o,h])=>{(i.start===void 0||i.start!==-1)&&["id","ID"].includes(o)&&(typeof h=="string"||Array.isArray(h)&&h.length<=50)&&(i.start=-1)})}r==="crm.type.list"&&i.order&&delete i.order.ID}if(r==="task.item.list")if(!i)i=[{ID:"ASC"},[""],[""],["ID"]];else{Array.isArray(i[0])&&(i[0]={});const[A,o,h,m]=i;A.ID="ASC",m[0]!==""&&m.includes("ID")||m.push("ID")}return{method:r,params:i}}async batchChunk(e,r){return new Promise(i=>{const A=[];let o;this.callBatch(e,async h=>{var m,u,s,d,g,a,c;for(const[y,O]of Object.entries(h)){if(!this.canContinue)return;if(O.error())switch(this.errors[y]=((u=(m=O.error())==null?void 0:m.ex)==null?void 0:u.error)??((d=(s=O.error())==null?void 0:s.ex)==null?void 0:d.error_description)??((g=O.error())==null?void 0:g.toString())??"Неизвестная ошибка",o=!0,((c=(a=O.error())==null?void 0:a.ex)==null?void 0:c.error)??""){case"OPERATION_TIME_LIMIT":this.skipList.add(e[y].method),this.limitCall&&this.limitCall(y);break;case"QUERY_LIMIT_EXCEEDED":this.canContinue=!1;break;case"ACCESS_DENIED":this.skipList.add(e[y].method);break}const L=this.getData(O.data()),F=Array.isArray(L)?L.length:0,x=typeof O.total=="function"&&O.total()!==void 0,U=x?O.total():F;r==="count"?this.result[y]?this.result[y]+=F:this.result[y]=U:this.result[y]=L,this.setProgressData({key:y,value:O,type:r});const k=r==="count"?!x&&F===this.limit:U>this.limit&&U>F;if(!this.canContinue||k){let B=e[y];if(Array.isArray(B)){const[it,H={}]=B;B=[it,H]}else{const{method:it,params:H={}}=B;B=[it,H]}A.push([y,B,U])}}o>0&&this.errorLogger(),A.length?await this.batchPayload(A,r).then(()=>i(this.result)):i(this.result)})})}async batchPayload(e,r){const i=new Map,A=(u,s,d,g)=>{let a="ID";this.result[u][this.result[u].length-1].ID||(a="id");let c=`${a}`;if(JSON.stringify(g[1]).toLocaleLowerCase().includes('"id":"desc"')?c="<"+c:c=">"+c,s===1||d.length===0)return{field:c,id:this.result[u][this.result[u].length-1][a]};let O="";const[L,F]=g;return(L==="tasks.task.list"||L==="task.item.list")&&(O="[tasks]"),["crm.item.list","crm.stagehistory.list"].includes(L)&&(O="[items]"),L==="crm.type.list"&&(O="[types]"),L==="socialnetwork.api.workgroup.list"&&(O="[workgroups]"),{field:c,id:`$result[${[u,s-1].join("__")}]${O}[49][${a}]`}},o=(u,s)=>{const[d,g]=u;let a=JSON.parse(JSON.stringify(g)),c;if(d==="task.item.list"){a=[...a];const[y,O,L,F]=a;return O[s.field]=s.id,[d,a]}return["user.get"].includes(d)||a.FILTER?(a.FILTER||(a.FILTER={}),c=a.FILTER):(a.filter||(a.filter={}),c=a.filter),["socialnetwork.api.workgroup.list","tasks.task.list"].includes(d)?c[">ID"]=s.id:c[s.field]=s.id,[d,{...a,start:-1}]},h=u=>{Object.entries(u).forEach(([s,d])=>{var c,y,O,L,F,x,U;const[g]=s.split("__"),a=this.getData(d.data());if(Array.isArray(a)&&(r==="count"?this.result[g]+=a.length:this.result[g].push(...a)),d.error()){this.errors[g]=((y=(c=d.error())==null?void 0:c.ex)==null?void 0:y.error)??((L=(O=d.error())==null?void 0:O.ex)==null?void 0:L.error_description)??((F=d.error())==null?void 0:F.toString())??"Неизвестная ошибка";const k=((U=(x=d.error())==null?void 0:x.ex)==null?void 0:U.error)??"";if(k==="OPERATION_TIME_LIMIT"){this.limitCall&&this.limitCall(g);const B=i.get(g);switch(k){case"OPERATION_TIME_LIMIT":B&&(this.skipList.add(B),this.limitCall&&this.limitCall(g));break;case"QUERY_LIMIT_EXCEEDED":this.canContinue=!1;break;case"ACCESS_DENIED":this.skipList.add(B);break}}}this.setProgressData({key:g,value:d,type:r})})};let m=[];for await(const[u,s,d]of e){if(!this.canContinue)return;const[g]=s;if(i.set(u,g),this.skipList.has(g))continue;let a=1;for(;d>a*50&&!this.skipList.has(g);){const c=[u,a].join("__"),y=A(u,a,m,s);m.push([c,o(s,y)]),m.length%50===0&&(await new Promise(O=>this.callBatch(Object.fromEntries(m),L=>{h(L),O()})),m=[],await this.delay()),a++}}m.length&&(await new Promise(u=>this.callBatch(Object.fromEntries(m),s=>{h(s),u()})),await this.delay())}errorLogger(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(this.errors).forEach(([e,r])=>{r&&console.log(`[${e}]`,r.toString())}),console.groupEnd()}}class ut{constructor(){Y(this,V,{})}get hash(){return this.createHash(8)}createHash(e){let r="abcdefghijklmnopqrstuvwxyz0123456789",i="";e=e||6;for(let A=0;A<e;A++)i+=r.charAt(Math.floor(Math.random()*r.length));return i}actionFilter({keyTimer:e,duration:r=10,action:i}){_(this,V)[e]&&(clearTimeout(_(this,V)[e]),_(this,V)[e]=null),i&&(_(this,V)[e]=setTimeout(()=>{i()},r))}async noSleep(){let e=document.createElement("video");e.classList.add("no-sleep"),e.muted=!0,e.autoplay=!0,e.setAttribute("playsinline",""),e.addEventListener("loadeddata",()=>{e.style.position="fixed",e.style.left="-9999px",document.querySelector("body").append(e),e.play().catch(r=>{console.warn("noSleep: autoplay prevented",r)})}),e.addEventListener("ended",()=>{this.actionFilter({keyTimer:"no-sleep",duration:5e3,action:()=>{e.play().catch(r=>{console.warn("noSleep: replay prevented",r)})}})}),e.src="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAP5tZGF0AAAAAQYAAADlZYiEE28FmH9jNWDBjI+Z/1tIBZsjfhbmcNNUpBFej0U3p+zhaJ3eemJRL2LUMa5tkidy6bp+eatLE3jBIY864TvaAmqEFCgLMTCwVbem1n3myAw9yDXQdR5HfU/8iYf+eneVnRf7Qx9M70XDUuPx1MJX671XJwAE0VAMpnhbcUDx0pTldvUX9KQPhkZNH3eyZHmObkAeyEJ2tl+BEBJIGc90BiqKL60+5EA6fXB6iG5UU/M5KsW8BNAAUw5CbRJIqohNk10fwKbUXwya03rqGkE8+wuYGtEbrVYXb+iOl1mHHVPLYQbIAAcGyAAHAAAFNG1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAAAAvAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAIldHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAFAAAAA8AAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAAAAAAAAAAAQAAAAABnW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAAAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAUhtaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAEIc3RibAAAAKRzdHNkAAAAAAAAAAEAAACUYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAFAAPAASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAAC5hdmNDAU1AC//hABZnTUAL2wUH7ARAAAADAEAAAAQDxQq4AQAFaOrAZXIAAAAQcGFzcAAAAAEAAAABAAAAGHN0dHMAAAAAAAAAAQAAAAEAAAAAAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAABAAAAAQAAABRzdHN6AAAAAAAAAO4AAAABAAAAFHN0Y28AAAAAAAAAAQAAADAAAAIadHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAAAvAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAALwAAAAAAAQAAAAABkm1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAArEQAAAgAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAT1taW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAQFzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAAC7gAAAAViBYCAgAISCAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAACAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAgAAAAEAAAAUc3RzegAAAAAAAAAEAAAAAgAAABRzdGNvAAAAAAAAAAEAAAEeAAAAGnNncGQBAAAAcm9sbAAAAAIAAAAB//8AAAAcc2JncAAAAAByb2xsAAAAAQAAAAIAAAABAAAAgXVkdGEAAAB5bWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWR0YQAAAAAAAAAAAAAAAAAAAAAfa2V5cwAAAAAAAAABAAAAD21kdGFlbmNvZGVyAAAALWlsc3QAAAAlAAAAAQAAAB1kYXRhAAAAAQAAAABMYXZmNTguMTIuMTAw"}downloadFileJson(e,r){let i=new Blob([JSON.stringify(e)],{type:"application/json"}),A=URL.createObjectURL(i),o=document.createElement("a");o.style.display="none",o.href=A,o.download=`${r}.json`,document.body.appendChild(o),o.click(),setTimeout(()=>{document.body.removeChild(o),URL.revokeObjectURL(A)},200)}}V=new WeakMap;const ft=new ut;class gt{constructor(){Y(this,nt);Y(this,st);Y(this,At);Y(this,ot);Y(this,at);Y(this,j,"logger");Y(this,Z,!1);Y(this,K,new Map);Y(this,tt,{});Y(this,G,null);Y(this,q,!1);Y(this,et,!1);M(this,"periodClear",3);Q(this,nt,Nt).call(this)}async init(){try{let e=new v(BX24.callBatch),{entityList:r}=await e.batch({entityList:{method:"entity.get"}});if(r&&Array.isArray(r))if(r.find(A=>A.ENTITY==_(this,j)))J(this,Z,!0);else{let{entityAdd:A}=await e.batch({entityAdd:{method:"entity.add",params:{ENTITY:_(this,j),NAME:_(this,j),ACCESS:{AU:"X"}}}});A&&J(this,Z,!0)}return Q(this,ot,pt).call(this).catch(i=>{console.error("Ошибка при проверке периода очистки:",i)}),_(this,Z)}catch(e){return console.error("Ошибка при инициализации логера:",e),!1}}start({type:e,data:r}){if(!_(this,Z))return Q(this,st,dt).call(this,"entity"),null;if(!e||!r)return console.error("Невалидные данные для логирования:",{type:e,data:r}),null;const i=ft.hash,A={type:e,data:r,userInfo:_(this,tt),errorList:{},status:"",answer:null,date:new Date().getTime()};return _(this,K).set(i,A),J(this,et,!0),i}async stop({key:e,errorList:r,status:i,answer:A}){var h;if(!_(this,et))return;if(!_(this,Z)){Q(this,st,dt).call(this,"entity");return}let o=_(this,K).get(e);if(!o){console.error(`Не найдены данные логирования для ключа: ${e}`);return}r&&(o.errorList=r),i&&(o.status=i),A&&(o.answer=A),await Q(this,At,Ot).call(this),(h=o==null?void 0:o.data)!=null&&h.updateList&&J(this,q,!0),J(this,et,!1)}async getEntityList(e){var r;try{if((r=_(this,G))!=null&&r.length&&!_(this,q))return _(this,G);let i=new v(BX24.callBatch),{entityList:A}=await i.batch({entityList:{method:"entity.item.get",params:{ENTITY:_(this,j),SORT:{ID:"DESC"}}}},e);return!A||!Array.isArray(A)?(console.warn("Получен невалидный список записей"),[]):(A=A.map(o=>{try{const{ID:h,DATE_CREATE:m,DETAIL_TEXT:u}=o;return{...JSON.parse(u),id:h,dateCreate:m}}catch(h){return console.error(`Ошибка парсинга записи ${o.ID}:`,h),null}}).filter(o=>o!==null),J(this,q,!1),J(this,G,A),A)}catch(i){return console.error("Ошибка при получении списка записей:",i),[]}}async downAllEntityJson(){try{if(_(this,G)||await this.getEntityList(),!_(this,G)||_(this,G).length===0)return console.warn("Нет данных для выгрузки"),!1;let e=rt().format("%Y-%m-%d");return ft.downloadFileJson(_(this,G),`sdklogger-entity-data__${e}`),!0}catch(e){return console.error("Ошибка при выгрузке данных в JSON:",e),!1}}}j=new WeakMap,Z=new WeakMap,K=new WeakMap,tt=new WeakMap,G=new WeakMap,q=new WeakMap,et=new WeakMap,nt=new WeakSet,Nt=async function(){try{const e=new v(BX24.callBatch),r=BX24.isAdmin(),{curUser:i}=await e.batch({curUser:{method:"user.current"}});J(this,tt,{isAdmin:r,curUser:i})}catch(e){console.error("Ошибка при получении информации о пользователе:",e),J(this,tt,{isAdmin:!1,curUser:null})}},st=new WeakSet,dt=function(e){e=="entity"&&ft.actionFilter({keyTimer:"error.logger.entity",duration:500,action:()=>{console.error("Хранилище для логгера не инициализировано")}})},At=new WeakSet,Ot=async function(){try{let e={},r=new v(BX24.callBatch);for(let[i,A]of _(this,K).entries())if(A.status){const o=JSON.stringify(A);e[i]={method:"entity.item.add",params:{ENTITY:_(this,j),NAME:_(this,j),DETAIL_TEXT:o}}}if(Object.keys(e).length){let i=await r.batch(e),{errors:A}=r;for(let[o,h]of Object.entries({...i,...A}))_(this,K).delete(o);return!0}return!1}catch(e){return console.error("Ошибка при добавлении записей в хранилище:",e),!1}},ot=new WeakSet,pt=async function(){try{let e=new v(BX24.callBatch),{serverTime:r}=await e.batch({serverTime:{method:"server.time"}});if(!r){console.error("Не удалось получить время сервера");return}if(_(this,G)||await this.getEntityList(),!_(this,G)||_(this,G).length===0)return;let i=_(this,G).filter(A=>{try{let{dateCreate:o}=A;return o?rt(new Date(o)).between(rt(new Date(r)),"month")>=this.periodClear:!1}catch(o){return console.error("Ошибка при проверке даты записи:",o),!1}});i.length>0&&(console.log(`Найдено ${i.length} записей для очистки (старше ${this.periodClear} месяцев)`),await Q(this,at,_t).call(this,i))}catch(e){console.error("Ошибка при проверке периода очистки:",e)}},at=new WeakSet,_t=async function(e){try{if(!e||e.length===0)return!1;let r=new v(BX24.callBatch),i=e.filter(o=>o&&o.id).map(o=>{let{id:h}=o;return{method:"entity.item.delete",params:{ENTITY:_(this,j),ID:h}}});if(i.length===0)return!1;const A=await r.batch(i);return console.log(`Успешно удалено ${i.length} записей`),J(this,q,!0),A}catch(r){return console.error("Ошибка при очистке устаревших записей:",r),!1}};class Rt{constructor(e){Y(this,ht);Y(this,lt);M(this,"domain","");M(this,"isAdmin",!1);M(this,"appInfo",null);M(this,"appConst",null);M(this,"userInfo",null);M(this,"placeData",null);M(this,"placeInfo",null);M(this,"logger",!1);this.appConst=e}init(){return new Promise((e,r)=>{let A=setInterval(()=>{window.BX24&&BX24.init(async()=>{console.info("init BX24"),clearInterval(A),clearTimeout(o),this.domain=BX24.getDomain(),this.isAdmin=BX24.isAdmin(),this.placeInfo=BX24.placement.info(),this.logger?(this.logger=new gt,await this.logger.init()):this.logger={start:()=>{},stop:()=>{},getEntityList:()=>{}};const[h,m]=await Promise.all([Q(this,ht,yt).call(this),Q(this,lt,Et).call(this)]);this.appInfo=h,this.userInfo=m;let u=new ut;try{u.noSleep()}catch(s){console.warn("Failed to initialize noSleep:",s)}e(!0)})},100);const o=setTimeout(()=>{clearInterval(A);const h=new Error("BX24 initialization timeout: BX24 object not found within 30 seconds");console.error(h),r(h)},3e4)})}userOption(e,r){if(typeof BX24>"u"||!BX24.userOption){console.warn("BX24.userOption is not available. Make sure BX24 is initialized.");return}return r!==void 0?BX24.userOption.set(e,r):BX24.userOption.get(e)}appOption(e,r){if(typeof BX24>"u"||!BX24.appOption){console.warn("BX24.appOption is not available. Make sure BX24 is initialized.");return}return r!==void 0?BX24.appOption.set(e,r):BX24.appOption.get(e)}async call({method:e,params:r,updateList:i}){let A;if(i&&(A=this.logger.start({type:"call",data:{method:e,params:r,updateList:i}})),r||(r={}),typeof BX24>"u"||!BX24.callMethod){const o=new Error("BX24 is not initialized");throw console.error(o),o}return new Promise((o,h)=>{BX24.callMethod(e,r,async m=>{let u={};if(m!=null&&m.answer)for(let[s,d]of Object.entries(m.answer))s!=="result"&&d&&(u[s]=d);if(m.error()){let s=m.error();if(console.error(s),A)try{await this.logger.stop({answer:u,key:A,status:"fail",errorList:{0:s.toString()}})}catch(d){console.error("Logger error:",d)}o(!1)}else{let s=m.data();if(s!=null&&s.items&&(s=s.items),A)try{await this.logger.stop({answer:u,key:A,status:"success"})}catch(d){console.error("Logger error:",d)}o(s)}})})}async batch(e,r,{errorCall:i,limitCommandSerial:A,updateList:o,limitCall:h}={}){if(typeof BX24>"u"||!BX24.callBatch){const s=new Error("BX24 is not initialized");return console.error(s),!1}let m=new v(BX24.callBatch),u;o&&(u=this.logger.start({type:"batch",data:{commandList:e,updateList:o}})),A&&console.warn("limitCommandSerial is deprecated and not used in current Batch implementation");try{let s=await m.batch(e,r,h);if(Object.keys(m.errors).length){if(i&&i(m.errors),u)try{await this.logger.stop({key:u,status:"fail",errorList:m.errors})}catch(d){console.error("Logger error:",d)}}else if(u)try{await this.logger.stop({key:u,status:"success"})}catch(d){console.error("Logger error:",d)}return s}catch(s){if(u)try{await this.logger.stop({key:u,status:"fail-runtime",errorList:{0:s==null?void 0:s.toString()}})}catch(d){console.error("Logger error:",d)}return console.error(s),!1}}async batchTotalCount(e,r,{errorCall:i,updateList:A,limitCall:o}={}){if(typeof BX24>"u"||!BX24.callBatch){const u=new Error("BX24 is not initialized");return console.error(u),!1}let h=new v(BX24.callBatch),m;A&&(m=this.logger.start({type:"batch-total-count",data:{commandList:e}}));try{let u=await h.batchTotalCount(e,r,o);if(Object.keys(h.errors).length){if(i&&i(h.errors),m)try{await this.logger.stop({key:m,status:"fail",errorList:h.errors})}catch(s){console.error("Logger error:",s)}}else if(m)try{await this.logger.stop({key:m,status:"success"})}catch(s){console.error("Logger error:",s)}return u}catch(u){if(m)try{await this.logger.stop({key:m,status:"fail-runtime",errorList:{0:u==null?void 0:u.toString()}})}catch(s){console.error("Logger error:",s)}return console.error(u),!1}}async getPlacement(){return await this.call({method:"placement.get"}).then(e=>(this.placeData||(this.placeData=e),e))}async placementBind(e,r=!0){var d;if(!this.isAdmin)return;r&&await this.placementCheck();let i=[];if(Array.isArray(e)?i=e.map(g=>typeof g=="string"?{placement:g}:g):typeof e=="string"?i=[{placement:e}]:i=[e],this.placeData=await this.getPlacement(),!this.placeData)return;const{appName:A,pathApp:o}=this.appConst;let h=A;this.domain==="szdl.bitrix24.ru"&&((d=this.appInfo)!=null&&d.ID)&&(h=`${A}: #${this.appInfo.ID}`);const m=h.replace(" CRM",""),u={},s=[];for(let g=0;g<i.length;g++){const a=i[g],c=a.placement,y=a.userId;let O=o,L=c;if(c==="PAGE_BACKGROUND_WORKER"){if(!y){console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${c}`);continue}O=`${o}?USER_ID=${y}/`}if(c==="PAGE_BACKGROUND_WORKER_ALL"&&(L="PAGE_BACKGROUND_WORKER"),this.placeData.find(k=>k.placement===L&&k.handler===O))continue;let x=this.placeData.find(k=>k.placement===L&&k.handler!==O);x&&s.push({placement:L,handler:x.handler});const U={PLACEMENT:L,HANDLER:O,LANG_ALL:{ru:{TITLE:L==="USER_PROFILE_TOOLBAR"?m:h}},OPTIONS:{errorHandlerUrl:O}};c==="PAGE_BACKGROUND_WORKER"&&y&&(U.USER_ID=y),u[`bind_${g}`]={method:"placement.bind",params:U}}s.length>0&&await this.placementUnBind(s),Object.keys(u).length>0&&await this.batch(u),Object.keys(u).length>0&&(this.placeData=await this.getPlacement(),Object.values(u).forEach(g=>{console.log("Приложение успешно встроено в",g.params.PLACEMENT)}))}async placementUnBind(e){let r=[];Array.isArray(e)?r=e.map(A=>typeof A=="string"?{placement:A}:A):typeof e=="string"?r=[{placement:e}]:r=[e];const i={};for(let A=0;A<r.length;A++){const o=r[A],h=o.placement,m=o.handler,u={PLACEMENT:h};m&&(u.HANDLER=m),i[`unbind_${A}`]={method:"placement.unbind",params:u}}Object.keys(i).length>0&&(await this.batch(i),r.forEach(A=>{console.log("Встройка отвязана",A.placement)}))}async placementCheck(){if(this.placeData=await this.getPlacement(),!this.placeData)return;const{pathApp:e}=this.appConst,r=[],i=[];for(const A of this.placeData){if(!A.handler||A.handler.includes(e))continue;const{placement:o,handler:h,userId:m}=A;r.push({placement:o,handler:h}),i.push({placement:o,userId:m})}r.length>0&&await this.placementUnBind(r),i.length>0&&await this.placementBind(i,!1)}getBotList(){return this.call({method:"imbot.bot.list",params:{}}).then(e=>{let r=Object.values(e);return console.log("chat-bot list:",r),r})}regBot({code:e,type:r,name:i}){const{appName:A,pathApp:o,chatBotLogo:h}=this.appConst,m=this.appInfo.ID;return this.call({method:"imbot.register",params:{CODE:e??this.appInfo.CODE,TYPE:r??"O",EVENT_HANDLER:o,OPENLINE:"Y",CLIENT_ID:"",PROPERTIES:{NAME:`${i??A} - бот #${m}`,LAST_NAME:"",COLOR:"GREEN",EMAIL:"",PERSONAL_BIRTHDAY:rt().format("%Y-%m-%d"),WORK_POSITION:"Почтальон",PERSONAL_WWW:"",PERSONAL_GENDER:"M",PERSONAL_PHOTO:h??""}}}).then(u=>(console.log("Чат-бот добавлен",u),u))}unRegBot(e){return this.call({method:"imbot.unregister",params:{BOT_ID:e}}).then(r=>(console.log("чат-бот удален",r),r))}getLoggerList(e){return this.logger.getEntityList(e)}}ht=new WeakSet,yt=function(){return this.call({method:"app.info"})},lt=new WeakSet,Et=function(){return this.call({method:"user.current"})};class Lt{constructor(e){M(this,"entityName","tabs");M(this,"maxTabs",5);M(this,"interval");M(this,"id",0);M(this,"tabList",[]);M(this,"random",this.getRandomNum());M(this,"continueCondition");M(this,"defaultContinueBackground",()=>!0);M(this,"activeMaxPause",60*1e3*5+this.random);M(this,"activeMinPause",60*1e3*3+this.random);if(!e){console.error("В бек-воркер не переданы настройки, отмена вызова"),console.log("BackgroundWorker: Отмена конструктора - отсутствуют опции");return}const{appFunc:r,bx:i,users:A,continueBackground:o}=e;this.bx=i,this.appPath=i.appConst.pathApp??"",this.appName=i.appConst.appName??"",this.appInit=r,this.users=A,this.start=new Date,this.continueCondition=typeof o=="function"?o:this.defaultContinueBackground}async init(){if(!this.appInit){console.error("Функция-запуск не передана в appInit, отмена инициализации бекворкера"),console.log("BackgroundWorker: Отмена init - не передана appInit");return}if(!this.bx){console.error("Не передан экземпляр bxBoot"),console.log("BackgroundWorker: Отмена init - отсутствует bx");return}if(await this.bx.placementBind(["PAGE_BACKGROUND_WORKER"]),!await this.continueBackground()){console.log("BackgroundWorker: Отмена init - условие запуска не выполнено");return}await this.checkEntity(),this.tabList=await this.getFilteredTabList(),this.id=await this.addTab(),console.log("tabId",this.id),this.interval=setInterval(()=>{this.backgroundPolling().catch(e=>{console.error("BackgroundWorker: backgroundPolling failed",e)})},this.activeMinPause)}async checkEntity(){var i;const e=await this.bx.call({method:"entity.get"});((i=e==null?void 0:e.find)==null?void 0:i.call(e,A=>A.ENTITY===this.entityName))||await this.bx.call({method:"entity.add",params:{ENTITY:this.entityName,NAME:this.entityName,ACCESS:{AU:"X"}}})}async getTabs(){var r;const e=await this.bx.call({method:"entity.item.get",params:{ENTITY:this.entityName,FILTER:{NAME:(r=this.bx.userInfo)==null?void 0:r.ID},SORT:{DATE_CREATE:"DESC"}}});return e!=null&&e.length?e.map(i=>{if(!i)return{id:void 0,data:void 0};try{return{id:i.ID,data:{...JSON.parse(i.DETAIL_TEXT)}}}catch(A){return console.log(A),{id:i.ID,data:void 0}}}):[]}async addTab(){var r;const e={lastActive:new Date().toISOString(),duration:new Date().getTime()-this.start.getTime(),start:!1};return this.tabList.length<this.maxTabs&&await this.bx.call({method:"entity.item.add",params:{ENTITY:this.entityName,NAME:(r=this.bx.userInfo)==null?void 0:r.ID,DETAIL_TEXT:JSON.stringify(e)}})||0}async updateTab(e){var i;const r={lastActive:new Date().toISOString(),duration:new Date().getTime()-this.start.getTime(),start:e};await this.bx.call({method:"entity.item.update",params:{ENTITY:this.entityName,ID:this.id,NAME:(i=this.bx.userInfo)==null?void 0:i.ID,DETAIL_TEXT:JSON.stringify(r)}})}async deleteTabs(e=[]){if(!e.length)return;const r=e.map(i=>({method:"entity.item.delete",params:{ENTITY:this.entityName,ID:i.id}}));r.length&&await this.bx.batch(r)}getRandomNum(){const e=Math.round(Number(Math.random().toFixed(2))*30);return Math.round(Math.random())?e:-e}async continueBackground(){try{const r=!!await Promise.resolve(this.continueCondition(this));return console.log(r?"BackgroundWorker: Условие продолжения выполнено":"BackgroundWorker: Отмена continueBackground - внешнее условие вернуло false"),r}catch(e){return console.error("BackgroundWorker: Ошибка при выполнении условия продолжения",e),console.log("BackgroundWorker: Отмена continueBackground - исключение в условии запуска"),!1}}async getFilteredTabList(){const e=[],r=[],i=await this.getTabs();for(const A of i){if(!(A!=null&&A.data)){e.push(A);continue}new Date().getTime()-new Date(A.data.lastActive).getTime()>this.activeMaxPause?e.push(A):r.push(A)}return await this.deleteTabs(e),r}async backgroundPolling(){if(!await this.continueBackground()){this.interval&&(clearInterval(this.interval),this.interval=void 0),console.log("BackgroundWorker: Остановка backgroundPolling - условие continueBackground не выполнено");return}if(this.tabList=await this.getFilteredTabList(),!this.id){this.id=await this.addTab();return}let e=this.checkOtherTabs();e&&(await this.pause(Math.round(Number(Math.random().toFixed(2))*1e4)),this.tabList=await this.getFilteredTabList(),e=this.checkOtherTabs(),e&&await this.startBackground())}checkOtherTabs(){var A,o;let e=!1,r=new Date().getTime()-new Date(this.start).getTime();for(const h of this.tabList)if(+h.id!==this.id&&((A=h.data)!=null&&A.start&&(e=!0),((o=h.data)==null?void 0:o.duration)>r)){r=!1;break}const i=!e&&!!r;return this.updateTab(i).catch(h=>{console.error("BackgroundWorker: updateTab failed",h)}),console.log(`BackgroundWorker: Проверка вкладок - можно запускать приложение? ${i}`),i}async startBackground(){this.interval&&(clearInterval(this.interval),this.interval=void 0),this.interval=setInterval(()=>{this.updateTab(!0).catch(e=>{console.error("BackgroundWorker: periodic updateTab failed",e)})},this.activeMinPause),await this.appInit(),this.interval&&(clearInterval(this.interval),this.interval=void 0),this.id&&(await this.deleteTabs([{id:this.id}]),this.id=0)}async setBackgroundWorkerAll(){var d,g;if(!((d=this.bx)!=null&&d.isAdmin)){console.log("BackgroundWorker: Отмена setBackgroundWorkerAll - пользователь не админ");return}(g=this.users)!=null&&g.length||await this.getEntityData();const e=await this.bx.getPlacement(),r=new Map;let i=null;e.forEach(a=>{a.placement==="PAGE_BACKGROUND_WORKER"&&(a.userId?r.set(+a.userId,a):i=a)}),console.log(`setBackgroundWorkerAll: Найдено ${r.size} индивидуальных и ${i?1:0} общих привязок PAGE_BACKGROUND_WORKER`);const A=await this.getAdminsList(),o=await this.getEligibleUsersForBackgroundWorker(A);o.sort((a,c)=>{const y=a.LAST_LOGIN?new Date(a.LAST_LOGIN):new Date(0);return(c.LAST_LOGIN?new Date(c.LAST_LOGIN):new Date(0))-y}),console.log(`setBackgroundWorkerAll: Найдено ${o.length} подходящих пользователей (админы и руководители)`);const h=[];!i&&this.appPath&&(h.push({method:"placement.bind",params:{PLACEMENT:"PAGE_BACKGROUND_WORKER",HANDLER:`${this.appPath}/`,LANG_ALL:{ru:{TITLE:this.appName}},OPTIONS:{errorHandlerUrl:`${this.appPath}/`}}}),console.log("setBackgroundWorkerAll: Добавлен в очередь создание общего бэк-воркера"));const m=10,u=o.slice(0,m),s=[];for(const[a]of r)o.find(y=>+y.ID===a)||s.push(a);for(const a of s)this.appPath&&(h.push({method:"placement.unbind",params:{PLACEMENT:"PAGE_BACKGROUND_WORKER",HANDLER:`${this.appPath}?USER_ID=${a}/`}}),console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${a}`));for(const a of u)r.has(+a.ID)||!this.appPath||h.push({method:"placement.bind",params:{PLACEMENT:"PAGE_BACKGROUND_WORKER",HANDLER:`${this.appPath}?USER_ID=${a.ID}/`,LANG_ALL:{ru:{TITLE:this.appName}},OPTIONS:{errorHandlerUrl:`${this.appPath}?USER_ID=${a.ID}/`},USER_ID:a.ID}});h.length?(console.log(`setBackgroundWorkerAll: Выполняем ${h.length} операций через batch`),await this.bx.batch(h),console.log("setBackgroundWorkerAll: Все операции batch выполнены успешно")):console.log("setBackgroundWorkerAll: Нет операций для выполнения")}async getEligibleUsersForBackgroundWorker(e=[]){return(this.users??[]).filter(i=>i.ACTIVE==="Y"||i.ACTIVE===!0).filter(i=>{const A=+i.ID;return e.includes(A)})}async updateAdminsList(){var e,r,i;try{const A=BX24.appOption.get("adminsList");let o=[];if(A)try{o=JSON.parse(A)}catch{console.log("updateAdminsList: Ошибка парсинга существующего списка админов, создаем новый"),o=[]}const h=+(((e=this.bx.userInfo)==null?void 0:e.ID)??0);(r=this.bx)!=null&&r.isAdmin&&h&&!o.includes(h)&&(o.push(h),console.log(`updateAdminsList: Добавлен новый админ ${h}`)),!((i=this.bx)!=null&&i.isAdmin)&&h&&o.includes(h)&&(o=o.filter(s=>s!==h),console.log(`updateAdminsList: Удален из списка админов пользователь ${h} (больше не админ)`));const m=new Set((this.users??[]).filter(s=>s.ACTIVE==="Y"||s.ACTIVE===!0).map(s=>+s.ID)),u=o.filter(s=>m.has(s));return u.length!==o.length&&(console.log(`updateAdminsList: Удалено ${o.length-u.length} неактивных админов`),o=u),BX24.appOption.set("adminsList",JSON.stringify(o)),console.log(`BackgroundWorker: Список админов обновлен: ${o.length} админов`),o}catch(A){return console.error("BackgroundWorker: Ошибка при обновлении списка админов:",A),[]}}async getAdminsList(){try{const e=BX24.appOption.get("adminsList");return e?JSON.parse(e):[]}catch(e){return console.error("getAdminsList: Ошибка при получении списка админов:",e),[]}}async getEntityData(){const e={users:{method:"user.get",params:{filter:{ACTIVE:"Y"}}}},{users:r}=await this.bx.batch(e).then(i=>i?(Array.isArray(i.users)||(i.users=[]),i):{users:[]});this.users=r}pause(e=500,r){return new Promise(i=>{setTimeout(()=>{r&&r(),i(!0)},e)})}}N.BackgroundWorker=Lt,N.Batch=v,N.BxBoot=Rt,N.BxHelper=ut,N.BxLogger=gt,N.tempus=rt,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
1
+ var bt=Object.defineProperty;var St=(N,E,b)=>E in N?bt(N,E,{enumerable:!0,configurable:!0,writable:!0,value:b}):N[E]=b;var M=(N,E,b)=>(St(N,typeof E!="symbol"?E+"":E,b),b),mt=(N,E,b)=>{if(!E.has(N))throw TypeError("Cannot "+b)};var p=(N,E,b)=>(mt(N,E,"read from private field"),b?b.call(N):E.get(N)),Y=(N,E,b)=>{if(E.has(N))throw TypeError("Cannot add the same private member more than once");E instanceof WeakSet?E.add(N):E.set(N,b)},J=(N,E,b,$)=>(mt(N,E,"write to private field"),$?$.call(N,b):E.set(N,b),b);var Q=(N,E,b)=>(mt(N,E,"access private method"),b);(function(N,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(N=typeof globalThis<"u"?globalThis:N||self,E(N["szdl-utils-kit"]={}))})(this,function(N){var V,j,Z,K,tt,G,q,et,nt,Nt,st,dt,At,Ot,ot,_t,at,pt,ht,yt,lt,Et;"use strict";var E=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function b(W){return W&&W.__esModule&&Object.prototype.hasOwnProperty.call(W,"default")?W.default:W}var $={exports:{}};(function(W,e){(function(r){Array.prototype.indexOf||(Array.prototype.indexOf=function(t,n){var c,f;for(c=n||0,f=this.length;c<f;c+=1)if(this[c]===t)return c;return-1});var i=this,A=function(t,n){for(var c=t.toString();c.length<n;)c="0"+c;return c},o=function(t,n){return n!==r?(t.year(n.year()||n.year),t.month(n.month()||n.month),t.day(n.day()||n.day),t.hours(n.hours()||n.hours),t.minutes(n.minutes()||n.minutes),t.seconds(n.seconds()||n.seconds),t.milliseconds(n.milliseconds()||n.milliseconds),t):r},h=function(t,n){var c,f="";return c=t.slice(n,n+1),c!==""&&!isNaN(Number(c))&&(f+="%H"),c=t.charAt(n+2),c!==""&&c===":"&&(f+=c),c=t.slice(n+3,n+4),c!==""&&!isNaN(Number(c))&&(f+="%M"),c=t.charAt(n+5),c!==""&&c===":"&&(f+=c),c=t.slice(n+6,n+7),c!==""&&!isNaN(Number(c))&&(f+="%S"),f},m=function(t,n){var c,f=[t.slice(n,n+1),t.charAt(n+2),t.slice(n+3,n+4),t.charAt(n+5),t.slice(n+6,n+9)],S;return!isNaN(Number(f[0]))&&!isNaN(Number(f[2]))&&!isNaN(Number(f[4]))?(f[1]==="."&&f[3]==="."?c="%d.%m.%Y":f[1]==="-"&&f[3]==="-"?c="%m-%d-%Y":f[1]==="/"&&f[3]==="/"&&(c="%m/%d/%Y"),c):(S=[t.slice(n,n+3),t.charAt(n+4),t.slice(n+5,n+6),t.charAt(n+7),t.slice(n+8,n+9)],!isNaN(Number(S[0]))&&!isNaN(Number(S[2]))&&!isNaN(Number(S[4]))?(S[1]==="-"&&S[3]==="-"&&(c="%Y-%m-%d"),c):"")},l=i.tempus,s,d,g=i.navigator||{},a="en",u={en:{JANUARY_SHORT:"Jan",FEBRUARY_SHORT:"Feb",MARCH_SHORT:"Mar",APRIL_SHORT:"Apr",MAY_SHORT:"May",JUNE_SHORT:"Jun",JULY_SHORT:"Jul",AUGUST_SHORT:"Aug",SEPTEMBER_SHORT:"Sep",OCTOBER_SHORT:"Oct",NOVEMBER_SHORT:"Nov",DECEMBER_SHORT:"Dec",JANUARY_LONG:"January",FEBRUARY_LONG:"February",MARCH_LONG:"March",APRIL_LONG:"April",MAY_LONG:"May",JUNE_LONG:"June",JULY_LONG:"July",AUGUST_LONG:"August",SEPTEMBER_LONG:"September",OCTOBER_LONG:"October",NOVEMBER_LONG:"November",DECEMBER_LONG:"December",SUNDAY_SHORT:"Sun",MONDAY_SHORT:"Mon",TUESDAY_SHORT:"Tue",WEDNESDAY_SHORT:"Wed",THURSDAY_SHORT:"Thu",FRIDAY_SHORT:"Fri",SATURDAY_SHORT:"Sat",SUNDAY_LONG:"Sunday",MONDAY_LONG:"Monday",TUESDAY_LONG:"Tuesday",WEDNESDAY_LONG:"Wednesday",THURSDAY_LONG:"Thursday",FRIDAY_LONG:"Friday",SATURDAY_LONG:"Saturday"},ru:{JANUARY_SHORT:"Янв",FEBRUARY_SHORT:"Фев",MARCH_SHORT:"Мар",APRIL_SHORT:"Апр",MAY_SHORT:"Май",JUNE_SHORT:"Июн",JULY_SHORT:"Июл",AUGUST_SHORT:"Авг",SEPTEMBER_SHORT:"Сен",OCTOBER_SHORT:"Окт",NOVEMBER_SHORT:"Ноя",DECEMBER_SHORT:"Дек",JANUARY_LONG:"Январь",FEBRUARY_LONG:"Февраль",MARCH_LONG:"Март",APRIL_LONG:"Апрель",MAY_LONG:"Май",JUNE_LONG:"Июнь",JULY_LONG:"Июль",AUGUST_LONG:"Август",SEPTEMBER_LONG:"Сентябрь",OCTOBER_LONG:"Октябрь",NOVEMBER_LONG:"Ноябрь",DECEMBER_LONG:"Декабрь",SUNDAY_SHORT:"Вс",MONDAY_SHORT:"Пн",TUESDAY_SHORT:"Вт",WEDNESDAY_SHORT:"Ср",THURSDAY_SHORT:"Чт",FRIDAY_SHORT:"Пт",SATURDAY_SHORT:"Сб",SUNDAY_LONG:"Воскресенье",MONDAY_LONG:"Понедельник",TUESDAY_LONG:"Вторник",WEDNESDAY_LONG:"Среда",THURSDAY_LONG:"Четверг",FRIDAY_LONG:"Пятница",SATURDAY_LONG:"Суббота"},ua:{JANUARY_SHORT:"Січ",FEBRUARY_SHORT:"Лют",MARCH_SHORT:"Берез",APRIL_SHORT:"Квіт",MAY_SHORT:"Трав",JUNE_SHORT:"Черв",JULY_SHORT:"Лип",AUGUST_SHORT:"Серп",SEPTEMBER_SHORT:"Верес",OCTOBER_SHORT:"Жовт",NOVEMBER_SHORT:"Листоп",DECEMBER_SHORT:"Груд",JANUARY_LONG:"Січень",FEBRUARY_LONG:"Лютий",MARCH_LONG:"Березень",APRIL_LONG:"Квітень",MAY_LONG:"Травень",JUNE_LONG:"Червень",JULY_LONG:"Липень",AUGUST_LONG:"Серпень",SEPTEMBER_LONG:"Вересень",OCTOBER_LONG:"Жовтень",NOVEMBER_LONG:"Листопад",DECEMBER_LONG:"Грудень",SUNDAY_SHORT:"Нд",MONDAY_SHORT:"Пн",TUESDAY_SHORT:"Вт",WEDNESDAY_SHORT:"Ср",THURSDAY_SHORT:"Чт",FRIDAY_SHORT:"Пт",SATURDAY_SHORT:"Сб",SUNDAY_LONG:"Неділя",MONDAY_LONG:"Понеділок",TUESDAY_LONG:"Вівторок",WEDNESDAY_LONG:"Середа",THURSDAY_LONG:"Четвер",FRIDAY_LONG:"П’ятниця",SATURDAY_LONG:"Субота"},de:{JANUARY_SHORT:"Jan",FEBRUARY_SHORT:"Feb",MARCH_SHORT:"März",APRIL_SHORT:"Apr",MAY_SHORT:"Mai",JUNE_SHORT:"Juni",JULY_SHORT:"Juli",AUGUST_SHORT:"Aug",SEPTEMBER_SHORT:"Sept",OCTOBER_SHORT:"Okt",NOVEMBER_SHORT:"Nov",DECEMBER_SHORT:"Dez",JANUARY_LONG:"Januar",FEBRUARY_LONG:"Februar",MARCH_LONG:"März",APRIL_LONG:"April",MAY_LONG:"Mai",JUNE_LONG:"Juni",JULY_LONG:"Juli",AUGUST_LONG:"August",SEPTEMBER_LONG:"September",OCTOBER_LONG:"Oktober",NOVEMBER_LONG:"November",DECEMBER_LONG:"Dezember",SUNDAY_SHORT:"So",MONDAY_SHORT:"Mo",TUESDAY_SHORT:"Di",WEDNESDAY_SHORT:"Mi",THURSDAY_SHORT:"Do",FRIDAY_SHORT:"Fr",SATURDAY_SHORT:"Sa",SUNDAY_LONG:"Sonntag",MONDAY_LONG:"Montag",TUESDAY_LONG:"Dienstag",WEDNESDAY_LONG:"Mittwoch",THURSDAY_LONG:"Donnerstag",FRIDAY_LONG:"Freitag",SATURDAY_LONG:"Samstag"}},y=function(){return[u[a].JANUARY_LONG,u[a].FEBRUARY_LONG,u[a].MARCH_LONG,u[a].APRIL_LONG,u[a].MAY_LONG,u[a].JUNE_LONG,u[a].JULY_LONG,u[a].AUGUST_LONG,u[a].SEPTEMBER_LONG,u[a].OCTOBER_LONG,u[a].NOVEMBER_LONG,u[a].DECEMBER_LONG]},O=function(){return[u[a].JANUARY_SHORT,u[a].FEBRUARY_SHORT,u[a].MARCH_SHORT,u[a].APRIL_SHORT,u[a].MAY_SHORT,u[a].JUNE_SHORT,u[a].JULY_SHORT,u[a].AUGUST_SHORT,u[a].SEPTEMBER_SHORT,u[a].OCTOBER_SHORT,u[a].NOVEMBER_SHORT,u[a].DECEMBER_SHORT]},L=function(){return[u[a].SUNDAY_LONG,u[a].MONDAY_LONG,u[a].TUESDAY_LONG,u[a].WEDNESDAY_LONG,u[a].THURSDAY_LONG,u[a].FRIDAY_LONG,u[a].SATURDAY_LONG]},F=function(){return[u[a].SUNDAY_SHORT,u[a].MONDAY_SHORT,u[a].TUESDAY_SHORT,u[a].WEDNESDAY_SHORT,u[a].THURSDAY_SHORT,u[a].FRIDAY_SHORT,u[a].SATURDAY_SHORT]},x,U,k,B,it=function(t,n,c){var f;i.XMLHttpRequest?f=new XMLHttpRequest:f=new ActiveXObject("Microsoft.XMLHTTP"),f.onreadystatechange=function(){f.readyState===4&&(f.status===200?n&&(i.JSON===r?alert(`Please, include json2 into your project if you want use old browsers!
2
+ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`):n(JSON.parse(f.responseText))):c&&c(f))},f.open("GET",t,!1),f.send()},H={"%d":{format:function(t){return A(t.day()||s.MIN_DAY,2)},parse:function(t){var n=Number(t);return{day:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%m":{format:function(t){return A(t.month()||s.MIN_MONTH,2)},parse:function(t){var n=Number(t);return{month:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%Y":{format:function(t){return A(t.year()||s.MIN_YEAR,4)},parse:function(t){var n=Number(t);return{year:isNaN(n)?r:n}},minLength:4,maxLength:4,type:"number"},"%w":{format:function(t){return t.dayOfWeek()||s.MIN_DAY_OF_WEEK},parse:function(){return{}},minLength:1,maxLength:1,type:"number"},"%a":{format:function(t){var n=t.dayOfWeek();return B[n!==r?n:s.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%A":{format:function(t){var n=t.dayOfWeek();return k[n!==r?n:s.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%b":{format:function(t){var n=s.options("monthFromZero")?t.month():t.month()-1;return U[n!==r?n:s.MIN_MONTH]},parse:function(t){var n=s.monthNames().indexOf(t)+(s.options("monthFromZero")?0:1);return{month:n!==-1?n:r}},minLength:1,maxLength:999,type:"word"},"%B":{format:function(t){var n=s.options("monthFromZero")?t.month():t.month()-1;return x[n!==r?n:s.MIN_MONTH]},parse:function(t){var n=s.monthNames(!0).indexOf(t)+(s.options("monthFromZero")?0:1);return{month:n!==-1?n:r}},minLength:1,maxLength:999,type:"word"},"%H":{format:function(t){return A(t.hours()||s.MIN_HOURS,2)},parse:function(t){var n=Number(t);return{hours:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%M":{format:function(t){return A(t.minutes()||s.MIN_MINUTES,2)},parse:function(t){var n=Number(t);return{minutes:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%S":{format:function(t){return A(t.seconds()||s.MIN_SECONDS,2)},parse:function(t){var n=Number(t);return{seconds:isNaN(n)?r:n}},minLength:2,maxLength:2,type:"number"},"%s":{format:function(t){return t.timestamp()},parse:function(t){return isNaN(Number(t))?{}:s(Number(t)).get()},minLength:1,maxLength:20,type:"number"},"%F":{format:function(t){return A(t.year()||s.MIN_YEAR,4)+"-"+A(t.month()||s.MIN_MONTH,2)+"-"+A(t.day()||s.MIN_DAY,2)},parse:function(t){var n=Number(t.slice(0,4)),c=Number(t.slice(5,7)),f=Number(t.slice(8,10));return{year:n,month:c,day:f}},minLength:10,maxLength:10,type:"string"},"%D":{format:function(t){return A(t.month()||s.MIN_MONTH,2)+"/"+A(t.day()||s.MIN_DAY,2)+"/"+A(t.year()||s.MIN_YEAR,4)},parse:function(t){var n=Number(t.slice(0,2)),c=Number(t.slice(3,5)),f=Number(t.slice(6,10));return{year:f,month:n,day:c}},minLength:10,maxLength:10,type:"string"}},ct={useMilliseconds:!1,monthFromZero:!1},T;T=function(t,n,c){return this._d=new Date,this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t!==r&&this.set(t,n,c),this},T.fn=T.prototype,T.fn.dayCount=function(){var t=this.month(),n=s.MAX_DAY_IN_MONTHS[t-(s.options("monthFromZero")?0:1)];return this.leapYear()&&t===(s.options("monthFromZero")?1:2)&&(n+=1),n},T.fn.year=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_YEAR&&Number(t)<=s.MAX_YEAR?(this._d.setFullYear(Number(t)),this._i.year=!1):this._i.year=Number(t):(this._d.setFullYear(s.MIN_YEAR),this._i.year=!1);else return this._i.year===!1?this._d.getFullYear():this._i.year;return this},T.fn.month=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_MONTH&&Number(t)<=s.MAX_MONTH?(this._d.setMonth(s.options("monthFromZero")?Number(t):Number(t)-1),this._i.month=!1):this._i.month=Number(t):(this._d.setMonth(s.options("monthFromZero")?s.MIN_MONTH:s.MIN_MONTH-1),this._i.month=!1);else return this._i.month===!1?s.options("monthFromZero")?this._d.getMonth():this._d.getMonth()+1:this._i.month;return this},T.fn.day=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_DAY&&Number(t)<=this.dayCount()?(this._d.setDate(Number(t)),this._i.day=!1):this._i.day=Number(t):(this._d.setDate(s.MIN_DAY),this._i.day=!1);else return this._i.day===!1?this._d.getDate():this._i.day;return this},T.fn.hours=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_HOURS&&Number(t)<=s.MAX_HOURS?(this._d.setHours(Number(t)),this._i.hours=!1):this._i.hours=Number(t):(this._d.setHours(s.MIN_HOURS),this._i.hours=!1);else return this._i.hours===!1?this._d.getHours():this._i.hours;return this},T.fn.minutes=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_MINUTES&&Number(t)<=s.MAX_MINUTES?(this._d.setMinutes(Number(t)),this._i.minutes=!1):this._i.minutes=Number(t):(this._d.setMinutes(s.MIN_MINUTES),this._i.minutes=!1);else return this._i.minutes===!1?this._d.getMinutes():this._i.minutes;return this},T.fn.seconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_SECONDS&&Number(t)<=s.MAX_SECONDS?(this._d.setSeconds(Number(t)),this._i.seconds=!1):this._i.seconds=Number(t):(this._d.setSeconds(s.MIN_SECONDS),this._i.seconds=!1);else return this._i.seconds===!1?this._d.getSeconds():this._i.seconds;return this},T.fn.milliseconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=s.MIN_MILLISECONDS&&Number(t)<=s.MAX_MILLISECONDS?(this._d.setMilliseconds(Number(t)),this._i.milliseconds=!1):this._i.milliseconds=Number(t):(this._d.setMilliseconds(s.MIN_MILLISECONDS),this._i.milliseconds=!1);else return this._i.milliseconds===!1?this._d.getMilliseconds():this._i.milliseconds;return this},T.fn.week=function(){var t=new Date(this.year(),0,1),n=s(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc()*1e3;return Math.ceil(((n-t.getTime())/864e5+t.getDay()+1)/7)},T.fn.set=function(t,n,c){if(this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t===r)return this._d=new Date,this;if(t instanceof Date)return this._d=t,this;if(typeof t=="number")return this._d=new Date(t*(s.options("useMilliseconds")?1:1e3)),this;if(typeof t=="object"&&(t instanceof Array?(this.day(s.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(s.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"){var f,S=[],_,R,z=[],C=0,P=0,D,X,I={},w;if(t===r)return _=o(this,c),_===r&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),_;for(n===r&&(n=s.detectFormat(t));C<n.length;){if(n.charAt(C)==="%"){if(R=n.charAt(C)+n.charAt(C+1),H[R]!==r){switch(D=0,X="",H[R].type){case"number":for(;D<H[R].maxLength&&P+D<t.length&&!isNaN(Number(t.charAt(P+D)));)X+=t.charAt(P+D),D+=1;break;case"word":for(;D<H[R].maxLength&&P+D<t.length&&/^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(P+D));)X+=t.charAt(P+D),D+=1;break;case"string":for(;D<H[R].maxLength&&P+D<t.length;)X+=t.charAt(P+D),D+=1;break}if(D<H[R].minLength)return _=o(this,c),_===r&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),_;S.push(R),z.push(X),D-=1,P+=D,C+=1}}else if(t.charAt(P)!==n.charAt(C))return _=o(this,c),_===r&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),_;C+=1,P+=1}for(f in S)S.hasOwnProperty(f)&&H.hasOwnProperty(S[f])&&(w=H[S[f]].parse(z[f]),I={year:w.year!==r?w.year:I.year,month:w.month!==r?w.month:I.month,day:w.day!==r?w.day:I.day,hours:w.hours!==r?w.hours:I.hours,minutes:w.minutes!==r?w.minutes:I.minutes,seconds:w.seconds!==r?w.seconds:I.seconds});this.day(s.MIN_DAY),this.year(I.year),this.month(I.month),this.day(I.day),this.hours(I.hours),this.minutes(I.minutes),this.seconds(I.seconds),this.milliseconds(I.milliseconds)}return this},T.fn.leapYear=function(){var t=this.year();return t%4===0?t%100===0?t%400===0:!0:!1},T.fn.timestamp=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(s.options("useMilliseconds")?1:1e3)+this._d.getTimezoneOffset()*6e4),this):s.options("useMilliseconds")?this._d.getTime()-this._d.getTimezoneOffset()*6e4:Math.floor(this._d.getTime()/1e3)-this._d.getTimezoneOffset()*60},T.fn.utc=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(s.options("useMilliseconds")?1:1e3)),this):s.options("useMilliseconds")?this._d.getTime():Math.floor(this._d.getTime()/1e3)},T.fn.dayOfWeek=function(t){if(t==="long")return k[this._d.getDay()];if(t==="short")return B[this._d.getDay()];if(t===r)return this._d.getDay();if(t===0||t==="Sunday")return this.calc({day:-this.dayOfWeek()});if(t===1||t==="Monday")return this.calc({day:(this.dayOfWeek()===0?-6:1)-this.dayOfWeek()});if(t===2||t==="Tuesday")return this.calc({day:(this.dayOfWeek()===0?-5:2)-this.dayOfWeek()});if(t===3||t==="Wednesday")return this.calc({day:(this.dayOfWeek()===0?-4:3)-this.dayOfWeek()});if(t===4||t==="Thursday")return this.calc({day:(this.dayOfWeek()===0?-3:4)-this.dayOfWeek()});if(t===5||t==="Friday")return this.calc({day:(this.dayOfWeek()===0?-2:5)-this.dayOfWeek()});if(t===6||t==="Saturday")return this.calc({day:(this.dayOfWeek()===0?-1:6)-this.dayOfWeek()})},T.fn.timezone=function(t){switch(t){case"hours":return Math.floor(this._d.getTimezoneOffset()/60);case"minutes":return this._d.getTimezoneOffset();default:return this._d.getTimezoneOffset()*60}},T.fn.get=function(t){switch(t){case"Date":return new Date(this.year(),this.month()-(s.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds());case"DateUTC":return new Date(Date.UTC(this.year(),this.month()-(s.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()));case"Array":return[this.year(),this.month(),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()];default:return{year:this.year(),month:this.month(),week:this.week(),day:this.day(),hours:this.hours(),minutes:this.minutes(),seconds:this.seconds(),milliseconds:this.milliseconds(),utc:this.utc(),dayOfWeek:this.dayOfWeek(),dayOfWeekShort:this.dayOfWeek("short"),dayOfWeekLong:this.dayOfWeek("long"),timestamp:this.timestamp()}}},T.fn.format=function(t){for(var n=0,c="",f;n<t.length;)t.charAt(n)==="%"?(f=t.charAt(n)+t.charAt(n+1),H[f]!==r?(c+=H[f].format(this),n+=1):c+="%"):c+=t.charAt(n),n+=1;return c},T.fn.valid=function(){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},T.fn.errors=function(){return this._i},T.fn.between=function(t,n){var c=this.timestamp(),f=t.timestamp();switch(n){case"year":return Math.floor((f-c)/31556952);case"month":return Math.floor((f-c)/2629746);case"day":return Math.floor((f-c)/86400);case"hours":return Math.floor((f-c)/3600);case"minutes":return Math.floor((f-c)/60);case"seconds":return f-c;default:return r}},T.fn.calc=function(t){return t.year!==r&&this._d.setFullYear(this._d.getFullYear()+t.year),t.month!==r&&this._d.setMonth(this._d.getMonth()+t.month),t.day!==r&&this._d.setDate(this._d.getDate()+t.day),t.hours!==r&&this._d.setHours(this._d.getHours()+t.hours),t.minutes!==r&&this._d.setMinutes(this._d.getMinutes()+t.minutes),t.seconds!==r&&this._d.setSeconds(this._d.getSeconds()+t.seconds),t.milliseconds!==r&&this._d.setMilliseconds(this._d.getMilliseconds()+t.milliseconds),this},s=function(t,n,c){return new T(t,n,c)},s.MIN_YEAR=1e3,s.MAX_YEAR=3e3,s.MIN_MONTH=1,s.MAX_MONTH=12,s.MIN_DAY=1,s.MAX_DAY_IN_MONTHS=[31,28,31,30,31,30,31,31,30,31,30,31],s.MIN_DAY_OF_WEEK=0,s.MAX_DAY_OF_WEEK=6,s.MIN_HOURS=0,s.MAX_HOURS=23,s.MIN_MINUTES=0,s.MAX_MINUTES=59,s.MIN_SECONDS=0,s.MAX_SECONDS=59,s.MIN_MILLISECONDS=0,s.MAX_MILLISECONDS=999,s.VERSION="0.2.18",s.options=function(t,n){if(t===r)return ct;if(ct.hasOwnProperty(t)){if(n===r)return ct[t];ct[t]=n,t==="monthFromZero"&&(s.MIN_MONTH=n?0:1,s.MAX_MONTH=n?11:12)}return r},s.noConflict=function(){return i.tempus=l,s},s.generate=function(t){var n,c,f,S,_,R,z,C;if(typeof t.dateFrom!="number"&&(t.dateFrom instanceof T?n=t.dateFrom.utc():n=s(t.dateFrom,t.formatFrom).utc()),typeof t.dateTo!="number"&&(t.dateTo instanceof T?c=t.dateTo.utc():c=s(t.dateTo,t.formatTo!==r?t.formatTo:t.formatFrom).utc()),typeof t.period=="number"?_={year:0,month:0,day:0,hours:0,minutes:0,seconds:t.period}:typeof t.period=="string"?_={year:t.period==="year"?1:0,month:t.period==="month"?1:0,day:t.period==="day"?1:0,hours:t.period==="hours"?1:0,minutes:t.period==="minutes"?1:0,seconds:t.period==="seconds"?1:0}:typeof t.period=="object"&&(_={year:t.period.year!==r?t.period.year:0,month:t.period.month!==r?t.period.month:0,day:t.period.day!==r?t.period.day:0,hours:t.period.hours!==r?t.period.hours:0,minutes:t.period.minutes!==r?t.period.minutes:0,seconds:t.period.seconds!==r?t.period.seconds:0}),t.groupBy===r?R=t.asObject===!0?{}:[]:(R=[],R.push([]),z=s(n).get()[t.groupBy]),C=function(X,I,w){return t.asObject===!0?t.format!==r?X[s(I).format(t.format)]={}:X[s(I).format("%F %H:%M:%S")]={}:t.format!==r?X.push(w?null:s(I).format(t.format)):X.push(w?null:s(I)),X},t.groupBy!==r&&t.fillNulls){var P={year:_.year?-_.year:r,month:_.month?-_.month:r,day:_.day?-_.day:r,hours:_.hours?-_.hours:r,minutes:_.minutes?-_.minutes:r,seconds:_.seconds?-_.seconds:r,milliseconds:_.milliseconds?-_.milliseconds:r};for(f=s(n).calc(P).utc();s(f).get()[t.groupBy]===z;)C(R[R.length-1],f,!0),f=s(f).calc(P).utc();if(t.groupBy==="week"){var D=s(n).dayOfWeek();for(f=s(n).dayOfWeek(0).utc();R[0].length<D&&f<n;)C(R[R.length-1],f,!0),f=s(f).calc(_).utc()}}for(;n<=c;)t.groupBy===r?C(R,n):s(n).get()[t.groupBy]===z?C(R[R.length-1],n):(R.push([]),C(R[R.length-1],n),z=s(n).get()[t.groupBy]),n=s(n).calc(_).utc();if(t.groupBy!==r&&t.fillNulls)for(S=s(c).calc(_).utc();s(S).get()[t.groupBy]===z;)C(R[R.length-1],S,!0),S=s(S).calc(_).utc();return R},s.monthNames=function(t){switch(t){case"long":return x;default:return U}},s.dayNames=function(t){switch(t){case"long":return k;default:return B}},s.lang=function(t){if(t!==r)a=t,u[a]===r&&(a="en"),x=y(),U=O(),k=L(),B=F();else return a;return r},s.availableLangs=function(){return Object.keys(u)},s.registerFormat=function(t,n,c,f,S,_){H[t]={format:n,parse:c,minLength:f,maxLength:S,type:_}},s.unregisterFormat=function(t){delete H[t]},s.detectFormat=function(t){var n,c,f;return n=m(t,0),n!==""&&(f=10),c=t.charAt(f),(c==="T"||c===" ")&&(n+=c,f+=1),n+=h(t,f),n},d={TempusDate:T},s.classes=function(t,n){if(n===r)return d[t];d[t]=n},s.loadTranslations=function(t){typeof t=="object"?u=t:typeof t=="string"&&it(t,function(n){u=n},function(n){})},a=(g.language||g.systemLanguage||g.userLanguage||"en").substr(0,2).toLowerCase(),u[a]===r&&(a="en"),x=y(),U=O(),k=L(),B=F(),W.exports&&(e=W.exports=s),e.tempus=s}).call(E)})($,$.exports);var Tt=$.exports;const rt=b(Tt);class v{constructor(e){this.callBatch=e,this.result={},this.errors={},this.limit=50,this.canContinue=!0,this.progressCall="",this.limitCall="",this.progressData="",this.progressTimer="",this.progressDelay=100,this.oldPercent="no",this.chunkRate=1,this.totalProgress=0,this.skipList=new Set}getData(e){return(e==null?void 0:e.items)??(e==null?void 0:e.tasks)??(e==null?void 0:e.types)??(e==null?void 0:e.type)??(e==null?void 0:e.fields)??(e==null?void 0:e.workgroups)??e}get progressPercent(){let e=0;if(!this.progressData)return{percent:Math.round(e),allCount:0,allTotal:0};let r=0,i=0;return Object.values(this.progressData).forEach(A=>{const{total:o,count:h}=A;r+=o??0,i+=h??0}),r?e=i/r*100*this.chunkRate+this.totalProgress:i===0&&r===0?e=100*this.chunkRate+this.totalProgress:e=100,{percent:Math.round(e),allCount:i,allTotal:r}}setProgressData({key:e,value:r,type:i}){const A=this.getData(r.data()),o=Array.isArray(A)?A.length:0;let h=r.total()||o;i==="count"&&(h=o);let m=1;A&&(m=o),this.progressCall&&(this.progressData||(this.progressData={}),this.progressData[e]&&this.progressData[e].count&&(m+=this.progressData[e].count),this.progressData[e]?this.progressData[e].count=m:this.progressData[e]={total:h,count:m},this.progressTimer||(this.progressTimer=setInterval(()=>{const{percent:l,allCount:s,allTotal:d}=this.progressPercent;(this.oldPercent==="no"||this.oldPercent<this.progressPercent.percent)&&(this.progressCall({data:this.progressData,percent:l,allCount:s,allTotal:d}),this.oldPercent=this.progressPercent.percent),l>=100&&this.clearProgressData()},this.progressDelay)))}delay(){return new Promise(e=>setTimeout(e,500))}stop(){this.canContinue=!1}clearProgressData(){clearInterval(this.progressTimer),this.progressTimer="",this.progressData="",this.progressCall="",this.limitCall="",this.oldPercent="no"}async batch(e,r,i){this.progressTimer&&this.clearProgressData(),r&&(this.progressCall=r),i&&(this.limitCall=i),this.canContinue=!0,this.result={},this.errors={};const A={};this.chunkRate=(1/Math.ceil(Object.keys(e).length/this.limit)).toFixed(5);let o={},h=0;for(const[m,l]of Object.entries(e)){if(!this.canContinue)break;const s=this.arrayChunk(l);if(!s){h++;continue}o[m]=s,(Object.keys(o).length>=50||h+1===Object.keys(e).length)&&(await this.batchChunk(o),Object.entries(this.result).forEach(([d,g])=>{A[d]=g}),this.totalProgress=Math.round(h/Object.keys(e).length*100),o={}),h++}return Object.entries(this.errors).length&&(A.errorsList=this.errors),r&&r({percent:100}),Promise.resolve(A)}async batchTotalCount(e,r,i){this.progressTimer&&this.clearProgressData(),r&&(this.progressCall=r),i&&(this.limitCall=i),this.canContinue=!0,this.result={},this.errors={};const A={};this.chunkRate=(1/Math.ceil(Object.keys(e).length/this.limit)).toFixed(5);let o={},h=0;for(const[m,l]of Object.entries(e)){if(!this.canContinue)break;const s=this.arrayChunk(l);if(!s){h++;continue}o[m]=s,(Object.keys(o).length>=50||h+1===Object.keys(e).length)&&(await this.batchChunk(o,"count"),Object.entries(this.result).forEach(([d,g])=>{A[d]=g}),this.totalProgress=Math.round(h/Object.keys(e).length*100),o={}),h++}return Object.entries(this.errors).length&&(A.errorsList=this.errors),r&&r({percent:100}),Promise.resolve(A)}arrayChunk(e){let r="",i={};if(Array.isArray(e)?[r]=e:(r=e.method,i=e.params),this.skipList.has(r))return!1;if((r.includes("list")||r==="user.get")&&r!=="task.item.list"){if(!i)i={order:{ID:"ASC",id:"ASC"}};else{r==="tasks.task.list"?(i.order||(i.order={}),i.order.ID="asc"):r==="user.get"?(i.sort||(i.sort="ID"),i.order||(i.order="ASC")):i.order={ID:"ASC",id:"ASC"},Array.isArray(i.select)&&!i.select.includes("ID")&&i.select.push("ID");const A=r==="user.get"?i.FILTER:i.filter;typeof A=="object"&&A!==null&&!Array.isArray(A)&&Object.entries(A).forEach(([o,h])=>{(i.start===void 0||i.start!==-1)&&["id","ID"].includes(o)&&(typeof h=="string"||Array.isArray(h)&&h.length<=50)&&(i.start=-1)})}r==="crm.type.list"&&i.order&&delete i.order.ID}if(r==="task.item.list")if(!i)i=[{ID:"ASC"},[""],[""],["ID"]];else{Array.isArray(i[0])&&(i[0]={});const[A,o,h,m]=i;A.ID="ASC",m[0]!==""&&m.includes("ID")||m.push("ID")}return{method:r,params:i}}async batchChunk(e,r){return new Promise(i=>{const A=[];let o;this.callBatch(e,async h=>{var m,l,s,d,g,a,u;for(const[y,O]of Object.entries(h)){if(!this.canContinue)return;if(O.error())switch(this.errors[y]=((l=(m=O.error())==null?void 0:m.ex)==null?void 0:l.error)??((d=(s=O.error())==null?void 0:s.ex)==null?void 0:d.error_description)??((g=O.error())==null?void 0:g.toString())??"Неизвестная ошибка",o=!0,((u=(a=O.error())==null?void 0:a.ex)==null?void 0:u.error)??""){case"OPERATION_TIME_LIMIT":this.skipList.add(e[y].method),this.limitCall&&this.limitCall(y);break;case"QUERY_LIMIT_EXCEEDED":this.canContinue=!1;break;case"ACCESS_DENIED":this.skipList.add(e[y].method);break}const L=this.getData(O.data()),F=Array.isArray(L)?L.length:0,x=typeof O.total=="function"&&O.total()!==void 0,U=x?O.total():F;r==="count"?this.result[y]?this.result[y]+=F:this.result[y]=U:this.result[y]=L,this.setProgressData({key:y,value:O,type:r});const k=r==="count"?!x&&F===this.limit:U>this.limit&&U>F;if(!this.canContinue||k){let B=e[y];if(Array.isArray(B)){const[it,H={}]=B;B=[it,H]}else{const{method:it,params:H={}}=B;B=[it,H]}A.push([y,B,U])}}o>0&&this.errorLogger(),A.length?await this.batchPayload(A,r).then(()=>i(this.result)):i(this.result)})})}async batchPayload(e,r){const i=new Map,A=(l,s,d,g)=>{let a="ID";this.result[l][this.result[l].length-1].ID||(a="id");let u=`${a}`;if(JSON.stringify(g[1]).toLocaleLowerCase().includes('"id":"desc"')?u="<"+u:u=">"+u,s===1||d.length===0)return{field:u,id:this.result[l][this.result[l].length-1][a]};let O="";const[L,F]=g;return(L==="tasks.task.list"||L==="task.item.list")&&(O="[tasks]"),["crm.item.list","crm.stagehistory.list"].includes(L)&&(O="[items]"),L==="crm.type.list"&&(O="[types]"),L==="socialnetwork.api.workgroup.list"&&(O="[workgroups]"),{field:u,id:`$result[${[l,s-1].join("__")}]${O}[49][${a}]`}},o=(l,s)=>{const[d,g]=l;let a=JSON.parse(JSON.stringify(g)),u;if(d==="task.item.list"){a=[...a];const[y,O,L,F]=a;return O[s.field]=s.id,[d,a]}return["user.get"].includes(d)||a.FILTER?(a.FILTER||(a.FILTER={}),u=a.FILTER):(a.filter||(a.filter={}),u=a.filter),["socialnetwork.api.workgroup.list","tasks.task.list"].includes(d)?u[">ID"]=s.id:u[s.field]=s.id,[d,{...a,start:-1}]},h=l=>{Object.entries(l).forEach(([s,d])=>{var u,y,O,L,F,x,U;const[g]=s.split("__"),a=this.getData(d.data());if(Array.isArray(a)&&(r==="count"?this.result[g]+=a.length:this.result[g].push(...a)),d.error()){this.errors[g]=((y=(u=d.error())==null?void 0:u.ex)==null?void 0:y.error)??((L=(O=d.error())==null?void 0:O.ex)==null?void 0:L.error_description)??((F=d.error())==null?void 0:F.toString())??"Неизвестная ошибка";const k=((U=(x=d.error())==null?void 0:x.ex)==null?void 0:U.error)??"";if(k==="OPERATION_TIME_LIMIT"){this.limitCall&&this.limitCall(g);const B=i.get(g);switch(k){case"OPERATION_TIME_LIMIT":B&&(this.skipList.add(B),this.limitCall&&this.limitCall(g));break;case"QUERY_LIMIT_EXCEEDED":this.canContinue=!1;break;case"ACCESS_DENIED":this.skipList.add(B);break}}}this.setProgressData({key:g,value:d,type:r})})};let m=[];for await(const[l,s,d]of e){if(!this.canContinue)return;const[g]=s;if(i.set(l,g),this.skipList.has(g))continue;let a=1;for(;d>a*50&&!this.skipList.has(g);){const u=[l,a].join("__"),y=A(l,a,m,s);m.push([u,o(s,y)]),m.length%50===0&&(await new Promise(O=>this.callBatch(Object.fromEntries(m),L=>{h(L),O()})),m=[],await this.delay()),a++}}m.length&&(await new Promise(l=>this.callBatch(Object.fromEntries(m),s=>{h(s),l()})),await this.delay())}errorLogger(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(this.errors).forEach(([e,r])=>{r&&console.log(`[${e}]`,r.toString())}),console.groupEnd()}}class ut{constructor(){Y(this,V,{})}get hash(){return this.createHash(8)}createHash(e){let r="abcdefghijklmnopqrstuvwxyz0123456789",i="";e=e||6;for(let A=0;A<e;A++)i+=r.charAt(Math.floor(Math.random()*r.length));return i}actionFilter({keyTimer:e,duration:r=10,action:i}){p(this,V)[e]&&(clearTimeout(p(this,V)[e]),p(this,V)[e]=null),i&&(p(this,V)[e]=setTimeout(()=>{i()},r))}async noSleep(){let e=document.createElement("video");e.classList.add("no-sleep"),e.muted=!0,e.autoplay=!0,e.setAttribute("playsinline",""),e.addEventListener("loadeddata",()=>{e.style.position="fixed",e.style.left="-9999px",document.querySelector("body").append(e),e.play().catch(r=>{console.warn("noSleep: autoplay prevented",r)})}),e.addEventListener("ended",()=>{this.actionFilter({keyTimer:"no-sleep",duration:5e3,action:()=>{e.play().catch(r=>{console.warn("noSleep: replay prevented",r)})}})}),e.src="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAP5tZGF0AAAAAQYAAADlZYiEE28FmH9jNWDBjI+Z/1tIBZsjfhbmcNNUpBFej0U3p+zhaJ3eemJRL2LUMa5tkidy6bp+eatLE3jBIY864TvaAmqEFCgLMTCwVbem1n3myAw9yDXQdR5HfU/8iYf+eneVnRf7Qx9M70XDUuPx1MJX671XJwAE0VAMpnhbcUDx0pTldvUX9KQPhkZNH3eyZHmObkAeyEJ2tl+BEBJIGc90BiqKL60+5EA6fXB6iG5UU/M5KsW8BNAAUw5CbRJIqohNk10fwKbUXwya03rqGkE8+wuYGtEbrVYXb+iOl1mHHVPLYQbIAAcGyAAHAAAFNG1vb3YAAABsbXZoZAAAAAAAAAAAAAAAAAAAA+gAAAAvAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAIldHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAFAAAAA8AAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAAAAAAAAAAAQAAAAABnW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAQAAAAAAAVcQAAAAAAC1oZGxyAAAAAAAAAAB2aWRlAAAAAAAAAAAAAAAAVmlkZW9IYW5kbGVyAAAAAUhtaW5mAAAAFHZtaGQAAAABAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAAEIc3RibAAAAKRzdHNkAAAAAAAAAAEAAACUYXZjMQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAFAAPAASAAAAEgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABj//wAAAC5hdmNDAU1AC//hABZnTUAL2wUH7ARAAAADAEAAAAQDxQq4AQAFaOrAZXIAAAAQcGFzcAAAAAEAAAABAAAAGHN0dHMAAAAAAAAAAQAAAAEAAAAAAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAABAAAAAQAAABRzdHN6AAAAAAAAAO4AAAABAAAAFHN0Y28AAAAAAAAAAQAAADAAAAIadHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAAAvAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAAALwAAAAAAAQAAAAABkm1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAArEQAAAgAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAT1taW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAQFzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAAC7gAAAAViBYCAgAISCAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAACAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAgAAAAEAAAAUc3RzegAAAAAAAAAEAAAAAgAAABRzdGNvAAAAAAAAAAEAAAEeAAAAGnNncGQBAAAAcm9sbAAAAAIAAAAB//8AAAAcc2JncAAAAAByb2xsAAAAAQAAAAIAAAABAAAAgXVkdGEAAAB5bWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWR0YQAAAAAAAAAAAAAAAAAAAAAfa2V5cwAAAAAAAAABAAAAD21kdGFlbmNvZGVyAAAALWlsc3QAAAAlAAAAAQAAAB1kYXRhAAAAAQAAAABMYXZmNTguMTIuMTAw"}downloadFileJson(e,r){let i=new Blob([JSON.stringify(e)],{type:"application/json"}),A=URL.createObjectURL(i),o=document.createElement("a");o.style.display="none",o.href=A,o.download=`${r}.json`,document.body.appendChild(o),o.click(),setTimeout(()=>{document.body.removeChild(o),URL.revokeObjectURL(A)},200)}}V=new WeakMap;const ft=new ut;class gt{constructor(){Y(this,nt);Y(this,st);Y(this,At);Y(this,ot);Y(this,at);Y(this,j,"logger");Y(this,Z,!1);Y(this,K,new Map);Y(this,tt,{});Y(this,G,null);Y(this,q,!1);Y(this,et,!1);M(this,"periodClear",3);Q(this,nt,Nt).call(this)}async init(){try{let e=new v(BX24.callBatch),{entityList:r}=await e.batch({entityList:{method:"entity.get"}});if(r&&Array.isArray(r))if(r.find(A=>A.ENTITY==p(this,j)))J(this,Z,!0);else{let{entityAdd:A}=await e.batch({entityAdd:{method:"entity.add",params:{ENTITY:p(this,j),NAME:p(this,j),ACCESS:{AU:"X"}}}});A&&J(this,Z,!0)}return Q(this,ot,_t).call(this).catch(i=>{console.error("Ошибка при проверке периода очистки:",i)}),p(this,Z)}catch(e){return console.error("Ошибка при инициализации логера:",e),!1}}start({type:e,data:r}){if(!p(this,Z))return Q(this,st,dt).call(this,"entity"),null;if(!e||!r)return console.error("Невалидные данные для логирования:",{type:e,data:r}),null;const i=ft.hash,A={type:e,data:r,userInfo:p(this,tt),errorList:{},status:"",answer:null,date:new Date().getTime()};return p(this,K).set(i,A),J(this,et,!0),i}async stop({key:e,errorList:r,status:i,answer:A}){var h;if(!p(this,et))return;if(!p(this,Z)){Q(this,st,dt).call(this,"entity");return}let o=p(this,K).get(e);if(!o){console.error(`Не найдены данные логирования для ключа: ${e}`);return}r&&(o.errorList=r),i&&(o.status=i),A&&(o.answer=A),await Q(this,At,Ot).call(this),(h=o==null?void 0:o.data)!=null&&h.updateList&&J(this,q,!0),J(this,et,!1)}async getEntityList(e){var r;try{if((r=p(this,G))!=null&&r.length&&!p(this,q))return p(this,G);let i=new v(BX24.callBatch),{entityList:A}=await i.batch({entityList:{method:"entity.item.get",params:{ENTITY:p(this,j),SORT:{ID:"DESC"}}}},e);return!A||!Array.isArray(A)?(console.warn("Получен невалидный список записей"),[]):(A=A.map(o=>{try{const{ID:h,DATE_CREATE:m,DETAIL_TEXT:l}=o;return{...JSON.parse(l),id:h,dateCreate:m}}catch(h){return console.error(`Ошибка парсинга записи ${o.ID}:`,h),null}}).filter(o=>o!==null),J(this,q,!1),J(this,G,A),A)}catch(i){return console.error("Ошибка при получении списка записей:",i),[]}}async downAllEntityJson(){try{if(p(this,G)||await this.getEntityList(),!p(this,G)||p(this,G).length===0)return console.warn("Нет данных для выгрузки"),!1;let e=rt().format("%Y-%m-%d");return ft.downloadFileJson(p(this,G),`sdklogger-entity-data__${e}`),!0}catch(e){return console.error("Ошибка при выгрузке данных в JSON:",e),!1}}}j=new WeakMap,Z=new WeakMap,K=new WeakMap,tt=new WeakMap,G=new WeakMap,q=new WeakMap,et=new WeakMap,nt=new WeakSet,Nt=async function(){try{const e=new v(BX24.callBatch),r=BX24.isAdmin(),{curUser:i}=await e.batch({curUser:{method:"user.current"}});J(this,tt,{isAdmin:r,curUser:i})}catch(e){console.error("Ошибка при получении информации о пользователе:",e),J(this,tt,{isAdmin:!1,curUser:null})}},st=new WeakSet,dt=function(e){e=="entity"&&ft.actionFilter({keyTimer:"error.logger.entity",duration:500,action:()=>{console.error("Хранилище для логгера не инициализировано")}})},At=new WeakSet,Ot=async function(){try{let e={},r=new v(BX24.callBatch);for(let[i,A]of p(this,K).entries())if(A.status){const o=JSON.stringify(A);e[i]={method:"entity.item.add",params:{ENTITY:p(this,j),NAME:p(this,j),DETAIL_TEXT:o}}}if(Object.keys(e).length){let i=await r.batch(e),{errors:A}=r;for(let[o,h]of Object.entries({...i,...A}))p(this,K).delete(o);return!0}return!1}catch(e){return console.error("Ошибка при добавлении записей в хранилище:",e),!1}},ot=new WeakSet,_t=async function(){try{let e=new v(BX24.callBatch),{serverTime:r}=await e.batch({serverTime:{method:"server.time"}});if(!r){console.error("Не удалось получить время сервера");return}if(p(this,G)||await this.getEntityList(),!p(this,G)||p(this,G).length===0)return;let i=p(this,G).filter(A=>{try{let{dateCreate:o}=A;return o?rt(new Date(o)).between(rt(new Date(r)),"month")>=this.periodClear:!1}catch(o){return console.error("Ошибка при проверке даты записи:",o),!1}});i.length>0&&(console.log(`Найдено ${i.length} записей для очистки (старше ${this.periodClear} месяцев)`),await Q(this,at,pt).call(this,i))}catch(e){console.error("Ошибка при проверке периода очистки:",e)}},at=new WeakSet,pt=async function(e){try{if(!e||e.length===0)return!1;let r=new v(BX24.callBatch),i=e.filter(o=>o&&o.id).map(o=>{let{id:h}=o;return{method:"entity.item.delete",params:{ENTITY:p(this,j),ID:h}}});if(i.length===0)return!1;const A=await r.batch(i);return console.log(`Успешно удалено ${i.length} записей`),J(this,q,!0),A}catch(r){return console.error("Ошибка при очистке устаревших записей:",r),!1}};class Rt{constructor(e){Y(this,ht);Y(this,lt);M(this,"domain","");M(this,"isAdmin",!1);M(this,"appInfo",null);M(this,"appConst",null);M(this,"userInfo",null);M(this,"placeData",null);M(this,"placeInfo",null);M(this,"logger",!1);this.appConst=e}init(){return new Promise((e,r)=>{let A=setInterval(()=>{window.BX24&&BX24.init(async()=>{console.info("init BX24"),clearInterval(A),clearTimeout(o),this.domain=BX24.getDomain(),this.isAdmin=BX24.isAdmin(),this.placeInfo=BX24.placement.info(),this.logger?(this.logger=new gt,await this.logger.init()):this.logger={start:()=>{},stop:()=>{},getEntityList:()=>{}};const[h,m]=await Promise.all([Q(this,ht,yt).call(this),Q(this,lt,Et).call(this)]);this.appInfo=h,this.userInfo=m;let l=new ut;try{l.noSleep()}catch(s){console.warn("Failed to initialize noSleep:",s)}e(!0)})},100);const o=setTimeout(()=>{clearInterval(A);const h=new Error("BX24 initialization timeout: BX24 object not found within 30 seconds");console.error(h),r(h)},3e4)})}userOption(e,r){if(typeof BX24>"u"||!BX24.userOption){console.warn("BX24.userOption is not available. Make sure BX24 is initialized.");return}return r!==void 0?BX24.userOption.set(e,r):BX24.userOption.get(e)}appOption(e,r){if(typeof BX24>"u"||!BX24.appOption){console.warn("BX24.appOption is not available. Make sure BX24 is initialized.");return}return r!==void 0?BX24.appOption.set(e,r):BX24.appOption.get(e)}async call({method:e,params:r,updateList:i}){let A;if(i&&(A=this.logger.start({type:"call",data:{method:e,params:r,updateList:i}})),r||(r={}),typeof BX24>"u"||!BX24.callMethod){const o=new Error("BX24 is not initialized");throw console.error(o),o}return new Promise((o,h)=>{BX24.callMethod(e,r,async m=>{let l={};if(m!=null&&m.answer)for(let[s,d]of Object.entries(m.answer))s!=="result"&&d&&(l[s]=d);if(m.error()){let s=m.error();if(console.error(s),A)try{await this.logger.stop({answer:l,key:A,status:"fail",errorList:{0:s.toString()}})}catch(d){console.error("Logger error:",d)}o(!1)}else{let s=m.data();if(s!=null&&s.items&&(s=s.items),A)try{await this.logger.stop({answer:l,key:A,status:"success"})}catch(d){console.error("Logger error:",d)}o(s)}})})}async batch(e,r,{errorCall:i,limitCommandSerial:A,updateList:o,limitCall:h}={}){if(typeof BX24>"u"||!BX24.callBatch){const s=new Error("BX24 is not initialized");return console.error(s),!1}let m=new v(BX24.callBatch),l;o&&(l=this.logger.start({type:"batch",data:{commandList:e,updateList:o}})),A&&console.warn("limitCommandSerial is deprecated and not used in current Batch implementation");try{let s=await m.batch(e,r,h);if(Object.keys(m.errors).length){if(i&&i(m.errors),l)try{await this.logger.stop({key:l,status:"fail",errorList:m.errors})}catch(d){console.error("Logger error:",d)}}else if(l)try{await this.logger.stop({key:l,status:"success"})}catch(d){console.error("Logger error:",d)}return s}catch(s){if(l)try{await this.logger.stop({key:l,status:"fail-runtime",errorList:{0:s==null?void 0:s.toString()}})}catch(d){console.error("Logger error:",d)}return console.error(s),!1}}async batchTotalCount(e,r,{errorCall:i,updateList:A,limitCall:o}={}){if(typeof BX24>"u"||!BX24.callBatch){const l=new Error("BX24 is not initialized");return console.error(l),!1}let h=new v(BX24.callBatch),m;A&&(m=this.logger.start({type:"batch-total-count",data:{commandList:e}}));try{let l=await h.batchTotalCount(e,r,o);if(Object.keys(h.errors).length){if(i&&i(h.errors),m)try{await this.logger.stop({key:m,status:"fail",errorList:h.errors})}catch(s){console.error("Logger error:",s)}}else if(m)try{await this.logger.stop({key:m,status:"success"})}catch(s){console.error("Logger error:",s)}return l}catch(l){if(m)try{await this.logger.stop({key:m,status:"fail-runtime",errorList:{0:l==null?void 0:l.toString()}})}catch(s){console.error("Logger error:",s)}return console.error(l),!1}}async getPlacement(){return await this.call({method:"placement.get"}).then(e=>(this.placeData||(this.placeData=e),e))}async placementBind(e,r=!0){var d;if(!this.isAdmin)return;r&&await this.placementCheck();let i=[];if(Array.isArray(e)?i=e.map(g=>typeof g=="string"?{placement:g}:g):typeof e=="string"?i=[{placement:e}]:i=[e],this.placeData=await this.getPlacement(),!this.placeData)return;const{appName:A,pathApp:o}=this.appConst;let h=A;this.domain==="szdl.bitrix24.ru"&&((d=this.appInfo)!=null&&d.ID)&&(h=`${A}: #${this.appInfo.ID}`);const m=h.replace(" CRM",""),l={},s=[];for(let g=0;g<i.length;g++){const a=i[g],u=a.placement,y=a.userId;let O=o,L=u;if(u==="PAGE_BACKGROUND_WORKER"){if(!y){console.warn(`placementBind: userId is required for PAGE_BACKGROUND_WORKER, skipping ${u}`);continue}O=`${o}?USER_ID=${y}/`}if(u==="PAGE_BACKGROUND_WORKER_ALL"&&(L="PAGE_BACKGROUND_WORKER"),this.placeData.find(k=>k.placement===L&&k.handler===O))continue;let x=this.placeData.find(k=>k.placement===L&&k.handler!==O);x&&s.push({placement:L,handler:x.handler});const U={PLACEMENT:L,HANDLER:O,LANG_ALL:{ru:{TITLE:L==="USER_PROFILE_TOOLBAR"?m:h}},OPTIONS:{errorHandlerUrl:O}};u==="PAGE_BACKGROUND_WORKER"&&y&&(U.USER_ID=y),l[`bind_${g}`]={method:"placement.bind",params:U}}s.length>0&&await this.placementUnBind(s),Object.keys(l).length>0&&await this.batch(l),Object.keys(l).length>0&&(this.placeData=await this.getPlacement(),Object.values(l).forEach(g=>{console.log("Приложение успешно встроено в",g.params.PLACEMENT)}))}async placementUnBind(e){let r=[];Array.isArray(e)?r=e.map(A=>typeof A=="string"?{placement:A}:A):typeof e=="string"?r=[{placement:e}]:r=[e];const i={};for(let A=0;A<r.length;A++){const o=r[A],h=o.placement,m=o.handler,l={PLACEMENT:h};m&&(l.HANDLER=m),i[`unbind_${A}`]={method:"placement.unbind",params:l}}Object.keys(i).length>0&&(await this.batch(i),r.forEach(A=>{console.log("Встройка отвязана",A.placement)}))}async placementCheck(){if(this.placeData=await this.getPlacement(),!this.placeData)return;const{pathApp:e}=this.appConst,r=[],i=[];for(const A of this.placeData){if(!A.handler||A.handler.includes(e))continue;const{placement:o,handler:h,userId:m}=A;r.push({placement:o,handler:h}),i.push({placement:o,userId:m})}r.length>0&&await this.placementUnBind(r),i.length>0&&await this.placementBind(i,!1)}getBotList(){return this.call({method:"imbot.bot.list",params:{}}).then(e=>{let r=Object.values(e);return console.log("chat-bot list:",r),r})}regBot({code:e,type:r,name:i}){const{appName:A,pathApp:o,chatBotLogo:h}=this.appConst,m=this.appInfo.ID;return this.call({method:"imbot.register",params:{CODE:e??this.appInfo.CODE,TYPE:r??"O",EVENT_HANDLER:o,OPENLINE:"Y",CLIENT_ID:"",PROPERTIES:{NAME:`${i??A} - бот #${m}`,LAST_NAME:"",COLOR:"GREEN",EMAIL:"",PERSONAL_BIRTHDAY:rt().format("%Y-%m-%d"),WORK_POSITION:"Почтальон",PERSONAL_WWW:"",PERSONAL_GENDER:"M",PERSONAL_PHOTO:h??""}}}).then(l=>(console.log("Чат-бот добавлен",l),l))}unRegBot(e){return this.call({method:"imbot.unregister",params:{BOT_ID:e}}).then(r=>(console.log("чат-бот удален",r),r))}getLoggerList(e){return this.logger.getEntityList(e)}}ht=new WeakSet,yt=function(){return this.call({method:"app.info"})},lt=new WeakSet,Et=function(){return this.call({method:"user.current"})};class Lt{constructor(e){M(this,"entityName","tabs");M(this,"maxTabs",5);M(this,"interval");M(this,"id",0);M(this,"tabList",[]);M(this,"random",this.getRandomNum());M(this,"continueCondition");M(this,"defaultContinueBackground",()=>!0);M(this,"activeMaxPause",60*1e3*5+this.random);M(this,"activeMinPause",60*1e3*3+this.random);if(!e){console.error("В бек-воркер не переданы настройки, отмена вызова"),console.log("BackgroundWorker: Отмена конструктора - отсутствуют опции");return}const{appFunc:r,bx:i,users:A,continueBackground:o}=e;this.bx=i,this.appPath=i.appConst.pathApp??"",this.appName=i.appConst.appName??"",this.appInit=r,this.users=A,this.start=new Date,this.continueCondition=typeof o=="function"?o:this.defaultContinueBackground}async init(){if(!this.appInit){console.error("Функция-запуск не передана в appInit, отмена инициализации бекворкера"),console.log("BackgroundWorker: Отмена init - не передана appInit");return}if(!this.bx){console.error("Не передан экземпляр bxBoot"),console.log("BackgroundWorker: Отмена init - отсутствует bx");return}if(await this.bx.placementBind(["PAGE_BACKGROUND_WORKER"]),!await this.continueBackground()){console.log("BackgroundWorker: Отмена init - условие запуска не выполнено");return}await this.checkEntity(),this.tabList=await this.getFilteredTabList(),this.id=await this.addTab(),console.log("tabId",this.id),this.interval=setInterval(()=>{this.backgroundPolling().catch(e=>{console.error("BackgroundWorker: backgroundPolling failed",e)})},this.activeMinPause)}async checkEntity(){var i;const e=await this.bx.call({method:"entity.get"});((i=e==null?void 0:e.find)==null?void 0:i.call(e,A=>A.ENTITY===this.entityName))||await this.bx.call({method:"entity.add",params:{ENTITY:this.entityName,NAME:this.entityName,ACCESS:{AU:"X"}}})}async getTabs(){var r;const e=await this.bx.call({method:"entity.item.get",params:{ENTITY:this.entityName,FILTER:{NAME:(r=this.bx.userInfo)==null?void 0:r.ID},SORT:{DATE_CREATE:"DESC"}}});return e!=null&&e.length?e.map(i=>{if(!i)return{id:void 0,data:void 0};try{return{id:i.ID,data:{...JSON.parse(i.DETAIL_TEXT)}}}catch(A){return console.log(A),{id:i.ID,data:void 0}}}):[]}async addTab(){var r;const e={lastActive:new Date().toISOString(),duration:new Date().getTime()-this.start.getTime(),start:!1};return this.tabList.length<this.maxTabs&&await this.bx.call({method:"entity.item.add",params:{ENTITY:this.entityName,NAME:(r=this.bx.userInfo)==null?void 0:r.ID,DETAIL_TEXT:JSON.stringify(e)}})||0}async updateTab(e){var i;const r={lastActive:new Date().toISOString(),duration:new Date().getTime()-this.start.getTime(),start:e};await this.bx.call({method:"entity.item.update",params:{ENTITY:this.entityName,ID:this.id,NAME:(i=this.bx.userInfo)==null?void 0:i.ID,DETAIL_TEXT:JSON.stringify(r)}})}async deleteTabs(e=[]){if(!e.length)return;const r=e.map(i=>({method:"entity.item.delete",params:{ENTITY:this.entityName,ID:i.id}}));r.length&&await this.bx.batch(r)}getRandomNum(){const e=Math.round(Number(Math.random().toFixed(2))*30);return Math.round(Math.random())?e:-e}async continueBackground(){try{const r=!!await Promise.resolve(this.continueCondition(this));return console.log(r?"BackgroundWorker: Условие продолжения выполнено":"BackgroundWorker: Отмена continueBackground - внешнее условие вернуло false"),r}catch(e){return console.error("BackgroundWorker: Ошибка при выполнении условия продолжения",e),console.log("BackgroundWorker: Отмена continueBackground - исключение в условии запуска"),!1}}async getFilteredTabList(){const e=[],r=[],i=await this.getTabs();for(const A of i){if(!(A!=null&&A.data)){e.push(A);continue}new Date().getTime()-new Date(A.data.lastActive).getTime()>this.activeMaxPause?e.push(A):r.push(A)}return await this.deleteTabs(e),r}async backgroundPolling(){if(!await this.continueBackground()){this.interval&&(clearInterval(this.interval),this.interval=void 0),console.log("BackgroundWorker: Остановка backgroundPolling - условие continueBackground не выполнено");return}if(this.tabList=await this.getFilteredTabList(),!this.id){this.id=await this.addTab();return}let e=this.checkOtherTabs();e&&(await this.pause(Math.round(Number(Math.random().toFixed(2))*1e4)),this.tabList=await this.getFilteredTabList(),e=this.checkOtherTabs(),e&&await this.startBackground())}checkOtherTabs(){var A,o;let e=!1,r=new Date().getTime()-new Date(this.start).getTime();for(const h of this.tabList)if(+h.id!==this.id&&((A=h.data)!=null&&A.start&&(e=!0),((o=h.data)==null?void 0:o.duration)>r)){r=!1;break}const i=!e&&!!r;return this.updateTab(i).catch(h=>{console.error("BackgroundWorker: updateTab failed",h)}),console.log(`BackgroundWorker: Проверка вкладок - можно запускать приложение? ${i}`),i}async startBackground(){this.interval&&(clearInterval(this.interval),this.interval=void 0),this.interval=setInterval(()=>{this.updateTab(!0).catch(e=>{console.error("BackgroundWorker: periodic updateTab failed",e)})},this.activeMinPause),await this.appInit(),this.interval&&(clearInterval(this.interval),this.interval=void 0),this.id&&(await this.deleteTabs([{id:this.id}]),this.id=0)}async setBackgroundWorkerAll(){var d,g;if(!((d=this.bx)!=null&&d.isAdmin)){console.log("BackgroundWorker: Отмена setBackgroundWorkerAll - пользователь не админ");return}(g=this.users)!=null&&g.length||await this.getEntityData();const e=await this.bx.getPlacement(),r=new Map;let i=null;e.forEach(a=>{a.placement==="PAGE_BACKGROUND_WORKER"&&(a.userId?r.set(+a.userId,a):i=a)}),console.log(`setBackgroundWorkerAll: Найдено ${r.size} индивидуальных и ${i?1:0} общих привязок PAGE_BACKGROUND_WORKER`);const A=await this.updateAdminsList(),o=await this.getEligibleUsersForBackgroundWorker(A);o.sort((a,u)=>{const y=a.LAST_LOGIN?new Date(a.LAST_LOGIN):new Date(0);return(u.LAST_LOGIN?new Date(u.LAST_LOGIN):new Date(0))-y}),console.log(`setBackgroundWorkerAll: Найдено ${o.length} подходящих пользователей (админы и руководители)`);const h=[];!i&&this.appPath&&(h.push({method:"placement.bind",params:{PLACEMENT:"PAGE_BACKGROUND_WORKER",HANDLER:`${this.appPath}/`,LANG_ALL:{ru:{TITLE:this.appName}},OPTIONS:{errorHandlerUrl:`${this.appPath}/`}}}),console.log("setBackgroundWorkerAll: Добавлен в очередь создание общего бэк-воркера"));const m=10,l=o.slice(0,m),s=[];for(const[a]of r)o.find(y=>+y.ID===a)||s.push(a);for(const a of s)this.appPath&&(h.push({method:"placement.unbind",params:{PLACEMENT:"PAGE_BACKGROUND_WORKER",HANDLER:`${this.appPath}?USER_ID=${a}/`}}),console.log(`setBackgroundWorkerAll: Добавлена в очередь отвязка бэк-воркера от пользователя ${a}`));for(const a of l)r.has(+a.ID)||!this.appPath||h.push({method:"placement.bind",params:{PLACEMENT:"PAGE_BACKGROUND_WORKER",HANDLER:`${this.appPath}?USER_ID=${a.ID}/`,LANG_ALL:{ru:{TITLE:this.appName}},OPTIONS:{errorHandlerUrl:`${this.appPath}?USER_ID=${a.ID}/`},USER_ID:a.ID}});h.length?(console.log(`setBackgroundWorkerAll: Выполняем ${h.length} операций через batch`),await this.bx.batch(h),console.log("setBackgroundWorkerAll: Все операции batch выполнены успешно")):console.log("setBackgroundWorkerAll: Нет операций для выполнения")}async getEligibleUsersForBackgroundWorker(e=[]){return(this.users??[]).filter(i=>i.ACTIVE==="Y"||i.ACTIVE===!0).filter(i=>{const A=+i.ID;return e.includes(A)})}async updateAdminsList(){var e,r,i;try{let A=await this.getAdminsList();const o=+(((e=this.bx.userInfo)==null?void 0:e.ID)??0);(r=this.bx)!=null&&r.isAdmin&&o&&!A.includes(o)&&(A.push(o),console.log(`updateAdminsList: Добавлен новый админ ${o}`)),!((i=this.bx)!=null&&i.isAdmin)&&o&&A.includes(o)&&(A=A.filter(l=>l!==o),console.log(`updateAdminsList: Удален из списка админов пользователь ${o} (больше не админ)`));const h=new Set((this.users??[]).filter(l=>l.ACTIVE==="Y"||l.ACTIVE===!0).map(l=>+l.ID)),m=A.filter(l=>h.has(l));return m.length!==A.length&&(console.log(`updateAdminsList: Удалено ${A.length-m.length} неактивных админов`),A=m),BX24.appOption.set("adminsList",JSON.stringify(A)),console.log(`BackgroundWorker: Список админов обновлен: ${A.length} админов`),A}catch(A){return console.error("BackgroundWorker: Ошибка при обновлении списка админов:",A),[]}}async getAdminsList(){try{const e=BX24.appOption.get("adminsList");return e?JSON.parse(e):[]}catch(e){return console.error("getAdminsList: Ошибка при получении списка админов:",e),[]}}async getEntityData(){const e={users:{method:"user.get",params:{filter:{ACTIVE:"Y"}}}},{users:r}=await this.bx.batch(e).then(i=>i?(Array.isArray(i.users)||(i.users=[]),i):{users:[]});this.users=r}pause(e=500,r){return new Promise(i=>{setTimeout(()=>{r&&r(),i(!0)},e)})}}N.BackgroundWorker=Lt,N.Batch=v,N.BxBoot=Rt,N.BxHelper=ut,N.BxLogger=gt,N.tempus=rt,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "szdl-utils-kit",
3
3
  "description": "utils-kit library",
4
4
  "private": false,
5
- "version": "0.3.5",
5
+ "version": "0.3.6",
6
6
  "type": "module",
7
7
  "author": "Stanislav Ovv",
8
8
  "license": "BSD",
@@ -28,7 +28,7 @@
28
28
  "watch": "vite build --watch",
29
29
  "build": "vite build",
30
30
  "preview": "vite preview",
31
- "pub": "npm version patch && npm publish"
31
+ "pub": "npm version patch --no-git-tag-version && npm publish"
32
32
  },
33
33
  "devDependencies": {
34
34
  "vite": "^4.4.5",