mqtt 5.15.2 → 5.16.1

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.
Files changed (36) hide show
  1. package/README.md +73 -0
  2. package/build/lib/KeepaliveManager.js +1 -1
  3. package/build/lib/KeepaliveManager.js.map +1 -1
  4. package/build/lib/client.d.ts +16 -1
  5. package/build/lib/client.js +130 -24
  6. package/build/lib/client.js.map +1 -1
  7. package/build/lib/handlers/ack.d.ts +1 -0
  8. package/build/lib/handlers/ack.js +13 -1
  9. package/build/lib/handlers/ack.js.map +1 -1
  10. package/build/lib/handlers/auth.d.ts +6 -2
  11. package/build/lib/handlers/auth.js +31 -9
  12. package/build/lib/handlers/auth.js.map +1 -1
  13. package/build/lib/handlers/connack.d.ts +4 -2
  14. package/build/lib/handlers/connack.js +24 -14
  15. package/build/lib/handlers/connack.js.map +1 -1
  16. package/build/lib/handlers/index.js +40 -16
  17. package/build/lib/handlers/index.js.map +1 -1
  18. package/build/lib/handlers/publish.js +35 -11
  19. package/build/lib/handlers/publish.js.map +1 -1
  20. package/build/lib/handlers/pubrel.js +1 -0
  21. package/build/lib/handlers/pubrel.js.map +1 -1
  22. package/build/lib/number-allocator.d.ts +12 -0
  23. package/build/lib/number-allocator.js +61 -0
  24. package/build/lib/number-allocator.js.map +1 -0
  25. package/build/lib/shared.d.ts +5 -1
  26. package/build/lib/shared.js.map +1 -1
  27. package/build/lib/topic-alias-send.js +1 -1
  28. package/build/lib/topic-alias-send.js.map +1 -1
  29. package/build/lib/unique-message-id-provider.js +1 -1
  30. package/build/lib/unique-message-id-provider.js.map +1 -1
  31. package/build/mqtt.d.ts +1 -0
  32. package/build/tsconfig.build.tsbuildinfo +1 -1
  33. package/dist/mqtt.esm.js +8 -8
  34. package/dist/mqtt.js +619 -3318
  35. package/dist/mqtt.min.js +8 -8
  36. package/package.json +5 -5
package/dist/mqtt.js CHANGED
@@ -31,80 +31,6 @@ var mqtt = (() => {
31
31
  });
32
32
 
33
33
  // node_modules/@jspm/core/nodelibs/browser/process.js
34
- var process_exports = {};
35
- __export(process_exports, {
36
- _debugEnd: () => _debugEnd,
37
- _debugProcess: () => _debugProcess,
38
- _events: () => _events,
39
- _eventsCount: () => _eventsCount,
40
- _exiting: () => _exiting,
41
- _fatalExceptions: () => _fatalExceptions,
42
- _getActiveHandles: () => _getActiveHandles,
43
- _getActiveRequests: () => _getActiveRequests,
44
- _kill: () => _kill,
45
- _linkedBinding: () => _linkedBinding,
46
- _maxListeners: () => _maxListeners,
47
- _preload_modules: () => _preload_modules,
48
- _rawDebug: () => _rawDebug,
49
- _startProfilerIdleNotifier: () => _startProfilerIdleNotifier,
50
- _stopProfilerIdleNotifier: () => _stopProfilerIdleNotifier,
51
- _tickCallback: () => _tickCallback,
52
- abort: () => abort,
53
- addListener: () => addListener,
54
- allowedNodeEnvironmentFlags: () => allowedNodeEnvironmentFlags,
55
- arch: () => arch,
56
- argv: () => argv,
57
- argv0: () => argv0,
58
- assert: () => assert,
59
- binding: () => binding,
60
- browser: () => browser,
61
- chdir: () => chdir,
62
- config: () => config,
63
- cpuUsage: () => cpuUsage,
64
- cwd: () => cwd,
65
- debugPort: () => debugPort,
66
- default: () => process,
67
- dlopen: () => dlopen,
68
- domain: () => domain,
69
- emit: () => emit,
70
- emitWarning: () => emitWarning,
71
- env: () => env,
72
- execArgv: () => execArgv,
73
- execPath: () => execPath,
74
- exit: () => exit,
75
- features: () => features,
76
- hasUncaughtExceptionCaptureCallback: () => hasUncaughtExceptionCaptureCallback,
77
- hrtime: () => hrtime,
78
- kill: () => kill,
79
- listeners: () => listeners,
80
- memoryUsage: () => memoryUsage,
81
- moduleLoadList: () => moduleLoadList,
82
- nextTick: () => nextTick,
83
- off: () => off,
84
- on: () => on,
85
- once: () => once,
86
- openStdin: () => openStdin,
87
- pid: () => pid,
88
- platform: () => platform,
89
- ppid: () => ppid,
90
- prependListener: () => prependListener,
91
- prependOnceListener: () => prependOnceListener,
92
- reallyExit: () => reallyExit,
93
- release: () => release,
94
- removeAllListeners: () => removeAllListeners,
95
- removeListener: () => removeListener,
96
- resourceUsage: () => resourceUsage,
97
- setSourceMapsEnabled: () => setSourceMapsEnabled,
98
- setUncaughtExceptionCaptureCallback: () => setUncaughtExceptionCaptureCallback,
99
- stderr: () => stderr,
100
- stdin: () => stdin,
101
- stdout: () => stdout,
102
- title: () => title,
103
- umask: () => umask,
104
- uptime: () => uptime,
105
- version: () => version,
106
- versions: () => versions
107
- });
108
34
  function unimplemented(name2) {
109
35
  throw new Error("Node.js process " + name2 + " is not supported by JSPM core outside of Node.js");
110
36
  }
@@ -395,10 +321,101 @@ var mqtt = (() => {
395
321
  }
396
322
  });
397
323
 
324
+ // scripts/browser-process.js
325
+ var browser_process_exports = {};
326
+ __export(browser_process_exports, {
327
+ _debugEnd: () => _debugEnd,
328
+ _debugProcess: () => _debugProcess,
329
+ _events: () => _events,
330
+ _eventsCount: () => _eventsCount,
331
+ _exiting: () => _exiting,
332
+ _fatalExceptions: () => _fatalExceptions,
333
+ _getActiveHandles: () => _getActiveHandles,
334
+ _getActiveRequests: () => _getActiveRequests,
335
+ _kill: () => _kill,
336
+ _linkedBinding: () => _linkedBinding,
337
+ _maxListeners: () => _maxListeners,
338
+ _preload_modules: () => _preload_modules,
339
+ _rawDebug: () => _rawDebug,
340
+ _startProfilerIdleNotifier: () => _startProfilerIdleNotifier,
341
+ _stopProfilerIdleNotifier: () => _stopProfilerIdleNotifier,
342
+ _tickCallback: () => _tickCallback,
343
+ abort: () => abort,
344
+ addListener: () => addListener,
345
+ allowedNodeEnvironmentFlags: () => allowedNodeEnvironmentFlags,
346
+ arch: () => arch,
347
+ argv: () => argv,
348
+ argv0: () => argv0,
349
+ assert: () => assert,
350
+ binding: () => binding,
351
+ browser: () => browser,
352
+ chdir: () => chdir,
353
+ config: () => config,
354
+ cpuUsage: () => cpuUsage,
355
+ cwd: () => cwd,
356
+ debugPort: () => debugPort,
357
+ default: () => browser_process_default,
358
+ dlopen: () => dlopen,
359
+ domain: () => domain,
360
+ emit: () => emit,
361
+ emitWarning: () => emitWarning,
362
+ env: () => env,
363
+ execArgv: () => execArgv,
364
+ execPath: () => execPath,
365
+ exit: () => exit,
366
+ features: () => features,
367
+ hasUncaughtExceptionCaptureCallback: () => hasUncaughtExceptionCaptureCallback,
368
+ hrtime: () => hrtime,
369
+ kill: () => kill,
370
+ listeners: () => listeners,
371
+ memoryUsage: () => memoryUsage,
372
+ moduleLoadList: () => moduleLoadList,
373
+ nextTick: () => nextTick2,
374
+ off: () => off,
375
+ on: () => on,
376
+ once: () => once,
377
+ openStdin: () => openStdin,
378
+ pid: () => pid,
379
+ platform: () => platform,
380
+ ppid: () => ppid,
381
+ prependListener: () => prependListener,
382
+ prependOnceListener: () => prependOnceListener,
383
+ reallyExit: () => reallyExit,
384
+ release: () => release,
385
+ removeAllListeners: () => removeAllListeners,
386
+ removeListener: () => removeListener,
387
+ resourceUsage: () => resourceUsage,
388
+ setSourceMapsEnabled: () => setSourceMapsEnabled,
389
+ setUncaughtExceptionCaptureCallback: () => setUncaughtExceptionCaptureCallback,
390
+ stderr: () => stderr,
391
+ stdin: () => stdin,
392
+ stdout: () => stdout,
393
+ title: () => title,
394
+ umask: () => umask,
395
+ uptime: () => uptime,
396
+ version: () => version,
397
+ versions: () => versions
398
+ });
399
+ function nextTick2(callback, ...args) {
400
+ schedule(() => callback(...args));
401
+ }
402
+ var schedule, browser_process_default;
403
+ var init_browser_process = __esm({
404
+ "scripts/browser-process.js"() {
405
+ init_dirname();
406
+ init_buffer2();
407
+ init_process2();
408
+ init_process();
409
+ init_process();
410
+ schedule = typeof queueMicrotask === "function" ? queueMicrotask : (fn) => setTimeout(fn, 0);
411
+ browser_process_default = { ...process, nextTick: nextTick2 };
412
+ }
413
+ });
414
+
398
415
  // node_modules/esbuild-plugin-polyfill-node/polyfills/process.js
399
416
  var init_process2 = __esm({
400
417
  "node_modules/esbuild-plugin-polyfill-node/polyfills/process.js"() {
401
- init_process();
418
+ init_browser_process();
402
419
  }
403
420
  });
404
421
 
@@ -3545,171 +3562,6 @@ var mqtt = (() => {
3545
3562
  }
3546
3563
  });
3547
3564
 
3548
- // node_modules/process/browser.js
3549
- var require_browser2 = __commonJS({
3550
- "node_modules/process/browser.js"(exports8, module) {
3551
- init_dirname();
3552
- init_buffer2();
3553
- init_process2();
3554
- var process3 = module.exports = {};
3555
- var cachedSetTimeout;
3556
- var cachedClearTimeout;
3557
- function defaultSetTimout() {
3558
- throw new Error("setTimeout has not been defined");
3559
- }
3560
- function defaultClearTimeout() {
3561
- throw new Error("clearTimeout has not been defined");
3562
- }
3563
- (function() {
3564
- try {
3565
- if (typeof setTimeout === "function") {
3566
- cachedSetTimeout = setTimeout;
3567
- } else {
3568
- cachedSetTimeout = defaultSetTimout;
3569
- }
3570
- } catch (e) {
3571
- cachedSetTimeout = defaultSetTimout;
3572
- }
3573
- try {
3574
- if (typeof clearTimeout === "function") {
3575
- cachedClearTimeout = clearTimeout;
3576
- } else {
3577
- cachedClearTimeout = defaultClearTimeout;
3578
- }
3579
- } catch (e) {
3580
- cachedClearTimeout = defaultClearTimeout;
3581
- }
3582
- })();
3583
- function runTimeout(fun) {
3584
- if (cachedSetTimeout === setTimeout) {
3585
- return setTimeout(fun, 0);
3586
- }
3587
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
3588
- cachedSetTimeout = setTimeout;
3589
- return setTimeout(fun, 0);
3590
- }
3591
- try {
3592
- return cachedSetTimeout(fun, 0);
3593
- } catch (e) {
3594
- try {
3595
- return cachedSetTimeout.call(null, fun, 0);
3596
- } catch (e2) {
3597
- return cachedSetTimeout.call(this, fun, 0);
3598
- }
3599
- }
3600
- }
3601
- function runClearTimeout(marker) {
3602
- if (cachedClearTimeout === clearTimeout) {
3603
- return clearTimeout(marker);
3604
- }
3605
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
3606
- cachedClearTimeout = clearTimeout;
3607
- return clearTimeout(marker);
3608
- }
3609
- try {
3610
- return cachedClearTimeout(marker);
3611
- } catch (e) {
3612
- try {
3613
- return cachedClearTimeout.call(null, marker);
3614
- } catch (e2) {
3615
- return cachedClearTimeout.call(this, marker);
3616
- }
3617
- }
3618
- }
3619
- var queue3 = [];
3620
- var draining3 = false;
3621
- var currentQueue3;
3622
- var queueIndex3 = -1;
3623
- function cleanUpNextTick3() {
3624
- if (!draining3 || !currentQueue3) {
3625
- return;
3626
- }
3627
- draining3 = false;
3628
- if (currentQueue3.length) {
3629
- queue3 = currentQueue3.concat(queue3);
3630
- } else {
3631
- queueIndex3 = -1;
3632
- }
3633
- if (queue3.length) {
3634
- drainQueue3();
3635
- }
3636
- }
3637
- function drainQueue3() {
3638
- if (draining3) {
3639
- return;
3640
- }
3641
- var timeout = runTimeout(cleanUpNextTick3);
3642
- draining3 = true;
3643
- var len = queue3.length;
3644
- while (len) {
3645
- currentQueue3 = queue3;
3646
- queue3 = [];
3647
- while (++queueIndex3 < len) {
3648
- if (currentQueue3) {
3649
- currentQueue3[queueIndex3].run();
3650
- }
3651
- }
3652
- queueIndex3 = -1;
3653
- len = queue3.length;
3654
- }
3655
- currentQueue3 = null;
3656
- draining3 = false;
3657
- runClearTimeout(timeout);
3658
- }
3659
- process3.nextTick = function(fun) {
3660
- var args = new Array(arguments.length - 1);
3661
- if (arguments.length > 1) {
3662
- for (var i = 1; i < arguments.length; i++) {
3663
- args[i - 1] = arguments[i];
3664
- }
3665
- }
3666
- queue3.push(new Item3(fun, args));
3667
- if (queue3.length === 1 && !draining3) {
3668
- runTimeout(drainQueue3);
3669
- }
3670
- };
3671
- function Item3(fun, array) {
3672
- this.fun = fun;
3673
- this.array = array;
3674
- }
3675
- Item3.prototype.run = function() {
3676
- this.fun.apply(null, this.array);
3677
- };
3678
- process3.title = "browser";
3679
- process3.browser = true;
3680
- process3.env = {};
3681
- process3.argv = [];
3682
- process3.version = "";
3683
- process3.versions = {};
3684
- function noop3() {
3685
- }
3686
- process3.on = noop3;
3687
- process3.addListener = noop3;
3688
- process3.once = noop3;
3689
- process3.off = noop3;
3690
- process3.removeListener = noop3;
3691
- process3.removeAllListeners = noop3;
3692
- process3.emit = noop3;
3693
- process3.prependListener = noop3;
3694
- process3.prependOnceListener = noop3;
3695
- process3.listeners = function(name2) {
3696
- return [];
3697
- };
3698
- process3.binding = function(name2) {
3699
- throw new Error("process.binding is not supported");
3700
- };
3701
- process3.cwd = function() {
3702
- return "/";
3703
- };
3704
- process3.chdir = function(dir) {
3705
- throw new Error("process.chdir is not supported");
3706
- };
3707
- process3.umask = function() {
3708
- return 0;
3709
- };
3710
- }
3711
- });
3712
-
3713
3565
  // node_modules/readable-stream/lib/internal/streams/utils.js
