@profullstack/threatcrush 0.13.13 → 0.13.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5328,7 +5328,7 @@ var require_toml = __commonJS({
5328
5328
  }
5329
5329
  });
5330
5330
 
5331
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/color.js
5331
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/color.js
5332
5332
  function rgb(r, g, b) {
5333
5333
  return RGB_FLAG | (r & 255) << 16 | (g & 255) << 8 | b & 255;
5334
5334
  }
@@ -5439,7 +5439,7 @@ function grayscale(c) {
5439
5439
  }
5440
5440
  var DEFAULT_COLOR, RGB_FLAG, IDX_FLAG, CUBE, BASE16;
5441
5441
  var init_color = __esm({
5442
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/color.js"() {
5442
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/color.js"() {
5443
5443
  "use strict";
5444
5444
  DEFAULT_COLOR = 0;
5445
5445
  RGB_FLAG = 16777216;
@@ -5466,7 +5466,7 @@ var init_color = __esm({
5466
5466
  }
5467
5467
  });
5468
5468
 
5469
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/unicode.js
5469
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/unicode.js
5470
5470
  function isLoneSurrogate(cp) {
5471
5471
  return cp >= 55296 && cp <= 57343;
5472
5472
  }
@@ -5491,6 +5491,8 @@ function internCluster(text) {
5491
5491
  return existing;
5492
5492
  if (clusters.length >= MAX_CLUSTERS) {
5493
5493
  const first = safe.codePointAt(0) ?? 32;
5494
+ if (clusterWidth(safe) === 2 && charWidth(first) !== 2)
5495
+ return 12288;
5494
5496
  return charWidth(first) > 0 ? first : 32;
5495
5497
  }
5496
5498
  const id = CLUSTER_BASE + clusters.length;
@@ -5536,14 +5538,26 @@ function charWidth(cp) {
5536
5538
  return 2;
5537
5539
  return 1;
5538
5540
  }
5541
+ function clusterWidth(text) {
5542
+ const first = text.codePointAt(0) ?? 32;
5543
+ const base = charWidth(first);
5544
+ if (base === 2)
5545
+ return 2;
5546
+ if (isRegional(first)) {
5547
+ const second = text.codePointAt(2);
5548
+ return second !== void 0 && isRegional(second) ? 2 : 1;
5549
+ }
5550
+ if (isKeycapBase(first) && text.includes("\u20E3"))
5551
+ return 2;
5552
+ if (inRanges(first, PICTOGRAPHIC) && (text.includes("\uFE0F") || /[\u{1f3fb}-\u{1f3ff}]/u.test(text)))
5553
+ return 2;
5554
+ return 1;
5555
+ }
5539
5556
  function cellWidth(value) {
5540
5557
  if (value === CONTINUATION)
5541
5558
  return 0;
5542
- if (value >= CLUSTER_BASE) {
5543
- const t = clusterText(value);
5544
- const first = t.codePointAt(0) ?? 32;
5545
- return charWidth(first) === 2 ? 2 : 1;
5546
- }
5559
+ if (value >= CLUSTER_BASE)
5560
+ return clusterWidth(clusterText(value));
5547
5561
  return charWidth(value);
5548
5562
  }
5549
5563
  function graphemes(text) {
@@ -5583,6 +5597,15 @@ function graphemes(text) {
5583
5597
  parts += 2;
5584
5598
  continue;
5585
5599
  }
5600
+ const pictographicBase = inRanges(cp, PICTOGRAPHIC);
5601
+ const joins = pictographicBase && (isToneModifier(next) || isTag(next)) || isRegional(cp) && isRegional(next) && size === 2 && !cluster;
5602
+ if (joins) {
5603
+ cluster = cluster || text.slice(i, i + size);
5604
+ cluster += text.slice(i + size, i + size + nsize);
5605
+ size += nsize;
5606
+ parts += 1;
5607
+ continue;
5608
+ }
5586
5609
  if (charWidth(next) !== 0)
5587
5610
  break;
5588
5611
  if (isUnsafeCodepoint(next))
@@ -5594,7 +5617,8 @@ function graphemes(text) {
5594
5617
  }
5595
5618
  if (width === 0) {
5596
5619
  } else if (cluster) {
5597
- out.push({ value: internCluster(cluster), width });
5620
+ const value = internCluster(cluster);
5621
+ out.push({ value, width: cellWidth(value) });
5598
5622
  } else {
5599
5623
  out.push({ value: cp, width });
5600
5624
  }
@@ -5691,9 +5715,9 @@ function wrap(text, width) {
5691
5715
  }
5692
5716
  return lines;
5693
5717
  }
5694
- var CLUSTER_BASE, CONTINUATION, clusters, clusterIds, REPLACEMENT, UNSAFE, MAX_CLUSTER_CODEPOINTS, MAX_CLUSTERS, ZERO_WIDTH, WIDE, PICTOGRAPHIC, ZWJ;
5718
+ var CLUSTER_BASE, CONTINUATION, clusters, clusterIds, REPLACEMENT, UNSAFE, MAX_CLUSTER_CODEPOINTS, MAX_CLUSTERS, ZERO_WIDTH, WIDE, PICTOGRAPHIC, isRegional, isToneModifier, isTag, isKeycapBase, ZWJ;
5695
5719
  var init_unicode = __esm({
5696
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/unicode.js"() {
5720
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/unicode.js"() {
5697
5721
  "use strict";
5698
5722
  CLUSTER_BASE = 1114112;
5699
5723
  CONTINUATION = 4294967295;
@@ -5796,14 +5820,18 @@ var init_unicode = __esm({
5796
5820
  [126976, 129791],
5797
5821
  [130048, 131069]
5798
5822
  ];
5823
+ isRegional = (cp) => cp >= 127462 && cp <= 127487;
5824
+ isToneModifier = (cp) => cp >= 127995 && cp <= 127999;
5825
+ isTag = (cp) => cp >= 917536 && cp <= 917631;
5826
+ isKeycapBase = (cp) => cp >= 48 && cp <= 57 || cp === 35 || cp === 42;
5799
5827
  ZWJ = 8205;
5800
5828
  }
5801
5829
  });
5802
5830
 
5803
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/buffer.js
5831
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/buffer.js
5804
5832
  var Attr, FrameBuffer;
5805
5833
  var init_buffer = __esm({
5806
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/buffer.js"() {
5834
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/buffer.js"() {
5807
5835
  "use strict";
5808
5836
  init_color();
5809
5837
  init_unicode();
@@ -5992,7 +6020,7 @@ var init_buffer = __esm({
5992
6020
  }
5993
6021
  });
5994
6022
 
5995
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/ansi.js
6023
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/ansi.js
5996
6024
  function moveTo(x, y) {
5997
6025
  return `${CSI}${y + 1};${x + 1}H`;
5998
6026
  }
@@ -6033,9 +6061,17 @@ function fg16(i) {
6033
6061
  function bg16(i) {
6034
6062
  return i < 8 ? `${CSI}${40 + i}m` : `${CSI}${100 + i - 8}m`;
6035
6063
  }
6036
- var ESC, CSI, ansi, fgDefault, bgDefault;
6064
+ function stripAnsi(text) {
6065
+ const stripped = text.replace(
6066
+ // eslint-disable-next-line no-control-regex
6067
+ /(?:\x1b\[|\x9b)[0-9;?<=>]*[ -/]*[@-~]|(?:\x1b\]|\x9d)[\s\S]*?(?:\x07|\x1b\\|\x9c|$)|(?:\x1bP|\x90)[\s\S]*?(?:\x1b\\|\x9c|$)|\x1b[@-Z\\-_]/g,
6068
+ ""
6069
+ );
6070
+ return stripped.replace(TEXT_UNSAFE, "");
6071
+ }
6072
+ var ESC, CSI, ansi, fgDefault, bgDefault, TEXT_UNSAFE;
6037
6073
  var init_ansi = __esm({
6038
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/ansi.js"() {
6074
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/ansi.js"() {
6039
6075
  "use strict";
6040
6076
  init_unicode();
6041
6077
  ESC = "\x1B";
@@ -6067,10 +6103,11 @@ var init_ansi = __esm({
6067
6103
  };
6068
6104
  fgDefault = `${CSI}39m`;
6069
6105
  bgDefault = `${CSI}49m`;
6106
+ TEXT_UNSAFE = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/gu;
6070
6107
  }
6071
6108
  });
6072
6109
 
6073
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/diff.js
6110
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/diff.js
6074
6111
  function encodeRows(buffer, options = {}) {
6075
6112
  const encoder = new Encoder({ ...options, origin: { x: 0, y: 0 }, relative: false });
6076
6113
  const width = buffer.width;
@@ -6091,7 +6128,7 @@ function encodeRows(buffer, options = {}) {
6091
6128
  }
6092
6129
  var GAP_MERGE, Encoder;
6093
6130
  var init_diff = __esm({
6094
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/diff.js"() {
6131
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/diff.js"() {
6095
6132
  "use strict";
6096
6133
  init_buffer();
6097
6134
  init_buffer();
@@ -6302,7 +6339,7 @@ var init_diff = __esm({
6302
6339
  }
6303
6340
  });
6304
6341
 
6305
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/capabilities.js
6342
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/capabilities.js
6306
6343
  function detectProgram(env2) {
6307
6344
  if (env2.KITTY_WINDOW_ID || env2.TERM === "xterm-kitty")
6308
6345
  return "kitty";
@@ -6399,12 +6436,12 @@ function detectCapabilities(overrides = {}, env2 = process.env, stream = process
6399
6436
  };
6400
6437
  }
6401
6438
  var init_capabilities = __esm({
6402
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/capabilities.js"() {
6439
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/capabilities.js"() {
6403
6440
  "use strict";
6404
6441
  }
6405
6442
  });
6406
6443
 
6407
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/input.js
6444
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/input.js
6408
6445
  function decodeModifiers(param) {
6409
6446
  const bits = Math.max(0, param - 1);
6410
6447
  return { shift: (bits & 1) !== 0, alt: (bits & 2) !== 0, ctrl: (bits & 4) !== 0 };
@@ -6440,7 +6477,7 @@ function matchKey(event, binding) {
6440
6477
  }
6441
6478
  var SPECIAL, PASTE_END, InputParser, SPECIAL_KEYS_SORTED;
6442
6479
  var init_input = __esm({
6443
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/input.js"() {
6480
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/input.js"() {
6444
6481
  "use strict";
6445
6482
  SPECIAL = {
6446
6483
  "[A": "up",
@@ -6683,7 +6720,7 @@ var init_input = __esm({
6683
6720
  }
6684
6721
  });
6685
6722
 
6686
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/terminal.js
6723
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/terminal.js
6687
6724
  function anchor() {
6688
6725
  return ansi.reset + ansi.cursorSave;
6689
6726
  }
@@ -6692,7 +6729,7 @@ function toAnchor() {
6692
6729
  }
6693
6730
  var Terminal;
6694
6731
  var init_terminal = __esm({
6695
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/terminal.js"() {
6732
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/terminal.js"() {
6696
6733
  "use strict";
6697
6734
  init_ansi();
6698
6735
  init_capabilities();
@@ -6978,7 +7015,7 @@ var init_terminal = __esm({
6978
7015
  }
6979
7016
  });
6980
7017
 
6981
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/theme.js
7018
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/theme.js
6982
7019
  function variant(base, overrides) {
6983
7020
  return { ...base, ...overrides };
6984
7021
  }
@@ -7007,7 +7044,7 @@ function seriesColor(theme, index) {
7007
7044
  }
7008
7045
  var DARK, DRACULA, NORD, TOKYO_NIGHT, GRUVBOX, MATRIX, MONOCHROME, HIGH_CONTRAST, LIGHT, themes, themeList;
7009
7046
  var init_theme = __esm({
7010
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/theme.js"() {
7047
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/theme.js"() {
7011
7048
  "use strict";
7012
7049
  init_color();
7013
7050
  DARK = {
@@ -7218,7 +7255,7 @@ var init_theme = __esm({
7218
7255
  }
7219
7256
  });
7220
7257
 
7221
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/layout.js
7258
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/layout.js
7222
7259
  function parse(c, total) {
7223
7260
  const min = c.min ?? 0;
7224
7261
  const max = c.max ?? Infinity;
@@ -7392,12 +7429,12 @@ function isEmpty(rect) {
7392
7429
  return rect.width <= 0 || rect.height <= 0;
7393
7430
  }
7394
7431
  var init_layout = __esm({
7395
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/layout.js"() {
7432
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/layout.js"() {
7396
7433
  "use strict";
7397
7434
  }
7398
7435
  });
7399
7436
 
7400
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/richtext.js
7437
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/richtext.js
7401
7438
  function isRich(value) {
7402
7439
  return typeof value !== "string";
7403
7440
  }
@@ -7602,14 +7639,14 @@ function wrapRich(value, width) {
7602
7639
  return out;
7603
7640
  }
7604
7641
  var init_richtext = __esm({
7605
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/richtext.js"() {
7642
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/richtext.js"() {
7606
7643
  "use strict";
7607
7644
  init_buffer();
7608
7645
  init_unicode();
7609
7646
  }
7610
7647
  });
7611
7648
 
7612
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/surface.js
7649
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/surface.js
7613
7650
  function borderGlyph(style, bits) {
7614
7651
  const chars = BORDERS[style];
7615
7652
  for (const [part, value] of Object.entries(PART_BITS)) {
@@ -7648,7 +7685,7 @@ function createSurface(buffer, theme, rect) {
7648
7685
  }
7649
7686
  var BORDERS, EDGE_UP, EDGE_RIGHT, EDGE_DOWN, EDGE_LEFT, PART_BITS, BITS_BY_CODEPOINT, Surface;
7650
7687
  var init_surface = __esm({
7651
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/surface.js"() {
7688
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/surface.js"() {
7652
7689
  "use strict";
7653
7690
  init_layout();
7654
7691
  init_unicode();
@@ -7913,17 +7950,18 @@ var init_surface = __esm({
7913
7950
  if (sides.right)
7914
7951
  putV(w - 1, 1, h - 2, b.v);
7915
7952
  }
7953
+ const headerWidth = Math.max(0, w - Math.max(0, options.titleRightPadding ?? 0));
7916
7954
  const subtitle = options.subtitle ? ` ${options.subtitle} ` : "";
7917
- const subtitleWidth = subtitle && stringWidth(subtitle) + 4 < w ? stringWidth(subtitle) : 0;
7955
+ const subtitleWidth = subtitle && stringWidth(subtitle) + 4 < headerWidth ? stringWidth(subtitle) : 0;
7918
7956
  if (options.title && sides.top) {
7919
7957
  const titleColor = options.titleColor ?? this.theme.title;
7920
7958
  const label = ` ${options.title} `;
7921
- const limit = subtitleWidth > 0 ? w - 1 - subtitleWidth : w - 2;
7959
+ const limit = subtitleWidth > 0 ? headerWidth - 1 - subtitleWidth : headerWidth - 2;
7922
7960
  const room = Math.max(0, limit - 2);
7923
7961
  const shown = truncate(label, room);
7924
7962
  const tw = stringWidth(shown);
7925
7963
  const align = options.titleAlign ?? "left";
7926
- const tx = align === "left" ? 2 : align === "right" ? Math.max(2, limit - tw) : Math.max(2, Math.min(limit - tw, Math.floor((w - tw) / 2)));
7964
+ const tx = align === "left" ? 2 : align === "right" ? Math.max(2, limit - tw) : Math.max(2, Math.min(limit - tw, Math.floor((headerWidth - tw) / 2)));
7927
7965
  this.text(tx, 0, shown, {
7928
7966
  fg: titleColor,
7929
7967
  bg,
@@ -7932,7 +7970,7 @@ var init_surface = __esm({
7932
7970
  });
7933
7971
  }
7934
7972
  if (subtitleWidth > 0 && sides.top) {
7935
- this.text(w - 2 - subtitleWidth, 0, subtitle, {
7973
+ this.text(headerWidth - 2 - subtitleWidth, 0, subtitle, {
7936
7974
  fg: options.subtitleColor ?? this.theme.muted,
7937
7975
  bg
7938
7976
  });
@@ -7958,13 +7996,13 @@ var init_surface = __esm({
7958
7996
  }
7959
7997
  });
7960
7998
 
7961
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/braille.js
7999
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/braille.js
7962
8000
  function snap(v) {
7963
8001
  return Math.round(v + (v >= 0 ? 1e-9 : -1e-9));
7964
8002
  }
7965
8003
  var BRAILLE_BASE, DOT_BITS, BrailleCanvas;
7966
8004
  var init_braille = __esm({
7967
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/braille.js"() {
8005
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/braille.js"() {
7968
8006
  "use strict";
7969
8007
  BRAILLE_BASE = 10240;
7970
8008
  DOT_BITS = [
@@ -8218,7 +8256,7 @@ var init_braille = __esm({
8218
8256
  }
8219
8257
  });
8220
8258
 
8221
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/blocks.js
8259
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/blocks.js
8222
8260
  function verticalGlyph(ratio2, mode = "block") {
8223
8261
  const r = ratio2 <= 0 ? 0 : ratio2 >= 1 ? 1 : ratio2;
8224
8262
  if (mode === "ascii")
@@ -8237,14 +8275,14 @@ function horizontalGlyph(ratio2, mode = "block") {
8237
8275
  }
8238
8276
  var HORIZONTAL_EIGHTHS, VERTICAL_EIGHTHS;
8239
8277
  var init_blocks = __esm({
8240
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/blocks.js"() {
8278
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/blocks.js"() {
8241
8279
  "use strict";
8242
8280
  HORIZONTAL_EIGHTHS = ["", "\u258F", "\u258E", "\u258D", "\u258C", "\u258B", "\u258A", "\u2589", "\u2588"];
8243
8281
  VERTICAL_EIGHTHS = ["", "\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
8244
8282
  }
8245
8283
  });
8246
8284
 
8247
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/plot.js
8285
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/plot.js
8248
8286
  function bound(value) {
8249
8287
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
8250
8288
  }
@@ -8533,7 +8571,7 @@ function donut(surface, options) {
8533
8571
  blit(surface, canvas, (col, row) => colorFor.get(`${col},${row}`) ?? theme.muted, options.background);
8534
8572
  }
8535
8573
  var init_plot = __esm({
8536
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/plot.js"() {
8574
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/plot.js"() {
8537
8575
  "use strict";
8538
8576
  init_color();
8539
8577
  init_braille();
@@ -8542,7 +8580,7 @@ var init_plot = __esm({
8542
8580
  }
8543
8581
  });
8544
8582
 
8545
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/canvas.js
8583
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/canvas.js
8546
8584
  function span(bounds) {
8547
8585
  if (!bounds)
8548
8586
  return UNIT;
@@ -8638,7 +8676,7 @@ function drawCanvas(surface, options) {
8638
8676
  }
8639
8677
  var UNIT;
8640
8678
  var init_canvas = __esm({
8641
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/canvas.js"() {
8679
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/canvas.js"() {
8642
8680
  "use strict";
8643
8681
  init_color();
8644
8682
  init_braille();
@@ -8647,7 +8685,7 @@ var init_canvas = __esm({
8647
8685
  }
8648
8686
  });
8649
8687
 
8650
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/text.js
8688
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/text.js
8651
8689
  function attrsOf(o) {
8652
8690
  let a = o.attrs ?? 0;
8653
8691
  if (o.bold)
@@ -8776,7 +8814,7 @@ function drawStatusBar(surface, options) {
8776
8814
  return spans;
8777
8815
  }
8778
8816
  var init_text = __esm({
8779
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/text.js"() {
8817
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/text.js"() {
8780
8818
  "use strict";
8781
8819
  init_buffer();
8782
8820
  init_color();
@@ -8786,7 +8824,7 @@ var init_text = __esm({
8786
8824
  }
8787
8825
  });
8788
8826
 
8789
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/calendar.js
8827
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/calendar.js
8790
8828
  function daysInMonth(year, month) {
8791
8829
  if (month === 2)
8792
8830
  return isLeapYear(year) ? 29 : 28;
@@ -8866,7 +8904,7 @@ function calendarHeight(options) {
8866
8904
  }
8867
8905
  var MONTH_NAMES, WEEKDAY_NAMES, DAY_WIDTH, GRID_WIDTH;
8868
8906
  var init_calendar = __esm({
8869
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/calendar.js"() {
8907
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/calendar.js"() {
8870
8908
  "use strict";
8871
8909
  init_buffer();
8872
8910
  init_unicode();
@@ -8890,7 +8928,7 @@ var init_calendar = __esm({
8890
8928
  }
8891
8929
  });
8892
8930
 
8893
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/chart.js
8931
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/chart.js
8894
8932
  function bound2(value) {
8895
8933
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
8896
8934
  }
@@ -9090,7 +9128,7 @@ function plotCells(surface, series, o) {
9090
9128
  });
9091
9129
  }
9092
9130
  var init_chart = __esm({
9093
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/chart.js"() {
9131
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/chart.js"() {
9094
9132
  "use strict";
9095
9133
  init_color();
9096
9134
  init_braille();
@@ -9100,7 +9138,7 @@ var init_chart = __esm({
9100
9138
  }
9101
9139
  });
9102
9140
 
9103
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/chart.js
9141
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/chart.js
9104
9142
  function niceLabel(value) {
9105
9143
  if (!Number.isFinite(value))
9106
9144
  return "";
@@ -9162,7 +9200,7 @@ function drawChart(surface, options) {
9162
9200
  }
9163
9201
  }
9164
9202
  var init_chart2 = __esm({
9165
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/chart.js"() {
9203
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/chart.js"() {
9166
9204
  "use strict";
9167
9205
  init_unicode();
9168
9206
  init_theme();
@@ -9170,14 +9208,14 @@ var init_chart2 = __esm({
9170
9208
  }
9171
9209
  });
9172
9210
 
9173
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/shadow.js
9211
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/shadow.js
9174
9212
  var init_shadow = __esm({
9175
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/shadow.js"() {
9213
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/shadow.js"() {
9176
9214
  "use strict";
9177
9215
  }
9178
9216
  });
9179
9217
 
9180
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/surface.js
9218
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/surface.js
9181
9219
  function drawClear(surface, options = {}) {
9182
9220
  if (surface.empty)
9183
9221
  return;
@@ -9201,16 +9239,16 @@ function drawFill(surface, options = {}) {
9201
9239
  }
9202
9240
  }
9203
9241
  var init_surface2 = __esm({
9204
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/surface.js"() {
9242
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/surface.js"() {
9205
9243
  "use strict";
9206
9244
  init_unicode();
9207
9245
  }
9208
9246
  });
9209
9247
 
9210
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/world-data.js
9248
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/world-data.js
9211
9249
  var WORLD_COUNTRIES;
9212
9250
  var init_world_data = __esm({
9213
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/world-data.js"() {
9251
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/world-data.js"() {
9214
9252
  "use strict";
9215
9253
  WORLD_COUNTRIES = [
9216
9254
  {
@@ -10501,7 +10539,7 @@ var init_world_data = __esm({
10501
10539
  }
10502
10540
  });
10503
10541
 
10504
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/world.js
10542
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/world.js
10505
10543
  function matches(country, keys) {
10506
10544
  for (const key of keys) {
10507
10545
  if (key.length === 0)
@@ -10566,7 +10604,7 @@ function degreesAt(column, row, width, height, x = WORLD_X, y = WORLD_Y) {
10566
10604
  }
10567
10605
  var WORLD_X, WORLD_Y;
10568
10606
  var init_world = __esm({
10569
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/graphics/world.js"() {
10607
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/graphics/world.js"() {
10570
10608
  "use strict";
10571
10609
  init_world_data();
10572
10610
  WORLD_X = { min: -180, max: 180 };
@@ -10574,7 +10612,7 @@ var init_world = __esm({
10574
10612
  }
10575
10613
  });
10576
10614
 
10577
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/world.js
10615
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/world.js
10578
10616
  function drawWorldMap(surface, options = {}) {
10579
10617
  if (surface.empty)
10580
10618
  return;
@@ -10598,14 +10636,14 @@ function countryAtCell(column, row, width, height, options = {}) {
10598
10636
  return countryAt(at.lon, at.lat);
10599
10637
  }
10600
10638
  var init_world2 = __esm({
10601
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/world.js"() {
10639
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/world.js"() {
10602
10640
  "use strict";
10603
10641
  init_canvas();
10604
10642
  init_world();
10605
10643
  }
10606
10644
  });
10607
10645
 
10608
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/scrollbar.js
10646
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/scrollbar.js
10609
10647
  function isVertical(orientation) {
10610
10648
  return orientation === "right" || orientation === "left";
10611
10649
  }
@@ -10661,13 +10699,13 @@ function offsetForPosition(position, track, total, viewport) {
10661
10699
  return Math.round(at / usable2 * (total - visible));
10662
10700
  }
10663
10701
  var init_scrollbar = __esm({
10664
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/scrollbar.js"() {
10702
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/scrollbar.js"() {
10665
10703
  "use strict";
10666
10704
  init_color();
10667
10705
  }
10668
10706
  });
10669
10707
 
10670
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/table.js
10708
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/table.js
10671
10709
  function cellValue(row, column, index) {
10672
10710
  if (column.render)
10673
10711
  return column.render(row, index);
@@ -10726,7 +10764,8 @@ function drawTable(surface, options) {
10726
10764
  break;
10727
10765
  const y = i + headerRows;
10728
10766
  const selected = options.selected === rowIndex;
10729
- const rowBg = selected ? theme.selection : options.zebra && rowIndex % 2 === 1 ? zebraBg : options.background;
10767
+ const hovered = !selected && options.hovered === rowIndex;
10768
+ const rowBg = selected ? theme.selection : hovered ? hoverBg(theme) : options.zebra && rowIndex % 2 === 1 ? zebraBg : options.background;
10730
10769
  if (rowBg !== void 0)
10731
10770
  surface.fillRect(0, y, bodyWidth, 1, { bg: rowBg });
10732
10771
  let x = 0;
@@ -10757,6 +10796,9 @@ function drawTable(surface, options) {
10757
10796
  drawScrollbar(surface, surface.width - 1, headerRows, capacity, options.rows.length, offset);
10758
10797
  }
10759
10798
  }
10799
+ function hoverBg(theme) {
10800
+ return elevate(theme, 0.1);
10801
+ }
10760
10802
  function drawList(surface, options) {
10761
10803
  if (surface.empty)
10762
10804
  return;
@@ -10770,13 +10812,15 @@ function drawList(surface, options) {
10770
10812
  break;
10771
10813
  const item = typeof raw === "string" ? { label: raw } : raw;
10772
10814
  const selected = options.selected === index;
10815
+ const hovered = !selected && options.hovered === index;
10773
10816
  const bullet = options.bullet ? `${options.bullet} ` : "";
10774
10817
  const label = `${bullet}${item.label}`;
10775
- if (selected)
10776
- surface.fillRect(0, i, width, 1, { bg: theme.selection });
10818
+ const bg = selected ? theme.selection : hovered ? hoverBg(theme) : options.background;
10819
+ if (selected || hovered)
10820
+ surface.fillRect(0, i, width, 1, { bg });
10777
10821
  surface.text(0, i, fit(truncate(label, width), width), {
10778
10822
  fg: selected ? theme.selectionText : item.color ?? theme.foreground,
10779
- bg: selected ? theme.selection : options.background,
10823
+ bg,
10780
10824
  attrs: selected ? Attr.Bold : 0
10781
10825
  });
10782
10826
  }
@@ -10799,6 +10843,8 @@ function drawTree(surface, options) {
10799
10843
  const theme = surface.theme;
10800
10844
  const flat = [];
10801
10845
  flatten(options.nodes, 0, [], flat);
10846
+ const scrollbar = options.scrollbar ?? false;
10847
+ const width = surface.width - (scrollbar ? 1 : 0);
10802
10848
  const offset = resolveOffset(options.offset, options.selected, surface.height, flat.length, options.followSelection);
10803
10849
  const guides = options.guides !== false;
10804
10850
  const guideColor = options.guideColor ?? mix(theme.border, theme.foreground, 0.15);
@@ -10808,9 +10854,10 @@ function drawTree(surface, options) {
10808
10854
  if (!entry)
10809
10855
  break;
10810
10856
  const selected = options.selected === index;
10811
- const bg = selected ? theme.selection : options.background;
10812
- if (selected)
10813
- surface.fillRect(0, i, surface.width, 1, { bg: theme.selection });
10857
+ const hovered = !selected && options.hovered === index;
10858
+ const bg = selected ? theme.selection : hovered ? hoverBg(theme) : options.background;
10859
+ if (selected || hovered)
10860
+ surface.fillRect(0, i, width, 1, { bg });
10814
10861
  let prefix = "";
10815
10862
  if (guides) {
10816
10863
  for (let d = 0; d < entry.depth; d++)
@@ -10820,7 +10867,7 @@ function drawTree(surface, options) {
10820
10867
  prefix = " ".repeat(entry.depth);
10821
10868
  }
10822
10869
  const valuesWidth = (entry.node.values ?? []).reduce((a, v) => a + v.width + 1, 0);
10823
- const labelWidth = Math.max(0, surface.width - valuesWidth);
10870
+ const labelWidth = Math.max(0, width - valuesWidth);
10824
10871
  surface.text(0, i, truncate(prefix, labelWidth), { fg: guideColor, bg });
10825
10872
  const px = Math.min(stringWidth(prefix), labelWidth);
10826
10873
  surface.text(px, i, truncate(entry.node.label, Math.max(0, labelWidth - px)), {
@@ -10836,6 +10883,10 @@ function drawTree(surface, options) {
10836
10883
  });
10837
10884
  vx += value.width + 1;
10838
10885
  }
10886
+ options.onRow?.(entry.node, index, i);
10887
+ }
10888
+ if (scrollbar && flat.length > surface.height && surface.height > 0) {
10889
+ drawScrollbar(surface, surface.width - 1, 0, surface.height, flat.length, offset);
10839
10890
  }
10840
10891
  }
10841
10892
  function drawLog(surface, options) {
@@ -10885,7 +10936,7 @@ function drawLog(surface, options) {
10885
10936
  }
10886
10937
  }
10887
10938
  var init_table = __esm({
10888
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/table.js"() {
10939
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/table.js"() {
10889
10940
  "use strict";
10890
10941
  init_buffer();
10891
10942
  init_color();
@@ -10896,7 +10947,7 @@ var init_table = __esm({
10896
10947
  }
10897
10948
  });
10898
10949
 
10899
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/meters.js
10950
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/meters.js
10900
10951
  function clampRatio(value) {
10901
10952
  return value > 1 ? 1 : value > 0 ? value : 0;
10902
10953
  }
@@ -11089,7 +11140,7 @@ function drawColumns(surface, options) {
11089
11140
  }
11090
11141
  }
11091
11142
  var init_meters = __esm({
11092
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/meters.js"() {
11143
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/meters.js"() {
11093
11144
  "use strict";
11094
11145
  init_buffer();
11095
11146
  init_color();
@@ -11100,7 +11151,7 @@ var init_meters = __esm({
11100
11151
  }
11101
11152
  });
11102
11153
 
11103
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/controls.js
11154
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/controls.js
11104
11155
  function variantColor(surface, options) {
11105
11156
  const t = surface.theme;
11106
11157
  if (options.color)
@@ -11233,6 +11284,7 @@ function drawModal(root, options) {
11233
11284
  const surface = root.sub(x, y, width, height);
11234
11285
  const inner = surface.box({
11235
11286
  title: options.title,
11287
+ titleRightPadding: options.titleRightPadding,
11236
11288
  titleAlign: options.align ?? "center",
11237
11289
  border: "rounded",
11238
11290
  borderColor: options.color ?? theme.borderFocused,
@@ -11318,7 +11370,7 @@ function drawTooltip(root, options) {
11318
11370
  inner.text(0, 0, truncate(options.text, inner.width), { fg: theme.foreground });
11319
11371
  }
11320
11372
  var init_controls = __esm({
11321
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/controls.js"() {
11373
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/controls.js"() {
11322
11374
  "use strict";
11323
11375
  init_buffer();
11324
11376
  init_color();
@@ -11327,9 +11379,64 @@ var init_controls = __esm({
11327
11379
  }
11328
11380
  });
11329
11381
 
11330
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/index.js
11382
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/spinner.js
11383
+ function spinnerFrame(elapsed, frames, interval = 80) {
11384
+ if (frames.length === 0)
11385
+ return "";
11386
+ const step = Math.max(1, interval);
11387
+ return frames[Math.floor(Math.max(0, elapsed) / step) % frames.length] ?? "";
11388
+ }
11389
+ function drawSpinner(surface, options) {
11390
+ if (surface.empty)
11391
+ return 0;
11392
+ const theme = surface.theme;
11393
+ const named = typeof options.frames === "string" ? SPINNER_FRAMES[options.frames] : options.frames;
11394
+ const frames = named ?? SPINNER_FRAMES.dots;
11395
+ const active = options.active ?? true;
11396
+ const glyph = active ? spinnerFrame(options.elapsed, frames, options.interval) : options.doneGlyph ?? "\u2713";
11397
+ const color = options.color ?? (active ? theme.accent : theme.success);
11398
+ const labelColor = options.labelColor ?? theme.foreground;
11399
+ const bg = options.background;
11400
+ const glyphWidth = stringWidth(glyph);
11401
+ const width = surface.width;
11402
+ const labelRoom = Math.max(0, width - glyphWidth - 1);
11403
+ const label = options.label && labelRoom > 0 ? truncate(options.label, labelRoom) : "";
11404
+ const labelWidth = label ? 1 + stringWidth(label) : 0;
11405
+ const leftWidth = glyphWidth + labelWidth;
11406
+ const readWidth = options.text ? stringWidth(options.text) : 0;
11407
+ const readout = readWidth > 0 && leftWidth + 1 + readWidth <= width ? options.text : "";
11408
+ const total = Math.min(width, readout ? leftWidth + 1 + readWidth : leftWidth);
11409
+ const x0 = options.align === "right" ? width - total : options.align === "center" ? Math.floor((width - total) / 2) : 0;
11410
+ const x = Math.max(0, x0);
11411
+ if (bg !== void 0)
11412
+ surface.fill({ bg });
11413
+ surface.text(x, 0, glyph, { fg: color, bg, attrs: Attr.Bold });
11414
+ if (label)
11415
+ surface.text(x + glyphWidth + 1, 0, label, { fg: labelColor, bg });
11416
+ if (readout) {
11417
+ const rx = options.align === "center" ? x + leftWidth + 1 : width - readWidth;
11418
+ surface.text(rx, 0, readout, { fg: theme.muted, bg });
11419
+ }
11420
+ return total;
11421
+ }
11422
+ var SPINNER_FRAMES;
11423
+ var init_spinner = __esm({
11424
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/spinner.js"() {
11425
+ "use strict";
11426
+ init_buffer();
11427
+ init_unicode();
11428
+ SPINNER_FRAMES = {
11429
+ dots: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
11430
+ arc: ["\u25DC", "\u25E0", "\u25DD", "\u25DE", "\u25E1", "\u25DF"],
11431
+ line: ["\u2500", "\u2572", "\u2502", "\u2571"],
11432
+ ascii: ["|", "/", "-", "\\"]
11433
+ };
11434
+ }
11435
+ });
11436
+
11437
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/index.js
11331
11438
  var init_widgets = __esm({
11332
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/widgets/index.js"() {
11439
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/widgets/index.js"() {
11333
11440
  "use strict";
11334
11441
  init_text();
11335
11442
  init_calendar();
@@ -11341,10 +11448,75 @@ var init_widgets = __esm({
11341
11448
  init_table();
11342
11449
  init_meters();
11343
11450
  init_controls();
11451
+ init_spinner();
11452
+ }
11453
+ });
11454
+
11455
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/markdown.js
11456
+ function markdownText(value) {
11457
+ return stripAnsi(value).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, "").replace(/([\\`*_{}\[\]<>#|!])/g, "\\$1");
11458
+ }
11459
+ function clipboardSequence(text, tmux = false) {
11460
+ const payload = Buffer.from(text, "utf8").toString("base64");
11461
+ if (payload.length > 1e5)
11462
+ throw new RangeError("Markdown exceeds the terminal clipboard limit.");
11463
+ const sequence = `\x1B]52;c;${payload}\x07`;
11464
+ return tmux ? `\x1BPtmux;${sequence.replace(/\x1b/g, "\x1B\x1B")}\x1B\\` : sequence;
11465
+ }
11466
+ var MarkdownSummary;
11467
+ var init_markdown = __esm({
11468
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/markdown.js"() {
11469
+ "use strict";
11470
+ init_ansi();
11471
+ init_richtext();
11472
+ MarkdownSummary = class _MarkdownSummary {
11473
+ blocks = [];
11474
+ add(block) {
11475
+ this.blocks.push(block);
11476
+ }
11477
+ child() {
11478
+ const child = new _MarkdownSummary();
11479
+ this.add(() => child.body());
11480
+ return child;
11481
+ }
11482
+ text(value) {
11483
+ this.add(markdownText(toSpanLines(value).map((line) => line.map((s) => s.text).join("")).join("\n")));
11484
+ }
11485
+ values(rows) {
11486
+ this.add(rows.filter((row) => row.label || row.value).map(({ label, value }) => {
11487
+ const key = markdownText(label.replace(/:\s*$/, "")).replace(/\s*\n\s*/g, " ");
11488
+ const content = markdownText(value).replace(/\n/g, "\n ");
11489
+ return key ? `- **${key}:** ${content}` : `- ${content}`;
11490
+ }).join("\n"));
11491
+ }
11492
+ series(values, label = "Series", format = String) {
11493
+ const finite = values.filter(Number.isFinite);
11494
+ if (!finite.length) {
11495
+ this.values([{ label, value: "No samples" }]);
11496
+ return;
11497
+ }
11498
+ const latest = values.at(-1);
11499
+ const min = finite.reduce((a, b) => Math.min(a, b), Infinity);
11500
+ const max = finite.reduce((a, b) => Math.max(a, b), -Infinity);
11501
+ this.values([{ label, value: `Latest: ${latest !== void 0 && Number.isFinite(latest) ? format(latest) : "unavailable"}; min: ${format(min)}; max: ${format(max)}; ${finite.length} samples` }]);
11502
+ }
11503
+ body() {
11504
+ return this.blocks.map((block) => typeof block === "function" ? block() : block).filter((block) => block.trim()).join("\n\n");
11505
+ }
11506
+ document(title, subtitle, context, footer2) {
11507
+ return [
11508
+ `## ${markdownText(title || "Summary").replace(/\s*\n\s*/g, " ")}`,
11509
+ context ? markdownText(context) : "",
11510
+ subtitle ? markdownText(subtitle) : "",
11511
+ this.body(),
11512
+ footer2 ? markdownText(footer2) : ""
11513
+ ].filter(Boolean).join("\n\n") + "\n";
11514
+ }
11515
+ };
11344
11516
  }
11345
11517
  });
11346
11518
 
11347
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/ui.js
11519
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/ui.js
11348
11520
  function dispatchHit(regions, event) {
11349
11521
  for (let i = regions.length - 1; i >= 0; i--) {
11350
11522
  const hit = regions[i];
@@ -11374,7 +11546,7 @@ function countClicks(previous, press) {
11374
11546
  }
11375
11547
  var DOUBLE_CLICK_MS, Container, GridContainer;
11376
11548
  var init_ui = __esm({
11377
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/ui.js"() {
11549
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/ui.js"() {
11378
11550
  "use strict";
11379
11551
  init_layout();
11380
11552
  init_unicode();
@@ -11382,8 +11554,11 @@ var init_ui = __esm({
11382
11554
  init_braille();
11383
11555
  init_canvas();
11384
11556
  init_widgets();
11557
+ init_markdown();
11558
+ init_surface();
11385
11559
  DOUBLE_CLICK_MS = 400;
11386
11560
  Container = class _Container {
11561
+ summary;
11387
11562
  surface;
11388
11563
  ctx;
11389
11564
  direction;
@@ -11391,7 +11566,8 @@ var init_ui = __esm({
11391
11566
  gap;
11392
11567
  justify;
11393
11568
  inner;
11394
- constructor(surface, ctx, direction = "column", options = {}) {
11569
+ constructor(surface, ctx, direction = "column", options = {}, summary) {
11570
+ this.summary = summary;
11395
11571
  this.surface = surface;
11396
11572
  this.ctx = ctx;
11397
11573
  this.direction = direction;
@@ -11469,16 +11645,18 @@ var init_ui = __esm({
11469
11645
  // ---------------------------------------------------------------- layout
11470
11646
  /** A horizontal container. Children default to equal shares. */
11471
11647
  row(options = {}, build) {
11648
+ const summary = this.summary?.child();
11472
11649
  return this.add((surface) => {
11473
- const container = new _Container(surface, this.ctx, "row", options);
11650
+ const container = new _Container(surface, this.ctx, "row", options, summary);
11474
11651
  build?.(container);
11475
11652
  container.flush();
11476
11653
  }, this.sizeOf(options, "fill"), options.bordered ?? false);
11477
11654
  }
11478
11655
  /** A vertical container. */
11479
11656
  column(options = {}, build) {
11657
+ const summary = this.summary?.child();
11480
11658
  return this.add((surface) => {
11481
- const container = new _Container(surface, this.ctx, "column", options);
11659
+ const container = new _Container(surface, this.ctx, "column", options, summary);
11482
11660
  build?.(container);
11483
11661
  container.flush();
11484
11662
  }, this.sizeOf(options, "fill"), options.bordered ?? false);
@@ -11492,8 +11670,9 @@ var init_ui = __esm({
11492
11670
  * });
11493
11671
  */
11494
11672
  grid(options = {}, build) {
11673
+ const summary = this.summary?.child();
11495
11674
  return this.add((surface) => {
11496
- const container = new GridContainer(surface, this.ctx, options);
11675
+ const container = new GridContainer(surface, this.ctx, options, summary);
11497
11676
  build?.(container);
11498
11677
  container.flush();
11499
11678
  }, this.sizeOf(options, "fill"), options.bordered ?? false);
@@ -11501,18 +11680,25 @@ var init_ui = __esm({
11501
11680
  /** A bordered panel. The callback receives its interior as a column. */
11502
11681
  panel(options = {}, build) {
11503
11682
  const focus = options.focusable ? this.ctx.registerFocus() : void 0;
11683
+ const copy = options.copyMarkdown ?? this.ctx.copyMarkdown ?? false;
11684
+ const summary = options.copyMarkdown !== false && (copy || this.summary) ? new MarkdownSummary() : void 0;
11685
+ if (summary)
11686
+ this.summary?.add(() => summary.body() ? summary.document(options.title, options.subtitle, void 0, options.footer) : "");
11504
11687
  return this.add((surface) => {
11505
11688
  if (options.onClick) {
11506
11689
  const onClick = options.onClick;
11507
11690
  this.ctx.hit({ rect: surface.hitRect(), onClick: (x, y, button, clicks = 1) => onClick(x, y, button, clicks) });
11508
11691
  }
11509
11692
  const focused = options.focused ?? focus?.focused ?? false;
11693
+ const canCopy = copy !== false && !!this.ctx.copyText && surface.width >= 9 && (options.border ?? "rounded") !== "none" && resolveSides(options.sides).top;
11694
+ const copyWidth = surface.width >= 18 ? 6 : 3;
11510
11695
  const boxOptions = {
11511
11696
  title: options.title,
11512
11697
  titleAlign: options.titleAlign,
11513
11698
  titleColor: options.titleColor,
11514
11699
  subtitle: options.subtitle,
11515
11700
  subtitleColor: options.subtitleColor,
11701
+ titleRightPadding: canCopy ? copyWidth + 2 : 0,
11516
11702
  footer: options.footer,
11517
11703
  border: options.border ?? "rounded",
11518
11704
  ...options.sides === void 0 ? {} : { sides: options.sides },
@@ -11524,9 +11710,22 @@ var init_ui = __esm({
11524
11710
  const container = new _Container(interior, this.ctx, "column", {
11525
11711
  gap: options.gap,
11526
11712
  padding: options.padding ?? [0, 1]
11527
- });
11713
+ }, summary);
11528
11714
  build?.(container);
11529
11715
  container.flush();
11716
+ if (canCopy && (copy !== true || summary?.body())) {
11717
+ const action = () => this.ctx.copyText?.(() => typeof copy === "function" ? copy() : typeof copy === "string" ? copy : summary.document(options.title, options.subtitle, this.ctx.markdownContext, options.footer));
11718
+ const copyFocus = this.ctx.registerFocus(action, true);
11719
+ const target = surface.sub(surface.width - copyWidth - 2, 0, copyWidth, 1);
11720
+ const glyph = this.ctx.capabilities.unicode ? "\u29C9" : "C";
11721
+ drawButton(target, { label: copyWidth === 6 ? `${glyph} MD` : glyph, variant: "ghost", focused: copyFocus.focused });
11722
+ this.ctx.hit({ rect: target.hitRect(), onClick: (_x, _y, button) => {
11723
+ if (button === "left")
11724
+ action();
11725
+ } });
11726
+ } else if (canCopy) {
11727
+ surface.box({ ...boxOptions, titleRightPadding: 0, fill: false });
11728
+ }
11530
11729
  }, this.sizeOf(options, "fill"), (options.border ?? "rounded") !== "none");
11531
11730
  }
11532
11731
  /** A panel without a border — a grouping box that costs no rows. */
@@ -11553,6 +11752,7 @@ var init_ui = __esm({
11553
11752
  * paragraph reserves the rows it will actually occupy once wrapped.
11554
11753
  */
11555
11754
  text(content, options = {}) {
11755
+ this.summary?.text(content);
11556
11756
  const lines = isRich(content) ? (options.wrap ? wrapRich(content, this.crossWidth) : toSpanLines(content)).length : options.wrap ? wrap(content, this.crossWidth).length : content.split("\n").length;
11557
11757
  return this.add((s) => drawText(s, content, options), this.sizeOf(options, "auto", lines));
11558
11758
  }
@@ -11565,10 +11765,30 @@ var init_ui = __esm({
11565
11765
  return this.text(content, { fg: this.theme.title, bold: true, ...options });
11566
11766
  }
11567
11767
  badge(options) {
11768
+ this.summary?.text(options.text);
11568
11769
  return this.add((s) => drawBadge(s, options), this.sizeOf(options, "auto", 1));
11569
11770
  }
11771
+ /**
11772
+ * A busy indicator that animates on its own. The frame comes from the app
11773
+ * clock, and while the spinner is active the container asks for another
11774
+ * frame after this one, so the caller never runs a timer. Pass
11775
+ * `active: false` when the work is done and the line settles on a tick.
11776
+ */
11777
+ spinner(options) {
11778
+ if (options.label)
11779
+ this.summary?.values([{ label: "Status", value: options.label }]);
11780
+ const still = this.ctx.reducedMotion;
11781
+ if ((options.active ?? true) && !still)
11782
+ this.ctx.invalidate();
11783
+ const elapsed = still ? 0 : options.elapsed ?? this.ctx.elapsed;
11784
+ const unicode = this.ctx.capabilities.unicode;
11785
+ const frames = options.frames ?? (unicode ? "dots" : "ascii");
11786
+ const doneGlyph = options.doneGlyph ?? (unicode ? "\u2713" : "*");
11787
+ return this.add((s) => drawSpinner(s, { ...options, elapsed, frames, doneGlyph }), this.sizeOf(options, "auto", 1));
11788
+ }
11570
11789
  /** Aligned label/value pairs. */
11571
11790
  keyValues(rows, options = {}) {
11791
+ this.summary?.values(rows);
11572
11792
  return this.add((s) => drawKeyValues(s, { ...options, rows }), this.sizeOf(options, "auto", rows.length));
11573
11793
  }
11574
11794
  // ------------------------------------------------------------------ data
@@ -11624,11 +11844,12 @@ var init_ui = __esm({
11624
11844
  }
11625
11845
  /** Register the widget's rect so the wheel and clicks reach it. */
11626
11846
  attachScroll(surface, handlers, headerRows = 0) {
11627
- if (!handlers.onScroll && !handlers.onSelectRow && !handlers.onActivateRow && !handlers.onFocus)
11847
+ if (!handlers.onScroll && !handlers.onSelectRow && !handlers.onActivateRow && !handlers.onFocus && !handlers.onHoverRow)
11628
11848
  return;
11629
11849
  this.ctx.hit({
11630
11850
  rect: surface.hitRect(),
11631
11851
  onScroll: handlers.onScroll ? (delta) => handlers.onScroll?.(delta) : void 0,
11852
+ onHover: handlers.onHoverRow ? (_x, y) => handlers.onHoverRow?.(y >= headerRows ? y - headerRows : null) : void 0,
11632
11853
  onClick: (_x, y, _button, clicks = 1) => {
11633
11854
  handlers.onFocus?.();
11634
11855
  if (y < headerRows)
@@ -11648,19 +11869,25 @@ var init_ui = __esm({
11648
11869
  // --------------------------------------------------------------- metrics
11649
11870
  /** `label ████████░░░ 42%` */
11650
11871
  meter(options) {
11872
+ this.summary?.values([{ label: options.label ?? "Value", value: options.text ?? `${Math.round((options.max ? options.value / options.max : options.value) * 100)}%` }]);
11651
11873
  return this.add((s) => drawMeter(s, options), this.sizeOfData(options, "auto", "max", 1));
11652
11874
  }
11653
11875
  /** A stack or grid of meters. */
11654
11876
  meters(items, options = {}) {
11877
+ this.summary?.values(items.map((item) => ({ label: item.label ?? "Value", value: item.text ?? `${Math.round((item.max ? item.value / item.max : item.value) * 100)}%` })));
11655
11878
  const columns = Math.max(1, options.columns ?? 1);
11656
11879
  const rows = Math.ceil(items.length / columns);
11657
11880
  return this.add((s) => drawMeters(s, { ...options, items }), this.sizeOf(options, "auto", rows));
11658
11881
  }
11659
11882
  progress(options) {
11883
+ this.summary?.values([{ label: options.label ?? "Progress", value: options.showCount ? `${options.value}/${options.max ?? 1}` : `${Math.round(options.value / (options.max ?? 1) * 100)}%` }]);
11660
11884
  return this.add((s) => drawProgress(s, options), this.sizeOfData(options, "auto", "max", 1));
11661
11885
  }
11662
11886
  /** Braille line/area graph. Fills the space it is given. */
11663
11887
  graph(options) {
11888
+ for (const series of options.series ?? [{ values: options.values ?? [] }]) {
11889
+ this.summary?.series(series.values, series.label, options.axisFormat);
11890
+ }
11664
11891
  return this.add((s) => drawGraph(s, options), this.sizeOfData(options, "fill", "min-max"));
11665
11892
  }
11666
11893
  /**
@@ -11706,6 +11933,10 @@ var init_ui = __esm({
11706
11933
  return this.graph({ ...options, series });
11707
11934
  }
11708
11935
  sparkline(options) {
11936
+ if (options.text)
11937
+ this.summary?.values([{ label: options.label ?? "Value", value: options.text }]);
11938
+ else
11939
+ this.summary?.series(options.values, options.label);
11709
11940
  return this.add((s) => drawSparklineWidget(s, options), this.sizeOfData(options, "auto", "min-max", 1));
11710
11941
  }
11711
11942
  histogram(options) {
@@ -11713,6 +11944,7 @@ var init_ui = __esm({
11713
11944
  }
11714
11945
  /** A semicircular dial. Wants at least 9x5. */
11715
11946
  gauge(options) {
11947
+ this.summary?.values([{ label: "Gauge", value: options.label ?? `${Math.round(options.value * 100)}%` }]);
11716
11948
  return this.add((s) => gauge(s, options), this.sizeOf(options, "fill"));
11717
11949
  }
11718
11950
  donut(options) {
@@ -11723,6 +11955,19 @@ var init_ui = __esm({
11723
11955
  return this.add((s) => drawHeatBar(s, options), this.sizeOf(options, "auto", 1));
11724
11956
  }
11725
11957
  // ---------------------------------------------------------------- inputs
11958
+ /** A compact copy-as-Markdown button for a status strip or custom pane. */
11959
+ copyButton(options) {
11960
+ const action = () => this.ctx.copyText?.(options.markdown);
11961
+ const focus = this.ctx.registerFocus(action, true);
11962
+ const label = options.label ?? (this.ctx.capabilities.unicode ? "\u29C9 MD" : "C MD");
11963
+ return this.add((surface) => {
11964
+ drawButton(surface, { label, focused: focus.focused, variant: "ghost", disabled: !this.ctx.copyText });
11965
+ this.ctx.hit({ rect: surface.hitRect(), onClick: (_x, _y, button) => {
11966
+ if (button === "left")
11967
+ action();
11968
+ } });
11969
+ }, this.sizeOf({ ...options, width: options.width ?? stringWidth(label) + 2 }, "auto", 1));
11970
+ }
11726
11971
  /** A button. Pass `onPress` and it joins the Tab order automatically. */
11727
11972
  button(options) {
11728
11973
  const focus = this.ctx.registerFocus(options.onPress);
@@ -11794,10 +12039,21 @@ var init_ui = __esm({
11794
12039
  }, this.sizeOf(options, "auto", 1));
11795
12040
  }
11796
12041
  // -------------------------------------------------------------- overlays
11797
- /** A centred dialog drawn above everything else this frame. */
12042
+ /** A centred dialog. Tab/arrows move focus; Enter/Space activate; Esc dismisses. */
11798
12043
  modal(options, build) {
11799
12044
  this.ctx.overlay((root) => {
11800
- const inner = drawModal(root, options);
12045
+ const copy = options.copyMarkdown ?? this.ctx.copyMarkdown ?? false;
12046
+ const summary = new MarkdownSummary();
12047
+ if (options.message)
12048
+ summary.text(options.message);
12049
+ const canCopy = copy !== false && !!this.ctx.copyText && Math.min(options.width ?? 60, root.width - 4) >= 18;
12050
+ const buttons = options.buttons?.map((button) => {
12051
+ if (!button.onPress)
12052
+ return button;
12053
+ const focus = this.ctx.registerFocus(button.onPress);
12054
+ return { ...button, focused: button.focused ?? focus.focused };
12055
+ });
12056
+ const inner = drawModal(root, { ...options, buttons, titleRightPadding: canCopy ? 8 : 0 });
11801
12057
  this.ctx.hit({ rect: root.hitRect(), onClick: () => options.onDismiss?.() });
11802
12058
  const interior = inner.hitRect();
11803
12059
  this.ctx.hit({
@@ -11816,11 +12072,21 @@ var init_ui = __esm({
11816
12072
  });
11817
12073
  }
11818
12074
  if (build) {
11819
- const container = new _Container(inner, this.ctx, "column", { padding: [1, 1] });
12075
+ const container = new _Container(inner, this.ctx, "column", { padding: [1, 1] }, summary);
11820
12076
  build(container);
11821
12077
  container.flush();
11822
12078
  }
11823
- });
12079
+ if (canCopy && (copy !== true || summary.body())) {
12080
+ const action = () => this.ctx.copyText?.(() => typeof copy === "function" ? copy() : typeof copy === "string" ? copy : summary.document(options.title, void 0, this.ctx.markdownContext));
12081
+ const focus = this.ctx.registerFocus(action, true);
12082
+ const target = root.region({ x: interior.x + interior.width - 7, y: interior.y - 1, width: 6, height: 1 });
12083
+ drawButton(target, { label: this.ctx.capabilities.unicode ? "\u29C9 MD" : "C MD", variant: "ghost", focused: focus.focused });
12084
+ this.ctx.hit({ rect: target.hitRect(), onClick: (_x, _y, button) => {
12085
+ if (button === "left")
12086
+ action();
12087
+ } });
12088
+ }
12089
+ }, { modal: true, onDismiss: options.onDismiss, onKey: options.onKey });
11824
12090
  return this;
11825
12091
  }
11826
12092
  commandPalette(options) {
@@ -11900,11 +12166,13 @@ var init_ui = __esm({
11900
12166
  }
11901
12167
  };
11902
12168
  GridContainer = class {
12169
+ summary;
11903
12170
  surface;
11904
12171
  ctx;
11905
12172
  options;
11906
12173
  cells = [];
11907
- constructor(surface, ctx, options) {
12174
+ constructor(surface, ctx, options, summary) {
12175
+ this.summary = summary;
11908
12176
  this.surface = options.padding ? surface.inset(options.padding) : surface;
11909
12177
  this.ctx = ctx;
11910
12178
  this.options = options;
@@ -11937,22 +12205,25 @@ var init_ui = __esm({
11937
12205
  }
11938
12206
  /** A panel occupying the next free cell (or several, with colSpan/rowSpan). */
11939
12207
  panel(options = {}, build) {
12208
+ const summary = this.summary?.child();
11940
12209
  return this.push(options, (surface) => {
11941
- const container = new Container(surface, this.ctx, "column");
12210
+ const container = new Container(surface, this.ctx, "column", {}, summary);
11942
12211
  container.panel(options, build);
11943
12212
  container.flush();
11944
12213
  }, (options.border ?? "rounded") !== "none");
11945
12214
  }
11946
12215
  cell(options = {}, build) {
12216
+ const summary = this.summary?.child();
11947
12217
  return this.push(options, (surface) => {
11948
- const container = new Container(surface, this.ctx, "column", options);
12218
+ const container = new Container(surface, this.ctx, "column", options, summary);
11949
12219
  build?.(container);
11950
12220
  container.flush();
11951
12221
  }, options.bordered ?? false);
11952
12222
  }
11953
12223
  row(options = {}, build) {
12224
+ const summary = this.summary?.child();
11954
12225
  return this.push(options, (surface) => {
11955
- const container = new Container(surface, this.ctx, "row", options);
12226
+ const container = new Container(surface, this.ctx, "row", options, summary);
11956
12227
  build?.(container);
11957
12228
  container.flush();
11958
12229
  }, options.bordered ?? false);
@@ -12024,13 +12295,13 @@ var init_ui = __esm({
12024
12295
  }
12025
12296
  });
12026
12297
 
12027
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/app.js
12298
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/app.js
12028
12299
  async function createApp(options = {}) {
12029
12300
  return new App(options);
12030
12301
  }
12031
12302
  var App;
12032
12303
  var init_app = __esm({
12033
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/app.js"() {
12304
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/app.js"() {
12034
12305
  "use strict";
12035
12306
  init_buffer();
12036
12307
  init_diff();
@@ -12040,6 +12311,8 @@ var init_app = __esm({
12040
12311
  init_surface();
12041
12312
  init_ui();
12042
12313
  init_input();
12314
+ init_markdown();
12315
+ init_unicode();
12043
12316
  App = class {
12044
12317
  terminal;
12045
12318
  capabilities;
@@ -12064,8 +12337,14 @@ var init_app = __esm({
12064
12337
  focusIndex = 0;
12065
12338
  focusCount = 0;
12066
12339
  focusActions = [];
12340
+ focusConsumesKey = [];
12341
+ focusEngaged = false;
12342
+ copyNotice = null;
12343
+ copyTimer = null;
12067
12344
  hits = [];
12068
12345
  overlays = [];
12346
+ modal;
12347
+ backgroundFocusIndex = 0;
12069
12348
  lastStats = { frame: 0, renderMs: 0, changedCells: 0, dirtyRows: 0, bytes: 0, fps: 0 };
12070
12349
  constructor(options = {}) {
12071
12350
  this.options = options;
@@ -12092,6 +12371,31 @@ var init_app = __esm({
12092
12371
  get stats() {
12093
12372
  return this.lastStats;
12094
12373
  }
12374
+ /** Copy a user-requested summary. OSC 52 requires terminal clipboard support. */
12375
+ async copyToClipboard(value) {
12376
+ try {
12377
+ const text = typeof value === "function" ? value() : value;
12378
+ if (this.options.clipboard)
12379
+ await this.options.clipboard(text);
12380
+ else {
12381
+ if (!this.capabilities.tty)
12382
+ throw new Error("Clipboard needs an interactive terminal.");
12383
+ this.terminal.write(clipboardSequence(text, !!process.env.TMUX));
12384
+ }
12385
+ this.copyNotice = { text: this.options.clipboard ? "Markdown copied" : "Markdown copy sent", failed: false };
12386
+ } catch (error) {
12387
+ this.copyNotice = { text: `Copy failed: ${error instanceof Error ? error.message : String(error)}`, failed: true };
12388
+ }
12389
+ if (this.copyTimer)
12390
+ clearTimeout(this.copyTimer);
12391
+ this.copyTimer = setTimeout(() => {
12392
+ this.copyNotice = null;
12393
+ this.copyTimer = null;
12394
+ this.invalidate();
12395
+ }, 3e3);
12396
+ this.copyTimer.unref?.();
12397
+ this.invalidate();
12398
+ }
12095
12399
  /** Register the view. Called on every frame; keep it pure and cheap. */
12096
12400
  render(fn) {
12097
12401
  this.renderFn = fn;
@@ -12146,7 +12450,8 @@ var init_app = __esm({
12146
12450
  focusNext(delta = 1) {
12147
12451
  if (this.focusCount === 0)
12148
12452
  return;
12149
- this.focusIndex = (this.focusIndex + delta + this.focusCount) % this.focusCount;
12453
+ this.focusIndex = this.focusConsumesKey.some(Boolean) && !this.focusEngaged && !this.modal ? delta < 0 ? this.focusCount - 1 : 0 : (this.focusIndex + delta + this.focusCount) % this.focusCount;
12454
+ this.focusEngaged = true;
12150
12455
  this.dirty = true;
12151
12456
  }
12152
12457
  /** Activate the focused control, as Enter does. */
@@ -12204,6 +12509,7 @@ var init_app = __esm({
12204
12509
  elapsed: Date.now() - this.startedAt,
12205
12510
  focusIndex: -1,
12206
12511
  collapseBorders: this.options.collapseBorders ?? false,
12512
+ reducedMotion: this.options.reducedMotion ?? false,
12207
12513
  registerFocus: () => ({ index: -1, focused: false }),
12208
12514
  hit: () => {
12209
12515
  },
@@ -12252,6 +12558,10 @@ var init_app = __esm({
12252
12558
  }
12253
12559
  /** Stop the loop and restore the terminal. */
12254
12560
  stop() {
12561
+ if (this.copyTimer)
12562
+ clearTimeout(this.copyTimer);
12563
+ this.copyTimer = null;
12564
+ this.copyNotice = null;
12255
12565
  if (!this.running)
12256
12566
  return;
12257
12567
  this.running = false;
@@ -12279,12 +12589,35 @@ var init_app = __esm({
12279
12589
  return;
12280
12590
  }
12281
12591
  if (this.options.focusNavigation !== false) {
12592
+ if (!this.modal && !["tab", "enter", "space"].includes(event.name))
12593
+ this.focusEngaged = false;
12282
12594
  if (event.name === "tab") {
12283
12595
  this.focusNext(event.shift ? -1 : 1);
12596
+ if (this.modal || this.focusConsumesKey.some(Boolean))
12597
+ return;
12598
+ } else if (this.modal && ["left", "right", "up", "down"].includes(event.name)) {
12599
+ this.focusNext(event.name === "left" || event.name === "up" ? -1 : 1);
12600
+ return;
12284
12601
  } else if (event.name === "enter" || event.name === "space") {
12285
- this.activateFocused();
12602
+ const copyFocused = this.focusConsumesKey[this.focusIndex];
12603
+ const active = !copyFocused || this.focusEngaged || this.modal;
12604
+ const consumed = active && (this.modal || copyFocused) && this.focusActions[this.focusIndex];
12605
+ if (active)
12606
+ this.activateFocused();
12607
+ if (consumed)
12608
+ return;
12286
12609
  }
12287
12610
  }
12611
+ if (this.modal && event.name === "escape" && this.modal.onDismiss) {
12612
+ this.modal.onDismiss();
12613
+ this.dirty = true;
12614
+ return;
12615
+ }
12616
+ if (this.modal?.onKey) {
12617
+ this.modal.onKey(event);
12618
+ this.dirty = true;
12619
+ return;
12620
+ }
12288
12621
  this.emit("key", event);
12289
12622
  this.dirty = true;
12290
12623
  return;
@@ -12313,6 +12646,8 @@ var init_app = __esm({
12313
12646
  return { ...event, clicks };
12314
12647
  }
12315
12648
  dispatchMouse(event) {
12649
+ if (event.action === "press" && !this.modal)
12650
+ this.focusEngaged = false;
12316
12651
  if (dispatchHit(this.hits, event))
12317
12652
  this.dirty = true;
12318
12653
  }
@@ -12331,7 +12666,15 @@ var init_app = __esm({
12331
12666
  this.hits = [];
12332
12667
  this.overlays = [];
12333
12668
  this.focusActions = [];
12669
+ this.focusConsumesKey = [];
12334
12670
  let focusCursor = 0;
12671
+ const wasModal = this.modal !== void 0;
12672
+ const modalFocusIndex = this.focusIndex;
12673
+ if (wasModal)
12674
+ this.focusIndex = this.backgroundFocusIndex;
12675
+ else
12676
+ this.backgroundFocusIndex = this.focusIndex;
12677
+ this.modal = void 0;
12335
12678
  const ctx = {
12336
12679
  theme: this.theme,
12337
12680
  capabilities: this.capabilities,
@@ -12341,14 +12684,21 @@ var init_app = __esm({
12341
12684
  elapsed: Date.now() - this.startedAt,
12342
12685
  focusIndex: this.focusIndex,
12343
12686
  collapseBorders: this.options.collapseBorders ?? false,
12344
- registerFocus: (action) => {
12687
+ reducedMotion: this.options.reducedMotion ?? false,
12688
+ copyMarkdown: this.options.copyMarkdown,
12689
+ markdownContext: typeof this.options.markdownContext === "function" ? this.options.markdownContext() : this.options.markdownContext,
12690
+ copyText: (text) => {
12691
+ void this.copyToClipboard(text);
12692
+ },
12693
+ registerFocus: (action, consumeKey = false) => {
12345
12694
  const index = focusCursor++;
12346
12695
  if (action)
12347
12696
  this.focusActions[index] = action;
12348
- return { index, focused: index === this.focusIndex };
12697
+ this.focusConsumesKey[index] = consumeKey;
12698
+ return { index, focused: index === this.focusIndex && (!consumeKey || this.focusEngaged || !!this.modal) };
12349
12699
  },
12350
12700
  hit: (region) => this.hits.push(region),
12351
- overlay: (draw) => this.overlays.push(draw),
12701
+ overlay: (draw, options) => this.overlays.push({ draw, options }),
12352
12702
  invalidate: () => this.invalidate()
12353
12703
  };
12354
12704
  const root = createSurface(this.current, this.theme);
@@ -12365,11 +12715,29 @@ var init_app = __esm({
12365
12715
  app: this
12366
12716
  });
12367
12717
  container.flush();
12368
- for (const overlay of this.overlays)
12369
- overlay(root);
12718
+ for (const overlay of this.overlays) {
12719
+ if (overlay.options?.modal) {
12720
+ this.focusIndex = wasModal ? modalFocusIndex : 0;
12721
+ ctx.focusIndex = this.focusIndex;
12722
+ focusCursor = 0;
12723
+ this.focusActions = [];
12724
+ this.focusConsumesKey = [];
12725
+ this.modal = overlay.options;
12726
+ }
12727
+ overlay.draw(root);
12728
+ }
12729
+ if (this.copyNotice) {
12730
+ const label = truncate(` ${this.copyNotice.text} `, root.width);
12731
+ root.text(Math.max(0, root.width - stringWidth(label)), root.height - 1, label, {
12732
+ fg: this.copyNotice.failed ? this.theme.danger : this.theme.success,
12733
+ bg: this.theme.surface
12734
+ });
12735
+ }
12370
12736
  this.focusCount = Math.max(focusCursor, 0);
12371
- if (this.focusCount > 0 && this.focusIndex >= this.focusCount)
12737
+ if (this.focusCount > 0 && this.focusIndex >= this.focusCount) {
12372
12738
  this.focusIndex = 0;
12739
+ this.dirty = true;
12740
+ }
12373
12741
  const result = this.encoder.encode(this.previous, this.current, this.forceRepaint);
12374
12742
  this.forceRepaint = false;
12375
12743
  let output = result.output;
@@ -12399,9 +12767,9 @@ var init_app = __esm({
12399
12767
  }
12400
12768
  });
12401
12769
 
12402
- // ../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/index.js
12770
+ // ../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/index.js
12403
12771
  var init_dist = __esm({
12404
- "../../node_modules/.pnpm/@profullstack+hqtui@0.5.0/node_modules/@profullstack/hqtui/dist/index.js"() {
12772
+ "../../node_modules/.pnpm/@profullstack+hqtui@0.7.0/node_modules/@profullstack/hqtui/dist/index.js"() {
12405
12773
  "use strict";
12406
12774
  init_app();
12407
12775
  init_color();
@@ -15907,9 +16275,9 @@ var source_default = chalk;
15907
16275
  // src/index.ts
15908
16276
  var import_readline = __toESM(require("readline"));
15909
16277
  var import_node_child_process15 = require("child_process");
15910
- var import_node_fs35 = require("fs");
16278
+ var import_node_fs36 = require("fs");
15911
16279
  var import_node_path24 = require("path");
15912
- var import_node_os9 = require("os");
16280
+ var import_node_os10 = require("os");
15913
16281
 
15914
16282
  // src/commands/monitor.ts
15915
16283
  var import_node_fs7 = require("fs");
@@ -23535,7 +23903,7 @@ function ansiRegex({ onlyFirst = false } = {}) {
23535
23903
 
23536
23904
  // ../../node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.js
23537
23905
  var regex = ansiRegex();
23538
- function stripAnsi(string) {
23906
+ function stripAnsi2(string) {
23539
23907
  if (typeof string !== "string") {
23540
23908
  throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
23541
23909
  }
@@ -23652,7 +24020,7 @@ function stringWidth2(string, options = {}) {
23652
24020
  countAnsiEscapeCodes = false
23653
24021
  } = options;
23654
24022
  if (!countAnsiEscapeCodes) {
23655
- string = stripAnsi(string);
24023
+ string = stripAnsi2(string);
23656
24024
  }
23657
24025
  if (string.length === 0) {
23658
24026
  return 0;
@@ -23899,7 +24267,7 @@ var Ora = class {
23899
24267
  const fullSuffixText = this.#getFullSuffixText(this.#suffixText, "-");
23900
24268
  const fullText = " ".repeat(this.#indent) + fullPrefixText + "--" + this.#text + "--" + fullSuffixText;
23901
24269
  this.#lineCount = 0;
23902
- for (const line of stripAnsi(fullText).split("\n")) {
24270
+ for (const line of stripAnsi2(fullText).split("\n")) {
23903
24271
  this.#lineCount += Math.max(1, Math.ceil(stringWidth2(line, { countAnsiEscapeCodes: true }) / columns));
23904
24272
  }
23905
24273
  }
@@ -28019,6 +28387,78 @@ function ask(question, opts = {}) {
28019
28387
  return stdinIsInteractive() ? askTerminal(question, mask) : askPiped(question, mask);
28020
28388
  }
28021
28389
 
28390
+ // src/core/link-login.ts
28391
+ var import_node_crypto3 = require("crypto");
28392
+ var import_node_os5 = require("os");
28393
+ function createPkce() {
28394
+ const verifier = (0, import_node_crypto3.randomBytes)(32).toString("base64url");
28395
+ const challenge = (0, import_node_crypto3.createHash)("sha256").update(verifier).digest("base64url");
28396
+ return { verifier, challenge };
28397
+ }
28398
+ async function startLinkLogin(pkce, deviceName = (0, import_node_os5.hostname)()) {
28399
+ const res = await fetch(`${apiUrl()}/api/auth/cli/start`, {
28400
+ method: "POST",
28401
+ headers: { "Content-Type": "application/json" },
28402
+ body: JSON.stringify({
28403
+ code_challenge: pkce.challenge,
28404
+ code_challenge_method: "S256",
28405
+ device_name: deviceName
28406
+ }),
28407
+ signal: AbortSignal.timeout(15e3)
28408
+ });
28409
+ const data = await res.json().catch(() => ({}));
28410
+ if (!res.ok || !data.request_id || !data.verification_url || !data.user_code) {
28411
+ throw new Error(data.error || `Could not start login (${res.status})`);
28412
+ }
28413
+ return data;
28414
+ }
28415
+ var sleep = (ms) => new Promise((resolve5) => setTimeout(resolve5, ms));
28416
+ async function waitForApproval(request, pkce, opts = {}) {
28417
+ const wait = opts.sleepMs ?? sleep;
28418
+ const now = opts.now ?? Date.now;
28419
+ const deadline = Date.parse(request.expires_at) || now() + 10 * 6e4;
28420
+ const intervalMs = Math.max(1, request.interval || 3) * 1e3;
28421
+ while (now() < deadline) {
28422
+ await wait(intervalMs);
28423
+ let res;
28424
+ try {
28425
+ res = await fetch(`${apiUrl()}/api/auth/cli/token`, {
28426
+ method: "POST",
28427
+ headers: { "Content-Type": "application/json" },
28428
+ body: JSON.stringify({ request_id: request.request_id, code_verifier: pkce.verifier }),
28429
+ signal: AbortSignal.timeout(15e3)
28430
+ });
28431
+ } catch {
28432
+ continue;
28433
+ }
28434
+ const data = await res.json().catch(() => ({}));
28435
+ if (res.ok && data.session?.access_token && data.user?.id) {
28436
+ updateCliConfig({
28437
+ email: data.user.email,
28438
+ user_id: data.user.id,
28439
+ token: data.session.access_token,
28440
+ refresh_token: data.session.refresh_token,
28441
+ expires_at: data.session.expires_at
28442
+ });
28443
+ return { ok: true, email: data.user.email || data.user.id, userId: data.user.id };
28444
+ }
28445
+ switch (data.error) {
28446
+ case "authorization_pending":
28447
+ continue;
28448
+ case "access_denied":
28449
+ return { ok: false, error: "The login was denied in the browser." };
28450
+ case "expired_token":
28451
+ return { ok: false, error: "The login link expired before it was approved." };
28452
+ case "invalid_grant":
28453
+ return { ok: false, error: "The login request is no longer valid. Run threatcrush login again." };
28454
+ default:
28455
+ if (res.status === 429 || res.status >= 500) continue;
28456
+ return { ok: false, error: data.error || `Login failed (${res.status})` };
28457
+ }
28458
+ }
28459
+ return { ok: false, error: "The login link expired before it was approved." };
28460
+ }
28461
+
28022
28462
  // src/commands/login.ts
28023
28463
  var API_URL = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
28024
28464
  var INPUT_CLOSED = {
@@ -28073,6 +28513,10 @@ async function loginCommand(opts = {}) {
28073
28513
  `));
28074
28514
  return;
28075
28515
  }
28516
+ if (!opts.password && !opts.email) {
28517
+ await linkLoginCommand();
28518
+ return;
28519
+ }
28076
28520
  console.log(source_default.green(" Log in to threatcrush.com"));
28077
28521
  console.log(source_default.gray(" " + "\u2500".repeat(40)));
28078
28522
  const result = await login({ email: opts.email });
@@ -28090,6 +28534,43 @@ async function loginCommand(opts = {}) {
28090
28534
  \u2713 Logged in as ${source_default.white(result.email)}`));
28091
28535
  console.log(source_default.dim(` Credentials saved to ${CLI_CONFIG_PATH}
28092
28536
  `));
28537
+ await rememberFirstOrg();
28538
+ }
28539
+ async function linkLoginCommand() {
28540
+ const pkce = createPkce();
28541
+ let request;
28542
+ try {
28543
+ request = await startLinkLogin(pkce);
28544
+ } catch (err) {
28545
+ console.log(source_default.red(` \u2717 ${err.message}
28546
+ `));
28547
+ process.exitCode = 1;
28548
+ return;
28549
+ }
28550
+ console.log(source_default.green(" Log in to threatcrush.com"));
28551
+ console.log(source_default.gray(" " + "\u2500".repeat(40)));
28552
+ console.log(` Open this link in a browser where you are signed in:
28553
+ `);
28554
+ console.log(` ${source_default.white.underline(request.verification_url)}
28555
+ `);
28556
+ console.log(` Check it shows this code: ${source_default.green.bold(request.user_code)}
28557
+ `);
28558
+ console.log(source_default.dim(" Waiting for approval\u2026 (Ctrl-C to cancel)"));
28559
+ const result = await waitForApproval(request, pkce);
28560
+ if (!result.ok) {
28561
+ console.log(source_default.red(`
28562
+ \u2717 ${result.error}
28563
+ `));
28564
+ process.exitCode = 1;
28565
+ return;
28566
+ }
28567
+ console.log(source_default.green(`
28568
+ \u2713 Logged in as ${source_default.white(result.email)}`));
28569
+ console.log(source_default.dim(` Credentials saved to ${CLI_CONFIG_PATH}
28570
+ `));
28571
+ await rememberFirstOrg();
28572
+ }
28573
+ async function rememberFirstOrg() {
28093
28574
  try {
28094
28575
  const res = await fetch(`${API_URL}/api/orgs`, { headers: authHeaders() });
28095
28576
  if (res.ok) {
@@ -28617,7 +29098,7 @@ var import_toml3 = __toESM(require_toml());
28617
29098
  init_paths();
28618
29099
 
28619
29100
  // src/daemon/module-trust.ts
28620
- var import_node_crypto3 = require("crypto");
29101
+ var import_node_crypto4 = require("crypto");
28621
29102
  var import_node_fs15 = require("fs");
28622
29103
  var import_node_path12 = require("path");
28623
29104
  init_paths();
@@ -28641,7 +29122,7 @@ function collectFiles(root, dir = root, out = []) {
28641
29122
  return out;
28642
29123
  }
28643
29124
  function computeModuleDigest(modulePath) {
28644
- const hash = (0, import_node_crypto3.createHash)("sha256");
29125
+ const hash = (0, import_node_crypto4.createHash)("sha256");
28645
29126
  for (const entry of collectFiles(modulePath)) {
28646
29127
  const relPath = (0, import_node_path12.relative)(modulePath, entry.path).split(import_node_path12.sep).join("/");
28647
29128
  hash.update(relPath);
@@ -28730,7 +29211,7 @@ function verifyModuleSignature(modulePath, digest) {
28730
29211
  return { ok: false, reason: `mod.sig references unpinned key "${parsed.keyId}"` };
28731
29212
  }
28732
29213
  try {
28733
- const valid = (0, import_node_crypto3.verify)(
29214
+ const valid = (0, import_node_crypto4.verify)(
28734
29215
  null,
28735
29216
  Buffer.from(digest, "hex"),
28736
29217
  publicKey,
@@ -29598,7 +30079,7 @@ function selectProbes(categories = []) {
29598
30079
  }
29599
30080
 
29600
30081
  // src/aiscan/runner.ts
29601
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
30082
+ var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
29602
30083
  async function runAiScan(target, send, opts = {}) {
29603
30084
  const probes = (opts.probes ?? selectProbes(opts.categories)).slice(
29604
30085
  0,
@@ -29618,7 +30099,7 @@ async function runAiScan(target, send, opts = {}) {
29618
30099
  }
29619
30100
  results.push({ probe, vulnerable, response, error });
29620
30101
  opts.onProbe?.(probe, vulnerable);
29621
- if (opts.delayMs && opts.delayMs > 0) await sleep(opts.delayMs);
30102
+ if (opts.delayMs && opts.delayMs > 0) await sleep2(opts.delayMs);
29622
30103
  }
29623
30104
  const findings = results.filter((r) => r.vulnerable).map((r) => ({
29624
30105
  type: r.probe.id,
@@ -29817,11 +30298,11 @@ async function aiScanMoshCommand(file, args) {
29817
30298
  }
29818
30299
 
29819
30300
  // src/commands/orgs.ts
29820
- var import_node_os5 = require("os");
30301
+ var import_node_os6 = require("os");
29821
30302
  var import_node_fs18 = require("fs");
29822
30303
  var import_node_path14 = require("path");
29823
30304
  var API_URL3 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
29824
- var CONFIG_PATH = (0, import_node_path14.join)((0, import_node_os5.homedir)(), ".threatcrush", "config.json");
30305
+ var CONFIG_PATH = (0, import_node_path14.join)((0, import_node_os6.homedir)(), ".threatcrush", "config.json");
29825
30306
  function readConfig() {
29826
30307
  try {
29827
30308
  return JSON.parse((0, import_node_fs18.readFileSync)(CONFIG_PATH, "utf-8"));
@@ -29830,7 +30311,7 @@ function readConfig() {
29830
30311
  }
29831
30312
  }
29832
30313
  function writeConfig(config) {
29833
- const dir = (0, import_node_path14.join)((0, import_node_os5.homedir)(), ".threatcrush");
30314
+ const dir = (0, import_node_path14.join)((0, import_node_os6.homedir)(), ".threatcrush");
29834
30315
  if (!(0, import_node_fs18.existsSync)(dir)) (0, import_node_fs18.mkdirSync)(dir, { recursive: true });
29835
30316
  (0, import_node_fs18.writeFileSync)(CONFIG_PATH, JSON.stringify(config, null, 2));
29836
30317
  }
@@ -29968,7 +30449,7 @@ async function useOrganization(slug) {
29968
30449
 
29969
30450
  // src/commands/servers.ts
29970
30451
  var import_node_readline3 = __toESM(require("readline"));
29971
- var import_node_os6 = require("os");
30452
+ var import_node_os7 = require("os");
29972
30453
  async function serversCommand(options) {
29973
30454
  const { action, name, org } = options;
29974
30455
  if (action === "list" || !action) {
@@ -30027,7 +30508,7 @@ async function chooseOrg(orgs, flag, ask2) {
30027
30508
  async function linkServer(opts = {}, ask2 = askChoice) {
30028
30509
  if (!hasSession()) throw new Error("Not logged in. Run: threatcrush login");
30029
30510
  const org = await chooseOrg(await fetchOrgs(), opts.org, ask2);
30030
- const host = opts.hostname ?? (0, import_node_os6.hostname)();
30511
+ const host = opts.hostname ?? (0, import_node_os7.hostname)();
30031
30512
  const listRes = await cloudFetch(`/api/orgs/${org.id}/servers`);
30032
30513
  if (!listRes.ok) throw new Error(`Failed to list servers in /${org.slug} (${listRes.status})`);
30033
30514
  const { servers = [] } = await listRes.json();
@@ -30143,12 +30624,12 @@ function timeAgo(dateStr) {
30143
30624
  }
30144
30625
 
30145
30626
  // src/commands/connect.ts
30146
- var import_node_os7 = require("os");
30627
+ var import_node_os8 = require("os");
30147
30628
  var import_node_fs19 = require("fs");
30148
30629
  var import_node_path15 = require("path");
30149
30630
  var import_node_child_process3 = require("child_process");
30150
30631
  var API_URL4 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
30151
- var CONFIG_PATH2 = (0, import_node_path15.join)((0, import_node_os7.homedir)(), ".threatcrush", "config.json");
30632
+ var CONFIG_PATH2 = (0, import_node_path15.join)((0, import_node_os8.homedir)(), ".threatcrush", "config.json");
30152
30633
  function readConfig2() {
30153
30634
  try {
30154
30635
  return JSON.parse((0, import_node_fs19.readFileSync)(CONFIG_PATH2, "utf-8"));
@@ -30273,20 +30754,20 @@ async function resolveServer(nameOrSlug, orgSlug) {
30273
30754
  }
30274
30755
  }
30275
30756
  async function sshConnect(options) {
30276
- const { hostname: hostname2, port, username, identity } = options;
30277
- if (!hostname2) {
30757
+ const { hostname: hostname3, port, username, identity } = options;
30758
+ if (!hostname3) {
30278
30759
  console.log(source_default.red(" No hostname available for this server.\n"));
30279
30760
  return;
30280
30761
  }
30281
30762
  const user = username || "root";
30282
- console.log(source_default.green(` Connecting to ${user}@${hostname2}:${port}...
30763
+ console.log(source_default.green(` Connecting to ${user}@${hostname3}:${port}...
30283
30764
  `));
30284
30765
  console.log(source_default.dim(" (Spawning SSH session \u2014 exit with Ctrl+D or type 'exit')\n"));
30285
30766
  const sshArgs = ["-p", String(port)];
30286
30767
  if (identity) {
30287
30768
  sshArgs.push("-i", identity);
30288
30769
  }
30289
- sshArgs.push(`${user}@${hostname2}`);
30770
+ sshArgs.push(`${user}@${hostname3}`);
30290
30771
  const ssh = (0, import_node_child_process3.spawn)("ssh", sshArgs, { stdio: "inherit" });
30291
30772
  ssh.on("error", (err) => {
30292
30773
  console.log(source_default.red(`
@@ -30313,7 +30794,7 @@ var import_node_fs31 = require("fs");
30313
30794
  // src/daemon/index.ts
30314
30795
  var import_node_fs29 = require("fs");
30315
30796
  var import_node_child_process10 = require("child_process");
30316
- var import_node_os8 = require("os");
30797
+ var import_node_os9 = require("os");
30317
30798
  var import_node_path20 = require("path");
30318
30799
  var import_node_util = require("util");
30319
30800
  init_paths();
@@ -32118,7 +32599,7 @@ var RunsWorker = class {
32118
32599
  };
32119
32600
 
32120
32601
  // src/core/cloud-events.ts
32121
- var import_node_crypto4 = require("crypto");
32602
+ var import_node_crypto5 = require("crypto");
32122
32603
  var import_node_net3 = require("net");
32123
32604
  function currentLink() {
32124
32605
  if (!hasSession()) return null;
@@ -32191,7 +32672,7 @@ function remediationEvent(serverId, event) {
32191
32672
  return {
32192
32673
  type: "remediation",
32193
32674
  server_id: serverId,
32194
- event_id: (0, import_node_crypto4.randomUUID)(),
32675
+ event_id: (0, import_node_crypto5.randomUUID)(),
32195
32676
  action_type: d.action,
32196
32677
  target_value: event.source_ip,
32197
32678
  status: d.failed === true ? "failed" : "executed",
@@ -34295,7 +34776,7 @@ async function runDaemon() {
34295
34776
  cloudSync = new CloudSync({
34296
34777
  bus,
34297
34778
  version,
34298
- hostname: (0, import_node_os8.hostname)(),
34779
+ hostname: (0, import_node_os9.hostname)(),
34299
34780
  minSeverity,
34300
34781
  spoolPath: (0, import_node_path20.join)(PATHS.stateDir, "cloud-spool.jsonl"),
34301
34782
  log: logLine,
@@ -34755,6 +35236,74 @@ async function uninstallServiceCommand() {
34755
35236
  console.log(source_default.green(" \u2713 threatcrushd service removed."));
34756
35237
  }
34757
35238
 
35239
+ // src/commands/save.ts
35240
+ var import_node_fs33 = require("fs");
35241
+ var import_toml5 = __toESM(require_toml());
35242
+ init_paths();
35243
+ var SECRET_KEY = /pass(word)?|secret|token|api_?key|private|webhook|dsn|url|routing_key|auth/i;
35244
+ var REDACTED = "[redacted]";
35245
+ var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
35246
+ function redactConfig(value, depth = 0) {
35247
+ if (depth > 10) return REDACTED;
35248
+ if (Array.isArray(value)) return value.map((v) => redactConfig(v, depth + 1));
35249
+ if (value && typeof value === "object") {
35250
+ return Object.fromEntries(
35251
+ Object.entries(value).filter(([key]) => !UNSAFE_KEYS.has(key)).map(([key, v]) => [
35252
+ key,
35253
+ SECRET_KEY.test(key) && v !== null && typeof v !== "object" && typeof v !== "boolean" ? REDACTED : redactConfig(v, depth + 1)
35254
+ ])
35255
+ );
35256
+ }
35257
+ return value;
35258
+ }
35259
+ async function saveCommand(opts = {}) {
35260
+ banner();
35261
+ if (!hasSession()) {
35262
+ console.log(source_default.yellow(" Not logged in."));
35263
+ console.log(source_default.dim(` Log in with ${source_default.white("threatcrush login")}, then link this machine with ${source_default.white("threatcrush servers link")}.
35264
+ `));
35265
+ process.exitCode = 1;
35266
+ return;
35267
+ }
35268
+ const link = currentLink();
35269
+ if (!link) {
35270
+ console.log(source_default.yellow(" This machine is not linked to a dashboard server."));
35271
+ console.log(source_default.dim(` Link it with ${source_default.white("threatcrush servers link")}.
35272
+ `));
35273
+ process.exitCode = 1;
35274
+ return;
35275
+ }
35276
+ const path = opts.config ?? PATHS.configFile;
35277
+ let config = {};
35278
+ if ((0, import_node_fs33.existsSync)(path)) {
35279
+ try {
35280
+ config = import_toml5.default.parse((0, import_node_fs33.readFileSync)(path, "utf-8"));
35281
+ } catch (err) {
35282
+ console.log(source_default.red(` \u2717 ${path} is not valid TOML: ${err.message}
35283
+ `));
35284
+ process.exitCode = 1;
35285
+ return;
35286
+ }
35287
+ }
35288
+ const res = await cloudFetch(`/api/orgs/${link.orgId}/servers/${link.serverId}/config`, {
35289
+ method: "PUT",
35290
+ body: JSON.stringify({ config: redactConfig(config), source: path })
35291
+ });
35292
+ const data = await res.json().catch(() => ({}));
35293
+ if (!res.ok) {
35294
+ console.log(source_default.red(` \u2717 ${data.error || `Save failed (${res.status})`}
35295
+ `));
35296
+ process.exitCode = 1;
35297
+ return;
35298
+ }
35299
+ const sections = Object.keys(config);
35300
+ console.log(source_default.green(` \u2713 Saved ${path} to ${source_default.white(data.server?.name ?? link.serverId)}`));
35301
+ console.log(source_default.dim(
35302
+ sections.length > 0 ? ` Sections: ${sections.join(", ")} (secrets redacted)
35303
+ ` : " No config file here, so the built-in defaults were saved as empty.\n"
35304
+ ));
35305
+ }
35306
+
34758
35307
  // src/commands/welcome.ts
34759
35308
  init_paths();
34760
35309
  var LOGO = source_default.green(`
@@ -34809,7 +35358,7 @@ function nextSteps() {
34809
35358
  }
34810
35359
  steps.push({
34811
35360
  heading: "Open the live dashboard",
34812
- hint: "react-blessed TUI \u2014 subscribes to events from the daemon.",
35361
+ hint: "hqtui dashboard \u2014 subscribes to events from the daemon.",
34813
35362
  cmd: "threatcrush tui"
34814
35363
  });
34815
35364
  return steps;
@@ -34840,7 +35389,7 @@ function welcomeCommand() {
34840
35389
  }
34841
35390
 
34842
35391
  // src/commands/properties.ts
34843
- var import_node_fs33 = require("fs");
35392
+ var import_node_fs34 = require("fs");
34844
35393
  var import_node_path23 = require("path");
34845
35394
  var import_node_readline6 = __toESM(require("readline"));
34846
35395
  var API_URL5 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
@@ -35171,7 +35720,7 @@ async function propertiesRunsCommand(opts) {
35171
35720
  }
35172
35721
  function parseImportFile(path) {
35173
35722
  const ext = (0, import_node_path23.extname)(path).toLowerCase();
35174
- const raw = (0, import_node_fs33.readFileSync)(path, "utf-8");
35723
+ const raw = (0, import_node_fs34.readFileSync)(path, "utf-8");
35175
35724
  if (ext === ".json") {
35176
35725
  const parsed = JSON.parse(raw);
35177
35726
  if (!Array.isArray(parsed)) throw new Error("JSON must be an array of objects");
@@ -35366,7 +35915,7 @@ async function rulesCommand(opts) {
35366
35915
  }
35367
35916
 
35368
35917
  // src/commands/harden.ts
35369
- var import_node_fs34 = require("fs");
35918
+ var import_node_fs35 = require("fs");
35370
35919
  var import_node_child_process13 = require("child_process");
35371
35920
  function tryExec(cmd) {
35372
35921
  try {
@@ -35377,7 +35926,7 @@ function tryExec(cmd) {
35377
35926
  }
35378
35927
  function tryRead(path) {
35379
35928
  try {
35380
- return (0, import_node_fs34.readFileSync)(path, "utf-8");
35929
+ return (0, import_node_fs35.readFileSync)(path, "utf-8");
35381
35930
  } catch {
35382
35931
  return null;
35383
35932
  }
@@ -35481,8 +36030,8 @@ function checkSshWeakConfig() {
35481
36030
  };
35482
36031
  }
35483
36032
  function checkAutoUpdates() {
35484
- const unattended = (0, import_node_fs34.existsSync)("/etc/apt/apt.conf.d/20auto-upgrades") || (0, import_node_fs34.existsSync)("/etc/apt/apt.conf.d/50unattended-upgrades");
35485
- const dnfAuto = (0, import_node_fs34.existsSync)("/etc/dnf/automatic.conf");
36033
+ const unattended = (0, import_node_fs35.existsSync)("/etc/apt/apt.conf.d/20auto-upgrades") || (0, import_node_fs35.existsSync)("/etc/apt/apt.conf.d/50unattended-upgrades");
36034
+ const dnfAuto = (0, import_node_fs35.existsSync)("/etc/dnf/automatic.conf");
35486
36035
  if (unattended || dnfAuto) {
35487
36036
  return {
35488
36037
  key: "auto-updates",
@@ -35608,7 +36157,7 @@ function checkFail2ban() {
35608
36157
  explanation: "fail2ban is installed and running."
35609
36158
  };
35610
36159
  }
35611
- if ((0, import_node_fs34.existsSync)("/etc/fail2ban/fail2ban.conf")) {
36160
+ if ((0, import_node_fs35.existsSync)("/etc/fail2ban/fail2ban.conf")) {
35612
36161
  return {
35613
36162
  key: checkKey,
35614
36163
  status: "warn",
@@ -36056,7 +36605,7 @@ ${source_default.dim(" C R U S H")}
36056
36605
  var API_URL6 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
36057
36606
  var PKG_NAME = "@profullstack/threatcrush";
36058
36607
  var DESKTOP_PKG_NAME = "@profullstack/threatcrush-desktop";
36059
- var INSTALL_CONFIG_PATH = (0, import_node_path24.join)((0, import_node_os9.homedir)(), ".threatcrush", "install.json");
36608
+ var INSTALL_CONFIG_PATH = (0, import_node_path24.join)((0, import_node_os10.homedir)(), ".threatcrush", "install.json");
36060
36609
  function detectPackageManager() {
36061
36610
  try {
36062
36611
  const npmGlobal = (0, import_node_child_process15.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
@@ -36082,7 +36631,7 @@ function detectPackageManager() {
36082
36631
  }
36083
36632
  function readInstallConfig() {
36084
36633
  try {
36085
- return JSON.parse((0, import_node_fs35.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
36634
+ return JSON.parse((0, import_node_fs36.readFileSync)(INSTALL_CONFIG_PATH, "utf-8"));
36086
36635
  } catch {
36087
36636
  return {};
36088
36637
  }
@@ -36252,8 +36801,11 @@ program2.command("tui").description("Interactive security dashboard (htop for se
36252
36801
  program2.command("init").description("Sign in, auto-detect services, and configure ThreatCrush").option("-y, --yes", "Don't ask; answer yes to every question").option("--offline", "Skip signing in to threatcrush.com").action(async (opts) => {
36253
36802
  await initCommand({ yes: opts.yes, offline: opts.offline });
36254
36803
  });
36255
- program2.command("login").description("Log in to your threatcrush.com account").option("-e, --email <email>", "Email to log in with").action(async (opts) => {
36256
- await loginCommand({ email: opts.email });
36804
+ program2.command("login").description("Log in to your threatcrush.com account (prints a link to approve in your browser)").option("-p, --password", "Log in with email and password instead of a link").option("-e, --email <email>", "Email to log in with (implies --password)").action(async (opts) => {
36805
+ await loginCommand({ email: opts.email, password: opts.password });
36806
+ });
36807
+ program2.command("save").description("Save this machine's daemon config to its threatcrush.com server (secrets redacted)").option("-c, --config <path>", "Config file to save (default: the one the daemon reads)").action(async (opts) => {
36808
+ await saveCommand({ config: opts.config });
36257
36809
  });
36258
36810
  program2.command("logout").description("Clear stored threatcrush.com credentials").action(async () => {
36259
36811
  await logoutCommand();
@@ -36353,7 +36905,7 @@ program2.command("uninstall-service").description("Remove the threatcrushd syste
36353
36905
  program2.command("logs").description("Tail daemon logs").action(async () => {
36354
36906
  console.log(LOGO2);
36355
36907
  const logPath = PATHS.logFile;
36356
- if (!(0, import_node_fs35.existsSync)(logPath)) {
36908
+ if (!(0, import_node_fs36.existsSync)(logPath)) {
36357
36909
  console.log(source_default.yellow(` No log file found at ${logPath}`));
36358
36910
  console.log(source_default.dim(" Start the daemon first with `threatcrush start`\n"));
36359
36911
  return;
@@ -36526,10 +37078,10 @@ storeCmd.command("search <query>").description("Search for modules in the store"
36526
37078
  });
36527
37079
  storeCmd.command("publish <url>").description("Publish a module from a git URL or web URL").action(async (url) => {
36528
37080
  console.log(LOGO2);
36529
- const configPath = (0, import_node_path24.join)((0, import_node_os9.homedir)(), ".threatcrush", "config.json");
37081
+ const configPath = (0, import_node_path24.join)((0, import_node_os10.homedir)(), ".threatcrush", "config.json");
36530
37082
  let email = "";
36531
37083
  try {
36532
- const config = JSON.parse((0, import_node_fs35.readFileSync)(configPath, "utf-8"));
37084
+ const config = JSON.parse((0, import_node_fs36.readFileSync)(configPath, "utf-8"));
36533
37085
  email = config.email || "";
36534
37086
  } catch {
36535
37087
  }
@@ -36546,9 +37098,9 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
36546
37098
  return;
36547
37099
  }
36548
37100
  try {
36549
- const dir = (0, import_node_path24.join)((0, import_node_os9.homedir)(), ".threatcrush");
36550
- if (!(0, import_node_fs35.existsSync)(dir)) (0, import_node_fs35.mkdirSync)(dir, { recursive: true });
36551
- (0, import_node_fs35.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
37101
+ const dir = (0, import_node_path24.join)((0, import_node_os10.homedir)(), ".threatcrush");
37102
+ if (!(0, import_node_fs36.existsSync)(dir)) (0, import_node_fs36.mkdirSync)(dir, { recursive: true });
37103
+ (0, import_node_fs36.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
36552
37104
  console.log(source_default.dim(` Saved email to ${configPath}`));
36553
37105
  } catch {
36554
37106
  }