@fefeding/aicmd 1.0.26 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +60 -5
  2. package/README.zh.md +66 -5
  3. package/dist/public/.vite/manifest.json +133 -13
  4. package/dist/public/ai-settings.css +1868 -0
  5. package/dist/public/ai-settings.js +7579 -0
  6. package/dist/public/bootstrap-icons.woff +0 -0
  7. package/dist/public/bootstrap-icons.woff2 +0 -0
  8. package/dist/public/bootstrap.css +1 -1
  9. package/dist/public/bootstrap.js +60 -119
  10. package/dist/public/connection-editor.css +5 -0
  11. package/dist/public/connection-editor.js +831 -0
  12. package/dist/public/connection.js +118 -0
  13. package/dist/public/index.css +0 -381
  14. package/dist/public/index.js +186 -5467
  15. package/dist/public/rdp_client_bg.wasm +0 -0
  16. package/dist/public/selection-copy.css +494 -0
  17. package/dist/public/selection-copy.js +5540 -0
  18. package/dist/public/src/term.html +17 -0
  19. package/dist/public/src/vscode-edit.html +21 -0
  20. package/dist/public/src/vscode-term.html +24 -0
  21. package/dist/public/term.css +14 -0
  22. package/dist/public/term.js +333 -0
  23. package/dist/public/views.css +111 -1515
  24. package/dist/public/views.js +233 -7476
  25. package/dist/public/vscode-clipboard.js +658 -0
  26. package/dist/public/vscode-edit.js +91 -0
  27. package/dist/public/vscode-term.js +116 -0
  28. package/dist/public/vue.js +360 -195
  29. package/dist/public/xterm.js +1647 -10
  30. package/dist/public/zmodem.js +2726 -0
  31. package/dist/server/index.d.ts +12 -2
  32. package/dist/server/index.d.ts.map +1 -1
  33. package/dist/server/index.js +14 -1
  34. package/dist/server/index.js.map +1 -1
  35. package/dist/server/index.ts +14 -1
  36. package/dist/server/model/connection.entity.d.ts +27 -2
  37. package/dist/server/model/connection.entity.d.ts.map +1 -1
  38. package/dist/server/model/connection.entity.js +11 -1
  39. package/dist/server/model/connection.entity.js.map +1 -1
  40. package/dist/server/model/connection.entity.ts +30 -2
  41. package/dist/server/service/ai.service.d.ts +15 -0
  42. package/dist/server/service/ai.service.d.ts.map +1 -1
  43. package/dist/server/service/ai.service.js +38 -6
  44. package/dist/server/service/ai.service.js.map +1 -1
  45. package/dist/server/service/ai.service.ts +43 -6
  46. package/dist/server/service/connection.service.d.ts +1 -1
  47. package/dist/server/service/connection.service.d.ts.map +1 -1
  48. package/dist/server/service/connection.service.js +32 -3
  49. package/dist/server/service/connection.service.js.map +1 -1
  50. package/dist/server/service/connection.service.ts +30 -3
  51. package/dist/server/service/monitor.service.d.ts.map +1 -1
  52. package/dist/server/service/monitor.service.js +8 -1
  53. package/dist/server/service/monitor.service.js.map +1 -1
  54. package/dist/server/service/monitor.service.ts +8 -1
  55. package/dist/server/service/rdp-tunnel.service.d.ts +22 -0
  56. package/dist/server/service/rdp-tunnel.service.d.ts.map +1 -0
  57. package/dist/server/service/rdp-tunnel.service.js +474 -0
  58. package/dist/server/service/rdp-tunnel.service.js.map +1 -0
  59. package/dist/server/service/rdp-tunnel.service.ts +439 -0
  60. package/dist/server/service/rdp.service.d.ts +64 -0
  61. package/dist/server/service/rdp.service.d.ts.map +1 -0
  62. package/dist/server/service/rdp.service.js +324 -0
  63. package/dist/server/service/rdp.service.js.map +1 -0
  64. package/dist/server/service/rdp.service.ts +324 -0
  65. package/dist/server/service/ssh.service.d.ts +57 -1
  66. package/dist/server/service/ssh.service.d.ts.map +1 -1
  67. package/dist/server/service/ssh.service.js +460 -109
  68. package/dist/server/service/ssh.service.js.map +1 -1
  69. package/dist/server/service/ssh.service.ts +455 -107
  70. package/dist/server/utils/ansi.d.ts +20 -0
  71. package/dist/server/utils/ansi.d.ts.map +1 -0
  72. package/dist/server/utils/ansi.js +39 -0
  73. package/dist/server/utils/ansi.js.map +1 -0
  74. package/dist/server/utils/ansi.ts +34 -0
  75. package/dist/server/utils/proxy.d.ts +28 -0
  76. package/dist/server/utils/proxy.d.ts.map +1 -0
  77. package/dist/server/utils/proxy.js +596 -0
  78. package/dist/server/utils/proxy.js.map +1 -0
  79. package/dist/server/utils/proxy.ts +556 -0
  80. package/dist/server/utils/rdp-ws.d.ts +15 -0
  81. package/dist/server/utils/rdp-ws.d.ts.map +1 -0
  82. package/dist/server/utils/rdp-ws.js +28 -0
  83. package/dist/server/utils/rdp-ws.js.map +1 -0
  84. package/dist/server/utils/rdp-ws.ts +32 -0
  85. package/dist/view/index.html +9 -7
  86. package/electron/main.js +118 -3
  87. package/electron/preload.js +4 -0
  88. package/package.json +32 -31
  89. package/public/aicmd.png +0 -0
  90. package/server.js +132 -12
  91. package/dist/public/rolldown-runtime.js +0 -41
@@ -1,5 +1,5 @@
1
- import { n as __esmMin, t as __commonJSMin } from "./rolldown-runtime.js";
2
- //#region node_modules/.pnpm/@xterm+xterm@5.5.0/node_modules/@xterm/xterm/lib/xterm.js
1
+ import { m as __esmMin, p as __commonJSMin } from "./vscode-clipboard.js";
2
+ // node_modules/.pnpm/@xterm+xterm@5.5.0/node_modules/@xterm/xterm/lib/xterm.js
3
3
  var require_xterm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
4
  (function(e, t) {
5
5
  if ("object" == typeof exports && "object" == typeof module) module.exports = t();
@@ -7206,8 +7206,7 @@ var require_xterm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7206
7206
  })(), s;
7207
7207
  })()));
7208
7208
  }));
7209
- //#endregion
7210
- //#region node_modules/.pnpm/@xterm+addon-fit@0.10.0_@xterm+xterm@5.5.0/node_modules/@xterm/addon-fit/lib/addon-fit.js
7209
+ // node_modules/.pnpm/@xterm+addon-fit@0.10.0_@xterm+xterm@5.5.0/node_modules/@xterm/addon-fit/lib/addon-fit.js
7211
7210
  var require_addon_fit = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7212
7211
  (function(e, t) {
7213
7212
  "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.FitAddon = t() : e.FitAddon = t();
@@ -7242,8 +7241,7 @@ var require_addon_fit = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7242
7241
  })(), e;
7243
7242
  })()));
7244
7243
  }));
7245
- //#endregion
7246
- //#region node_modules/.pnpm/@xterm+addon-web-links@0.11.0_@xterm+xterm@5.5.0/node_modules/@xterm/addon-web-links/lib/addon-web-links.js
7244
+ // node_modules/.pnpm/@xterm+addon-web-links@0.11.0_@xterm+xterm@5.5.0/node_modules/@xterm/addon-web-links/lib/addon-web-links.js
7247
7245
  var require_addon_web_links = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7248
7246
  (function(e, t) {
7249
7247
  "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.WebLinksAddon = t() : e.WebLinksAddon = t();
@@ -7374,8 +7372,1647 @@ var require_addon_web_links = /* @__PURE__ */ __commonJSMin(((exports, module) =
7374
7372
  })(), o;
7375
7373
  })()));
7376
7374
  }));
7377
- //#endregion
7378
- //#region node_modules/.pnpm/@xterm+xterm@5.5.0/node_modules/@xterm/xterm/css/xterm.css
7375
+ // node_modules/.pnpm/@xterm+xterm@5.5.0/node_modules/@xterm/xterm/css/xterm.css
7379
7376
  var init_xterm = __esmMin((() => {}));