3714
3566
  var require_utils = __commonJS({
3715
3567
  "node_modules/readable-stream/lib/internal/streams/utils.js"(exports8, module) {
@@ -3929,7 +3781,7 @@ var mqtt = (() => {
3929
3781
  init_dirname();
3930
3782
  init_buffer2();
3931
3783
  init_process2();
3932
- var process3 = require_browser2();
3784
+ var process3 = (init_browser_process(), __toCommonJS(browser_process_exports));
3933
3785
  var { AbortError, codes } = require_errors();
3934
3786
  var { ERR_INVALID_ARG_TYPE, ERR_STREAM_PREMATURE_CLOSE } = codes;
3935
3787
  var { kEmptyObject, once: once4 } = require_util();
@@ -4184,7 +4036,7 @@ var mqtt = (() => {
4184
4036
  init_dirname();
4185
4037
  init_buffer2();
4186
4038
  init_process2();
4187
- var process3 = require_browser2();
4039
+ var process3 = (init_browser_process(), __toCommonJS(browser_process_exports));
4188
4040
  var {
4189
4041
  aggregateTwoErrors,
4190
4042
  codes: { ERR_MULTIPLE_CALLBACK },
@@ -5092,7 +4944,7 @@ var mqtt = (() => {
5092
4944
  init_dirname();
5093
4945
  init_buffer2();
5094
4946
  init_process2();
5095
- var process3 = require_browser2();
4947
+ var process3 = (init_browser_process(), __toCommonJS(browser_process_exports));
5096
4948
  var { PromisePrototypeThen, SymbolAsyncIterator, SymbolIterator } = require_primordials();
5097
4949
  var { Buffer: Buffer3 } = (init_buffer(), __toCommonJS(buffer_exports));
5098
4950
  var { ERR_INVALID_ARG_TYPE, ERR_STREAM_NULL_VALUES } = require_errors().codes;
@@ -5190,7 +5042,7 @@ var mqtt = (() => {
5190
5042
  init_dirname();
5191
5043
  init_buffer2();
5192
5044
  init_process2();
5193
- var process3 = require_browser2();
5045
+ var process3 = (init_browser_process(), __toCommonJS(browser_process_exports));
5194
5046
  var {
5195
5047
  ArrayPrototypeIndexOf,
5196
5048
  NumberIsInteger,
@@ -6159,7 +6011,7 @@ var mqtt = (() => {
6159
6011
  init_dirname();
6160
6012
  init_buffer2();
6161
6013
  init_process2();
6162
- var process3 = require_browser2();
6014
+ var process3 = (init_browser_process(), __toCommonJS(browser_process_exports));
6163
6015
  var {
6164
6016
  ArrayPrototypeSlice,
6165
6017
  Error: Error2,
@@ -6782,7 +6634,7 @@ var mqtt = (() => {
6782
6634
  init_dirname();
6783
6635
  init_buffer2();
6784
6636
  init_process2();
6785
- var process3 = require_browser2();
6637
+ var process3 = (init_browser_process(), __toCommonJS(browser_process_exports));
6786
6638
  var bufferModule = (init_buffer(), __toCommonJS(buffer_exports));
6787
6639
  var {
6788
6640
  isReadable,
@@ -7379,7 +7231,7 @@ var mqtt = (() => {
7379
7231
  init_dirname();
7380
7232
  init_buffer2();
7381
7233
  init_process2();
7382
- var process3 = require_browser2();
7234
+ var process3 = (init_browser_process(), __toCommonJS(browser_process_exports));
7383
7235
  var { ArrayIsArray, Promise: Promise2, SymbolAsyncIterator, SymbolDispose } = require_primordials();
7384
7236
  var eos = require_end_of_stream();
7385
7237
  var { once: once4 } = require_util();
@@ -8576,7 +8428,7 @@ var mqtt = (() => {
8576
8428
  });
8577
8429
 
8578
8430
  // node_modules/readable-stream/lib/ours/browser.js
8579
- var require_browser3 = __commonJS({
8431
+ var require_browser2 = __commonJS({
8580
8432
  "node_modules/readable-stream/lib/ours/browser.js"(exports8, module) {
8581
8433
  "use strict";
8582
8434
  init_dirname();
@@ -8980,7 +8832,7 @@ var mqtt = (() => {
8980
8832
  init_dirname();
8981
8833
  init_buffer2();
8982
8834
  init_process2();
8983
- var DuplexStream = require_browser3().Duplex;
8835
+ var DuplexStream = require_browser2().Duplex;
8984
8836
  var inherits = require_inherits_browser();
8985
8837
  var BufferList = require_BufferList();
8986
8838
  function BufferListStream(callback) {
@@ -9644,7 +9496,7 @@ var mqtt = (() => {
9644
9496
  });
9645
9497
 
9646
9498
  // node_modules/debug/src/browser.js
9647
- var require_browser4 = __commonJS({
9499
+ var require_browser3 = __commonJS({
9648
9500
  "node_modules/debug/src/browser.js"(exports8, module) {
9649
9501
  init_dirname();
9650
9502
  init_buffer2();
@@ -9793,8 +9645,8 @@ var mqtt = (() => {
9793
9645
  r = exports8.storage.getItem("debug") || exports8.storage.getItem("DEBUG");
9794
9646
  } catch (error) {
9795
9647
  }
9796
- if (!r && typeof process_exports !== "undefined" && "env" in process_exports) {
9797
- r = process_exports.env.DEBUG;
9648
+ if (!r && typeof browser_process_exports !== "undefined" && "env" in browser_process_exports) {
9649
+ r = browser_process_exports.env.DEBUG;
9798
9650
  }
9799
9651
  return r;
9800
9652
  }
@@ -9826,7 +9678,7 @@ var mqtt = (() => {
9826
9678
  var { EventEmitter: EventEmitter2 } = (init_events(), __toCommonJS(events_exports));
9827
9679
  var Packet = require_packet();
9828
9680
  var constants = require_constants();
9829
- var debug = require_browser4()("mqtt-packet:parser");
9681
+ var debug = require_browser3()("mqtt-packet:parser");
9830
9682
  var Parser = class _Parser extends EventEmitter2 {
9831
9683
  constructor() {
9832
9684
  super();
@@ -10549,12 +10401,12 @@ var mqtt = (() => {
10549
10401
  init_dirname();
10550
10402
  init_buffer2();
10551
10403
  init_process2();
10552
- if (typeof process_exports === "undefined" || !process_exports.version || process_exports.version.indexOf("v0.") === 0 || process_exports.version.indexOf("v1.") === 0 && process_exports.version.indexOf("v1.8.") !== 0) {
10553
- module.exports = { nextTick: nextTick3 };
10404
+ if (typeof browser_process_exports === "undefined" || !browser_process_exports.version || browser_process_exports.version.indexOf("v0.") === 0 || browser_process_exports.version.indexOf("v1.") === 0 && browser_process_exports.version.indexOf("v1.8.") !== 0) {
10405
+ module.exports = { nextTick: nextTick4 };
10554
10406
  } else {
10555
- module.exports = process_exports;
10407
+ module.exports = browser_process_exports;
10556
10408
  }
10557
- function nextTick3(fn, arg1, arg2, arg3) {
10409
+ function nextTick4(fn, arg1, arg2, arg3) {
10558
10410
  if (typeof fn !== "function") {
10559
10411
  throw new TypeError('"callback" argument must be a function');
10560
10412
  }
@@ -10563,17 +10415,17 @@ var mqtt = (() => {
10563
10415
  switch (len) {
10564
10416
  case 0:
10565
10417
  case 1:
10566
- return process_exports.nextTick(fn);
10418
+ return browser_process_exports.nextTick(fn);
10567
10419
  case 2:
10568
- return process_exports.nextTick(function afterTickOne() {
10420
+ return browser_process_exports.nextTick(function afterTickOne() {
10569
10421
  fn.call(null, arg1);
10570
10422
  });
10571
10423
  case 3:
10572
- return process_exports.nextTick(function afterTickTwo() {
10424
+ return browser_process_exports.nextTick(function afterTickTwo() {
10573
10425
  fn.call(null, arg1, arg2);
10574
10426
  });
10575
10427
  case 4:
10576
- return process_exports.nextTick(function afterTickThree() {
10428
+ return browser_process_exports.nextTick(function afterTickThree() {
10577
10429
  fn.call(null, arg1, arg2, arg3);
10578
10430
  });
10579
10431
  default:
@@ -10582,7 +10434,7 @@ var mqtt = (() => {
10582
10434
  while (i < args.length) {
10583
10435
  args[i++] = arguments[i];
10584
10436
  }
10585
- return process_exports.nextTick(function afterTick() {
10437
+ return browser_process_exports.nextTick(function afterTick() {
10586
10438
  fn.apply(null, args);
10587
10439
  });
10588
10440
  }
@@ -10601,8 +10453,8 @@ var mqtt = (() => {
10601
10453
  var empty2 = Buffer3.allocUnsafe(0);
10602
10454
  var zeroBuf = Buffer3.from([0]);
10603
10455
  var numbers = require_numbers();
10604
- var nextTick3 = require_process_nextick_args().nextTick;
10605
- var debug = require_browser4()("mqtt-packet:writeToStream");
10456
+ var nextTick4 = require_process_nextick_args().nextTick;
10457
+ var debug = require_browser3()("mqtt-packet:writeToStream");
10606
10458
  var numCache = numbers.cache;
10607
10459
  var generateNumber = numbers.generateNumber;
10608
10460
  var generateCache = numbers.generateCache;
@@ -10614,7 +10466,7 @@ var mqtt = (() => {
10614
10466
  debug("generate called");
10615
10467
  if (stream.cork) {
10616
10468
  stream.cork();
10617
- nextTick3(uncork, stream);
10469
+ nextTick4(uncork, stream);
10618
10470
  }
10619
10471
  if (toGenerate) {
10620
10472
  toGenerate = false;
@@ -11777,7 +11629,7 @@ var mqtt = (() => {
11777
11629
  init_buffer2();
11778
11630
  init_process2();
11779
11631
  Object.defineProperty(exports8, "__esModule", { value: true });
11780
- var readable_stream_1 = require_browser3();
11632
+ var readable_stream_1 = require_browser2();
11781
11633
  var streamsOpts = { objectMode: true };
11782
11634
  var defaultStoreOptions = {
11783
11635
  clean: true
@@ -11856,52 +11708,136 @@ var mqtt = (() => {
11856
11708
  }
11857
11709
  });
11858
11710
 
11859
- // build/lib/handlers/publish.js
11860
- var require_publish = __commonJS({
11861
- "build/lib/handlers/publish.js"(exports8) {
11711
+ // package-json:../../package.json
11712
+ var require_package = __commonJS({
11713
+ "package-json:../../package.json"(exports8, module) {
11714
+ module.exports = { version: "5.16.1" };
11715
+ }
11716
+ });
11717
+
11718
+ // build/lib/shared.js
11719
+ var require_shared = __commonJS({
11720
+ "build/lib/shared.js"(exports8) {
11862
11721
  "use strict";
11863
11722
  init_dirname();
11864
11723
  init_buffer2();
11865
11724
  init_process2();
11866
11725
  Object.defineProperty(exports8, "__esModule", { value: true });
11867
- var validReasonCodes = [0, 16, 128, 131, 135, 144, 145, 151, 153];
11868
- var handlePublish = (client, packet, done) => {
11869
- client.log("handlePublish: packet %o", packet);
11870
- done = typeof done !== "undefined" ? done : client.noop;
11871
- let topic = packet.topic.toString();
11872
- const message = packet.payload;
11873
- const { qos } = packet;
11874
- const { messageId } = packet;
11875
- const { options } = client;
11876
- if (client.options.protocolVersion === 5) {
11877
- let alias;
11878
- if (packet.properties) {
11879
- alias = packet.properties.topicAlias;
11880
- }
11881
- if (typeof alias !== "undefined") {
11882
- if (topic.length === 0) {
11883
- if (alias > 0 && alias <= 65535) {
11884
- const gotTopic = client["topicAliasRecv"].getTopicByAlias(alias);
11885
- if (gotTopic) {
11886
- topic = gotTopic;
11887
- client.log("handlePublish :: topic complemented by alias. topic: %s - alias: %d", topic, alias);
11888
- } else {
11889
- client.log("handlePublish :: unregistered topic alias. alias: %d", alias);
11890
- client.emit("error", new Error("Received unregistered Topic Alias"));
11891
- return;
11892
- }
11893
- } else {
11894
- client.log("handlePublish :: topic alias out of range. alias: %d", alias);
11895
- client.emit("error", new Error("Received Topic Alias is out of range"));
11896
- return;
11897
- }
11898
- } else if (client["topicAliasRecv"].put(topic, alias)) {
11899
- client.log("handlePublish :: registered topic: %s - alias: %d", topic, alias);
11900
- } else {
11901
- client.log("handlePublish :: topic alias out of range. alias: %d", alias);
11902
- client.emit("error", new Error("Received Topic Alias is out of range"));
11903
- return;
11904
- }
11726
+ exports8.MQTTJS_VERSION = exports8.nextTick = exports8.ErrorWithSubackPacket = exports8.ErrorWithReasonCode = void 0;
11727
+ exports8.applyMixin = applyMixin;
11728
+ var ErrorWithReasonCode = class _ErrorWithReasonCode extends Error {
11729
+ code;
11730
+ constructor(message, code) {
11731
+ super(message);
11732
+ this.code = code;
11733
+ Object.setPrototypeOf(this, _ErrorWithReasonCode.prototype);
11734
+ Object.getPrototypeOf(this).name = "ErrorWithReasonCode";
11735
+ }
11736
+ };
11737
+ exports8.ErrorWithReasonCode = ErrorWithReasonCode;
11738
+ var ErrorWithSubackPacket = class _ErrorWithSubackPacket extends Error {
11739
+ packet;
11740
+ constructor(message, packet) {
11741
+ super(message);
11742
+ this.packet = packet;
11743
+ Object.setPrototypeOf(this, _ErrorWithSubackPacket.prototype);
11744
+ Object.getPrototypeOf(this).name = "ErrorWithSubackPacket";
11745
+ }
11746
+ };
11747
+ exports8.ErrorWithSubackPacket = ErrorWithSubackPacket;
11748
+ function applyMixin(target, mixin, includeConstructor = false) {
11749
+ const inheritanceChain = [mixin];
11750
+ while (true) {
11751
+ const current = inheritanceChain[0];
11752
+ const base = Object.getPrototypeOf(current);
11753
+ if (base?.prototype) {
11754
+ inheritanceChain.unshift(base);
11755
+ } else {
11756
+ break;
11757
+ }
11758
+ }
11759
+ for (const ctor of inheritanceChain) {
11760
+ for (const prop of Object.getOwnPropertyNames(ctor.prototype)) {
11761
+ if (includeConstructor || prop !== "constructor") {
11762
+ Object.defineProperty(target.prototype, prop, Object.getOwnPropertyDescriptor(ctor.prototype, prop) ?? /* @__PURE__ */ Object.create(null));
11763
+ }
11764
+ }
11765
+ }
11766
+ }
11767
+ exports8.nextTick = typeof browser_process_exports?.nextTick === "function" ? browser_process_exports.nextTick : (callback) => {
11768
+ setTimeout(callback, 0);
11769
+ };
11770
+ exports8.MQTTJS_VERSION = require_package().version;
11771
+ }
11772
+ });
11773
+
11774
+ // build/lib/handlers/publish.js
11775
+ var require_publish = __commonJS({
11776
+ "build/lib/handlers/publish.js"(exports8) {
11777
+ "use strict";
11778
+ init_dirname();
11779
+ init_buffer2();
11780
+ init_process2();
11781
+ Object.defineProperty(exports8, "__esModule", { value: true });
11782
+ var shared_1 = require_shared();
11783
+ var validReasonCodes = [0, 16, 128, 131, 135, 144, 145, 151, 153];
11784
+ var TOPIC_ALIAS_INVALID = 148;
11785
+ var PROTOCOL_ERROR = 130;
11786
+ var rejectTopicAlias = (client, message, done, pump, reasonCode = TOPIC_ALIAS_INVALID) => {
11787
+ pump?.discardParsedPackets();
11788
+ if (!pump || pump.isCurrent()) {
11789
+ client["_cleanUp"](true);
11790
+ }
11791
+ done();
11792
+ client.emit("error", new shared_1.ErrorWithReasonCode(message, reasonCode));
11793
+ };
11794
+ var failCustomAck = (client, error, done) => {
11795
+ done();
11796
+ client.emit("error", error);
11797
+ };
11798
+ var handlePublish = (client, packet, done, pump) => {
11799
+ client.log("handlePublish: packet %o", packet);
11800
+ done = typeof done !== "undefined" ? done : client.noop;
11801
+ let topic = packet.topic.toString();
11802
+ const message = packet.payload;
11803
+ const { qos } = packet;
11804
+ const { messageId } = packet;
11805
+ const { options } = client;
11806
+ if (client.options.protocolVersion === 5) {
11807
+ let alias;
11808
+ if (packet.properties) {
11809
+ alias = packet.properties.topicAlias;
11810
+ }
11811
+ if (typeof alias !== "undefined") {
11812
+ const topicAliasRecv = client["topicAliasRecv"];
11813
+ if (!topicAliasRecv) {
11814
+ client.log("handlePublish :: received unexpected topic alias. alias: %d", alias);
11815
+ rejectTopicAlias(client, "Received a PUBLISH Topic Alias but no Topic Alias Maximum was advertised", done, pump);
11816
+ return;
11817
+ }
11818
+ if (topic.length === 0) {
11819
+ if (alias > 0 && alias <= 65535) {
11820
+ const gotTopic = topicAliasRecv.getTopicByAlias(alias);
11821
+ if (gotTopic) {
11822
+ topic = gotTopic;
11823
+ client.log("handlePublish :: topic complemented by alias. topic: %s - alias: %d", topic, alias);
11824
+ } else {
11825
+ client.log("handlePublish :: unregistered topic alias. alias: %d", alias);
11826
+ rejectTopicAlias(client, "Received unregistered Topic Alias", done, pump, PROTOCOL_ERROR);
11827
+ return;
11828
+ }
11829
+ } else {
11830
+ client.log("handlePublish :: topic alias out of range. alias: %d", alias);
11831
+ rejectTopicAlias(client, `Received Topic Alias ${alias} is outside the valid range 1-65535`, done, pump);
11832
+ return;
11833
+ }
11834
+ } else if (topicAliasRecv.put(topic, alias)) {
11835
+ client.log("handlePublish :: registered topic: %s - alias: %d", topic, alias);
11836
+ } else {
11837
+ client.log("handlePublish :: topic alias outside the advertised maximum. alias: %d - max: %d", alias, topicAliasRecv.max);
11838
+ rejectTopicAlias(client, `Received Topic Alias ${alias} is outside the advertised Topic Alias Maximum range 1-${topicAliasRecv.max}`, done, pump);
11839
+ return;
11840
+ }
11905
11841
  }
11906
11842
  }
11907
11843
  client.log("handlePublish: qos %d", qos);
@@ -11913,14 +11849,17 @@ var mqtt = (() => {
11913
11849
  error = null;
11914
11850
  }
11915
11851
  if (error) {
11916
- return client.emit("error", error);
11852
+ return failCustomAck(client, error, done);
11917
11853
  }
11918
11854
  if (validReasonCodes.indexOf(code) === -1) {
11919
- return client.emit("error", new Error("Wrong reason code for pubrec"));
11855
+ return failCustomAck(client, new Error("Wrong reason code for pubrec"), done);
11920
11856
  }
11921
11857
  if (code) {
11922
11858
  client["_sendPacket"]({ cmd: "pubrec", messageId, reasonCode: code }, done);
11923
11859
  } else {
11860
+ if (!client["_trackIncomingQoS2Publish"](messageId, done, pump)) {
11861
+ return;
11862
+ }
11924
11863
  client.incomingStore.put(packet, () => {
11925
11864
  client["_sendPacket"]({ cmd: "pubrec", messageId }, done);
11926
11865
  });
@@ -11935,10 +11874,10 @@ var mqtt = (() => {
11935
11874
  error = null;
11936
11875
  }
11937
11876
  if (error) {
11938
- return client.emit("error", error);
11877
+ return failCustomAck(client, error, done);
11939
11878
  }
11940
11879
  if (validReasonCodes.indexOf(code) === -1) {
11941
- return client.emit("error", new Error("Wrong reason code for puback"));
11880
+ return failCustomAck(client, new Error("Wrong reason code for puback"), done);
11942
11881
  }
11943
11882
  if (!code) {
11944
11883
  client.emit("message", topic, message, packet);
@@ -11965,66 +11904,63 @@ var mqtt = (() => {
11965
11904
  }
11966
11905
  });
11967
11906
 
11968
- // package-json:../../package.json
11969
- var require_package = __commonJS({
11970
- "package-json:../../package.json"(exports8, module) {
11971
- module.exports = { version: "5.15.2" };
11972
- }
11973
- });
11974
-
11975
- // build/lib/shared.js
11976
- var require_shared = __commonJS({
11977
- "build/lib/shared.js"(exports8) {
11907
+ // build/lib/handlers/auth.js
11908
+ var require_auth = __commonJS({
11909
+ "build/lib/handlers/auth.js"(exports8) {
11978
11910
  "use strict";
11979
11911
  init_dirname();
11980
11912
  init_buffer2();
11981
11913
  init_process2();
11982
11914
  Object.defineProperty(exports8, "__esModule", { value: true });
11983
- exports8.MQTTJS_VERSION = exports8.nextTick = exports8.ErrorWithSubackPacket = exports8.ErrorWithReasonCode = void 0;
11984
- exports8.applyMixin = applyMixin;
11985
- var ErrorWithReasonCode = class _ErrorWithReasonCode extends Error {
11986
- code;
11987
- constructor(message, code) {
11988
- super(message);
11989
- this.code = code;
11990
- Object.setPrototypeOf(this, _ErrorWithReasonCode.prototype);
11991
- Object.getPrototypeOf(this).name = "ErrorWithReasonCode";
11915
+ var shared_1 = require_shared();
11916
+ var PROTOCOL_ERROR = 130;
11917
+ var rejectAuth = (client, error, pump) => {
11918
+ client.log("handleAuth :: %s", error.message);
11919
+ pump?.discardParsedPackets();
11920
+ if (!pump || pump.isCurrent()) {
11921
+ client["_cleanUp"](true);
11992
11922
  }
11923
+ client.emit("error", error);
11993
11924
  };
11994
- exports8.ErrorWithReasonCode = ErrorWithReasonCode;
11995
- var ErrorWithSubackPacket = class _ErrorWithSubackPacket extends Error {
11996
- packet;
11997
- constructor(message, packet) {
11998
- super(message);
11999
- this.packet = packet;
12000
- Object.setPrototypeOf(this, _ErrorWithSubackPacket.prototype);
12001
- Object.getPrototypeOf(this).name = "ErrorWithSubackPacket";
11925
+ var handleAuth = (client, packet, pump) => {
11926
+ const { options } = client;
11927
+ const version4 = options.protocolVersion;
11928
+ const rc = version4 === 5 ? packet.reasonCode : packet.returnCode;
11929
+ if (version4 !== 5) {
11930
+ rejectAuth(client, new shared_1.ErrorWithReasonCode(`Protocol error: Auth packets are only supported in MQTT 5. Your version:${version4}`, PROTOCOL_ERROR), pump);
11931
+ return;
12002
11932
  }
12003
- };
12004
- exports8.ErrorWithSubackPacket = ErrorWithSubackPacket;
12005
- function applyMixin(target, mixin, includeConstructor = false) {
12006
- const inheritanceChain = [mixin];
12007
- while (true) {
12008
- const current = inheritanceChain[0];
12009
- const base = Object.getPrototypeOf(current);
12010
- if (base?.prototype) {
12011
- inheritanceChain.unshift(base);
12012
- } else {
12013
- break;
12014
- }
11933
+ const authenticationMethod = client["_authenticationMethod"];
11934
+ if (!authenticationMethod) {
11935
+ rejectAuth(client, new shared_1.ErrorWithReasonCode("Protocol error: Auth packet received but enhanced authentication was not requested", PROTOCOL_ERROR), pump);
11936
+ return;
12015
11937
  }
12016
- for (const ctor of inheritanceChain) {
12017
- for (const prop of Object.getOwnPropertyNames(ctor.prototype)) {
12018
- if (includeConstructor || prop !== "constructor") {
12019
- Object.defineProperty(target.prototype, prop, Object.getOwnPropertyDescriptor(ctor.prototype, prop) ?? /* @__PURE__ */ Object.create(null));
11938
+ if (packet.properties?.authenticationMethod !== authenticationMethod) {
11939
+ rejectAuth(client, new shared_1.ErrorWithReasonCode(`Protocol error: Auth packet Authentication Method does not match the "${authenticationMethod}" sent in CONNECT`, PROTOCOL_ERROR), pump);
11940
+ return;
11941
+ }
11942
+ client.handleAuth(packet, (err, packet2) => {
11943
+ if (err) {
11944
+ rejectAuth(client, err, pump);
11945
+ return;
11946
+ }
11947
+ if (rc === 0) {
11948
+ client.log("handleAuth :: authentication exchange completed successfully");
11949
+ return;
11950
+ }
11951
+ if (rc === 24) {
11952
+ if (!packet2) {
11953
+ rejectAuth(client, new shared_1.ErrorWithReasonCode("Protocol error: No auth packet to continue the authentication exchange", PROTOCOL_ERROR), pump);
11954
+ return;
12020
11955
  }
11956
+ client.reconnecting = false;
11957
+ client["_sendPacket"](packet2);
11958
+ return;
12021
11959
  }
12022
- }
12023
- }
12024
- exports8.nextTick = typeof process_exports?.nextTick === "function" ? process_exports.nextTick : (callback) => {
12025
- setTimeout(callback, 0);
11960
+ rejectAuth(client, new shared_1.ErrorWithReasonCode(`Protocol error: Auth packet reason code ${rc} is not one a broker may send`, PROTOCOL_ERROR), pump);
11961
+ });
12026
11962
  };
12027
- exports8.MQTTJS_VERSION = require_package().version;
11963
+ exports8.default = handleAuth;
12028
11964
  }
12029
11965
  });
12030
11966
 
@@ -12083,16 +12019,28 @@ var mqtt = (() => {
12083
12019
  161: "Subscription Identifiers not supported",
12084
12020
  162: "Wildcard Subscriptions not supported"
12085
12021
  };
12022
+ var acksForPendingCmd = {
12023
+ publish: ["puback", "pubrec", "pubcomp"],
12024
+ pubrel: ["pubcomp"],
12025
+ subscribe: ["suback"],
12026
+ unsubscribe: ["unsuback"]
12027
+ };
12086
12028
  var handleAck = (client, packet) => {
12087
12029
  const { messageId } = packet;
12088
12030
  const type = packet.cmd;
12089
12031
  let response = null;
12090
- const cb = client.outgoing[messageId] ? client.outgoing[messageId].cb : null;
12032
+ const pending = client.outgoing[messageId];
12033
+ const cb = pending ? pending.cb : null;
12091
12034
  let err = null;
12092
12035
  if (!cb) {
12093
12036
  client.log("_handleAck :: Server sent an ack in error. Ignoring.");
12094
12037
  return;
12095
12038
  }
12039
+ if (!acksForPendingCmd[pending.cmd]?.includes(type)) {
12040
+ client.log("_handleAck :: %s does not answer the pending %s on message id %d. Ignoring.", type, pending.cmd, messageId);
12041
+ client.emit("error", new Error(`Protocol error: ${type} does not answer the ${pending.cmd} pending on message id ${messageId}`));
12042
+ return;
12043
+ }
12096
12044
  client.log("_handleAck :: packet type", type);
12097
12045
  switch (type) {
12098
12046
  case "pubcomp":
@@ -12165,43 +12113,6 @@ var mqtt = (() => {
12165
12113
  }
12166
12114
  });
12167
12115
 
12168
- // build/lib/handlers/auth.js
12169
- var require_auth = __commonJS({
12170
- "build/lib/handlers/auth.js"(exports8) {
12171
- "use strict";
12172
- init_dirname();
12173
- init_buffer2();
12174
- init_process2();
12175
- Object.defineProperty(exports8, "__esModule", { value: true });
12176
- var shared_1 = require_shared();
12177
- var ack_1 = require_ack();
12178
- var handleAuth = (client, packet) => {
12179
- const { options } = client;
12180
- const version4 = options.protocolVersion;
12181
- const rc = version4 === 5 ? packet.reasonCode : packet.returnCode;
12182
- if (version4 !== 5) {
12183
- const err = new shared_1.ErrorWithReasonCode(`Protocol error: Auth packets are only supported in MQTT 5. Your version:${version4}`, rc);
12184
- client.emit("error", err);
12185
- return;
12186
- }
12187
- client.handleAuth(packet, (err, packet2) => {
12188
- if (err) {
12189
- client.emit("error", err);
12190
- return;
12191
- }
12192
- if (rc === 24) {
12193
- client.reconnecting = false;
12194
- client["_sendPacket"](packet2);
12195
- } else {
12196
- const error = new shared_1.ErrorWithReasonCode(`Connection refused: ${ack_1.ReasonCodes[rc]}`, rc);
12197
- client.emit("error", error);
12198
- }
12199
- });
12200
- };
12201
- exports8.default = handleAuth;
12202
- }
12203
- });
12204
-
12205
12116
  // node_modules/lru-cache/dist/commonjs/index.js
12206
12117
  var require_commonjs = __commonJS({
12207
12118
  "node_modules/lru-cache/dist/commonjs/index.js"(exports8) {
@@ -12213,7 +12124,7 @@ var mqtt = (() => {
12213
12124
  exports8.LRUCache = void 0;
12214
12125
  var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
12215
12126
  var warned = /* @__PURE__ */ new Set();
12216
- var PROCESS = typeof process_exports === "object" && !!process_exports ? process_exports : {};
12127
+ var PROCESS = typeof browser_process_exports === "object" && !!browser_process_exports ? browser_process_exports : {};
12217
12128
  var emitWarning3 = (msg, type, code, fn) => {
12218
12129
  typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
12219
12130
  };
@@ -13506,2885 +13417,148 @@ var mqtt = (() => {
13506
13417
  this.#disposed?.push([v, k, reason]);
13507
13418
  }
13508
13419
  }
13509
- this.#keyMap.delete(k);
13510
- this.#keyList[index] = void 0;
13511
- this.#valList[index] = void 0;
13512
- if (index === this.#tail) {
13513
- this.#tail = this.#prev[index];
13514
- } else if (index === this.#head) {
13515
- this.#head = this.#next[index];
13516
- } else {
13517
- const pi = this.#prev[index];
13518
- this.#next[pi] = this.#next[index];
13519
- const ni = this.#next[index];
13520
- this.#prev[ni] = this.#prev[index];
13521
- }
13522
- this.#size--;
13523
- this.#free.push(index);
13524
- }
13525
- }
13526
- }
13527
- if (this.#hasDisposeAfter && this.#disposed?.length) {
13528
- const dt = this.#disposed;
13529
- let task;
13530
- while (task = dt?.shift()) {
13531
- this.#disposeAfter?.(...task);
13532
- }
13533
- }
13534
- return deleted;
13535
- }
13536
- /**
13537
- * Clear the cache entirely, throwing away all values.
13538
- */
13539
- clear() {
13540
- return this.#clear("delete");
13541
- }
13542
- #clear(reason) {
13543
- for (const index of this.#rindexes({ allowStale: true })) {
13544
- const v = this.#valList[index];
13545
- if (this.#isBackgroundFetch(v)) {
13546
- v.__abortController.abort(new Error("deleted"));
13547
- } else {
13548
- const k = this.#keyList[index];
13549
- if (this.#hasDispose) {
13550
- this.#dispose?.(v, k, reason);
13551
- }
13552
- if (this.#hasDisposeAfter) {
13553
- this.#disposed?.push([v, k, reason]);
13554
- }
13555
- }
13556
- }
13557
- this.#keyMap.clear();
13558
- this.#valList.fill(void 0);
13559
- this.#keyList.fill(void 0);
13560
- if (this.#ttls && this.#starts) {
13561
- this.#ttls.fill(0);
13562
- this.#starts.fill(0);
13563
- }
13564
- if (this.#sizes) {
13565
- this.#sizes.fill(0);
13566
- }
13567
- this.#head = 0;
13568
- this.#tail = 0;
13569
- this.#free.length = 0;
13570
- this.#calculatedSize = 0;
13571
- this.#size = 0;
13572
- if (this.#hasDisposeAfter && this.#disposed) {
13573
- const dt = this.#disposed;
13574
- let task;
13575
- while (task = dt?.shift()) {
13576
- this.#disposeAfter?.(...task);
13577
- }
13578
- }
13579
- }
13580
- };
13581
- exports8.LRUCache = LRUCache;
13582
- }
13583
- });
13584
-
13585
- // node_modules/js-sdsl/dist/cjs/container/ContainerBase/index.js
13586
- var require_ContainerBase = __commonJS({
13587
- "node_modules/js-sdsl/dist/cjs/container/ContainerBase/index.js"(exports8) {
13588
- "use strict";
13589
- init_dirname();
13590
- init_buffer2();
13591
- init_process2();
13592
- Object.defineProperty(exports8, "t", {
13593
- value: true
13594
- });
13595
- exports8.ContainerIterator = exports8.Container = exports8.Base = void 0;
13596
- var ContainerIterator = class {
13597
- constructor(t = 0) {
13598
- this.iteratorType = t;
13599
- }
13600
- equals(t) {
13601
- return this.o === t.o;
13602
- }
13603
- };
13604
- exports8.ContainerIterator = ContainerIterator;
13605
- var Base = class {
13606
- constructor() {
13607
- this.i = 0;
13608
- }
13609
- get length() {
13610
- return this.i;
13611
- }
13612
- size() {
13613
- return this.i;
13614
- }
13615
- empty() {
13616
- return this.i === 0;
13617
- }
13618
- };
13619
- exports8.Base = Base;
13620
- var Container = class extends Base {
13621
- };
13622
- exports8.Container = Container;
13623
- }
13624
- });
13625
-
13626
- // node_modules/js-sdsl/dist/cjs/container/OtherContainer/Stack.js
13627
- var require_Stack = __commonJS({
13628
- "node_modules/js-sdsl/dist/cjs/container/OtherContainer/Stack.js"(exports8) {
13629
- "use strict";
13630
- init_dirname();
13631
- init_buffer2();
13632
- init_process2();
13633
- Object.defineProperty(exports8, "t", {
13634
- value: true
13635
- });
13636
- exports8.default = void 0;
13637
- var _ContainerBase = require_ContainerBase();
13638
- var Stack = class extends _ContainerBase.Base {
13639
- constructor(t = []) {
13640
- super();
13641
- this.S = [];
13642
- const s = this;
13643
- t.forEach((function(t2) {
13644
- s.push(t2);
13645
- }));
13646
- }
13647
- clear() {
13648
- this.i = 0;
13649
- this.S = [];
13650
- }
13651
- push(t) {
13652
- this.S.push(t);
13653
- this.i += 1;
13654
- return this.i;
13655
- }
13656
- pop() {
13657
- if (this.i === 0) return;
13658
- this.i -= 1;
13659
- return this.S.pop();
13660
- }
13661
- top() {
13662
- return this.S[this.i - 1];
13663
- }
13664
- };
13665
- var _default = Stack;
13666
- exports8.default = _default;
13667
- }
13668
- });
13669
-
13670
- // node_modules/js-sdsl/dist/cjs/container/OtherContainer/Queue.js
13671
- var require_Queue = __commonJS({
13672
- "node_modules/js-sdsl/dist/cjs/container/OtherContainer/Queue.js"(exports8) {
13673
- "use strict";
13674
- init_dirname();
13675
- init_buffer2();
13676
- init_process2();
13677
- Object.defineProperty(exports8, "t", {
13678
- value: true
13679
- });
13680
- exports8.default = void 0;
13681
- var _ContainerBase = require_ContainerBase();
13682
- var Queue = class extends _ContainerBase.Base {
13683
- constructor(t = []) {
13684
- super();
13685
- this.j = 0;
13686
- this.q = [];
13687
- const s = this;
13688
- t.forEach((function(t2) {
13689
- s.push(t2);
13690
- }));
13691
- }
13692
- clear() {
13693
- this.q = [];
13694
- this.i = this.j = 0;
13695
- }
13696
- push(t) {
13697
- const s = this.q.length;
13698
- if (this.j / s > 0.5 && this.j + this.i >= s && s > 4096) {
13699
- const s2 = this.i;
13700
- for (let t2 = 0; t2 < s2; ++t2) {
13701
- this.q[t2] = this.q[this.j + t2];
13702
- }
13703
- this.j = 0;
13704
- this.q[this.i] = t;
13705
- } else this.q[this.j + this.i] = t;
13706
- return ++this.i;
13707
- }
13708
- pop() {
13709
- if (this.i === 0) return;
13710
- const t = this.q[this.j++];
13711
- this.i -= 1;
13712
- return t;
13713
- }
13714
- front() {
13715
- if (this.i === 0) return;
13716
- return this.q[this.j];
13717
- }
13718
- };
13719
- var _default = Queue;
13720
- exports8.default = _default;
13721
- }
13722
- });
13723
-
13724
- // node_modules/js-sdsl/dist/cjs/container/OtherContainer/PriorityQueue.js
13725
- var require_PriorityQueue = __commonJS({
13726
- "node_modules/js-sdsl/dist/cjs/container/OtherContainer/PriorityQueue.js"(exports8) {
13727
- "use strict";
13728
- init_dirname();
13729
- init_buffer2();
13730
- init_process2();
13731
- Object.defineProperty(exports8, "t", {
13732
- value: true
13733
- });
13734
- exports8.default = void 0;
13735
- var _ContainerBase = require_ContainerBase();
13736
- var PriorityQueue = class extends _ContainerBase.Base {
13737
- constructor(t = [], s = function(t2, s2) {
13738
- if (t2 > s2) return -1;
13739
- if (t2 < s2) return 1;
13740
- return 0;
13741
- }, i = true) {
13742
- super();
13743
- this.v = s;
13744
- if (Array.isArray(t)) {
13745
- this.C = i ? [...t] : t;
13746
- } else {
13747
- this.C = [];
13748
- const s2 = this;
13749
- t.forEach((function(t2) {
13750
- s2.C.push(t2);
13751
- }));
13752
- }
13753
- this.i = this.C.length;
13754
- const e = this.i >> 1;
13755
- for (let t2 = this.i - 1 >> 1; t2 >= 0; --t2) {
13756
- this.k(t2, e);
13757
- }
13758
- }
13759
- m(t) {
13760
- const s = this.C[t];
13761
- while (t > 0) {
13762
- const i = t - 1 >> 1;
13763
- const e = this.C[i];
13764
- if (this.v(e, s) <= 0) break;
13765
- this.C[t] = e;
13766
- t = i;
13767
- }
13768
- this.C[t] = s;
13769
- }
13770
- k(t, s) {
13771
- const i = this.C[t];
13772
- while (t < s) {
13773
- let s2 = t << 1 | 1;
13774
- const e = s2 + 1;
13775
- let h = this.C[s2];
13776
- if (e < this.i && this.v(h, this.C[e]) > 0) {
13777
- s2 = e;
13778
- h = this.C[e];
13779
- }
13780
- if (this.v(h, i) >= 0) break;
13781
- this.C[t] = h;
13782
- t = s2;
13783
- }
13784
- this.C[t] = i;
13785
- }
13786
- clear() {
13787
- this.i = 0;
13788
- this.C.length = 0;
13789
- }
13790
- push(t) {
13791
- this.C.push(t);
13792
- this.m(this.i);
13793
- this.i += 1;
13794
- }
13795
- pop() {
13796
- if (this.i === 0) return;
13797
- const t = this.C[0];
13798
- const s = this.C.pop();
13799
- this.i -= 1;
13800
- if (this.i) {
13801
- this.C[0] = s;
13802
- this.k(0, this.i >> 1);
13803
- }
13804
- return t;
13805
- }
13806
- top() {
13807
- return this.C[0];
13808
- }
13809
- find(t) {
13810
- return this.C.indexOf(t) >= 0;
13811
- }
13812
- remove(t) {
13813
- const s = this.C.indexOf(t);
13814
- if (s < 0) return false;
13815
- if (s === 0) {
13816
- this.pop();
13817
- } else if (s === this.i - 1) {
13818
- this.C.pop();
13819
- this.i -= 1;
13820
- } else {
13821
- this.C.splice(s, 1, this.C.pop());
13822
- this.i -= 1;
13823
- this.m(s);
13824
- this.k(s, this.i >> 1);
13825
- }
13826
- return true;
13827
- }
13828
- updateItem(t) {
13829
- const s = this.C.indexOf(t);
13830
- if (s < 0) return false;
13831
- this.m(s);
13832
- this.k(s, this.i >> 1);
13833
- return true;
13834
- }
13835
- toArray() {
13836
- return [...this.C];
13837
- }
13838
- };
13839
- var _default = PriorityQueue;
13840
- exports8.default = _default;
13841
- }
13842
- });
13843
-
13844
- // node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.js
13845
- var require_Base = __commonJS({
13846
- "node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.js"(exports8) {
13847
- "use strict";
13848
- init_dirname();
13849
- init_buffer2();
13850
- init_process2();
13851
- Object.defineProperty(exports8, "t", {
13852
- value: true
13853
- });
13854
- exports8.default = void 0;
13855
- var _ContainerBase = require_ContainerBase();
13856
- var SequentialContainer = class extends _ContainerBase.Container {
13857
- };
13858
- var _default = SequentialContainer;
13859
- exports8.default = _default;
13860
- }
13861
- });
13862
-
13863
- // node_modules/js-sdsl/dist/cjs/utils/throwError.js
13864
- var require_throwError = __commonJS({
13865
- "node_modules/js-sdsl/dist/cjs/utils/throwError.js"(exports8) {
13866
- "use strict";
13867
- init_dirname();
13868
- init_buffer2();
13869
- init_process2();
13870
- Object.defineProperty(exports8, "t", {
13871
- value: true
13872
- });
13873
- exports8.throwIteratorAccessError = throwIteratorAccessError;
13874
- function throwIteratorAccessError() {
13875
- throw new RangeError("Iterator access denied!");
13876
- }
13877
- }
13878
- });
13879
-
13880
- // node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.js
13881
- var require_RandomIterator = __commonJS({
13882
- "node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.js"(exports8) {
13883
- "use strict";
13884
- init_dirname();
13885
- init_buffer2();
13886
- init_process2();
13887
- Object.defineProperty(exports8, "t", {
13888
- value: true
13889
- });
13890
- exports8.RandomIterator = void 0;
13891
- var _ContainerBase = require_ContainerBase();
13892
- var _throwError = require_throwError();
13893
- var RandomIterator = class extends _ContainerBase.ContainerIterator {
13894
- constructor(t, r) {
13895
- super(r);
13896
- this.o = t;
13897
- if (this.iteratorType === 0) {
13898
- this.pre = function() {
13899
- if (this.o === 0) {
13900
- (0, _throwError.throwIteratorAccessError)();
13901
- }
13902
- this.o -= 1;
13903
- return this;
13904
- };
13905
- this.next = function() {
13906
- if (this.o === this.container.size()) {
13907
- (0, _throwError.throwIteratorAccessError)();
13908
- }
13909
- this.o += 1;
13910
- return this;
13911
- };
13912
- } else {
13913
- this.pre = function() {
13914
- if (this.o === this.container.size() - 1) {
13915
- (0, _throwError.throwIteratorAccessError)();
13916
- }
13917
- this.o += 1;
13918
- return this;
13919
- };
13920
- this.next = function() {
13921
- if (this.o === -1) {
13922
- (0, _throwError.throwIteratorAccessError)();
13923
- }
13924
- this.o -= 1;
13925
- return this;
13926
- };
13927
- }
13928
- }
13929
- get pointer() {
13930
- return this.container.getElementByPos(this.o);
13931
- }
13932
- set pointer(t) {
13933
- this.container.setElementByPos(this.o, t);
13934
- }
13935
- };
13936
- exports8.RandomIterator = RandomIterator;
13937
- }
13938
- });
13939
-
13940
- // node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.js
13941
- var require_Vector = __commonJS({
13942
- "node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.js"(exports8) {
13943
- "use strict";
13944
- init_dirname();
13945
- init_buffer2();
13946
- init_process2();
13947
- Object.defineProperty(exports8, "t", {
13948
- value: true
13949
- });
13950
- exports8.default = void 0;
13951
- var _Base = _interopRequireDefault(require_Base());
13952
- var _RandomIterator = require_RandomIterator();
13953
- function _interopRequireDefault(t) {
13954
- return t && t.t ? t : {
13955
- default: t
13956
- };
13957
- }
13958
- var VectorIterator = class _VectorIterator extends _RandomIterator.RandomIterator {
13959
- constructor(t, r, e) {
13960
- super(t, e);
13961
- this.container = r;
13962
- }
13963
- copy() {
13964
- return new _VectorIterator(this.o, this.container, this.iteratorType);
13965
- }
13966
- };
13967
- var Vector = class extends _Base.default {
13968
- constructor(t = [], r = true) {
13969
- super();
13970
- if (Array.isArray(t)) {
13971
- this.J = r ? [...t] : t;
13972
- this.i = t.length;
13973
- } else {
13974
- this.J = [];
13975
- const r2 = this;
13976
- t.forEach((function(t2) {
13977
- r2.pushBack(t2);
13978
- }));
13979
- }
13980
- }
13981
- clear() {
13982
- this.i = 0;
13983
- this.J.length = 0;
13984
- }
13985
- begin() {
13986
- return new VectorIterator(0, this);
13987
- }
13988
- end() {
13989
- return new VectorIterator(this.i, this);
13990
- }
13991
- rBegin() {
13992
- return new VectorIterator(this.i - 1, this, 1);
13993
- }
13994
- rEnd() {
13995
- return new VectorIterator(-1, this, 1);
13996
- }
13997
- front() {
13998
- return this.J[0];
13999
- }
14000
- back() {
14001
- return this.J[this.i - 1];
14002
- }
14003
- getElementByPos(t) {
14004
- if (t < 0 || t > this.i - 1) {
14005
- throw new RangeError();
14006
- }
14007
- return this.J[t];
14008
- }
14009
- eraseElementByPos(t) {
14010
- if (t < 0 || t > this.i - 1) {
14011
- throw new RangeError();
14012
- }
14013
- this.J.splice(t, 1);
14014
- this.i -= 1;
14015
- return this.i;
14016
- }
14017
- eraseElementByValue(t) {
14018
- let r = 0;
14019
- for (let e = 0; e < this.i; ++e) {
14020
- if (this.J[e] !== t) {
14021
- this.J[r++] = this.J[e];
14022
- }
14023
- }
14024
- this.i = this.J.length = r;
14025
- return this.i;
14026
- }
14027
- eraseElementByIterator(t) {
14028
- const r = t.o;
14029
- t = t.next();
14030
- this.eraseElementByPos(r);
14031
- return t;
14032
- }
14033
- pushBack(t) {
14034
- this.J.push(t);
14035
- this.i += 1;
14036
- return this.i;
14037
- }
14038
- popBack() {
14039
- if (this.i === 0) return;
14040
- this.i -= 1;
14041
- return this.J.pop();
14042
- }
14043
- setElementByPos(t, r) {
14044
- if (t < 0 || t > this.i - 1) {
14045
- throw new RangeError();
14046
- }
14047
- this.J[t] = r;
14048
- }
14049
- insert(t, r, e = 1) {
14050
- if (t < 0 || t > this.i) {
14051
- throw new RangeError();
14052
- }
14053
- this.J.splice(t, 0, ...new Array(e).fill(r));
14054
- this.i += e;
14055
- return this.i;
14056
- }
14057
- find(t) {
14058
- for (let r = 0; r < this.i; ++r) {
14059
- if (this.J[r] === t) {
14060
- return new VectorIterator(r, this);
14061
- }
14062
- }
14063
- return this.end();
14064
- }
14065
- reverse() {
14066
- this.J.reverse();
14067
- }
14068
- unique() {
14069
- let t = 1;
14070
- for (let r = 1; r < this.i; ++r) {
14071
- if (this.J[r] !== this.J[r - 1]) {
14072
- this.J[t++] = this.J[r];
14073
- }
14074
- }
14075
- this.i = this.J.length = t;
14076
- return this.i;
14077
- }
14078
- sort(t) {
14079
- this.J.sort(t);
14080
- }
14081
- forEach(t) {
14082
- for (let r = 0; r < this.i; ++r) {
14083
- t(this.J[r], r, this);
14084
- }
14085
- }
14086
- [Symbol.iterator]() {
14087
- return function* () {
14088
- yield* this.J;
14089
- }.bind(this)();
14090
- }
14091
- };
14092
- var _default = Vector;
14093
- exports8.default = _default;
14094
- }
14095
- });
14096
-
14097
- // node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.js
14098
- var require_LinkList = __commonJS({
14099
- "node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.js"(exports8) {
14100
- "use strict";
14101
- init_dirname();
14102
- init_buffer2();
14103
- init_process2();
14104
- Object.defineProperty(exports8, "t", {
14105
- value: true
14106
- });
14107
- exports8.default = void 0;
14108
- var _Base = _interopRequireDefault(require_Base());
14109
- var _ContainerBase = require_ContainerBase();
14110
- var _throwError = require_throwError();
14111
- function _interopRequireDefault(t) {
14112
- return t && t.t ? t : {
14113
- default: t
14114
- };
14115
- }
14116
- var LinkListIterator = class _LinkListIterator extends _ContainerBase.ContainerIterator {
14117
- constructor(t, i, s, r) {
14118
- super(r);
14119
- this.o = t;
14120
- this.h = i;
14121
- this.container = s;
14122
- if (this.iteratorType === 0) {
14123
- this.pre = function() {
14124
- if (this.o.L === this.h) {
14125
- (0, _throwError.throwIteratorAccessError)();
14126
- }
14127
- this.o = this.o.L;
14128
- return this;
14129
- };
14130
- this.next = function() {
14131
- if (this.o === this.h) {
14132
- (0, _throwError.throwIteratorAccessError)();
14133
- }
14134
- this.o = this.o.B;
14135
- return this;
14136
- };
14137
- } else {
14138
- this.pre = function() {
14139
- if (this.o.B === this.h) {
14140
- (0, _throwError.throwIteratorAccessError)();
14141
- }
14142
- this.o = this.o.B;
14143
- return this;
14144
- };
14145
- this.next = function() {
14146
- if (this.o === this.h) {
14147
- (0, _throwError.throwIteratorAccessError)();
14148
- }
14149
- this.o = this.o.L;
14150
- return this;
14151
- };
14152
- }
14153
- }
14154
- get pointer() {
14155
- if (this.o === this.h) {
14156
- (0, _throwError.throwIteratorAccessError)();
14157
- }
14158
- return this.o.l;
14159
- }
14160
- set pointer(t) {
14161
- if (this.o === this.h) {
14162
- (0, _throwError.throwIteratorAccessError)();
14163
- }
14164
- this.o.l = t;
14165
- }
14166
- copy() {
14167
- return new _LinkListIterator(this.o, this.h, this.container, this.iteratorType);
14168
- }
14169
- };
14170
- var LinkList = class extends _Base.default {
14171
- constructor(t = []) {
14172
- super();
14173
- this.h = {};
14174
- this.p = this._ = this.h.L = this.h.B = this.h;
14175
- const i = this;
14176
- t.forEach((function(t2) {
14177
- i.pushBack(t2);
14178
- }));
14179
- }
14180
- V(t) {
14181
- const { L: i, B: s } = t;
14182
- i.B = s;
14183
- s.L = i;
14184
- if (t === this.p) {
14185
- this.p = s;
14186
- }
14187
- if (t === this._) {
14188
- this._ = i;
14189
- }
14190
- this.i -= 1;
14191
- }
14192
- G(t, i) {
14193
- const s = i.B;
14194
- const r = {
14195
- l: t,
14196
- L: i,
14197
- B: s
14198
- };
14199
- i.B = r;
14200
- s.L = r;
14201
- if (i === this.h) {
14202
- this.p = r;
14203
- }
14204
- if (s === this.h) {
14205
- this._ = r;
14206
- }
14207
- this.i += 1;
14208
- }
14209
- clear() {
14210
- this.i = 0;
14211
- this.p = this._ = this.h.L = this.h.B = this.h;
14212
- }
14213
- begin() {
14214
- return new LinkListIterator(this.p, this.h, this);
14215
- }
14216
- end() {
14217
- return new LinkListIterator(this.h, this.h, this);
14218
- }
14219
- rBegin() {
14220
- return new LinkListIterator(this._, this.h, this, 1);
14221
- }
14222
- rEnd() {
14223
- return new LinkListIterator(this.h, this.h, this, 1);
14224
- }
14225
- front() {
14226
- return this.p.l;
14227
- }
14228
- back() {
14229
- return this._.l;
14230
- }
14231
- getElementByPos(t) {
14232
- if (t < 0 || t > this.i - 1) {
14233
- throw new RangeError();
14234
- }
14235
- let i = this.p;
14236
- while (t--) {
14237
- i = i.B;
14238
- }
14239
- return i.l;
14240
- }
14241
- eraseElementByPos(t) {
14242
- if (t < 0 || t > this.i - 1) {
14243
- throw new RangeError();
14244
- }
14245
- let i = this.p;
14246
- while (t--) {
14247
- i = i.B;
14248
- }
14249
- this.V(i);
14250
- return this.i;
14251
- }
14252
- eraseElementByValue(t) {
14253
- let i = this.p;
14254
- while (i !== this.h) {
14255
- if (i.l === t) {
14256
- this.V(i);
14257
- }
14258
- i = i.B;
14259
- }
14260
- return this.i;
14261
- }
14262
- eraseElementByIterator(t) {
14263
- const i = t.o;
14264
- if (i === this.h) {
14265
- (0, _throwError.throwIteratorAccessError)();
14266
- }
14267
- t = t.next();
14268
- this.V(i);
14269
- return t;
14270
- }
14271
- pushBack(t) {
14272
- this.G(t, this._);
14273
- return this.i;
14274
- }
14275
- popBack() {
14276
- if (this.i === 0) return;
14277
- const t = this._.l;
14278
- this.V(this._);
14279
- return t;
14280
- }
14281
- pushFront(t) {
14282
- this.G(t, this.h);
14283
- return this.i;
14284
- }
14285
- popFront() {
14286
- if (this.i === 0) return;
14287
- const t = this.p.l;
14288
- this.V(this.p);
14289
- return t;
14290
- }
14291
- setElementByPos(t, i) {
14292
- if (t < 0 || t > this.i - 1) {
14293
- throw new RangeError();
14294
- }
14295
- let s = this.p;
14296
- while (t--) {
14297
- s = s.B;
14298
- }
14299
- s.l = i;
14300
- }
14301
- insert(t, i, s = 1) {
14302
- if (t < 0 || t > this.i) {
14303
- throw new RangeError();
14304
- }
14305
- if (s <= 0) return this.i;
14306
- if (t === 0) {
14307
- while (s--) this.pushFront(i);
14308
- } else if (t === this.i) {
14309
- while (s--) this.pushBack(i);
14310
- } else {
14311
- let r = this.p;
14312
- for (let i2 = 1; i2 < t; ++i2) {
14313
- r = r.B;
14314
- }
14315
- const e = r.B;
14316
- this.i += s;
14317
- while (s--) {
14318
- r.B = {
14319
- l: i,
14320
- L: r
14321
- };
14322
- r.B.L = r;
14323
- r = r.B;
14324
- }
14325
- r.B = e;
14326
- e.L = r;
14327
- }
14328
- return this.i;
14329
- }
14330
- find(t) {
14331
- let i = this.p;
14332
- while (i !== this.h) {
14333
- if (i.l === t) {
14334
- return new LinkListIterator(i, this.h, this);
14335
- }
14336
- i = i.B;
14337
- }
14338
- return this.end();
14339
- }
14340
- reverse() {
14341
- if (this.i <= 1) return;
14342
- let t = this.p;
14343
- let i = this._;
14344
- let s = 0;
14345
- while (s << 1 < this.i) {
14346
- const r = t.l;
14347
- t.l = i.l;
14348
- i.l = r;
14349
- t = t.B;
14350
- i = i.L;
14351
- s += 1;
14352
- }
14353
- }
14354
- unique() {
14355
- if (this.i <= 1) {
14356
- return this.i;
14357
- }
14358
- let t = this.p;
14359
- while (t !== this.h) {
14360
- let i = t;
14361
- while (i.B !== this.h && i.l === i.B.l) {
14362
- i = i.B;
14363
- this.i -= 1;
14364
- }
14365
- t.B = i.B;
14366
- t.B.L = t;
14367
- t = t.B;
14368
- }
14369
- return this.i;
14370
- }
14371
- sort(t) {
14372
- if (this.i <= 1) return;
14373
- const i = [];
14374
- this.forEach((function(t2) {
14375
- i.push(t2);
14376
- }));
14377
- i.sort(t);
14378
- let s = this.p;
14379
- i.forEach((function(t2) {
14380
- s.l = t2;
14381
- s = s.B;
14382
- }));
14383
- }
14384
- merge(t) {
14385
- const i = this;
14386
- if (this.i === 0) {
14387
- t.forEach((function(t2) {
14388
- i.pushBack(t2);
14389
- }));
14390
- } else {
14391
- let s = this.p;
14392
- t.forEach((function(t2) {
14393
- while (s !== i.h && s.l <= t2) {
14394
- s = s.B;
14395
- }
14396
- i.G(t2, s.L);
14397
- }));
14398
- }
14399
- return this.i;
14400
- }
14401
- forEach(t) {
14402
- let i = this.p;
14403
- let s = 0;
14404
- while (i !== this.h) {
14405
- t(i.l, s++, this);
14406
- i = i.B;
14407
- }
14408
- }
14409
- [Symbol.iterator]() {
14410
- return function* () {
14411
- if (this.i === 0) return;
14412
- let t = this.p;
14413
- while (t !== this.h) {
14414
- yield t.l;
14415
- t = t.B;
14416
- }
14417
- }.bind(this)();
14418
- }
14419
- };
14420
- var _default = LinkList;
14421
- exports8.default = _default;
14422
- }
14423
- });
14424
-
14425
- // node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.js
14426
- var require_Deque = __commonJS({
14427
- "node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.js"(exports8) {
14428
- "use strict";
14429
- init_dirname();
14430
- init_buffer2();
14431
- init_process2();
14432
- Object.defineProperty(exports8, "t", {
14433
- value: true
14434
- });
14435
- exports8.default = void 0;
14436
- var _Base = _interopRequireDefault(require_Base());
14437
- var _RandomIterator = require_RandomIterator();
14438
- function _interopRequireDefault(t) {
14439
- return t && t.t ? t : {
14440
- default: t
14441
- };
14442
- }
14443
- var DequeIterator = class _DequeIterator extends _RandomIterator.RandomIterator {
14444
- constructor(t, i, s) {
14445
- super(t, s);
14446
- this.container = i;
14447
- }
14448
- copy() {
14449
- return new _DequeIterator(this.o, this.container, this.iteratorType);
14450
- }
14451
- };
14452
- var Deque = class extends _Base.default {
14453
- constructor(t = [], i = 1 << 12) {
14454
- super();
14455
- this.j = 0;
14456
- this.D = 0;
14457
- this.R = 0;
14458
- this.N = 0;
14459
- this.P = 0;
14460
- this.A = [];
14461
- const s = (() => {
14462
- if (typeof t.length === "number") return t.length;
14463
- if (typeof t.size === "number") return t.size;
14464
- if (typeof t.size === "function") return t.size();
14465
- throw new TypeError("Cannot get the length or size of the container");
14466
- })();
14467
- this.F = i;
14468
- this.P = Math.max(Math.ceil(s / this.F), 1);
14469
- for (let t2 = 0; t2 < this.P; ++t2) {
14470
- this.A.push(new Array(this.F));
14471
- }
14472
- const h = Math.ceil(s / this.F);
14473
- this.j = this.R = (this.P >> 1) - (h >> 1);
14474
- this.D = this.N = this.F - s % this.F >> 1;
14475
- const e = this;
14476
- t.forEach((function(t2) {
14477
- e.pushBack(t2);
14478
- }));
14479
- }
14480
- T() {
14481
- const t = [];
14482
- const i = Math.max(this.P >> 1, 1);
14483
- for (let s = 0; s < i; ++s) {
14484
- t[s] = new Array(this.F);
14485
- }
14486
- for (let i2 = this.j; i2 < this.P; ++i2) {
14487
- t[t.length] = this.A[i2];
14488
- }
14489
- for (let i2 = 0; i2 < this.R; ++i2) {
14490
- t[t.length] = this.A[i2];
14491
- }
14492
- t[t.length] = [...this.A[this.R]];
14493
- this.j = i;
14494
- this.R = t.length - 1;
14495
- for (let s = 0; s < i; ++s) {
14496
- t[t.length] = new Array(this.F);
14497
- }
14498
- this.A = t;
14499
- this.P = t.length;
14500
- }
14501
- O(t) {
14502
- const i = this.D + t + 1;
14503
- const s = i % this.F;
14504
- let h = s - 1;
14505
- let e = this.j + (i - s) / this.F;
14506
- if (s === 0) e -= 1;
14507
- e %= this.P;
14508
- if (h < 0) h += this.F;
14509
- return {
14510
- curNodeBucketIndex: e,
14511
- curNodePointerIndex: h
14512
- };
14513
- }
14514
- clear() {
14515
- this.A = [new Array(this.F)];
14516
- this.P = 1;
14517
- this.j = this.R = this.i = 0;
14518
- this.D = this.N = this.F >> 1;
14519
- }
14520
- begin() {
14521
- return new DequeIterator(0, this);
14522
- }
14523
- end() {
14524
- return new DequeIterator(this.i, this);
14525
- }
14526
- rBegin() {
14527
- return new DequeIterator(this.i - 1, this, 1);
14528
- }
14529
- rEnd() {
14530
- return new DequeIterator(-1, this, 1);
14531
- }
14532
- front() {
14533
- if (this.i === 0) return;
14534
- return this.A[this.j][this.D];
14535
- }
14536
- back() {
14537
- if (this.i === 0) return;
14538
- return this.A[this.R][this.N];
14539
- }
14540
- pushBack(t) {
14541
- if (this.i) {
14542
- if (this.N < this.F - 1) {
14543
- this.N += 1;
14544
- } else if (this.R < this.P - 1) {
14545
- this.R += 1;
14546
- this.N = 0;
14547
- } else {
14548
- this.R = 0;
14549
- this.N = 0;
14550
- }
14551
- if (this.R === this.j && this.N === this.D) this.T();
14552
- }
14553
- this.i += 1;
14554
- this.A[this.R][this.N] = t;
14555
- return this.i;
14556
- }
14557
- popBack() {
14558
- if (this.i === 0) return;
14559
- const t = this.A[this.R][this.N];
14560
- if (this.i !== 1) {
14561
- if (this.N > 0) {
14562
- this.N -= 1;
14563
- } else if (this.R > 0) {
14564
- this.R -= 1;
14565
- this.N = this.F - 1;
14566
- } else {
14567
- this.R = this.P - 1;
14568
- this.N = this.F - 1;
14569
- }
14570
- }
14571
- this.i -= 1;
14572
- return t;
14573
- }
14574
- pushFront(t) {
14575
- if (this.i) {
14576
- if (this.D > 0) {
14577
- this.D -= 1;
14578
- } else if (this.j > 0) {
14579
- this.j -= 1;
14580
- this.D = this.F - 1;
14581
- } else {
14582
- this.j = this.P - 1;
14583
- this.D = this.F - 1;
14584
- }
14585
- if (this.j === this.R && this.D === this.N) this.T();
14586
- }
14587
- this.i += 1;
14588
- this.A[this.j][this.D] = t;
14589
- return this.i;
14590
- }
14591
- popFront() {
14592
- if (this.i === 0) return;
14593
- const t = this.A[this.j][this.D];
14594
- if (this.i !== 1) {
14595
- if (this.D < this.F - 1) {
14596
- this.D += 1;
14597
- } else if (this.j < this.P - 1) {
14598
- this.j += 1;
14599
- this.D = 0;
14600
- } else {
14601
- this.j = 0;
14602
- this.D = 0;
14603
- }
14604
- }
14605
- this.i -= 1;
14606
- return t;
14607
- }
14608
- getElementByPos(t) {
14609
- if (t < 0 || t > this.i - 1) {
14610
- throw new RangeError();
14611
- }
14612
- const { curNodeBucketIndex: i, curNodePointerIndex: s } = this.O(t);
14613
- return this.A[i][s];
14614
- }
14615
- setElementByPos(t, i) {
14616
- if (t < 0 || t > this.i - 1) {
14617
- throw new RangeError();
14618
- }
14619
- const { curNodeBucketIndex: s, curNodePointerIndex: h } = this.O(t);
14620
- this.A[s][h] = i;
14621
- }
14622
- insert(t, i, s = 1) {
14623
- if (t < 0 || t > this.i) {
14624
- throw new RangeError();
14625
- }
14626
- if (t === 0) {
14627
- while (s--) this.pushFront(i);
14628
- } else if (t === this.i) {
14629
- while (s--) this.pushBack(i);
14630
- } else {
14631
- const h = [];
14632
- for (let i2 = t; i2 < this.i; ++i2) {
14633
- h.push(this.getElementByPos(i2));
14634
- }
14635
- this.cut(t - 1);
14636
- for (let t2 = 0; t2 < s; ++t2) this.pushBack(i);
14637
- for (let t2 = 0; t2 < h.length; ++t2) this.pushBack(h[t2]);
14638
- }
14639
- return this.i;
14640
- }
14641
- cut(t) {
14642
- if (t < 0) {
14643
- this.clear();
14644
- return 0;
14645
- }
14646
- const { curNodeBucketIndex: i, curNodePointerIndex: s } = this.O(t);
14647
- this.R = i;
14648
- this.N = s;
14649
- this.i = t + 1;
14650
- return this.i;
14651
- }
14652
- eraseElementByPos(t) {
14653
- if (t < 0 || t > this.i - 1) {
14654
- throw new RangeError();
14655
- }
14656
- if (t === 0) this.popFront();
14657
- else if (t === this.i - 1) this.popBack();
14658
- else {
14659
- const i = [];
14660
- for (let s2 = t + 1; s2 < this.i; ++s2) {
14661
- i.push(this.getElementByPos(s2));
14662
- }
14663
- this.cut(t);
14664
- this.popBack();
14665
- const s = this;
14666
- i.forEach((function(t2) {
14667
- s.pushBack(t2);
14668
- }));
14669
- }
14670
- return this.i;
14671
- }
14672
- eraseElementByValue(t) {
14673
- if (this.i === 0) return 0;
14674
- const i = [];
14675
- for (let s2 = 0; s2 < this.i; ++s2) {
14676
- const h = this.getElementByPos(s2);
14677
- if (h !== t) i.push(h);
14678
- }
14679
- const s = i.length;
14680
- for (let t2 = 0; t2 < s; ++t2) this.setElementByPos(t2, i[t2]);
14681
- return this.cut(s - 1);
14682
- }
14683
- eraseElementByIterator(t) {
14684
- const i = t.o;
14685
- this.eraseElementByPos(i);
14686
- t = t.next();
14687
- return t;
14688
- }
14689
- find(t) {
14690
- for (let i = 0; i < this.i; ++i) {
14691
- if (this.getElementByPos(i) === t) {
14692
- return new DequeIterator(i, this);
14693
- }
14694
- }
14695
- return this.end();
14696
- }
14697
- reverse() {
14698
- let t = 0;
14699
- let i = this.i - 1;
14700
- while (t < i) {
14701
- const s = this.getElementByPos(t);
14702
- this.setElementByPos(t, this.getElementByPos(i));
14703
- this.setElementByPos(i, s);
14704
- t += 1;
14705
- i -= 1;
14706
- }
14707
- }
14708
- unique() {
14709
- if (this.i <= 1) {
14710
- return this.i;
14711
- }
14712
- let t = 1;
14713
- let i = this.getElementByPos(0);
14714
- for (let s = 1; s < this.i; ++s) {
14715
- const h = this.getElementByPos(s);
14716
- if (h !== i) {
14717
- i = h;
14718
- this.setElementByPos(t++, h);
14719
- }
14720
- }
14721
- while (this.i > t) this.popBack();
14722
- return this.i;
14723
- }
14724
- sort(t) {
14725
- const i = [];
14726
- for (let t2 = 0; t2 < this.i; ++t2) {
14727
- i.push(this.getElementByPos(t2));
14728
- }
14729
- i.sort(t);
14730
- for (let t2 = 0; t2 < this.i; ++t2) this.setElementByPos(t2, i[t2]);
14731
- }
14732
- shrinkToFit() {
14733
- if (this.i === 0) return;
14734
- const t = [];
14735
- this.forEach((function(i) {
14736
- t.push(i);
14737
- }));
14738
- this.P = Math.max(Math.ceil(this.i / this.F), 1);
14739
- this.i = this.j = this.R = this.D = this.N = 0;
14740
- this.A = [];
14741
- for (let t2 = 0; t2 < this.P; ++t2) {
14742
- this.A.push(new Array(this.F));
14743
- }
14744
- for (let i = 0; i < t.length; ++i) this.pushBack(t[i]);
14745
- }
14746
- forEach(t) {
14747
- for (let i = 0; i < this.i; ++i) {
14748
- t(this.getElementByPos(i), i, this);
14749
- }
14750
- }
14751
- [Symbol.iterator]() {
14752
- return function* () {
14753
- for (let t = 0; t < this.i; ++t) {
14754
- yield this.getElementByPos(t);
14755
- }
14756
- }.bind(this)();
14757
- }
14758
- };
14759
- var _default = Deque;
14760
- exports8.default = _default;
14761
- }
14762
- });
14763
-
14764
- // node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeNode.js
14765
- var require_TreeNode = __commonJS({
14766
- "node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeNode.js"(exports8) {
14767
- "use strict";
14768
- init_dirname();
14769
- init_buffer2();
14770
- init_process2();
14771
- Object.defineProperty(exports8, "t", {
14772
- value: true
14773
- });
14774
- exports8.TreeNodeEnableIndex = exports8.TreeNode = void 0;
14775
- var TreeNode = class {
14776
- constructor(e, t) {
14777
- this.ee = 1;
14778
- this.u = void 0;
14779
- this.l = void 0;
14780
- this.U = void 0;
14781
- this.W = void 0;
14782
- this.tt = void 0;
14783
- this.u = e;
14784
- this.l = t;
14785
- }
14786
- L() {
14787
- let e = this;
14788
- if (e.ee === 1 && e.tt.tt === e) {
14789
- e = e.W;
14790
- } else if (e.U) {
14791
- e = e.U;
14792
- while (e.W) {
14793
- e = e.W;
14794
- }
14795
- } else {
14796
- let t = e.tt;
14797
- while (t.U === e) {
14798
- e = t;
14799
- t = e.tt;
14800
- }
14801
- e = t;
14802
- }
14803
- return e;
14804
- }
14805
- B() {
14806
- let e = this;
14807
- if (e.W) {
14808
- e = e.W;
14809
- while (e.U) {
14810
- e = e.U;
14811
- }
14812
- return e;
14813
- } else {
14814
- let t = e.tt;
14815
- while (t.W === e) {
14816
- e = t;
14817
- t = e.tt;
14818
- }
14819
- if (e.W !== t) {
14820
- return t;
14821
- } else return e;
14822
- }
14823
- }
14824
- te() {
14825
- const e = this.tt;
14826
- const t = this.W;
14827
- const s = t.U;
14828
- if (e.tt === this) e.tt = t;
14829
- else if (e.U === this) e.U = t;
14830
- else e.W = t;
14831
- t.tt = e;
14832
- t.U = this;
14833
- this.tt = t;
14834
- this.W = s;
14835
- if (s) s.tt = this;
14836
- return t;
14837
- }
14838
- se() {
14839
- const e = this.tt;
14840
- const t = this.U;
14841
- const s = t.W;
14842
- if (e.tt === this) e.tt = t;
14843
- else if (e.U === this) e.U = t;
14844
- else e.W = t;
14845
- t.tt = e;
14846
- t.W = this;
14847
- this.tt = t;
14848
- this.U = s;
14849
- if (s) s.tt = this;
14850
- return t;
14851
- }
14852
- };
14853
- exports8.TreeNode = TreeNode;
14854
- var TreeNodeEnableIndex = class extends TreeNode {
14855
- constructor() {
14856
- super(...arguments);
14857
- this.rt = 1;
14858
- }
14859
- te() {
14860
- const e = super.te();
14861
- this.ie();
14862
- e.ie();
14863
- return e;
14864
- }
14865
- se() {
14866
- const e = super.se();
14867
- this.ie();
14868
- e.ie();
14869
- return e;
14870
- }
14871
- ie() {
14872
- this.rt = 1;
14873
- if (this.U) {
14874
- this.rt += this.U.rt;
14875
- }
14876
- if (this.W) {
14877
- this.rt += this.W.rt;
14878
- }
14879
- }
14880
- };
14881
- exports8.TreeNodeEnableIndex = TreeNodeEnableIndex;
14882
- }
14883
- });
14884
-
14885
- // node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/index.js
14886
- var require_Base2 = __commonJS({
14887
- "node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/index.js"(exports8) {
14888
- "use strict";
14889
- init_dirname();
14890
- init_buffer2();
14891
- init_process2();
14892
- Object.defineProperty(exports8, "t", {
14893
- value: true
14894
- });
14895
- exports8.default = void 0;
14896
- var _TreeNode = require_TreeNode();
14897
- var _ContainerBase = require_ContainerBase();
14898
- var _throwError = require_throwError();
14899
- var TreeContainer = class extends _ContainerBase.Container {
14900
- constructor(e = function(e2, t2) {
14901
- if (e2 < t2) return -1;
14902
- if (e2 > t2) return 1;
14903
- return 0;
14904
- }, t = false) {
14905
- super();
14906
- this.Y = void 0;
14907
- this.v = e;
14908
- if (t) {
14909
- this.re = _TreeNode.TreeNodeEnableIndex;
14910
- this.M = function(e2, t2, i) {
14911
- const s = this.ne(e2, t2, i);
14912
- if (s) {
14913
- let e3 = s.tt;
14914
- while (e3 !== this.h) {
14915
- e3.rt += 1;
14916
- e3 = e3.tt;
14917
- }
14918
- const t3 = this.he(s);
14919
- if (t3) {
14920
- const { parentNode: e4, grandParent: i2, curNode: s2 } = t3;
14921
- e4.ie();
14922
- i2.ie();
14923
- s2.ie();
14924
- }
14925
- }
14926
- return this.i;
14927
- };
14928
- this.V = function(e2) {
14929
- let t2 = this.fe(e2);
14930
- while (t2 !== this.h) {
14931
- t2.rt -= 1;
14932
- t2 = t2.tt;
14933
- }
14934
- };
14935
- } else {
14936
- this.re = _TreeNode.TreeNode;
14937
- this.M = function(e2, t2, i) {
14938
- const s = this.ne(e2, t2, i);
14939
- if (s) this.he(s);
14940
- return this.i;
14941
- };
14942
- this.V = this.fe;
14943
- }
14944
- this.h = new this.re();
14945
- }
14946
- X(e, t) {
14947
- let i = this.h;
14948
- while (e) {
14949
- const s = this.v(e.u, t);
14950
- if (s < 0) {
14951
- e = e.W;
14952
- } else if (s > 0) {
14953
- i = e;
14954
- e = e.U;
14955
- } else return e;
14956
- }
14957
- return i;
14958
- }
14959
- Z(e, t) {
14960
- let i = this.h;
14961
- while (e) {
14962
- const s = this.v(e.u, t);
14963
- if (s <= 0) {
14964
- e = e.W;
14965
- } else {
14966
- i = e;
14967
- e = e.U;
14968
- }
14969
- }
14970
- return i;
14971
- }
14972
- $(e, t) {
14973
- let i = this.h;
14974
- while (e) {
14975
- const s = this.v(e.u, t);
14976
- if (s < 0) {
14977
- i = e;
14978
- e = e.W;
14979
- } else if (s > 0) {
14980
- e = e.U;
14981
- } else return e;
14982
- }
14983
- return i;
14984
- }
14985
- rr(e, t) {
14986
- let i = this.h;
14987
- while (e) {
14988
- const s = this.v(e.u, t);
14989
- if (s < 0) {
14990
- i = e;
14991
- e = e.W;
14992
- } else {
14993
- e = e.U;
14994
- }
14995
- }
14996
- return i;
14997
- }
14998
- ue(e) {
14999
- while (true) {
15000
- const t = e.tt;
15001
- if (t === this.h) return;
15002
- if (e.ee === 1) {
15003
- e.ee = 0;
15004
- return;
15005
- }
15006
- if (e === t.U) {
15007
- const i = t.W;
15008
- if (i.ee === 1) {
15009
- i.ee = 0;
15010
- t.ee = 1;
15011
- if (t === this.Y) {
15012
- this.Y = t.te();
15013
- } else t.te();
15014
- } else {
15015
- if (i.W && i.W.ee === 1) {
15016
- i.ee = t.ee;
15017
- t.ee = 0;
15018
- i.W.ee = 0;
15019
- if (t === this.Y) {
15020
- this.Y = t.te();
15021
- } else t.te();
15022
- return;
15023
- } else if (i.U && i.U.ee === 1) {
15024
- i.ee = 1;
15025
- i.U.ee = 0;
15026
- i.se();
15027
- } else {
15028
- i.ee = 1;
15029
- e = t;
15030
- }
15031
- }
15032
- } else {
15033
- const i = t.U;
15034
- if (i.ee === 1) {
15035
- i.ee = 0;
15036
- t.ee = 1;
15037
- if (t === this.Y) {
15038
- this.Y = t.se();
15039
- } else t.se();
15040
- } else {
15041
- if (i.U && i.U.ee === 1) {
15042
- i.ee = t.ee;
15043
- t.ee = 0;
15044
- i.U.ee = 0;
15045
- if (t === this.Y) {
15046
- this.Y = t.se();
15047
- } else t.se();
15048
- return;
15049
- } else if (i.W && i.W.ee === 1) {
15050
- i.ee = 1;
15051
- i.W.ee = 0;
15052
- i.te();
15053
- } else {
15054
- i.ee = 1;
15055
- e = t;
15056
- }
15057
- }
15058
- }
15059
- }
15060
- }
15061
- fe(e) {
15062
- if (this.i === 1) {
15063
- this.clear();
15064
- return this.h;
15065
- }
15066
- let t = e;
15067
- while (t.U || t.W) {
15068
- if (t.W) {
15069
- t = t.W;
15070
- while (t.U) t = t.U;
15071
- } else {
15072
- t = t.U;
15073
- }
15074
- [e.u, t.u] = [t.u, e.u];
15075
- [e.l, t.l] = [t.l, e.l];
15076
- e = t;
15077
- }
15078
- if (this.h.U === t) {
15079
- this.h.U = t.tt;
15080
- } else if (this.h.W === t) {
15081
- this.h.W = t.tt;
15082
- }
15083
- this.ue(t);
15084
- const i = t.tt;
15085
- if (t === i.U) {
15086
- i.U = void 0;
15087
- } else i.W = void 0;
15088
- this.i -= 1;
15089
- this.Y.ee = 0;
15090
- return i;
15091
- }
15092
- oe(e, t) {
15093
- if (e === void 0) return false;
15094
- const i = this.oe(e.U, t);
15095
- if (i) return true;
15096
- if (t(e)) return true;
15097
- return this.oe(e.W, t);
15098
- }
15099
- he(e) {
15100
- while (true) {
15101
- const t = e.tt;
15102
- if (t.ee === 0) return;
15103
- const i = t.tt;
15104
- if (t === i.U) {
15105
- const s = i.W;
15106
- if (s && s.ee === 1) {
15107
- s.ee = t.ee = 0;
15108
- if (i === this.Y) return;
15109
- i.ee = 1;
15110
- e = i;
15111
- continue;
15112
- } else if (e === t.W) {
15113
- e.ee = 0;
15114
- if (e.U) e.U.tt = t;
15115
- if (e.W) e.W.tt = i;
15116
- t.W = e.U;
15117
- i.U = e.W;
15118
- e.U = t;
15119
- e.W = i;
15120
- if (i === this.Y) {
15121
- this.Y = e;
15122
- this.h.tt = e;
15123
- } else {
15124
- const t2 = i.tt;
15125
- if (t2.U === i) {
15126
- t2.U = e;
15127
- } else t2.W = e;
15128
- }
15129
- e.tt = i.tt;
15130
- t.tt = e;
15131
- i.tt = e;
15132
- i.ee = 1;
15133
- return {
15134
- parentNode: t,
15135
- grandParent: i,
15136
- curNode: e
15137
- };
15138
- } else {
15139
- t.ee = 0;
15140
- if (i === this.Y) {
15141
- this.Y = i.se();
15142
- } else i.se();
15143
- i.ee = 1;
15144
- }
15145
- } else {
15146
- const s = i.U;
15147
- if (s && s.ee === 1) {
15148
- s.ee = t.ee = 0;
15149
- if (i === this.Y) return;
15150
- i.ee = 1;
15151
- e = i;
15152
- continue;
15153
- } else if (e === t.U) {
15154
- e.ee = 0;
15155
- if (e.U) e.U.tt = i;
15156
- if (e.W) e.W.tt = t;
15157
- i.W = e.U;
15158
- t.U = e.W;
15159
- e.U = i;
15160
- e.W = t;
15161
- if (i === this.Y) {
15162
- this.Y = e;
15163
- this.h.tt = e;
15164
- } else {
15165
- const t2 = i.tt;
15166
- if (t2.U === i) {
15167
- t2.U = e;
15168
- } else t2.W = e;
15169
- }
15170
- e.tt = i.tt;
15171
- t.tt = e;
15172
- i.tt = e;
15173
- i.ee = 1;
15174
- return {
15175
- parentNode: t,
15176
- grandParent: i,
15177
- curNode: e
15178
- };
15179
- } else {
15180
- t.ee = 0;
15181
- if (i === this.Y) {
15182
- this.Y = i.te();
15183
- } else i.te();
15184
- i.ee = 1;
15185
- }
15186
- }
15187
- return;
15188
- }
15189
- }
15190
- ne(e, t, i) {
15191
- if (this.Y === void 0) {
15192
- this.i += 1;
15193
- this.Y = new this.re(e, t);
15194
- this.Y.ee = 0;
15195
- this.Y.tt = this.h;
15196
- this.h.tt = this.Y;
15197
- this.h.U = this.Y;
15198
- this.h.W = this.Y;
15199
- return;
15200
- }
15201
- let s;
15202
- const r = this.h.U;
15203
- const n = this.v(r.u, e);
15204
- if (n === 0) {
15205
- r.l = t;
15206
- return;
15207
- } else if (n > 0) {
15208
- r.U = new this.re(e, t);
15209
- r.U.tt = r;
15210
- s = r.U;
15211
- this.h.U = s;
15212
- } else {
15213
- const r2 = this.h.W;
15214
- const n2 = this.v(r2.u, e);
15215
- if (n2 === 0) {
15216
- r2.l = t;
15217
- return;
15218
- } else if (n2 < 0) {
15219
- r2.W = new this.re(e, t);
15220
- r2.W.tt = r2;
15221
- s = r2.W;
15222
- this.h.W = s;
15223
- } else {
15224
- if (i !== void 0) {
15225
- const r3 = i.o;
15226
- if (r3 !== this.h) {
15227
- const i2 = this.v(r3.u, e);
15228
- if (i2 === 0) {
15229
- r3.l = t;
15230
- return;
15231
- } else if (i2 > 0) {
15232
- const i3 = r3.L();
15233
- const n3 = this.v(i3.u, e);
15234
- if (n3 === 0) {
15235
- i3.l = t;
15236
- return;
15237
- } else if (n3 < 0) {
15238
- s = new this.re(e, t);
15239
- if (i3.W === void 0) {
15240
- i3.W = s;
15241
- s.tt = i3;
15242
- } else {
15243
- r3.U = s;
15244
- s.tt = r3;
15245
- }
15246
- }
15247
- }
15248
- }
15249
- }
15250
- if (s === void 0) {
15251
- s = this.Y;
15252
- while (true) {
15253
- const i2 = this.v(s.u, e);
15254
- if (i2 > 0) {
15255
- if (s.U === void 0) {
15256
- s.U = new this.re(e, t);
15257
- s.U.tt = s;
15258
- s = s.U;
15259
- break;
15260
- }
15261
- s = s.U;
15262
- } else if (i2 < 0) {
15263
- if (s.W === void 0) {
15264
- s.W = new this.re(e, t);
15265
- s.W.tt = s;
15266
- s = s.W;
15267
- break;
15268
- }
15269
- s = s.W;
15270
- } else {
15271
- s.l = t;
15272
- return;
15273
- }
15274
- }
15275
- }
15276
- }
15277
- }
15278
- this.i += 1;
15279
- return s;
15280
- }
15281
- I(e, t) {
15282
- while (e) {
15283
- const i = this.v(e.u, t);
15284
- if (i < 0) {
15285
- e = e.W;
15286
- } else if (i > 0) {
15287
- e = e.U;
15288
- } else return e;
15289
- }
15290
- return e || this.h;
15291
- }
15292
- clear() {
15293
- this.i = 0;
15294
- this.Y = void 0;
15295
- this.h.tt = void 0;
15296
- this.h.U = this.h.W = void 0;
15297
- }
15298
- updateKeyByIterator(e, t) {
15299
- const i = e.o;
15300
- if (i === this.h) {
15301
- (0, _throwError.throwIteratorAccessError)();
15302
- }
15303
- if (this.i === 1) {
15304
- i.u = t;
15305
- return true;
15306
- }
15307
- if (i === this.h.U) {
15308
- if (this.v(i.B().u, t) > 0) {
15309
- i.u = t;
15310
- return true;
15311
- }
15312
- return false;
15313
- }
15314
- if (i === this.h.W) {
15315
- if (this.v(i.L().u, t) < 0) {
15316
- i.u = t;
15317
- return true;
15318
- }
15319
- return false;
15320
- }
15321
- const s = i.L().u;
15322
- if (this.v(s, t) >= 0) return false;
15323
- const r = i.B().u;
15324
- if (this.v(r, t) <= 0) return false;
15325
- i.u = t;
15326
- return true;
15327
- }
15328
- eraseElementByPos(e) {
15329
- if (e < 0 || e > this.i - 1) {
15330
- throw new RangeError();
15331
- }
15332
- let t = 0;
15333
- const i = this;
15334
- this.oe(this.Y, (function(s) {
15335
- if (e === t) {
15336
- i.V(s);
15337
- return true;
15338
- }
15339
- t += 1;
15340
- return false;
15341
- }));
15342
- return this.i;
15343
- }
15344
- eraseElementByKey(e) {
15345
- if (this.i === 0) return false;
15346
- const t = this.I(this.Y, e);
15347
- if (t === this.h) return false;
15348
- this.V(t);
15349
- return true;
15350
- }
15351
- eraseElementByIterator(e) {
15352
- const t = e.o;
15353
- if (t === this.h) {
15354
- (0, _throwError.throwIteratorAccessError)();
15355
- }
15356
- const i = t.W === void 0;
15357
- const s = e.iteratorType === 0;
15358
- if (s) {
15359
- if (i) e.next();
15360
- } else {
15361
- if (!i || t.U === void 0) e.next();
15362
- }
15363
- this.V(t);
15364
- return e;
15365
- }
15366
- forEach(e) {
15367
- let t = 0;
15368
- for (const i of this) e(i, t++, this);
15369
- }
15370
- getElementByPos(e) {
15371
- if (e < 0 || e > this.i - 1) {
15372
- throw new RangeError();
15373
- }
15374
- let t;
15375
- let i = 0;
15376
- for (const s of this) {
15377
- if (i === e) {
15378
- t = s;
15379
- break;
15380
- }
15381
- i += 1;
15382
- }
15383
- return t;
15384
- }
15385
- getHeight() {
15386
- if (this.i === 0) return 0;
15387
- const traversal = function(e) {
15388
- if (!e) return 0;
15389
- return Math.max(traversal(e.U), traversal(e.W)) + 1;
15390
- };
15391
- return traversal(this.Y);
15392
- }
15393
- };
15394
- var _default = TreeContainer;
15395
- exports8.default = _default;
15396
- }
15397
- });
15398
-
15399
- // node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeIterator.js
15400
- var require_TreeIterator = __commonJS({
15401
- "node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeIterator.js"(exports8) {
15402
- "use strict";
15403
- init_dirname();
15404
- init_buffer2();
15405
- init_process2();
15406
- Object.defineProperty(exports8, "t", {
15407
- value: true
15408
- });
15409
- exports8.default = void 0;
15410
- var _ContainerBase = require_ContainerBase();
15411
- var _throwError = require_throwError();
15412
- var TreeIterator = class extends _ContainerBase.ContainerIterator {
15413
- constructor(t, r, i) {
15414
- super(i);
15415
- this.o = t;
15416
- this.h = r;
15417
- if (this.iteratorType === 0) {
15418
- this.pre = function() {
15419
- if (this.o === this.h.U) {
15420
- (0, _throwError.throwIteratorAccessError)();
15421
- }
15422
- this.o = this.o.L();
15423
- return this;
15424
- };
15425
- this.next = function() {
15426
- if (this.o === this.h) {
15427
- (0, _throwError.throwIteratorAccessError)();
15428
- }
15429
- this.o = this.o.B();
15430
- return this;
15431
- };
15432
- } else {
15433
- this.pre = function() {
15434
- if (this.o === this.h.W) {
15435
- (0, _throwError.throwIteratorAccessError)();
15436
- }
15437
- this.o = this.o.B();
15438
- return this;
15439
- };
15440
- this.next = function() {
15441
- if (this.o === this.h) {
15442
- (0, _throwError.throwIteratorAccessError)();
15443
- }
15444
- this.o = this.o.L();
15445
- return this;
15446
- };
15447
- }
15448
- }
15449
- get index() {
15450
- let t = this.o;
15451
- const r = this.h.tt;
15452
- if (t === this.h) {
15453
- if (r) {
15454
- return r.rt - 1;
15455
- }
15456
- return 0;
15457
- }
15458
- let i = 0;
15459
- if (t.U) {
15460
- i += t.U.rt;
15461
- }
15462
- while (t !== r) {
15463
- const r2 = t.tt;
15464
- if (t === r2.W) {
15465
- i += 1;
15466
- if (r2.U) {
15467
- i += r2.U.rt;
15468
- }
15469
- }
15470
- t = r2;
15471
- }
15472
- return i;
15473
- }
15474
- };
15475
- var _default = TreeIterator;
15476
- exports8.default = _default;
15477
- }
15478
- });
15479
-
15480
- // node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedSet.js
15481
- var require_OrderedSet = __commonJS({
15482
- "node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedSet.js"(exports8) {
15483
- "use strict";
15484
- init_dirname();
15485
- init_buffer2();
15486
- init_process2();
15487
- Object.defineProperty(exports8, "t", {
15488
- value: true
15489
- });
15490
- exports8.default = void 0;
15491
- var _Base = _interopRequireDefault(require_Base2());
15492
- var _TreeIterator = _interopRequireDefault(require_TreeIterator());
15493
- var _throwError = require_throwError();
15494
- function _interopRequireDefault(e) {
15495
- return e && e.t ? e : {
15496
- default: e
15497
- };
15498
- }
15499
- var OrderedSetIterator = class _OrderedSetIterator extends _TreeIterator.default {
15500
- constructor(e, t, r, i) {
15501
- super(e, t, i);
15502
- this.container = r;
15503
- }
15504
- get pointer() {
15505
- if (this.o === this.h) {
15506
- (0, _throwError.throwIteratorAccessError)();
15507
- }
15508
- return this.o.u;
15509
- }
15510
- copy() {
15511
- return new _OrderedSetIterator(this.o, this.h, this.container, this.iteratorType);
15512
- }
15513
- };
15514
- var OrderedSet = class extends _Base.default {
15515
- constructor(e = [], t, r) {
15516
- super(t, r);
15517
- const i = this;
15518
- e.forEach((function(e2) {
15519
- i.insert(e2);
15520
- }));
15521
- }
15522
- *K(e) {
15523
- if (e === void 0) return;
15524
- yield* this.K(e.U);
15525
- yield e.u;
15526
- yield* this.K(e.W);
15527
- }
15528
- begin() {
15529
- return new OrderedSetIterator(this.h.U || this.h, this.h, this);
15530
- }
15531
- end() {
15532
- return new OrderedSetIterator(this.h, this.h, this);
15533
- }
15534
- rBegin() {
15535
- return new OrderedSetIterator(this.h.W || this.h, this.h, this, 1);
15536
- }
15537
- rEnd() {
15538
- return new OrderedSetIterator(this.h, this.h, this, 1);
15539
- }
15540
- front() {
15541
- return this.h.U ? this.h.U.u : void 0;
15542
- }
15543
- back() {
15544
- return this.h.W ? this.h.W.u : void 0;
15545
- }
15546
- insert(e, t) {
15547
- return this.M(e, void 0, t);
15548
- }
15549
- find(e) {
15550
- const t = this.I(this.Y, e);
15551
- return new OrderedSetIterator(t, this.h, this);
15552
- }
15553
- lowerBound(e) {
15554
- const t = this.X(this.Y, e);
15555
- return new OrderedSetIterator(t, this.h, this);
15556
- }
15557
- upperBound(e) {
15558
- const t = this.Z(this.Y, e);
15559
- return new OrderedSetIterator(t, this.h, this);
15560
- }
15561
- reverseLowerBound(e) {
15562
- const t = this.$(this.Y, e);
15563
- return new OrderedSetIterator(t, this.h, this);
15564
- }
15565
- reverseUpperBound(e) {
15566
- const t = this.rr(this.Y, e);
15567
- return new OrderedSetIterator(t, this.h, this);
15568
- }
15569
- union(e) {
15570
- const t = this;
15571
- e.forEach((function(e2) {
15572
- t.insert(e2);
15573
- }));
15574
- return this.i;
15575
- }
15576
- [Symbol.iterator]() {
15577
- return this.K(this.Y);
15578
- }
15579
- };
15580
- var _default = OrderedSet;
15581
- exports8.default = _default;
15582
- }
15583
- });
15584
-
15585
- // node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedMap.js
15586
- var require_OrderedMap = __commonJS({
15587
- "node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedMap.js"(exports8) {
15588
- "use strict";
15589
- init_dirname();
15590
- init_buffer2();
15591
- init_process2();
15592
- Object.defineProperty(exports8, "t", {
15593
- value: true
15594
- });
15595
- exports8.default = void 0;
15596
- var _Base = _interopRequireDefault(require_Base2());
15597
- var _TreeIterator = _interopRequireDefault(require_TreeIterator());
15598
- var _throwError = require_throwError();
15599
- function _interopRequireDefault(r) {
15600
- return r && r.t ? r : {
15601
- default: r
15602
- };
15603
- }
15604
- var OrderedMapIterator = class _OrderedMapIterator extends _TreeIterator.default {
15605
- constructor(r, t, e, s) {
15606
- super(r, t, s);
15607
- this.container = e;
15608
- }
15609
- get pointer() {
15610
- if (this.o === this.h) {
15611
- (0, _throwError.throwIteratorAccessError)();
15612
- }
15613
- const r = this;
15614
- return new Proxy([], {
15615
- get(t, e) {
15616
- if (e === "0") return r.o.u;
15617
- else if (e === "1") return r.o.l;
15618
- },
15619
- set(t, e, s) {
15620
- if (e !== "1") {
15621
- throw new TypeError("props must be 1");
15622
- }
15623
- r.o.l = s;
15624
- return true;
15625
- }
15626
- });
15627
- }
15628
- copy() {
15629
- return new _OrderedMapIterator(this.o, this.h, this.container, this.iteratorType);
15630
- }
15631
- };
15632
- var OrderedMap = class extends _Base.default {
15633
- constructor(r = [], t, e) {
15634
- super(t, e);
15635
- const s = this;
15636
- r.forEach((function(r2) {
15637
- s.setElement(r2[0], r2[1]);
15638
- }));
15639
- }
15640
- *K(r) {
15641
- if (r === void 0) return;
15642
- yield* this.K(r.U);
15643
- yield [r.u, r.l];
15644
- yield* this.K(r.W);
15645
- }
15646
- begin() {
15647
- return new OrderedMapIterator(this.h.U || this.h, this.h, this);
15648
- }
15649
- end() {
15650
- return new OrderedMapIterator(this.h, this.h, this);
15651
- }
15652
- rBegin() {
15653
- return new OrderedMapIterator(this.h.W || this.h, this.h, this, 1);
15654
- }
15655
- rEnd() {
15656
- return new OrderedMapIterator(this.h, this.h, this, 1);
15657
- }
15658
- front() {
15659
- if (this.i === 0) return;
15660
- const r = this.h.U;
15661
- return [r.u, r.l];
15662
- }
15663
- back() {
15664
- if (this.i === 0) return;
15665
- const r = this.h.W;
15666
- return [r.u, r.l];
15667
- }
15668
- lowerBound(r) {
15669
- const t = this.X(this.Y, r);
15670
- return new OrderedMapIterator(t, this.h, this);
15671
- }
15672
- upperBound(r) {
15673
- const t = this.Z(this.Y, r);
15674
- return new OrderedMapIterator(t, this.h, this);
15675
- }
15676
- reverseLowerBound(r) {
15677
- const t = this.$(this.Y, r);
15678
- return new OrderedMapIterator(t, this.h, this);
15679
- }
15680
- reverseUpperBound(r) {
15681
- const t = this.rr(this.Y, r);
15682
- return new OrderedMapIterator(t, this.h, this);
15683
- }
15684
- setElement(r, t, e) {
15685
- return this.M(r, t, e);
15686
- }
15687
- find(r) {
15688
- const t = this.I(this.Y, r);
15689
- return new OrderedMapIterator(t, this.h, this);
15690
- }
15691
- getElementByKey(r) {
15692
- const t = this.I(this.Y, r);
15693
- return t.l;
15694
- }
15695
- union(r) {
15696
- const t = this;
15697
- r.forEach((function(r2) {
15698
- t.setElement(r2[0], r2[1]);
15699
- }));
15700
- return this.i;
15701
- }
15702
- [Symbol.iterator]() {
15703
- return this.K(this.Y);
15704
- }
15705
- };
15706
- var _default = OrderedMap;
15707
- exports8.default = _default;
15708
- }
15709
- });
15710
-
15711
- // node_modules/js-sdsl/dist/cjs/utils/checkObject.js
15712
- var require_checkObject = __commonJS({
15713
- "node_modules/js-sdsl/dist/cjs/utils/checkObject.js"(exports8) {
15714
- "use strict";
15715
- init_dirname();
15716
- init_buffer2();
15717
- init_process2();
15718
- Object.defineProperty(exports8, "t", {
15719
- value: true
15720
- });
15721
- exports8.default = checkObject;
15722
- function checkObject(e) {
15723
- const t = typeof e;
15724
- return t === "object" && e !== null || t === "function";
15725
- }
15726
- }
15727
- });
15728
-
15729
- // node_modules/js-sdsl/dist/cjs/container/HashContainer/Base/index.js
15730
- var require_Base3 = __commonJS({
15731
- "node_modules/js-sdsl/dist/cjs/container/HashContainer/Base/index.js"(exports8) {
15732
- "use strict";
15733
- init_dirname();
15734
- init_buffer2();
15735
- init_process2();
15736
- Object.defineProperty(exports8, "t", {
15737
- value: true
15738
- });
15739
- exports8.HashContainerIterator = exports8.HashContainer = void 0;
15740
- var _ContainerBase = require_ContainerBase();
15741
- var _checkObject = _interopRequireDefault(require_checkObject());
15742
- var _throwError = require_throwError();
15743
- function _interopRequireDefault(t) {
15744
- return t && t.t ? t : {
15745
- default: t
15746
- };
15747
- }
15748
- var HashContainerIterator = class extends _ContainerBase.ContainerIterator {
15749
- constructor(t, e, i) {
15750
- super(i);
15751
- this.o = t;
15752
- this.h = e;
15753
- if (this.iteratorType === 0) {
15754
- this.pre = function() {
15755
- if (this.o.L === this.h) {
15756
- (0, _throwError.throwIteratorAccessError)();
15757
- }
15758
- this.o = this.o.L;
15759
- return this;
15760
- };
15761
- this.next = function() {
15762
- if (this.o === this.h) {
15763
- (0, _throwError.throwIteratorAccessError)();
15764
- }
15765
- this.o = this.o.B;
15766
- return this;
15767
- };
15768
- } else {
15769
- this.pre = function() {
15770
- if (this.o.B === this.h) {
15771
- (0, _throwError.throwIteratorAccessError)();
15772
- }
15773
- this.o = this.o.B;
15774
- return this;
15775
- };
15776
- this.next = function() {
15777
- if (this.o === this.h) {
15778
- (0, _throwError.throwIteratorAccessError)();
15779
- }
15780
- this.o = this.o.L;
15781
- return this;
15782
- };
15783
- }
15784
- }
15785
- };
15786
- exports8.HashContainerIterator = HashContainerIterator;
15787
- var HashContainer = class extends _ContainerBase.Container {
15788
- constructor() {
15789
- super();
15790
- this.H = [];
15791
- this.g = {};
15792
- this.HASH_TAG = Symbol("@@HASH_TAG");
15793
- Object.setPrototypeOf(this.g, null);
15794
- this.h = {};
15795
- this.h.L = this.h.B = this.p = this._ = this.h;
15796
- }
15797
- V(t) {
15798
- const { L: e, B: i } = t;
15799
- e.B = i;
15800
- i.L = e;
15801
- if (t === this.p) {
15802
- this.p = i;
15803
- }
15804
- if (t === this._) {
15805
- this._ = e;
15806
- }
15807
- this.i -= 1;
15808
- }
15809
- M(t, e, i) {
15810
- if (i === void 0) i = (0, _checkObject.default)(t);
15811
- let s;
15812
- if (i) {
15813
- const i2 = t[this.HASH_TAG];
15814
- if (i2 !== void 0) {
15815
- this.H[i2].l = e;
15816
- return this.i;
15817
- }
15818
- Object.defineProperty(t, this.HASH_TAG, {
15819
- value: this.H.length,
15820
- configurable: true
15821
- });
15822
- s = {
15823
- u: t,
15824
- l: e,
15825
- L: this._,
15826
- B: this.h
15827
- };
15828
- this.H.push(s);
15829
- } else {
15830
- const i2 = this.g[t];
15831
- if (i2) {
15832
- i2.l = e;
15833
- return this.i;
15834
- }
15835
- s = {
15836
- u: t,
15837
- l: e,
15838
- L: this._,
15839
- B: this.h
15840
- };
15841
- this.g[t] = s;
15842
- }
15843
- if (this.i === 0) {
15844
- this.p = s;
15845
- this.h.B = s;
15846
- } else {
15847
- this._.B = s;
15848
- }
15849
- this._ = s;
15850
- this.h.L = s;
15851
- return ++this.i;
15852
- }
15853
- I(t, e) {
15854
- if (e === void 0) e = (0, _checkObject.default)(t);
15855
- if (e) {
15856
- const e2 = t[this.HASH_TAG];
15857
- if (e2 === void 0) return this.h;
15858
- return this.H[e2];
15859
- } else {
15860
- return this.g[t] || this.h;
15861
- }
15862
- }
15863
- clear() {
15864
- const t = this.HASH_TAG;
15865
- this.H.forEach((function(e) {
15866
- delete e.u[t];
15867
- }));
15868
- this.H = [];
15869
- this.g = {};
15870
- Object.setPrototypeOf(this.g, null);
15871
- this.i = 0;
15872
- this.p = this._ = this.h.L = this.h.B = this.h;
15873
- }
15874
- eraseElementByKey(t, e) {
15875
- let i;
15876
- if (e === void 0) e = (0, _checkObject.default)(t);
15877
- if (e) {
15878
- const e2 = t[this.HASH_TAG];
15879
- if (e2 === void 0) return false;
15880
- delete t[this.HASH_TAG];
15881
- i = this.H[e2];
15882
- delete this.H[e2];
15883
- } else {
15884
- i = this.g[t];
15885
- if (i === void 0) return false;
15886
- delete this.g[t];
15887
- }
15888
- this.V(i);
15889
- return true;
15890
- }
15891
- eraseElementByIterator(t) {
15892
- const e = t.o;
15893
- if (e === this.h) {
15894
- (0, _throwError.throwIteratorAccessError)();
15895
- }
15896
- this.V(e);
15897
- return t.next();
15898
- }
15899
- eraseElementByPos(t) {
15900
- if (t < 0 || t > this.i - 1) {
15901
- throw new RangeError();
15902
- }
15903
- let e = this.p;
15904
- while (t--) {
15905
- e = e.B;
15906
- }
15907
- this.V(e);
15908
- return this.i;
15909
- }
15910
- };
15911
- exports8.HashContainer = HashContainer;
15912
- }
15913
- });
15914
-
15915
- // node_modules/js-sdsl/dist/cjs/container/HashContainer/HashSet.js
15916
- var require_HashSet = __commonJS({
15917
- "node_modules/js-sdsl/dist/cjs/container/HashContainer/HashSet.js"(exports8) {
15918
- "use strict";
15919
- init_dirname();
15920
- init_buffer2();
15921
- init_process2();
15922
- Object.defineProperty(exports8, "t", {
15923
- value: true
15924
- });
15925
- exports8.default = void 0;
15926
- var _Base = require_Base3();
15927
- var _throwError = require_throwError();
15928
- var HashSetIterator = class _HashSetIterator extends _Base.HashContainerIterator {
15929
- constructor(t, e, r, s) {
15930
- super(t, e, s);
15931
- this.container = r;
15932
- }
15933
- get pointer() {
15934
- if (this.o === this.h) {
15935
- (0, _throwError.throwIteratorAccessError)();
15936
- }
15937
- return this.o.u;
15938
- }
15939
- copy() {
15940
- return new _HashSetIterator(this.o, this.h, this.container, this.iteratorType);
15941
- }
15942
- };
15943
- var HashSet = class extends _Base.HashContainer {
15944
- constructor(t = []) {
15945
- super();
15946
- const e = this;
15947
- t.forEach((function(t2) {
15948
- e.insert(t2);
15949
- }));
15950
- }
15951
- begin() {
15952
- return new HashSetIterator(this.p, this.h, this);
15953
- }
15954
- end() {
15955
- return new HashSetIterator(this.h, this.h, this);
15956
- }
15957
- rBegin() {
15958
- return new HashSetIterator(this._, this.h, this, 1);
15959
- }
15960
- rEnd() {
15961
- return new HashSetIterator(this.h, this.h, this, 1);
15962
- }
15963
- front() {
15964
- return this.p.u;
15965
- }
15966
- back() {
15967
- return this._.u;
15968
- }
15969
- insert(t, e) {
15970
- return this.M(t, void 0, e);
15971
- }
15972
- getElementByPos(t) {
15973
- if (t < 0 || t > this.i - 1) {
15974
- throw new RangeError();
15975
- }
15976
- let e = this.p;
15977
- while (t--) {
15978
- e = e.B;
15979
- }
15980
- return e.u;
15981
- }
15982
- find(t, e) {
15983
- const r = this.I(t, e);
15984
- return new HashSetIterator(r, this.h, this);
15985
- }
15986
- forEach(t) {
15987
- let e = 0;
15988
- let r = this.p;
15989
- while (r !== this.h) {
15990
- t(r.u, e++, this);
15991
- r = r.B;
13420
+ this.#keyMap.delete(k);
13421
+ this.#keyList[index] = void 0;
13422
+ this.#valList[index] = void 0;
13423
+ if (index === this.#tail) {
13424
+ this.#tail = this.#prev[index];
13425
+ } else if (index === this.#head) {
13426
+ this.#head = this.#next[index];
13427
+ } else {
13428
+ const pi = this.#prev[index];
13429
+ this.#next[pi] = this.#next[index];
13430
+ const ni = this.#next[index];
13431
+ this.#prev[ni] = this.#prev[index];
13432
+ }
13433
+ this.#size--;
13434
+ this.#free.push(index);
13435
+ }
13436
+ }
15992
13437
  }
15993
- }
15994
- [Symbol.iterator]() {
15995
- return function* () {
15996
- let t = this.p;
15997
- while (t !== this.h) {
15998
- yield t.u;
15999
- t = t.B;
13438
+ if (this.#hasDisposeAfter && this.#disposed?.length) {
13439
+ const dt = this.#disposed;
13440
+ let task;
13441
+ while (task = dt?.shift()) {
13442
+ this.#disposeAfter?.(...task);
16000
13443
  }
16001
- }.bind(this)();
13444
+ }
13445
+ return deleted;
16002
13446
  }
16003
- };
16004
- var _default = HashSet;
16005
- exports8.default = _default;
16006
- }
16007
- });
16008
-
16009
- // node_modules/js-sdsl/dist/cjs/container/HashContainer/HashMap.js
16010
- var require_HashMap = __commonJS({
16011
- "node_modules/js-sdsl/dist/cjs/container/HashContainer/HashMap.js"(exports8) {
16012
- "use strict";
16013
- init_dirname();
16014
- init_buffer2();
16015
- init_process2();
16016
- Object.defineProperty(exports8, "t", {
16017
- value: true
16018
- });
16019
- exports8.default = void 0;
16020
- var _Base = require_Base3();
16021
- var _checkObject = _interopRequireDefault(require_checkObject());
16022
- var _throwError = require_throwError();
16023
- function _interopRequireDefault(t) {
16024
- return t && t.t ? t : {
16025
- default: t
16026
- };
16027
- }
16028
- var HashMapIterator = class _HashMapIterator extends _Base.HashContainerIterator {
16029
- constructor(t, e, r, s) {
16030
- super(t, e, s);
16031
- this.container = r;
13447
+ /**
13448
+ * Clear the cache entirely, throwing away all values.
13449
+ */
13450
+ clear() {
13451
+ return this.#clear("delete");
16032
13452
  }
16033
- get pointer() {
16034
- if (this.o === this.h) {
16035
- (0, _throwError.throwIteratorAccessError)();
16036
- }
16037
- const t = this;
16038
- return new Proxy([], {
16039
- get(e, r) {
16040
- if (r === "0") return t.o.u;
16041
- else if (r === "1") return t.o.l;
16042
- },
16043
- set(e, r, s) {
16044
- if (r !== "1") {
16045
- throw new TypeError("props must be 1");
13453
+ #clear(reason) {
13454
+ for (const index of this.#rindexes({ allowStale: true })) {
13455
+ const v = this.#valList[index];
13456
+ if (this.#isBackgroundFetch(v)) {
13457
+ v.__abortController.abort(new Error("deleted"));
13458
+ } else {
13459
+ const k = this.#keyList[index];
13460
+ if (this.#hasDispose) {
13461
+ this.#dispose?.(v, k, reason);
13462
+ }
13463
+ if (this.#hasDisposeAfter) {
13464
+ this.#disposed?.push([v, k, reason]);
16046
13465
  }
16047
- t.o.l = s;
16048
- return true;
16049
13466
  }
16050
- });
16051
- }
16052
- copy() {
16053
- return new _HashMapIterator(this.o, this.h, this.container, this.iteratorType);
16054
- }
16055
- };
16056
- var HashMap = class extends _Base.HashContainer {
16057
- constructor(t = []) {
16058
- super();
16059
- const e = this;
16060
- t.forEach((function(t2) {
16061
- e.setElement(t2[0], t2[1]);
16062
- }));
16063
- }
16064
- begin() {
16065
- return new HashMapIterator(this.p, this.h, this);
16066
- }
16067
- end() {
16068
- return new HashMapIterator(this.h, this.h, this);
16069
- }
16070
- rBegin() {
16071
- return new HashMapIterator(this._, this.h, this, 1);
16072
- }
16073
- rEnd() {
16074
- return new HashMapIterator(this.h, this.h, this, 1);
16075
- }
16076
- front() {
16077
- if (this.i === 0) return;
16078
- return [this.p.u, this.p.l];
16079
- }
16080
- back() {
16081
- if (this.i === 0) return;
16082
- return [this._.u, this._.l];
16083
- }
16084
- setElement(t, e, r) {
16085
- return this.M(t, e, r);
16086
- }
16087
- getElementByKey(t, e) {
16088
- if (e === void 0) e = (0, _checkObject.default)(t);
16089
- if (e) {
16090
- const e2 = t[this.HASH_TAG];
16091
- return e2 !== void 0 ? this.H[e2].l : void 0;
16092
- }
16093
- const r = this.g[t];
16094
- return r ? r.l : void 0;
16095
- }
16096
- getElementByPos(t) {
16097
- if (t < 0 || t > this.i - 1) {
16098
- throw new RangeError();
16099
13467
  }
16100
- let e = this.p;
16101
- while (t--) {
16102
- e = e.B;
13468
+ this.#keyMap.clear();
13469
+ this.#valList.fill(void 0);
13470
+ this.#keyList.fill(void 0);
13471
+ if (this.#ttls && this.#starts) {
13472
+ this.#ttls.fill(0);
13473
+ this.#starts.fill(0);
16103
13474
  }
16104
- return [e.u, e.l];
16105
- }
16106
- find(t, e) {
16107
- const r = this.I(t, e);
16108
- return new HashMapIterator(r, this.h, this);
16109
- }
16110
- forEach(t) {
16111
- let e = 0;
16112
- let r = this.p;
16113
- while (r !== this.h) {
16114
- t([r.u, r.l], e++, this);
16115
- r = r.B;
13475
+ if (this.#sizes) {
13476
+ this.#sizes.fill(0);
16116
13477
  }
16117
- }
16118
- [Symbol.iterator]() {
16119
- return function* () {
16120
- let t = this.p;
16121
- while (t !== this.h) {
16122
- yield [t.u, t.l];
16123
- t = t.B;
13478
+ this.#head = 0;
13479
+ this.#tail = 0;
13480
+ this.#free.length = 0;
13481
+ this.#calculatedSize = 0;
13482
+ this.#size = 0;
13483
+ if (this.#hasDisposeAfter && this.#disposed) {
13484
+ const dt = this.#disposed;
13485
+ let task;
13486
+ while (task = dt?.shift()) {
13487
+ this.#disposeAfter?.(...task);
16124
13488
  }
16125
- }.bind(this)();
13489
+ }
16126
13490
  }
16127
13491
  };
16128
- var _default = HashMap;
16129
- exports8.default = _default;
16130
- }
16131
- });
16132
-
16133
- // node_modules/js-sdsl/dist/cjs/index.js
16134
- var require_cjs = __commonJS({
16135
- "node_modules/js-sdsl/dist/cjs/index.js"(exports8) {
16136
- "use strict";
16137
- init_dirname();
16138
- init_buffer2();
16139
- init_process2();
16140
- Object.defineProperty(exports8, "t", {
16141
- value: true
16142
- });
16143
- Object.defineProperty(exports8, "Deque", {
16144
- enumerable: true,
16145
- get: function() {
16146
- return _Deque.default;
16147
- }
16148
- });
16149
- Object.defineProperty(exports8, "HashMap", {
16150
- enumerable: true,
16151
- get: function() {
16152
- return _HashMap.default;
16153
- }
16154
- });
16155
- Object.defineProperty(exports8, "HashSet", {
16156
- enumerable: true,
16157
- get: function() {
16158
- return _HashSet.default;
16159
- }
16160
- });
16161
- Object.defineProperty(exports8, "LinkList", {
16162
- enumerable: true,
16163
- get: function() {
16164
- return _LinkList.default;
16165
- }
16166
- });
16167
- Object.defineProperty(exports8, "OrderedMap", {
16168
- enumerable: true,
16169
- get: function() {
16170
- return _OrderedMap.default;
16171
- }
16172
- });
16173
- Object.defineProperty(exports8, "OrderedSet", {
16174
- enumerable: true,
16175
- get: function() {
16176
- return _OrderedSet.default;
16177
- }
16178
- });
16179
- Object.defineProperty(exports8, "PriorityQueue", {
16180
- enumerable: true,
16181
- get: function() {
16182
- return _PriorityQueue.default;
16183
- }
16184
- });
16185
- Object.defineProperty(exports8, "Queue", {
16186
- enumerable: true,
16187
- get: function() {
16188
- return _Queue.default;
16189
- }
16190
- });
16191
- Object.defineProperty(exports8, "Stack", {
16192
- enumerable: true,
16193
- get: function() {
16194
- return _Stack.default;
16195
- }
16196
- });
16197
- Object.defineProperty(exports8, "Vector", {
16198
- enumerable: true,
16199
- get: function() {
16200
- return _Vector.default;
16201
- }
16202
- });
16203
- var _Stack = _interopRequireDefault(require_Stack());
16204
- var _Queue = _interopRequireDefault(require_Queue());
16205
- var _PriorityQueue = _interopRequireDefault(require_PriorityQueue());
16206
- var _Vector = _interopRequireDefault(require_Vector());
16207
- var _LinkList = _interopRequireDefault(require_LinkList());
16208
- var _Deque = _interopRequireDefault(require_Deque());
16209
- var _OrderedSet = _interopRequireDefault(require_OrderedSet());
16210
- var _OrderedMap = _interopRequireDefault(require_OrderedMap());
16211
- var _HashSet = _interopRequireDefault(require_HashSet());
16212
- var _HashMap = _interopRequireDefault(require_HashMap());
16213
- function _interopRequireDefault(e) {
16214
- return e && e.t ? e : {
16215
- default: e
16216
- };
16217
- }
13492
+ exports8.LRUCache = LRUCache;
16218
13493
  }
16219
13494
  });
16220
13495
 
16221
- // node_modules/number-allocator/lib/number-allocator.js
13496
+ // build/lib/number-allocator.js
16222
13497
  var require_number_allocator = __commonJS({
16223
- "node_modules/number-allocator/lib/number-allocator.js"(exports8, module) {
13498
+ "build/lib/number-allocator.js"(exports8) {
16224
13499
  "use strict";
16225
13500
  init_dirname();
16226
13501
  init_buffer2();
16227
13502
  init_process2();
16228
- var SortedSet = require_cjs().OrderedSet;
16229
- var debugTrace = require_browser4()("number-allocator:trace");
16230
- var debugError = require_browser4()("number-allocator:error");
16231
- function Interval(low, high) {
16232
- this.low = low;
16233
- this.high = high;
16234
- }
16235
- Interval.prototype.equals = function(other) {
16236
- return this.low === other.low && this.high === other.high;
16237
- };
16238
- Interval.prototype.compare = function(other) {
16239
- if (this.low < other.low && this.high < other.low) return -1;
16240
- if (other.low < this.low && other.high < this.low) return 1;
16241
- return 0;
16242
- };
16243
- function NumberAllocator(min, max) {
16244
- if (!(this instanceof NumberAllocator)) {
16245
- return new NumberAllocator(min, max);
13503
+ Object.defineProperty(exports8, "__esModule", { value: true });
13504
+ exports8.NumberAllocator = void 0;
13505
+ var NumberAllocator = class {
13506
+ used;
13507
+ min;
13508
+ max;
13509
+ lowWaterMark;
13510
+ constructor(min, max) {
13511
+ this.min = min;
13512
+ this.max = max;
13513
+ this.used = /* @__PURE__ */ new Set();
13514
+ this.lowWaterMark = min;
16246
13515
  }
16247
- this.min = min;
16248
- this.max = max;
16249
- this.ss = new SortedSet(
16250
- [],
16251
- (lhs, rhs) => {
16252
- return lhs.compare(rhs);
13516
+ firstVacant() {
13517
+ if (this.used.size === this.max - this.min + 1) {
13518
+ return null;
13519
+ }
13520
+ for (let i = this.lowWaterMark; i <= this.max; i++) {
13521
+ if (!this.used.has(i)) {
13522
+ return i;
13523
+ }
16253
13524
  }
16254
- );
16255
- debugTrace("Create");
16256
- this.clear();
16257
- }
16258
- NumberAllocator.prototype.firstVacant = function() {
16259
- if (this.ss.size() === 0) return null;
16260
- return this.ss.front().low;
16261
- };
16262
- NumberAllocator.prototype.alloc = function() {
16263
- if (this.ss.size() === 0) {
16264
- debugTrace("alloc():empty");
16265
13525
  return null;
16266
13526
  }
16267
- const it = this.ss.begin();
16268
- const low = it.pointer.low;
16269
- const high = it.pointer.high;
16270
- const num = low;
16271
- if (num + 1 <= high) {
16272
- this.ss.updateKeyByIterator(it, new Interval(low + 1, high));
16273
- } else {
16274
- this.ss.eraseElementByPos(0);
16275
- }
16276
- debugTrace("alloc():" + num);
16277
- return num;
16278
- };
16279
- NumberAllocator.prototype.use = function(num) {
16280
- const key = new Interval(num, num);
16281
- const it = this.ss.lowerBound(key);
16282
- if (!it.equals(this.ss.end())) {
16283
- const low = it.pointer.low;
16284
- const high = it.pointer.high;
16285
- if (it.pointer.equals(key)) {
16286
- this.ss.eraseElementByIterator(it);
16287
- debugTrace("use():" + num);
16288
- return true;
13527
+ alloc() {
13528
+ if (this.used.size === this.max - this.min + 1) {
13529
+ return null;
16289
13530
  }
16290
- if (low > num) return false;
16291
- if (low === num) {
16292
- this.ss.updateKeyByIterator(it, new Interval(low + 1, high));
16293
- debugTrace("use():" + num);
16294
- return true;
13531
+ for (let i = this.lowWaterMark; i <= this.max; i++) {
13532
+ if (!this.used.has(i)) {
13533
+ this.used.add(i);
13534
+ this.lowWaterMark = i + 1;
13535
+ return i;
13536
+ }
16295
13537
  }
16296
- if (high === num) {
16297
- this.ss.updateKeyByIterator(it, new Interval(low, high - 1));
16298
- debugTrace("use():" + num);
16299
- return true;
13538
+ return null;
13539
+ }
13540
+ use(num) {
13541
+ if (num < this.min || num > this.max || this.used.has(num)) {
13542
+ return false;
16300
13543
  }
16301
- this.ss.updateKeyByIterator(it, new Interval(num + 1, high));
16302
- this.ss.insert(new Interval(low, num - 1));
16303
- debugTrace("use():" + num);
13544
+ this.used.add(num);
16304
13545
  return true;
16305
13546
  }
16306
- debugTrace("use():failed");
16307
- return false;
16308
- };
16309
- NumberAllocator.prototype.free = function(num) {
16310
- if (num < this.min || num > this.max) {
16311
- debugError("free():" + num + " is out of range");
16312
- return;
16313
- }
16314
- const key = new Interval(num, num);
16315
- const it = this.ss.upperBound(key);
16316
- if (it.equals(this.ss.end())) {
16317
- if (it.equals(this.ss.begin())) {
16318
- this.ss.insert(key);
13547
+ free(num) {
13548
+ if (num < this.min || num > this.max) {
16319
13549
  return;
16320
13550
  }
16321
- it.pre();
16322
- const low = it.pointer.high;
16323
- const high = it.pointer.high;
16324
- if (high + 1 === num) {
16325
- this.ss.updateKeyByIterator(it, new Interval(low, num));
16326
- } else {
16327
- this.ss.insert(key);
16328
- }
16329
- } else {
16330
- if (it.equals(this.ss.begin())) {
16331
- if (num + 1 === it.pointer.low) {
16332
- const high = it.pointer.high;
16333
- this.ss.updateKeyByIterator(it, new Interval(num, high));
16334
- } else {
16335
- this.ss.insert(key);
16336
- }
16337
- } else {
16338
- const rLow = it.pointer.low;
16339
- const rHigh = it.pointer.high;
16340
- it.pre();
16341
- const lLow = it.pointer.low;
16342
- const lHigh = it.pointer.high;
16343
- if (lHigh + 1 === num) {
16344
- if (num + 1 === rLow) {
16345
- this.ss.eraseElementByIterator(it);
16346
- this.ss.updateKeyByIterator(it, new Interval(lLow, rHigh));
16347
- } else {
16348
- this.ss.updateKeyByIterator(it, new Interval(lLow, num));
16349
- }
16350
- } else {
16351
- if (num + 1 === rLow) {
16352
- this.ss.eraseElementByIterator(it.next());
16353
- this.ss.insert(new Interval(num, rHigh));
16354
- } else {
16355
- this.ss.insert(key);
16356
- }
16357
- }
13551
+ this.used.delete(num);
13552
+ if (num < this.lowWaterMark) {
13553
+ this.lowWaterMark = num;
16358
13554
  }
16359
13555
  }
16360
- debugTrace("free():" + num);
16361
- };
16362
- NumberAllocator.prototype.clear = function() {
16363
- debugTrace("clear()");
16364
- this.ss.clear();
16365
- this.ss.insert(new Interval(this.min, this.max));
16366
- };
16367
- NumberAllocator.prototype.intervalCount = function() {
16368
- return this.ss.size();
16369
- };
16370
- NumberAllocator.prototype.dump = function() {
16371
- console.log("length:" + this.ss.size());
16372
- for (const element of this.ss) {
16373
- console.log(element);
13556
+ clear() {
13557
+ this.used.clear();
13558
+ this.lowWaterMark = this.min;
16374
13559
  }
16375
13560
  };
16376
- module.exports = NumberAllocator;
16377
- }
16378
- });
16379
-
16380
- // node_modules/number-allocator/index.js
16381
- var require_number_allocator2 = __commonJS({
16382
- "node_modules/number-allocator/index.js"(exports8, module) {
16383
- init_dirname();
16384
- init_buffer2();
16385
- init_process2();
16386
- var NumberAllocator = require_number_allocator();
16387
- module.exports.NumberAllocator = NumberAllocator;
13561
+ exports8.NumberAllocator = NumberAllocator;
16388
13562
  }
16389
13563
  });
16390
13564
 
@@ -16397,7 +13571,7 @@ var mqtt = (() => {
16397
13571
  init_process2();
16398
13572
  Object.defineProperty(exports8, "__esModule", { value: true });
16399
13573
  var lru_cache_1 = require_commonjs();
16400
- var number_allocator_1 = require_number_allocator2();
13574
+ var number_allocator_1 = require_number_allocator();
16401
13575
  var TopicAliasSend = class {
16402
13576
  aliasToTopic;
16403
13577
  topicToAlias;
@@ -16468,16 +13642,27 @@ var mqtt = (() => {
16468
13642
  var ack_1 = require_ack();
16469
13643
  var topic_alias_send_1 = __importDefault(require_topic_alias_send());
16470
13644
  var shared_1 = require_shared();
16471
- var handleConnack = (client, packet) => {
13645
+ var handleConnack = (client, packet, pump) => {
16472
13646
  client.log("_handleConnack");
16473
13647
  const { options } = client;
16474
13648
  const version4 = options.protocolVersion;
16475
13649
  const rc = version4 === 5 ? packet.reasonCode : packet.returnCode;
13650
+ if (client["connackReceived"]) {
13651
+ const err = new shared_1.ErrorWithReasonCode("Protocol error: duplicate CONNACK on the same network connection", 130);
13652
+ pump?.discardParsedPackets();
13653
+ client["_cleanUp"](true);
13654
+ client.emit("error", err);
13655
+ return;
13656
+ }
13657
+ client["connackReceived"] = true;
16476
13658
  clearTimeout(client["connackTimer"]);
16477
13659
  delete client["topicAliasSend"];
13660
+ client["_serverProperties"] = packet.properties;
16478
13661
  if (packet.properties) {
16479
13662
  if (packet.properties.topicAliasMaximum) {
16480
13663
  if (packet.properties.topicAliasMaximum > 65535) {
13664
+ pump?.discardParsedPackets();
13665
+ client["_cleanUp"](true);
16481
13666
  client.emit("error", new Error("topicAliasMaximum from broker is out of range"));
16482
13667
  return;
16483
13668
  }
@@ -16485,24 +13670,23 @@ var mqtt = (() => {
16485
13670
  client["topicAliasSend"] = new topic_alias_send_1.default(packet.properties.topicAliasMaximum);
16486
13671
  }
16487
13672
  }
16488
- if (packet.properties.serverKeepAlive && options.keepalive) {
16489
- options.keepalive = packet.properties.serverKeepAlive;
16490
- }
16491
- if (packet.properties.maximumPacketSize) {
16492
- if (!options.properties) {
16493
- options.properties = {};
16494
- }
16495
- options.properties.maximumPacketSize = packet.properties.maximumPacketSize;
16496
- }
16497
13673
  }
16498
13674
  if (rc === 0) {
16499
13675
  client.reconnecting = false;
16500
13676
  client["_onConnect"](packet);
16501
13677
  } else if (rc > 0) {
13678
+ client.log("_handleConnack :: connection refused with reason code %d", rc);
16502
13679
  const err = new shared_1.ErrorWithReasonCode(`Connection refused: ${ack_1.ReasonCodes[rc]}`, rc);
16503
- client.emit("error", err);
16504
- if (client.options.reconnectOnConnackError) {
16505
- client["_cleanUp"](true);
13680
+ pump?.discardParsedPackets();
13681
+ client["reconnectSuppressed"] = true;
13682
+ client["_cleanUp"](true);
13683
+ try {
13684
+ client.emit("error", err);
13685
+ } finally {
13686
+ if (options.reconnectOnConnackError) {
13687
+ client["reconnectSuppressed"] = false;
13688
+ client["_setupReconnect"]();
13689
+ }
16506
13690
  }
16507
13691
  }
16508
13692
  };
@@ -16531,6 +13715,7 @@ var mqtt = (() => {
16531
13715
  return callback(err2);
16532
13716
  }
16533
13717
  client.incomingStore.del(pub, client.noop);
13718
+ client["_releaseIncomingQoS2Publish"](messageId);
16534
13719
  client["_sendPacket"](comp, callback);
16535
13720
  });
16536
13721
  } else {
@@ -16558,21 +13743,34 @@ var mqtt = (() => {
16558
13743
  var connack_1 = __importDefault(require_connack());
16559
13744
  var ack_1 = __importDefault(require_ack());
16560
13745
  var pubrel_1 = __importDefault(require_pubrel());
16561
- var handle = (client, packet, done) => {
13746
+ var shared_1 = require_shared();
13747
+ var remainingLengthBytes = (remainingLength) => {
13748
+ if (remainingLength < 128)
13749
+ return 1;
13750
+ if (remainingLength < 16384)
13751
+ return 2;
13752
+ if (remainingLength < 2097152)
13753
+ return 3;
13754
+ return 4;
13755
+ };
13756
+ var totalPacketSize = (remainingLength) => 1 + remainingLengthBytes(remainingLength) + remainingLength;
13757
+ var handle = (client, packet, done, pump) => {
16562
13758
  const { options } = client;
16563
- if (options.protocolVersion === 5 && options.properties && options.properties.maximumPacketSize && options.properties.maximumPacketSize < packet.length) {
16564
- client.emit("error", new Error(`exceeding packets size ${packet.cmd}`));
16565
- client.end({
16566
- reasonCode: 149,
16567
- properties: { reasonString: "Maximum packet size was exceeded" }
16568
- });
13759
+ const maximumPacketSize = options.properties?.maximumPacketSize;
13760
+ const packetSize = totalPacketSize(packet.length);
13761
+ if (options.protocolVersion === 5 && maximumPacketSize && maximumPacketSize < packetSize) {
13762
+ client.log("_handlePacket :: %s packet of %d bytes exceeds the advertised maximumPacketSize %d", packet.cmd, packetSize, maximumPacketSize);
13763
+ pump?.discardParsedPackets();
13764
+ client["_cleanUp"](true);
13765
+ done();
13766
+ client.emit("error", new shared_1.ErrorWithReasonCode(`exceeding packets size ${packet.cmd}: ${packetSize} bytes, maximumPacketSize is ${maximumPacketSize}`, 149));
16569
13767
  return client;
16570
13768
  }
16571
13769
  client.log("_handlePacket :: emitting packetreceive");
16572
13770
  client.emit("packetreceive", packet);
16573
13771
  switch (packet.cmd) {
16574
13772
  case "publish":
16575
- (0, publish_1.default)(client, packet, done);
13773
+ (0, publish_1.default)(client, packet, done, pump);
16576
13774
  break;
16577
13775
  case "puback":
16578
13776
  case "pubrec":
@@ -16580,21 +13778,30 @@ var mqtt = (() => {
16580
13778
  case "suback":
16581
13779
  case "unsuback":
16582
13780
  client.reschedulePing();
16583
- (0, ack_1.default)(client, packet);
16584
- done();
13781
+ try {
13782
+ (0, ack_1.default)(client, packet);
13783
+ } finally {
13784
+ done();
13785
+ }
16585
13786
  break;
16586
13787
  case "pubrel":
16587
13788
  client.reschedulePing();
16588
13789
  (0, pubrel_1.default)(client, packet, done);
16589
13790
  break;
16590
13791
  case "connack":
16591
- (0, connack_1.default)(client, packet);
16592
- done();
13792
+ try {
13793
+ (0, connack_1.default)(client, packet, pump);
13794
+ } finally {
13795
+ done();
13796
+ }
16593
13797
  break;
16594
13798
  case "auth":
16595
13799
  client.reschedulePing();
16596
- (0, auth_1.default)(client, packet);
16597
- done();
13800
+ try {
13801
+ (0, auth_1.default)(client, packet, pump);
13802
+ } finally {
13803
+ done();
13804
+ }
16598
13805
  break;
16599
13806
  case "pingresp":
16600
13807
  client.log("_handlePacket :: received pingresp");
@@ -17572,7 +14779,7 @@ var mqtt = (() => {
17572
14779
  var symbol = Symbol();
17573
14780
  var timerId = generateUniqueNumber(scheduledIntervalsState2);
17574
14781
  scheduledIntervalsState2.set(timerId, symbol);
17575
- var _schedule = function schedule() {
14782
+ var _schedule = function schedule2() {
17576
14783
  return set(delay, timerId).then(function() {
17577
14784
  var state = scheduledIntervalsState2.get(timerId);
17578
14785
  if (state === void 0) {
@@ -17736,8 +14943,8 @@ var mqtt = (() => {
17736
14943
  var isStandardBrowserEnv = () => {
17737
14944
  if (typeof window !== "undefined") {
17738
14945
  const electronRenderCheck = typeof navigator !== "undefined" && navigator.userAgent?.toLowerCase().indexOf(" electron/") > -1;
17739
- if (electronRenderCheck && process_exports?.versions) {
17740
- const electronMainCheck = Object.prototype.hasOwnProperty.call(process_exports.versions, "electron");
14946
+ if (electronRenderCheck && browser_process_exports?.versions) {
14947
+ const electronMainCheck = Object.prototype.hasOwnProperty.call(browser_process_exports.versions, "electron");
17741
14948
  return !electronMainCheck;
17742
14949
  }
17743
14950
  return typeof window.document !== "undefined";
@@ -17859,7 +15066,7 @@ var mqtt = (() => {
17859
15066
  constructor(client, variant) {
17860
15067
  this.client = client;
17861
15068
  this.timer = typeof variant === "object" && "set" in variant && "clear" in variant ? variant : (0, get_timer_1.default)(variant);
17862
- this.setKeepalive(client.options.keepalive);
15069
+ this.setKeepalive(client.keepalive);
17863
15070
  }
17864
15071
  clear() {
17865
15072
  if (this.timerId) {
@@ -17955,12 +15162,13 @@ var mqtt = (() => {
17955
15162
  };
17956
15163
  Object.defineProperty(exports8, "__esModule", { value: true });
17957
15164
  var mqtt_packet_1 = __importDefault(require_mqtt());
17958
- var readable_stream_1 = require_browser3();
15165
+ var readable_stream_1 = require_browser2();
17959
15166
  var default_1 = __importDefault(require_default());
17960
- var debug_1 = __importDefault(require_browser4());
15167
+ var debug_1 = __importDefault(require_browser3());
17961
15168
  var validations = __importStar(require_validations());
17962
15169
  var store_1 = __importDefault(require_store());
17963
15170
  var handlers_1 = __importDefault(require_handlers());
15171
+ var ack_1 = require_ack();
17964
15172
  var default_message_id_provider_1 = __importDefault(require_default_message_id_provider());
17965
15173
  var topic_alias_recv_1 = __importDefault(require_topic_alias_recv());
17966
15174
  var shared_1 = require_shared();
@@ -17973,6 +15181,8 @@ var mqtt = (() => {
17973
15181
  callback(...args);
17974
15182
  });
17975
15183
  });
15184
+ var MAX_RECEIVE_MAXIMUM = 65535;
15185
+ var RECEIVE_MAXIMUM_EXCEEDED = 147;
17976
15186
  var defaultConnectOptions = {
17977
15187
  keepalive: 60,
17978
15188
  reschedulePings: true,
@@ -18015,8 +15225,15 @@ var mqtt = (() => {
18015
15225
  _firstConnection;
18016
15226
  topicAliasRecv;
18017
15227
  topicAliasSend;
15228
+ _incomingQoS2Ids;
15229
+ _receiveMaximum;
18018
15230
  _deferredReconnect;
15231
+ _currentPump;
15232
+ connackReceived;
15233
+ reconnectSuppressed;
15234
+ _authenticationMethod;
18019
15235
  connackPacket;
15236
+ _serverProperties;
18020
15237
  static defaultId() {
18021
15238
  return `mqttjs_${Math.random().toString(16).substr(2, 8)}`;
18022
15239
  }
@@ -18057,6 +15274,16 @@ var mqtt = (() => {
18057
15274
  this.messageIdProvider = typeof this.options.messageIdProvider === "undefined" ? new default_message_id_provider_1.default() : this.options.messageIdProvider;
18058
15275
  this.outgoingStore = options.outgoingStore || new store_1.default();
18059
15276
  this.incomingStore = options.incomingStore || new store_1.default();
15277
+ this._incomingQoS2Ids = /* @__PURE__ */ new Set();
15278
+ this._receiveMaximum = MAX_RECEIVE_MAXIMUM;
15279
+ const receiveMaximum = options.properties?.receiveMaximum;
15280
+ if (receiveMaximum !== void 0) {
15281
+ if (Number.isInteger(receiveMaximum) && receiveMaximum >= 1 && receiveMaximum <= MAX_RECEIVE_MAXIMUM) {
15282
+ this._receiveMaximum = receiveMaximum;
15283
+ } else {
15284
+ this.log("MqttClient :: options.properties.receiveMaximum %o is not an integer between 1 and %d, enforcing and advertising %d instead", receiveMaximum, MAX_RECEIVE_MAXIMUM, MAX_RECEIVE_MAXIMUM);
15285
+ }
15286
+ }
18060
15287
  this.queueQoSZero = options.queueQoSZero === void 0 ? true : options.queueQoSZero;
18061
15288
  this._resubscribeTopics = {};
18062
15289
  this.messageIdToTopic = {};
@@ -18066,6 +15293,8 @@ var mqtt = (() => {
18066
15293
  this.reconnecting = false;
18067
15294
  this.queue = [];
18068
15295
  this.connackTimer = null;
15296
+ this.connackReceived = false;
15297
+ this.reconnectSuppressed = false;
18069
15298
  this.reconnectTimer = null;
18070
15299
  this._storeProcessing = false;
18071
15300
  this._packetIdsDuringStoreProcessing = {};
@@ -18118,6 +15347,7 @@ var mqtt = (() => {
18118
15347
  this.log("close :: clearing connackTimer");
18119
15348
  clearTimeout(this.connackTimer);
18120
15349
  this._destroyKeepaliveManager();
15350
+ this._serverProperties = void 0;
18121
15351
  if (this.topicAliasRecv) {
18122
15352
  this.topicAliasRecv.clear();
18123
15353
  }
@@ -18141,16 +15371,57 @@ var mqtt = (() => {
18141
15371
  getLastMessageId() {
18142
15372
  return this.messageIdProvider.getLastAllocated();
18143
15373
  }
15374
+ _trackIncomingQoS2Publish(messageId, done, pump) {
15375
+ if (this._incomingQoS2Ids.has(messageId)) {
15376
+ return true;
15377
+ }
15378
+ if (this.options.protocolVersion === 5 && this._incomingQoS2Ids.size >= this._receiveMaximum) {
15379
+ this.log("_trackIncomingQoS2Publish :: inbound QoS 2 messages exceeded receiveMaximum %d", this._receiveMaximum);
15380
+ pump?.discardParsedPackets();
15381
+ if (!pump || pump.isCurrent()) {
15382
+ this._cleanUp(true);
15383
+ }
15384
+ done();
15385
+ this.emit("error", new shared_1.ErrorWithReasonCode(`${ack_1.ReasonCodes[RECEIVE_MAXIMUM_EXCEEDED]}: ${this._incomingQoS2Ids.size + 1} inbound QoS 2 messages in flight, receiveMaximum is ${this._receiveMaximum}`, RECEIVE_MAXIMUM_EXCEEDED));
15386
+ return false;
15387
+ }
15388
+ this._incomingQoS2Ids.add(messageId);
15389
+ return true;
15390
+ }
15391
+ _releaseIncomingQoS2Publish(messageId) {
15392
+ this._incomingQoS2Ids.delete(messageId);
15393
+ }
15394
+ _discardIncomingQoS2State() {
15395
+ if (this._incomingQoS2Ids.size === 0) {
15396
+ return;
15397
+ }
15398
+ this.log("_discardIncomingQoS2State :: session not resumed, dropping %d inbound QoS 2 message(s)", this._incomingQoS2Ids.size);
15399
+ for (const messageId of this._incomingQoS2Ids) {
15400
+ this.incomingStore.del({ messageId }, this.noop);
15401
+ }
15402
+ this._incomingQoS2Ids.clear();
15403
+ }
18144
15404
  connect() {
18145
15405
  const writable = new readable_stream_1.Writable();
18146
15406
  const parser = mqtt_packet_1.default.parser(this.options);
18147
15407
  let completeParse = null;
18148
15408
  const packets = [];
15409
+ const pump = {
15410
+ discardParsedPackets: () => {
15411
+ packets.length = 0;
15412
+ },
15413
+ isCurrent: () => this._currentPump === pump
15414
+ };
15415
+ this._currentPump = pump;
15416
+ this.connackReceived = false;
15417
+ this.reconnectSuppressed = false;
18149
15418
  this.log("connect :: calling method to clear reconnect");
18150
15419
  this._clearReconnect();
15420
+ this._serverProperties = void 0;
18151
15421
  if (this.disconnected && !this.reconnecting) {
18152
15422
  this.incomingStore = this.options.incomingStore || new store_1.default();
18153
15423
  this.outgoingStore = this.options.outgoingStore || new store_1.default();
15424
+ this._incomingQoS2Ids.clear();
18154
15425
  this.disconnecting = false;
18155
15426
  this.disconnected = false;
18156
15427
  }
@@ -18162,10 +15433,14 @@ var mqtt = (() => {
18162
15433
  });
18163
15434
  const work = () => {
18164
15435
  this.log("work :: getting next packet in queue");
15436
+ if (this._currentPump !== pump) {
15437
+ this.log("work :: pump superseded, dropping %d queued packets", packets.length);
15438
+ packets.length = 0;
15439
+ }
18165
15440
  const packet = packets.shift();
18166
15441
  if (packet) {
18167
15442
  this.log("work :: packet pulled from queue");
18168
- (0, handlers_1.default)(this, packet, nextTickWork);
15443
+ (0, handlers_1.default)(this, packet, nextTickWork, pump);
18169
15444
  } else {
18170
15445
  this.log("work :: no packets in queue");
18171
15446
  const done = completeParse;
@@ -18181,7 +15456,8 @@ var mqtt = (() => {
18181
15456
  } else {
18182
15457
  const done = completeParse;
18183
15458
  completeParse = null;
18184
- done();
15459
+ if (done)
15460
+ done();
18185
15461
  }
18186
15462
  };
18187
15463
  writable._write = (buf, enc, done) => {
@@ -18218,8 +15494,11 @@ var mqtt = (() => {
18218
15494
  keepalive: this.options.keepalive,
18219
15495
  username: this.options.username,
18220
15496
  password: this.options.password,
18221
- properties: this.options.properties
15497
+ properties: this.options.properties ? { ...this.options.properties } : void 0
18222
15498
  };
15499
+ if (connectPacket.properties?.receiveMaximum !== void 0) {
15500
+ connectPacket.properties.receiveMaximum = this._receiveMaximum;
15501
+ }
18223
15502
  if (this.options.will) {
18224
15503
  connectPacket.will = {
18225
15504
  ...this.options.will,
@@ -18234,6 +15513,7 @@ var mqtt = (() => {
18234
15513
  connectPacket.properties.topicAliasMaximum = this.topicAliasRecv.max;
18235
15514
  }
18236
15515
  }
15516
+ this._authenticationMethod = connectPacket.properties?.authenticationMethod;
18237
15517
  this._writePacket(connectPacket);
18238
15518
  parser.on("error", this.emit.bind(this, "error"));
18239
15519
  if (this.options.properties) {
@@ -18252,13 +15532,14 @@ var mqtt = (() => {
18252
15532
  }
18253
15533
  this.stream.setMaxListeners(1e3);
18254
15534
  clearTimeout(this.connackTimer);
18255
- this.connackTimer = setTimeout(() => {
18256
- this.log("!!connectTimeout hit!! Calling _cleanUp with force `true`");
18257
- this.emit("error", new Error("connack timeout"));
18258
- this._cleanUp(true);
18259
- }, this.options.connectTimeout);
15535
+ this.connackTimer = setTimeout(() => this._onConnackTimeout(), this.options.connectTimeout);
18260
15536
  return this;
18261
15537
  }
15538
+ _onConnackTimeout() {
15539
+ this.log("!!connectTimeout hit!! Calling _cleanUp with force `true`");
15540
+ this._cleanUp(true);
15541
+ this.emit("error", new Error("connack timeout"));
15542
+ }
18262
15543
  publish(topic, message, opts, callback) {
18263
15544
  this.log("publish :: message `%s` to topic `%s`", message, topic);
18264
15545
  const { options } = this;
@@ -18304,6 +15585,7 @@ var mqtt = (() => {
18304
15585
  case 2:
18305
15586
  this.outgoing[packet.messageId] = {
18306
15587
  volatile: false,
15588
+ cmd: "publish",
18307
15589
  cb: callback || this.noop
18308
15590
  };
18309
15591
  this.log("MqttClient:publish: packet cmd: %s", packet.cmd);
@@ -18436,18 +15718,22 @@ var mqtt = (() => {
18436
15718
  const promise = new Promise((resolve2, reject) => {
18437
15719
  this.outgoing[packet.messageId] = {
18438
15720
  volatile: true,
18439
- cb(err, packet2) {
18440
- if (!err) {
18441
- const { granted } = packet2;
18442
- for (let grantedI = 0; grantedI < granted.length; grantedI += 1) {
18443
- chunkedSubs[grantedI].qos = granted[grantedI];
18444
- }
18445
- }
18446
- if (!err) {
18447
- resolve2(packet2);
18448
- } else {
15721
+ cmd: "subscribe",
15722
+ cb: (err, packet2) => {
15723
+ if (err) {
18449
15724
  reject(new shared_1.ErrorWithSubackPacket(err.message, packet2));
15725
+ return;
15726
+ }
15727
+ const { granted } = packet2;
15728
+ if (granted.length !== chunkedSubs.length) {
15729
+ reject(new shared_1.ErrorWithSubackPacket(`Protocol error: suback granted ${granted.length} reason code(s) for ${chunkedSubs.length} subscription(s)`, packet2));
15730
+ this._cleanUp(true);
15731
+ return;
15732
+ }
15733
+ for (let grantedI = 0; grantedI < granted.length; grantedI += 1) {
15734
+ chunkedSubs[grantedI].qos = granted[grantedI];
18450
15735
  }
15736
+ resolve2(packet2);
18451
15737
  }
18452
15738
  };
18453
15739
  });
@@ -18535,6 +15821,7 @@ var mqtt = (() => {
18535
15821
  }
18536
15822
  this.outgoing[packet.messageId] = {
18537
15823
  volatile: true,
15824
+ cmd: "unsubscribe",
18538
15825
  cb: callback
18539
15826
  };
18540
15827
  this.log("unsubscribe: call _sendPacket");
@@ -18578,6 +15865,7 @@ var mqtt = (() => {
18578
15865
  const closeStores = () => {
18579
15866
  this.log("end :: closeStores: closing incoming and outgoing stores");
18580
15867
  this.disconnected = true;
15868
+ this._incomingQoS2Ids.clear();
18581
15869
  this.incomingStore.close((e1) => {
18582
15870
  this.outgoingStore.close((e2) => {
18583
15871
  this.log("end :: closeStores: emitting end");
@@ -18649,6 +15937,7 @@ var mqtt = (() => {
18649
15937
  }
18650
15938
  this.incomingStore = this.options.incomingStore || new store_1.default();
18651
15939
  this.outgoingStore = this.options.outgoingStore || new store_1.default();
15940
+ this._incomingQoS2Ids.clear();
18652
15941
  this.disconnecting = false;
18653
15942
  this.disconnected = false;
18654
15943
  this._deferredReconnect = null;
@@ -18717,7 +16006,7 @@ var mqtt = (() => {
18717
16006
  _reconnect() {
18718
16007
  this.log("_reconnect: emitting reconnect to client");
18719
16008
  this.emit("reconnect");
18720
- if (this.connected) {
16009
+ if (this.connected && !this.stream.destroyed) {
18721
16010
  this.end(() => {
18722
16011
  this.connect();
18723
16012
  });
@@ -18728,7 +16017,7 @@ var mqtt = (() => {
18728
16017
  }
18729
16018
  }
18730
16019
  _setupReconnect() {
18731
- if (!this.disconnecting && !this.reconnectTimer && this.options.reconnectPeriod > 0) {
16020
+ if (!this.disconnecting && !this.reconnectSuppressed && !this.reconnectTimer && this.options.reconnectPeriod > 0) {
18732
16021
  if (!this.reconnecting) {
18733
16022
  this.log("_setupReconnect :: emit `offline` state");
18734
16023
  this.emit("offline");
@@ -18950,9 +16239,16 @@ var mqtt = (() => {
18950
16239
  cb(new Error("No connection to broker"));
18951
16240
  }
18952
16241
  }
16242
+ get serverProperties() {
16243
+ return this._serverProperties;
16244
+ }
16245
+ get keepalive() {
16246
+ const serverKeepAlive = this.connected ? this._serverProperties?.serverKeepAlive : void 0;
16247
+ return serverKeepAlive && this.options.keepalive ? serverKeepAlive : this.options.keepalive;
16248
+ }
18953
16249
  _setupKeepaliveManager() {
18954
- this.log("_setupKeepaliveManager :: keepalive %d (seconds)", this.options.keepalive);
18955
- if (!this.keepaliveManager && this.options.keepalive) {
16250
+ this.log("_setupKeepaliveManager :: keepalive %d (seconds)", this.keepalive);
16251
+ if (!this.keepaliveManager && this.keepalive) {
18956
16252
  this.keepaliveManager = new KeepaliveManager_1.default(this, this.options.timerVariant);
18957
16253
  }
18958
16254
  }
@@ -18964,7 +16260,7 @@ var mqtt = (() => {
18964
16260
  }
18965
16261
  }
18966
16262
  reschedulePing(force = false) {
18967
- if (this.keepaliveManager && this.options.keepalive && (force || this.options.reschedulePings)) {
16263
+ if (this.keepaliveManager && this.keepalive && (force || this.options.reschedulePings)) {
18968
16264
  this._reschedulePing();
18969
16265
  }
18970
16266
  }
@@ -18977,9 +16273,9 @@ var mqtt = (() => {
18977
16273
  this._sendPacket({ cmd: "pingreq" });
18978
16274
  }
18979
16275
  onKeepaliveTimeout() {
18980
- this.emit("error", new Error("Keepalive timeout"));
18981
16276
  this.log("onKeepaliveTimeout :: calling _cleanUp with force true");
18982
16277
  this._cleanUp(true);
16278
+ this.emit("error", new Error("Keepalive timeout"));
18983
16279
  }
18984
16280
  _resubscribe() {
18985
16281
  this.log("_resubscribe");
@@ -19012,9 +16308,13 @@ var mqtt = (() => {
19012
16308
  return;
19013
16309
  }
19014
16310
  this.connackPacket = packet;
16311
+ const sessionResumed = !this.options.clean && (this.options.protocolVersion < 4 || packet.sessionPresent === true);
16312
+ if (!sessionResumed) {
16313
+ this._discardIncomingQoS2State();
16314
+ }
19015
16315
  this.messageIdProvider.clear();
19016
- this._setupKeepaliveManager();
19017
16316
  this.connected = true;
16317
+ this._setupKeepaliveManager();
19018
16318
  const startStreamProcess = () => {
19019
16319
  let outStore = this.outgoingStore.createStream();
19020
16320
  const remove = () => {
@@ -19053,6 +16353,7 @@ var mqtt = (() => {
19053
16353
  cb = this.outgoing[packet2.messageId] ? this.outgoing[packet2.messageId].cb : null;
19054
16354
  this.outgoing[packet2.messageId] = {
19055
16355
  volatile: false,
16356
+ cmd: packet2.cmd,
19056
16357
  cb(err, status) {
19057
16358
  if (cb) {
19058
16359
  cb(err, status);
@@ -19135,7 +16436,7 @@ var mqtt = (() => {
19135
16436
  init_buffer2();
19136
16437
  init_process2();
19137
16438
  Object.defineProperty(exports8, "__esModule", { value: true });
19138
- var number_allocator_1 = require_number_allocator2();
16439
+ var number_allocator_1 = require_number_allocator();
19139
16440
  var UniqueMessageIdProvider = class {
19140
16441
  numberAllocator;
19141
16442
  lastId;
@@ -20226,7 +17527,7 @@ var mqtt = (() => {
20226
17527
  draining2 = false;
20227
17528
  clearTimeout(timeout);
20228
17529
  }
20229
- function nextTick2(fun) {
17530
+ function nextTick3(fun) {
20230
17531
  var args = new Array(arguments.length - 1);
20231
17532
  if (arguments.length > 1) {
20232
17533
  for (var i = 1; i < arguments.length; i++)
@@ -20450,7 +17751,7 @@ var mqtt = (() => {
20450
17751
  setUncaughtExceptionCaptureCallback: setUncaughtExceptionCaptureCallback2,
20451
17752
  hasUncaughtExceptionCaptureCallback: hasUncaughtExceptionCaptureCallback2,
20452
17753
  emitWarning: emitWarning2,
20453
- nextTick: nextTick2,
17754
+ nextTick: nextTick3,
20454
17755
  _tickCallback: _tickCallback2,
20455
17756
  _debugProcess: _debugProcess2,
20456
17757
  _debugEnd: _debugEnd2,
@@ -22883,7 +20184,7 @@ var mqtt = (() => {
22883
20184
  });
22884
20185
 
22885
20186
  // node_modules/ws/browser.js
22886
- var require_browser5 = __commonJS({
20187
+ var require_browser4 = __commonJS({
22887
20188
  "node_modules/ws/browser.js"(exports8, module) {
22888
20189
  "use strict";
22889
20190
  init_dirname();
@@ -22907,7 +20208,7 @@ var mqtt = (() => {
22907
20208
  Object.defineProperty(exports8, "__esModule", { value: true });
22908
20209
  exports8.BufferedDuplex = void 0;
22909
20210
  exports8.writev = writev;
22910
- var readable_stream_1 = require_browser3();
20211
+ var readable_stream_1 = require_browser2();
22911
20212
  var buffer_1 = (init_buffer(), __toCommonJS(buffer_exports));
22912
20213
  function writev(chunks, cb) {
22913
20214
  const buffers = new Array(chunks.length);
@@ -22997,9 +20298,9 @@ var mqtt = (() => {
22997
20298
  Object.defineProperty(exports8, "__esModule", { value: true });
22998
20299
  exports8.streamBuilder = exports8.browserStreamBuilder = void 0;
22999
20300
  var buffer_1 = (init_buffer(), __toCommonJS(buffer_exports));
23000
- var ws_1 = __importDefault(require_browser5());
23001
- var debug_1 = __importDefault(require_browser4());
23002
- var readable_stream_1 = require_browser3();
20301
+ var ws_1 = __importDefault(require_browser4());
20302
+ var debug_1 = __importDefault(require_browser3());
20303
+ var readable_stream_1 = require_browser2();
23003
20304
  var is_browser_1 = __importDefault(require_is_browser());
23004
20305
  var BufferedDuplex_1 = require_BufferedDuplex();
23005
20306
  var debug = (0, debug_1.default)("mqttjs:ws");
@@ -23265,7 +20566,7 @@ var mqtt = (() => {
23265
20566
  };
23266
20567
  Object.defineProperty(exports8, "__esModule", { value: true });
23267
20568
  var net_1 = __importDefault((init_net(), __toCommonJS(net_exports)));
23268
- var debug_1 = __importDefault(require_browser4());
20569
+ var debug_1 = __importDefault(require_browser3());
23269
20570
  var socks_1 = __importDefault(require_socks());
23270
20571
  var debug = (0, debug_1.default)("mqttjs:tcp");
23271
20572
  var buildStream = (client, opts) => {
@@ -23313,7 +20614,7 @@ var mqtt = (() => {
23313
20614
  Object.defineProperty(exports8, "__esModule", { value: true });
23314
20615
  var tls_1 = (init_empty(), __toCommonJS(empty_exports));
23315
20616
  var net_1 = __importDefault((init_net(), __toCommonJS(net_exports)));
23316
- var debug_1 = __importDefault(require_browser4());
20617
+ var debug_1 = __importDefault(require_browser3());
23317
20618
  var socks_1 = __importDefault(require_socks());
23318
20619
  var debug = (0, debug_1.default)("mqttjs:tls");
23319
20620
  function connect(opts) {
@@ -23368,7 +20669,7 @@ var mqtt = (() => {
23368
20669
  init_process2();
23369
20670
  Object.defineProperty(exports8, "__esModule", { value: true });
23370
20671
  var buffer_1 = (init_buffer(), __toCommonJS(buffer_exports));
23371
- var readable_stream_1 = require_browser3();
20672
+ var readable_stream_1 = require_browser2();
23372
20673
  var BufferedDuplex_1 = require_BufferedDuplex();
23373
20674
  var socketTask;
23374
20675
  var proxy;
@@ -23489,7 +20790,7 @@ var mqtt = (() => {
23489
20790
  init_process2();
23490
20791
  Object.defineProperty(exports8, "__esModule", { value: true });
23491
20792
  var buffer_1 = (init_buffer(), __toCommonJS(buffer_exports));
23492
- var readable_stream_1 = require_browser3();
20793
+ var readable_stream_1 = require_browser2();
23493
20794
  var BufferedDuplex_1 = require_BufferedDuplex();
23494
20795
  var my;
23495
20796
  var proxy;
@@ -23604,12 +20905,12 @@ var mqtt = (() => {
23604
20905
  };
23605
20906
  Object.defineProperty(exports8, "__esModule", { value: true });
23606
20907
  exports8.connectAsync = connectAsync;
23607
- var debug_1 = __importDefault(require_browser4());
20908
+ var debug_1 = __importDefault(require_browser3());
23608
20909
  var url_1 = __importDefault((init_url(), __toCommonJS(url_exports)));
23609
20910
  var client_1 = __importDefault(require_client());
23610
20911
  var is_browser_1 = __importDefault(require_is_browser());
23611
- if (typeof process_exports?.nextTick !== "function") {
23612
- process_exports.nextTick = setImmediate;
20912
+ if (typeof browser_process_exports?.nextTick !== "function") {
20913
+ browser_process_exports.nextTick = setImmediate;
23613
20914
  }
23614
20915
  var debug = (0, debug_1.default)("mqttjs");
23615
20916
  var protocols = null;
@@ -23672,8 +20973,8 @@ var mqtt = (() => {
23672
20973
  }
23673
20974
  if (is_browser_1.default || opts.unixSocket) {
23674
20975
  opts.socksProxy = void 0;
23675
- } else if (opts.socksProxy === void 0 && typeof process_exports !== "undefined") {
23676
- opts.socksProxy = process_exports.env["MQTTJS_SOCKS_PROXY"];
20976
+ } else if (opts.socksProxy === void 0 && typeof browser_process_exports !== "undefined") {
20977
+ opts.socksProxy = browser_process_exports.env["MQTTJS_SOCKS_PROXY"];
23677
20978
  }
23678
20979
  if (opts.cert && opts.key) {
23679
20980
  if (opts.protocol) {