szdl-utils-kit 0.3.25 → 0.3.28

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 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))
1
+ var ke = Object.defineProperty;
2
+ var we = (d, e, t) => e in d ? ke(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
3
+ var w = (d, e, t) => (we(d, typeof e != "symbol" ? e + "" : e, t), t), Qt = (d, e, t) => {
4
+ if (!e.has(d))
5
5
  throw TypeError("Cannot " + t);
6
6
  };
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))
7
+ var b = (d, e, t) => (Qt(d, e, "read from private field"), t ? t.call(d) : e.get(d)), E = (d, e, t) => {
8
+ if (e.has(d))
9
9
  throw TypeError("Cannot add the same private member more than once");
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;
10
+ e instanceof WeakSet ? e.add(d) : e.set(d, t);
11
+ }, x = (d, e, t, r) => (Qt(d, e, "write to private field"), r ? r.call(d, t) : e.set(d, t), t);
12
+ var p = (d, e, t) => (Qt(d, e, "access private method"), t);
13
+ var Ce = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
14
+ function Be(d) {
15
+ return d && d.__esModule && Object.prototype.hasOwnProperty.call(d, "default") ? d.default : d;
16
16
  }
17
- var Vt = { exports: {} };
18
- (function(m, e) {
17
+ var $t = { exports: {} };
18
+ (function(d, e) {
19
19
  (function(t) {
20
20
  Array.prototype.indexOf || (Array.prototype.indexOf = function(s, o) {
21
- var g, p;
22
- for (g = o || 0, p = this.length; g < p; g += 1)
23
- if (this[g] === s)
24
- return g;
21
+ var m, y;
22
+ for (m = o || 0, y = this.length; m < y; m += 1)
23
+ if (this[m] === s)
24
+ return m;
25
25
  return -1;
26
26
  });
27
27
  var r = this, i = function(s, o) {
28
- for (var g = s.toString(); g.length < o; )
29
- g = "0" + g;
30
- return g;
28
+ for (var m = s.toString(); m.length < o; )
29
+ m = "0" + m;
30
+ return m;
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
- }, c = function(s, o) {
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;
33
+ }, l = function(s, o) {
34
+ var m, y = "";
35
+ return m = s.slice(o, o + 1), m !== "" && !isNaN(Number(m)) && (y += "%H"), m = s.charAt(o + 2), m !== "" && m === ":" && (y += m), m = s.slice(o + 3, o + 4), m !== "" && !isNaN(Number(m)) && (y += "%M"), m = s.charAt(o + 5), m !== "" && m === ":" && (y += m), m = s.slice(o + 6, o + 7), m !== "" && !isNaN(Number(m)) && (y += "%S"), y;
36
36
  }, h = function(s, o) {
37
- var g, p = [
37
+ var m, y = [
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
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 = [
44
+ return !isNaN(Number(y[0])) && !isNaN(Number(y[2])) && !isNaN(Number(y[4])) ? (y[1] === "." && y[3] === "." ? m = "%d.%m.%Y" : y[1] === "-" && y[3] === "-" ? m = "%m-%d-%Y" : y[1] === "/" && y[3] === "/" && (m = "%m/%d/%Y"), m) : (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(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 = {
50
+ ], !isNaN(Number(H[0])) && !isNaN(Number(H[2])) && !isNaN(Number(H[4])) ? (H[1] === "-" && H[3] === "-" && (m = "%Y-%m-%d"), m) : "");
51
+ }, u = r.tempus, n, g, f = r.navigator || {}, A = "en", c = {
52
52
  en: {
53
53
  JANUARY_SHORT: "Jan",
54
54
  FEBRUARY_SHORT: "Feb",
@@ -209,62 +209,62 @@ var Vt = { exports: {} };
209
209
  FRIDAY_LONG: "Freitag",
210
210
  SATURDAY_LONG: "Samstag"
211
211
  }
212
- }, O = function() {
212
+ }, N = function() {
213
213
  return [
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
214
+ c[A].JANUARY_LONG,
215
+ c[A].FEBRUARY_LONG,
216
+ c[A].MARCH_LONG,
217
+ c[A].APRIL_LONG,
218
+ c[A].MAY_LONG,
219
+ c[A].JUNE_LONG,
220
+ c[A].JULY_LONG,
221
+ c[A].AUGUST_LONG,
222
+ c[A].SEPTEMBER_LONG,
223
+ c[A].OCTOBER_LONG,
224
+ c[A].NOVEMBER_LONG,
225
+ c[A].DECEMBER_LONG
226
226
  ];
227
227
  }, _ = function() {
228
228
  return [
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
229
+ c[A].JANUARY_SHORT,
230
+ c[A].FEBRUARY_SHORT,
231
+ c[A].MARCH_SHORT,
232
+ c[A].APRIL_SHORT,
233
+ c[A].MAY_SHORT,
234
+ c[A].JUNE_SHORT,
235
+ c[A].JULY_SHORT,
236
+ c[A].AUGUST_SHORT,
237
+ c[A].SEPTEMBER_SHORT,
238
+ c[A].OCTOBER_SHORT,
239
+ c[A].NOVEMBER_SHORT,
240
+ c[A].DECEMBER_SHORT
241
241
  ];
242
- }, b = function() {
242
+ }, R = function() {
243
243
  return [
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
244
+ c[A].SUNDAY_LONG,
245
+ c[A].MONDAY_LONG,
246
+ c[A].TUESDAY_LONG,
247
+ c[A].WEDNESDAY_LONG,
248
+ c[A].THURSDAY_LONG,
249
+ c[A].FRIDAY_LONG,
250
+ c[A].SATURDAY_LONG
251
251
  ];
252
252
  }, k = function() {
253
253
  return [
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
254
+ c[A].SUNDAY_SHORT,
255
+ c[A].MONDAY_SHORT,
256
+ c[A].TUESDAY_SHORT,
257
+ c[A].WEDNESDAY_SHORT,
258
+ c[A].THURSDAY_SHORT,
259
+ c[A].FRIDAY_SHORT,
260
+ c[A].SATURDAY_SHORT
261
261
  ];
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();
262
+ }, T, L, G, O, S = function(s, o, m) {
263
+ var y;
264
+ r.XMLHttpRequest ? y = new XMLHttpRequest() : y = new ActiveXObject("Microsoft.XMLHTTP"), y.onreadystatechange = function() {
265
+ y.readyState === 4 && (y.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(y.responseText))) : m && m(y));
267
+ }, y.open("GET", s, !1), y.send();
268
268
  }, I = {
269
269
  "%d": {
270
270
  format: function(s) {
@@ -316,7 +316,7 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
316
316
  "%a": {
317
317
  format: function(s) {
318
318
  var o = s.dayOfWeek();
319
- return N[o !== t ? o : n.MIN_DAY_OF_WEEK];
319
+ return O[o !== t ? o : n.MIN_DAY_OF_WEEK];
320
320
  },
321
321
  parse: function() {
322
322
  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 M[o !== t ? o : n.MIN_MONTH];
343
+ return L[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);
@@ -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)), g = Number(s.slice(5, 7)), p = Number(s.slice(8, 10));
418
+ var o = Number(s.slice(0, 4)), m = Number(s.slice(5, 7)), y = Number(s.slice(8, 10));
419
419
  return {
420
420
  year: o,
421
- month: g,
422
- day: p
421
+ month: m,
422
+ day: y
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)), g = Number(s.slice(3, 5)), p = Number(s.slice(6, 10));
434
+ var o = Number(s.slice(0, 2)), m = Number(s.slice(3, 5)), y = Number(s.slice(6, 10));
435
435
  return {
436
- year: p,
436
+ year: y,
437
437
  month: o,
438
- day: g
438
+ day: m
439
439
  };
440
440
  },
441
441
  minLength: 10,
442
442
  maxLength: 10,
443
443
  type: "string"
444
444
  }
445
- }, C = {
445
+ }, B = {
446
446
  useMilliseconds: !1,
447
447
  monthFromZero: !1
448
- }, R;
449
- R = function(s, o, g) {
448
+ }, M;
449
+ M = function(s, o, m) {
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, g), this;
459
- }, R.fn = R.prototype, R.fn.dayCount = function() {
458
+ }, s !== t && this.set(s, o, m), this;
459
+ }, M.fn = M.prototype, M.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
- }, R.fn.year = function(s) {
462
+ }, M.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
- }, R.fn.month = function(s) {
468
+ }, M.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
- }, R.fn.day = function(s) {
474
+ }, M.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
- }, R.fn.hours = function(s) {
480
+ }, M.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
- }, R.fn.minutes = function(s) {
486
+ }, M.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
- }, R.fn.seconds = function(s) {
492
+ }, M.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
- }, R.fn.milliseconds = function(s) {
498
+ }, M.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
- }, R.fn.week = function() {
504
+ }, M.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
- }, R.fn.set = function(s, o, g) {
507
+ }, M.fn.set = function(s, o, m) {
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 p, H = [], D, B, Q = [], W = 0, F = 0, U, X, P = {}, Y;
523
+ var y, H = [], D, C, Q = [], W = 0, F = 0, U, X, P = {}, Y;
524
524
  if (s === t)
525
- return D = a(this, g), D === t && (this._i = {
525
+ return D = a(this, m), 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 (B = o.charAt(W) + o.charAt(W + 1), I[B] !== t) {
537
- switch (U = 0, X = "", I[B].type) {
536
+ if (C = o.charAt(W) + o.charAt(W + 1), I[C] !== t) {
537
+ switch (U = 0, X = "", I[C].type) {
538
538
  case "number":
539
- for (; U < I[B].maxLength && F + U < s.length && !isNaN(Number(s.charAt(F + U))); )
539
+ for (; U < I[C].maxLength && F + U < s.length && !isNaN(Number(s.charAt(F + U))); )
540
540
  X += s.charAt(F + U), U += 1;
541
541
  break;
542
542
  case "word":
543
- for (; U < I[B].maxLength && F + U < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + U)); )
543
+ for (; U < I[C].maxLength && F + U < s.length && /^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(s.charAt(F + U)); )
544
544
  X += s.charAt(F + U), U += 1;
545
545
  break;
546
546
  case "string":
547
- for (; U < I[B].maxLength && F + U < s.length; )
547
+ for (; U < I[C].maxLength && F + U < s.length; )
548
548
  X += s.charAt(F + U), U += 1;
549
549
  break;
550
550
  }
551
- if (U < I[B].minLength)
552
- return D = a(this, g), D === t && (this._i = {
551
+ if (U < I[C].minLength)
552
+ return D = a(this, m), 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
- H.push(B), Q.push(X), U -= 1, F += U, W += 1;
561
+ H.push(C), 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, g), D === t && (this._i = {
564
+ return D = a(this, m), D === t && (this._i = {
565
565
  year: -1,
566
566
  month: -1,
567
567
  day: -1,
@@ -572,8 +572,8 @@ 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 (p in H)
576
- H.hasOwnProperty(p) && I.hasOwnProperty(H[p]) && (Y = I[H[p]].parse(Q[p]), P = {
575
+ for (y in H)
576
+ H.hasOwnProperty(y) && I.hasOwnProperty(H[y]) && (Y = I[H[y]].parse(Q[y]), P = {
577
577
  year: Y.year !== t ? Y.year : P.year,
578
578
  month: Y.month !== t ? Y.month : P.month,
579
579
  day: Y.day !== t ? Y.day : P.day,
@@ -584,18 +584,18 @@ https://github.com/douglascrockford/JSON-js/blob/master/json2.js`) : o(JSON.pars
584
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
- }, R.fn.leapYear = function() {
587
+ }, M.fn.leapYear = function() {
588
588
  var s = this.year();
589
589
  return s % 4 === 0 ? s % 100 === 0 ? s % 400 === 0 : !0 : !1;
590
- }, R.fn.timestamp = function(s) {
590
+ }, M.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
- }, R.fn.utc = function(s) {
592
+ }, M.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
- }, R.fn.dayOfWeek = function(s) {
594
+ }, M.fn.dayOfWeek = function(s) {
595
595
  if (s === "long")
596
596
  return G[this._d.getDay()];
597
597
  if (s === "short")
598
- return N[this._d.getDay()];
598
+ return O[this._d.getDay()];
599
599
  if (s === t)
600
600
  return this._d.getDay();
601
601
  if (s === 0 || s === "Sunday")
@@ -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
- }, R.fn.timezone = function(s) {
615
+ }, M.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
- }, R.fn.get = function(s) {
624
+ }, M.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
- }, 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() {
673
+ }, M.fn.format = function(s) {
674
+ for (var o = 0, m = "", y; o < s.length; )
675
+ s.charAt(o) === "%" ? (y = s.charAt(o) + s.charAt(o + 1), I[y] !== t ? (m += I[y].format(this), o += 1) : m += "%") : m += s.charAt(o), o += 1;
676
+ return m;
677
+ }, M.fn.valid = function() {
678
678
  return this._i.year === !1 && this._i.month === !1 && this._i.day === !1 && this._i.hours === !1 && this._i.minutes === !1 && this._i.seconds === !1 && this._i.milliseconds === !1;
679
- }, R.fn.errors = function() {
679
+ }, M.fn.errors = function() {
680
680
  return this._i;
681
- }, R.fn.between = function(s, o) {
682
- var g = this.timestamp(), p = s.timestamp();
681
+ }, M.fn.between = function(s, o) {
682
+ var m = this.timestamp(), y = s.timestamp();
683
683
  switch (o) {
684
684
  case "year":
685
- return Math.floor((p - g) / 31556952);
685
+ return Math.floor((y - m) / 31556952);
686
686
  case "month":
687
- return Math.floor((p - g) / 2629746);
687
+ return Math.floor((y - m) / 2629746);
688
688
  case "day":
689
- return Math.floor((p - g) / 86400);
689
+ return Math.floor((y - m) / 86400);
690
690
  case "hours":
691
- return Math.floor((p - g) / 3600);
691
+ return Math.floor((y - m) / 3600);
692
692
  case "minutes":
693
- return Math.floor((p - g) / 60);
693
+ return Math.floor((y - m) / 60);
694
694
  case "seconds":
695
- return p - g;
695
+ return y - m;
696
696
  default:
697
697
  return t;
698
698
  }
699
- }, R.fn.calc = function(s) {
699
+ }, M.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, g) {
702
- return new R(s, o, g);
701
+ }, n = function(s, o, m) {
702
+ return new M(s, o, m);
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 C;
706
- if (C.hasOwnProperty(s)) {
705
+ return B;
706
+ if (B.hasOwnProperty(s)) {
707
707
  if (o === t)
708
- return C[s];
709
- C[s] = o, s === "monthFromZero" && (n.MIN_MONTH = o ? 0 : 1, n.MAX_MONTH = o ? 11 : 12);
708
+ return B[s];
709
+ B[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 = f, n;
713
+ return r.tempus = u, n;
714
714
  }, n.generate = function(s) {
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 = {
715
+ var o, m, y, H, D, C, Q, W;
716
+ if (typeof s.dateFrom != "number" && (s.dateFrom instanceof M ? o = s.dateFrom.utc() : o = n(s.dateFrom, s.formatFrom).utc()), typeof s.dateTo != "number" && (s.dateTo instanceof M ? m = s.dateTo.utc() : m = 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,7 +734,7 @@ 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 ? B = s.asObject === !0 ? {} : [] : (B = [], B.push([]), Q = n(o).get()[s.groupBy]), W = function(X, P, Y) {
737
+ }), s.groupBy === t ? C = s.asObject === !0 ? {} : [] : (C = [], C.push([]), Q = n(o).get()[s.groupBy]), W = function(X, P, Y) {
738
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 = {
@@ -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 (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();
749
+ for (y = n(o).calc(F).utc(); n(y).get()[s.groupBy] === Q; )
750
+ W(C[C.length - 1], y, !0), y = n(y).calc(F).utc();
751
751
  if (s.groupBy === "week") {
752
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();
753
+ for (y = n(o).dayOfWeek(0).utc(); C[0].length < U && y < o; )
754
+ W(C[C.length - 1], y, !0), y = n(y).calc(D).utc();
755
755
  }
756
756
  }
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();
757
+ for (; o <= m; )
758
+ s.groupBy === t ? W(C, o) : n(o).get()[s.groupBy] === Q ? W(C[C.length - 1], o) : (C.push([]), W(C[C.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 (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;
760
+ for (H = n(m).calc(D).utc(); n(H).get()[s.groupBy] === Q; )
761
+ W(C[C.length - 1], H, !0), H = n(H).calc(D).utc();
762
+ return C;
763
763
  }, n.monthNames = function(s) {
764
764
  switch (s) {
765
765
  case "long":
766
766
  return T;
767
767
  default:
768
- return M;
768
+ return L;
769
769
  }
770
770
  }, n.dayNames = function(s) {
771
771
  switch (s) {
772
772
  case "long":
773
773
  return G;
774
774
  default:
775
- return N;
775
+ return O;
776
776
  }
777
777
  }, n.lang = function(s) {
778
778
  if (s !== t)
779
- A = s, l[A] === t && (A = "en"), T = O(), M = _(), G = b(), N = k();
779
+ A = s, c[A] === t && (A = "en"), T = N(), L = _(), G = R(), O = k();
780
780
  else
781
781
  return A;
782
782
  return t;
783
783
  }, n.availableLangs = function() {
784
- return Object.keys(l);
785
- }, n.registerFormat = function(s, o, g, p, H, D) {
784
+ return Object.keys(c);
785
+ }, n.registerFormat = function(s, o, m, y, H, D) {
786
786
  I[s] = {
787
787
  format: o,
788
- parse: g,
789
- minLength: p,
788
+ parse: m,
789
+ minLength: y,
790
790
  maxLength: H,
791
791
  type: D
792
792
  };
793
793
  }, n.unregisterFormat = function(s) {
794
794
  delete I[s];
795
795
  }, n.detectFormat = function(s) {
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
796
+ var o, m, y;
797
+ return o = h(s, 0), o !== "" && (y = 10), m = s.charAt(y), (m === "T" || m === " ") && (o += m, y += 1), o += l(s, y), o;
798
+ }, g = {
799
+ TempusDate: M
800
800
  }, n.classes = function(s, o) {
801
801
  if (o === t)
802
- return u[s];
803
- u[s] = o;
802
+ return g[s];
803
+ g[s] = o;
804
804
  }, n.loadTranslations = function(s) {
805
- typeof s == "object" ? l = s : typeof s == "string" && S(s, function(o) {
806
- l = o;
805
+ typeof s == "object" ? c = s : typeof s == "string" && S(s, function(o) {
806
+ c = o;
807
807
  }, function(o) {
808
808
  });
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;
809
+ }, A = (f.language || f.systemLanguage || f.userLanguage || "en").substr(0, 2).toLowerCase(), c[A] === t && (A = "en"), T = N(), L = _(), G = R(), O = k(), d.exports && (e = d.exports = n), e.tempus = n;
810
+ }).call(Ce);
811
+ })($t, $t.exports);
812
+ var He = $t.exports;
813
+ const Lt = /* @__PURE__ */ Be(He);
814
+ var It, he, Dt, kt, wt, Ct, ot, bt, Bt, ue, Ht, fe, $, ut, tt, ft, gt, te, et, dt, Ut, de, Pt, me, At, Mt, yt, ee, pt, se;
815
815
  const J = class J {
816
816
  constructor(e) {
817
817
  /**
@@ -820,12 +820,12 @@ const J = class J {
820
820
  * формула sum(count)/sum(total)×chunkRate (один длинный list, batchTotalCount, смешанные batch).
821
821
  * @returns {boolean}
822
822
  */
823
- E(this, St);
823
+ E(this, It);
824
824
  /**
825
825
  * Одно обновление колбэка прогресса, если снимок изменился.
826
826
  * @returns {void}
827
827
  */
828
- E(this, At);
828
+ E(this, ot);
829
829
  /**
830
830
  * Проверяет, изменились ли метрики прогресса относительно предыдущей отправки.
831
831
  *
@@ -838,7 +838,7 @@ const J = class J {
838
838
  *
839
839
  * @returns {void}
840
840
  */
841
- E(this, Ct);
841
+ E(this, Ht);
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
- E(this, Z);
849
+ E(this, $);
850
850
  /**
851
851
  * Проверяет operating-time в результате batch и ставит паузу,
852
852
  * если сервер приблизился к лимиту выполнения.
@@ -855,6 +855,21 @@ const J = class J {
855
855
  * @returns {Promise<number>} Максимальный operating-time среди команд.
856
856
  */
857
857
  E(this, tt);
858
+ /**
859
+ * Состояние приёма «опоздавших» ответов callBatch после клиентского таймаута.
860
+ * Живёт на весь цикл ретраев одного chunk — ответ от более ранней попытки
861
+ * принимается, пока chunk ещё не завершён успешно.
862
+ * @returns {{
863
+ * inRetryCycle: boolean,
864
+ * inTimeoutWait: boolean,
865
+ * lateResult: Object|null,
866
+ * lateWaiters: Array<(result: Object) => void>,
867
+ * notifyLateResponse: (result: Object) => void,
868
+ * waitForLateOrLimit: () => Promise<void>,
869
+ * resetLateResult: () => void,
870
+ * }}
871
+ */
872
+ E(this, gt);
858
873
  /**
859
874
  * Выполняет один chunk с автоматическим повтором после лимит-паузы.
860
875
  * Повтор запускается при ошибках QUERY_LIMIT_EXCEEDED, OPERATION_TIME_LIMIT или TIMEOUT.
@@ -869,18 +884,19 @@ const J = class J {
869
884
  *
870
885
  * @param {string} method - Имя REST-метода.
871
886
  * @param {Object} params - Параметры REST-метода.
887
+ * @param {{ onLateResponse?: (result: Object) => void }} [options] - `onLateResponse` — ответ после клиентского таймаута
872
888
  * @returns {Promise<Object|null>} Raw-result BX24 или null при таймауте/ошибке вызова.
873
889
  */
874
- E(this, Ht);
890
+ E(this, Ut);
875
891
  /**
876
892
  * Код и текст ошибки подкоманды batch.
877
893
  * `errorsList` по-прежнему отдаёт коды; описания — в `errorsListMessages`.
878
894
  * @param {{ error?: () => { ex?: { error?: string, error_description?: string }, toString?: () => string } | null }} value
879
895
  * @returns {{ code: string, message: string }}
880
896
  */
881
- E(this, Ut);
882
- E(this, ct);
883
- E(this, gt);
897
+ E(this, Pt);
898
+ E(this, At);
899
+ E(this, yt);
884
900
  /**
885
901
  * Resets mutable runtime state before each public batch run.
886
902
  * @param {Function} progressCall - Progress callback for current run.
@@ -901,31 +917,31 @@ const J = class J {
901
917
  if (!this.progressData)
902
918
  return { percent: 0, allCount: 0, allTotal: 0 };
903
919
  const e = this.totalBatchCommands || 0;
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];
908
- if (!O)
920
+ if (e > 0 && Array.isArray(this.batchCommandKeyOrder) && this.batchCommandKeyOrder.length && p(this, It, he).call(this)) {
921
+ let u = 0;
922
+ for (const c of this.batchCommandKeyOrder) {
923
+ const N = this.progressData[c];
924
+ if (!N)
909
925
  continue;
910
- const _ = Number(O.total) || 0, b = Number(O.count) || 0;
911
- _ === 0 && b === 0 ? f += 1 : _ > 0 && (f += Math.min(1, b / _));
926
+ const _ = Number(N.total) || 0, R = Number(N.count) || 0;
927
+ _ === 0 && R === 0 ? u += 1 : _ > 0 && (u += Math.min(1, R / _));
912
928
  }
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 };
929
+ const n = u / e * 100;
930
+ let g = Math.max(0, Math.min(100, Math.floor(n)));
931
+ const f = e, A = Math.min(e, Math.floor(u));
932
+ return { percent: g, allCount: A, allTotal: f };
917
933
  }
918
934
  let t = 0, r = 0;
919
- for (const f of Object.values(this.progressData)) {
920
- const { total: n, count: u } = f;
921
- t += n ?? 0, r += u ?? 0;
935
+ for (const u of Object.values(this.progressData)) {
936
+ const { total: n, count: g } = u;
937
+ t += n ?? 0, r += g ?? 0;
922
938
  }
923
939
  const i = Number(this.chunkRate) || 0;
924
940
  let a = 0;
925
941
  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));
926
- let c = Math.floor(a);
942
+ let l = Math.floor(a);
927
943
  const h = Number(this.chunkRate) || 0;
928
- return t > 0 && r >= t && h >= 1 && (c = 100), { percent: c, allCount: r, allTotal: t };
944
+ return t > 0 && r >= t && h >= 1 && (l = 100), { percent: l, allCount: r, allTotal: t };
929
945
  }
930
946
  /**
931
947
  * Обновление данных прогресса выполнения
@@ -935,34 +951,34 @@ const J = class J {
935
951
  * @param {string} params.type - Тип обработки ('count' или undefined)
936
952
  */
937
953
  setProgressData({ key: e, value: t, type: r }) {
938
- var l, O;
954
+ var c, N;
939
955
  if (!this.progressCall)
940
956
  return;
941
957
  const i = this.getData(t.data()), a = Array.isArray(i) ? i.length : 0;
942
- let c = a;
958
+ let l = a;
943
959
  if (typeof t.total == "function") {
944
960
  const _ = t.total();
945
961
  if (_ != null && _ !== "") {
946
- const b = Number(_);
947
- Number.isFinite(b) && (c = b);
962
+ const R = Number(_);
963
+ Number.isFinite(R) && (l = R);
948
964
  }
949
965
  }
950
966
  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);
967
+ r === "count" ? (l || (l = a), h = l > 0 ? l : a > 0 ? a : 1) : i && (h = a), this.progressData || (this.progressData = {});
968
+ const u = ((c = this.progressData[e]) == null ? void 0 : c.total) ?? 0, n = ((N = this.progressData[e]) == null ? void 0 : N.count) ?? 0, g = h + n, f = Math.max(u, l ?? 0, g);
953
969
  if (this.progressData[e] = {
954
- total: d,
955
- count: Math.min(u, d)
970
+ total: f,
971
+ count: Math.min(g, f)
956
972
  }, typeof document < "u" && (document == null ? void 0 : document.hidden) === !0) {
957
- y(this, At, Mt).call(this);
973
+ p(this, ot, bt).call(this);
958
974
  return;
959
975
  }
960
- y(this, At, Mt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
976
+ p(this, ot, bt).call(this), this.progressTimer || (this.progressTimer = setInterval(() => {
961
977
  if (!this.progressCall) {
962
978
  this.clearProgressData();
963
979
  return;
964
980
  }
965
- y(this, At, Mt).call(this);
981
+ p(this, ot, bt).call(this);
966
982
  const { percent: _ } = this.progressPercent;
967
983
  _ >= 100 && (clearInterval(this.progressTimer), this.progressTimer = "");
968
984
  }, this.progressDelay));
@@ -987,7 +1003,7 @@ const J = class J {
987
1003
  * @returns {void}
988
1004
  */
989
1005
  setTimeLimitState(e, t, r) {
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);
1006
+ 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, p(this, Ht, fe).call(this);
991
1007
  }
992
1008
  /**
993
1009
  * Подписывает внешний код на изменения состояния лимита.
@@ -1020,20 +1036,20 @@ const J = class J {
1020
1036
  const a = i.filter || i.FILTER;
1021
1037
  if (!a || typeof a != "object" || Array.isArray(a))
1022
1038
  return [{ key: e, request: t }];
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 = [];
1039
+ for (const [l, h] of Object.entries(a))
1040
+ if (!String(l).trim().startsWith("!") && Array.isArray(h) && h.length > this.filterChunkSize) {
1041
+ const u = [];
1026
1042
  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,
1043
+ const g = h.slice(n, n + this.filterChunkSize), f = n === 0 ? e : `${e}__chunk_${Math.floor(n / this.filterChunkSize)}`, A = { ...i };
1044
+ i.filter ? (A.filter = { ...a }, A.filter[l] = g) : i.FILTER && (A.FILTER = { ...a }, A.FILTER[l] = g), u.push({
1045
+ key: f,
1030
1046
  request: { method: r, params: A },
1031
1047
  originalKey: e,
1032
- filterKey: c,
1048
+ filterKey: l,
1033
1049
  chunkIndex: Math.floor(n / this.filterChunkSize)
1034
1050
  });
1035
1051
  }
1036
- return f;
1052
+ return u;
1037
1053
  }
1038
1054
  return [{ key: e, request: t }];
1039
1055
  }
@@ -1044,13 +1060,13 @@ const J = class J {
1044
1060
  * @returns {Array} Объединенный массив результатов
1045
1061
  */
1046
1062
  mergeSplitResults(e, t) {
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;
1063
+ const r = [], i = String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), a = new RegExp(`^${i}(?:__chunk_\\d+)?$`), l = Object.keys(e).filter((h) => a.test(h)).sort((h, u) => {
1064
+ const n = h.match(/__chunk_(\d+)$/), g = u.match(/__chunk_(\d+)$/);
1065
+ return n ? g ? parseInt(n[1]) - parseInt(g[1]) : 1 : -1;
1050
1066
  });
1051
- for (const h of c) {
1052
- const f = e[h];
1053
- Array.isArray(f) ? r.push(...f) : f && r.push(f);
1067
+ for (const h of l) {
1068
+ const u = e[h];
1069
+ Array.isArray(u) ? r.push(...u) : u && r.push(u);
1054
1070
  }
1055
1071
  return r;
1056
1072
  }
@@ -1067,28 +1083,32 @@ const J = class J {
1067
1083
  * поэтому добавляем таймаут в 30 секунд
1068
1084
  * @param {Object} chunk - Объект с методами для выполнения
1069
1085
  * @param {Function} callback - Callback функция для обработки результата
1086
+ * @param {{ onLateResponse?: (result: Object) => void }} [options] - Опции; `onLateResponse` — ответ после клиентского таймаута
1070
1087
  * @returns {Promise<void>}
1071
1088
  */
1072
- callBatchWithTimeout(e, t) {
1073
- return new Promise((r, i) => {
1074
- let a = !1, c = null;
1075
- const h = async (n) => {
1076
- if (!a) {
1077
- a = !0, c && clearTimeout(c);
1089
+ callBatchWithTimeout(e, t, r = {}) {
1090
+ const { onLateResponse: i } = r;
1091
+ return new Promise((a, l) => {
1092
+ let h = !1, u = null;
1093
+ const n = async (f) => {
1094
+ if (h)
1095
+ typeof i == "function" && i(f);
1096
+ else {
1097
+ h = !0, u && clearTimeout(u);
1078
1098
  try {
1079
- await Promise.resolve(t(n)), r();
1080
- } catch (u) {
1081
- console.error("Error in callBatch callback:", u), i(u);
1099
+ await Promise.resolve(t(f)), a();
1100
+ } catch (A) {
1101
+ console.error("Error in callBatch callback:", A), l(A);
1082
1102
  }
1083
1103
  }
1084
- }, f = async () => {
1085
- if (!a) {
1086
- a = !0, c && clearTimeout(c), console.warn(
1104
+ }, g = async () => {
1105
+ if (!h) {
1106
+ h = !0, u && clearTimeout(u), console.warn(
1087
1107
  `Batch request timeout after ${this.requestTimeoutMs}ms. This may indicate a CORS or network error.`
1088
1108
  );
1089
- const n = {};
1090
- Object.keys(e).forEach((u) => {
1091
- n[u] = {
1109
+ const f = {};
1110
+ Object.keys(e).forEach((A) => {
1111
+ f[A] = {
1092
1112
  error: () => ({
1093
1113
  ex: {
1094
1114
  error: "TIMEOUT",
@@ -1100,23 +1120,23 @@ const J = class J {
1100
1120
  };
1101
1121
  });
1102
1122
  try {
1103
- await Promise.resolve(t(n)), r();
1104
- } catch (u) {
1105
- console.error("Error in timeout callback:", u), r();
1123
+ await Promise.resolve(t(f)), a();
1124
+ } catch (A) {
1125
+ console.error("Error in timeout callback:", A), a();
1106
1126
  }
1107
1127
  }
1108
1128
  };
1109
1129
  try {
1110
- this.callBatch(e, async (n) => {
1111
- await h(n);
1130
+ this.callBatch(e, async (f) => {
1131
+ await n(f);
1112
1132
  });
1113
- } catch (n) {
1114
- a || console.error("Error calling callBatch:", n);
1133
+ } catch (f) {
1134
+ h || console.error("Error calling callBatch:", f);
1115
1135
  }
1116
- c = setTimeout(async () => {
1117
- a || (console.warn(
1136
+ u = setTimeout(async () => {
1137
+ h || (console.warn(
1118
1138
  `Batch request attempt timeout after ${this.requestTimeoutMs}ms. Switching to timeout fallback result.`
1119
- ), await f());
1139
+ ), await g());
1120
1140
  }, this.requestTimeoutMs);
1121
1141
  });
1122
1142
  }
@@ -1139,34 +1159,34 @@ const J = class J {
1139
1159
  * @returns {Promise<Object>}
1140
1160
  */
1141
1161
  async batch(e, t, r = {}) {
1142
- y(this, pt, te).call(this, t);
1143
- const i = {}, a = {}, c = {};
1144
- for (const [u, d] of Object.entries(e)) {
1145
- const A = this.arrayChunk(d);
1162
+ p(this, pt, se).call(this, t);
1163
+ const i = {}, a = {}, l = {};
1164
+ for (const [g, f] of Object.entries(e)) {
1165
+ const A = this.arrayChunk(f);
1146
1166
  if (!A)
1147
1167
  continue;
1148
- const l = this.splitLargeFilters(u, A);
1149
- if (l.length === 1)
1150
- a[u] = A;
1168
+ const c = this.splitLargeFilters(g, A);
1169
+ if (c.length === 1)
1170
+ a[g] = A;
1151
1171
  else {
1152
- c[u] = [];
1153
- for (const O of l)
1154
- a[O.key] = O.request, c[u].push(O.key);
1172
+ l[g] = [];
1173
+ for (const N of c)
1174
+ a[N.key] = N.request, l[g].push(N.key);
1155
1175
  }
1156
1176
  }
1157
1177
  this.batchCommandKeyOrder = Object.keys(a), this.totalBatchCommands = this.batchCommandKeyOrder.length, this.batchCommandMethods = this.batchCommandKeyOrder.map(
1158
- (u) => {
1159
- var d;
1160
- return String(((d = a[u]) == null ? void 0 : d.method) || "");
1178
+ (g) => {
1179
+ var f;
1180
+ return String(((f = a[g]) == null ? void 0 : f.method) || "");
1161
1181
  }
1162
1182
  ), this.chunkRate = (1 / Math.ceil(Object.keys(a).length / this.limit)).toFixed(5);
1163
- let h = {}, f = 0;
1183
+ let h = {}, u = 0;
1164
1184
  const n = Object.keys(a).length;
1165
- for (const [u, d] of Object.entries(a)) {
1185
+ for (const [g, f] of Object.entries(a)) {
1166
1186
  if (!this.canContinue)
1167
1187
  break;
1168
- if (h[u] = d, Object.keys(h).length >= this.limit || f + 1 === n) {
1169
- const A = f + 1 === n;
1188
+ if (h[g] = f, Object.keys(h).length >= this.limit || u + 1 === n) {
1189
+ const A = u + 1 === n;
1170
1190
  await this.batchChunk(
1171
1191
  h,
1172
1192
  void 0,
@@ -1175,22 +1195,22 @@ const J = class J {
1175
1195
  disablePagination: !1,
1176
1196
  oneBatch: !!(r != null && r.oneBatch)
1177
1197
  }
1178
- ), Object.entries(this.result).forEach(([l, O]) => {
1179
- i[l] = O;
1198
+ ), Object.entries(this.result).forEach(([c, N]) => {
1199
+ i[c] = N;
1180
1200
  }), this.totalProgress = Math.round(
1181
- f / n * 100
1201
+ u / n * 100
1182
1202
  ), h = {};
1183
1203
  }
1184
- f++;
1204
+ u++;
1185
1205
  }
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;
1206
+ for (const [g, f] of Object.entries(l))
1207
+ if (f && f.length > 0) {
1208
+ const A = this.mergeSplitResults(i, g);
1209
+ for (const c of f)
1210
+ delete i[c];
1211
+ i[g] = A;
1192
1212
  }
1193
- return y(this, gt, $t).call(this, i), t && t({ percent: 100 }), Promise.resolve(i);
1213
+ return p(this, yt, ee).call(this, i), t && t({ percent: 100 }), Promise.resolve(i);
1194
1214
  }
1195
1215
  /**
1196
1216
  * Выполняет батч-запрос и возвращает только количество элементов для каждой команды.
@@ -1202,59 +1222,59 @@ const J = class J {
1202
1222
  * @returns {Promise<Object>} Объект с количеством элементов для каждого ключа
1203
1223
  */
1204
1224
  async batchTotalCount(e, t) {
1205
- y(this, pt, te).call(this, t);
1225
+ p(this, pt, se).call(this, t);
1206
1226
  const r = {}, i = {}, a = {};
1207
- for (const [f, n] of Object.entries(e)) {
1208
- const u = this.arrayChunk(n);
1209
- if (!u)
1227
+ for (const [u, n] of Object.entries(e)) {
1228
+ const g = this.arrayChunk(n);
1229
+ if (!g)
1210
1230
  continue;
1211
- const d = this.splitLargeFilters(f, u);
1212
- if (d.length === 1)
1213
- i[f] = u;
1231
+ const f = this.splitLargeFilters(u, g);
1232
+ if (f.length === 1)
1233
+ i[u] = g;
1214
1234
  else {
1215
- a[f] = [];
1216
- for (const A of d)
1217
- i[A.key] = A.request, a[f].push(A.key);
1235
+ a[u] = [];
1236
+ for (const A of f)
1237
+ i[A.key] = A.request, a[u].push(A.key);
1218
1238
  }
1219
1239
  }
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) {
1240
+ const l = [], h = Object.entries(i);
1241
+ for (let u = 0; u < h.length; u += this.limit) {
1242
+ const n = h.slice(u, u + this.limit), g = {};
1243
+ for (const [f, A] of n) {
1224
1244
  if (!this.canContinue)
1225
1245
  break;
1226
- u[d] = A;
1246
+ g[f] = A;
1227
1247
  }
1228
- Object.keys(u).length > 0 && c.push(u);
1248
+ Object.keys(g).length > 0 && l.push(g);
1229
1249
  }
1230
- this.chunkRate = (1 / c.length).toFixed(5);
1231
- for (const [f, n] of Object.entries(c)) {
1250
+ this.chunkRate = (1 / l.length).toFixed(5);
1251
+ for (const [u, n] of Object.entries(l)) {
1232
1252
  if (!this.canContinue)
1233
1253
  break;
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)) {
1254
+ this.totalProgress = Math.round(Number(u) / l.length * 100), this.progressData = {}, this.lastProgressSnapshot = null;
1255
+ const g = Number(u) === l.length - 1;
1256
+ await p(this, et, dt).call(this, n, async (f) => {
1257
+ for (const [A, c] of Object.entries(f)) {
1238
1258
  if (!this.canContinue)
1239
1259
  return;
1240
- if (l.error()) {
1241
- y(this, ct, Lt).call(this, A, l), r[A] = 0;
1260
+ if (c.error()) {
1261
+ p(this, At, Mt).call(this, A, c), r[A] = 0;
1242
1262
  continue;
1243
1263
  }
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" });
1264
+ const N = this.getData(c.data()), _ = Array.isArray(N) ? N.length : 0, k = typeof c.total == "function" && c.total() !== void 0 ? c.total() : _;
1265
+ r[A] = k, this.setProgressData({ key: A, value: c, type: "count" });
1246
1266
  }
1247
- await y(this, tt, ft).call(this, d, !u);
1267
+ await p(this, tt, ft).call(this, f, !g);
1248
1268
  });
1249
1269
  }
1250
- for (const [f, n] of Object.entries(a))
1270
+ for (const [u, n] of Object.entries(a))
1251
1271
  if (n && n.length > 0) {
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;
1272
+ let g = 0;
1273
+ for (const f of n)
1274
+ r[f] !== void 0 && (g += r[f] || 0), delete r[f];
1275
+ r[u] = g;
1256
1276
  }
1257
- return Object.entries(this.errors).length && (y(this, gt, $t).call(this, r), this.errorLogger()), t && t({ percent: 100 }), Promise.resolve(r);
1277
+ return Object.entries(this.errors).length && (p(this, yt, ee).call(this, r), this.errorLogger()), t && t({ percent: 100 }), Promise.resolve(r);
1258
1278
  }
1259
1279
  /**
1260
1280
  * Выполняет одиночный REST-вызов с таймаутом и авто-повтором после лимит-паузы.
@@ -1264,36 +1284,40 @@ const J = class J {
1264
1284
  * @returns {Promise<{success: boolean, data: any, answer: Object, error: string|null}>}
1265
1285
  */
1266
1286
  async call({ method: e, params: t = {} }) {
1267
- var r, i, a, c, h, f, n;
1287
+ var i, a, l, h, u, n, g;
1288
+ const r = p(this, gt, te).call(this, this.callLimitPauseMs);
1268
1289
  for (; ; ) {
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);
1272
- continue;
1273
- }
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);
1290
+ let f = await p(this, Ut, de).call(this, e, t, {
1291
+ onLateResponse: (N) => r.notifyLateResponse(N)
1292
+ });
1293
+ if (!f)
1294
+ if (r.inRetryCycle = !0, await r.waitForLateOrLimit(), r.lateResult)
1295
+ f = r.lateResult, r.resetLateResult(), r.inRetryCycle = !1;
1296
+ else
1297
+ continue;
1298
+ const A = {};
1299
+ if (f != null && f.answer)
1300
+ for (const [N, _] of Object.entries(f.answer))
1301
+ N !== "result" && _ && (A[N] = _);
1302
+ if (f.error()) {
1303
+ const N = ((a = (i = f.error()) == null ? void 0 : i.ex) == null ? void 0 : a.error) ?? "";
1304
+ if (["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT", "TIMEOUT"].includes(N)) {
1305
+ await p(this, $, ut).call(this, this.callLimitPauseMs);
1282
1306
  continue;
1283
1307
  }
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) || "Неизвестная ошибка";
1308
+ const _ = ((l = f.error()) == null ? void 0 : l.toString()) || ((u = (h = f.error()) == null ? void 0 : h.ex) == null ? void 0 : u.error_description) || ((g = (n = f.error()) == null ? void 0 : n.ex) == null ? void 0 : g.error) || "Неизвестная ошибка";
1285
1309
  return {
1286
1310
  success: !1,
1287
1311
  data: !1,
1288
- answer: d,
1289
- error: O
1312
+ answer: A,
1313
+ error: _
1290
1314
  };
1291
1315
  }
1292
- let A = u.data();
1293
- return A != null && A.items && (A = A.items), {
1316
+ let c = f.data();
1317
+ return c != null && c.items && (c = c.items), r.inRetryCycle = !1, {
1294
1318
  success: !0,
1295
- data: A,
1296
- answer: d,
1319
+ data: c,
1320
+ answer: A,
1297
1321
  error: null
1298
1322
  };
1299
1323
  }
@@ -1313,8 +1337,8 @@ const J = class J {
1313
1337
  else {
1314
1338
  t === "entity.item.get" ? (r.SORT || (r.SORT = { ID: "ASC" }), Array.isArray(r.select) ? r.select.includes("ID") || r.select.push("ID") : r.select = ["ID"]) : t === "tasks.task.list" ? (r.order || (r.order = {}), r.order.ID = "asc") : t === "user.get" ? (r.sort || (r.sort = "ID"), r.order || (r.order = "ASC")) : r.order = { ID: "ASC", id: "ASC" }, Array.isArray(r.select) && !r.select.includes("ID") && r.select.push("ID");
1315
1339
  const i = t === "user.get" || t === "entity.item.get" ? r.FILTER : r.filter;
1316
- typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a, c]) => {
1317
- (r.start === void 0 || r.start !== -1) && ["id", "ID"].includes(a) && (typeof c == "string" || Array.isArray(c) && c.length <= 50) && (r.start = -1);
1340
+ typeof i == "object" && i !== null && !Array.isArray(i) && Object.entries(i).forEach(([a, l]) => {
1341
+ (r.start === void 0 || r.start !== -1) && ["id", "ID"].includes(a) && (typeof l == "string" || Array.isArray(l) && l.length <= 50) && (r.start = -1);
1318
1342
  });
1319
1343
  }
1320
1344
  t === "crm.type.list" && r.order && delete r.order.ID;
@@ -1324,7 +1348,7 @@ const J = class J {
1324
1348
  r = [{ ID: "ASC" }, [""], [""], ["ID"]];
1325
1349
  else {
1326
1350
  Array.isArray(r[0]) && (r[0] = {});
1327
- const [i, a, c, h] = r;
1351
+ const [i, a, l, h] = r;
1328
1352
  i.ID = "ASC", h[0] !== "" && h.includes("ID") || h.push("ID");
1329
1353
  }
1330
1354
  return { method: t, params: r };
@@ -1337,38 +1361,38 @@ const J = class J {
1337
1361
  */
1338
1362
  async batchChunk(e, t, r = !0, i = {}) {
1339
1363
  return new Promise((a) => {
1340
- const c = [];
1364
+ const l = [];
1341
1365
  let h;
1342
- const f = !!(i != null && i.disablePagination);
1366
+ const u = !!(i != null && i.disablePagination);
1343
1367
  (async () => {
1344
- await y(this, et, dt).call(this, e, async (u) => {
1345
- for (const [A, l] of Object.entries(u)) {
1368
+ await p(this, et, dt).call(this, e, async (g) => {
1369
+ for (const [A, c] of Object.entries(g)) {
1346
1370
  if (!this.canContinue)
1347
1371
  return;
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];
1372
+ c.error() && (p(this, At, Mt).call(this, A, c), h = !0);
1373
+ const N = this.getData(c.data()), _ = Array.isArray(N) ? N.length : 0, R = typeof c.total == "function" && c.total() !== void 0, k = R ? c.total() : _;
1374
+ t === "count" ? this.result[A] ? this.result[A] += _ : this.result[A] = k : this.result[A] = N, this.setProgressData({ key: A, value: c, type: t });
1375
+ const T = e[A], L = Array.isArray(T) ? T[0] : T == null ? void 0 : T.method, G = typeof L == "string" && (L.includes(".list") || L === "user.get" || L === "entity.item.get"), O = t === "count" ? !R && _ === this.limit : G ? _ === this.limit : k > this.limit && k > _, S = t !== "count" && L === "entity.item.get" && _ === this.limit && !O, I = O || S;
1376
+ if (!u && (!this.canContinue || I)) {
1377
+ let B = e[A];
1378
+ if (Array.isArray(B)) {
1379
+ const [M, s = {}] = B;
1380
+ B = [M, s];
1357
1381
  } else {
1358
- const { method: R, params: s = {} } = C;
1359
- C = [R, s];
1382
+ const { method: M, params: s = {} } = B;
1383
+ B = [M, s];
1360
1384
  }
1361
- c.push([
1385
+ l.push([
1362
1386
  A,
1363
- C,
1387
+ B,
1364
1388
  k,
1365
1389
  { entityItemGetScan: S }
1366
1390
  ]);
1367
1391
  }
1368
1392
  }
1369
1393
  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(
1394
+ const f = l.length > 0 || r;
1395
+ await p(this, tt, ft).call(this, g, f), l.length ? await this.batchPayload(l, t, i).then(
1372
1396
  () => a(this.result)
1373
1397
  ) : a(this.result);
1374
1398
  });
@@ -1381,94 +1405,94 @@ const J = class J {
1381
1405
  * @param {{oneBatch?: boolean}} [options] - Опции выполнения payload.
1382
1406
  */
1383
1407
  async batchPayload(e, t, r = {}) {
1384
- const i = !!(r != null && r.oneBatch), a = (O, _, b, k) => {
1408
+ const i = !!(r != null && r.oneBatch), a = (N, _, R, k) => {
1385
1409
  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)
1410
+ this.result[N][this.result[N].length - 1].ID || (T = "id");
1411
+ let L = `${T}`;
1412
+ if (JSON.stringify(k[1]).toLocaleLowerCase().includes('"id":"desc"') ? L = "<" + L : L = ">" + L, _ === 1 || R.length === 0)
1389
1413
  return {
1390
- field: M,
1391
- id: this.result[O][this.result[O].length - 1][T]
1414
+ field: L,
1415
+ id: this.result[N][this.result[N].length - 1][T]
1392
1416
  };
1393
- let N = "";
1417
+ let O = "";
1394
1418
  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}]`
1419
+ return (S === "tasks.task.list" || S === "task.item.list") && (O = "[tasks]"), ["crm.item.list", "crm.stagehistory.list"].includes(S) && (O = "[items]"), S === "crm.type.list" && (O = "[types]"), S === "socialnetwork.api.workgroup.list" && (O = "[workgroups]"), {
1420
+ field: L,
1421
+ id: `$result[${[N, _ - 1].join("__")}]${O}[49][${T}]`
1398
1422
  };
1399
- }, c = (O, _) => {
1400
- const [b, k] = O;
1401
- let T = JSON.parse(JSON.stringify(k)), M;
1402
- if (b === "task.item.list") {
1423
+ }, l = (N, _) => {
1424
+ const [R, k] = N;
1425
+ let T = JSON.parse(JSON.stringify(k)), L;
1426
+ if (R === "task.item.list") {
1403
1427
  T = [...T];
1404
- const [G, N, S, I] = T;
1405
- return N[_.field] = _.id, [b, T];
1428
+ const [G, O, S, I] = T;
1429
+ return O[_.field] = _.id, [R, T];
1406
1430
  }
1407
- return ["user.get"].includes(b) || T.FILTER ? (T.FILTER || (T.FILTER = {}), M = T.FILTER) : (T.filter || (T.filter = {}), M = T.filter), [
1431
+ return ["user.get"].includes(R) || T.FILTER ? (T.FILTER || (T.FILTER = {}), L = T.FILTER) : (T.filter || (T.filter = {}), L = T.filter), [
1408
1432
  "socialnetwork.api.workgroup.list",
1409
1433
  "tasks.task.list"
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 });
1434
+ ].includes(R) ? L[">ID"] = _.id : L[_.field] = _.id, [R, { ...T, start: -1 }];
1435
+ }, h = (N) => {
1436
+ Object.entries(N).forEach(([_, R]) => {
1437
+ const [k] = _.split("__"), T = this.getData(R.data());
1438
+ Array.isArray(T) && (t === "count" ? this.result[k] += T.length : this.result[k].push(...T)), R.error() && p(this, At, Mt).call(this, k, R), this.setProgressData({ key: k, value: R, type: t });
1415
1439
  });
1416
- }, f = (O, _) => {
1417
- if (!Array.isArray(O) || O.length === 0)
1440
+ }, u = (N, _) => {
1441
+ if (!Array.isArray(N) || N.length === 0)
1418
1442
  return null;
1419
- const b = O[O.length - 1];
1443
+ const R = N[N.length - 1];
1420
1444
  let k = "ID";
1421
- b.ID || (k = "id");
1445
+ R.ID || (k = "id");
1422
1446
  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, _) => {
1447
+ return JSON.stringify(_[1]).toLocaleLowerCase().includes('"id":"desc"') ? T = "<" + T : T = ">" + T, { field: T, id: R[k] };
1448
+ }, n = 1e4, g = async (N, _) => {
1425
1449
  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, _);
1429
- if (!N)
1450
+ let R = this.limit;
1451
+ for (let L = 1; this.canContinue && R === this.limit && L <= n; L++) {
1452
+ const G = this.result[N], O = u(G, _);
1453
+ if (!O)
1430
1454
  break;
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);
1455
+ const S = `${N}__eiscan_${L}`, I = l(_, O);
1456
+ let B = null;
1457
+ await p(this, et, dt).call(this, { [S]: I }, async (m) => {
1458
+ B = m, h(m);
1435
1459
  });
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];
1460
+ const M = L < n;
1461
+ await p(this, tt, ft).call(this, B, M), await this.delay();
1462
+ const s = B == null ? void 0 : B[S];
1439
1463
  if ((k = s == null ? void 0 : s.error) != null && k.call(s)) {
1440
- b = 0;
1464
+ R = 0;
1441
1465
  break;
1442
1466
  }
1443
1467
  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;
1468
+ R = Array.isArray(o) ? o.length : 0;
1445
1469
  }
1446
1470
  };
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;
1451
- for await (const O of e) {
1471
+ let f = [], A = 0;
1472
+ const c = async (N = !0) => f.length ? (await p(this, et, dt).call(this, Object.fromEntries(f), async (_) => {
1473
+ h(_), await p(this, tt, ft).call(this, _, N);
1474
+ }), A++, f = [], i && A >= 1 ? !0 : (await this.delay(), !1)) : !1;
1475
+ for await (const N of e) {
1452
1476
  if (!this.canContinue)
1453
1477
  return;
1454
- const [_, b, k, T = {}] = O;
1478
+ const [_, R, k, T = {}] = N;
1455
1479
  if (T.entityItemGetScan) {
1456
- if (await l(!0))
1480
+ if (await c(!0))
1457
1481
  return;
1458
1482
  if (i)
1459
1483
  continue;
1460
- await u(_, b);
1484
+ await g(_, R);
1461
1485
  continue;
1462
1486
  }
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))
1487
+ let L = 1;
1488
+ for (; k > L * this.limit; ) {
1489
+ const G = [_, L].join("__"), O = a(_, L, f, R);
1490
+ if (f.push([G, l(R, O)]), i && f.length === 49 && await c(!0) || f.length % 50 === 0 && await c(!0))
1467
1491
  return;
1468
- M++;
1492
+ L++;
1469
1493
  }
1470
1494
  }
1471
- await l(!1);
1495
+ await c(!1);
1472
1496
  }
1473
1497
  /**
1474
1498
  * Вывод ошибок в консоль в группированном виде
@@ -1479,29 +1503,29 @@ const J = class J {
1479
1503
  }), console.groupEnd();
1480
1504
  }
1481
1505
  };
1482
- St = new WeakSet(), ce = function() {
1506
+ It = new WeakSet(), he = function() {
1483
1507
  const e = this.totalBatchCommands || 0, t = this.batchCommandMethods;
1484
- if (e < L(J, It) || !Array.isArray(t) || t.length !== e)
1508
+ if (e < b(J, Dt) || !Array.isArray(t) || t.length !== e)
1485
1509
  return !1;
1486
- if (t.filter((a) => a === "crm.deal.list").length >= L(J, Dt))
1510
+ if (t.filter((a) => a === "crm.deal.list").length >= b(J, kt))
1487
1511
  return !0;
1488
1512
  const i = t.filter(
1489
1513
  (a) => typeof a == "string" && a.includes(".list")
1490
1514
  ).length;
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() {
1515
+ return i >= b(J, wt) && i / e >= b(J, Ct);
1516
+ }, Dt = new WeakMap(), kt = new WeakMap(), wt = new WeakMap(), Ct = new WeakMap(), ot = new WeakSet(), bt = function() {
1493
1517
  if (!this.progressCall || !this.progressData)
1494
1518
  return;
1495
1519
  const { percent: e, allCount: t, allTotal: r } = this.progressPercent, i = { percent: e, allCount: t, allTotal: r };
1496
- y(this, Bt, le).call(this, i) && (this.progressCall({
1520
+ p(this, Bt, ue).call(this, i) && (this.progressCall({
1497
1521
  data: this.progressData,
1498
1522
  percent: e,
1499
1523
  allCount: t,
1500
1524
  allTotal: r
1501
1525
  }), this.lastProgressSnapshot = i);
1502
- }, Bt = new WeakSet(), le = function(e) {
1526
+ }, Bt = new WeakSet(), ue = function(e) {
1503
1527
  return this.lastProgressSnapshot ? this.lastProgressSnapshot.percent !== e.percent || this.lastProgressSnapshot.allCount !== e.allCount || this.lastProgressSnapshot.allTotal !== e.allTotal : !0;
1504
- }, Ct = new WeakSet(), he = function() {
1528
+ }, Ht = new WeakSet(), fe = function() {
1505
1529
  const e = {
1506
1530
  limit: this.timeLimit.limit,
1507
1531
  date: this.timeLimit.date,
@@ -1513,7 +1537,7 @@ St = new WeakSet(), ce = function() {
1513
1537
  } catch (r) {
1514
1538
  console.warn("Batch timeLimit listener error:", r);
1515
1539
  }
1516
- }, Z = new WeakSet(), at = async function(e = this.defaultPauseMs) {
1540
+ }, $ = new WeakSet(), ut = async function(e = this.defaultPauseMs) {
1517
1541
  this.setTimeLimitState(!0, (/* @__PURE__ */ new Date()).toISOString(), e), await new Promise((t) => setTimeout(t, e)), this.setTimeLimitState(!1, void 0);
1518
1542
  }, tt = new WeakSet(), ft = async function(e, t = !0) {
1519
1543
  if (!t)
@@ -1530,81 +1554,129 @@ St = new WeakSet(), ce = function() {
1530
1554
  }
1531
1555
  } catch {
1532
1556
  }
1533
- r >= this.operatingThreshold && await y(this, Z, at).call(this);
1557
+ r >= this.operatingThreshold && await p(this, $, ut).call(this);
1558
+ }, gt = new WeakSet(), te = function(e = this.defaultPauseMs) {
1559
+ const t = this;
1560
+ return {
1561
+ inRetryCycle: !1,
1562
+ inTimeoutWait: !1,
1563
+ lateResult: null,
1564
+ lateWaiters: [],
1565
+ notifyLateResponse(i) {
1566
+ if (!(!this.inRetryCycle && !this.inTimeoutWait)) {
1567
+ this.lateResult = i;
1568
+ for (const a of this.lateWaiters)
1569
+ a(i);
1570
+ this.lateWaiters = [];
1571
+ }
1572
+ },
1573
+ waitForLateOrLimit() {
1574
+ var a;
1575
+ this.inTimeoutWait = !0;
1576
+ const i = new Promise((l) => {
1577
+ if (this.lateResult) {
1578
+ l(this.lateResult);
1579
+ return;
1580
+ }
1581
+ this.lateWaiters.push(l);
1582
+ });
1583
+ return Promise.race([
1584
+ p(a = t, $, ut).call(a, e),
1585
+ i
1586
+ ]).finally(() => {
1587
+ this.inTimeoutWait = !1;
1588
+ });
1589
+ },
1590
+ resetLateResult() {
1591
+ this.lateResult = null;
1592
+ }
1593
+ };
1534
1594
  }, et = new WeakSet(), dt = async function(e, t) {
1535
1595
  let r = !1, i = e;
1596
+ const a = p(this, gt, te).call(this);
1536
1597
  do
1537
- r = !1, await this.callBatchWithTimeout(i, async (a) => {
1538
- var f, n;
1539
- let c = !1;
1540
- const h = /* @__PURE__ */ new Set();
1541
- for (const [u, d] of Object.entries(a || {})) {
1542
- if (!(d != null && d.error) || !d.error())
1543
- continue;
1544
- const A = ((n = (f = d.error()) == null ? void 0 : f.ex) == null ? void 0 : n.error) ?? "";
1545
- if (A === "TIMEOUT") {
1546
- c = !0;
1547
- break;
1598
+ r = !1, await this.callBatchWithTimeout(
1599
+ i,
1600
+ async (l) => {
1601
+ var n, g;
1602
+ let h = !1;
1603
+ const u = /* @__PURE__ */ new Set();
1604
+ for (const [f, A] of Object.entries(l || {})) {
1605
+ if (!(A != null && A.error) || !A.error())
1606
+ continue;
1607
+ const c = ((g = (n = A.error()) == null ? void 0 : n.ex) == null ? void 0 : g.error) ?? "";
1608
+ if (c === "TIMEOUT") {
1609
+ h = !0;
1610
+ break;
1611
+ }
1612
+ ["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(c) && u.add(f);
1548
1613
  }
1549
- ["QUERY_LIMIT_EXCEEDED", "OPERATION_TIME_LIMIT"].includes(A) && h.add(u);
1550
- }
1551
- if (c) {
1552
- r = !0, await y(this, Z, at).call(this);
1553
- return;
1554
- }
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));
1564
- return;
1614
+ if (h) {
1615
+ if (a.inRetryCycle = !0, r = !0, await a.waitForLateOrLimit(), a.lateResult) {
1616
+ r = !1, a.inRetryCycle = !1;
1617
+ const f = a.lateResult;
1618
+ a.resetLateResult(), await t(f);
1619
+ }
1620
+ return;
1621
+ }
1622
+ if (u.size > 0) {
1623
+ const f = {};
1624
+ for (const [c, N] of Object.entries(l || {}))
1625
+ u.has(c) || (f[c] = N);
1626
+ Object.keys(f).length && await t(f);
1627
+ const A = {};
1628
+ for (const c of u)
1629
+ i[c] && (A[c] = i[c]);
1630
+ i = A, Object.keys(i).length && (r = !0, await p(this, $, ut).call(this));
1631
+ return;
1632
+ }
1633
+ a.inRetryCycle = !1, await t(l);
1634
+ },
1635
+ {
1636
+ onLateResponse: (l) => a.notifyLateResponse(l)
1565
1637
  }
1566
- await t(a);
1567
- });
1638
+ );
1568
1639
  while (r);
1569
- }, Ht = new WeakSet(), ue = function(e, t) {
1570
- return new Promise((r) => {
1640
+ }, Ut = new WeakSet(), de = function(e, t, r = {}) {
1641
+ const { onLateResponse: i } = r;
1642
+ return new Promise((a) => {
1571
1643
  if (typeof this.callMethod != "function") {
1572
- r(null);
1644
+ a(null);
1573
1645
  return;
1574
1646
  }
1575
- let i = !1;
1576
- const a = setTimeout(() => {
1577
- i || (i = !0, r(null));
1647
+ let l = !1;
1648
+ const h = setTimeout(() => {
1649
+ l || (l = !0, a(null));
1578
1650
  }, this.requestTimeoutMs);
1579
1651
  try {
1580
- this.callMethod(e, t, (c) => {
1581
- i || (i = !0, clearTimeout(a), r(c));
1652
+ this.callMethod(e, t, (u) => {
1653
+ l ? typeof i == "function" && i(u) : (l = !0, clearTimeout(h), a(u));
1582
1654
  });
1583
1655
  } catch {
1584
- i || (i = !0, clearTimeout(a), r(null));
1656
+ l || (l = !0, clearTimeout(h), a(null));
1585
1657
  }
1586
1658
  });
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() : "";
1659
+ }, Pt = new WeakSet(), me = function(e) {
1660
+ 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(), l = typeof (t == null ? void 0 : t.toString) == "function" ? String(t.toString()).trim() : "";
1589
1661
  let h = a;
1590
- return !h && c && c !== i && (h = c), h || (h = i || "Неизвестная ошибка"), {
1662
+ return !h && l && l !== i && (h = l), h || (h = i || "Неизвестная ошибка"), {
1591
1663
  code: i || h,
1592
1664
  message: h
1593
1665
  };
1594
- }, ct = new WeakSet(), Lt = function(e, t) {
1595
- const { code: r, message: i } = y(this, Ut, fe).call(this, t);
1666
+ }, At = new WeakSet(), Mt = function(e, t) {
1667
+ const { code: r, message: i } = p(this, Pt, me).call(this, t);
1596
1668
  this.errors[e] = r, this.errorMessages[e] = i;
1597
- }, gt = new WeakSet(), $t = function(e) {
1669
+ }, yt = new WeakSet(), ee = function(e) {
1598
1670
  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) {
1671
+ }, pt = new WeakSet(), se = function(e) {
1600
1672
  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);
1601
1673
  }, /** Не включать вес по командам для совсем маленьких batch. */
1602
- E(J, It, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
1603
- E(J, Dt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
1604
- E(J, kt, 8), E(J, wt, 0.65);
1674
+ E(J, Dt, 5), /** Явный сигнал: много отдельных выборок сделок по фильтрам. */
1675
+ E(J, kt, 5), /** Достаточно «list»-методов в пачке и доля list от всех команд. */
1676
+ E(J, wt, 8), E(J, Ct, 0.65);
1605
1677
  let K = J;
1606
1678
  var st;
1607
- class de {
1679
+ class ge {
1608
1680
  constructor() {
1609
1681
  E(this, st, {});
1610
1682
  }
@@ -1635,7 +1707,7 @@ class de {
1635
1707
  * @param {Function} params.action - Функция для выполнения
1636
1708
  */
1637
1709
  actionFilter({ keyTimer: e, duration: t = 10, action: r }) {
1638
- L(this, st)[e] && (clearTimeout(L(this, st)[e]), L(this, st)[e] = null), r && (L(this, st)[e] = setTimeout(() => {
1710
+ b(this, st)[e] && (clearTimeout(b(this, st)[e]), b(this, st)[e] = null), r && (b(this, st)[e] = setTimeout(() => {
1639
1711
  r();
1640
1712
  }, t));
1641
1713
  }
@@ -1674,28 +1746,28 @@ class de {
1674
1746
  }
1675
1747
  }
1676
1748
  st = new WeakMap();
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 {
1749
+ const Zt = new ge();
1750
+ var j, z, rt, lt, Nt, Z, v, it, ct, Gt, ye, Ot, re, Yt, pe, Wt, Ne, xt, Oe;
1751
+ class Ue {
1680
1752
  constructor() {
1681
1753
  /** user.current — только при первом реальном использовании (сохранение лога, выгрузка). */
1682
- E(this, Pt);
1754
+ E(this, Gt);
1683
1755
  /** Вывод ошибок логера
1684
1756
  * @param {'entity'} type - тип ошибки
1685
1757
  */
1686
- E(this, Nt);
1687
- E(this, Gt);
1758
+ E(this, Ot);
1688
1759
  E(this, Yt);
1689
1760
  E(this, Wt);
1761
+ E(this, xt);
1690
1762
  E(this, j, "logger");
1691
1763
  E(this, z, !1);
1692
1764
  E(this, rt, /* @__PURE__ */ new Map());
1693
1765
  E(this, lt, {});
1694
- E(this, yt, !1);
1695
- E(this, V, null);
1766
+ E(this, Nt, !1);
1767
+ E(this, Z, null);
1696
1768
  E(this, v, null);
1697
1769
  E(this, it, !1);
1698
- E(this, ht, !1);
1770
+ E(this, ct, !1);
1699
1771
  /** Очистка хранилища элементов старше 'N' месяцев */
1700
1772
  w(this, "periodClear", 3);
1701
1773
  }
@@ -1707,7 +1779,7 @@ class Ce {
1707
1779
  });
1708
1780
  if (t && Array.isArray(t))
1709
1781
  if (t.find(
1710
- (i) => i.ENTITY == L(this, j)
1782
+ (i) => i.ENTITY == b(this, j)
1711
1783
  ))
1712
1784
  x(this, z, !0);
1713
1785
  else {
@@ -1715,15 +1787,15 @@ class Ce {
1715
1787
  entityAdd: {
1716
1788
  method: "entity.add",
1717
1789
  params: {
1718
- ENTITY: L(this, j),
1719
- NAME: L(this, j),
1790
+ ENTITY: b(this, j),
1791
+ NAME: b(this, j),
1720
1792
  ACCESS: { AU: "X" }
1721
1793
  }
1722
1794
  }
1723
1795
  });
1724
1796
  i && x(this, z, !0);
1725
1797
  }
1726
- return L(this, z);
1798
+ return b(this, z);
1727
1799
  } catch (e) {
1728
1800
  return console.error("Ошибка при инициализации логера:", e), !1;
1729
1801
  }
@@ -1745,11 +1817,11 @@ class Ce {
1745
1817
  * @returns {string|null}
1746
1818
  */
1747
1819
  start({ type: e, data: t }) {
1748
- if (!L(this, z))
1749
- return y(this, Nt, ee).call(this, "entity"), null;
1820
+ if (!b(this, z))
1821
+ return p(this, Ot, re).call(this, "entity"), null;
1750
1822
  if (!e || !t)
1751
1823
  return console.error("Невалидные данные для логирования:", { type: e, data: t }), null;
1752
- const r = Qt.hash, i = {
1824
+ const r = Zt.hash, i = {
1753
1825
  type: e,
1754
1826
  data: t,
1755
1827
  userInfo: null,
@@ -1758,7 +1830,7 @@ class Ce {
1758
1830
  answer: null,
1759
1831
  date: (/* @__PURE__ */ new Date()).getTime()
1760
1832
  };
1761
- return L(this, rt).set(r, i), x(this, ht, !0), r;
1833
+ return b(this, rt).set(r, i), x(this, ct, !0), r;
1762
1834
  }
1763
1835
  /**
1764
1836
  * @param {{
@@ -1768,19 +1840,19 @@ class Ce {
1768
1840
  * answer: { [key]: unknown } }}
1769
1841
  */
1770
1842
  async stop({ key: e, errorList: t, status: r, answer: i }) {
1771
- var c;
1772
- if (!L(this, ht))
1843
+ var l;
1844
+ if (!b(this, ct))
1773
1845
  return;
1774
- if (!L(this, z)) {
1775
- y(this, Nt, ee).call(this, "entity");
1846
+ if (!b(this, z)) {
1847
+ p(this, Ot, re).call(this, "entity");
1776
1848
  return;
1777
1849
  }
1778
- let a = L(this, rt).get(e);
1850
+ let a = b(this, rt).get(e);
1779
1851
  if (!a) {
1780
1852
  console.error(`Не найдены данные логирования для ключа: ${e}`);
1781
1853
  return;
1782
1854
  }
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);
1855
+ t && (a.errorList = t), r && (a.status = r), i && (a.answer = i), await p(this, Gt, ye).call(this), a.userInfo = b(this, lt), await p(this, Yt, pe).call(this), (l = a == null ? void 0 : a.data) != null && l.updateList && x(this, it, !0), x(this, ct, !1);
1784
1856
  }
1785
1857
  /**
1786
1858
  * @param { ({percent}:{percent:number})=>{} } progressCall - коллбэк
@@ -1788,14 +1860,14 @@ class Ce {
1788
1860
  async getEntityList(e) {
1789
1861
  var t;
1790
1862
  try {
1791
- if ((t = L(this, v)) != null && t.length && !L(this, it))
1792
- return L(this, v);
1863
+ if ((t = b(this, v)) != null && t.length && !b(this, it))
1864
+ return b(this, v);
1793
1865
  let r = new K(BX24.callBatch), { entityList: i } = await r.batch(
1794
1866
  {
1795
1867
  entityList: {
1796
1868
  method: "entity.item.get",
1797
1869
  params: {
1798
- ENTITY: L(this, j),
1870
+ ENTITY: b(this, j),
1799
1871
  SORT: { ID: "DESC" }
1800
1872
  }
1801
1873
  }
@@ -1804,16 +1876,16 @@ class Ce {
1804
1876
  );
1805
1877
  return !i || !Array.isArray(i) ? (console.warn("Получен невалидный список записей"), []) : (i = i.map((a) => {
1806
1878
  try {
1807
- const { ID: c, DATE_CREATE: h, DETAIL_TEXT: f } = a;
1879
+ const { ID: l, DATE_CREATE: h, DETAIL_TEXT: u } = a;
1808
1880
  return {
1809
- ...JSON.parse(f),
1810
- id: c,
1881
+ ...JSON.parse(u),
1882
+ id: l,
1811
1883
  dateCreate: h
1812
1884
  };
1813
- } catch (c) {
1885
+ } catch (l) {
1814
1886
  return console.error(
1815
1887
  `Ошибка парсинга записи ${a.ID}:`,
1816
- c
1888
+ l
1817
1889
  ), null;
1818
1890
  }
1819
1891
  }).filter((a) => a !== null), x(this, it, !1), x(this, v, i), i);
@@ -1826,16 +1898,16 @@ class Ce {
1826
1898
  * Не вызывается из `init` — вызывайте явно (например, из настроек или планировщика).
1827
1899
  */
1828
1900
  runStorageMaintenance() {
1829
- return y(this, Yt, pe).call(this);
1901
+ return p(this, Wt, Ne).call(this);
1830
1902
  }
1831
1903
  /** Выгрузка всех данных из хранилища в JSON-файл */
1832
1904
  async downAllEntityJson() {
1833
1905
  try {
1834
- if (L(this, v) || await this.getEntityList(), !L(this, v) || L(this, v).length === 0)
1906
+ if (b(this, v) || await this.getEntityList(), !b(this, v) || b(this, v).length === 0)
1835
1907
  return console.warn("Нет данных для выгрузки"), !1;
1836
- let e = bt().format("%Y-%m-%d");
1837
- return Qt.downloadFileJson(
1838
- L(this, v),
1908
+ let e = Lt().format("%Y-%m-%d");
1909
+ return Zt.downloadFileJson(
1910
+ b(this, v),
1839
1911
  `sdklogger-entity-data__${e}`
1840
1912
  ), !0;
1841
1913
  } catch (e) {
@@ -1843,9 +1915,9 @@ class Ce {
1843
1915
  }
1844
1916
  }
1845
1917
  }
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 () => {
1918
+ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), Nt = new WeakMap(), Z = new WeakMap(), v = new WeakMap(), it = new WeakMap(), ct = new WeakMap(), Gt = new WeakSet(), ye = async function() {
1919
+ if (!b(this, Nt))
1920
+ return b(this, Z) ? b(this, Z) : (x(this, Z, (async () => {
1849
1921
  try {
1850
1922
  const e = new K(BX24.callBatch), t = BX24.isAdmin(), { curUser: r } = await e.batch({
1851
1923
  curUser: { method: "user.current" }
@@ -1857,43 +1929,43 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt
1857
1929
  e
1858
1930
  ), x(this, lt, { isAdmin: !1, curUser: null });
1859
1931
  } finally {
1860
- x(this, yt, !0), x(this, V, null);
1932
+ x(this, Nt, !0), x(this, Z, null);
1861
1933
  }
1862
- })()), L(this, V));
1863
- }, Nt = new WeakSet(), ee = function(e) {
1864
- e == "entity" && Qt.actionFilter({
1934
+ })()), b(this, Z));
1935
+ }, Ot = new WeakSet(), re = function(e) {
1936
+ e == "entity" && Zt.actionFilter({
1865
1937
  keyTimer: "error.logger.entity",
1866
1938
  duration: 500,
1867
1939
  action: () => {
1868
1940
  console.error("Хранилище для логгера не инициализировано");
1869
1941
  }
1870
1942
  });
1871
- }, Gt = new WeakSet(), ge = async function() {
1943
+ }, Yt = new WeakSet(), pe = async function() {
1872
1944
  try {
1873
1945
  let e = {}, t = new K(BX24.callBatch);
1874
- for (let [r, i] of L(this, rt).entries())
1946
+ for (let [r, i] of b(this, rt).entries())
1875
1947
  if (i.status) {
1876
1948
  const a = JSON.stringify(i);
1877
1949
  e[r] = {
1878
1950
  method: "entity.item.add",
1879
1951
  params: {
1880
- ENTITY: L(this, j),
1881
- NAME: L(this, j),
1952
+ ENTITY: b(this, j),
1953
+ NAME: b(this, j),
1882
1954
  DETAIL_TEXT: a
1883
1955
  }
1884
1956
  };
1885
1957
  }
1886
1958
  if (Object.keys(e).length) {
1887
1959
  let r = await t.batch(e), { errors: i } = t;
1888
- for (let [a, c] of Object.entries({ ...r, ...i }))
1889
- L(this, rt).delete(a);
1960
+ for (let [a, l] of Object.entries({ ...r, ...i }))
1961
+ b(this, rt).delete(a);
1890
1962
  return !0;
1891
1963
  }
1892
1964
  return !1;
1893
1965
  } catch (e) {
1894
1966
  return console.error("Ошибка при добавлении записей в хранилище:", e), !1;
1895
1967
  }
1896
- }, Yt = new WeakSet(), pe = async function() {
1968
+ }, Wt = new WeakSet(), Ne = async function() {
1897
1969
  try {
1898
1970
  let e = new K(BX24.callBatch), { serverTime: t } = await e.batch({
1899
1971
  serverTime: { method: "server.time" }
@@ -1902,13 +1974,13 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt
1902
1974
  console.error("Не удалось получить время сервера");
1903
1975
  return;
1904
1976
  }
1905
- if (L(this, v) || await this.getEntityList(), !L(this, v) || L(this, v).length === 0)
1977
+ if (b(this, v) || await this.getEntityList(), !b(this, v) || b(this, v).length === 0)
1906
1978
  return;
1907
- let r = L(this, v).filter((i) => {
1979
+ let r = b(this, v).filter((i) => {
1908
1980
  try {
1909
1981
  let { dateCreate: a } = i;
1910
- return a ? bt(new Date(a)).between(
1911
- bt(new Date(t)),
1982
+ return a ? Lt(new Date(a)).between(
1983
+ Lt(new Date(t)),
1912
1984
  "month"
1913
1985
  ) >= this.periodClear : !1;
1914
1986
  } catch (a) {
@@ -1917,21 +1989,21 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt
1917
1989
  });
1918
1990
  r.length > 0 && (console.log(
1919
1991
  `Найдено ${r.length} записей для очистки (старше ${this.periodClear} месяцев)`
1920
- ), await y(this, Wt, ye).call(this, r));
1992
+ ), await p(this, xt, Oe).call(this, r));
1921
1993
  } catch (e) {
1922
1994
  console.error("Ошибка при проверке периода очистки:", e);
1923
1995
  }
1924
- }, Wt = new WeakSet(), ye = async function(e) {
1996
+ }, xt = new WeakSet(), Oe = async function(e) {
1925
1997
  try {
1926
1998
  if (!e || e.length === 0)
1927
1999
  return !1;
1928
2000
  let t = new K(BX24.callBatch), r = e.filter((a) => a && a.id).map((a) => {
1929
- let { id: c } = a;
2001
+ let { id: l } = a;
1930
2002
  return {
1931
2003
  method: "entity.item.delete",
1932
2004
  params: {
1933
- ENTITY: L(this, j),
1934
- ID: c
2005
+ ENTITY: b(this, j),
2006
+ ID: l
1935
2007
  }
1936
2008
  };
1937
2009
  });
@@ -1943,36 +2015,36 @@ j = new WeakMap(), z = new WeakMap(), rt = new WeakMap(), lt = new WeakMap(), yt
1943
2015
  return console.error("Ошибка при очистке устаревших записей:", t), !1;
1944
2016
  }
1945
2017
  };
1946
- function oe(m) {
1947
- if (!m || typeof m != "string")
2018
+ function le(d) {
2019
+ if (!d || typeof d != "string")
1948
2020
  return "";
1949
2021
  try {
1950
- const e = new URL(m);
2022
+ const e = new URL(d);
1951
2023
  e.search = "", e.hash = "";
1952
2024
  let t = e.toString();
1953
2025
  return t.endsWith("/") && e.pathname !== "/" && (t = t.slice(0, -1)), t;
1954
2026
  } catch {
1955
- return m.split("?")[0].split("#")[0].replace(/\/$/, "");
2027
+ return d.split("?")[0].split("#")[0].replace(/\/$/, "");
1956
2028
  }
1957
2029
  }
1958
- function Ne(m) {
1959
- return !m || typeof m != "string" ? !1 : m.toLowerCase().includes("/marketplace/app");
2030
+ function _e(d) {
2031
+ return !d || typeof d != "string" ? !1 : d.toLowerCase().includes("/marketplace/app");
1960
2032
  }
1961
- function He() {
2033
+ function Pe() {
1962
2034
  var e;
1963
2035
  if (typeof window > "u" || !((e = window.location) != null && e.href))
1964
2036
  return "";
1965
- const m = oe(window.location.href);
1966
- return Ne(m) ? "" : m;
2037
+ const d = le(window.location.href);
2038
+ return _e(d) ? "" : d;
1967
2039
  }
1968
- function se(m) {
1969
- if (!(m != null && m.appConst) || typeof m.appConst != "object")
2040
+ function ie(d) {
2041
+ if (!(d != null && d.appConst) || typeof d.appConst != "object")
1970
2042
  return "";
1971
- const e = He();
1972
- return e ? (m.appConst.pathApp = e, e) : oe(m.appConst.pathApp ?? "");
2043
+ const e = Pe();
2044
+ return e ? (d.appConst.pathApp = e, e) : le(d.appConst.pathApp ?? "");
1973
2045
  }
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 {
2046
+ var ht, St, Ft, Te, _t, ne, vt, Ee, Xt, Re, Jt, Le, V, at, Tt, ae, jt, be, Et, oe, Kt, Me;
2047
+ class Je {
1976
2048
  /**
1977
2049
  * @param {Object} appConst - Константы приложения
1978
2050
  * @param {string} appConst.appName - Название приложения
@@ -1985,24 +2057,24 @@ class ve {
1985
2057
  *
1986
2058
  * @returns {Batch} Shared Batch instance.
1987
2059
  */
1988
- E(this, ut);
1989
- E(this, xt);
2060
+ E(this, ht);
2061
+ E(this, Ft);
1990
2062
  /**
1991
2063
  * `this.logger === true` → `BxLogger` + лёгкий `init` (сущность хранилища, без полной выгрузки);
1992
2064
  * иначе — заглушка.
1993
2065
  * @param {boolean} runLoggerMaintenance
1994
2066
  */
1995
- E(this, Ot);
2067
+ E(this, _t);
1996
2068
  /**
1997
2069
  * @returns {boolean}
1998
2070
  */
1999
- E(this, Ft);
2000
- /** Запрос данных о приложении */
2001
2071
  E(this, vt);
2002
- /** Запрос данных о текущем пользователе */
2072
+ /** Запрос данных о приложении */
2003
2073
  E(this, Xt);
2004
- E(this, $);
2005
- E(this, _t);
2074
+ /** Запрос данных о текущем пользователе */
2075
+ E(this, Jt);
2076
+ E(this, V);
2077
+ E(this, Tt);
2006
2078
  /**
2007
2079
  * Расширяет errorList для случаев TIMEOUT и LIMIT
2008
2080
  * Если есть ошибки TIMEOUT или LIMIT, добавляет все необработанные сущности из commandList
@@ -2012,17 +2084,17 @@ class ve {
2012
2084
  * @param {Array} updateList - Список обновлений для логирования (опционально)
2013
2085
  * @returns {Object} Расширенный список ошибок
2014
2086
  */
2015
- E(this, Jt);
2087
+ E(this, jt);
2016
2088
  /**
2017
2089
  * Нормализует входные данные в массив объектов {placement, handler?}
2018
2090
  * @private
2019
2091
  */
2020
- E(this, Tt);
2092
+ E(this, Et);
2021
2093
  /**
2022
2094
  * Находит встройки с устаревшим handler (не содержащим текущий pathApp)
2023
2095
  * @private
2024
2096
  */
2025
- E(this, jt);
2097
+ E(this, Kt);
2026
2098
  w(this, "domain", "");
2027
2099
  w(this, "isAdmin", !1);
2028
2100
  w(this, "appInfo", null);
@@ -2046,7 +2118,7 @@ class ve {
2046
2118
  * @returns {() => void} Функция отписки.
2047
2119
  */
2048
2120
  subscribeTimeLimit(e) {
2049
- return y(this, ut, Rt).call(this).subscribeTimeLimit(e);
2121
+ return p(this, ht, St).call(this).subscribeTimeLimit(e);
2050
2122
  }
2051
2123
  /**
2052
2124
  * Единая инициализация: внутри автоматически выбирается ветка обычного приложения или
@@ -2062,34 +2134,34 @@ class ve {
2062
2134
  return new Promise((e, t) => {
2063
2135
  const i = setTimeout(() => {
2064
2136
  clearInterval(a);
2065
- const c = new Error(
2137
+ const l = new Error(
2066
2138
  "BX24 initialization timeout: BX24 object not found within 30 seconds"
2067
2139
  );
2068
- console.error(c), t(c);
2140
+ console.error(l), t(l);
2069
2141
  }, 3e4);
2070
2142
  let a = setInterval(() => {
2071
2143
  window.BX24 && BX24.init(async () => {
2072
2144
  clearInterval(a), clearTimeout(i), this.domain = BX24.getDomain(), this.isAdmin = BX24.isAdmin(), this.placeInfo = BX24.placement.info();
2073
- const c = y(this, Ft, _e).call(this);
2145
+ const l = p(this, vt, Ee).call(this);
2074
2146
  if (console.info(
2075
- c ? "init BX24 (background worker)" : "init BX24"
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, {
2147
+ l ? "init BX24 (background worker)" : "init BX24"
2148
+ ), this.appInfo = await p(this, Xt, Re).call(this), this.userInfo = await p(this, Jt, Le).call(this), ie(this), l)
2149
+ await p(this, _t, ne).call(this, !1, {
2078
2150
  skipInit: !0
2079
2151
  });
2080
2152
  else {
2081
- await y(this, Ot, re).call(this, !0);
2082
- const h = new de();
2153
+ await p(this, _t, ne).call(this, !0);
2154
+ const h = new ge();
2083
2155
  try {
2084
2156
  h.noSleep();
2085
- } catch (f) {
2157
+ } catch (u) {
2086
2158
  console.warn(
2087
2159
  "Failed to initialize noSleep:",
2088
- f
2160
+ u
2089
2161
  );
2090
2162
  }
2091
2163
  }
2092
- e({ isBackworker: c });
2164
+ e({ isBackworker: l });
2093
2165
  });
2094
2166
  }, 100);
2095
2167
  });
@@ -2145,14 +2217,14 @@ class ve {
2145
2217
  const h = new Error("BX24 is not initialized");
2146
2218
  throw console.error(h), h;
2147
2219
  }
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, {
2150
- answer: c.answer,
2220
+ const l = await p(this, ht, St).call(this).call({ method: e, params: t });
2221
+ return l.success ? (await p(this, V, at).call(this, i, {
2222
+ answer: l.answer,
2151
2223
  status: "success"
2152
- }), c.data) : (console.error(c.error), await y(this, $, ot).call(this, i, {
2153
- answer: c.answer,
2224
+ }), l.data) : (console.error(l.error), await p(this, V, at).call(this, i, {
2225
+ answer: l.answer,
2154
2226
  status: "fail",
2155
- errorList: { 0: c.error || "Unknown call error" }
2227
+ errorList: { 0: l.error || "Unknown call error" }
2156
2228
  }), !1);
2157
2229
  }
2158
2230
  /**
@@ -2176,10 +2248,10 @@ class ve {
2176
2248
  */
2177
2249
  async batch(e, t, { errorCall: r, updateList: i, batchOptions: a } = {}) {
2178
2250
  if (typeof BX24 > "u" || !BX24.callBatch) {
2179
- const c = new Error("BX24 is not initialized");
2180
- return console.error(c), !1;
2251
+ const l = new Error("BX24 is not initialized");
2252
+ return console.error(l), !1;
2181
2253
  }
2182
- return y(this, _t, ie).call(this, {
2254
+ return p(this, Tt, ae).call(this, {
2183
2255
  mode: "batch",
2184
2256
  commandList: e,
2185
2257
  progressCall: t,
@@ -2215,7 +2287,7 @@ class ve {
2215
2287
  const a = new Error("BX24 is not initialized");
2216
2288
  return console.error(a), !1;
2217
2289
  }
2218
- return y(this, _t, ie).call(this, {
2290
+ return p(this, Tt, ae).call(this, {
2219
2291
  mode: "batch-total-count",
2220
2292
  commandList: e,
2221
2293
  progressCall: t,
@@ -2237,42 +2309,42 @@ class ve {
2237
2309
  if (!this.isAdmin || (this.placeData = await this.getPlacement(), !this.placeData))
2238
2310
  return;
2239
2311
  const { appName: t, pathApp: r } = this.appConst;
2240
- let i = y(this, Tt, ne).call(this, e);
2312
+ let i = p(this, Et, oe).call(this, e);
2241
2313
  i = i.filter(
2242
- (l) => l.placement !== "PAGE_BACKGROUND_WORKER" && l.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2314
+ (c) => c.placement !== "PAGE_BACKGROUND_WORKER" && c.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2243
2315
  );
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 });
2316
+ const a = p(this, Kt, Me).call(this, r), l = new Set(i.map((c) => c.placement));
2317
+ for (const c of a)
2318
+ l.has(c.placement) || i.push({ placement: c.placement });
2247
2319
  if (i.length === 0)
2248
2320
  return;
2249
2321
  let h = t;
2250
2322
  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
2323
+ const u = h.replace(" CRM", ""), n = {}, g = [], f = /* @__PURE__ */ new Map();
2324
+ for (const c of this.placeData)
2325
+ f.has(c.placement) || f.set(c.placement, []), f.get(c.placement).push(c);
2326
+ for (let c = 0; c < i.length; c++) {
2327
+ const { placement: N, options: _ } = i[c], R = f.get(N) || [];
2328
+ if (R.some(
2329
+ (L) => L.handler === r
2258
2330
  ))
2259
2331
  continue;
2260
- const T = b.filter(
2261
- (M) => M.handler !== r
2332
+ const T = R.filter(
2333
+ (L) => L.handler !== r
2262
2334
  );
2263
- for (const M of T)
2264
- u.push({
2265
- placement: O,
2266
- handler: M.handler
2335
+ for (const L of T)
2336
+ g.push({
2337
+ placement: N,
2338
+ handler: L.handler
2267
2339
  });
2268
- n[`bind_${l}`] = {
2340
+ n[`bind_${c}`] = {
2269
2341
  method: "placement.bind",
2270
2342
  params: {
2271
- PLACEMENT: O,
2343
+ PLACEMENT: N,
2272
2344
  HANDLER: r,
2273
2345
  LANG_ALL: {
2274
2346
  ru: {
2275
- TITLE: O === "USER_PROFILE_TOOLBAR" ? f : h
2347
+ TITLE: N === "USER_PROFILE_TOOLBAR" ? u : h
2276
2348
  }
2277
2349
  },
2278
2350
  OPTIONS: {
@@ -2282,8 +2354,8 @@ class ve {
2282
2354
  }
2283
2355
  };
2284
2356
  }
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);
2357
+ g.length > 0 && await this.placementUnBind(g), Object.keys(n).length > 0 && (await this.batch(n), this.placeData = await this.getPlacement(), Object.values(n).forEach((c) => {
2358
+ console.log("Приложение успешно встроено в", c.params.PLACEMENT);
2287
2359
  }));
2288
2360
  }
2289
2361
  /**
@@ -2291,7 +2363,7 @@ class ve {
2291
2363
  * @param {string|string[]|Object|Object[]} place - Место или массив мест для отвязки
2292
2364
  */
2293
2365
  async placementUnBind(e) {
2294
- let t = y(this, Tt, ne).call(this, e);
2366
+ let t = p(this, Et, oe).call(this, e);
2295
2367
  if (t = t.filter(
2296
2368
  (i) => i.placement !== "PAGE_BACKGROUND_WORKER" && i.placement !== "PAGE_BACKGROUND_WORKER_ALL"
2297
2369
  ), t.length === 0)
@@ -2321,7 +2393,7 @@ class ve {
2321
2393
  }
2322
2394
  /* регистрация бота */
2323
2395
  async regBot({ code: e, type: t, name: r }) {
2324
- const { appName: i, pathApp: a, chatBotLogo: c } = this.appConst, h = this.appInfo.ID, f = await this.call({
2396
+ const { appName: i, pathApp: a, chatBotLogo: l } = this.appConst, h = this.appInfo.ID, u = await this.call({
2325
2397
  method: "imbot.register",
2326
2398
  params: {
2327
2399
  CODE: e ?? this.appInfo.CODE,
@@ -2344,7 +2416,7 @@ class ve {
2344
2416
  // Цвет чат-бота для мобильного приложения RED, GREEN, MINT, LIGHT_BLUE, DARK_BLUE, PURPLE, AQUA, PINK, LIME, BROWN, AZURE, KHAKI, SAND, MARENGO, GRAY, GRAPHITE
2345
2417
  EMAIL: "",
2346
2418
  // E-mail для связи. НЕЛЬЗЯ использовать e-mail, дублирующий e-mail реальных пользователей
2347
- PERSONAL_BIRTHDAY: bt().format("%Y-%m-%d"),
2419
+ PERSONAL_BIRTHDAY: Lt().format("%Y-%m-%d"),
2348
2420
  // День рождения в формате YYYY-mm-dd
2349
2421
  WORK_POSITION: "Почтальон",
2350
2422
  // Занимаемая должность, используется как описание чат-бота
@@ -2352,12 +2424,12 @@ class ve {
2352
2424
  // Ссылка на сайт
2353
2425
  PERSONAL_GENDER: "M",
2354
2426
  // Пол чат-бота, допустимые значения M - мужской, F - женский, пусто, если не требуется указывать
2355
- PERSONAL_PHOTO: c ?? ""
2427
+ PERSONAL_PHOTO: l ?? ""
2356
2428
  // Аватар чат-бота - base64
2357
2429
  }
2358
2430
  }
2359
2431
  });
2360
- return console.log("Чат-бот добавлен", f), f;
2432
+ return console.log("Чат-бот добавлен", u), u;
2361
2433
  }
2362
2434
  /* Убрать регистрацию бота */
2363
2435
  async unRegBot(e) {
@@ -2374,12 +2446,12 @@ class ve {
2374
2446
  return this.logger.getEntityList(e);
2375
2447
  }
2376
2448
  }
2377
- ut = new WeakSet(), Rt = function() {
2449
+ ht = new WeakSet(), St = function() {
2378
2450
  return this.batchClient || (this.batchClient = new K({
2379
2451
  callBatch: BX24.callBatch,
2380
2452
  callMethod: BX24.callMethod
2381
2453
  }), this.timeLimit = this.batchClient.timeLimit), this.batchClient;
2382
- }, xt = new WeakSet(), Oe = function() {
2454
+ }, Ft = new WeakSet(), Te = function() {
2383
2455
  return {
2384
2456
  start: () => {
2385
2457
  },
@@ -2388,17 +2460,17 @@ ut = new WeakSet(), Rt = function() {
2388
2460
  getEntityList: () => {
2389
2461
  }
2390
2462
  };
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() {
2463
+ }, _t = new WeakSet(), ne = async function(e, { skipInit: t = !1 } = {}) {
2464
+ this.logger ? (this.logger = new Ue(), t ? this.logger.enableBackworkerMode() : await this.logger.init(), e && typeof this.logger.runStorageMaintenance == "function" && this.logger.runStorageMaintenance()) : this.logger = p(this, Ft, Te).call(this);
2465
+ }, vt = new WeakSet(), Ee = function() {
2394
2466
  var r, i, a;
2395
2467
  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;
2396
2468
  return e === "PAGE_BACKGROUND_WORKER" || t === "PAGE_BACKGROUND_WORKER";
2397
- }, vt = new WeakSet(), Te = function() {
2469
+ }, Xt = new WeakSet(), Re = function() {
2398
2470
  return this.call({ method: "app.info" });
2399
- }, Xt = new WeakSet(), Ee = function() {
2471
+ }, Jt = new WeakSet(), Le = function() {
2400
2472
  return this.call({ method: "user.current" });
2401
- }, $ = new WeakSet(), ot = async function(e, t) {
2473
+ }, V = new WeakSet(), at = async function(e, t) {
2402
2474
  if (e)
2403
2475
  try {
2404
2476
  await this.logger.stop({
@@ -2408,115 +2480,115 @@ ut = new WeakSet(), Rt = function() {
2408
2480
  } catch (r) {
2409
2481
  console.error("Logger error:", r);
2410
2482
  }
2411
- }, _t = new WeakSet(), ie = async function({
2483
+ }, Tt = new WeakSet(), ae = async function({
2412
2484
  mode: e,
2413
2485
  commandList: t,
2414
2486
  progressCall: r,
2415
2487
  errorCall: i,
2416
2488
  updateList: a,
2417
- batchOptions: c
2489
+ batchOptions: l
2418
2490
  }) {
2419
- const h = y(this, ut, Rt).call(this), f = a ? this.logger.start({
2491
+ const h = p(this, ht, St).call(this), u = a ? this.logger.start({
2420
2492
  type: e,
2421
2493
  data: e === "batch" ? { commandList: t, updateList: a } : { commandList: t }
2422
2494
  }) : void 0;
2423
2495
  try {
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, {
2496
+ const n = e === "batch" ? await h.batch(t, r, l) : await h.batchTotalCount(t, r), g = p(this, jt, be).call(this, h, n, t, a);
2497
+ return Object.keys(g).length ? (i && i(g), await p(this, V, at).call(this, u, {
2426
2498
  status: "fail",
2427
- errorList: u
2428
- })) : await y(this, $, ot).call(this, f, { status: "success" }), n;
2499
+ errorList: g
2500
+ })) : await p(this, V, at).call(this, u, { status: "success" }), n;
2429
2501
  } catch (n) {
2430
- return await y(this, $, ot).call(this, f, {
2502
+ return await p(this, V, at).call(this, u, {
2431
2503
  status: "fail-runtime",
2432
2504
  errorList: { 0: n == null ? void 0 : n.toString() }
2433
2505
  }), console.error(n), !1;
2434
2506
  }
2435
- }, Jt = new WeakSet(), be = function(e, t, r, i) {
2507
+ }, jt = new WeakSet(), be = function(e, t, r, i) {
2436
2508
  let a = { ...e.errors };
2437
2509
  if (Object.values(e.errors).some(
2438
2510
  (h) => {
2439
2511
  if (typeof h != "string")
2440
2512
  return !1;
2441
- const f = h.toUpperCase();
2442
- return f === "TIMEOUT" || f === "OPERATION_TIME_LIMIT" || f.includes("TIMEOUT") || f.includes("OPERATION_TIME_LIMIT");
2513
+ const u = h.toUpperCase();
2514
+ return u === "TIMEOUT" || u === "OPERATION_TIME_LIMIT" || u.includes("TIMEOUT") || u.includes("OPERATION_TIME_LIMIT");
2443
2515
  }
2444
2516
  ) && i) {
2445
2517
  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();
2518
+ (f) => f !== "errorsList" && f !== "errorsListMessages"
2519
+ ) : [], u = new Set(Object.keys(e.errors || {})), n = /* @__PURE__ */ new Set();
2448
2520
  if (t) {
2449
- for (const d of h)
2450
- if (!f.has(d)) {
2451
- const A = t[d];
2452
- A != null && n.add(d);
2521
+ for (const f of h)
2522
+ if (!u.has(f)) {
2523
+ const A = t[f];
2524
+ A != null && n.add(f);
2453
2525
  }
2454
2526
  }
2455
- const u = Object.values(e.errors).find(
2456
- (d) => {
2457
- if (typeof d != "string")
2527
+ const g = Object.values(e.errors).find(
2528
+ (f) => {
2529
+ if (typeof f != "string")
2458
2530
  return !1;
2459
- const A = d.toUpperCase();
2531
+ const A = f.toUpperCase();
2460
2532
  return A === "TIMEOUT" || A === "OPERATION_TIME_LIMIT" || A.includes("TIMEOUT") || A.includes("OPERATION_TIME_LIMIT");
2461
2533
  }
2462
2534
  );
2463
- for (const d of Object.keys(r))
2464
- !n.has(d) && !e.errors[d] && (a[d] = u || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
2535
+ for (const f of Object.keys(r))
2536
+ !n.has(f) && !e.errors[f] && (a[f] = g || "TIMEOUT или OPERATION_TIME_LIMIT: запрос не был обработан");
2465
2537
  }
2466
2538
  return a;
2467
- }, Tt = new WeakSet(), ne = function(e) {
2539
+ }, Et = new WeakSet(), oe = function(e) {
2468
2540
  if (!e)
2469
2541
  return [];
2470
2542
  let t = [];
2471
2543
  return Array.isArray(e) ? t = e.map(
2472
2544
  (r) => typeof r == "string" ? { placement: r } : r
2473
2545
  ) : typeof e == "string" ? t = [{ placement: e }] : t = [e], t;
2474
- }, jt = new WeakSet(), Me = function(e) {
2546
+ }, Kt = new WeakSet(), Me = function(e) {
2475
2547
  return this.placeData ? this.placeData.filter((t) => !(t.placement === "PAGE_BACKGROUND_WORKER" || !t.handler || t.handler.includes(e))) : [];
2476
2548
  };
2477
- const Le = "szdl-utils-kit|";
2478
- function Ue() {
2549
+ const Se = "szdl-utils-kit|";
2550
+ function Ge() {
2479
2551
  if (typeof sessionStorage > "u")
2480
2552
  return `ephemeral-${Date.now()}-${Math.random().toString(16).slice(2)}`;
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;
2553
+ let d = sessionStorage.getItem("szdl-cross-tab-instance-id");
2554
+ return d || (d = `${Date.now()}-${Math.random().toString(16).slice(2)}`, sessionStorage.setItem("szdl-cross-tab-instance-id", d)), d;
2483
2555
  }
2484
- function Pe() {
2556
+ function Ye() {
2485
2557
  return typeof navigator < "u" && typeof navigator.locks < "u" && typeof navigator.locks.request == "function";
2486
2558
  }
2487
- const Zt = /* @__PURE__ */ new Map();
2488
- function Ge(m = "default") {
2559
+ const Vt = /* @__PURE__ */ new Map();
2560
+ function We(d = "default") {
2489
2561
  if (typeof BroadcastChannel > "u")
2490
2562
  return null;
2491
- const e = `${Le}bc:${m}`;
2492
- return Zt.has(e) || Zt.set(e, new BroadcastChannel(e)), Zt.get(e);
2563
+ const e = `${Se}bc:${d}`;
2564
+ return Vt.has(e) || Vt.set(e, new BroadcastChannel(e)), Vt.get(e);
2493
2565
  }
2494
- function Ae(m, e) {
2495
- const t = Ge(m);
2566
+ function ce(d, e) {
2567
+ const t = We(d);
2496
2568
  if (t)
2497
2569
  try {
2498
2570
  const r = e && typeof e == "object" && !Array.isArray(e) ? e : { data: e };
2499
2571
  t.postMessage({
2500
2572
  ...r,
2501
- tabId: Ue(),
2573
+ tabId: Ge(),
2502
2574
  ts: Date.now()
2503
2575
  });
2504
2576
  } catch {
2505
2577
  }
2506
2578
  }
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(
2579
+ async function xe(d, e, t = {}) {
2580
+ const { ifAvailable: r = !1 } = t, i = typeof d == "string" && d.length > 0 ? d : "default", a = `${Se}${i}`;
2581
+ return Ye() ? navigator.locks.request(
2510
2582
  a,
2511
2583
  { mode: "exclusive", ifAvailable: !!r },
2512
- async (c) => {
2513
- if (r && c == null)
2584
+ async (l) => {
2585
+ if (r && l == null)
2514
2586
  return { skipped: !0, coordination: "locks" };
2515
- Ae(i, { type: "lock-acquired", resource: i });
2587
+ ce(i, { type: "lock-acquired", resource: i });
2516
2588
  try {
2517
2589
  return { skipped: !1, result: await e(), coordination: "locks" };
2518
2590
  } finally {
2519
- Ae(i, { type: "lock-released", resource: i });
2591
+ ce(i, { type: "lock-released", resource: i });
2520
2592
  }
2521
2593
  }
2522
2594
  ) : { skipped: !1, result: await e(), coordination: "none" };
@@ -2537,16 +2609,16 @@ const q = {
2537
2609
  /** Heartbeat лидера во время appInit; null — вычислить из poll/activeMaxPause. */
2538
2610
  leaderHeartbeatMs: null
2539
2611
  };
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'`
2612
+ function Fe(d) {
2613
+ return d == null ? "user" : d === "user" || d === "portal" ? d : (console.warn(
2614
+ `BackgroundWorker: coordinationScope должен быть 'user' или 'portal', получено ${JSON.stringify(d)} — используется 'user'`
2543
2615
  ), "user");
2544
2616
  }
2545
- function xe(m = {}) {
2546
- const e = { ...q, ...m };
2617
+ function ve(d = {}) {
2618
+ const e = { ...q, ...d };
2547
2619
  for (const t of Object.keys(q)) {
2548
2620
  if (t === "leaderHeartbeatMs") {
2549
- const i = m == null ? void 0 : m.leaderHeartbeatMs;
2621
+ const i = d == null ? void 0 : d.leaderHeartbeatMs;
2550
2622
  if (i == null) {
2551
2623
  e.leaderHeartbeatMs = null;
2552
2624
  continue;
@@ -2560,19 +2632,19 @@ function xe(m = {}) {
2560
2632
  }
2561
2633
  return e;
2562
2634
  }
2563
- var Kt, Re, Et, ae, nt, mt, qt, Se;
2564
- class Xe {
2635
+ var qt, Ie, Rt, Ae, nt, mt, zt, De;
2636
+ class je {
2565
2637
  constructor(e) {
2566
- E(this, Kt);
2638
+ E(this, qt);
2567
2639
  /**
2568
2640
  * Канонический base URL для placement (без завершающего `/`).
2569
2641
  * Пустая строка — не биндить (некорректный или marketplace URL).
2570
2642
  */
2571
- E(this, Et);
2643
+ E(this, Rt);
2572
2644
  /** Ключ NAME в entity: userId или общий ключ портала. */
2573
2645
  E(this, nt);
2574
2646
  /** Имя Web Lock для подтверждения лидерства. */
2575
- E(this, qt);
2647
+ E(this, zt);
2576
2648
  w(this, "entityName", "tabs");
2577
2649
  w(this, "maxTabs", 20);
2578
2650
  w(this, "tabList", []);
@@ -2593,7 +2665,9 @@ class Xe {
2593
2665
  w(this, "defaultContinueBackground", () => !0);
2594
2666
  /** @type {'user' | 'portal'} */
2595
2667
  w(this, "coordinationScope", "user");
2596
- var f, n, u;
2668
+ /** Привязывать общую встройку PAGE_BACKGROUND_WORKER без USER_ID. @default true */
2669
+ w(this, "bindGeneralPlacement", !0);
2670
+ var n, g, f;
2597
2671
  if (!e) {
2598
2672
  console.error("BackgroundWorker: Нет опций конструктора");
2599
2673
  return;
@@ -2603,10 +2677,11 @@ class Xe {
2603
2677
  bx: r,
2604
2678
  users: i,
2605
2679
  continueBackground: a,
2606
- timing: c,
2607
- coordinationScope: h
2680
+ timing: l,
2681
+ coordinationScope: h,
2682
+ bindGeneralPlacement: u
2608
2683
  } = 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;
2684
+ this.bx = r, this.appInit = t, this.users = i, this.coordinationScope = Fe(h), this.bindGeneralPlacement = u !== !1, p(this, qt, Ie).call(this, l), ie(r), this.appPath = p(this, Rt, Ae).call(this, ((n = r == null ? void 0 : r.appConst) == null ? void 0 : n.pathApp) ?? ""), this.appName = ((g = r == null ? void 0 : r.appConst) == null ? void 0 : g.appName) ?? "", this.appCodeName = ((f = r == null ? void 0 : r.appConst) == null ? void 0 : f.appCodeName) ?? "", this.start = /* @__PURE__ */ new Date(), this.continueCondition = typeof a == "function" ? a : this.defaultContinueBackground;
2610
2685
  }
2611
2686
  async init() {
2612
2687
  if (!this.appInit) {
@@ -2650,8 +2725,8 @@ class Xe {
2650
2725
  if (typeof BX24 > "u" || !((e = BX24.placement) != null && e.info))
2651
2726
  return !1;
2652
2727
  try {
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;
2728
+ 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) || "", l = 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));
2729
+ return !l || h;
2655
2730
  } catch {
2656
2731
  return !1;
2657
2732
  }
@@ -2676,7 +2751,7 @@ class Xe {
2676
2751
  );
2677
2752
  }
2678
2753
  async getTabs() {
2679
- const e = y(this, nt, mt).call(this), t = await this.safeCall(
2754
+ const e = p(this, nt, mt).call(this), t = await this.safeCall(
2680
2755
  () => this.bx.call({
2681
2756
  method: "entity.item.get",
2682
2757
  params: {
@@ -2716,7 +2791,7 @@ class Xe {
2716
2791
  method: "entity.item.add",
2717
2792
  params: {
2718
2793
  ENTITY: this.entityName,
2719
- NAME: y(this, nt, mt).call(this),
2794
+ NAME: p(this, nt, mt).call(this),
2720
2795
  DETAIL_TEXT: JSON.stringify(e)
2721
2796
  }
2722
2797
  })
@@ -2740,7 +2815,7 @@ class Xe {
2740
2815
  params: {
2741
2816
  ENTITY: this.entityName,
2742
2817
  ID: this.id,
2743
- NAME: y(this, nt, mt).call(this),
2818
+ NAME: p(this, nt, mt).call(this),
2744
2819
  DETAIL_TEXT: JSON.stringify(t)
2745
2820
  }
2746
2821
  })
@@ -2769,22 +2844,22 @@ class Xe {
2769
2844
  ), !0;
2770
2845
  const i = +(((t = this.bx.userInfo) == null ? void 0 : t.ID) ?? 0), a = this.isIndividualPlacement(
2771
2846
  typeof window < "u" ? window.location.href : ""
2772
- ), c = !a;
2847
+ ), l = !a;
2773
2848
  if (!i)
2774
2849
  return !0;
2775
2850
  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=")))
2851
+ for (const u of r) {
2852
+ if (u.placement !== "PAGE_BACKGROUND_WORKER" || !(u.userId || u.handler && u.handler.includes("USER_ID=")))
2778
2853
  continue;
2779
- const u = f.userId || (f.handler ? this.extractUserIdFromHandler(f.handler) : null);
2780
- if (u && +u === i) {
2854
+ const g = u.userId || (u.handler ? this.extractUserIdFromHandler(u.handler) : null);
2855
+ if (g && +g === i) {
2781
2856
  h = !0;
2782
2857
  break;
2783
2858
  }
2784
2859
  }
2785
2860
  return a ? (console.log(
2786
2861
  "BackgroundWorker: Индивидуальная встройка - разрешено"
2787
- ), !0) : c && h ? (console.log(
2862
+ ), !0) : l && h ? (console.log(
2788
2863
  "BackgroundWorker: Есть личная встройка, общую не запускаем"
2789
2864
  ), !1) : (console.log(
2790
2865
  "BackgroundWorker: Проверка типа встройки пройдена, продолжаем"
@@ -2819,8 +2894,8 @@ class Xe {
2819
2894
  }
2820
2895
  }
2821
2896
  async refreshTabs(e = !1, t = this.activeMaxPause) {
2822
- const r = [], i = [], a = Date.now(), c = await this.getTabs();
2823
- for (const h of c) {
2897
+ const r = [], i = [], a = Date.now(), l = await this.getTabs();
2898
+ for (const h of l) {
2824
2899
  if (!(h != null && h.data)) {
2825
2900
  r.push(h);
2826
2901
  continue;
@@ -2836,13 +2911,13 @@ class Xe {
2836
2911
  selectLeaderId() {
2837
2912
  var t;
2838
2913
  return this.tabList.length && +((t = [...this.tabList].sort((r, i) => {
2839
- var h, f, n, u;
2914
+ var h, u, n, g;
2840
2915
  const a = new Date(
2841
- ((h = r.data) == null ? void 0 : h.createdAt) || ((f = r.data) == null ? void 0 : f.lastActive) || 0
2842
- ).getTime(), c = new Date(
2843
- ((n = i.data) == null ? void 0 : n.createdAt) || ((u = i.data) == null ? void 0 : u.lastActive) || 0
2916
+ ((h = r.data) == null ? void 0 : h.createdAt) || ((u = r.data) == null ? void 0 : u.lastActive) || 0
2917
+ ).getTime(), l = new Date(
2918
+ ((n = i.data) == null ? void 0 : n.createdAt) || ((g = i.data) == null ? void 0 : g.lastActive) || 0
2844
2919
  ).getTime();
2845
- return a === c ? (+r.id || 0) - (+i.id || 0) : a - c;
2920
+ return a === l ? (+r.id || 0) - (+i.id || 0) : a - l;
2846
2921
  })[0]) == null ? void 0 : t.id) || 0;
2847
2922
  }
2848
2923
  async confirmLeaderAfterLock() {
@@ -2851,8 +2926,8 @@ class Xe {
2851
2926
  return !!(e && +this.id == +e);
2852
2927
  }
2853
2928
  async runAsLeader() {
2854
- const e = y(this, qt, Se).call(this);
2855
- (await Ye(
2929
+ const e = p(this, zt, De).call(this);
2930
+ (await xe(
2856
2931
  e,
2857
2932
  async () => {
2858
2933
  if (await this.updateTabState(!0), console.log(
@@ -2892,15 +2967,15 @@ class Xe {
2892
2967
  );
2893
2968
  }
2894
2969
  async setBackgroundWorkerAll() {
2895
- var k, T, M, G;
2970
+ var k, T, L, G;
2896
2971
  if (!((k = this.bx) != null && k.isAdmin)) {
2897
2972
  console.log(
2898
2973
  "BackgroundWorker: setBackgroundWorkerAll доступен только админам"
2899
2974
  );
2900
2975
  return;
2901
2976
  }
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) ?? "");
2977
+ (T = this.users) != null && T.length || await this.getEntityData(), ie(this.bx);
2978
+ const e = p(this, Rt, Ae).call(this, ((G = (L = this.bx) == null ? void 0 : L.appConst) == null ? void 0 : G.pathApp) ?? "");
2904
2979
  if (!e) {
2905
2980
  console.error(
2906
2981
  "BackgroundWorker: setBackgroundWorkerAll — нет валидного pathApp, привязка PAGE_BACKGROUND_WORKER пропущена"
@@ -2911,47 +2986,44 @@ class Xe {
2911
2986
  () => this.bx.getPlacement()
2912
2987
  ), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
2913
2988
  let a = null;
2914
- (t || []).forEach((N) => {
2915
- if (N.placement !== "PAGE_BACKGROUND_WORKER")
2989
+ (t || []).forEach((O) => {
2990
+ if (O.placement !== "PAGE_BACKGROUND_WORKER")
2916
2991
  return;
2917
- if (N.userId || N.handler && N.handler.includes("USER_ID=")) {
2918
- const I = N.userId || (N.handler ? this.extractUserIdFromHandler(N.handler) : null);
2992
+ if (O.userId || O.handler && O.handler.includes("USER_ID=")) {
2993
+ const I = O.userId || (O.handler ? this.extractUserIdFromHandler(O.handler) : null);
2919
2994
  if (I) {
2920
- const C = +I;
2921
- r.set(C, N), i.has(C) || i.set(C, []), i.get(C).push(N);
2995
+ const B = +I;
2996
+ r.set(B, O), i.has(B) || i.set(B, []), i.get(B).push(O);
2922
2997
  }
2923
2998
  } else
2924
- a = N;
2999
+ a = O;
2925
3000
  });
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);
3001
+ const l = await this.resolveAdmins(), h = await this.getEligibleUsersForBackgroundWorker(l);
3002
+ h.sort((O, S) => {
3003
+ const I = O.LAST_LOGIN ? new Date(O.LAST_LOGIN) : /* @__PURE__ */ new Date(0);
2929
3004
  return (S.LAST_LOGIN ? new Date(S.LAST_LOGIN) : /* @__PURE__ */ new Date(0)) - I;
2930
3005
  });
2931
- const f = 10, n = this.coordinationScope === "portal" ? [] : h.slice(0, f), u = n.filter((N) => {
2932
- const S = r.get(+N.ID);
3006
+ const u = 10, n = h.slice(0, u), g = n.filter((O) => {
3007
+ const S = r.get(+O.ID);
2933
3008
  if (!S)
2934
3009
  return !0;
2935
- const I = `${e}?USER_ID=${N.ID}/`;
3010
+ const I = `${e}?USER_ID=${O.ID}/`;
2936
3011
  return S.handler !== I;
2937
- }), d = [];
2938
- if (this.coordinationScope === "portal")
2939
- for (const N of r.keys())
2940
- d.push(+N);
2941
- for (const [N] of r) {
2942
- const S = +N || 0;
2943
- h.find((C) => +C.ID === S) || d.push(S);
3012
+ }), f = [];
3013
+ for (const [O] of r) {
3014
+ const S = +O || 0;
3015
+ h.find((B) => +B.ID === S) || f.push(S);
2944
3016
  }
2945
- for (const N of n) {
2946
- const S = r.get(+N.ID);
3017
+ for (const O of n) {
3018
+ const S = r.get(+O.ID);
2947
3019
  if (!S)
2948
3020
  continue;
2949
- const I = `${e}?USER_ID=${N.ID}/`;
2950
- S.handler !== I && d.push(+N.ID);
3021
+ const I = `${e}?USER_ID=${O.ID}/`;
3022
+ S.handler !== I && f.push(+O.ID);
2951
3023
  }
2952
- const A = [], l = [...new Set(d)];
2953
- for (const N of l) {
2954
- const S = i.get(+N) || [];
3024
+ const A = [], c = [...new Set(f)];
3025
+ for (const O of c) {
3026
+ const S = i.get(+O) || [];
2955
3027
  for (const I of S)
2956
3028
  I != null && I.handler && A.push({
2957
3029
  method: "placement.unbind",
@@ -2961,28 +3033,28 @@ class Xe {
2961
3033
  }
2962
3034
  });
2963
3035
  }
2964
- const O = a && (u.length > 0 || a.handler !== `${e}`);
2965
- O && A.push({
3036
+ const N = a && (!this.bindGeneralPlacement || g.length > 0 || a.handler !== `${e}`);
3037
+ N && A.push({
2966
3038
  method: "placement.unbind",
2967
3039
  params: {
2968
3040
  PLACEMENT: "PAGE_BACKGROUND_WORKER",
2969
3041
  HANDLER: a.handler || `${e}`
2970
3042
  }
2971
3043
  });
2972
- for (const N of u)
3044
+ for (const O of g)
2973
3045
  A.push({
2974
3046
  method: "placement.bind",
2975
3047
  params: {
2976
3048
  PLACEMENT: "PAGE_BACKGROUND_WORKER",
2977
- HANDLER: `${e}?USER_ID=${N.ID}/`,
3049
+ HANDLER: `${e}?USER_ID=${O.ID}/`,
2978
3050
  LANG_ALL: { ru: { TITLE: this.appName } },
2979
3051
  OPTIONS: {
2980
- errorHandlerUrl: `${e}?USER_ID=${N.ID}/`
3052
+ errorHandlerUrl: `${e}?USER_ID=${O.ID}/`
2981
3053
  },
2982
- USER_ID: N.ID
3054
+ USER_ID: O.ID
2983
3055
  }
2984
3056
  });
2985
- (!a || O) && A.push({
3057
+ this.bindGeneralPlacement && (!a || N) && A.push({
2986
3058
  method: "placement.bind",
2987
3059
  params: {
2988
3060
  PLACEMENT: "PAGE_BACKGROUND_WORKER",
@@ -2992,20 +3064,20 @@ class Xe {
2992
3064
  }
2993
3065
  });
2994
3066
  const _ = A.filter(
2995
- (N) => N.method === "placement.unbind"
2996
- ), b = A.filter(
2997
- (N) => N.method === "placement.bind"
3067
+ (O) => O.method === "placement.unbind"
3068
+ ), R = A.filter(
3069
+ (O) => O.method === "placement.bind"
2998
3070
  );
2999
3071
  _.length && await this.safeCall(
3000
3072
  () => this.bx.batch(
3001
3073
  Object.fromEntries(
3002
- _.map((N, S) => [`unbind_${S}`, N])
3074
+ _.map((O, S) => [`unbind_${S}`, O])
3003
3075
  )
3004
3076
  )
3005
- ), b.length && await this.safeCall(
3077
+ ), R.length && await this.safeCall(
3006
3078
  () => this.bx.batch(
3007
3079
  Object.fromEntries(
3008
- b.map((N, S) => [`bind_${S}`, N])
3080
+ R.map((O, S) => [`bind_${S}`, O])
3009
3081
  )
3010
3082
  )
3011
3083
  ), A.length || console.log("setBackgroundWorkerAll: Нет операций");
@@ -3016,16 +3088,16 @@ class Xe {
3016
3088
  const r = +(((e = this.bx.userInfo) == null ? void 0 : e.ID) ?? 0), i = !!((t = this.bx) != null && t.isAdmin), a = await this.getAdminsList() || [];
3017
3089
  if (!i) {
3018
3090
  if (r && a.includes(+r)) {
3019
- const f = a.filter(
3091
+ const u = a.filter(
3020
3092
  (n) => +n != +r
3021
3093
  );
3022
- return await this.saveAdminsList(f), f;
3094
+ return await this.saveAdminsList(u), u;
3023
3095
  }
3024
3096
  return a;
3025
3097
  }
3026
- const c = /* @__PURE__ */ new Set([...a || []]);
3027
- r && c.add(+r);
3028
- const h = [...c].filter(Boolean);
3098
+ const l = /* @__PURE__ */ new Set([...a || []]);
3099
+ r && l.add(+r);
3100
+ const h = [...l].filter(Boolean);
3029
3101
  return await this.saveAdminsList(h), h;
3030
3102
  } catch (r) {
3031
3103
  return console.error("BackgroundWorker: resolveAdmins error", r), [];
@@ -3084,33 +3156,33 @@ class Xe {
3084
3156
  }
3085
3157
  }
3086
3158
  }
3087
- Kt = new WeakSet(), Re = function(e) {
3088
- const t = xe(e);
3159
+ qt = new WeakSet(), Ie = function(e) {
3160
+ const t = ve(e);
3089
3161
  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;
3090
3162
  const r = t.pollIntervalMs + t.pollIntervalJitterMs + t.leaderConfirmDelayMs;
3091
3163
  t.activeMaxPauseMs < r && console.warn(
3092
3164
  `BackgroundWorker: activeMaxPauseMs (${t.activeMaxPauseMs}) меньше poll+jitter+leaderConfirm (${r}) — «живые» вкладки могут удаляться раньше следующего тика`
3093
3165
  );
3094
- }, Et = new WeakSet(), ae = function(e) {
3166
+ }, Rt = new WeakSet(), Ae = function(e) {
3095
3167
  if (!e || typeof e != "string")
3096
3168
  return "";
3097
- const t = oe(e).replace(/\/+$/, "");
3098
- return t ? Ne(t) ? (console.error(
3169
+ const t = le(e).replace(/\/+$/, "");
3170
+ return t ? _e(t) ? (console.error(
3099
3171
  "BackgroundWorker: pathApp не должен указывать на /marketplace/app/… Откройте приложение во встроенном iframe (entry CDN), не в оболочке маркетплейса."
3100
3172
  ), "") : t : "";
3101
3173
  }, nt = new WeakSet(), mt = function() {
3102
3174
  var e, t;
3103
3175
  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)}`;
3176
+ }, zt = new WeakSet(), De = function() {
3177
+ return `background-worker:${this.entityName}:${p(this, nt, mt).call(this)}`;
3106
3178
  };
3107
3179
  export {
3108
- Xe as BackgroundWorker,
3180
+ je as BackgroundWorker,
3109
3181
  K as Batch,
3110
- ve as BxBoot,
3111
- de as BxHelper,
3112
- Ce as BxLogger,
3182
+ Je as BxBoot,
3183
+ ge as BxHelper,
3184
+ Ue as BxLogger,
3113
3185
  q as DEFAULT_BACKGROUND_WORKER_TIMING,
3114
- xe as resolveBackgroundWorkerTiming,
3115
- bt as tempus
3186
+ ve as resolveBackgroundWorkerTiming,
3187
+ Lt as tempus
3116
3188
  };