7380
- //#endregion
7381
- export { require_xterm as i, require_addon_web_links as n, require_addon_fit as r, init_xterm as t };
7377
+ // node_modules/.pnpm/@xterm+addon-search@0.16.0/node_modules/@xterm/addon-search/lib/addon-search.mjs
7378
+ /**
7379
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
7380
+ * @license MIT
7381
+ *
7382
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
7383
+ * @license MIT
7384
+ *
7385
+ * Originally forked from (with the author's permission):
7386
+ * Fabrice Bellard's javascript vt100 for jslinux:
7387
+ * http://bellard.org/jslinux/
7388
+ * Copyright (c) 2011 Fabrice Bellard
7389
+ */
7390
+ function le(r) {
7391
+ ft(r) || pt.onUnexpectedError(r);
7392
+ }
7393
+ function ft(r) {
7394
+ return r instanceof ee ? !0 : r instanceof Error && r.name === Ce && r.message === Ce;
7395
+ }
7396
+ function mt(r, e, t = 0, n = r.length) {
7397
+ let i = t, s = n;
7398
+ for (; i < s;) {
7399
+ let a = Math.floor((i + s) / 2);
7400
+ e(r[a]) ? i = a + 1 : s = a;
7401
+ }
7402
+ return i - 1;
7403
+ }
7404
+ function $e(r, e) {
7405
+ return (t, n) => e(r(t), r(n));
7406
+ }
7407
+ function Xe(r, e) {
7408
+ let t = Object.create(null);
7409
+ for (let n of r) {
7410
+ let i = e(n), s = t[i];
7411
+ s || (s = t[i] = []), s.push(n);
7412
+ }
7413
+ return t;
7414
+ }
7415
+ function Pe(r, e) {
7416
+ let t = this, n = !1, i;
7417
+ return function() {
7418
+ if (n) return i;
7419
+ if (n = !0, e) try {
7420
+ i = r.apply(t, arguments);
7421
+ } finally {
7422
+ e();
7423
+ }
7424
+ else i = r.apply(t, arguments);
7425
+ return i;
7426
+ };
7427
+ }
7428
+ function vt(r) {
7429
+ K = r;
7430
+ }
7431
+ function pe(r) {
7432
+ return K?.trackDisposable(r), r;
7433
+ }
7434
+ function fe(r) {
7435
+ K?.markAsDisposed(r);
7436
+ }
7437
+ function te(r, e) {
7438
+ K?.setParent(r, e);
7439
+ }
7440
+ function bt(r, e) {
7441
+ if (K) for (let t of r) K.setParent(t, e);
7442
+ }
7443
+ function Q(r) {
7444
+ if (Le.is(r)) {
7445
+ let e = [];
7446
+ for (let t of r) if (t) try {
7447
+ t.dispose();
7448
+ } catch (n) {
7449
+ e.push(n);
7450
+ }
7451
+ if (e.length === 1) throw e[0];
7452
+ if (e.length > 1) throw new AggregateError(e, "Encountered errors while disposing of store");
7453
+ return Array.isArray(r) ? [] : r;
7454
+ } else if (r) return r.dispose(), r;
7455
+ }
7456
+ function me(...r) {
7457
+ let e = A(() => Q(r));
7458
+ return bt(r, e), e;
7459
+ }
7460
+ function A(r) {
7461
+ let e = pe({ dispose: Pe(() => {
7462
+ fe(e), r();
7463
+ }) });
7464
+ return e;
7465
+ }
7466
+ function xe(r, e = 0, t) {
7467
+ let n = setTimeout(() => {
7468
+ r(), t && i.dispose();
7469
+ }, e), i = A(() => {
7470
+ clearTimeout(n), t?.deleteAndLeak(i);
7471
+ });
7472
+ return t?.add(i), i;
7473
+ }
7474
+ var Re, pt, Ce, ee, ae, ue, Qe, Be, V, ce, Le, Tt, K, de, he, H, k, F, $, _t, Te, gt, tt, yt, ie, B, Oe, nt, be, Ae, ne, Me, Fe, xt, G, It, Dt, ve, C, Ne, it, Et, We, Y, ge, st, ye, N, W, O, Ot, M, j, Mt, Ft, Nt, qt, P, Ie, De, Ee, we, ke, ut;
7475
+ var init_addon_search = __esmMin((() => {
7476
+ Re = class {
7477
+ constructor() {
7478
+ this.listeners = [], this.unexpectedErrorHandler = function(e) {
7479
+ setTimeout(() => {
7480
+ throw e.stack ? ae.isErrorNoTelemetry(e) ? new ae(e.message + `
7481
+
7482
+ ` + e.stack) : /* @__PURE__ */ new Error(e.message + `
7483
+
7484
+ ` + e.stack) : e;
7485
+ }, 0);
7486
+ };
7487
+ }
7488
+ addListener(e) {
7489
+ return this.listeners.push(e), () => {
7490
+ this._removeListener(e);
7491
+ };
7492
+ }
7493
+ emit(e) {
7494
+ this.listeners.forEach((t) => {
7495
+ t(e);
7496
+ });
7497
+ }
7498
+ _removeListener(e) {
7499
+ this.listeners.splice(this.listeners.indexOf(e), 1);
7500
+ }
7501
+ setUnexpectedErrorHandler(e) {
7502
+ this.unexpectedErrorHandler = e;
7503
+ }
7504
+ getUnexpectedErrorHandler() {
7505
+ return this.unexpectedErrorHandler;
7506
+ }
7507
+ onUnexpectedError(e) {
7508
+ this.unexpectedErrorHandler(e), this.emit(e);
7509
+ }
7510
+ onUnexpectedExternalError(e) {
7511
+ this.unexpectedErrorHandler(e);
7512
+ }
7513
+ };
7514
+ pt = new Re();
7515
+ Ce = "Canceled";
7516
+ ee = class extends Error {
7517
+ constructor() {
7518
+ super(Ce), this.name = this.message;
7519
+ }
7520
+ };
7521
+ ae = class r extends Error {
7522
+ constructor(e) {
7523
+ super(e), this.name = "CodeExpectedError";
7524
+ }
7525
+ static fromError(e) {
7526
+ if (e instanceof r) return e;
7527
+ let t = new r();
7528
+ return t.message = e.message, t.stack = e.stack, t;
7529
+ }
7530
+ static isErrorNoTelemetry(e) {
7531
+ return e.name === "CodeExpectedError";
7532
+ }
7533
+ };
7534
+ ue = class ue {
7535
+ constructor(e) {
7536
+ this._array = e;
7537
+ this._findLastMonotonousLastIdx = 0;
7538
+ }
7539
+ findLastMonotonous(e) {
7540
+ if (ue.assertInvariants) {
7541
+ if (this._prevFindLastPredicate) {
7542
+ for (let n of this._array) if (this._prevFindLastPredicate(n) && !e(n)) throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.");
7543
+ }
7544
+ this._prevFindLastPredicate = e;
7545
+ }
7546
+ let t = mt(this._array, e, this._findLastMonotonousLastIdx);
7547
+ return this._findLastMonotonousLastIdx = t + 1, t === -1 ? void 0 : this._array[t];
7548
+ }
7549
+ };
7550
+ ue.assertInvariants = !1;
7551
+ ((h) => {
7552
+ function r(u) {
7553
+ return u < 0;
7554
+ }
7555
+ h.isLessThan = r;
7556
+ function e(u) {
7557
+ return u <= 0;
7558
+ }
7559
+ h.isLessThanOrEqual = e;
7560
+ function t(u) {
7561
+ return u > 0;
7562
+ }
7563
+ h.isGreaterThan = t;
7564
+ function n(u) {
7565
+ return u === 0;
7566
+ }
7567
+ h.isNeitherLessOrGreaterThan = n, h.greaterThan = 1, h.lessThan = -1, h.neitherLessOrGreaterThan = 0;
7568
+ })(Qe ||= {});
7569
+ Be = (r, e) => r - e;
7570
+ V = class V {
7571
+ constructor(e) {
7572
+ this.iterate = e;
7573
+ }
7574
+ forEach(e) {
7575
+ this.iterate((t) => (e(t), !0));
7576
+ }
7577
+ toArray() {
7578
+ let e = [];
7579
+ return this.iterate((t) => (e.push(t), !0)), e;
7580
+ }
7581
+ filter(e) {
7582
+ return new V((t) => this.iterate((n) => e(n) ? t(n) : !0));
7583
+ }
7584
+ map(e) {
7585
+ return new V((t) => this.iterate((n) => t(e(n))));
7586
+ }
7587
+ some(e) {
7588
+ let t = !1;
7589
+ return this.iterate((n) => (t = e(n), !t)), t;
7590
+ }
7591
+ findFirst(e) {
7592
+ let t;
7593
+ return this.iterate((n) => e(n) ? (t = n, !1) : !0), t;
7594
+ }
7595
+ findLast(e) {
7596
+ let t;
7597
+ return this.iterate((n) => (e(n) && (t = n), !0)), t;
7598
+ }
7599
+ findLastMaxBy(e) {
7600
+ let t, n = !0;
7601
+ return this.iterate((i) => ((n || Qe.isGreaterThan(e(i, t))) && (n = !1, t = i), !0)), t;
7602
+ }
7603
+ };
7604
+ V.empty = new V((e) => {});
7605
+ ce = class {
7606
+ constructor() {
7607
+ this.map = /* @__PURE__ */ new Map();
7608
+ }
7609
+ add(e, t) {
7610
+ let n = this.map.get(e);
7611
+ n || (n = /* @__PURE__ */ new Set(), this.map.set(e, n)), n.add(t);
7612
+ }
7613
+ delete(e, t) {
7614
+ let n = this.map.get(e);
7615
+ n && (n.delete(t), n.size === 0 && this.map.delete(e));
7616
+ }
7617
+ forEach(e, t) {
7618
+ let n = this.map.get(e);
7619
+ n && n.forEach(t);
7620
+ }
7621
+ get(e) {
7622
+ return this.map.get(e) || /* @__PURE__ */ new Set();
7623
+ }
7624
+ };
7625
+ ((z) => {
7626
+ function r(m) {
7627
+ return m && typeof m == "object" && typeof m[Symbol.iterator] == "function";
7628
+ }
7629
+ z.is = r;
7630
+ let e = Object.freeze([]);
7631
+ function t() {
7632
+ return e;
7633
+ }
7634
+ z.empty = t;
7635
+ function* n(m) {
7636
+ yield m;
7637
+ }
7638
+ z.single = n;
7639
+ function i(m) {
7640
+ return r(m) ? m : n(m);
7641
+ }
7642
+ z.wrap = i;
7643
+ function s(m) {
7644
+ return m || e;
7645
+ }
7646
+ z.from = s;
7647
+ function* a(m) {
7648
+ for (let _ = m.length - 1; _ >= 0; _--) yield m[_];
7649
+ }
7650
+ z.reverse = a;
7651
+ function h(m) {
7652
+ return !m || m[Symbol.iterator]().next().done === !0;
7653
+ }
7654
+ z.isEmpty = h;
7655
+ function u(m) {
7656
+ return m[Symbol.iterator]().next().value;
7657
+ }
7658
+ z.first = u;
7659
+ function p(m, _) {
7660
+ let y = 0;
7661
+ for (let L of m) if (_(L, y++)) return !0;
7662
+ return !1;
7663
+ }
7664
+ z.some = p;
7665
+ function T(m, _) {
7666
+ for (let y of m) if (_(y)) return y;
7667
+ }
7668
+ z.find = T;
7669
+ function* v(m, _) {
7670
+ for (let y of m) _(y) && (yield y);
7671
+ }
7672
+ z.filter = v;
7673
+ function* I(m, _) {
7674
+ let y = 0;
7675
+ for (let L of m) yield _(L, y++);
7676
+ }
7677
+ z.map = I;
7678
+ function* E(m, _) {
7679
+ let y = 0;
7680
+ for (let L of m) yield* _(L, y++);
7681
+ }
7682
+ z.flatMap = E;
7683
+ function* S(...m) {
7684
+ for (let _ of m) yield* _;
7685
+ }
7686
+ z.concat = S;
7687
+ function D(m, _, y) {
7688
+ let L = y;
7689
+ for (let X of m) L = _(L, X);
7690
+ return L;
7691
+ }
7692
+ z.reduce = D;
7693
+ function* x(m, _, y = m.length) {
7694
+ for (_ < 0 && (_ += m.length), y < 0 ? y += m.length : y > m.length && (y = m.length); _ < y; _++) yield m[_];
7695
+ }
7696
+ z.slice = x;
7697
+ function J(m, _ = Number.POSITIVE_INFINITY) {
7698
+ let y = [];
7699
+ if (_ === 0) return [y, m];
7700
+ let L = m[Symbol.iterator]();
7701
+ for (let X = 0; X < _; X++) {
7702
+ let Se = L.next();
7703
+ if (Se.done) return [y, z.empty()];
7704
+ y.push(Se.value);
7705
+ }
7706
+ return [y, { [Symbol.iterator]() {
7707
+ return L;
7708
+ } }];
7709
+ }
7710
+ z.consume = J;
7711
+ async function q(m) {
7712
+ let _ = [];
7713
+ for await (let y of m) _.push(y);
7714
+ return Promise.resolve(_);
7715
+ }
7716
+ z.asyncToArray = q;
7717
+ })(Le ||= {});
7718
+ Tt = !1;
7719
+ K = null;
7720
+ de = class de {
7721
+ constructor() {
7722
+ this.livingDisposables = /* @__PURE__ */ new Map();
7723
+ }
7724
+ getDisposableData(e) {
7725
+ let t = this.livingDisposables.get(e);
7726
+ return t || (t = {
7727
+ parent: null,
7728
+ source: null,
7729
+ isSingleton: !1,
7730
+ value: e,
7731
+ idx: de.idx++
7732
+ }, this.livingDisposables.set(e, t)), t;
7733
+ }
7734
+ trackDisposable(e) {
7735
+ let t = this.getDisposableData(e);
7736
+ t.source || (t.source = (/* @__PURE__ */ new Error()).stack);
7737
+ }
7738
+ setParent(e, t) {
7739
+ let n = this.getDisposableData(e);
7740
+ n.parent = t;
7741
+ }
7742
+ markAsDisposed(e) {
7743
+ this.livingDisposables.delete(e);
7744
+ }
7745
+ markAsSingleton(e) {
7746
+ this.getDisposableData(e).isSingleton = !0;
7747
+ }
7748
+ getRootParent(e, t) {
7749
+ let n = t.get(e);
7750
+ if (n) return n;
7751
+ let i = e.parent ? this.getRootParent(this.getDisposableData(e.parent), t) : e;
7752
+ return t.set(e, i), i;
7753
+ }
7754
+ getTrackedDisposables() {
7755
+ let e = /* @__PURE__ */ new Map();
7756
+ return [...this.livingDisposables.entries()].filter(([, n]) => n.source !== null && !this.getRootParent(n, e).isSingleton).flatMap(([n]) => n);
7757
+ }
7758
+ computeLeakingDisposables(e = 10, t) {
7759
+ let n;
7760
+ if (t) n = t;
7761
+ else {
7762
+ let u = /* @__PURE__ */ new Map(), p = [...this.livingDisposables.values()].filter((v) => v.source !== null && !this.getRootParent(v, u).isSingleton);
7763
+ if (p.length === 0) return;
7764
+ let T = new Set(p.map((v) => v.value));
7765
+ if (n = p.filter((v) => !(v.parent && T.has(v.parent))), n.length === 0) throw new Error("There are cyclic diposable chains!");
7766
+ }
7767
+ if (!n) return;
7768
+ function i(u) {
7769
+ function p(v, I) {
7770
+ for (; v.length > 0 && I.some((E) => typeof E == "string" ? E === v[0] : v[0].match(E));) v.shift();
7771
+ }
7772
+ let T = u.source.split(`
7773
+ `).map((v) => v.trim().replace("at ", "")).filter((v) => v !== "");
7774
+ return p(T, [
7775
+ "Error",
7776
+ /^trackDisposable \(.*\)$/,
7777
+ /^DisposableTracker.trackDisposable \(.*\)$/
7778
+ ]), T.reverse();
7779
+ }
7780
+ let s = new ce();
7781
+ for (let u of n) {
7782
+ let p = i(u);
7783
+ for (let T = 0; T <= p.length; T++) s.add(p.slice(0, T).join(`
7784
+ `), u);
7785
+ }
7786
+ n.sort($e((u) => u.idx, Be));
7787
+ let a = "", h = 0;
7788
+ for (let u of n.slice(0, e)) {
7789
+ h++;
7790
+ let p = i(u), T = [];
7791
+ for (let v = 0; v < p.length; v++) {
7792
+ let I = p[v];
7793
+ I = `(shared with ${s.get(p.slice(0, v + 1).join(`
7794
+ `)).size}/${n.length} leaks) at ${I}`;
7795
+ let D = Xe([...s.get(p.slice(0, v).join(`
7796
+ `))].map((x) => i(x)[v]), (x) => x);
7797
+ delete D[p[v]];
7798
+ for (let [x, J] of Object.entries(D)) T.unshift(` - stacktraces of ${J.length} other leaks continue with ${x}`);
7799
+ T.unshift(I);
7800
+ }
7801
+ a += `
7802
+
7803
+
7804
+ ==================== Leaking disposable ${h}/${n.length}: ${u.value.constructor.name} ====================
7805
+ ${T.join(`
7806
+ `)}
7807
+ ============================================================
7808
+
7809
+ `;
7810
+ }
7811
+ return n.length > e && (a += `
7812
+
7813
+
7814
+ ... and ${n.length - e} more leaking disposables
7815
+
7816
+ `), {
7817
+ leaks: n,
7818
+ details: a
7819
+ };
7820
+ }
7821
+ };
7822
+ de.idx = 0;
7823
+ if (Tt) {
7824
+ let r = "__is_disposable_tracked__";
7825
+ vt(new class {
7826
+ trackDisposable(e) {
7827
+ let t = (/* @__PURE__ */ new Error("Potentially leaked disposable")).stack;
7828
+ setTimeout(() => {
7829
+ e[r] || console.log(t);
7830
+ }, 3e3);
7831
+ }
7832
+ setParent(e, t) {
7833
+ if (e && e !== k.None) try {
7834
+ e[r] = !0;
7835
+ } catch {}
7836
+ }
7837
+ markAsDisposed(e) {
7838
+ if (e && e !== k.None) try {
7839
+ e[r] = !0;
7840
+ } catch {}
7841
+ }
7842
+ markAsSingleton(e) {}
7843
+ }());
7844
+ }
7845
+ he = class he {
7846
+ constructor() {
7847
+ this._toDispose = /* @__PURE__ */ new Set();
7848
+ this._isDisposed = !1;
7849
+ pe(this);
7850
+ }
7851
+ dispose() {
7852
+ this._isDisposed || (fe(this), this._isDisposed = !0, this.clear());
7853
+ }
7854
+ get isDisposed() {
7855
+ return this._isDisposed;
7856
+ }
7857
+ clear() {
7858
+ if (this._toDispose.size !== 0) try {
7859
+ Q(this._toDispose);
7860
+ } finally {
7861
+ this._toDispose.clear();
7862
+ }
7863
+ }
7864
+ add(e) {
7865
+ if (!e) return e;
7866
+ if (e === this) throw new Error("Cannot register a disposable on itself!");
7867
+ return te(e, this), this._isDisposed ? he.DISABLE_DISPOSED_WARNING || console.warn((/* @__PURE__ */ new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!")).stack) : this._toDispose.add(e), e;
7868
+ }
7869
+ delete(e) {
7870
+ if (e) {
7871
+ if (e === this) throw new Error("Cannot dispose a disposable on itself!");
7872
+ this._toDispose.delete(e), e.dispose();
7873
+ }
7874
+ }
7875
+ deleteAndLeak(e) {
7876
+ e && this._toDispose.has(e) && (this._toDispose.delete(e), te(e, null));
7877
+ }
7878
+ };
7879
+ he.DISABLE_DISPOSED_WARNING = !1;
7880
+ H = he;
7881
+ k = class {
7882
+ constructor() {
7883
+ this._store = new H();
7884
+ pe(this), te(this._store, this);
7885
+ }
7886
+ dispose() {
7887
+ fe(this), this._store.dispose();
7888
+ }
7889
+ _register(e) {
7890
+ if (e === this) throw new Error("Cannot register a disposable on itself!");
7891
+ return this._store.add(e);
7892
+ }
7893
+ };
7894
+ k.None = Object.freeze({ dispose() {} });
7895
+ F = class {
7896
+ constructor() {
7897
+ this._isDisposed = !1;
7898
+ pe(this);
7899
+ }
7900
+ get value() {
7901
+ return this._isDisposed ? void 0 : this._value;
7902
+ }
7903
+ set value(e) {
7904
+ this._isDisposed || e === this._value || (this._value?.dispose(), e && te(e, this), this._value = e);
7905
+ }
7906
+ clear() {
7907
+ this.value = void 0;
7908
+ }
7909
+ dispose() {
7910
+ this._isDisposed = !0, fe(this), this._value?.dispose(), this._value = void 0;
7911
+ }
7912
+ clearAndLeak() {
7913
+ let e = this._value;
7914
+ return this._value = void 0, e && te(e, null), e;
7915
+ }
7916
+ };
7917
+ $ = class $ {
7918
+ constructor(e) {
7919
+ this.element = e, this.next = $.Undefined, this.prev = $.Undefined;
7920
+ }
7921
+ };
7922
+ $.Undefined = new $(void 0);
7923
+ _t = globalThis.performance && typeof globalThis.performance.now == "function";
7924
+ Te = class r {
7925
+ static create(e) {
7926
+ return new r(e);
7927
+ }
7928
+ constructor(e) {
7929
+ this._now = _t && e === !1 ? Date.now : globalThis.performance.now.bind(globalThis.performance), this._startTime = this._now(), this._stopTime = -1;
7930
+ }
7931
+ stop() {
7932
+ this._stopTime = this._now();
7933
+ }
7934
+ reset() {
7935
+ this._startTime = this._now(), this._stopTime = -1;
7936
+ }
7937
+ elapsed() {
7938
+ return this._stopTime !== -1 ? this._stopTime - this._startTime : this._now() - this._startTime;
7939
+ }
7940
+ };
7941
+ gt = !1;
7942
+ tt = !1;
7943
+ yt = !1;
7944
+ ((re) => {
7945
+ re.None = () => k.None;
7946
+ function e(d) {
7947
+ if (yt) {
7948
+ let { onDidAddListener: o } = d, c = ne.create(), l = 0;
7949
+ d.onDidAddListener = () => {
7950
+ ++l === 2 && (console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"), c.print()), o?.();
7951
+ };
7952
+ }
7953
+ }
7954
+ function t(d, o) {
7955
+ return I(d, () => {}, 0, void 0, !0, void 0, o);
7956
+ }
7957
+ re.defer = t;
7958
+ function n(d) {
7959
+ return (o, c = null, l) => {
7960
+ let f = !1, b;
7961
+ return b = d((g) => {
7962
+ if (!f) return b ? b.dispose() : f = !0, o.call(c, g);
7963
+ }, null, l), f && b.dispose(), b;
7964
+ };
7965
+ }
7966
+ re.once = n;
7967
+ function i(d, o, c) {
7968
+ return T((l, f = null, b) => d((g) => l.call(f, o(g)), null, b), c);
7969
+ }
7970
+ re.map = i;
7971
+ function s(d, o, c) {
7972
+ return T((l, f = null, b) => d((g) => {
7973
+ o(g), l.call(f, g);
7974
+ }, null, b), c);
7975
+ }
7976
+ re.forEach = s;
7977
+ function a(d, o, c) {
7978
+ return T((l, f = null, b) => d((g) => o(g) && l.call(f, g), null, b), c);
7979
+ }
7980
+ re.filter = a;
7981
+ function h(d) {
7982
+ return d;
7983
+ }
7984
+ re.signal = h;
7985
+ function u(...d) {
7986
+ return (o, c = null, l) => {
7987
+ return v(me(...d.map((b) => b((g) => o.call(c, g)))), l);
7988
+ };
7989
+ }
7990
+ re.any = u;
7991
+ function p(d, o, c, l) {
7992
+ let f = c;
7993
+ return i(d, (b) => (f = o(f, b), f), l);
7994
+ }
7995
+ re.reduce = p;
7996
+ function T(d, o) {
7997
+ let c, l = {
7998
+ onWillAddFirstListener() {
7999
+ c = d(f.fire, f);
8000
+ },
8001
+ onDidRemoveLastListener() {
8002
+ c?.dispose();
8003
+ }
8004
+ };
8005
+ o || e(l);
8006
+ let f = new C(l);
8007
+ return o?.add(f), f.event;
8008
+ }
8009
+ function v(d, o) {
8010
+ return o instanceof Array ? o.push(d) : o && o.add(d), d;
8011
+ }
8012
+ function I(d, o, c = 100, l = !1, f = !1, b, g) {
8013
+ let w, R, U, se = 0, Z, Ve = {
8014
+ leakWarningThreshold: b,
8015
+ onWillAddFirstListener() {
8016
+ w = d((dt) => {
8017
+ se++, R = o(R, dt), l && !U && (oe.fire(R), R = void 0), Z = () => {
8018
+ let ht = R;
8019
+ R = void 0, U = void 0, (!l || se > 1) && oe.fire(ht), se = 0;
8020
+ }, typeof c == "number" ? (clearTimeout(U), U = setTimeout(Z, c)) : U === void 0 && (U = 0, queueMicrotask(Z));
8021
+ });
8022
+ },
8023
+ onWillRemoveListener() {
8024
+ f && se > 0 && Z?.();
8025
+ },
8026
+ onDidRemoveLastListener() {
8027
+ Z = void 0, w.dispose();
8028
+ }
8029
+ };
8030
+ g || e(Ve);
8031
+ let oe = new C(Ve);
8032
+ return g?.add(oe), oe.event;
8033
+ }
8034
+ re.debounce = I;
8035
+ function E(d, o = 0, c) {
8036
+ return re.debounce(d, (l, f) => l ? (l.push(f), l) : [f], o, void 0, !0, void 0, c);
8037
+ }
8038
+ re.accumulate = E;
8039
+ function S(d, o = (l, f) => l === f, c) {
8040
+ let l = !0, f;
8041
+ return a(d, (b) => {
8042
+ let g = l || !o(b, f);
8043
+ return l = !1, f = b, g;
8044
+ }, c);
8045
+ }
8046
+ re.latch = S;
8047
+ function D(d, o, c) {
8048
+ return [re.filter(d, o, c), re.filter(d, (l) => !o(l), c)];
8049
+ }
8050
+ re.split = D;
8051
+ function x(d, o = !1, c = [], l) {
8052
+ let f = c.slice(), b = d((R) => {
8053
+ f ? f.push(R) : w.fire(R);
8054
+ });
8055
+ l && l.add(b);
8056
+ let g = () => {
8057
+ f?.forEach((R) => w.fire(R)), f = null;
8058
+ }, w = new C({
8059
+ onWillAddFirstListener() {
8060
+ b || (b = d((R) => w.fire(R)), l && l.add(b));
8061
+ },
8062
+ onDidAddFirstListener() {
8063
+ f && (o ? setTimeout(g) : g());
8064
+ },
8065
+ onDidRemoveLastListener() {
8066
+ b && b.dispose(), b = null;
8067
+ }
8068
+ });
8069
+ return l && l.add(w), w.event;
8070
+ }
8071
+ re.buffer = x;
8072
+ function J(d, o) {
8073
+ return (l, f, b) => {
8074
+ let g = o(new z());
8075
+ return d(function(w) {
8076
+ let R = g.evaluate(w);
8077
+ R !== q && l.call(f, R);
8078
+ }, void 0, b);
8079
+ };
8080
+ }
8081
+ re.chain = J;
8082
+ let q = Symbol("HaltChainable");
8083
+ class z {
8084
+ constructor() {
8085
+ this.steps = [];
8086
+ }
8087
+ map(o) {
8088
+ return this.steps.push(o), this;
8089
+ }
8090
+ forEach(o) {
8091
+ return this.steps.push((c) => (o(c), c)), this;
8092
+ }
8093
+ filter(o) {
8094
+ return this.steps.push((c) => o(c) ? c : q), this;
8095
+ }
8096
+ reduce(o, c) {
8097
+ let l = c;
8098
+ return this.steps.push((f) => (l = o(l, f), l)), this;
8099
+ }
8100
+ latch(o = (c, l) => c === l) {
8101
+ let c = !0, l;
8102
+ return this.steps.push((f) => {
8103
+ let b = c || !o(f, l);
8104
+ return c = !1, l = f, b ? f : q;
8105
+ }), this;
8106
+ }
8107
+ evaluate(o) {
8108
+ for (let c of this.steps) if (o = c(o), o === q) break;
8109
+ return o;
8110
+ }
8111
+ }
8112
+ function m(d, o, c = (l) => l) {
8113
+ let l = (...w) => g.fire(c(...w)), f = () => d.on(o, l), b = () => d.removeListener(o, l), g = new C({
8114
+ onWillAddFirstListener: f,
8115
+ onDidRemoveLastListener: b
8116
+ });
8117
+ return g.event;
8118
+ }
8119
+ re.fromNodeEventEmitter = m;
8120
+ function _(d, o, c = (l) => l) {
8121
+ let l = (...w) => g.fire(c(...w)), f = () => d.addEventListener(o, l), b = () => d.removeEventListener(o, l), g = new C({
8122
+ onWillAddFirstListener: f,
8123
+ onDidRemoveLastListener: b
8124
+ });
8125
+ return g.event;
8126
+ }
8127
+ re.fromDOMEventEmitter = _;
8128
+ function y(d) {
8129
+ return new Promise((o) => n(d)(o));
8130
+ }
8131
+ re.toPromise = y;
8132
+ function L(d) {
8133
+ let o = new C();
8134
+ return d.then((c) => {
8135
+ o.fire(c);
8136
+ }, () => {
8137
+ o.fire(void 0);
8138
+ }).finally(() => {
8139
+ o.dispose();
8140
+ }), o.event;
8141
+ }
8142
+ re.fromPromise = L;
8143
+ function X(d, o) {
8144
+ return d((c) => o.fire(c));
8145
+ }
8146
+ re.forward = X;
8147
+ function Se(d, o, c) {
8148
+ return o(c), d((l) => o(l));
8149
+ }
8150
+ re.runAndSubscribe = Se;
8151
+ class ct {
8152
+ constructor(o, c) {
8153
+ this._observable = o;
8154
+ this._counter = 0;
8155
+ this._hasChanged = !1;
8156
+ let l = {
8157
+ onWillAddFirstListener: () => {
8158
+ o.addObserver(this);
8159
+ },
8160
+ onDidRemoveLastListener: () => {
8161
+ o.removeObserver(this);
8162
+ }
8163
+ };
8164
+ c || e(l), this.emitter = new C(l), c && c.add(this.emitter);
8165
+ }
8166
+ beginUpdate(o) {
8167
+ this._counter++;
8168
+ }
8169
+ handlePossibleChange(o) {}
8170
+ handleChange(o, c) {
8171
+ this._hasChanged = !0;
8172
+ }
8173
+ endUpdate(o) {
8174
+ this._counter--, this._counter === 0 && (this._observable.reportChanges(), this._hasChanged && (this._hasChanged = !1, this.emitter.fire(this._observable.get())));
8175
+ }
8176
+ }
8177
+ function zt(d, o) {
8178
+ return new ct(d, o).emitter.event;
8179
+ }
8180
+ re.fromObservable = zt;
8181
+ function Ut(d) {
8182
+ return (o, c, l) => {
8183
+ let f = 0, b = !1, g = {
8184
+ beginUpdate() {
8185
+ f++;
8186
+ },
8187
+ endUpdate() {
8188
+ f--, f === 0 && (d.reportChanges(), b && (b = !1, o.call(c)));
8189
+ },
8190
+ handlePossibleChange() {},
8191
+ handleChange() {
8192
+ b = !0;
8193
+ }
8194
+ };
8195
+ d.addObserver(g), d.reportChanges();
8196
+ let w = { dispose() {
8197
+ d.removeObserver(g);
8198
+ } };
8199
+ return l instanceof H ? l.add(w) : Array.isArray(l) && l.push(w), w;
8200
+ };
8201
+ }
8202
+ re.fromObservableLight = Ut;
8203
+ })(ie ||= {});
8204
+ B = class B {
8205
+ constructor(e) {
8206
+ this.listenerCount = 0;
8207
+ this.invocationCount = 0;
8208
+ this.elapsedOverall = 0;
8209
+ this.durations = [];
8210
+ this.name = `${e}_${B._idPool++}`, B.all.add(this);
8211
+ }
8212
+ start(e) {
8213
+ this._stopWatch = new Te(), this.listenerCount = e;
8214
+ }
8215
+ stop() {
8216
+ if (this._stopWatch) {
8217
+ let e = this._stopWatch.elapsed();
8218
+ this.durations.push(e), this.elapsedOverall += e, this.invocationCount += 1, this._stopWatch = void 0;
8219
+ }
8220
+ }
8221
+ };
8222
+ B.all = /* @__PURE__ */ new Set(), B._idPool = 0;
8223
+ Oe = B;
8224
+ nt = -1;
8225
+ be = class be {
8226
+ constructor(e, t, n = (be._idPool++).toString(16).padStart(3, "0")) {
8227
+ this._errorHandler = e;
8228
+ this.threshold = t;
8229
+ this.name = n;
8230
+ this._warnCountdown = 0;
8231
+ }
8232
+ dispose() {
8233
+ this._stacks?.clear();
8234
+ }
8235
+ check(e, t) {
8236
+ let n = this.threshold;
8237
+ if (n <= 0 || t < n) return;
8238
+ this._stacks || (this._stacks = /* @__PURE__ */ new Map());
8239
+ let i = this._stacks.get(e.value) || 0;
8240
+ if (this._stacks.set(e.value, i + 1), this._warnCountdown -= 1, this._warnCountdown <= 0) {
8241
+ this._warnCountdown = n * .5;
8242
+ let [s, a] = this.getMostFrequentStack(), h = `[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${a}):`;
8243
+ console.warn(h), console.warn(s);
8244
+ let u = new Me(h, s);
8245
+ this._errorHandler(u);
8246
+ }
8247
+ return () => {
8248
+ let s = this._stacks.get(e.value) || 0;
8249
+ this._stacks.set(e.value, s - 1);
8250
+ };
8251
+ }
8252
+ getMostFrequentStack() {
8253
+ if (!this._stacks) return;
8254
+ let e, t = 0;
8255
+ for (let [n, i] of this._stacks) (!e || t < i) && (e = [n, i], t = i);
8256
+ return e;
8257
+ }
8258
+ };
8259
+ be._idPool = 1;
8260
+ Ae = be;
8261
+ ne = class r {
8262
+ constructor(e) {
8263
+ this.value = e;
8264
+ }
8265
+ static create() {
8266
+ return new r((/* @__PURE__ */ new Error()).stack ?? "");
8267
+ }
8268
+ print() {
8269
+ console.warn(this.value.split(`
8270
+ `).slice(2).join(`
8271
+ `));
8272
+ }
8273
+ };
8274
+ Me = class extends Error {
8275
+ constructor(e, t) {
8276
+ super(e), this.name = "ListenerLeakError", this.stack = t;
8277
+ }
8278
+ };
8279
+ Fe = class extends Error {
8280
+ constructor(e, t) {
8281
+ super(e), this.name = "ListenerRefusalError", this.stack = t;
8282
+ }
8283
+ };
8284
+ xt = 0;
8285
+ G = class {
8286
+ constructor(e) {
8287
+ this.value = e;
8288
+ this.id = xt++;
8289
+ }
8290
+ };
8291
+ It = 2;
8292
+ Dt = (r, e) => {
8293
+ if (r instanceof G) e(r);
8294
+ else for (let t = 0; t < r.length; t++) {
8295
+ let n = r[t];
8296
+ n && e(n);
8297
+ }
8298
+ };
8299
+ if (gt) {
8300
+ let r = [];
8301
+ setInterval(() => {
8302
+ r.length !== 0 && (console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"), console.warn(r.join(`
8303
+ `)), r.length = 0);
8304
+ }, 3e3), ve = new FinalizationRegistry((e) => {
8305
+ typeof e == "string" && r.push(e);
8306
+ });
8307
+ }
8308
+ C = class {
8309
+ constructor(e) {
8310
+ this._size = 0;
8311
+ this._options = e, this._leakageMon = nt > 0 || this._options?.leakWarningThreshold ? new Ae(e?.onListenerError ?? le, this._options?.leakWarningThreshold ?? nt) : void 0, this._perfMon = this._options?._profName ? new Oe(this._options._profName) : void 0, this._deliveryQueue = this._options?.deliveryQueue;
8312
+ }
8313
+ dispose() {
8314
+ if (!this._disposed) {
8315
+ if (this._disposed = !0, this._deliveryQueue?.current === this && this._deliveryQueue.reset(), this._listeners) {
8316
+ if (tt) {
8317
+ let e = this._listeners;
8318
+ queueMicrotask(() => {
8319
+ Dt(e, (t) => t.stack?.print());
8320
+ });
8321
+ }
8322
+ this._listeners = void 0, this._size = 0;
8323
+ }
8324
+ this._options?.onDidRemoveLastListener?.(), this._leakageMon?.dispose();
8325
+ }
8326
+ }
8327
+ get event() {
8328
+ return this._event ??= (e, t, n) => {
8329
+ if (this._leakageMon && this._size > this._leakageMon.threshold ** 2) {
8330
+ let u = `[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;
8331
+ console.warn(u);
8332
+ let p = this._leakageMon.getMostFrequentStack() ?? ["UNKNOWN stack", -1], T = new Fe(`${u}. HINT: Stack shows most frequent listener (${p[1]}-times)`, p[0]);
8333
+ return (this._options?.onListenerError || le)(T), k.None;
8334
+ }
8335
+ if (this._disposed) return k.None;
8336
+ t && (e = e.bind(t));
8337
+ let i = new G(e), s;
8338
+ this._leakageMon && this._size >= Math.ceil(this._leakageMon.threshold * .2) && (i.stack = ne.create(), s = this._leakageMon.check(i.stack, this._size + 1)), this._listeners ? this._listeners instanceof G ? (this._deliveryQueue ??= new Ne(), this._listeners = [this._listeners, i]) : this._listeners.push(i) : (this._options?.onWillAddFirstListener?.(this), this._listeners = i, this._options?.onDidAddFirstListener?.(this)), this._size++;
8339
+ let h = A(() => {
8340
+ ve?.unregister(h), s?.(), this._removeListener(i);
8341
+ });
8342
+ if (n instanceof H ? n.add(h) : Array.isArray(n) && n.push(h), ve) {
8343
+ let u = (/* @__PURE__ */ new Error()).stack.split(`
8344
+ `).slice(2, 3).join(`
8345
+ `).trim(), p = /(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(u);
8346
+ ve.register(h, p?.[2] ?? u, h);
8347
+ }
8348
+ return h;
8349
+ }, this._event;
8350
+ }
8351
+ _removeListener(e) {
8352
+ if (this._options?.onWillRemoveListener?.(this), !this._listeners) return;
8353
+ if (this._size === 1) {
8354
+ this._listeners = void 0, this._options?.onDidRemoveLastListener?.(this), this._size = 0;
8355
+ return;
8356
+ }
8357
+ let t = this._listeners, n = t.indexOf(e);
8358
+ if (n === -1) throw console.log("disposed?", this._disposed), console.log("size?", this._size), console.log("arr?", JSON.stringify(this._listeners)), /* @__PURE__ */ new Error("Attempted to dispose unknown listener");
8359
+ this._size--, t[n] = void 0;
8360
+ let i = this._deliveryQueue.current === this;
8361
+ if (this._size * It <= t.length) {
8362
+ let s = 0;
8363
+ for (let a = 0; a < t.length; a++) t[a] ? t[s++] = t[a] : i && (this._deliveryQueue.end--, s < this._deliveryQueue.i && this._deliveryQueue.i--);
8364
+ t.length = s;
8365
+ }
8366
+ }
8367
+ _deliver(e, t) {
8368
+ if (!e) return;
8369
+ let n = this._options?.onListenerError || le;
8370
+ if (!n) {
8371
+ e.value(t);
8372
+ return;
8373
+ }
8374
+ try {
8375
+ e.value(t);
8376
+ } catch (i) {
8377
+ n(i);
8378
+ }
8379
+ }
8380
+ _deliverQueue(e) {
8381
+ let t = e.current._listeners;
8382
+ for (; e.i < e.end;) this._deliver(t[e.i++], e.value);
8383
+ e.reset();
8384
+ }
8385
+ fire(e) {
8386
+ if (this._deliveryQueue?.current && (this._deliverQueue(this._deliveryQueue), this._perfMon?.stop()), this._perfMon?.start(this._size), this._listeners) if (this._listeners instanceof G) this._deliver(this._listeners, e);
8387
+ else {
8388
+ let t = this._deliveryQueue;
8389
+ t.enqueue(this, e, this._listeners.length), this._deliverQueue(t);
8390
+ }
8391
+ this._perfMon?.stop();
8392
+ }
8393
+ hasListeners() {
8394
+ return this._size > 0;
8395
+ }
8396
+ };
8397
+ Ne = class {
8398
+ constructor() {
8399
+ this.i = -1;
8400
+ this.end = 0;
8401
+ }
8402
+ enqueue(e, t, n) {
8403
+ this.i = 0, this.end = n, this.current = e, this.value = t;
8404
+ }
8405
+ reset() {
8406
+ this.i = this.end, this.current = void 0, this.value = void 0;
8407
+ }
8408
+ };
8409
+ it = Object.freeze(function(r, e) {
8410
+ let t = setTimeout(r.bind(e), 0);
8411
+ return { dispose() {
8412
+ clearTimeout(t);
8413
+ } };
8414
+ });
8415
+ ((n) => {
8416
+ function r(i) {
8417
+ return i === n.None || i === n.Cancelled || i instanceof We ? !0 : !i || typeof i != "object" ? !1 : typeof i.isCancellationRequested == "boolean" && typeof i.onCancellationRequested == "function";
8418
+ }
8419
+ n.isCancellationToken = r, n.None = Object.freeze({
8420
+ isCancellationRequested: !1,
8421
+ onCancellationRequested: ie.None
8422
+ }), n.Cancelled = Object.freeze({
8423
+ isCancellationRequested: !0,
8424
+ onCancellationRequested: it
8425
+ });
8426
+ })(Et ||= {});
8427
+ We = class {
8428
+ constructor() {
8429
+ this._isCancelled = !1;
8430
+ this._emitter = null;
8431
+ }
8432
+ cancel() {
8433
+ this._isCancelled || (this._isCancelled = !0, this._emitter && (this._emitter.fire(void 0), this.dispose()));
8434
+ }
8435
+ get isCancellationRequested() {
8436
+ return this._isCancelled;
8437
+ }
8438
+ get onCancellationRequested() {
8439
+ return this._isCancelled ? it : (this._emitter || (this._emitter = new C()), this._emitter.event);
8440
+ }
8441
+ dispose() {
8442
+ this._emitter && (this._emitter.dispose(), this._emitter = null);
8443
+ }
8444
+ };
8445
+ Y = "en";
8446
+ ge = !1;
8447
+ st = !1;
8448
+ ye = Y;
8449
+ W = globalThis;
8450
+ typeof W.vscode < "u" && typeof W.vscode.process < "u" ? O = W.vscode.process : typeof process < "u" && typeof process?.versions?.node == "string" && (O = process);
8451
+ Ot = typeof O?.versions?.electron == "string" && O?.type === "renderer";
8452
+ if (typeof O == "object") {
8453
+ O.platform, O.platform, ge = O.platform === "linux", ge && O.env.SNAP && O.env.SNAP_REVISION, O.env.CI || O.env.BUILD_ARTIFACTSTAGINGDIRECTORY, ye = Y;
8454
+ let r = O.env.VSCODE_NLS_CONFIG;
8455
+ if (r) try {
8456
+ let e = JSON.parse(r);
8457
+ e.userLocale, e.osLocale, ye = e.resolvedLanguage || Y, e.languagePack?.translationsConfigFile;
8458
+ } catch {}
8459
+ } else typeof navigator == "object" && !Ot ? (N = navigator.userAgent, N.indexOf("Windows"), N.indexOf("Macintosh"), (N.indexOf("Macintosh") >= 0 || N.indexOf("iPad") >= 0 || N.indexOf("iPhone") >= 0) && navigator.maxTouchPoints && navigator.maxTouchPoints, ge = N.indexOf("Linux") >= 0, N?.indexOf("Mobi"), st = !0, ye = globalThis._VSCODE_NLS_LANGUAGE || Y, navigator.language.toLowerCase()) : console.error("Unable to resolve platform.");
8460
+ st && typeof W.importScripts == "function" && W.origin;
8461
+ M = N;
8462
+ j = ye;
8463
+ ((n) => {
8464
+ function r() {
8465
+ return j;
8466
+ }
8467
+ n.value = r;
8468
+ function e() {
8469
+ return j.length === 2 ? j === "en" : j.length >= 3 ? j[0] === "e" && j[1] === "n" && j[2] === "-" : !1;
8470
+ }
8471
+ n.isDefaultVariant = e;
8472
+ function t() {
8473
+ return j === "en";
8474
+ }
8475
+ n.isDefault = t;
8476
+ })(Mt ||= {});
8477
+ Ft = typeof W.postMessage == "function" && !W.importScripts;
8478
+ (() => {
8479
+ if (Ft) {
8480
+ let r = [];
8481
+ W.addEventListener("message", (t) => {
8482
+ if (t.data && t.data.vscodeScheduleAsyncWork) for (let n = 0, i = r.length; n < i; n++) {
8483
+ let s = r[n];
8484
+ if (s.id === t.data.vscodeScheduleAsyncWork) {
8485
+ r.splice(n, 1), s.callback();
8486
+ return;
8487
+ }
8488
+ }
8489
+ });
8490
+ let e = 0;
8491
+ return (t) => {
8492
+ let n = ++e;
8493
+ r.push({
8494
+ id: n,
8495
+ callback: t
8496
+ }), W.postMessage({ vscodeScheduleAsyncWork: n }, "*");
8497
+ };
8498
+ }
8499
+ return (r) => setTimeout(r);
8500
+ })();
8501
+ Nt = !!(M && M.indexOf("Chrome") >= 0);
8502
+ M && M.indexOf("Firefox");
8503
+ !Nt && M && M.indexOf("Safari");
8504
+ M && M.indexOf("Edg/");
8505
+ M && M.indexOf("Android");
8506
+ (function() {
8507
+ typeof globalThis.requestIdleCallback != "function" || globalThis.cancelIdleCallback;
8508
+ })();
8509
+ ((t) => {
8510
+ async function r(n) {
8511
+ let i, s = await Promise.all(n.map((a) => a.then((h) => h, (h) => {
8512
+ i || (i = h);
8513
+ })));
8514
+ if (typeof i < "u") throw i;
8515
+ return s;
8516
+ }
8517
+ t.settled = r;
8518
+ function e(n) {
8519
+ return new Promise(async (i, s) => {
8520
+ try {
8521
+ await n(i, s);
8522
+ } catch (a) {
8523
+ s(a);
8524
+ }
8525
+ });
8526
+ }
8527
+ t.withAsyncBody = e;
8528
+ })(qt ||= {});
8529
+ P = class P {
8530
+ static fromArray(e) {
8531
+ return new P((t) => {
8532
+ t.emitMany(e);
8533
+ });
8534
+ }
8535
+ static fromPromise(e) {
8536
+ return new P(async (t) => {
8537
+ t.emitMany(await e);
8538
+ });
8539
+ }
8540
+ static fromPromises(e) {
8541
+ return new P(async (t) => {
8542
+ await Promise.all(e.map(async (n) => t.emitOne(await n)));
8543
+ });
8544
+ }
8545
+ static merge(e) {
8546
+ return new P(async (t) => {
8547
+ await Promise.all(e.map(async (n) => {
8548
+ for await (let i of n) t.emitOne(i);
8549
+ }));
8550
+ });
8551
+ }
8552
+ constructor(e, t) {
8553
+ this._state = 0, this._results = [], this._error = null, this._onReturn = t, this._onStateChanged = new C(), queueMicrotask(async () => {
8554
+ let n = {
8555
+ emitOne: (i) => this.emitOne(i),
8556
+ emitMany: (i) => this.emitMany(i),
8557
+ reject: (i) => this.reject(i)
8558
+ };
8559
+ try {
8560
+ await Promise.resolve(e(n)), this.resolve();
8561
+ } catch (i) {
8562
+ this.reject(i);
8563
+ } finally {
8564
+ n.emitOne = void 0, n.emitMany = void 0, n.reject = void 0;
8565
+ }
8566
+ });
8567
+ }
8568
+ [Symbol.asyncIterator]() {
8569
+ let e = 0;
8570
+ return {
8571
+ next: async () => {
8572
+ do {
8573
+ if (this._state === 2) throw this._error;
8574
+ if (e < this._results.length) return {
8575
+ done: !1,
8576
+ value: this._results[e++]
8577
+ };
8578
+ if (this._state === 1) return {
8579
+ done: !0,
8580
+ value: void 0
8581
+ };
8582
+ await ie.toPromise(this._onStateChanged.event);
8583
+ } while (!0);
8584
+ },
8585
+ return: async () => (this._onReturn?.(), {
8586
+ done: !0,
8587
+ value: void 0
8588
+ })
8589
+ };
8590
+ }
8591
+ static map(e, t) {
8592
+ return new P(async (n) => {
8593
+ for await (let i of e) n.emitOne(t(i));
8594
+ });
8595
+ }
8596
+ map(e) {
8597
+ return P.map(this, e);
8598
+ }
8599
+ static filter(e, t) {
8600
+ return new P(async (n) => {
8601
+ for await (let i of e) t(i) && n.emitOne(i);
8602
+ });
8603
+ }
8604
+ filter(e) {
8605
+ return P.filter(this, e);
8606
+ }
8607
+ static coalesce(e) {
8608
+ return P.filter(e, (t) => !!t);
8609
+ }
8610
+ coalesce() {
8611
+ return P.coalesce(this);
8612
+ }
8613
+ static async toPromise(e) {
8614
+ let t = [];
8615
+ for await (let n of e) t.push(n);
8616
+ return t;
8617
+ }
8618
+ toPromise() {
8619
+ return P.toPromise(this);
8620
+ }
8621
+ emitOne(e) {
8622
+ this._state === 0 && (this._results.push(e), this._onStateChanged.fire());
8623
+ }
8624
+ emitMany(e) {
8625
+ this._state === 0 && (this._results = this._results.concat(e), this._onStateChanged.fire());
8626
+ }
8627
+ resolve() {
8628
+ this._state === 0 && (this._state = 1, this._onStateChanged.fire());
8629
+ }
8630
+ reject(e) {
8631
+ this._state === 0 && (this._state = 2, this._error = e, this._onStateChanged.fire());
8632
+ }
8633
+ };
8634
+ P.EMPTY = P.fromArray([]);
8635
+ Ie = class extends k {
8636
+ constructor(t) {
8637
+ super();
8638
+ this._terminal = t;
8639
+ this._linesCacheTimeout = this._register(new F());
8640
+ this._linesCacheDisposables = this._register(new F());
8641
+ this._register(A(() => this._destroyLinesCache()));
8642
+ }
8643
+ initLinesCache() {
8644
+ this._linesCache || (this._linesCache = new Array(this._terminal.buffer.active.length), this._linesCacheDisposables.value = me(this._terminal.onLineFeed(() => this._destroyLinesCache()), this._terminal.onCursorMove(() => this._destroyLinesCache()), this._terminal.onResize(() => this._destroyLinesCache()))), this._linesCacheTimeout.value = xe(() => this._destroyLinesCache(), 15e3);
8645
+ }
8646
+ _destroyLinesCache() {
8647
+ this._linesCache = void 0, this._linesCacheDisposables.clear(), this._linesCacheTimeout.clear();
8648
+ }
8649
+ getLineFromCache(t) {
8650
+ return this._linesCache?.[t];
8651
+ }
8652
+ setLineInCache(t, n) {
8653
+ this._linesCache && (this._linesCache[t] = n);
8654
+ }
8655
+ translateBufferLineToStringWithWrap(t, n) {
8656
+ let i = [], s = [0], a = this._terminal.buffer.active.getLine(t);
8657
+ for (; a;) {
8658
+ let h = this._terminal.buffer.active.getLine(t + 1), u = h ? h.isWrapped : !1, p = a.translateToString(!u && n);
8659
+ if (u && h) {
8660
+ let T = a.getCell(a.length - 1);
8661
+ T && T.getCode() === 0 && T.getWidth() === 1 && h.getCell(0)?.getWidth() === 2 && (p = p.slice(0, -1));
8662
+ }
8663
+ if (i.push(p), u) s.push(s[s.length - 1] + p.length);
8664
+ else break;
8665
+ t++, a = h;
8666
+ }
8667
+ return [i.join(""), s];
8668
+ }
8669
+ };
8670
+ De = class {
8671
+ get cachedSearchTerm() {
8672
+ return this._cachedSearchTerm;
8673
+ }
8674
+ set cachedSearchTerm(e) {
8675
+ this._cachedSearchTerm = e;
8676
+ }
8677
+ get lastSearchOptions() {
8678
+ return this._lastSearchOptions;
8679
+ }
8680
+ set lastSearchOptions(e) {
8681
+ this._lastSearchOptions = e;
8682
+ }
8683
+ isValidSearchTerm(e) {
8684
+ return !!(e && e.length > 0);
8685
+ }
8686
+ didOptionsChange(e) {
8687
+ return this._lastSearchOptions ? e ? this._lastSearchOptions.caseSensitive !== e.caseSensitive || this._lastSearchOptions.regex !== e.regex || this._lastSearchOptions.wholeWord !== e.wholeWord : !1 : !0;
8688
+ }
8689
+ shouldUpdateHighlighting(e, t) {
8690
+ return t?.decorations ? this._cachedSearchTerm === void 0 || e !== this._cachedSearchTerm || this.didOptionsChange(t) : !1;
8691
+ }
8692
+ clearCachedTerm() {
8693
+ this._cachedSearchTerm = void 0;
8694
+ }
8695
+ reset() {
8696
+ this._cachedSearchTerm = void 0, this._lastSearchOptions = void 0;
8697
+ }
8698
+ };
8699
+ Ee = class {
8700
+ constructor(e, t) {
8701
+ this._terminal = e;
8702
+ this._lineCache = t;
8703
+ }
8704
+ find(e, t, n, i) {
8705
+ if (!e || e.length === 0) {
8706
+ this._terminal.clearSelection();
8707
+ return;
8708
+ }
8709
+ if (n > this._terminal.cols) throw new Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);
8710
+ this._lineCache.initLinesCache();
8711
+ let s = {
8712
+ startRow: t,
8713
+ startCol: n
8714
+ }, a = this._findInLine(e, s, i);
8715
+ if (!a) for (let h = t + 1; h < this._terminal.buffer.active.baseY + this._terminal.rows && (s.startRow = h, s.startCol = 0, a = this._findInLine(e, s, i), !a); h++);
8716
+ return a;
8717
+ }
8718
+ findNextWithSelection(e, t, n) {
8719
+ if (!e || e.length === 0) {
8720
+ this._terminal.clearSelection();
8721
+ return;
8722
+ }
8723
+ let i = this._terminal.getSelectionPosition();
8724
+ this._terminal.clearSelection();
8725
+ let s = 0, a = 0;
8726
+ i && (n === e ? (s = i.end.x, a = i.end.y) : (s = i.start.x, a = i.start.y)), this._lineCache.initLinesCache();
8727
+ let h = {
8728
+ startRow: a,
8729
+ startCol: s
8730
+ }, u = this._findInLine(e, h, t);
8731
+ if (!u) for (let p = a + 1; p < this._terminal.buffer.active.baseY + this._terminal.rows && (h.startRow = p, h.startCol = 0, u = this._findInLine(e, h, t), !u); p++);
8732
+ if (!u && a !== 0) for (let p = 0; p < a && (h.startRow = p, h.startCol = 0, u = this._findInLine(e, h, t), !u); p++);
8733
+ return !u && i && (h.startRow = i.start.y, h.startCol = 0, u = this._findInLine(e, h, t)), u;
8734
+ }
8735
+ findPreviousWithSelection(e, t, n) {
8736
+ if (!e || e.length === 0) {
8737
+ this._terminal.clearSelection();
8738
+ return;
8739
+ }
8740
+ let i = this._terminal.getSelectionPosition();
8741
+ this._terminal.clearSelection();
8742
+ let s = this._terminal.buffer.active.baseY + this._terminal.rows - 1, a = this._terminal.cols, h = !0;
8743
+ this._lineCache.initLinesCache();
8744
+ let u = {
8745
+ startRow: s,
8746
+ startCol: a
8747
+ }, p;
8748
+ if (i && (u.startRow = s = i.start.y, u.startCol = a = i.start.x, n !== e && (p = this._findInLine(e, u, t, !1), p || (u.startRow = s = i.end.y, u.startCol = a = i.end.x))), p || (p = this._findInLine(e, u, t, h)), !p) {
8749
+ u.startCol = Math.max(u.startCol, this._terminal.cols);
8750
+ for (let T = s - 1; T >= 0 && (u.startRow = T, p = this._findInLine(e, u, t, h), !p); T--);
8751
+ }
8752
+ if (!p && s !== this._terminal.buffer.active.baseY + this._terminal.rows - 1) for (let T = this._terminal.buffer.active.baseY + this._terminal.rows - 1; T >= s && (u.startRow = T, p = this._findInLine(e, u, t, h), !p); T--);
8753
+ return p;
8754
+ }
8755
+ _isWholeWord(e, t, n) {
8756
+ return (e === 0 || " ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e - 1])) && (e + n.length === t.length || " ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e + n.length]));
8757
+ }
8758
+ _findInLine(e, t, n = {}, i = !1) {
8759
+ let s = t.startRow, a = t.startCol;
8760
+ if (this._terminal.buffer.active.getLine(s)?.isWrapped) {
8761
+ if (i) {
8762
+ t.startCol += this._terminal.cols;
8763
+ return;
8764
+ }
8765
+ return t.startRow--, t.startCol += this._terminal.cols, this._findInLine(e, t, n);
8766
+ }
8767
+ let u = this._lineCache.getLineFromCache(s);
8768
+ u || (u = this._lineCache.translateBufferLineToStringWithWrap(s, !0), this._lineCache.setLineInCache(s, u));
8769
+ let [p, T] = u, v = this._bufferColsToStringOffset(s, a), I = e, E = p;
8770
+ n.regex || (I = n.caseSensitive ? e : e.toLowerCase(), E = n.caseSensitive ? p : p.toLowerCase());
8771
+ let S = -1;
8772
+ if (n.regex) {
8773
+ let D = RegExp(I, n.caseSensitive ? "g" : "gi"), x;
8774
+ if (i) for (; x = D.exec(E.slice(0, v));) S = D.lastIndex - x[0].length, e = x[0], D.lastIndex -= e.length - 1;
8775
+ else x = D.exec(E.slice(v)), x && x[0].length > 0 && (S = v + (D.lastIndex - x[0].length), e = x[0]);
8776
+ } else i ? v - I.length >= 0 && (S = E.lastIndexOf(I, v - I.length)) : S = E.indexOf(I, v);
8777
+ if (S >= 0) {
8778
+ if (n.wholeWord && !this._isWholeWord(S, E, e)) return;
8779
+ let D = 0;
8780
+ for (; D < T.length - 1 && S >= T[D + 1];) D++;
8781
+ let x = D;
8782
+ for (; x < T.length - 1 && S + e.length >= T[x + 1];) x++;
8783
+ let J = S - T[D], q = S + e.length - T[x], z = this._stringLengthToBufferSize(s + D, J), _ = this._stringLengthToBufferSize(s + x, q) - z + this._terminal.cols * (x - D);
8784
+ return {
8785
+ term: e,
8786
+ col: z,
8787
+ row: s + D,
8788
+ size: _
8789
+ };
8790
+ }
8791
+ }
8792
+ _stringLengthToBufferSize(e, t) {
8793
+ let n = this._terminal.buffer.active.getLine(e);
8794
+ if (!n) return 0;
8795
+ for (let i = 0; i < t; i++) {
8796
+ let s = n.getCell(i);
8797
+ if (!s) break;
8798
+ let a = s.getChars();
8799
+ a.length > 1 && (t -= a.length - 1);
8800
+ let h = n.getCell(i + 1);
8801
+ h && h.getWidth() === 0 && t++;
8802
+ }
8803
+ return t;
8804
+ }
8805
+ _bufferColsToStringOffset(e, t) {
8806
+ let n = e, i = 0, s = this._terminal.buffer.active.getLine(n);
8807
+ for (; t > 0 && s;) {
8808
+ for (let a = 0; a < t && a < this._terminal.cols; a++) {
8809
+ let h = s.getCell(a);
8810
+ if (!h) break;
8811
+ h.getWidth() && (i += h.getCode() === 0 ? 1 : h.getChars().length);
8812
+ }
8813
+ if (n++, s = this._terminal.buffer.active.getLine(n), s && !s.isWrapped) break;
8814
+ t -= this._terminal.cols;
8815
+ }
8816
+ return i;
8817
+ }
8818
+ };
8819
+ we = class extends k {
8820
+ constructor(t) {
8821
+ super();
8822
+ this._terminal = t;
8823
+ this._highlightDecorations = [];
8824
+ this._highlightedLines = /* @__PURE__ */ new Set();
8825
+ this._register(A(() => this.clearHighlightDecorations()));
8826
+ }
8827
+ createHighlightDecorations(t, n) {
8828
+ this.clearHighlightDecorations();
8829
+ for (let i of t) {
8830
+ let s = this._createResultDecorations(i, n, !1);
8831
+ if (s) for (let a of s) this._storeDecoration(a, i);
8832
+ }
8833
+ }
8834
+ createActiveDecoration(t, n) {
8835
+ let i = this._createResultDecorations(t, n, !0);
8836
+ if (i) return {
8837
+ decorations: i,
8838
+ match: t,
8839
+ dispose() {
8840
+ Q(i);
8841
+ }
8842
+ };
8843
+ }
8844
+ clearHighlightDecorations() {
8845
+ Q(this._highlightDecorations), this._highlightDecorations = [], this._highlightedLines.clear();
8846
+ }
8847
+ _storeDecoration(t, n) {
8848
+ this._highlightedLines.add(t.marker.line), this._highlightDecorations.push({
8849
+ decoration: t,
8850
+ match: n,
8851
+ dispose() {
8852
+ t.dispose();
8853
+ }
8854
+ });
8855
+ }
8856
+ _applyStyles(t, n, i) {
8857
+ t.classList.contains("xterm-find-result-decoration") || (t.classList.add("xterm-find-result-decoration"), n && (t.style.outline = `1px solid ${n}`)), i && t.classList.add("xterm-find-active-result-decoration");
8858
+ }
8859
+ _createResultDecorations(t, n, i) {
8860
+ let s = [], a = t.col, h = t.size, u = -this._terminal.buffer.active.baseY - this._terminal.buffer.active.cursorY + t.row;
8861
+ for (; h > 0;) {
8862
+ let T = Math.min(this._terminal.cols - a, h);
8863
+ s.push([
8864
+ u,
8865
+ a,
8866
+ T
8867
+ ]), a = 0, h -= T, u++;
8868
+ }
8869
+ let p = [];
8870
+ for (let T of s) {
8871
+ let v = this._terminal.registerMarker(T[0]), I = this._terminal.registerDecoration({
8872
+ marker: v,
8873
+ x: T[1],
8874
+ width: T[2],
8875
+ backgroundColor: i ? n.activeMatchBackground : n.matchBackground,
8876
+ overviewRulerOptions: this._highlightedLines.has(v.line) ? void 0 : {
8877
+ color: i ? n.activeMatchColorOverviewRuler : n.matchOverviewRuler,
8878
+ position: "center"
8879
+ }
8880
+ });
8881
+ if (I) {
8882
+ let E = [];
8883
+ E.push(v), E.push(I.onRender((S) => this._applyStyles(S, i ? n.activeMatchBorder : n.matchBorder, !1))), E.push(I.onDispose(() => Q(E))), p.push(I);
8884
+ }
8885
+ }
8886
+ return p.length === 0 ? void 0 : p;
8887
+ }
8888
+ };
8889
+ ke = class extends k {
8890
+ constructor() {
8891
+ super(...arguments);
8892
+ this._searchResults = [];
8893
+ this._onDidChangeResults = this._register(new C());
8894
+ }
8895
+ get onDidChangeResults() {
8896
+ return this._onDidChangeResults.event;
8897
+ }
8898
+ get searchResults() {
8899
+ return this._searchResults;
8900
+ }
8901
+ get selectedDecoration() {
8902
+ return this._selectedDecoration;
8903
+ }
8904
+ set selectedDecoration(t) {
8905
+ this._selectedDecoration = t;
8906
+ }
8907
+ updateResults(t, n) {
8908
+ this._searchResults = t.slice(0, n);
8909
+ }
8910
+ clearResults() {
8911
+ this._searchResults = [];
8912
+ }
8913
+ clearSelectedDecoration() {
8914
+ this._selectedDecoration && (this._selectedDecoration.dispose(), this._selectedDecoration = void 0);
8915
+ }
8916
+ findResultIndex(t) {
8917
+ for (let n = 0; n < this._searchResults.length; n++) {
8918
+ let i = this._searchResults[n];
8919
+ if (i.row === t.row && i.col === t.col && i.size === t.size) return n;
8920
+ }
8921
+ return -1;
8922
+ }
8923
+ fireResultsChanged(t) {
8924
+ if (!t) return;
8925
+ let n = -1;
8926
+ this._selectedDecoration && (n = this.findResultIndex(this._selectedDecoration.match)), this._onDidChangeResults.fire({
8927
+ resultIndex: n,
8928
+ resultCount: this._searchResults.length
8929
+ });
8930
+ }
8931
+ reset() {
8932
+ this.clearSelectedDecoration(), this.clearResults();
8933
+ }
8934
+ };
8935
+ ut = class extends k {
8936
+ constructor(t) {
8937
+ super();
8938
+ this._highlightTimeout = this._register(new F());
8939
+ this._lineCache = this._register(new F());
8940
+ this._state = new De();
8941
+ this._resultTracker = this._register(new ke());
8942
+ this._highlightLimit = t?.highlightLimit ?? 1e3;
8943
+ }
8944
+ get onDidChangeResults() {
8945
+ return this._resultTracker.onDidChangeResults;
8946
+ }
8947
+ activate(t) {
8948
+ this._terminal = t, this._lineCache.value = new Ie(t), this._engine = new Ee(t, this._lineCache.value), this._decorationManager = new we(t), this._register(this._terminal.onWriteParsed(() => this._updateMatches())), this._register(this._terminal.onResize(() => this._updateMatches())), this._register(A(() => this.clearDecorations()));
8949
+ }
8950
+ _updateMatches() {
8951
+ this._highlightTimeout.clear(), this._state.cachedSearchTerm && this._state.lastSearchOptions?.decorations && (this._highlightTimeout.value = xe(() => {
8952
+ let t = this._state.cachedSearchTerm;
8953
+ this._state.clearCachedTerm(), this.findPrevious(t, {
8954
+ ...this._state.lastSearchOptions,
8955
+ incremental: !0
8956
+ }, { noScroll: !0 });
8957
+ }, 200));
8958
+ }
8959
+ clearDecorations(t) {
8960
+ this._resultTracker.clearSelectedDecoration(), this._decorationManager?.clearHighlightDecorations(), this._resultTracker.clearResults(), t || this._state.clearCachedTerm();
8961
+ }
8962
+ clearActiveDecoration() {
8963
+ this._resultTracker.clearSelectedDecoration();
8964
+ }
8965
+ findNext(t, n, i) {
8966
+ if (!this._terminal || !this._engine) throw new Error("Cannot use addon until it has been loaded");
8967
+ this._state.lastSearchOptions = n, this._state.shouldUpdateHighlighting(t, n) && this._highlightAllMatches(t, n);
8968
+ let s = this._findNextAndSelect(t, n, i);
8969
+ return this._fireResults(n), this._state.cachedSearchTerm = t, s;
8970
+ }
8971
+ _highlightAllMatches(t, n) {
8972
+ if (!this._terminal || !this._engine || !this._decorationManager) throw new Error("Cannot use addon until it has been loaded");
8973
+ if (!this._state.isValidSearchTerm(t)) {
8974
+ this.clearDecorations();
8975
+ return;
8976
+ }
8977
+ this.clearDecorations(!0);
8978
+ let i = [], s, a = this._engine.find(t, 0, 0, n);
8979
+ for (; a && (s?.row !== a.row || s?.col !== a.col) && !(i.length >= this._highlightLimit);) s = a, i.push(s), a = this._engine.find(t, s.col + s.term.length >= this._terminal.cols ? s.row + 1 : s.row, s.col + s.term.length >= this._terminal.cols ? 0 : s.col + 1, n);
8980
+ this._resultTracker.updateResults(i, this._highlightLimit), n.decorations && this._decorationManager.createHighlightDecorations(i, n.decorations);
8981
+ }
8982
+ _findNextAndSelect(t, n, i) {
8983
+ if (!this._terminal || !this._engine) return !1;
8984
+ if (!this._state.isValidSearchTerm(t)) return this._terminal.clearSelection(), this.clearDecorations(), !1;
8985
+ let s = this._engine.findNextWithSelection(t, n, this._state.cachedSearchTerm);
8986
+ return this._selectResult(s, n?.decorations, i?.noScroll);
8987
+ }
8988
+ findPrevious(t, n, i) {
8989
+ if (!this._terminal || !this._engine) throw new Error("Cannot use addon until it has been loaded");
8990
+ this._state.lastSearchOptions = n, this._state.shouldUpdateHighlighting(t, n) && this._highlightAllMatches(t, n);
8991
+ let s = this._findPreviousAndSelect(t, n, i);
8992
+ return this._fireResults(n), this._state.cachedSearchTerm = t, s;
8993
+ }
8994
+ _fireResults(t) {
8995
+ this._resultTracker.fireResultsChanged(!!t?.decorations);
8996
+ }
8997
+ _findPreviousAndSelect(t, n, i) {
8998
+ if (!this._terminal || !this._engine) return !1;
8999
+ if (!this._state.isValidSearchTerm(t)) return this._terminal.clearSelection(), this.clearDecorations(), !1;
9000
+ let s = this._engine.findPreviousWithSelection(t, n, this._state.cachedSearchTerm);
9001
+ return this._selectResult(s, n?.decorations, i?.noScroll);
9002
+ }
9003
+ _selectResult(t, n, i) {
9004
+ if (!this._terminal || !this._decorationManager) return !1;
9005
+ if (this._resultTracker.clearSelectedDecoration(), !t) return this._terminal.clearSelection(), !1;
9006
+ if (this._terminal.select(t.col, t.row, t.size), n) {
9007
+ let s = this._decorationManager.createActiveDecoration(t, n);
9008
+ s && (this._resultTracker.selectedDecoration = s);
9009
+ }
9010
+ if (!i && (t.row >= this._terminal.buffer.active.viewportY + this._terminal.rows || t.row < this._terminal.buffer.active.viewportY)) {
9011
+ let s = t.row - this._terminal.buffer.active.viewportY;
9012
+ s -= Math.floor(this._terminal.rows / 2), this._terminal.scrollLines(s);
9013
+ }
9014
+ return !0;
9015
+ }
9016
+ };
9017
+ }));
9018
+ export { require_addon_fit as a, require_addon_web_links as i, ut as n, require_xterm as o, init_xterm as r, init_addon_search as t };