szdl-utils-kit 0.3.23 → 0.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,54 +1,54 @@
1
- var Ne = Object.defineProperty;
2
- var Oe = (y, e, t) => e in y ? Ne(y, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : y[e] = t;
3
- var B = (y, e, t) => (Oe(y, typeof e != "symbol" ? e + "" : e, t), t), Ft = (y, e, t) => {
4
- if (!e.has(y))
1
+ var Ie = Object.defineProperty;
2
+ var De = (m, e, t) => e in m ? Ie(m, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[e] = t;
3
+ var w = (m, e, t) => (De(m, typeof e != "symbol" ? e + "" : e, t), t), zt = (m, e, t) => {
4
+ if (!e.has(m))
5
5
  throw TypeError("Cannot " + t);
6
6
  };
7
- var S = (y, e, t) => (Ft(y, e, "read from private field"), t ? t.call(y) : e.get(y)), R = (y, e, t) => {
8
- if (e.has(y))
7
+ var L = (m, e, t) => (zt(m, e, "read from private field"), t ? t.call(m) : e.get(m)), E = (m, e, t) => {
8
+ if (e.has(m))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
- e instanceof WeakSet ? e.add(y) : e.set(y, t);
11
- }, x = (y, e, t, r) => (Ft(y, e, "write to private field"), r ? r.call(y, t) : e.set(y, t), t);
12
- var _ = (y, e, t) => (Ft(y, e, "access private method"), t);
13
- var _e = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
14
- function Te(y) {
15
- return y && y.__esModule && Object.prototype.hasOwnProperty.call(y, "default") ? y.default : y;
10
+ e instanceof WeakSet ? e.add(m) : e.set(m, t);
11
+ }, x = (m, e, t, r) => (zt(m, e, "write to private field"), r ? r.call(m, t) : e.set(m, t), t);
12
+ var y = (m, e, t) => (zt(m, e, "access private method"), t);
13
+ var ke = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
14
+ function we(m) {
15
+ return m && m.__esModule && Object.prototype.hasOwnProperty.call(m, "default") ? m.default : m;
16
16
  }
17
- var Jt = { exports: {} };
18
- (function(y, e) {
17
+ var Vt = { exports: {} };
18
+ (function(m, e) {
19
19
  (function(t) {
20
20
  Array.prototype.indexOf || (Array.prototype.indexOf = function(s, o) {
21
- var d, g;
22
- for (d = o || 0, g = this.length; d < g; d += 1)
23
- if (this[d] === s)
24
- return d;
21
+ var g, p;
22
+ for (g = o || 0, p = this.length; g < p; g += 1)
23
+ if (this[g] === s)
24
+ return g;
25
25
  return -1;
26
26
  });
27
27
  var r = this, i = function(s, o) {
28
- for (var d = s.toString(); d.length < o; )
29
- d = "0" + d;
30
- return d;
28
+ for (var g = s.toString(); g.length < o; )
29
+ g = "0" + g;
30
+ return g;
31
31
  }, a = function(s, o) {
32
32
  return o !== t ? (s.year(o.year() || o.year), s.month(o.month() || o.month), s.day(o.day() || o.day), s.hours(o.hours() || o.hours), s.minutes(o.minutes() || o.minutes), s.seconds(o.seconds() || o.seconds), s.milliseconds(o.milliseconds() || o.milliseconds), s) : t;
33
33
  }, c = function(s, o) {
34
- var d, g = "";
35
- return d = s.slice(o, o + 1), d !== "" && !isNaN(Number(d)) && (g += "%H"), d = s.charAt(o + 2), d !== "" && d === ":" && (g += d), d = s.slice(o + 3, o + 4), d !== "" && !isNaN(Number(d)) && (g += "%M"), d = s.charAt(o + 5), d !== "" && d === ":" && (g += d), d = s.slice(o + 6, o + 7), d !== "" && !isNaN(Number(d)) && (g += "%S"), g;
36
- }, l = function(s, o) {
37
- var d, g = [
34
+ var g, p = "";
35
+ return g = s.slice(o, o + 1), g !== "" && !isNaN(Number(g)) && (p += "%H"), g = s.charAt(o + 2), g !== "" && g === ":" && (p += g), g = s.slice(o + 3, o + 4), g !== "" && !isNaN(Number(g)) && (p += "%M"), g = s.charAt(o + 5), g !== "" && g === ":" && (p += g), g = s.slice(o + 6, o + 7), g !== "" && !isNaN(Number(g)) && (p += "%S"), p;
36
+ }, h = function(s, o) {
37
+ var g, p = [
38
38
  s.slice(o, o + 1),
39
39
  s.charAt(o + 2),
40
40
  s.slice(o + 3, o + 4),
41
41
  s.charAt(o + 5),
42
42
  s.slice(o + 6, o + 9)
43
- ], C;
44
- return !isNaN(Number(g[0])) && !isNaN(Number(g[2])) && !isNaN(Number(g[4])) ? (g[1] === "." && g[3] === "." ? d = "%d.%m.%Y" : g[1] === "-" && g[3] === "-" ? d = "%m-%d-%Y" : g[1] === "/" && g[3] === "/" && (d = "%m/%d/%Y"), d) : (C = [
43
+ ], H;
44
+ return !isNaN(Number(p[0])) && !isNaN(Number(p[2])) && !isNaN(Number(p[4])) ? (p[1] === "." && p[3] === "." ? g = "%d.%m.%Y" : p[1] === "-" && p[3] === "-" ? g = "%m-%d-%Y" : p[1] === "/" && p[3] === "/" && (g = "%m/%d/%Y"), g) : (H = [
45
45
  s.slice(o, o + 3),
46
46
  s.charAt(o + 4),
47
47
  s.slice(o + 5, o + 6),
48
48
  s.charAt(o + 7),
49
49
  s.slice(o + 8, o + 9)
50
- ], !isNaN(Number(C[0])) && !isNaN(Number(C[2])) && !isNaN(Number(C[4])) ? (C[1] === "-" && C[3] === "-" && (d = "%Y-%m-%d"), d) : "");
51
- }, h = r.tempus, n, f, m = r.navigator || {}, A = "en", u = {
50
+ ], !isNaN(Number(H[0])) && !isNaN(Number(H[2])) && !isNaN(Number(H[4])) ? (H[1] === "-" && H[3] === "-" && (g = "%Y-%m-%d"), g) : "");
51
+ }, f = r.tempus, n, u, d = r.navigator || {}, A = "en", l = {
52
52
  en: {
53
53
  JANUARY_SHORT: "Jan",
54
54
  FEBRUARY_SHORT: "Feb",
@@ -211,61 +211,61 @@ var Jt = { exports: {} };
211
211
  }
212
212
  }, O = function() {
213
213
  return [
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
214
+ l[A].JANUARY_LONG,
215
+ l[A].FEBRUARY_LONG,
216
+ l[A].MARCH_LONG,
217
+ l[A].APRIL_LONG,
218
+ l[A].MAY_LONG,
219
+ l[A].JUNE_LONG,
220
+ l[A].JULY_LONG,
221
+ l[A].AUGUST_LONG,
222
+ l[A].SEPTEMBER_LONG,
223
+ l[A].OCTOBER_LONG,
224
+ l[A].NOVEMBER_LONG,
225
+ l[A].DECEMBER_LONG
226
226
  ];
227
- }, T = function() {
227
+ }, _ = function() {
228
228
  return [
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
229
+ l[A].JANUARY_SHORT,
230
+ l[A].FEBRUARY_SHORT,
231
+ l[A].MARCH_SHORT,
232
+ l[A].APRIL_SHORT,
233
+ l[A].MAY_SHORT,
234
+ l[A].JUNE_SHORT,
235
+ l[A].JULY_SHORT,
236
+ l[A].AUGUST_SHORT,
237
+ l[A].SEPTEMBER_SHORT,
238
+ l[A].OCTOBER_SHORT,
239
+ l[A].NOVEMBER_SHORT,
240
+ l[A].DECEMBER_SHORT
241
241
  ];
242
- }, E = function() {
242
+ }, b = function() {
243
243
  return [
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
244
+ l[A].SUNDAY_LONG,
245
+ l[A].MONDAY_LONG,
246
+ l[A].TUESDAY_LONG,
247
+ l[A].WEDNESDAY_LONG,
248
+ l[A].THURSDAY_LONG,
249
+ l[A].FRIDAY_LONG,
250
+ l[A].SATURDAY_LONG
251
251
  ];
252
- }, M = function() {
252
+ }, k = function() {
253
253
  return [
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
254
+ l[A].SUNDAY_SHORT,
255
+ l[A].MONDAY_SHORT,
256
+ l[A].TUESDAY_SHORT,
257
+ l[A].WEDNESDAY_SHORT,
258
+ l[A].THURSDAY_SHORT,
259
+ l[A].FRIDAY_SHORT,
260
+ l[A].SATURDAY_SHORT
261
261
  ];
262
- }, p, b, H, N, I = function(s, o, d) {
263
- var g;
264
- r.XMLHttpRequest ? g = new XMLHttpRequest() : g = new ActiveXObject("Microsoft.XMLHTTP"), g.onreadystatechange = function() {
265
- g.readyState === 4 && (g.status === 200 ? o && (r.JSON === t ? alert(`Please, include json2 into your project if you want use old browsers!
266
- https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(g.responseText))) : d && d(g));
267
- }, g.open("GET", s, !1), g.send();
268
- }, L = {
262
+ }, T, M, G, N, S = function(s, o, g) {
263
+ var p;
264
+ r.XMLHttpRequest ? p = new XMLHttpRequest() : p = new ActiveXObject("Microsoft.XMLHTTP"), p.onreadystatechange = function() {
265
+ p.readyState === 4 && (p.status === 200 ? o && (r.JSON === t ? alert(`Please, include json2 into your project if you want use old browsers!
266
+ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.parse(p.responseText))) : g && g(p));
267
+ }, p.open("GET", s, !1), p.send();
268
+ }, I = {
269
269
  "%d": {
270
270
  format: function(s) {
271
271
  return i(s.day() || n.MIN_DAY, 2);
@@ -328,7 +328,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
328
328
  "%A": {
329
329
  format: function(s) {
330
330
  var o = s.dayOfWeek();
331
- return H[o !== t ? o : n.MIN_DAY_OF_WEEK];
331
+ return G[o !== t ? o : n.MIN_DAY_OF_WEEK];
332
332
  },
333
333
  parse: function() {
334
334
  return {};
@@ -340,7 +340,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
340
340
  "%b": {
341
341
  format: function(s) {
342
342
  var o = n.options("monthFromZero") ? s.month() : s.month() - 1;
343
- return b[o !== t ? o : n.MIN_MONTH];
343
+ return M[o !== t ? o : n.MIN_MONTH];
344
344
  },
345
345
  parse: function(s) {
346
346
  var o = n.monthNames().indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
@@ -353,7 +353,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
353
353
  "%B": {
354
354
  format: function(s) {
355
355
  var o = n.options("monthFromZero") ? s.month() : s.month() - 1;
356
- return p[o !== t ? o : n.MIN_MONTH];
356
+ return T[o !== t ? o : n.MIN_MONTH];
357
357
  },
358
358
  parse: function(s) {
359
359
  var o = n.monthNames(!0).indexOf(s) + (n.options("monthFromZero") ? 0 : 1);
@@ -415,11 +415,11 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
415
415
  return i(s.year() || n.MIN_YEAR, 4) + "-" + i(s.month() || n.MIN_MONTH, 2) + "-" + i(s.day() || n.MIN_DAY, 2);
416
416
  },
417
417
  parse: function(s) {
418
- var o = Number(s.slice(0, 4)), d = Number(s.slice(5, 7)), g = Number(s.slice(8, 10));
418
+ var o = Number(s.slice(0, 4)), g = Number(s.slice(5, 7)), p = Number(s.slice(8, 10));
419
419
  return {
420
420
  year: o,
421
- month: d,
422
- day: g
421
+ month: g,
422
+ day: p
423
423
  };
424
424
  },
425
425
  minLength: 10,
@@ -431,22 +431,22 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
431
431
  return i(s.month() || n.MIN_MONTH, 2) + "/" + i(s.day() || n.MIN_DAY, 2) + "/" + i(s.year() || n.MIN_YEAR, 4);
432
432
  },
433
433
  parse: function(s) {
434
- var o = Number(s.slice(0, 2)), d = Number(s.slice(3, 5)), g = Number(s.slice(6, 10));
434
+ var o = Number(s.slice(0, 2)), g = Number(s.slice(3, 5)), p = Number(s.slice(6, 10));
435
435
  return {
436
- year: g,
436
+ year: p,
437
437
  month: o,
438
- day: d
438
+ day: g
439
439
  };
440
440
  },
441
441
  minLength: 10,
442
442
  maxLength: 10,
443
443
  type: "string"
444
444
  }
445
- }, w = {
445
+ }, C = {
446
446
  useMilliseconds: !1,
447
447
  monthFromZero: !1
448
- }, k;
449
- k = function(s, o, d) {
448
+ }, R;
449
+ R = function(s, o, g) {
450
450
  return this._d = /* @__PURE__ */ new Date(), this._i = {
451
451
  year: !1,
452
452
  month: !1,
@@ -455,56 +455,56 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
455
455
  minutes: !1,
456
456
  seconds: !1,
457
457
  milliseconds: !1
458
- }, s !== t && this.set(s, o, d), this;
459
- }, k.fn = k.prototype, k.fn.dayCount = function() {
458
+ }, s !== t && this.set(s, o, g), this;
459
+ }, R.fn = R.prototype, R.fn.dayCount = function() {
460
460
  var s = this.month(), o = n.MAX_DAY_IN_MONTHS[s - (n.options("monthFromZero") ? 0 : 1)];
461
461
  return this.leapYear() && s === (n.options("monthFromZero") ? 1 : 2) && (o += 1), o;
462
- }, k.fn.year = function(s) {
462
+ }, R.fn.year = function(s) {
463
463
  if (arguments.length !== 0)
464
464
  (typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_YEAR && Number(s) <= n.MAX_YEAR ? (this._d.setFullYear(Number(s)), this._i.year = !1) : this._i.year = Number(s) : (this._d.setFullYear(n.MIN_YEAR), this._i.year = !1);
465
465
  else
466
466
  return this._i.year === !1 ? this._d.getFullYear() : this._i.year;
467
467
  return this;
468
- }, k.fn.month = function(s) {
468
+ }, R.fn.month = function(s) {
469
469
  if (arguments.length !== 0)
470
470
  (typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_MONTH && Number(s) <= n.MAX_MONTH ? (this._d.setMonth(n.options("monthFromZero") ? Number(s) : Number(s) - 1), this._i.month = !1) : this._i.month = Number(s) : (this._d.setMonth(n.options("monthFromZero") ? n.MIN_MONTH : n.MIN_MONTH - 1), this._i.month = !1);
471
471
  else
472
472
  return this._i.month === !1 ? n.options("monthFromZero") ? this._d.getMonth() : this._d.getMonth() + 1 : this._i.month;
473
473
  return this;
474
- }, k.fn.day = function(s) {
474
+ }, R.fn.day = function(s) {
475
475
  if (arguments.length !== 0)
476
476
  (typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_DAY && Number(s) <= this.dayCount() ? (this._d.setDate(Number(s)), this._i.day = !1) : this._i.day = Number(s) : (this._d.setDate(n.MIN_DAY), this._i.day = !1);
477
477
  else
478
478
  return this._i.day === !1 ? this._d.getDate() : this._i.day;
479
479
  return this;
480
- }, k.fn.hours = function(s) {
480
+ }, R.fn.hours = function(s) {
481
481
  if (arguments.length !== 0)
482
482
  (typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_HOURS && Number(s) <= n.MAX_HOURS ? (this._d.setHours(Number(s)), this._i.hours = !1) : this._i.hours = Number(s) : (this._d.setHours(n.MIN_HOURS), this._i.hours = !1);
483
483
  else
484
484
  return this._i.hours === !1 ? this._d.getHours() : this._i.hours;
485
485
  return this;
486
- }, k.fn.minutes = function(s) {
486
+ }, R.fn.minutes = function(s) {
487
487
  if (arguments.length !== 0)
488
488
  (typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_MINUTES && Number(s) <= n.MAX_MINUTES ? (this._d.setMinutes(Number(s)), this._i.minutes = !1) : this._i.minutes = Number(s) : (this._d.setMinutes(n.MIN_MINUTES), this._i.minutes = !1);
489
489
  else
490
490
  return this._i.minutes === !1 ? this._d.getMinutes() : this._i.minutes;
491
491
  return this;
492
- }, k.fn.seconds = function(s) {
492
+ }, R.fn.seconds = function(s) {
493
493
  if (arguments.length !== 0)
494
494
  (typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_SECONDS && Number(s) <= n.MAX_SECONDS ? (this._d.setSeconds(Number(s)), this._i.seconds = !1) : this._i.seconds = Number(s) : (this._d.setSeconds(n.MIN_SECONDS), this._i.seconds = !1);
495
495
  else
496
496
  return this._i.seconds === !1 ? this._d.getSeconds() : this._i.seconds;
497
497
  return this;
498
- }, k.fn.milliseconds = function(s) {
498
+ }, R.fn.milliseconds = function(s) {
499
499
  if (arguments.length !== 0)
500
500
  (typeof s == "number" || typeof s == "string") && !isNaN(Number(s)) ? Number(s) >= n.MIN_MILLISECONDS && Number(s) <= n.MAX_MILLISECONDS ? (this._d.setMilliseconds(Number(s)), this._i.milliseconds = !1) : this._i.milliseconds = Number(s) : (this._d.setMilliseconds(n.MIN_MILLISECONDS), this._i.milliseconds = !1);
501
501
  else
502
502
  return this._i.milliseconds === !1 ? this._d.getMilliseconds() : this._i.milliseconds;
503
503
  return this;
504
- }, k.fn.week = function() {
504
+ }, R.fn.week = function() {
505
505
  var s = new Date(this.year(), 0, 1), o = n(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc() * 1e3;
506
506
  return Math.ceil(((o - s.getTime()) / 864e5 + s.getDay() + 1) / 7);
507
- }, k.fn.set = function(s, o, d) {
507
+ }, R.fn.set = function(s, o, g) {
508
508
  if (this._i = {
509
509
  year: !1,
510
510
  month: !1,
@@ -520,9 +520,9 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
520
520
  if (typeof s == "number")
521
521
  return this._d = new Date(s * (n.options("useMilliseconds") ? 1 : 1e3)), this;
522
522
  if (typeof s == "object" && (s instanceof Array ? (this.day(n.MIN_DAY), this.year(s[0]), this.month(s[1]), this.day(s[2]), this.hours(s[3]), this.minutes(s[4]), this.seconds(s[5]), this.milliseconds(s[6])) : (this.day(n.MIN_DAY), this.year(s.year), this.month(s.month), this.day(s.day), this.hours(s.hours), this.minutes(s.minutes), this.seconds(s.seconds), this.milliseconds(s.milliseconds))), typeof s == "string") {
523
- var g, C = [], D, U, Q = [], W = 0, F = 0, P, X, G = {}, Y;
523
+ var p, H = [], D, B, Q = [], W = 0, F = 0, U, X, P = {}, Y;
524
524
  if (s === t)
525
- return D = a(this, d), D === t && (this._i = {
525
+ return D = a(this, g), D === t && (this._i = {
526
526
  year: -1,
527
527
  month: -1,
528
528
  day: -1,
@@ -533,23 +533,23 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
533
533
  }), D;
534
534
  for (o === t && (o = n.detectFormat(s)); W < o.length; ) {
535
535
  if (o.charAt(W) === "%") {
536
- if (U = o.charAt(W) + o.charAt(W + 1), L[U] !== t) {
537
- switch (P = 0, X = "", L[U].type) {
536
+ if (B = o.charAt(W) + o.charAt(W + 1), I[B] !== t) {
537
+ switch (U = 0, X = "", I[B].type) {
538
538
  case "number":
539
- for (; P < L[U].maxLength && F + P < s.length && !isNaN(Number(s.charAt(F + P))); )
540
- X += s.charAt(F + P), P += 1;
539
+ for (; U < I[B].maxLength && F + U < s.length && !isNaN(Number(s.charAt(F + U))); )
540
+ X += s.charAt(F + U), U += 1;
541
541
  break;
542
542
  case "word":
543
- for (; P < L[U].maxLength && F + P < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + P)); )
544
- X += s.charAt(F + P), P += 1;
543
+ for (; U < I[B].maxLength && F + U < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + U)); )
544
+ X += s.charAt(F + U), U += 1;
545
545
  break;
546
546
  case "string":
547
- for (; P < L[U].maxLength && F + P < s.length; )
548
- X += s.charAt(F + P), P += 1;
547
+ for (; U < I[B].maxLength && F + U < s.length; )
548
+ X += s.charAt(F + U), U += 1;
549
549
  break;
550
550
  }
551
- if (P < L[U].minLength)
552
- return D = a(this, d), D === t && (this._i = {
551
+ if (U < I[B].minLength)
552
+ return D = a(this, g), D === t && (this._i = {
553
553
  year: -1,
554
554
  month: -1,
555
555
  day: -1,
@@ -558,10 +558,10 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
558
558
  seconds: -1,
559
559
  milliseconds: -1
560
560
  }), D;
561
- C.push(U), Q.push(X), P -= 1, F += P, W += 1;
561
+ H.push(B), Q.push(X), U -= 1, F += U, W += 1;
562
562
  }
563
563
  } else if (s.charAt(F) !== o.charAt(W))
564
- return D = a(this, d), D === t && (this._i = {
564
+ return D = a(this, g), D === t && (this._i = {
565
565
  year: -1,
566
566
  month: -1,
567
567
  day: -1,
@@ -572,28 +572,28 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
572
572
  }), D;
573
573
  W += 1, F += 1;
574
574
  }
575
- for (g in C)
576
- C.hasOwnProperty(g) && L.hasOwnProperty(C[g]) && (Y = L[C[g]].parse(Q[g]), G = {
577
- year: Y.year !== t ? Y.year : G.year,
578
- month: Y.month !== t ? Y.month : G.month,
579
- day: Y.day !== t ? Y.day : G.day,
580
- hours: Y.hours !== t ? Y.hours : G.hours,
581
- minutes: Y.minutes !== t ? Y.minutes : G.minutes,
582
- seconds: Y.seconds !== t ? Y.seconds : G.seconds
575
+ for (p in H)
576
+ H.hasOwnProperty(p) && I.hasOwnProperty(H[p]) && (Y = I[H[p]].parse(Q[p]), P = {
577
+ year: Y.year !== t ? Y.year : P.year,
578
+ month: Y.month !== t ? Y.month : P.month,
579
+ day: Y.day !== t ? Y.day : P.day,
580
+ hours: Y.hours !== t ? Y.hours : P.hours,
581
+ minutes: Y.minutes !== t ? Y.minutes : P.minutes,
582
+ seconds: Y.seconds !== t ? Y.seconds : P.seconds
583
583
  });
584
- this.day(n.MIN_DAY), this.year(G.year), this.month(G.month), this.day(G.day), this.hours(G.hours), this.minutes(G.minutes), this.seconds(G.seconds), this.milliseconds(G.milliseconds);
584
+ this.day(n.MIN_DAY), this.year(P.year), this.month(P.month), this.day(P.day), this.hours(P.hours), this.minutes(P.minutes), this.seconds(P.seconds), this.milliseconds(P.milliseconds);
585
585
  }
586
586
  return this;
587
- }, k.fn.leapYear = function() {
587
+ }, R.fn.leapYear = function() {
588
588
  var s = this.year();
589
589
  return s % 4 === 0 ? s % 100 === 0 ? s % 400 === 0 : !0 : !1;
590
- }, k.fn.timestamp = function(s) {
590
+ }, R.fn.timestamp = function(s) {
591
591
  return arguments.length !== 0 ? (this._d = new Date(Number(s) * (n.options("useMilliseconds") ? 1 : 1e3) + this._d.getTimezoneOffset() * 6e4), this) : n.options("useMilliseconds") ? this._d.getTime() - this._d.getTimezoneOffset() * 6e4 : Math.floor(this._d.getTime() / 1e3) - this._d.getTimezoneOffset() * 60;
592
- }, k.fn.utc = function(s) {
592
+ }, R.fn.utc = function(s) {
593
593
  return arguments.length !== 0 ? (this._d = new Date(Number(s) * (n.options("useMilliseconds") ? 1 : 1e3)), this) : n.options("useMilliseconds") ? this._d.getTime() : Math.floor(this._d.getTime() / 1e3);
594
- }, k.fn.dayOfWeek = function(s) {
594
+ }, R.fn.dayOfWeek = function(s) {
595
595
  if (s === "long")
596
- return H[this._d.getDay()];
596
+ return G[this._d.getDay()];
597
597
  if (s === "short")
598
598
  return N[this._d.getDay()];
599
599
  if (s === t)
@@ -612,7 +612,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
612
612
  return this.calc({ day: (this.dayOfWeek() === 0 ? -2 : 5) - this.dayOfWeek() });
613
613
  if (s === 6 || s === "Saturday")
614
614
  return this.calc({ day: (this.dayOfWeek() === 0 ? -1 : 6) - this.dayOfWeek() });
615
- }, k.fn.timezone = function(s) {
615
+ }, R.fn.timezone = function(s) {
616
616
  switch (s) {
617
617
  case "hours":
618
618
  return Math.floor(this._d.getTimezoneOffset() / 60);
@@ -621,7 +621,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
621
621
  default:
622
622
  return this._d.getTimezoneOffset() * 60;
623
623
  }
624
- }, k.fn.get = function(s) {
624
+ }, R.fn.get = function(s) {
625
625
  switch (s) {
626
626
  case "Date":
627
627
  return new Date(
@@ -670,50 +670,50 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
670
670
  timestamp: this.timestamp()
671
671
  };
672
672
  }
673
- }, k.fn.format = function(s) {
674
- for (var o = 0, d = "", g; o < s.length; )
675
- s.charAt(o) === "%" ? (g = s.charAt(o) + s.charAt(o + 1), L[g] !== t ? (d += L[g].format(this), o += 1) : d += "%") : d += s.charAt(o), o += 1;
676
- return d;
677
- }, k.fn.valid = function() {
673
+ }, R.fn.format = function(s) {
674
+ for (var o = 0, g = "", p; o < s.length; )
675
+ s.charAt(o) === "%" ? (p = s.charAt(o) + s.charAt(o + 1), I[p] !== t ? (g += I[p].format(this), o += 1) : g += "%") : g += s.charAt(o), o += 1;
676
+ return g;
677
+ }, R.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
- }, k.fn.errors = function() {
679
+ }, R.fn.errors = function() {
680
680
  return this._i;
681
- }, k.fn.between = function(s, o) {
682
- var d = this.timestamp(), g = s.timestamp();
681
+ }, R.fn.between = function(s, o) {
682
+ var g = this.timestamp(), p = s.timestamp();
683
683
  switch (o) {
684
684
  case "year":
685
- return Math.floor((g - d) / 31556952);
685
+ return Math.floor((p - g) / 31556952);
686
686
  case "month":
687
- return Math.floor((g - d) / 2629746);
687
+ return Math.floor((p - g) / 2629746);
688
688
  case "day":
689
- return Math.floor((g - d) / 86400);
689
+ return Math.floor((p - g) / 86400);
690
690
  case "hours":
691
- return Math.floor((g - d) / 3600);
691
+ return Math.floor((p - g) / 3600);
692
692
  case "minutes":
693
- return Math.floor((g - d) / 60);
693
+ return Math.floor((p - g) / 60);
694
694
  case "seconds":
695
- return g - d;
695
+ return p - g;
696
696
  default:
697
697
  return t;
698
698
  }
699
- }, k.fn.calc = function(s) {
699
+ }, R.fn.calc = function(s) {
700
700
  return s.year !== t && this._d.setFullYear(this._d.getFullYear() + s.year), s.month !== t && this._d.setMonth(this._d.getMonth() + s.month), s.day !== t && this._d.setDate(this._d.getDate() + s.day), s.hours !== t && this._d.setHours(this._d.getHours() + s.hours), s.minutes !== t && this._d.setMinutes(this._d.getMinutes() + s.minutes), s.seconds !== t && this._d.setSeconds(this._d.getSeconds() + s.seconds), s.milliseconds !== t && this._d.setMilliseconds(this._d.getMilliseconds() + s.milliseconds), this;
701
- }, n = function(s, o, d) {
702
- return new k(s, o, d);
701
+ }, n = function(s, o, g) {
702
+ return new R(s, o, g);
703
703
  }, n.MIN_YEAR = 1e3, n.MAX_YEAR = 3e3, n.MIN_MONTH = 1, n.MAX_MONTH = 12, n.MIN_DAY = 1, n.MAX_DAY_IN_MONTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], n.MIN_DAY_OF_WEEK = 0, n.MAX_DAY_OF_WEEK = 6, n.MIN_HOURS = 0, n.MAX_HOURS = 23, n.MIN_MINUTES = 0, n.MAX_MINUTES = 59, n.MIN_SECONDS = 0, n.MAX_SECONDS = 59, n.MIN_MILLISECONDS = 0, n.MAX_MILLISECONDS = 999, n.VERSION = "0.2.18", n.options = function(s, o) {
704
704
  if (s === t)
705
- return w;
706
- if (w.hasOwnProperty(s)) {
705
+ return C;
706
+ if (C.hasOwnProperty(s)) {
707
707
  if (o === t)
708
- return w[s];
709
- w[s] = o, s === "monthFromZero" && (n.MIN_MONTH = o ? 0 : 1, n.MAX_MONTH = o ? 11 : 12);
708
+ return C[s];
709
+ C[s] = o, s === "monthFromZero" && (n.MIN_MONTH = o ? 0 : 1, n.MAX_MONTH = o ? 11 : 12);
710
710
  }
711
711
  return t;
712
712
  }, n.noConflict = function() {
713
- return r.tempus = h, n;
713
+ return r.tempus = f, n;
714
714
  }, n.generate = function(s) {
715
- var o, d, g, C, D, U, Q, W;
716
- if (typeof s.dateFrom != "number" && (s.dateFrom instanceof k ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof k ? d = s.dateTo.utc() : d = n(s.dateTo, s.formatTo !== t ? s.formatTo : s.formatFrom).utc()), typeof s.period == "number" ? D = {
715
+ var o, g, p, H, D, B, Q, W;
716
+ if (typeof s.dateFrom != "number" && (s.dateFrom instanceof R ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof R ? g = s.dateTo.utc() : g = n(s.dateTo, s.formatTo !== t ? s.formatTo : s.formatFrom).utc()), typeof s.period == "number" ? D = {
717
717
  year: 0,
718
718
  month: 0,
719
719
  day: 0,
@@ -734,8 +734,8 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
734
734
  hours: s.period.hours !== t ? s.period.hours : 0,
735
735
  minutes: s.period.minutes !== t ? s.period.minutes : 0,
736
736
  seconds: s.period.seconds !== t ? s.period.seconds : 0
737
- }), s.groupBy === t ? U = s.asObject === !0 ? {} : [] : (U = [], U.push([]), Q = n(o).get()[s.groupBy]), W = function(X, G, Y) {
738
- return s.asObject === !0 ? s.format !== t ? X[n(G).format(s.format)] = {} : X[n(G).format("%F %H:%M:%S")] = {} : s.format !== t ? X.push(Y ? null : n(G).format(s.format)) : X.push(Y ? null : n(G)), X;
737
+ }), s.groupBy === t ? B = s.asObject === !0 ? {} : [] : (B = [], B.push([]), Q = n(o).get()[s.groupBy]), W = function(X, P, Y) {
738
+ return s.asObject === !0 ? s.format !== t ? X[n(P).format(s.format)] = {} : X[n(P).format("%F %H:%M:%S")] = {} : s.format !== t ? X.push(Y ? null : n(P).format(s.format)) : X.push(Y ? null : n(P)), X;
739
739
  }, s.groupBy !== t && s.fillNulls) {
740
740
  var F = {
741
741
  year: D.year ? -D.year : t,
@@ -746,72 +746,72 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
746
746
  seconds: D.seconds ? -D.seconds : t,
747
747
  milliseconds: D.milliseconds ? -D.milliseconds : t
748
748
  };
749
- for (g = n(o).calc(F).utc(); n(g).get()[s.groupBy] === Q; )
750
- W(U[U.length - 1], g, !0), g = n(g).calc(F).utc();
749
+ for (p = n(o).calc(F).utc(); n(p).get()[s.groupBy] === Q; )
750
+ W(B[B.length - 1], p, !0), p = n(p).calc(F).utc();
751
751
  if (s.groupBy === "week") {
752
- var P = n(o).dayOfWeek();
753
- for (g = n(o).dayOfWeek(0).utc(); U[0].length < P && g < o; )
754
- W(U[U.length - 1], g, !0), g = n(g).calc(D).utc();
752
+ var U = n(o).dayOfWeek();
753
+ for (p = n(o).dayOfWeek(0).utc(); B[0].length < U && p < o; )
754
+ W(B[B.length - 1], p, !0), p = n(p).calc(D).utc();
755
755
  }
756
756
  }
757
- for (; o <= d; )
758
- s.groupBy === t ? W(U, o) : n(o).get()[s.groupBy] === Q ? W(U[U.length - 1], o) : (U.push([]), W(U[U.length - 1], o), Q = n(o).get()[s.groupBy]), o = n(o).calc(D).utc();
757
+ for (; o <= g; )
758
+ s.groupBy === t ? W(B, o) : n(o).get()[s.groupBy] === Q ? W(B[B.length - 1], o) : (B.push([]), W(B[B.length - 1], o), Q = n(o).get()[s.groupBy]), o = n(o).calc(D).utc();
759
759
  if (s.groupBy !== t && s.fillNulls)
760
- for (C = n(d).calc(D).utc(); n(C).get()[s.groupBy] === Q; )
761
- W(U[U.length - 1], C, !0), C = n(C).calc(D).utc();
762
- return U;
760
+ for (H = n(g).calc(D).utc(); n(H).get()[s.groupBy] === Q; )
761
+ W(B[B.length - 1], H, !0), H = n(H).calc(D).utc();
762
+ return B;
763
763
  }, n.monthNames = function(s) {
764
764
  switch (s) {
765
765
  case "long":
766
- return p;
766
+ return T;
767
767
  default:
768
- return b;
768
+ return M;
769
769
  }
770
770
  }, n.dayNames = function(s) {
771
771
  switch (s) {
772
772
  case "long":
773
- return H;
773
+ return G;
774
774
  default:
775
775
  return N;
776
776
  }
777
777
  }, n.lang = function(s) {
778
778
  if (s !== t)
779
- A = s, u[A] === t && (A = "en"), p = O(), b = T(), H = E(), N = M();
779
+ A = s, l[A] === t && (A = "en"), T = O(), M = _(), G = b(), N = k();
780
780
  else
781
781
  return A;
782
782
  return t;
783
783
  }, n.availableLangs = function() {
784
- return Object.keys(u);
785
- }, n.registerFormat = function(s, o, d, g, C, D) {
786
- L[s] = {
784
+ return Object.keys(l);
785
+ }, n.registerFormat = function(s, o, g, p, H, D) {
786
+ I[s] = {
787
787
  format: o,
788
- parse: d,
789
- minLength: g,
790
- maxLength: C,
788
+ parse: g,
789
+ minLength: p,
790
+ maxLength: H,
791
791
  type: D
792
792
  };
793
793
  }, n.unregisterFormat = function(s) {
794
- delete L[s];
794
+ delete I[s];
795
795
  }, n.detectFormat = function(s) {
796
- var o, d, g;
797
- return o = l(s, 0), o !== "" && (g = 10), d = s.charAt(g), (d === "T" || d === " ") && (o += d, g += 1), o += c(s, g), o;
798
- }, f = {
799
- TempusDate: k
796
+ var o, g, p;
797
+ return o = h(s, 0), o !== "" && (p = 10), g = s.charAt(p), (g === "T" || g === " ") && (o += g, p += 1), o += c(s, p), o;
798
+ }, u = {
799
+ TempusDate: R
800
800
  }, n.classes = function(s, o) {
801
801
  if (o === t)
802
- return f[s];
803
- f[s] = o;
802
+ return u[s];
803
+ u[s] = o;
804
804
  }, n.loadTranslations = function(s) {
805
- typeof s == "object" ? u = s : typeof s == "string" && I(s, function(o) {
806
- u = o;
805
+ typeof s == "object" ? l = s : typeof s == "string" && S(s, function(o) {
806
+ l = o;
807
807
  }, function(o) {
808
808
  });
809
- }, A = (m.language || m.systemLanguage || m.userLanguage || "en").substr(0, 2).toLowerCase(), u[A] === t && (A = "en"), p = O(), b = T(), H = E(), N = M(), y.exports && (e = y.exports = n), e.tempus = n;
810
- }).call(_e);
811
- })(Jt, Jt.exports);
812
- var Ee = Jt.exports;
813
- const Ot = /* @__PURE__ */ Te(Ee);
814
- var Et, ee, bt, Lt, Rt, Mt, ot, _t, It, se, St, re, Z, nt, tt, ht, et, ut, Dt, ie, ft, jt;
809
+ }, A = (d.language || d.systemLanguage || d.userLanguage || "en").substr(0, 2).toLowerCase(), l[A] === t && (A = "en"), T = O(), M = _(), G = b(), N = k(), m.exports && (e = m.exports = n), e.tempus = n;
810
+ }).call(ke);
811
+ })(Vt, Vt.exports);
812
+ var Be = Vt.exports;
813
+ const bt = /* @__PURE__ */ we(Be);
814
+ var St, ce, It, Dt, kt, wt, At, Mt, Bt, le, Ct, he, Z, at, tt, ft, et, dt, Ht, ue, Ut, fe, ct, Lt, gt, $t, pt, te;
815
815
  const J = class J {
816
816
  constructor(e) {
817
817
  /**
@@ -820,25 +820,25 @@ const J = class J {
820
820
  * формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
821
821
  * @returns {boolean}
822
822
  */
823
- R(this, Et);
823
+ E(this, St);
824
824
  /**
825
825
  * Одно обновление колбэка прогресса, если снимок изменился.
826
826
  * @returns {void}
827
827
  */
828
- R(this, ot);
828
+ E(this, At);
829
829
  /**
830
830
  * Проверяет, изменились ли метрики прогресса относительно предыдущей отправки.
831
831
  *
832
832
  * @param {{percent: number, allCount: number, allTotal: number}} snapshot - Текущий снимок прогресса.
833
833
  * @returns {boolean} `true`, если нужно отправить callback прогресса.
834
834
  */
835
- R(this, It);
835
+ E(this, Bt);
836
836
  /**
837
837
  * Уведомляет подписчиков о текущем состоянии лимита.
838
838
  *
839
839
  * @returns {void}
840
840
  */
841
- R(this, St);
841
+ E(this, Ct);
842
842
  /**
843
843
  * Включает состояние лимита, выдерживает паузу и затем выключает лимит.
844
844
  * Используется как единый "cooldown" перед повторной отправкой chunk.
@@ -846,7 +846,7 @@ const J = class J {
846
846
  * @param {number} [pauseMs=this.defaultPauseMs] - Длительность паузы; для batch по умолчанию 120 с, для `call()` — `callLimitPauseMs` (30 с).
847
847
  * @returns {Promise<void>}
848
848
  */
849
- R(this, Z);
849
+ E(this, Z);
850
850
  /**
851
851
  * Проверяет operating-time в результате batch и ставит паузу,
852
852
  * если сервер приблизился к лимиту выполнения.
@@ -854,7 +854,7 @@ const J = class J {
854
854
  * @param {Object} result - Результат текущего batch-запроса.
855
855
  * @returns {Promise<number>} Максимальный operating-time среди команд.
856
856
  */
857
- R(this, tt);
857
+ E(this, tt);
858
858
  /**
859
859
  * Выполняет один chunk с автоматическим повтором после лимит-паузы.
860
860
  * Повтор запускается при ошибках QUERY_LIMIT_EXCEEDED, OPERATION_TIME_LIMIT или TIMEOUT.
@@ -863,7 +863,7 @@ const J = class J {
863
863
  * @param {(result: Object) => Promise<void>} processResult - Обработчик успешного результата chunk.
864
864
  * @returns {Promise<void>}
865
865
  */
866
- R(this, et);
866
+ E(this, et);
867
867
  /**
868
868
  * Выполняет BX24.callMethod с таймаутом ожидания ответа.
869
869
  *
@@ -871,14 +871,23 @@ const J = class J {
871
871
  * @param {Object} params - Параметры REST-метода.
872
872
  * @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
873
873
  */
874
- R(this, Dt);
874
+ E(this, Ht);
875
+ /**
876
+ * Код и текст ошибки подкоманды batch.
877
+ * `errorsList` по-прежнему отдаёт коды; описания — в `errorsListMessages`.
878
+ * @param {{ error?: () => { ex?: { error?: string, error_description?: string }, toString?: () => string } | null }} value
879
+ * @returns {{ code: string, message: string }}
880
+ */
881
+ E(this, Ut);
882
+ E(this, ct);
883
+ E(this, gt);
875
884
  /**
876
885
  * Resets mutable runtime state before each public batch run.
877
886
  * @param {Function} progressCall - Progress callback for current run.
878
887
  * @returns {void}
879
888
  */
880
- R(this, ft);
881
- typeof e == "function" ? (this.callBatch = e, this.callMethod = null) : (this.callBatch = (e == null ? void 0 : e.callBatch) || null, this.callMethod = (e == null ? void 0 : e.callMethod) || null), this.result = {}, this.errors = {}, this.timeLimit = {
889
+ E(this, pt);
890
+ typeof e == "function" ? (this.callBatch = e, this.callMethod = null) : (this.callBatch = (e == null ? void 0 : e.callBatch) || null, this.callMethod = (e == null ? void 0 : e.callMethod) || null), this.result = {}, this.errors = {}, this.errorMessages = {}, this.timeLimit = {
882
891
  limit: !1,
883
892
  date: void 0,
884
893
  pauseMs: void 0
@@ -892,31 +901,31 @@ const J = class J {
892
901
  if (!this.progressData)
893
902
  return { percent: 0, allCount: 0, allTotal: 0 };
894
903
  const e = this.totalBatchCommands || 0;
895
- if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && _(this, Et, ee).call(this)) {
896
- let h = 0;
897
- for (const u of this.batchCommandKeyOrder) {
898
- const O = this.progressData[u];
904
+ if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && y(this, St, ce).call(this)) {
905
+ let f = 0;
906
+ for (const l of this.batchCommandKeyOrder) {
907
+ const O = this.progressData[l];
899
908
  if (!O)
900
909
  continue;
901
- const T = Number(O.total) || 0, E = Number(O.count) || 0;
902
- T === 0 && E === 0 ? h += 1 : T > 0 && (h += Math.min(1, E / T));
910
+ const _ = Number(O.total) || 0, b = Number(O.count) || 0;
911
+ _ === 0 && b === 0 ? f += 1 : _ > 0 && (f += Math.min(1, b / _));
903
912
  }
904
- const n = h / e * 100;
905
- let f = Math.max(0, Math.min(100, Math.floor(n)));
906
- const m = e, A = Math.min(e, Math.floor(h));
907
- return { percent: f, allCount: A, allTotal: m };
913
+ const n = f / e * 100;
914
+ let u = Math.max(0, Math.min(100, Math.floor(n)));
915
+ const d = e, A = Math.min(e, Math.floor(f));
916
+ return { percent: u, allCount: A, allTotal: d };
908
917
  }
909
918
  let t = 0, r = 0;
910
- for (const h of Object.values(this.progressData)) {
911
- const { total: n, count: f } = h;
912
- t += n ?? 0, r += f ?? 0;
919
+ for (const f of Object.values(this.progressData)) {
920
+ const { total: n, count: u } = f;
921
+ t += n ?? 0, r += u ?? 0;
913
922
  }
914
923
  const i = Number(this.chunkRate) || 0;
915
924
  let a = 0;
916
925
  t ? a = r / t * 100 * i + this.totalProgress : r === 0 && t === 0 ? a = i < 1 ? this.totalProgress : 100 * i + this.totalProgress : a = 100, a = Math.max(0, Math.min(a, 100));
917
926
  let c = Math.floor(a);
918
- const l = Number(this.chunkRate) || 0;
919
- return t > 0 && r >= t && l >= 1 && (c = 100), { percent: c, allCount: r, allTotal: t };
927
+ const h = Number(this.chunkRate) || 0;
928
+ return t > 0 && r >= t && h >= 1 && (c = 100), { percent: c, allCount: r, allTotal: t };
920
929
  }
921
930
  /**
922
931
  * Обновление данных прогресса выполнения
@@ -926,36 +935,36 @@ const J = class J {
926
935
  * @param {string} params.type - Тип обработки ('count' или undefined)
927
936
  */
928
937
  setProgressData({ key: e, value: t, type: r }) {
929
- var u, O;
938
+ var l, O;
930
939
  if (!this.progressCall)
931
940
  return;
932
941
  const i = this.getData(t.data()), a = Array.isArray(i) ? i.length : 0;
933
942
  let c = a;
934
943
  if (typeof t.total == "function") {
935
- const T = t.total();
936
- if (T != null && T !== "") {
937
- const E = Number(T);
938
- Number.isFinite(E) && (c = E);
944
+ const _ = t.total();
945
+ if (_ != null && _ !== "") {
946
+ const b = Number(_);
947
+ Number.isFinite(b) && (c = b);
939
948
  }
940
949
  }
941
- let l = 1;
942
- r === "count" ? (c || (c = a), l = c > 0 ? c : a > 0 ? a : 1) : i && (l = a), this.progressData || (this.progressData = {});
943
- const h = ((u = this.progressData[e]) == null ? void 0 : u.total) ?? 0, n = ((O = this.progressData[e]) == null ? void 0 : O.count) ?? 0, f = l + n, m = Math.max(h, c ?? 0, f);
950
+ let h = 1;
951
+ r === "count" ? (c || (c = a), h = c > 0 ? c : a > 0 ? a : 1) : i && (h = a), this.progressData || (this.progressData = {});
952
+ const f = ((l = this.progressData[e]) == null ? void 0 : l.total) ?? 0, n = ((O = this.progressData[e]) == null ? void 0 : O.count) ?? 0, u = h + n, d = Math.max(f, c ?? 0, u);
944
953
  if (this.progressData[e] = {
945
- total: m,
946
- count: Math.min(f, m)
954
+ total: d,
955
+ count: Math.min(u, d)
947
956
  }, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
948
- _(this, ot, _t).call(this);
957
+ y(this, At, Mt).call(this);
949
958
  return;
950
959
  }
951
- _(this, ot, _t).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
960
+ y(this, At, Mt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
952
961
  if (!this.progressCall) {
953
962
  this.clearProgressData();
954
963
  return;
955
964
  }
956
- _(this, ot, _t).call(this);
957
- const { percent: T } = this.progressPercent;
958
- T >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
965
+ y(this, At, Mt).call(this);
966
+ const { percent: _ } = this.progressPercent;
967
+ _ >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
959
968
  }, this.progressDelay));
960
969
  }
961
970
  /**
@@ -978,7 +987,7 @@ const J = class J {
978
987
  * @returns {void}
979
988
  */
980
989
  setTimeLimitState(e, t, r) {
981
- this.timeLimit.limit = !!e, this.timeLimit.date = e ? t : void 0, e && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0, _(this, St, re).call(this);
990
+ this.timeLimit.limit = !!e, this.timeLimit.date = e ? t : void 0, e && typeof r == "number" && r > 0 ? this.timeLimit.pauseMs = r : this.timeLimit.pauseMs = void 0, y(this, Ct, he).call(this);
982
991
  }
983
992
  /**
984
993
  * Подписывает внешний код на изменения состояния лимита.
@@ -1011,20 +1020,20 @@ const J = class J {
1011
1020
  const a = i.filter || i.FILTER;
1012
1021
  if (!a || typeof a != "object" || Array.isArray(a))
1013
1022
  return [{ key: e, request: t }];
1014
- for (const [c, l] of Object.entries(a))
1015
- if (!String(c).trim().startsWith("!") && Array.isArray(l) && l.length > this.filterChunkSize) {
1016
- const h = [];
1017
- for (let n = 0; n < l.length; n += this.filterChunkSize) {
1018
- const f = l.slice(n, n + this.filterChunkSize), m = n === 0 ? e : `${e}__chunk_${Math.floor(n / this.filterChunkSize)}`, A = { ...i };
1019
- i.filter ? (A.filter = { ...a }, A.filter[c] = f) : i.FILTER && (A.FILTER = { ...a }, A.FILTER[c] = f), h.push({
1020
- key: m,
1023
+ for (const [c, h] of Object.entries(a))
1024
+ if (!String(c).trim().startsWith("!") && Array.isArray(h) && h.length > this.filterChunkSize) {
1025
+ const f = [];
1026
+ for (let n = 0; n < h.length; n += this.filterChunkSize) {
1027
+ const u = h.slice(n, n + this.filterChunkSize), d = n === 0 ? e : `${e}__chunk_${Math.floor(n / this.filterChunkSize)}`, A = { ...i };
1028
+ i.filter ? (A.filter = { ...a }, A.filter[c] = u) : i.FILTER && (A.FILTER = { ...a }, A.FILTER[c] = u), f.push({
1029
+ key: d,
1021
1030
  request: { method: r, params: A },
1022
1031
  originalKey: e,
1023
1032
  filterKey: c,
1024
1033
  chunkIndex: Math.floor(n / this.filterChunkSize)
1025
1034
  });
1026
1035
  }
1027
- return h;
1036
+ return f;
1028
1037
  }
1029
1038
  return [{ key: e, request: t }];
1030
1039
  }
@@ -1035,13 +1044,13 @@ const J = class J {
1035
1044
  * @returns {Array} Объединенный массив результатов
1036
1045
  */
1037
1046
  mergeSplitResults(e, t) {
1038
- const r = [], i = String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), c = Object.keys(e).filter((l) => a.test(l)).sort((l, h) => {
1039
- const n = l.match(/__chunk_(\d+)$/), f = h.match(/__chunk_(\d+)$/);
1040
- return n ? f ? parseInt(n[1]) - parseInt(f[1]) : 1 : -1;
1047
+ const r = [], i = String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), c = Object.keys(e).filter((h) => a.test(h)).sort((h, f) => {
1048
+ const n = h.match(/__chunk_(\d+)$/), u = f.match(/__chunk_(\d+)$/);
1049
+ return n ? u ? parseInt(n[1]) - parseInt(u[1]) : 1 : -1;
1041
1050
  });
1042
- for (const l of c) {
1043
- const h = e[l];
1044
- Array.isArray(h) ? r.push(...h) : h && r.push(h);
1051
+ for (const h of c) {
1052
+ const f = e[h];
1053
+ Array.isArray(f) ? r.push(...f) : f && r.push(f);
1045
1054
  }
1046
1055
  return r;
1047
1056
  }
@@ -1063,23 +1072,23 @@ const J = class J {
1063
1072
  callBatchWithTimeout(e, t) {
1064
1073
  return new Promise((r, i) => {
1065
1074
  let a = !1, c = null;
1066
- const l = async (n) => {
1075
+ const h = async (n) => {
1067
1076
  if (!a) {
1068
1077
  a = !0, c && clearTimeout(c);
1069
1078
  try {
1070
1079
  await Promise.resolve(t(n)), r();
1071
- } catch (f) {
1072
- console.error("Error in callBatch callback:", f), i(f);
1080
+ } catch (u) {
1081
+ console.error("Error in callBatch callback:", u), i(u);
1073
1082
  }
1074
1083
  }
1075
- }, h = async () => {
1084
+ }, f = async () => {
1076
1085
  if (!a) {
1077
1086
  a = !0, c && clearTimeout(c), console.warn(
1078
1087
  `Batch request timeout after ${this.requestTimeoutMs}ms. This may indicate a CORS or network error.`
1079
1088
  );
1080
1089
  const n = {};
1081
- Object.keys(e).forEach((f) => {
1082
- n[f] = {
1090
+ Object.keys(e).forEach((u) => {
1091
+ n[u] = {
1083
1092
  error: () => ({
1084
1093
  ex: {
1085
1094
  error: "TIMEOUT",
@@ -1092,14 +1101,14 @@ const J = class J {
1092
1101
  });
1093
1102
  try {
1094
1103
  await Promise.resolve(t(n)), r();
1095
- } catch (f) {
1096
- console.error("Error in timeout callback:", f), r();
1104
+ } catch (u) {
1105
+ console.error("Error in timeout callback:", u), r();
1097
1106
  }
1098
1107
  }
1099
1108
  };
1100
1109
  try {
1101
1110
  this.callBatch(e, async (n) => {
1102
- await l(n);
1111
+ await h(n);
1103
1112
  });
1104
1113
  } catch (n) {
1105
1114
  a || console.error("Error calling callBatch:", n);
@@ -1107,7 +1116,7 @@ const J = class J {
1107
1116
  c = setTimeout(async () => {
1108
1117
  a || (console.warn(
1109
1118
  `Batch request attempt timeout after ${this.requestTimeoutMs}ms. Switching to timeout fallback result.`
1110
- ), await h());
1119
+ ), await f());
1111
1120
  }, this.requestTimeoutMs);
1112
1121
  });
1113
1122
  }
@@ -1130,58 +1139,58 @@ const J = class J {
1130
1139
  * @returns {Promise<Object>}
1131
1140
  */
1132
1141
  async batch(e, t, r = {}) {
1133
- _(this, ft, jt).call(this, t);
1142
+ y(this, pt, te).call(this, t);
1134
1143
  const i = {}, a = {}, c = {};
1135
- for (const [f, m] of Object.entries(e)) {
1136
- const A = this.arrayChunk(m);
1144
+ for (const [u, d] of Object.entries(e)) {
1145
+ const A = this.arrayChunk(d);
1137
1146
  if (!A)
1138
1147
  continue;
1139
- const u = this.splitLargeFilters(f, A);
1140
- if (u.length === 1)
1141
- a[f] = A;
1148
+ const l = this.splitLargeFilters(u, A);
1149
+ if (l.length === 1)
1150
+ a[u] = A;
1142
1151
  else {
1143
- c[f] = [];
1144
- for (const O of u)
1145
- a[O.key] = O.request, c[f].push(O.key);
1152
+ c[u] = [];
1153
+ for (const O of l)
1154
+ a[O.key] = O.request, c[u].push(O.key);
1146
1155
  }
1147
1156
  }
1148
1157
  this.batchCommandKeyOrder = Object.keys(a), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
1149
- (f) => {
1150
- var m;
1151
- return String(((m = a[f]) == null ? void 0 : m.method) || "");
1158
+ (u) => {
1159
+ var d;
1160
+ return String(((d = a[u]) == null ? void 0 : d.method) || "");
1152
1161
  }
1153
1162
  ), this.chunkRate = (1 / Math.ceil(Object.keys(a).length / this.limit)).toFixed(5);
1154
- let l = {}, h = 0;
1163
+ let h = {}, f = 0;
1155
1164
  const n = Object.keys(a).length;
1156
- for (const [f, m] of Object.entries(a)) {
1165
+ for (const [u, d] of Object.entries(a)) {
1157
1166
  if (!this.canContinue)
1158
1167
  break;
1159
- if (l[f] = m, Object.keys(l).length >= this.limit || h + 1 === n) {
1160
- const A = h + 1 === n;
1168
+ if (h[u] = d, Object.keys(h).length >= this.limit || f + 1 === n) {
1169
+ const A = f + 1 === n;
1161
1170
  await this.batchChunk(
1162
- l,
1171
+ h,
1163
1172
  void 0,
1164
1173
  !A,
1165
1174
  {
1166
1175
  disablePagination: !1,
1167
1176
  oneBatch: !!(r != null && r.oneBatch)
1168
1177
  }
1169
- ), Object.entries(this.result).forEach(([u, O]) => {
1170
- i[u] = O;
1178
+ ), Object.entries(this.result).forEach(([l, O]) => {
1179
+ i[l] = O;
1171
1180
  }), this.totalProgress = Math.round(
1172
- h / n * 100
1173
- ), l = {};
1181
+ f / n * 100
1182
+ ), h = {};
1174
1183
  }
1175
- h++;
1184
+ f++;
1176
1185
  }
1177
- for (const [f, m] of Object.entries(c))
1178
- if (m && m.length > 0) {
1179
- const A = this.mergeSplitResults(i, f);
1180
- for (const u of m)
1181
- delete i[u];
1182
- i[f] = A;
1186
+ for (const [u, d] of Object.entries(c))
1187
+ if (d && d.length > 0) {
1188
+ const A = this.mergeSplitResults(i, u);
1189
+ for (const l of d)
1190
+ delete i[l];
1191
+ i[u] = A;
1183
1192
  }
1184
- return Object.entries(this.errors).length && (i.errorsList = this.errors), t && t({ percent: 100 }), Promise.resolve(i);
1193
+ return y(this, gt, $t).call(this, i), t && t({ percent: 100 }), Promise.resolve(i);
1185
1194
  }
1186
1195
  /**
1187
1196
  * Выполняет батч-запрос и возвращает только количество элементов для каждой команды.
@@ -1193,61 +1202,59 @@ const J = class J {
1193
1202
  * @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
1194
1203
  */
1195
1204
  async batchTotalCount(e, t) {
1196
- _(this, ft, jt).call(this, t);
1205
+ y(this, pt, te).call(this, t);
1197
1206
  const r = {}, i = {}, a = {};
1198
- for (const [h, n] of Object.entries(e)) {
1199
- const f = this.arrayChunk(n);
1200
- if (!f)
1207
+ for (const [f, n] of Object.entries(e)) {
1208
+ const u = this.arrayChunk(n);
1209
+ if (!u)
1201
1210
  continue;
1202
- const m = this.splitLargeFilters(h, f);
1203
- if (m.length === 1)
1204
- i[h] = f;
1211
+ const d = this.splitLargeFilters(f, u);
1212
+ if (d.length === 1)
1213
+ i[f] = u;
1205
1214
  else {
1206
- a[h] = [];
1207
- for (const A of m)
1208
- i[A.key] = A.request, a[h].push(A.key);
1215
+ a[f] = [];
1216
+ for (const A of d)
1217
+ i[A.key] = A.request, a[f].push(A.key);
1209
1218
  }
1210
1219
  }
1211
- const c = [], l = Object.entries(i);
1212
- for (let h = 0; h < l.length; h += this.limit) {
1213
- const n = l.slice(h, h + this.limit), f = {};
1214
- for (const [m, A] of n) {
1220
+ const c = [], h = Object.entries(i);
1221
+ for (let f = 0; f < h.length; f += this.limit) {
1222
+ const n = h.slice(f, f + this.limit), u = {};
1223
+ for (const [d, A] of n) {
1215
1224
  if (!this.canContinue)
1216
1225
  break;
1217
- f[m] = A;
1226
+ u[d] = A;
1218
1227
  }
1219
- Object.keys(f).length > 0 && c.push(f);
1228
+ Object.keys(u).length > 0 && c.push(u);
1220
1229
  }
1221
1230
  this.chunkRate = (1 / c.length).toFixed(5);
1222
- for (const [h, n] of Object.entries(c)) {
1231
+ for (const [f, n] of Object.entries(c)) {
1223
1232
  if (!this.canContinue)
1224
1233
  break;
1225
- this.totalProgress = Math.round(Number(h) / c.length * 100), this.progressData = {}, this.lastProgressSnapshot = null;
1226
- const f = Number(h) === c.length - 1;
1227
- await _(this, et, ut).call(this, n, async (m) => {
1228
- var A, u, O, T, E;
1229
- for (const [M, p] of Object.entries(m)) {
1234
+ this.totalProgress = Math.round(Number(f) / c.length * 100), this.progressData = {}, this.lastProgressSnapshot = null;
1235
+ const u = Number(f) === c.length - 1;
1236
+ await y(this, et, dt).call(this, n, async (d) => {
1237
+ for (const [A, l] of Object.entries(d)) {
1230
1238
  if (!this.canContinue)
1231
1239
  return;
1232
- if (p.error()) {
1233
- const L = (u = (A = p.error()) == null ? void 0 : A.ex) == null ? void 0 : u.error, w = (T = (O = p.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
1234
- this.errors[M] = L && L.trim() || w && w.trim() || ((E = p.error()) == null ? void 0 : E.toString()) || "Неизвестная ошибка", r[M] = 0;
1240
+ if (l.error()) {
1241
+ y(this, ct, Lt).call(this, A, l), r[A] = 0;
1235
1242
  continue;
1236
1243
  }
1237
- const b = this.getData(p.data()), H = Array.isArray(b) ? b.length : 0, I = typeof p.total == "function" && p.total() !== void 0 ? p.total() : H;
1238
- r[M] = I, this.setProgressData({ key: M, value: p, type: "count" });
1244
+ const O = this.getData(l.data()), _ = Array.isArray(O) ? O.length : 0, k = typeof l.total == "function" && l.total() !== void 0 ? l.total() : _;
1245
+ r[A] = k, this.setProgressData({ key: A, value: l, type: "count" });
1239
1246
  }
1240
- await _(this, tt, ht).call(this, m, !f);
1247
+ await y(this, tt, ft).call(this, d, !u);
1241
1248
  });
1242
1249
  }
1243
- for (const [h, n] of Object.entries(a))
1250
+ for (const [f, n] of Object.entries(a))
1244
1251
  if (n && n.length > 0) {
1245
- let f = 0;
1246
- for (const m of n)
1247
- r[m] !== void 0 && (f += r[m] || 0), delete r[m];
1248
- r[h] = f;
1252
+ let u = 0;
1253
+ for (const d of n)
1254
+ r[d] !== void 0 && (u += r[d] || 0), delete r[d];
1255
+ r[f] = u;
1249
1256
  }
1250
- return Object.entries(this.errors).length && (r.errorsList = this.errors, this.errorLogger()), t && t({ percent: 100 }), Promise.resolve(r);
1257
+ return Object.entries(this.errors).length && (y(this, gt, $t).call(this, r), this.errorLogger()), t && t({ percent: 100 }), Promise.resolve(r);
1251
1258
  }
1252
1259
  /**
1253
1260
  * Выполняет одиночный REST-вызов с таймаутом и авто-повтором после лимит-паузы.
@@ -1257,36 +1264,36 @@ const J = class J {
1257
1264
  * @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
1258
1265
  */
1259
1266
  async call({ method: e, params: t = {} }) {
1260
- var r, i, a, c, l, h, n;
1267
+ var r, i, a, c, h, f, n;
1261
1268
  for (; ; ) {
1262
- const f = await _(this, Dt, ie).call(this, e, t);
1263
- if (!f) {
1264
- await _(this, Z, nt).call(this, this.callLimitPauseMs);
1269
+ const u = await y(this, Ht, ue).call(this, e, t);
1270
+ if (!u) {
1271
+ await y(this, Z, at).call(this, this.callLimitPauseMs);
1265
1272
  continue;
1266
1273
  }
1267
- const m = {};
1268
- if (f != null && f.answer)
1269
- for (const [u, O] of Object.entries(f.answer))
1270
- u !== "result" && O && (m[u] = O);
1271
- if (f.error()) {
1272
- const u = ((i = (r = f.error()) == null ? void 0 : r.ex) == null ? void 0 : i.error) ?? "";
1273
- if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(u)) {
1274
- await _(this, Z, nt).call(this, this.callLimitPauseMs);
1274
+ const d = {};
1275
+ if (u != null && u.answer)
1276
+ for (const [l, O] of Object.entries(u.answer))
1277
+ l !== "result" && O && (d[l] = O);
1278
+ if (u.error()) {
1279
+ const l = ((i = (r = u.error()) == null ? void 0 : r.ex) == null ? void 0 : i.error) ?? "";
1280
+ if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(l)) {
1281
+ await y(this, Z, at).call(this, this.callLimitPauseMs);
1275
1282
  continue;
1276
1283
  }
1277
- const O = ((a = f.error()) == null ? void 0 : a.toString()) || ((l = (c = f.error()) == null ? void 0 : c.ex) == null ? void 0 : l.error_description) || ((n = (h = f.error()) == null ? void 0 : h.ex) == null ? void 0 : n.error) || "Неизвестная ошибка";
1284
+ const O = ((a = u.error()) == null ? void 0 : a.toString()) || ((h = (c = u.error()) == null ? void 0 : c.ex) == null ? void 0 : h.error_description) || ((n = (f = u.error()) == null ? void 0 : f.ex) == null ? void 0 : n.error) || "Неизвестная ошибка";
1278
1285
  return {
1279
1286
  success: !1,
1280
1287
  data: !1,
1281
- answer: m,
1288
+ answer: d,
1282
1289
  error: O
1283
1290
  };
1284
1291
  }
1285
- let A = f.data();
1292
+ let A = u.data();
1286
1293
  return A != null && A.items && (A = A.items), {
1287
1294
  success: !0,
1288
1295
  data: A,
1289
- answer: m,
1296
+ answer: d,
1290
1297
  error: null
1291
1298
  };
1292
1299
  }
@@ -1317,8 +1324,8 @@ const J = class J {
1317
1324
  r = [{ ID: "ASC" }, [""], [""], ["ID"]];
1318
1325
  else {
1319
1326
  Array.isArray(r[0]) && (r[0] = {});
1320
- const [i, a, c, l] = r;
1321
- i.ID = "ASC", l[0] !== "" && l.includes("ID") || l.push("ID");
1327
+ const [i, a, c, h] = r;
1328
+ i.ID = "ASC", h[0] !== "" && h.includes("ID") || h.push("ID");
1322
1329
  }
1323
1330
  return { method: t, params: r };
1324
1331
  }
@@ -1331,41 +1338,37 @@ const J = class J {
1331
1338
  async batchChunk(e, t, r = !0, i = {}) {
1332
1339
  return new Promise((a) => {
1333
1340
  const c = [];
1334
- let l;
1335
- const h = !!(i != null && i.disablePagination);
1341
+ let h;
1342
+ const f = !!(i != null && i.disablePagination);
1336
1343
  (async () => {
1337
- await _(this, et, ut).call(this, e, async (f) => {
1338
- var A, u, O, T, E;
1339
- for (const [M, p] of Object.entries(f)) {
1344
+ await y(this, et, dt).call(this, e, async (u) => {
1345
+ for (const [A, l] of Object.entries(u)) {
1340
1346
  if (!this.canContinue)
1341
1347
  return;
1342
- if (p.error()) {
1343
- const g = (u = (A = p.error()) == null ? void 0 : A.ex) == null ? void 0 : u.error, C = (T = (O = p.error()) == null ? void 0 : O.ex) == null ? void 0 : T.error_description;
1344
- this.errors[M] = g && g.trim() || C && C.trim() || ((E = p.error()) == null ? void 0 : E.toString()) || "Неизвестная ошибка", l = !0;
1345
- }
1346
- const b = this.getData(p.data()), H = Array.isArray(b) ? b.length : 0, N = typeof p.total == "function" && p.total() !== void 0, I = N ? p.total() : H;
1347
- t === "count" ? this.result[M] ? this.result[M] += H : this.result[M] = I : this.result[M] = b, this.setProgressData({ key: M, value: p, type: t });
1348
- const L = e[M], w = Array.isArray(L) ? L[0] : L == null ? void 0 : L.method, k = typeof w == "string" && (w.includes(".list") || w === "user.get" || w === "entity.item.get"), s = t === "count" ? !N && H === this.limit : k ? H === this.limit : I > this.limit && I > H, o = t !== "count" && w === "entity.item.get" && H === this.limit && !s, d = s || o;
1349
- if (!h && (!this.canContinue || d)) {
1350
- let g = e[M];
1351
- if (Array.isArray(g)) {
1352
- const [C, D = {}] = g;
1353
- g = [C, D];
1348
+ l.error() && (y(this, ct, Lt).call(this, A, l), h = !0);
1349
+ const O = this.getData(l.data()), _ = Array.isArray(O) ? O.length : 0, b = typeof l.total == "function" && l.total() !== void 0, k = b ? l.total() : _;
1350
+ t === "count" ? this.result[A] ? this.result[A] += _ : this.result[A] = k : this.result[A] = O, this.setProgressData({ key: A, value: l, type: t });
1351
+ const T = e[A], M = Array.isArray(T) ? T[0] : T == null ? void 0 : T.method, G = typeof M == "string" && (M.includes(".list") || M === "user.get" || M === "entity.item.get"), N = t === "count" ? !b && _ === this.limit : G ? _ === this.limit : k > this.limit && k > _, S = t !== "count" && M === "entity.item.get" && _ === this.limit && !N, I = N || S;
1352
+ if (!f && (!this.canContinue || I)) {
1353
+ let C = e[A];
1354
+ if (Array.isArray(C)) {
1355
+ const [R, s = {}] = C;
1356
+ C = [R, s];
1354
1357
  } else {
1355
- const { method: C, params: D = {} } = g;
1356
- g = [C, D];
1358
+ const { method: R, params: s = {} } = C;
1359
+ C = [R, s];
1357
1360
  }
1358
1361
  c.push([
1359
- M,
1360
- g,
1361
- I,
1362
- { entityItemGetScan: o }
1362
+ A,
1363
+ C,
1364
+ k,
1365
+ { entityItemGetScan: S }
1363
1366
  ]);
1364
1367
  }
1365
1368
  }
1366
- l > 0 && this.errorLogger();
1367
- const m = c.length > 0 || r;
1368
- await _(this, tt, ht).call(this, f, m), c.length ? await this.batchPayload(c, t, i).then(
1369
+ h > 0 && this.errorLogger();
1370
+ const d = c.length > 0 || r;
1371
+ await y(this, tt, ft).call(this, u, d), c.length ? await this.batchPayload(c, t, i).then(
1369
1372
  () => a(this.result)
1370
1373
  ) : a(this.result);
1371
1374
  });
@@ -1378,99 +1381,94 @@ const J = class J {
1378
1381
  * @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
1379
1382
  */
1380
1383
  async batchPayload(e, t, r = {}) {
1381
- const i = !!(r != null && r.oneBatch), a = (O, T, E, M) => {
1382
- let p = "ID";
1383
- this.result[O][this.result[O].length - 1].ID || (p = "id");
1384
- let b = `${p}`;
1385
- if (JSON.stringify(M[1]).toLocaleLowerCase().includes('"id":"desc"') ? b = "<" + b : b = ">" + b, T === 1 || E.length === 0)
1384
+ const i = !!(r != null && r.oneBatch), a = (O, _, b, k) => {
1385
+ let T = "ID";
1386
+ this.result[O][this.result[O].length - 1].ID || (T = "id");
1387
+ let M = `${T}`;
1388
+ if (JSON.stringify(k[1]).toLocaleLowerCase().includes('"id":"desc"') ? M = "<" + M : M = ">" + M, _ === 1 || b.length === 0)
1386
1389
  return {
1387
- field: b,
1388
- id: this.result[O][this.result[O].length - 1][p]
1390
+ field: M,
1391
+ id: this.result[O][this.result[O].length - 1][T]
1389
1392
  };
1390
1393
  let N = "";
1391
- const [I, L] = M;
1392
- return (I === "tasks.task.list" || I === "task.item.list") && (N = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(I) && (N = "[items]"), I === "crm.type.list" && (N = "[types]"), I === "socialnetwork.api.workgroup.list" && (N = "[workgroups]"), {
1393
- field: b,
1394
- id: `$result[${[O, T - 1].join("__")}]${N}[49][${p}]`
1394
+ const [S, I] = k;
1395
+ return (S === "tasks.task.list" || S === "task.item.list") && (N = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(S) && (N = "[items]"), S === "crm.type.list" && (N = "[types]"), S === "socialnetwork.api.workgroup.list" && (N = "[workgroups]"), {
1396
+ field: M,
1397
+ id: `$result[${[O, _ - 1].join("__")}]${N}[49][${T}]`
1395
1398
  };
1396
- }, c = (O, T) => {
1397
- const [E, M] = O;
1398
- let p = JSON.parse(JSON.stringify(M)), b;
1399
- if (E === "task.item.list") {
1400
- p = [...p];
1401
- const [H, N, I, L] = p;
1402
- return N[T.field] = T.id, [E, p];
1399
+ }, c = (O, _) => {
1400
+ const [b, k] = O;
1401
+ let T = JSON.parse(JSON.stringify(k)), M;
1402
+ if (b === "task.item.list") {
1403
+ T = [...T];
1404
+ const [G, N, S, I] = T;
1405
+ return N[_.field] = _.id, [b, T];
1403
1406
  }
1404
- return ["user.get"].includes(E) || p.FILTER ? (p.FILTER || (p.FILTER = {}), b = p.FILTER) : (p.filter || (p.filter = {}), b = p.filter), [
1407
+ return ["user.get"].includes(b) || T.FILTER ? (T.FILTER || (T.FILTER = {}), M = T.FILTER) : (T.filter || (T.filter = {}), M = T.filter), [
1405
1408
  "socialnetwork.api.workgroup.list",
1406
1409
  "tasks.task.list"
1407
- ].includes(E) ? b[">ID"] = T.id : b[T.field] = T.id, [E, { ...p, start: -1 }];
1408
- }, l = (O) => {
1409
- Object.entries(O).forEach(([T, E]) => {
1410
- var b, H, N, I, L;
1411
- const [M] = T.split("__"), p = this.getData(E.data());
1412
- if (Array.isArray(p) && (t === "count" ? this.result[M] += p.length : this.result[M].push(...p)), E.error()) {
1413
- const w = (H = (b = E.error()) == null ? void 0 : b.ex) == null ? void 0 : H.error, k = (I = (N = E.error()) == null ? void 0 : N.ex) == null ? void 0 : I.error_description;
1414
- this.errors[M] = w && w.trim() || k && k.trim() || ((L = E.error()) == null ? void 0 : L.toString()) || "Неизвестная ошибка";
1415
- }
1416
- this.setProgressData({ key: M, value: E, type: t });
1410
+ ].includes(b) ? M[">ID"] = _.id : M[_.field] = _.id, [b, { ...T, start: -1 }];
1411
+ }, h = (O) => {
1412
+ Object.entries(O).forEach(([_, b]) => {
1413
+ const [k] = _.split("__"), T = this.getData(b.data());
1414
+ Array.isArray(T) && (t === "count" ? this.result[k] += T.length : this.result[k].push(...T)), b.error() && y(this, ct, Lt).call(this, k, b), this.setProgressData({ key: k, value: b, type: t });
1417
1415
  });
1418
- }, h = (O, T) => {
1416
+ }, f = (O, _) => {
1419
1417
  if (!Array.isArray(O) || O.length === 0)
1420
1418
  return null;
1421
- const E = O[O.length - 1];
1422
- let M = "ID";
1423
- E.ID || (M = "id");
1424
- let p = M;
1425
- return JSON.stringify(T[1]).toLocaleLowerCase().includes('"id":"desc"') ? p = "<" + p : p = ">" + p, { field: p, id: E[M] };
1426
- }, n = 1e4, f = async (O, T) => {
1427
- var M, p;
1428
- let E = this.limit;
1429
- for (let b = 1; this.canContinue && E === this.limit && b <= n; b++) {
1430
- const H = this.result[O], N = h(H, T);
1419
+ const b = O[O.length - 1];
1420
+ let k = "ID";
1421
+ b.ID || (k = "id");
1422
+ let T = k;
1423
+ return JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? T = "<" + T : T = ">" + T, { field: T, id: b[k] };
1424
+ }, n = 1e4, u = async (O, _) => {
1425
+ var k, T;
1426
+ let b = this.limit;
1427
+ for (let M = 1; this.canContinue && b === this.limit && M <= n; M++) {
1428
+ const G = this.result[O], N = f(G, _);
1431
1429
  if (!N)
1432
1430
  break;
1433
- const I = `${O}__eiscan_${b}`, L = c(T, N);
1434
- let w = null;
1435
- await _(this, et, ut).call(this, { [I]: L }, async (d) => {
1436
- w = d, l(d);
1431
+ const S = `${O}__eiscan_${M}`, I = c(_, N);
1432
+ let C = null;
1433
+ await y(this, et, dt).call(this, { [S]: I }, async (g) => {
1434
+ C = g, h(g);
1437
1435
  });
1438
- const k = b < n;
1439
- await _(this, tt, ht).call(this, w, k), await this.delay();
1440
- const s = w == null ? void 0 : w[I];
1441
- if ((M = s == null ? void 0 : s.error) != null && M.call(s)) {
1442
- E = 0;
1436
+ const R = M < n;
1437
+ await y(this, tt, ft).call(this, C, R), await this.delay();
1438
+ const s = C == null ? void 0 : C[S];
1439
+ if ((k = s == null ? void 0 : s.error) != null && k.call(s)) {
1440
+ b = 0;
1443
1441
  break;
1444
1442
  }
1445
- const o = this.getData((p = s == null ? void 0 : s.data) == null ? void 0 : p.call(s));
1446
- E = Array.isArray(o) ? o.length : 0;
1443
+ const o = this.getData((T = s == null ? void 0 : s.data) == null ? void 0 : T.call(s));
1444
+ b = Array.isArray(o) ? o.length : 0;
1447
1445
  }
1448
1446
  };
1449
- let m = [], A = 0;
1450
- const u = async (O = !0) => m.length ? (await _(this, et, ut).call(this, Object.fromEntries(m), async (T) => {
1451
- l(T), await _(this, tt, ht).call(this, T, O);
1452
- }), A++, m = [], i && A >= 1 ? !0 : (await this.delay(), !1)) : !1;
1447
+ let d = [], A = 0;
1448
+ const l = async (O = !0) => d.length ? (await y(this, et, dt).call(this, Object.fromEntries(d), async (_) => {
1449
+ h(_), await y(this, tt, ft).call(this, _, O);
1450
+ }), A++, d = [], i && A >= 1 ? !0 : (await this.delay(), !1)) : !1;
1453
1451
  for await (const O of e) {
1454
1452
  if (!this.canContinue)
1455
1453
  return;
1456
- const [T, E, M, p = {}] = O;
1457
- if (p.entityItemGetScan) {
1458
- if (await u(!0))
1454
+ const [_, b, k, T = {}] = O;
1455
+ if (T.entityItemGetScan) {
1456
+ if (await l(!0))
1459
1457
  return;
1460
1458
  if (i)
1461
1459
  continue;
1462
- await f(T, E);
1460
+ await u(_, b);
1463
1461
  continue;
1464
1462
  }
1465
- let b = 1;
1466
- for (; M > b * this.limit; ) {
1467
- const H = [T, b].join("__"), N = a(T, b, m, E);
1468
- if (m.push([H, c(E, N)]), i && m.length === 49 && await u(!0) || m.length % 50 === 0 && await u(!0))
1463
+ let M = 1;
1464
+ for (; k > M * this.limit; ) {
1465
+ const G = [_, M].join("__"), N = a(_, M, d, b);
1466
+ if (d.push([G, c(b, N)]), i && d.length === 49 && await l(!0) || d.length % 50 === 0 && await l(!0))
1469
1467
  return;
1470
- b++;
1468
+ M++;
1471
1469
  }
1472
1470
  }
1473
- await u(!1);
1471
+ await l(!1);
1474
1472
  }
1475
1473
  /**
1476
1474
  * Вывод ошибок в консоль в группированном виде
@@ -1481,29 +1479,29 @@ const J = class J {
1481
1479
  }), console.groupEnd();
1482
1480
  }
1483
1481
  };
1484
- Et = new WeakSet(), ee = function() {
1482
+ St = new WeakSet(), ce = function() {
1485
1483
  const e = this.totalBatchCommands || 0, t = this.batchCommandMethods;
1486
- if (e < S(J, bt) || !Array.isArray(t) || t.length !== e)
1484
+ if (e < L(J, It) || !Array.isArray(t) || t.length !== e)
1487
1485
  return !1;
1488
- if (t.filter((a) => a === "crm.deal.list").length >= S(J, Lt))
1486
+ if (t.filter((a) => a === "crm.deal.list").length >= L(J, Dt))
1489
1487
  return !0;
1490
1488
  const i = t.filter(
1491
1489
  (a) => typeof a == "string" && a.includes(".list")
1492
1490
  ).length;
1493
- return i >= S(J, Rt) && i / e >= S(J, Mt);
1494
- }, bt = new WeakMap(), Lt = new WeakMap(), Rt = new WeakMap(), Mt = new WeakMap(), ot = new WeakSet(), _t = function() {
1491
+ return i >= L(J, kt) && i / e >= L(J, wt);
1492
+ }, It = new WeakMap(), Dt = new WeakMap(), kt = new WeakMap(), wt = new WeakMap(), At = new WeakSet(), Mt = function() {
1495
1493
  if (!this.progressCall || !this.progressData)
1496
1494
  return;
1497
1495
  const { percent: e, allCount: t, allTotal: r } = this.progressPercent, i = { percent: e, allCount: t, allTotal: r };
1498
- _(this, It, se).call(this, i) && (this.progressCall({
1496
+ y(this, Bt, le).call(this, i) && (this.progressCall({
1499
1497
  data: this.progressData,
1500
1498
  percent: e,
1501
1499
  allCount: t,
1502
1500
  allTotal: r
1503
1501
  }), this.lastProgressSnapshot = i);
1504
- }, It = new WeakSet(), se = function(e) {
1502
+ }, Bt = new WeakSet(), le = function(e) {
1505
1503
  return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== e.percent || this.lastProgressSnapshot.allCount !== e.allCount || this.lastProgressSnapshot.allTotal !== e.allTotal : !0;
1506
- }, St = new WeakSet(), re = function() {
1504
+ }, Ct = new WeakSet(), he = function() {
1507
1505
  const e = {
1508
1506
  limit: this.timeLimit.limit,
1509
1507
  date: this.timeLimit.date,
@@ -1515,9 +1513,9 @@ Et = new WeakSet(), ee = function() {
1515
1513
  } catch (r) {
1516
1514
  console.warn("Batch timeLimit listener error:", r);
1517
1515
  }
1518
- }, Z = new WeakSet(), nt = async function(e = this.defaultPauseMs) {
1516
+ }, Z = new WeakSet(), at = async function(e = this.defaultPauseMs) {
1519
1517
  this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), e), await new Promise((t) => setTimeout(t, e)), this.setTimeLimitState(!1, void 0);
1520
- }, tt = new WeakSet(), ht = async function(e, t = !0) {
1518
+ }, tt = new WeakSet(), ft = async function(e, t = !0) {
1521
1519
  if (!t)
1522
1520
  return 0;
1523
1521
  let r = 0;
@@ -1532,43 +1530,43 @@ Et = new WeakSet(), ee = function() {
1532
1530
  }
1533
1531
  } catch {
1534
1532
  }
1535
- r >= this.operatingThreshold && await _(this, Z, nt).call(this);
1536
- }, et = new WeakSet(), ut = async function(e, t) {
1533
+ r >= this.operatingThreshold && await y(this, Z, at).call(this);
1534
+ }, et = new WeakSet(), dt = async function(e, t) {
1537
1535
  let r = !1, i = e;
1538
1536
  do
1539
1537
  r = !1, await this.callBatchWithTimeout(i, async (a) => {
1540
- var h, n;
1538
+ var f, n;
1541
1539
  let c = !1;
1542
- const l = /* @__PURE__ */ new Set();
1543
- for (const [f, m] of Object.entries(a || {})) {
1544
- if (!(m != null && m.error) || !m.error())
1540
+ const h = /* @__PURE__ */ new Set();
1541
+ for (const [u, d] of Object.entries(a || {})) {
1542
+ if (!(d != null && d.error) || !d.error())
1545
1543
  continue;
1546
- const A = ((n = (h = m.error()) == null ? void 0 : h.ex) == null ? void 0 : n.error) ?? "";
1544
+ const A = ((n = (f = d.error()) == null ? void 0 : f.ex) == null ? void 0 : n.error) ?? "";
1547
1545
  if (A === "TIMEOUT") {
1548
1546
  c = !0;
1549
1547
  break;
1550
1548
  }
1551
- ["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(A) && l.add(f);
1549
+ ["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(A) && h.add(u);
1552
1550
  }
1553
1551
  if (c) {
1554
- r = !0, await _(this, Z, nt).call(this);
1552
+ r = !0, await y(this, Z, at).call(this);
1555
1553
  return;
1556
1554
  }
1557
- if (l.size > 0) {
1558
- const f = {};
1559
- for (const [A, u] of Object.entries(a || {}))
1560
- l.has(A) || (f[A] = u);
1561
- Object.keys(f).length && await t(f);
1562
- const m = {};
1563
- for (const A of l)
1564
- i[A] && (m[A] = i[A]);
1565
- i = m, Object.keys(i).length && (r = !0, await _(this, Z, nt).call(this));
1555
+ if (h.size > 0) {
1556
+ const u = {};
1557
+ for (const [A, l] of Object.entries(a || {}))
1558
+ h.has(A) || (u[A] = l);
1559
+ Object.keys(u).length && await t(u);
1560
+ const d = {};
1561
+ for (const A of h)
1562
+ i[A] && (d[A] = i[A]);
1563
+ i = d, Object.keys(i).length && (r = !0, await y(this, Z, at).call(this));
1566
1564
  return;
1567
1565
  }
1568
1566
  await t(a);
1569
1567
  });
1570
1568
  while (r);
1571
- }, Dt = new WeakSet(), ie = function(e, t) {
1569
+ }, Ht = new WeakSet(), ue = function(e, t) {
1572
1570
  return new Promise((r) => {
1573
1571
  if (typeof this.callMethod != "function") {
1574
1572
  r(null);
@@ -1586,17 +1584,29 @@ Et = new WeakSet(), ee = function() {
1586
1584
  i || (i = !0, clearTimeout(a), r(null));
1587
1585
  }
1588
1586
  });
1589
- }, ft = new WeakSet(), jt = function(e) {
1590
- this.clearProgressData(), this.progressCall = typeof e == "function" ? e : "", this.canContinue = !0, this.result = {}, this.errors = {}, this.chunkRate = 1, this.totalProgress = 0, this.batchCommandKeyOrder = [], this.totalBatchCommands = 0, this.batchCommandMethods = [], this.setTimeLimitState(!1, void 0);
1587
+ }, Ut = new WeakSet(), fe = function(e) {
1588
+ const t = typeof (e == null ? void 0 : e.error) == "function" ? e.error() : null, r = (t == null ? void 0 : t.ex) || {}, i = String(r.error || "").trim(), a = String(r.error_description || "").trim(), c = typeof (t == null ? void 0 : t.toString) == "function" ? String(t.toString()).trim() : "";
1589
+ let h = a;
1590
+ return !h && c && c !== i && (h = c), h || (h = i || "Неизвестная ошибка"), {
1591
+ code: i || h,
1592
+ message: h
1593
+ };
1594
+ }, ct = new WeakSet(), Lt = function(e, t) {
1595
+ const { code: r, message: i } = y(this, Ut, fe).call(this, t);
1596
+ this.errors[e] = r, this.errorMessages[e] = i;
1597
+ }, gt = new WeakSet(), $t = function(e) {
1598
+ Object.entries(this.errors).length && (e.errorsList = { ...this.errors }, Object.entries(this.errorMessages).length && (e.errorsListMessages = { ...this.errorMessages }));
1599
+ }, pt = new WeakSet(), te = function(e) {
1600
+ this.clearProgressData(), this.progressCall = typeof e == "function" ? e : "", this.canContinue = !0, this.result = {}, this.errors = {}, this.errorMessages = {}, this.chunkRate = 1, this.totalProgress = 0, this.batchCommandKeyOrder = [], this.totalBatchCommands = 0, this.batchCommandMethods = [], this.setTimeLimitState(!1, void 0);
1591
1601
  }, /** Не включать вес по командам для совсем маленьких batch. */
1592
- R(J, bt, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
1593
- R(J, Lt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
1594
- R(J, Rt, 8), R(J, Mt, 0.65);
1602
+ E(J, It, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
1603
+ E(J, Dt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
1604
+ E(J, kt, 8), E(J, wt, 0.65);
1595
1605
  let K = J;
1596
1606
  var st;
1597
- class ne {
1607
+ class de {
1598
1608
  constructor() {
1599
- R(this, st, {});
1609
+ E(this, st, {});
1600
1610
  }
1601
1611
  /**
1602
1612
  * Получить случайный хеш-код длиной 8 символов
@@ -1625,7 +1635,7 @@ class ne {
1625
1635
  * @param {Function} params.action - Функция для выполнения
1626
1636
  */
1627
1637
  actionFilter({ keyTimer: e, duration: t = 10, action: r }) {
1628
- S(this, st)[e] && (clearTimeout(S(this, st)[e]), S(this, st)[e] = null), r && (S(this, st)[e] = setTimeout(() => {
1638
+ L(this, st)[e] && (clearTimeout(L(this, st)[e]), L(this, st)[e] = null), r && (L(this, st)[e] = setTimeout(() => {
1629
1639
  r();
1630
1640
  }, t));
1631
1641
  }
@@ -1664,30 +1674,30 @@ class ne {
1664
1674
  }
1665
1675
  }
1666
1676
  st = new WeakMap();
1667
- const vt = new ne();
1668
- var j, z, rt, At, dt, V, v, it, ct, kt, ae, mt, Kt, wt, oe, Bt, Ae, Ct, ce;
1669
- class be {
1677
+ const Qt = new de();
1678
+ var j, z, rt, lt, yt, V, v, it, ht, Pt, me, Nt, ee, Gt, ge, Yt, pe, Wt, ye;
1679
+ class Ce {
1670
1680
  constructor() {
1671
1681
  /** user.current — только при первом реальном использовании (сохранение лога, выгрузка). */
1672
- R(this, kt);
1682
+ E(this, Pt);
1673
1683
  /** Вывод ошибок логера
1674
1684
  * @param {'entity'} type - тип ошибки
1675
1685
  */
1676
- R(this, mt);
1677
- R(this, wt);
1678
- R(this, Bt);
1679
- R(this, Ct);
1680
- R(this, j, "logger");
1681
- R(this, z, !1);
1682
- R(this, rt, /* @__PURE__ */ new Map());
1683
- R(this, At, {});
1684
- R(this, dt, !1);
1685
- R(this, V, null);
1686
- R(this, v, null);
1687
- R(this, it, !1);
1688
- R(this, ct, !1);
1686
+ E(this, Nt);
1687
+ E(this, Gt);
1688
+ E(this, Yt);
1689
+ E(this, Wt);
1690
+ E(this, j, "logger");
1691
+ E(this, z, !1);
1692
+ E(this, rt, /* @__PURE__ */ new Map());
1693
+ E(this, lt, {});
1694
+ E(this, yt, !1);
1695
+ E(this, V, null);
1696
+ E(this, v, null);
1697
+ E(this, it, !1);
1698
+ E(this, ht, !1);
1689
1699
  /** Очистка хранилища элементов старше 'N' месяцев */
1690
- B(this, "periodClear", 3);
1700
+ w(this, "periodClear", 3);
1691
1701
  }
1692
1702
  /** Инициализация логера */
1693
1703
  async init() {
@@ -1697,7 +1707,7 @@ class be {
1697
1707
  });
1698
1708
  if (t && Array.isArray(t))
1699
1709
  if (t.find(
1700
- (i) => i.ENTITY == S(this, j)
1710
+ (i) => i.ENTITY == L(this, j)
1701
1711
  ))
1702
1712
  x(this, z, !0);
1703
1713
  else {
@@ -1705,15 +1715,15 @@ class be {
1705
1715
  entityAdd: {
1706
1716
  method: "entity.add",
1707
1717
  params: {
1708
- ENTITY: S(this, j),
1709
- NAME: S(this, j),
1718
+ ENTITY: L(this, j),
1719
+ NAME: L(this, j),
1710
1720
  ACCESS: { AU: "X" }
1711
1721
  }
1712
1722
  }
1713
1723
  });
1714
1724
  i && x(this, z, !0);
1715
1725
  }
1716
- return S(this, z);
1726
+ return L(this, z);
1717
1727
  } catch (e) {
1718
1728
  return console.error("Ошибка при инициализации логера:", e), !1;
1719
1729
  }
@@ -1735,11 +1745,11 @@ class be {
1735
1745
  * @returns {string|null}
1736
1746
  */
1737
1747
  start({ type: e, data: t }) {
1738
- if (!S(this, z))
1739
- return _(this, mt, Kt).call(this, "entity"), null;
1748
+ if (!L(this, z))
1749
+ return y(this, Nt, ee).call(this, "entity"), null;
1740
1750
  if (!e || !t)
1741
1751
  return console.error("Невалидные данные для логирования:", { type: e, data: t }), null;
1742
- const r = vt.hash, i = {
1752
+ const r = Qt.hash, i = {
1743
1753
  type: e,
1744
1754
  data: t,
1745
1755
  userInfo: null,
@@ -1748,7 +1758,7 @@ class be {
1748
1758
  answer: null,
1749
1759
  date: (/* @__PURE__ */ new Date()).getTime()
1750
1760
  };
1751
- return S(this, rt).set(r, i), x(this, ct, !0), r;
1761
+ return L(this, rt).set(r, i), x(this, ht, !0), r;
1752
1762
  }
1753
1763
  /**
1754
1764
  * @param {{
@@ -1759,18 +1769,18 @@ class be {
1759
1769
  */
1760
1770
  async stop({ key: e, errorList: t, status: r, answer: i }) {
1761
1771
  var c;
1762
- if (!S(this, ct))
1772
+ if (!L(this, ht))
1763
1773
  return;
1764
- if (!S(this, z)) {
1765
- _(this, mt, Kt).call(this, "entity");
1774
+ if (!L(this, z)) {
1775
+ y(this, Nt, ee).call(this, "entity");
1766
1776
  return;
1767
1777
  }
1768
- let a = S(this, rt).get(e);
1778
+ let a = L(this, rt).get(e);
1769
1779
  if (!a) {
1770
1780
  console.error(`Не найдены данные логирования для ключа: ${e}`);
1771
1781
  return;
1772
1782
  }
1773
- t && (a.errorList = t), r && (a.status = r), i && (a.answer = i), await _(this, kt, ae).call(this), a.userInfo = S(this, At), await _(this, wt, oe).call(this), (c = a == null ? void 0 : a.data) != null && c.updateList && x(this, it, !0), x(this, ct, !1);
1783
+ t && (a.errorList = t), r && (a.status = r), i && (a.answer = i), await y(this, Pt, me).call(this), a.userInfo = L(this, lt), await y(this, Gt, ge).call(this), (c = a == null ? void 0 : a.data) != null && c.updateList && x(this, it, !0), x(this, ht, !1);
1774
1784
  }
1775
1785
  /**
1776
1786
  * @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
@@ -1778,14 +1788,14 @@ class be {
1778
1788
  async getEntityList(e) {
1779
1789
  var t;
1780
1790
  try {
1781
- if ((t = S(this, v)) != null && t.length && !S(this, it))
1782
- return S(this, v);
1791
+ if ((t = L(this, v)) != null && t.length && !L(this, it))
1792
+ return L(this, v);
1783
1793
  let r = new K(BX24.callBatch), { entityList: i } = await r.batch(
1784
1794
  {
1785
1795
  entityList: {
1786
1796
  method: "entity.item.get",
1787
1797
  params: {
1788
- ENTITY: S(this, j),
1798
+ ENTITY: L(this, j),
1789
1799
  SORT: { ID: "DESC" }
1790
1800
  }
1791
1801
  }
@@ -1794,11 +1804,11 @@ class be {
1794
1804
  );
1795
1805
  return !i || !Array.isArray(i) ? (console.warn("Получен невалидный список записей"), []) : (i = i.map((a) => {
1796
1806
  try {
1797
- const { ID: c, DATE_CREATE: l, DETAIL_TEXT: h } = a;
1807
+ const { ID: c, DATE_CREATE: h, DETAIL_TEXT: f } = a;
1798
1808
  return {
1799
- ...JSON.parse(h),
1809
+ ...JSON.parse(f),
1800
1810
  id: c,
1801
- dateCreate: l
1811
+ dateCreate: h
1802
1812
  };
1803
1813
  } catch (c) {
1804
1814
  return console.error(
@@ -1816,16 +1826,16 @@ class be {
1816
1826
  * Не вызывается из `init` — вызывайте явно (например, из настроек или планировщика).
1817
1827
  */
1818
1828
  runStorageMaintenance() {
1819
- return _(this, Bt, Ae).call(this);
1829
+ return y(this, Yt, pe).call(this);
1820
1830
  }
1821
1831
  /** Выгрузка всех данных из хранилища в JSON-файл */
1822
1832
  async downAllEntityJson() {
1823
1833
  try {
1824
- if (S(this, v) || await this.getEntityList(), !S(this, v) || S(this, v).length === 0)
1834
+ if (L(this, v) || await this.getEntityList(), !L(this, v) || L(this, v).length === 0)
1825
1835
  return console.warn("Нет данных для выгрузки"), !1;
1826
- let e = Ot().format("%Y-%m-%d");
1827
- return vt.downloadFileJson(
1828
- S(this, v),
1836
+ let e = bt().format("%Y-%m-%d");
1837
+ return Qt.downloadFileJson(
1838
+ L(this, v),
1829
1839
  `sdklogger-entity-data__${e}`
1830
1840
  ), !0;
1831
1841
  } catch (e) {
@@ -1833,42 +1843,42 @@ class be {
1833
1843
  }
1834
1844
  }
1835
1845
  }
1836
- j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), dt = new WeakMap(), V = new WeakMap(), v = new WeakMap(), it = new WeakMap(), ct = new WeakMap(), kt = new WeakSet(), ae = async function() {
1837
- if (!S(this, dt))
1838
- return S(this, V) ? S(this, V) : (x(this, V, (async () => {
1846
+ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt = new WeakMap(), V = new WeakMap(), v = new WeakMap(), it = new WeakMap(), ht = new WeakMap(), Pt = new WeakSet(), me = async function() {
1847
+ if (!L(this, yt))
1848
+ return L(this, V) ? L(this, V) : (x(this, V, (async () => {
1839
1849
  try {
1840
1850
  const e = new K(BX24.callBatch), t = BX24.isAdmin(), { curUser: r } = await e.batch({
1841
1851
  curUser: { method: "user.current" }
1842
1852
  });
1843
- x(this, At, { isAdmin: t, curUser: r });
1853
+ x(this, lt, { isAdmin: t, curUser: r });
1844
1854
  } catch (e) {
1845
1855
  console.error(
1846
1856
  "Ошибка при получении информации о пользователе:",
1847
1857
  e
1848
- ), x(this, At, { isAdmin: !1, curUser: null });
1858
+ ), x(this, lt, { isAdmin: !1, curUser: null });
1849
1859
  } finally {
1850
- x(this, dt, !0), x(this, V, null);
1860
+ x(this, yt, !0), x(this, V, null);
1851
1861
  }
1852
- })()), S(this, V));
1853
- }, mt = new WeakSet(), Kt = function(e) {
1854
- e == "entity" && vt.actionFilter({
1862
+ })()), L(this, V));
1863
+ }, Nt = new WeakSet(), ee = function(e) {
1864
+ e == "entity" && Qt.actionFilter({
1855
1865
  keyTimer: "error.logger.entity",
1856
1866
  duration: 500,
1857
1867
  action: () => {
1858
1868
  console.error("Хранилище для логгера не инициализировано");
1859
1869
  }
1860
1870
  });
1861
- }, wt = new WeakSet(), oe = async function() {
1871
+ }, Gt = new WeakSet(), ge = async function() {
1862
1872
  try {
1863
1873
  let e = {}, t = new K(BX24.callBatch);
1864
- for (let [r, i] of S(this, rt).entries())
1874
+ for (let [r, i] of L(this, rt).entries())
1865
1875
  if (i.status) {
1866
1876
  const a = JSON.stringify(i);
1867
1877
  e[r] = {
1868
1878
  method: "entity.item.add",
1869
1879
  params: {
1870
- ENTITY: S(this, j),
1871
- NAME: S(this, j),
1880
+ ENTITY: L(this, j),
1881
+ NAME: L(this, j),
1872
1882
  DETAIL_TEXT: a
1873
1883
  }
1874
1884
  };
@@ -1876,14 +1886,14 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), dt
1876
1886
  if (Object.keys(e).length) {
1877
1887
  let r = await t.batch(e), { errors: i } = t;
1878
1888
  for (let [a, c] of Object.entries({ ...r, ...i }))
1879
- S(this, rt).delete(a);
1889
+ L(this, rt).delete(a);
1880
1890
  return !0;
1881
1891
  }
1882
1892
  return !1;
1883
1893
  } catch (e) {
1884
1894
  return console.error("Ошибка при добавлении записей в хранилище:", e), !1;
1885
1895
  }
1886
- }, Bt = new WeakSet(), Ae = async function() {
1896
+ }, Yt = new WeakSet(), pe = async function() {
1887
1897
  try {
1888
1898
  let e = new K(BX24.callBatch), { serverTime: t } = await e.batch({
1889
1899
  serverTime: { method: "server.time" }
@@ -1892,13 +1902,13 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), dt
1892
1902
  console.error("Не удалось получить время сервера");
1893
1903
  return;
1894
1904
  }
1895
- if (S(this, v) || await this.getEntityList(), !S(this, v) || S(this, v).length === 0)
1905
+ if (L(this, v) || await this.getEntityList(), !L(this, v) || L(this, v).length === 0)
1896
1906
  return;
1897
- let r = S(this, v).filter((i) => {
1907
+ let r = L(this, v).filter((i) => {
1898
1908
  try {
1899
1909
  let { dateCreate: a } = i;
1900
- return a ? Ot(new Date(a)).between(
1901
- Ot(new Date(t)),
1910
+ return a ? bt(new Date(a)).between(
1911
+ bt(new Date(t)),
1902
1912
  "month"
1903
1913
  ) >= this.periodClear : !1;
1904
1914
  } catch (a) {
@@ -1907,11 +1917,11 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), dt
1907
1917
  });
1908
1918
  r.length > 0 && (console.log(
1909
1919
  `Найдено ${r.length} записей для очистки (старше ${this.periodClear} месяцев)`
1910
- ), await _(this, Ct, ce).call(this, r));
1920
+ ), await y(this, Wt, ye).call(this, r));
1911
1921
  } catch (e) {
1912
1922
  console.error("Ошибка при проверке периода очистки:", e);
1913
1923
  }
1914
- }, Ct = new WeakSet(), ce = async function(e) {
1924
+ }, Wt = new WeakSet(), ye = async function(e) {
1915
1925
  try {
1916
1926
  if (!e || e.length === 0)
1917
1927
  return !1;
@@ -1920,7 +1930,7 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), dt
1920
1930
  return {
1921
1931
  method: "entity.item.delete",
1922
1932
  params: {
1923
- ENTITY: S(this, j),
1933
+ ENTITY: L(this, j),
1924
1934
  ID: c
1925
1935
  }
1926
1936
  };
@@ -1933,36 +1943,36 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), At = new WeakMap(), dt
1933
1943
  return console.error("Ошибка при очистке устаревших записей:", t), !1;
1934
1944
  }
1935
1945
  };
1936
- function $t(y) {
1937
- if (!y || typeof y != "string")
1946
+ function oe(m) {
1947
+ if (!m || typeof m != "string")
1938
1948
  return "";
1939
1949
  try {
1940
- const e = new URL(y);
1950
+ const e = new URL(m);
1941
1951
  e.search = "", e.hash = "";
1942
1952
  let t = e.toString();
1943
1953
  return t.endsWith("/") && e.pathname !== "/" && (t = t.slice(0, -1)), t;
1944
1954
  } catch {
1945
- return y.split("?")[0].split("#")[0].replace(/\/$/, "");
1955
+ return m.split("?")[0].split("#")[0].replace(/\/$/, "");
1946
1956
  }
1947
1957
  }
1948
- function le(y) {
1949
- return !y || typeof y != "string" ? !1 : y.toLowerCase().includes("/marketplace/app");
1958
+ function Ne(m) {
1959
+ return !m || typeof m != "string" ? !1 : m.toLowerCase().includes("/marketplace/app");
1950
1960
  }
1951
- function Le() {
1961
+ function He() {
1952
1962
  var e;
1953
1963
  if (typeof window > "u" || !((e = window.location) != null && e.href))
1954
1964
  return "";
1955
- const y = $t(window.location.href);
1956
- return le(y) ? "" : y;
1965
+ const m = oe(window.location.href);
1966
+ return Ne(m) ? "" : m;
1957
1967
  }
1958
- function qt(y) {
1959
- if (!(y != null && y.appConst) || typeof y.appConst != "object")
1968
+ function se(m) {
1969
+ if (!(m != null && m.appConst) || typeof m.appConst != "object")
1960
1970
  return "";
1961
- const e = Le();
1962
- return e ? (y.appConst.pathApp = e, e) : $t(y.appConst.pathApp ?? "");
1971
+ const e = He();
1972
+ return e ? (m.appConst.pathApp = e, e) : oe(m.appConst.pathApp ?? "");
1963
1973
  }
1964
- var lt, Tt, Ht, he, gt, zt, Ut, ue, Pt, fe, Gt, de, $, at, yt, Qt, Yt, me, pt, Zt, Wt, ge;
1965
- class we {
1974
+ var ut, Rt, xt, Oe, Ot, re, Ft, _e, vt, Te, Xt, Ee, $, ot, _t, ie, Jt, be, Tt, ne, jt, Me;
1975
+ class ve {
1966
1976
  /**
1967
1977
  * @param {Object} appConst - Константы приложения
1968
1978
  * @param {string} appConst.appName - Название приложения
@@ -1975,24 +1985,24 @@ class we {
1975
1985
  *
1976
1986
  * @returns {Batch} Shared Batch instance.
1977
1987
  */
1978
- R(this, lt);
1979
- R(this, Ht);
1988
+ E(this, ut);
1989
+ E(this, xt);
1980
1990
  /**
1981
1991
  * `this.logger === true` → `BxLogger` + лёгкий `init` (сущность хранилища, без полной выгрузки);
1982
1992
  * иначе — заглушка.
1983
1993
  * @param {boolean} runLoggerMaintenance
1984
1994
  */
1985
- R(this, gt);
1995
+ E(this, Ot);
1986
1996
  /**
1987
1997
  * @returns {boolean}
1988
1998
  */
1989
- R(this, Ut);
1999
+ E(this, Ft);
1990
2000
  /** Запрос данных о приложении */
1991
- R(this, Pt);
2001
+ E(this, vt);
1992
2002
  /** Запрос данных о текущем пользователе */
1993
- R(this, Gt);
1994
- R(this, $);
1995
- R(this, yt);
2003
+ E(this, Xt);
2004
+ E(this, $);
2005
+ E(this, _t);
1996
2006
  /**
1997
2007
  * Расширяет errorList для случаев TIMEOUT и LIMIT
1998
2008
  * Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
@@ -2002,31 +2012,31 @@ class we {
2002
2012
  * @param {Array} updateList - Список обновлений для логирования (опционально)
2003
2013
  * @returns {Object} Расширенный список ошибок
2004
2014
  */
2005
- R(this, Yt);
2015
+ E(this, Jt);
2006
2016
  /**
2007
2017
  * Нормализует входные данные в массив объектов {placement, handler?}
2008
2018
  * @private
2009
2019
  */
2010
- R(this, pt);
2020
+ E(this, Tt);
2011
2021
  /**
2012
2022
  * Находит встройки с устаревшим handler (не содержащим текущий pathApp)
2013
2023
  * @private
2014
2024
  */
2015
- R(this, Wt);
2016
- B(this, "domain", "");
2017
- B(this, "isAdmin", !1);
2018
- B(this, "appInfo", null);
2019
- B(this, "appConst", null);
2020
- B(this, "userInfo", null);
2021
- B(this, "placeData", null);
2022
- B(this, "placeInfo", null);
2023
- B(this, "logger", !1);
2024
- B(this, "timeLimit", {
2025
+ E(this, jt);
2026
+ w(this, "domain", "");
2027
+ w(this, "isAdmin", !1);
2028
+ w(this, "appInfo", null);
2029
+ w(this, "appConst", null);
2030
+ w(this, "userInfo", null);
2031
+ w(this, "placeData", null);
2032
+ w(this, "placeInfo", null);
2033
+ w(this, "logger", !1);
2034
+ w(this, "timeLimit", {
2025
2035
  limit: !1,
2026
2036
  date: void 0,
2027
2037
  pauseMs: void 0
2028
2038
  });
2029
- B(this, "batchClient", null);
2039
+ w(this, "batchClient", null);
2030
2040
  this.appConst = e;
2031
2041
  }
2032
2042
  /**
@@ -2036,7 +2046,7 @@ class we {
2036
2046
  * @returns {() => void} Функция отписки.
2037
2047
  */
2038
2048
  subscribeTimeLimit(e) {
2039
- return _(this, lt, Tt).call(this).subscribeTimeLimit(e);
2049
+ return y(this, ut, Rt).call(this).subscribeTimeLimit(e);
2040
2050
  }
2041
2051
  /**
2042
2052
  * Единая инициализация: внутри автоматически выбирается ветка обычного приложения или
@@ -2060,22 +2070,22 @@ class we {
2060
2070
  let a = setInterval(() => {
2061
2071
  window.BX24 && BX24.init(async () => {
2062
2072
  clearInterval(a), clearTimeout(i), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info();
2063
- const c = _(this, Ut, ue).call(this);
2073
+ const c = y(this, Ft, _e).call(this);
2064
2074
  if (console.info(
2065
2075
  c ? "init BX24 (background worker)" : "init BX24"
2066
- ), this.appInfo = await _(this, Pt, fe).call(this), this.userInfo = await _(this, Gt, de).call(this), qt(this), c)
2067
- await _(this, gt, zt).call(this, !1, {
2076
+ ), this.appInfo = await y(this, vt, Te).call(this), this.userInfo = await y(this, Xt, Ee).call(this), se(this), c)
2077
+ await y(this, Ot, re).call(this, !1, {
2068
2078
  skipInit: !0
2069
2079
  });
2070
2080
  else {
2071
- await _(this, gt, zt).call(this, !0);
2072
- const l = new ne();
2081
+ await y(this, Ot, re).call(this, !0);
2082
+ const h = new de();
2073
2083
  try {
2074
- l.noSleep();
2075
- } catch (h) {
2084
+ h.noSleep();
2085
+ } catch (f) {
2076
2086
  console.warn(
2077
2087
  "Failed to initialize noSleep:",
2078
- h
2088
+ f
2079
2089
  );
2080
2090
  }
2081
2091
  }
@@ -2132,14 +2142,14 @@ class we {
2132
2142
  type: "call",
2133
2143
  data: { method: e, params: t, updateList: r }
2134
2144
  })), t || (t = {}), typeof BX24 > "u" || !BX24.callMethod) {
2135
- const l = new Error("BX24 is not initialized");
2136
- throw console.error(l), l;
2145
+ const h = new Error("BX24 is not initialized");
2146
+ throw console.error(h), h;
2137
2147
  }
2138
- const c = await _(this, lt, Tt).call(this).call({ method: e, params: t });
2139
- return c.success ? (await _(this, $, at).call(this, i, {
2148
+ const c = await y(this, ut, Rt).call(this).call({ method: e, params: t });
2149
+ return c.success ? (await y(this, $, ot).call(this, i, {
2140
2150
  answer: c.answer,
2141
2151
  status: "success"
2142
- }), c.data) : (console.error(c.error), await _(this, $, at).call(this, i, {
2152
+ }), c.data) : (console.error(c.error), await y(this, $, ot).call(this, i, {
2143
2153
  answer: c.answer,
2144
2154
  status: "fail",
2145
2155
  errorList: { 0: c.error || "Unknown call error" }
@@ -2169,7 +2179,7 @@ class we {
2169
2179
  const c = new Error("BX24 is not initialized");
2170
2180
  return console.error(c), !1;
2171
2181
  }
2172
- return _(this, yt, Qt).call(this, {
2182
+ return y(this, _t, ie).call(this, {
2173
2183
  mode: "batch",
2174
2184
  commandList: e,
2175
2185
  progressCall: t,
@@ -2205,7 +2215,7 @@ class we {
2205
2215
  const a = new Error("BX24 is not initialized");
2206
2216
  return console.error(a), !1;
2207
2217
  }
2208
- return _(this, yt, Qt).call(this, {
2218
+ return y(this, _t, ie).call(this, {
2209
2219
  mode: "batch-total-count",
2210
2220
  commandList: e,
2211
2221
  progressCall: t,
@@ -2227,53 +2237,53 @@ class we {
2227
2237
  if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
2228
2238
  return;
2229
2239
  const { appName: t, pathApp: r } = this.appConst;
2230
- let i = _(this, pt, Zt).call(this, e);
2240
+ let i = y(this, Tt, ne).call(this, e);
2231
2241
  i = i.filter(
2232
- (u) => u.placement !== "PAGE_BACKGROUND_WORKER" && u.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2242
+ (l) => l.placement !== "PAGE_BACKGROUND_WORKER" && l.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2233
2243
  );
2234
- const a = _(this, Wt, ge).call(this, r), c = new Set(i.map((u) => u.placement));
2235
- for (const u of a)
2236
- c.has(u.placement) || i.push({ placement: u.placement });
2244
+ const a = y(this, jt, Me).call(this, r), c = new Set(i.map((l) => l.placement));
2245
+ for (const l of a)
2246
+ c.has(l.placement) || i.push({ placement: l.placement });
2237
2247
  if (i.length === 0)
2238
2248
  return;
2239
- let l = t;
2240
- this.domain === "szdl.bitrix24.ru" && ((A = this.appInfo) != null && A.ID) && (l = `${t}: #${this.appInfo.ID}`);
2241
- const h = l.replace(" CRM", ""), n = {}, f = [], m = /* @__PURE__ */ new Map();
2242
- for (const u of this.placeData)
2243
- m.has(u.placement) || m.set(u.placement, []), m.get(u.placement).push(u);
2244
- for (let u = 0; u < i.length; u++) {
2245
- const { placement: O, options: T } = i[u], E = m.get(O) || [];
2246
- if (E.some(
2247
- (b) => b.handler === r
2249
+ let h = t;
2250
+ this.domain === "szdl.bitrix24.ru" && ((A = this.appInfo) != null && A.ID) && (h = `${t}: #${this.appInfo.ID}`);
2251
+ const f = h.replace(" CRM", ""), n = {}, u = [], d = /* @__PURE__ */ new Map();
2252
+ for (const l of this.placeData)
2253
+ d.has(l.placement) || d.set(l.placement, []), d.get(l.placement).push(l);
2254
+ for (let l = 0; l < i.length; l++) {
2255
+ const { placement: O, options: _ } = i[l], b = d.get(O) || [];
2256
+ if (b.some(
2257
+ (M) => M.handler === r
2248
2258
  ))
2249
2259
  continue;
2250
- const p = E.filter(
2251
- (b) => b.handler !== r
2260
+ const T = b.filter(
2261
+ (M) => M.handler !== r
2252
2262
  );
2253
- for (const b of p)
2254
- f.push({
2263
+ for (const M of T)
2264
+ u.push({
2255
2265
  placement: O,
2256
- handler: b.handler
2266
+ handler: M.handler
2257
2267
  });
2258
- n[`bind_${u}`] = {
2268
+ n[`bind_${l}`] = {
2259
2269
  method: "placement.bind",
2260
2270
  params: {
2261
2271
  PLACEMENT: O,
2262
2272
  HANDLER: r,
2263
2273
  LANG_ALL: {
2264
2274
  ru: {
2265
- TITLE: O === "USER_PROFILE_TOOLBAR" ? h : l
2275
+ TITLE: O === "USER_PROFILE_TOOLBAR" ? f : h
2266
2276
  }
2267
2277
  },
2268
2278
  OPTIONS: {
2269
2279
  errorHandlerUrl: r,
2270
- ...T && typeof T == "object" ? T : {}
2280
+ ..._ && typeof _ == "object" ? _ : {}
2271
2281
  }
2272
2282
  }
2273
2283
  };
2274
2284
  }
2275
- f.length > 0 && await this.placementUnBind(f), Object.keys(n).length > 0 && (await this.batch(n), this.placeData = await this.getPlacement(), Object.values(n).forEach((u) => {
2276
- console.log("Приложение успешно встроено в", u.params.PLACEMENT);
2285
+ u.length > 0 && await this.placementUnBind(u), Object.keys(n).length > 0 && (await this.batch(n), this.placeData = await this.getPlacement(), Object.values(n).forEach((l) => {
2286
+ console.log("Приложение успешно встроено в", l.params.PLACEMENT);
2277
2287
  }));
2278
2288
  }
2279
2289
  /**
@@ -2281,7 +2291,7 @@ class we {
2281
2291
  * @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
2282
2292
  */
2283
2293
  async placementUnBind(e) {
2284
- let t = _(this, pt, Zt).call(this, e);
2294
+ let t = y(this, Tt, ne).call(this, e);
2285
2295
  if (t = t.filter(
2286
2296
  (i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2287
2297
  ), t.length === 0)
@@ -2311,7 +2321,7 @@ class we {
2311
2321
  }
2312
2322
  /* регистрация бота */
2313
2323
  async regBot({ code: e, type: t, name: r }) {
2314
- const { appName: i, pathApp: a, chatBotLogo: c } = this.appConst, l = this.appInfo.ID, h = await this.call({
2324
+ const { appName: i, pathApp: a, chatBotLogo: c } = this.appConst, h = this.appInfo.ID, f = await this.call({
2315
2325
  method: "imbot.register",
2316
2326
  params: {
2317
2327
  CODE: e ?? this.appInfo.CODE,
@@ -2326,7 +2336,7 @@ class we {
2326
2336
  // строковый идентификатор чат-бота, используется только в режиме Вебхуков
2327
2337
  PROPERTIES: {
2328
2338
  // Личные данные чат-бота (обяз.)
2329
- NAME: `${r ?? i} - бот #${l}`,
2339
+ NAME: `${r ?? i} - бот #${h}`,
2330
2340
  // Имя чат-бота (обязательное одно из полей NAME или LAST_NAME)
2331
2341
  LAST_NAME: "",
2332
2342
  // Фамилия чат-бота (обязательное одно из полей NAME или LAST_NAME)
@@ -2334,7 +2344,7 @@ class we {
2334
2344
  // Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
2335
2345
  EMAIL: "",
2336
2346
  // E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
2337
- PERSONAL_BIRTHDAY: Ot().format("%Y-%m-%d"),
2347
+ PERSONAL_BIRTHDAY: bt().format("%Y-%m-%d"),
2338
2348
  // День рождения в формате YYYY-mm-dd
2339
2349
  WORK_POSITION: "Почтальон",
2340
2350
  // Занимаемая должность, используется как описание чат-бота
@@ -2347,7 +2357,7 @@ class we {
2347
2357
  }
2348
2358
  }
2349
2359
  });
2350
- return console.log("Чат-бот добавлен", h), h;
2360
+ return console.log("Чат-бот добавлен", f), f;
2351
2361
  }
2352
2362
  /* Убрать регистрацию бота */
2353
2363
  async unRegBot(e) {
@@ -2364,12 +2374,12 @@ class we {
2364
2374
  return this.logger.getEntityList(e);
2365
2375
  }
2366
2376
  }
2367
- lt = new WeakSet(), Tt = function() {
2377
+ ut = new WeakSet(), Rt = function() {
2368
2378
  return this.batchClient || (this.batchClient = new K({
2369
2379
  callBatch: BX24.callBatch,
2370
2380
  callMethod: BX24.callMethod
2371
2381
  }), this.timeLimit = this.batchClient.timeLimit), this.batchClient;
2372
- }, Ht = new WeakSet(), he = function() {
2382
+ }, xt = new WeakSet(), Oe = function() {
2373
2383
  return {
2374
2384
  start: () => {
2375
2385
  },
@@ -2378,17 +2388,17 @@ lt = new WeakSet(), Tt = function() {
2378
2388
  getEntityList: () => {
2379
2389
  }
2380
2390
  };
2381
- }, gt = new WeakSet(), zt = async function(e, { skipInit: t = !1 } = {}) {
2382
- this.logger ? (this.logger = new be(), t ? this.logger.enableBackworkerMode() : await this.logger.init(), e && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = _(this, Ht, he).call(this);
2383
- }, Ut = new WeakSet(), ue = function() {
2391
+ }, Ot = new WeakSet(), re = async function(e, { skipInit: t = !1 } = {}) {
2392
+ this.logger ? (this.logger = new Ce(), t ? this.logger.enableBackworkerMode() : await this.logger.init(), e && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = y(this, xt, Oe).call(this);
2393
+ }, Ft = new WeakSet(), _e = function() {
2384
2394
  var r, i, a;
2385
2395
  const e = (r = this.placeInfo) == null ? void 0 : r.placement, t = (a = (i = this.placeInfo) == null ? void 0 : i.options) == null ? void 0 : a.ID;
2386
2396
  return e === "PAGE_BACKGROUND_WORKER" || t === "PAGE_BACKGROUND_WORKER";
2387
- }, Pt = new WeakSet(), fe = function() {
2397
+ }, vt = new WeakSet(), Te = function() {
2388
2398
  return this.call({ method: "app.info" });
2389
- }, Gt = new WeakSet(), de = function() {
2399
+ }, Xt = new WeakSet(), Ee = function() {
2390
2400
  return this.call({ method: "user.current" });
2391
- }, $ = new WeakSet(), at = async function(e, t) {
2401
+ }, $ = new WeakSet(), ot = async function(e, t) {
2392
2402
  if (e)
2393
2403
  try {
2394
2404
  await this.logger.stop({
@@ -2398,7 +2408,7 @@ lt = new WeakSet(), Tt = function() {
2398
2408
  } catch (r) {
2399
2409
  console.error("Logger error:", r);
2400
2410
  }
2401
- }, yt = new WeakSet(), Qt = async function({
2411
+ }, _t = new WeakSet(), ie = async function({
2402
2412
  mode: e,
2403
2413
  commandList: t,
2404
2414
  progressCall: r,
@@ -2406,105 +2416,107 @@ lt = new WeakSet(), Tt = function() {
2406
2416
  updateList: a,
2407
2417
  batchOptions: c
2408
2418
  }) {
2409
- const l = _(this, lt, Tt).call(this), h = a ? this.logger.start({
2419
+ const h = y(this, ut, Rt).call(this), f = a ? this.logger.start({
2410
2420
  type: e,
2411
2421
  data: e === "batch" ? { commandList: t, updateList: a } : { commandList: t }
2412
2422
  }) : void 0;
2413
2423
  try {
2414
- const n = e === "batch" ? await l.batch(t, r, c) : await l.batchTotalCount(t, r), f = _(this, Yt, me).call(this, l, n, t, a);
2415
- return Object.keys(f).length ? (i && i(f), await _(this, $, at).call(this, h, {
2424
+ const n = e === "batch" ? await h.batch(t, r, c) : await h.batchTotalCount(t, r), u = y(this, Jt, be).call(this, h, n, t, a);
2425
+ return Object.keys(u).length ? (i && i(u), await y(this, $, ot).call(this, f, {
2416
2426
  status: "fail",
2417
- errorList: f
2418
- })) : await _(this, $, at).call(this, h, { status: "success" }), n;
2427
+ errorList: u
2428
+ })) : await y(this, $, ot).call(this, f, { status: "success" }), n;
2419
2429
  } catch (n) {
2420
- return await _(this, $, at).call(this, h, {
2430
+ return await y(this, $, ot).call(this, f, {
2421
2431
  status: "fail-runtime",
2422
2432
  errorList: { 0: n == null ? void 0 : n.toString() }
2423
2433
  }), console.error(n), !1;
2424
2434
  }
2425
- }, Yt = new WeakSet(), me = function(e, t, r, i) {
2435
+ }, Jt = new WeakSet(), be = function(e, t, r, i) {
2426
2436
  let a = { ...e.errors };
2427
2437
  if (Object.values(e.errors).some(
2428
- (l) => {
2429
- if (typeof l != "string")
2438
+ (h) => {
2439
+ if (typeof h != "string")
2430
2440
  return !1;
2431
- const h = l.toUpperCase();
2432
- return h === "TIMEOUT" || h === "OPERATION_TIME_LIMIT" || h.includes("TIMEOUT") || h.includes("OPERATION_TIME_LIMIT");
2441
+ const f = h.toUpperCase();
2442
+ return f === "TIMEOUT" || f === "OPERATION_TIME_LIMIT" || f.includes("TIMEOUT") || f.includes("OPERATION_TIME_LIMIT");
2433
2443
  }
2434
2444
  ) && i) {
2435
- const l = t ? Object.keys(t).filter((m) => m !== "errorsList") : [], h = new Set(Object.keys(e.errors || {})), n = /* @__PURE__ */ new Set();
2445
+ const h = t ? Object.keys(t).filter(
2446
+ (d) => d !== "errorsList" && d !== "errorsListMessages"
2447
+ ) : [], f = new Set(Object.keys(e.errors || {})), n = /* @__PURE__ */ new Set();
2436
2448
  if (t) {
2437
- for (const m of l)
2438
- if (!h.has(m)) {
2439
- const A = t[m];
2440
- A != null && n.add(m);
2449
+ for (const d of h)
2450
+ if (!f.has(d)) {
2451
+ const A = t[d];
2452
+ A != null && n.add(d);
2441
2453
  }
2442
2454
  }
2443
- const f = Object.values(e.errors).find(
2444
- (m) => {
2445
- if (typeof m != "string")
2455
+ const u = Object.values(e.errors).find(
2456
+ (d) => {
2457
+ if (typeof d != "string")
2446
2458
  return !1;
2447
- const A = m.toUpperCase();
2459
+ const A = d.toUpperCase();
2448
2460
  return A === "TIMEOUT" || A === "OPERATION_TIME_LIMIT" || A.includes("TIMEOUT") || A.includes("OPERATION_TIME_LIMIT");
2449
2461
  }
2450
2462
  );
2451
- for (const m of Object.keys(r))
2452
- !n.has(m) && !e.errors[m] && (a[m] = f || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
2463
+ for (const d of Object.keys(r))
2464
+ !n.has(d) && !e.errors[d] && (a[d] = u || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
2453
2465
  }
2454
2466
  return a;
2455
- }, pt = new WeakSet(), Zt = function(e) {
2467
+ }, Tt = new WeakSet(), ne = function(e) {
2456
2468
  if (!e)
2457
2469
  return [];
2458
2470
  let t = [];
2459
2471
  return Array.isArray(e) ? t = e.map(
2460
2472
  (r) => typeof r == "string" ? { placement: r } : r
2461
2473
  ) : typeof e == "string" ? t = [{ placement: e }] : t = [e], t;
2462
- }, Wt = new WeakSet(), ge = function(e) {
2474
+ }, jt = new WeakSet(), Me = function(e) {
2463
2475
  return this.placeData ? this.placeData.filter((t) => !(t.placement === "PAGE_BACKGROUND_WORKER" || !t.handler || t.handler.includes(e))) : [];
2464
2476
  };
2465
- const ye = "szdl-utils-kit|";
2466
- function Re() {
2477
+ const Le = "szdl-utils-kit|";
2478
+ function Ue() {
2467
2479
  if (typeof sessionStorage > "u")
2468
2480
  return `ephemeral-${Date.now()}-${Math.random().toString(16).slice(2)}`;
2469
- let y = sessionStorage.getItem("szdl-cross-tab-instance-id");
2470
- return y || (y = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", y)), y;
2481
+ let m = sessionStorage.getItem("szdl-cross-tab-instance-id");
2482
+ return m || (m = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", m)), m;
2471
2483
  }
2472
- function Me() {
2484
+ function Pe() {
2473
2485
  return typeof navigator < "u" && typeof navigator.locks < "u" && typeof navigator.locks.request == "function";
2474
2486
  }
2475
- const Xt = /* @__PURE__ */ new Map();
2476
- function Ie(y = "default") {
2487
+ const Zt = /* @__PURE__ */ new Map();
2488
+ function Ge(m = "default") {
2477
2489
  if (typeof BroadcastChannel > "u")
2478
2490
  return null;
2479
- const e = `${ye}bc:${y}`;
2480
- return Xt.has(e) || Xt.set(e, new BroadcastChannel(e)), Xt.get(e);
2491
+ const e = `${Le}bc:${m}`;
2492
+ return Zt.has(e) || Zt.set(e, new BroadcastChannel(e)), Zt.get(e);
2481
2493
  }
2482
- function te(y, e) {
2483
- const t = Ie(y);
2494
+ function Ae(m, e) {
2495
+ const t = Ge(m);
2484
2496
  if (t)
2485
2497
  try {
2486
2498
  const r = e && typeof e == "object" && !Array.isArray(e) ? e : { data: e };
2487
2499
  t.postMessage({
2488
2500
  ...r,
2489
- tabId: Re(),
2501
+ tabId: Ue(),
2490
2502
  ts: Date.now()
2491
2503
  });
2492
2504
  } catch {
2493
2505
  }
2494
2506
  }
2495
- async function Se(y, e, t = {}) {
2496
- const { ifAvailable: r = !1 } = t, i = typeof y == "string" && y.length > 0 ? y : "default", a = `${ye}${i}`;
2497
- return Me() ? navigator.locks.request(
2507
+ async function Ye(m, e, t = {}) {
2508
+ const { ifAvailable: r = !1 } = t, i = typeof m == "string" && m.length > 0 ? m : "default", a = `${Le}${i}`;
2509
+ return Pe() ? navigator.locks.request(
2498
2510
  a,
2499
2511
  { mode: "exclusive", ifAvailable: !!r },
2500
2512
  async (c) => {
2501
2513
  if (r && c == null)
2502
2514
  return { skipped: !0, coordination: "locks" };
2503
- te(i, { type: "lock-acquired", resource: i });
2515
+ Ae(i, { type: "lock-acquired", resource: i });
2504
2516
  try {
2505
2517
  return { skipped: !1, result: await e(), coordination: "locks" };
2506
2518
  } finally {
2507
- te(i, { type: "lock-released", resource: i });
2519
+ Ae(i, { type: "lock-released", resource: i });
2508
2520
  }
2509
2521
  }
2510
2522
  ) : { skipped: !1, result: await e(), coordination: "none" };
@@ -2525,11 +2537,16 @@ const q = {
2525
2537
  /** Heartbeat лидера во время appInit; null — вычислить из poll/activeMaxPause. */
2526
2538
  leaderHeartbeatMs: null
2527
2539
  };
2528
- function De(y = {}) {
2529
- const e = { ...q, ...y };
2540
+ function We(m) {
2541
+ return m == null ? "user" : m === "user" || m === "portal" ? m : (console.warn(
2542
+ `BackgroundWorker: coordinationScope должен быть 'user' или 'portal', получено ${JSON.stringify(m)} — используется 'user'`
2543
+ ), "user");
2544
+ }
2545
+ function xe(m = {}) {
2546
+ const e = { ...q, ...m };
2530
2547
  for (const t of Object.keys(q)) {
2531
2548
  if (t === "leaderHeartbeatMs") {
2532
- const i = y == null ? void 0 : y.leaderHeartbeatMs;
2549
+ const i = m == null ? void 0 : m.leaderHeartbeatMs;
2533
2550
  if (i == null) {
2534
2551
  e.leaderHeartbeatMs = null;
2535
2552
  continue;
@@ -2543,40 +2560,53 @@ function De(y = {}) {
2543
2560
  }
2544
2561
  return e;
2545
2562
  }
2546
- var xt, pe, Nt, Vt;
2547
- class Be {
2563
+ var Kt, Re, Et, ae, nt, mt, qt, Se;
2564
+ class Xe {
2548
2565
  constructor(e) {
2549
- R(this, xt);
2566
+ E(this, Kt);
2550
2567
  /**
2551
2568
  * Канонический base URL для placement (без завершающего `/`).
2552
2569
  * Пустая строка — не биндить (некорректный или marketplace URL).
2553
2570
  */
2554
- R(this, Nt);
2555
- B(this, "entityName", "tabs");
2556
- B(this, "maxTabs", 20);
2557
- B(this, "tabList", []);
2558
- B(this, "id", 0);
2559
- B(this, "hasStarted", !1);
2560
- B(this, "heartbeat");
2561
- B(this, "runHeartbeat");
2562
- B(this, "startDelay", 0);
2563
- B(this, "activeMaxPause", q.activeMaxPauseMs);
2564
- B(this, "quickCleanupThreshold", q.quickCleanupThresholdMs);
2565
- B(this, "pollInterval", q.pollIntervalMs);
2566
- B(this, "pollIntervalBase", q.pollIntervalMs);
2567
- B(this, "pollIntervalJitter", q.pollIntervalJitterMs);
2568
- B(this, "leaderConfirmDelay", q.leaderConfirmDelayMs);
2569
- B(this, "leaderHeartbeatMs", null);
2570
- B(this, "sessionId", `${Date.now()}-${Math.random().toString(16).slice(2)}`);
2571
- B(this, "continueCondition");
2572
- B(this, "defaultContinueBackground", () => !0);
2573
- var l, h, n;
2571
+ E(this, Et);
2572
+ /** Ключ NAME в entity: userId или общий ключ портала. */
2573
+ E(this, nt);
2574
+ /** Имя Web Lock для подтверждения лидерства. */
2575
+ E(this, qt);
2576
+ w(this, "entityName", "tabs");
2577
+ w(this, "maxTabs", 20);
2578
+ w(this, "tabList", []);
2579
+ w(this, "id", 0);
2580
+ w(this, "hasStarted", !1);
2581
+ w(this, "heartbeat");
2582
+ w(this, "runHeartbeat");
2583
+ w(this, "startDelay", 0);
2584
+ w(this, "activeMaxPause", q.activeMaxPauseMs);
2585
+ w(this, "quickCleanupThreshold", q.quickCleanupThresholdMs);
2586
+ w(this, "pollInterval", q.pollIntervalMs);
2587
+ w(this, "pollIntervalBase", q.pollIntervalMs);
2588
+ w(this, "pollIntervalJitter", q.pollIntervalJitterMs);
2589
+ w(this, "leaderConfirmDelay", q.leaderConfirmDelayMs);
2590
+ w(this, "leaderHeartbeatMs", null);
2591
+ w(this, "sessionId", `${Date.now()}-${Math.random().toString(16).slice(2)}`);
2592
+ w(this, "continueCondition");
2593
+ w(this, "defaultContinueBackground", () => !0);
2594
+ /** @type {'user' | 'portal'} */
2595
+ w(this, "coordinationScope", "user");
2596
+ var f, n, u;
2574
2597
  if (!e) {
2575
2598
  console.error("BackgroundWorker: Нет опций конструктора");
2576
2599
  return;
2577
2600
  }
2578
- const { appFunc: t, bx: r, users: i, continueBackground: a, timing: c } = e;
2579
- this.bx = r, this.appInit = t, this.users = i, _(this, xt, pe).call(this, c), qt(r), this.appPath = _(this, Nt, Vt).call(this, ((l = r == null ? void 0 : r.appConst) == null ? void 0 : l.pathApp) ?? ""), this.appName = ((h = r == null ? void 0 : r.appConst) == null ? void 0 : h.appName) ?? "", this.appCodeName = ((n = r == null ? void 0 : r.appConst) == null ? void 0 : n.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
2601
+ const {
2602
+ appFunc: t,
2603
+ bx: r,
2604
+ users: i,
2605
+ continueBackground: a,
2606
+ timing: c,
2607
+ coordinationScope: h
2608
+ } = e;
2609
+ this.bx = r, this.appInit = t, this.users = i, this.coordinationScope = We(h), y(this, Kt, Re).call(this, c), se(r), this.appPath = y(this, Et, ae).call(this, ((f = r == null ? void 0 : r.appConst) == null ? void 0 : f.pathApp) ?? ""), this.appName = ((n = r == null ? void 0 : r.appConst) == null ? void 0 : n.appName) ?? "", this.appCodeName = ((u = r == null ? void 0 : r.appConst) == null ? void 0 : u.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
2580
2610
  }
2581
2611
  async init() {
2582
2612
  if (!this.appInit) {
@@ -2620,8 +2650,8 @@ class Be {
2620
2650
  if (typeof BX24 > "u" || !((e = BX24.placement) != null && e.info))
2621
2651
  return !1;
2622
2652
  try {
2623
- const t = BX24.placement.info(), r = t == null ? void 0 : t.placement, i = (t == null ? void 0 : t.options) || {}, a = (i == null ? void 0 : i.URI) || "", c = r === "PAGE_BACKGROUND_WORKER" || (i == null ? void 0 : i.ID) === "PAGE_BACKGROUND_WORKER", l = typeof a == "string" && (a.includes("marketplace/app") || a.includes("marketplace/apps") || a.includes("placement") || a.includes("sozdavatel" + this.appCodeName));
2624
- return !c || l;
2653
+ const t = BX24.placement.info(), r = t == null ? void 0 : t.placement, i = (t == null ? void 0 : t.options) || {}, a = (i == null ? void 0 : i.URI) || "", c = r === "PAGE_BACKGROUND_WORKER" || (i == null ? void 0 : i.ID) === "PAGE_BACKGROUND_WORKER", h = typeof a == "string" && (a.includes("marketplace/app") || a.includes("marketplace/apps") || a.includes("placement") || a.includes("sozdavatel" + this.appCodeName));
2654
+ return !c || h;
2625
2655
  } catch {
2626
2656
  return !1;
2627
2657
  }
@@ -2646,31 +2676,29 @@ class Be {
2646
2676
  );
2647
2677
  }
2648
2678
  async getTabs() {
2649
- const e = await this.safeCall(
2650
- () => {
2651
- var t;
2652
- return this.bx.call({
2653
- method: "entity.item.get",
2654
- params: {
2655
- ENTITY: this.entityName,
2656
- FILTER: { NAME: (t = this.bx.userInfo) == null ? void 0 : t.ID },
2657
- SORT: { DATE_CREATE: "DESC" }
2658
- }
2659
- });
2660
- }
2679
+ const e = y(this, nt, mt).call(this), t = await this.safeCall(
2680
+ () => this.bx.call({
2681
+ method: "entity.item.get",
2682
+ params: {
2683
+ ENTITY: this.entityName,
2684
+ FILTER: { NAME: e },
2685
+ SORT: { DATE_CREATE: "DESC" }
2686
+ }
2687
+ })
2661
2688
  );
2662
- return !Array.isArray(e) || !e.length ? [] : e.map((t) => {
2663
- if (!t)
2689
+ return !Array.isArray(t) || !t.length ? [] : t.map((r) => {
2690
+ if (!r)
2664
2691
  return { id: void 0, data: void 0 };
2665
2692
  try {
2666
- const r = JSON.parse(t.DETAIL_TEXT);
2667
- return { id: +t.ID || 0, data: r };
2668
- } catch (r) {
2669
- return console.log("BackgroundWorker: parse tab error", r), { id: +t.ID || 0, data: void 0 };
2693
+ const i = JSON.parse(r.DETAIL_TEXT);
2694
+ return { id: +r.ID || 0, data: i };
2695
+ } catch (i) {
2696
+ return console.log("BackgroundWorker: parse tab error", i), { id: +r.ID || 0, data: void 0 };
2670
2697
  }
2671
2698
  });
2672
2699
  }
2673
2700
  async ensureTabRegistered() {
2701
+ var r, i;
2674
2702
  if (this.id)
2675
2703
  return +this.id || 0;
2676
2704
  if (this.tabList.length >= this.maxTabs && await this.refreshTabs(!0, this.quickCleanupThreshold), this.tabList.length >= this.maxTabs)
@@ -2681,44 +2709,41 @@ class Be {
2681
2709
  lastActive: (/* @__PURE__ */ new Date()).toISOString(),
2682
2710
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2683
2711
  start: !1,
2684
- sessionId: this.sessionId
2712
+ sessionId: this.sessionId,
2713
+ userId: (i = (r = this.bx) == null ? void 0 : r.userInfo) == null ? void 0 : i.ID
2685
2714
  }, t = await this.safeCall(
2686
- () => {
2687
- var r;
2688
- return this.bx.call({
2689
- method: "entity.item.add",
2690
- params: {
2691
- ENTITY: this.entityName,
2692
- NAME: (r = this.bx.userInfo) == null ? void 0 : r.ID,
2693
- DETAIL_TEXT: JSON.stringify(e)
2694
- }
2695
- });
2696
- }
2715
+ () => this.bx.call({
2716
+ method: "entity.item.add",
2717
+ params: {
2718
+ ENTITY: this.entityName,
2719
+ NAME: y(this, nt, mt).call(this),
2720
+ DETAIL_TEXT: JSON.stringify(e)
2721
+ }
2722
+ })
2697
2723
  ) || 0;
2698
2724
  return this.id = +t || 0, this.id;
2699
2725
  }
2700
2726
  async updateTabState(e) {
2727
+ var r, i;
2701
2728
  if (!this.id)
2702
2729
  return;
2703
2730
  const t = {
2704
2731
  lastActive: (/* @__PURE__ */ new Date()).toISOString(),
2705
2732
  createdAt: this.start.toISOString(),
2706
2733
  start: e,
2707
- sessionId: this.sessionId
2734
+ sessionId: this.sessionId,
2735
+ userId: (i = (r = this.bx) == null ? void 0 : r.userInfo) == null ? void 0 : i.ID
2708
2736
  };
2709
2737
  await this.safeCall(
2710
- () => {
2711
- var r;
2712
- return this.bx.call({
2713
- method: "entity.item.update",
2714
- params: {
2715
- ENTITY: this.entityName,
2716
- ID: this.id,
2717
- NAME: (r = this.bx.userInfo) == null ? void 0 : r.ID,
2718
- DETAIL_TEXT: JSON.stringify(t)
2719
- }
2720
- });
2721
- }
2738
+ () => this.bx.call({
2739
+ method: "entity.item.update",
2740
+ params: {
2741
+ ENTITY: this.entityName,
2742
+ ID: this.id,
2743
+ NAME: y(this, nt, mt).call(this),
2744
+ DETAIL_TEXT: JSON.stringify(t)
2745
+ }
2746
+ })
2722
2747
  );
2723
2748
  }
2724
2749
  async deleteTabs(e = []) {
@@ -2747,19 +2772,19 @@ class Be {
2747
2772
  ), c = !a;
2748
2773
  if (!i)
2749
2774
  return !0;
2750
- let l = !1;
2751
- for (const h of r) {
2752
- if (h.placement !== "PAGE_BACKGROUND_WORKER" || !(h.userId || h.handler && h.handler.includes("USER_ID=")))
2775
+ let h = !1;
2776
+ for (const f of r) {
2777
+ if (f.placement !== "PAGE_BACKGROUND_WORKER" || !(f.userId || f.handler && f.handler.includes("USER_ID=")))
2753
2778
  continue;
2754
- const f = h.userId || (h.handler ? this.extractUserIdFromHandler(h.handler) : null);
2755
- if (f && +f === i) {
2756
- l = !0;
2779
+ const u = f.userId || (f.handler ? this.extractUserIdFromHandler(f.handler) : null);
2780
+ if (u && +u === i) {
2781
+ h = !0;
2757
2782
  break;
2758
2783
  }
2759
2784
  }
2760
2785
  return a ? (console.log(
2761
2786
  "BackgroundWorker: Индивидуальная встройка - разрешено"
2762
- ), !0) : c && l ? (console.log(
2787
+ ), !0) : c && h ? (console.log(
2763
2788
  "BackgroundWorker: Есть личная встройка, общую не запускаем"
2764
2789
  ), !1) : (console.log(
2765
2790
  "BackgroundWorker: Проверка типа встройки пройдена, продолжаем"
@@ -2795,27 +2820,27 @@ class Be {
2795
2820
  }
2796
2821
  async refreshTabs(e = !1, t = this.activeMaxPause) {
2797
2822
  const r = [], i = [], a = Date.now(), c = await this.getTabs();
2798
- for (const l of c) {
2799
- if (!(l != null && l.data)) {
2800
- r.push(l);
2823
+ for (const h of c) {
2824
+ if (!(h != null && h.data)) {
2825
+ r.push(h);
2801
2826
  continue;
2802
2827
  }
2803
- if (a - new Date(l.data.lastActive || 0).getTime() > t) {
2804
- r.push(l);
2828
+ if (a - new Date(h.data.lastActive || 0).getTime() > t) {
2829
+ r.push(h);
2805
2830
  continue;
2806
2831
  }
2807
- i.push(l);
2832
+ i.push(h);
2808
2833
  }
2809
2834
  return e && r.length && await this.deleteTabs(r), this.tabList = i, i;
2810
2835
  }
2811
2836
  selectLeaderId() {
2812
2837
  var t;
2813
2838
  return this.tabList.length && +((t = [...this.tabList].sort((r, i) => {
2814
- var l, h, n, f;
2839
+ var h, f, n, u;
2815
2840
  const a = new Date(
2816
- ((l = r.data) == null ? void 0 : l.createdAt) || ((h = r.data) == null ? void 0 : h.lastActive) || 0
2841
+ ((h = r.data) == null ? void 0 : h.createdAt) || ((f = r.data) == null ? void 0 : f.lastActive) || 0
2817
2842
  ).getTime(), c = new Date(
2818
- ((n = i.data) == null ? void 0 : n.createdAt) || ((f = i.data) == null ? void 0 : f.lastActive) || 0
2843
+ ((n = i.data) == null ? void 0 : n.createdAt) || ((u = i.data) == null ? void 0 : u.lastActive) || 0
2819
2844
  ).getTime();
2820
2845
  return a === c ? (+r.id || 0) - (+i.id || 0) : a - c;
2821
2846
  })[0]) == null ? void 0 : t.id) || 0;
@@ -2826,10 +2851,9 @@ class Be {
2826
2851
  return !!(e && +this.id == +e);
2827
2852
  }
2828
2853
  async runAsLeader() {
2829
- var i, a;
2830
- const e = String(((a = (i = this.bx) == null ? void 0 : i.userInfo) == null ? void 0 : a.ID) ?? "0"), t = `background-worker:${this.entityName}:${e}`;
2831
- (await Se(
2832
- t,
2854
+ const e = y(this, qt, Se).call(this);
2855
+ (await Ye(
2856
+ e,
2833
2857
  async () => {
2834
2858
  if (await this.updateTabState(!0), console.log(
2835
2859
  `BackgroundWorker: захват лидерства, пауза ${this.leaderConfirmDelay} мс перед запуском`
@@ -2840,25 +2864,25 @@ class Be {
2840
2864
  return;
2841
2865
  }
2842
2866
  this.hasStarted = !0;
2843
- const l = this.leaderHeartbeatMs ?? Math.min(
2867
+ const i = this.leaderHeartbeatMs ?? Math.min(
2844
2868
  this.activeMaxPause - 1500,
2845
2869
  Math.max(2500, Math.floor(this.pollInterval / 2))
2846
2870
  );
2847
2871
  this.runHeartbeat = setInterval(
2848
2872
  () => {
2849
2873
  this.updateTabState(!0).catch(
2850
- (h) => console.error(
2874
+ (a) => console.error(
2851
2875
  "BackgroundWorker: heartbeat update failed",
2852
- h
2876
+ a
2853
2877
  )
2854
2878
  );
2855
2879
  },
2856
- l
2880
+ i
2857
2881
  );
2858
2882
  try {
2859
2883
  await this.appInit();
2860
- } catch (h) {
2861
- console.error("BackgroundWorker: appInit failed", h);
2884
+ } catch (a) {
2885
+ console.error("BackgroundWorker: appInit failed", a);
2862
2886
  }
2863
2887
  this.stopTimers(), this.id && (await this.deleteTabs([{ id: this.id }]), this.id = 0);
2864
2888
  },
@@ -2868,15 +2892,15 @@ class Be {
2868
2892
  );
2869
2893
  }
2870
2894
  async setBackgroundWorkerAll() {
2871
- var M, p, b, H;
2872
- if (!((M = this.bx) != null && M.isAdmin)) {
2895
+ var k, T, M, G;
2896
+ if (!((k = this.bx) != null && k.isAdmin)) {
2873
2897
  console.log(
2874
2898
  "BackgroundWorker: setBackgroundWorkerAll доступен только админам"
2875
2899
  );
2876
2900
  return;
2877
2901
  }
2878
- (p = this.users) != null && p.length || await this.getEntityData(), qt(this.bx);
2879
- const e = _(this, Nt, Vt).call(this, ((H = (b = this.bx) == null ? void 0 : b.appConst) == null ? void 0 : H.pathApp) ?? "");
2902
+ (T = this.users) != null && T.length || await this.getEntityData(), se(this.bx);
2903
+ const e = y(this, Et, ae).call(this, ((G = (M = this.bx) == null ? void 0 : M.appConst) == null ? void 0 : G.pathApp) ?? "");
2880
2904
  if (!e) {
2881
2905
  console.error(
2882
2906
  "BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
@@ -2891,50 +2915,53 @@ class Be {
2891
2915
  if (N.placement !== "PAGE_BACKGROUND_WORKER")
2892
2916
  return;
2893
2917
  if (N.userId || N.handler && N.handler.includes("USER_ID=")) {
2894
- const L = N.userId || (N.handler ? this.extractUserIdFromHandler(N.handler) : null);
2895
- if (L) {
2896
- const w = +L;
2897
- r.set(w, N), i.has(w) || i.set(w, []), i.get(w).push(N);
2918
+ const I = N.userId || (N.handler ? this.extractUserIdFromHandler(N.handler) : null);
2919
+ if (I) {
2920
+ const C = +I;
2921
+ r.set(C, N), i.has(C) || i.set(C, []), i.get(C).push(N);
2898
2922
  }
2899
2923
  } else
2900
2924
  a = N;
2901
2925
  });
2902
- const c = await this.resolveAdmins(), l = await this.getEligibleUsersForBackgroundWorker(c);
2903
- l.sort((N, I) => {
2904
- const L = N.LAST_LOGIN ? new Date(N.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
2905
- return (I.LAST_LOGIN ? new Date(I.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - L;
2926
+ const c = await this.resolveAdmins(), h = await this.getEligibleUsersForBackgroundWorker(c);
2927
+ h.sort((N, S) => {
2928
+ const I = N.LAST_LOGIN ? new Date(N.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
2929
+ return (S.LAST_LOGIN ? new Date(S.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - I;
2906
2930
  });
2907
- const h = 10, n = l.slice(0, h), f = n.filter((N) => {
2908
- const I = r.get(+N.ID);
2909
- if (!I)
2931
+ const f = 10, n = this.coordinationScope === "portal" ? [] : h.slice(0, f), u = n.filter((N) => {
2932
+ const S = r.get(+N.ID);
2933
+ if (!S)
2910
2934
  return !0;
2911
- const L = `${e}?USER_ID=${N.ID}/`;
2912
- return I.handler !== L;
2913
- }), m = [];
2935
+ const I = `${e}?USER_ID=${N.ID}/`;
2936
+ return S.handler !== I;
2937
+ }), d = [];
2938
+ if (this.coordinationScope === "portal")
2939
+ for (const N of r.keys())
2940
+ d.push(+N);
2914
2941
  for (const [N] of r) {
2915
- const I = +N || 0;
2916
- l.find((w) => +w.ID === I) || m.push(I);
2942
+ const S = +N || 0;
2943
+ h.find((C) => +C.ID === S) || d.push(S);
2917
2944
  }
2918
2945
  for (const N of n) {
2919
- const I = r.get(+N.ID);
2920
- if (!I)
2946
+ const S = r.get(+N.ID);
2947
+ if (!S)
2921
2948
  continue;
2922
- const L = `${e}?USER_ID=${N.ID}/`;
2923
- I.handler !== L && m.push(+N.ID);
2949
+ const I = `${e}?USER_ID=${N.ID}/`;
2950
+ S.handler !== I && d.push(+N.ID);
2924
2951
  }
2925
- const A = [], u = [...new Set(m)];
2926
- for (const N of u) {
2927
- const I = i.get(+N) || [];
2928
- for (const L of I)
2929
- L != null && L.handler && A.push({
2952
+ const A = [], l = [...new Set(d)];
2953
+ for (const N of l) {
2954
+ const S = i.get(+N) || [];
2955
+ for (const I of S)
2956
+ I != null && I.handler && A.push({
2930
2957
  method: "placement.unbind",
2931
2958
  params: {
2932
2959
  PLACEMENT: "PAGE_BACKGROUND_WORKER",
2933
- HANDLER: L.handler
2960
+ HANDLER: I.handler
2934
2961
  }
2935
2962
  });
2936
2963
  }
2937
- const O = a && (f.length > 0 || a.handler !== `${e}`);
2964
+ const O = a && (u.length > 0 || a.handler !== `${e}`);
2938
2965
  O && A.push({
2939
2966
  method: "placement.unbind",
2940
2967
  params: {
@@ -2942,7 +2969,7 @@ class Be {
2942
2969
  HANDLER: a.handler || `${e}`
2943
2970
  }
2944
2971
  });
2945
- for (const N of f)
2972
+ for (const N of u)
2946
2973
  A.push({
2947
2974
  method: "placement.bind",
2948
2975
  params: {
@@ -2964,21 +2991,21 @@ class Be {
2964
2991
  OPTIONS: { errorHandlerUrl: `${e}` }
2965
2992
  }
2966
2993
  });
2967
- const T = A.filter(
2994
+ const _ = A.filter(
2968
2995
  (N) => N.method === "placement.unbind"
2969
- ), E = A.filter(
2996
+ ), b = A.filter(
2970
2997
  (N) => N.method === "placement.bind"
2971
2998
  );
2972
- T.length && await this.safeCall(
2999
+ _.length && await this.safeCall(
2973
3000
  () => this.bx.batch(
2974
3001
  Object.fromEntries(
2975
- T.map((N, I) => [`unbind_${I}`, N])
3002
+ _.map((N, S) => [`unbind_${S}`, N])
2976
3003
  )
2977
3004
  )
2978
- ), E.length && await this.safeCall(
3005
+ ), b.length && await this.safeCall(
2979
3006
  () => this.bx.batch(
2980
3007
  Object.fromEntries(
2981
- E.map((N, I) => [`bind_${I}`, N])
3008
+ b.map((N, S) => [`bind_${S}`, N])
2982
3009
  )
2983
3010
  )
2984
3011
  ), A.length || console.log("setBackgroundWorkerAll: Нет операций");
@@ -2989,17 +3016,17 @@ class Be {
2989
3016
  const r = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0), i = !!((t = this.bx) != null && t.isAdmin), a = await this.getAdminsList() || [];
2990
3017
  if (!i) {
2991
3018
  if (r && a.includes(+r)) {
2992
- const h = a.filter(
3019
+ const f = a.filter(
2993
3020
  (n) => +n != +r
2994
3021
  );
2995
- return await this.saveAdminsList(h), h;
3022
+ return await this.saveAdminsList(f), f;
2996
3023
  }
2997
3024
  return a;
2998
3025
  }
2999
3026
  const c = /* @__PURE__ */ new Set([...a || []]);
3000
3027
  r && c.add(+r);
3001
- const l = [...c].filter(Boolean);
3002
- return await this.saveAdminsList(l), l;
3028
+ const h = [...c].filter(Boolean);
3029
+ return await this.saveAdminsList(h), h;
3003
3030
  } catch (r) {
3004
3031
  return console.error("BackgroundWorker: resolveAdmins error", r), [];
3005
3032
  }
@@ -3057,28 +3084,33 @@ class Be {
3057
3084
  }
3058
3085
  }
3059
3086
  }
3060
- xt = new WeakSet(), pe = function(e) {
3061
- const t = De(e);
3087
+ Kt = new WeakSet(), Re = function(e) {
3088
+ const t = xe(e);
3062
3089
  this.startDelay = t.startDelayMs, this.leaderConfirmDelay = t.leaderConfirmDelayMs, this.activeMaxPause = t.activeMaxPauseMs, this.quickCleanupThreshold = t.quickCleanupThresholdMs, this.pollIntervalBase = t.pollIntervalMs, this.pollIntervalJitter = t.pollIntervalJitterMs, this.pollInterval = t.pollIntervalMs + (t.pollIntervalJitterMs > 0 ? Math.floor(Math.random() * t.pollIntervalJitterMs) : 0), this.leaderHeartbeatMs = t.leaderHeartbeatMs;
3063
3090
  const r = t.pollIntervalMs + t.pollIntervalJitterMs + t.leaderConfirmDelayMs;
3064
3091
  t.activeMaxPauseMs < r && console.warn(
3065
3092
  `BackgroundWorker: activeMaxPauseMs (${t.activeMaxPauseMs}) меньше poll+jitter+leaderConfirm (${r}) — «живые» вкладки могут удаляться раньше следующего тика`
3066
3093
  );
3067
- }, Nt = new WeakSet(), Vt = function(e) {
3094
+ }, Et = new WeakSet(), ae = function(e) {
3068
3095
  if (!e || typeof e != "string")
3069
3096
  return "";
3070
- const t = $t(e).replace(/\/+$/, "");
3071
- return t ? le(t) ? (console.error(
3097
+ const t = oe(e).replace(/\/+$/, "");
3098
+ return t ? Ne(t) ? (console.error(
3072
3099
  "BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
3073
3100
  ), "") : t : "";
3101
+ }, nt = new WeakSet(), mt = function() {
3102
+ var e, t;
3103
+ return this.coordinationScope === "portal" ? `${this.appCodeName || "app"}:portal` : String(((t = (e = this.bx) == null ? void 0 : e.userInfo) == null ? void 0 : t.ID) ?? "");
3104
+ }, qt = new WeakSet(), Se = function() {
3105
+ return `background-worker:${this.entityName}:${y(this, nt, mt).call(this)}`;
3074
3106
  };
3075
3107
  export {
3076
- Be as BackgroundWorker,
3108
+ Xe as BackgroundWorker,
3077
3109
  K as Batch,
3078
- we as BxBoot,
3079
- ne as BxHelper,
3080
- be as BxLogger,
3110
+ ve as BxBoot,
3111
+ de as BxHelper,
3112
+ Ce as BxLogger,
3081
3113
  q as DEFAULT_BACKGROUND_WORKER_TIMING,
3082
- De as resolveBackgroundWorkerTiming,
3083
- Ot as tempus
3114
+ xe as resolveBackgroundWorkerTiming,
3115
+ bt as tempus
3084
3116
  };