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