// Force strict mode and setup for ESM
"use strict";
import {
  Box_default,
  Text,
  require_jsx_runtime,
  theme,
  use_is_screen_reader_enabled_default,
  use_stdin_default,
  use_stdout_default
} from "./chunk-OJINH4QS.js";
import {
  require_react
} from "./chunk-HTHUX2T5.js";
import {
  noteInteraction
} from "./chunk-KW7NOTN6.js";
import {
  formatHistoryGapNotice,
  indexGapsByChild
} from "./chunk-KWD32WL5.js";
import {
  sanitizeFilenameForDisplay
} from "./chunk-JZZFWHB3.js";
import {
  formatDuration
} from "./chunk-E5Z2AVNV.js";
import {
  t
} from "./chunk-XP6JY4LW.js";
import {
  fetchGitDiff,
  findProviderByCredentials,
  getToolResponseDisplayText,
  resolveMetadataKey
} from "./chunk-YHRUZRL4.js";
import {
  KittySequenceOverflowEvent,
  logKittySequenceOverflow
} from "./chunk-D3DWHKLI.js";
import {
  ToolDisplayNames
} from "./chunk-2UUAIFQO.js";
import {
  createDebugLogger
} from "./chunk-7NFB7LBQ.js";
import {
  init_esbuild_shims
} from "./chunk-5O2XNYP6.js";
import {
  __commonJS,
  __name,
  __toESM
} from "./chunk-J2S4EL5Y.js";

// node_modules/cli-spinners/spinners.json
var require_spinners = __commonJS({
  "node_modules/cli-spinners/spinners.json"(exports, module) {
    module.exports = {
      dots: {
        interval: 80,
        frames: [
          "\u280B",
          "\u2819",
          "\u2839",
          "\u2838",
          "\u283C",
          "\u2834",
          "\u2826",
          "\u2827",
          "\u2807",
          "\u280F"
        ]
      },
      dots2: {
        interval: 80,
        frames: [
          "\u28FE",
          "\u28FD",
          "\u28FB",
          "\u28BF",
          "\u287F",
          "\u28DF",
          "\u28EF",
          "\u28F7"
        ]
      },
      dots3: {
        interval: 80,
        frames: [
          "\u280B",
          "\u2819",
          "\u281A",
          "\u281E",
          "\u2816",
          "\u2826",
          "\u2834",
          "\u2832",
          "\u2833",
          "\u2813"
        ]
      },
      dots4: {
        interval: 80,
        frames: [
          "\u2804",
          "\u2806",
          "\u2807",
          "\u280B",
          "\u2819",
          "\u2838",
          "\u2830",
          "\u2820",
          "\u2830",
          "\u2838",
          "\u2819",
          "\u280B",
          "\u2807",
          "\u2806"
        ]
      },
      dots5: {
        interval: 80,
        frames: [
          "\u280B",
          "\u2819",
          "\u281A",
          "\u2812",
          "\u2802",
          "\u2802",
          "\u2812",
          "\u2832",
          "\u2834",
          "\u2826",
          "\u2816",
          "\u2812",
          "\u2810",
          "\u2810",
          "\u2812",
          "\u2813",
          "\u280B"
        ]
      },
      dots6: {
        interval: 80,
        frames: [
          "\u2801",
          "\u2809",
          "\u2819",
          "\u281A",
          "\u2812",
          "\u2802",
          "\u2802",
          "\u2812",
          "\u2832",
          "\u2834",
          "\u2824",
          "\u2804",
          "\u2804",
          "\u2824",
          "\u2834",
          "\u2832",
          "\u2812",
          "\u2802",
          "\u2802",
          "\u2812",
          "\u281A",
          "\u2819",
          "\u2809",
          "\u2801"
        ]
      },
      dots7: {
        interval: 80,
        frames: [
          "\u2808",
          "\u2809",
          "\u280B",
          "\u2813",
          "\u2812",
          "\u2810",
          "\u2810",
          "\u2812",
          "\u2816",
          "\u2826",
          "\u2824",
          "\u2820",
          "\u2820",
          "\u2824",
          "\u2826",
          "\u2816",
          "\u2812",
          "\u2810",
          "\u2810",
          "\u2812",
          "\u2813",
          "\u280B",
          "\u2809",
          "\u2808"
        ]
      },
      dots8: {
        interval: 80,
        frames: [
          "\u2801",
          "\u2801",
          "\u2809",
          "\u2819",
          "\u281A",
          "\u2812",
          "\u2802",
          "\u2802",
          "\u2812",
          "\u2832",
          "\u2834",
          "\u2824",
          "\u2804",
          "\u2804",
          "\u2824",
          "\u2820",
          "\u2820",
          "\u2824",
          "\u2826",
          "\u2816",
          "\u2812",
          "\u2810",
          "\u2810",
          "\u2812",
          "\u2813",
          "\u280B",
          "\u2809",
          "\u2808",
          "\u2808"
        ]
      },
      dots9: {
        interval: 80,
        frames: [
          "\u28B9",
          "\u28BA",
          "\u28BC",
          "\u28F8",
          "\u28C7",
          "\u2867",
          "\u2857",
          "\u284F"
        ]
      },
      dots10: {
        interval: 80,
        frames: [
          "\u2884",
          "\u2882",
          "\u2881",
          "\u2841",
          "\u2848",
          "\u2850",
          "\u2860"
        ]
      },
      dots11: {
        interval: 100,
        frames: [
          "\u2801",
          "\u2802",
          "\u2804",
          "\u2840",
          "\u2880",
          "\u2820",
          "\u2810",
          "\u2808"
        ]
      },
      dots12: {
        interval: 80,
        frames: [
          "\u2880\u2800",
          "\u2840\u2800",
          "\u2804\u2800",
          "\u2882\u2800",
          "\u2842\u2800",
          "\u2805\u2800",
          "\u2883\u2800",
          "\u2843\u2800",
          "\u280D\u2800",
          "\u288B\u2800",
          "\u284B\u2800",
          "\u280D\u2801",
          "\u288B\u2801",
          "\u284B\u2801",
          "\u280D\u2809",
          "\u280B\u2809",
          "\u280B\u2809",
          "\u2809\u2819",
          "\u2809\u2819",
          "\u2809\u2829",
          "\u2808\u2899",
          "\u2808\u2859",
          "\u2888\u2829",
          "\u2840\u2899",
          "\u2804\u2859",
          "\u2882\u2829",
          "\u2842\u2898",
          "\u2805\u2858",
          "\u2883\u2828",
          "\u2843\u2890",
          "\u280D\u2850",
          "\u288B\u2820",
          "\u284B\u2880",
          "\u280D\u2841",
          "\u288B\u2801",
          "\u284B\u2801",
          "\u280D\u2809",
          "\u280B\u2809",
          "\u280B\u2809",
          "\u2809\u2819",
          "\u2809\u2819",
          "\u2809\u2829",
          "\u2808\u2899",
          "\u2808\u2859",
          "\u2808\u2829",
          "\u2800\u2899",
          "\u2800\u2859",
          "\u2800\u2829",
          "\u2800\u2898",
          "\u2800\u2858",
          "\u2800\u2828",
          "\u2800\u2890",
          "\u2800\u2850",
          "\u2800\u2820",
          "\u2800\u2880",
          "\u2800\u2840"
        ]
      },
      dots13: {
        interval: 80,
        frames: [
          "\u28FC",
          "\u28F9",
          "\u28BB",
          "\u283F",
          "\u285F",
          "\u28CF",
          "\u28E7",
          "\u28F6"
        ]
      },
      dots8Bit: {
        interval: 80,
        frames: [
          "\u2800",
          "\u2801",
          "\u2802",
          "\u2803",
          "\u2804",
          "\u2805",
          "\u2806",
          "\u2807",
          "\u2840",
          "\u2841",
          "\u2842",
          "\u2843",
          "\u2844",
          "\u2845",
          "\u2846",
          "\u2847",
          "\u2808",
          "\u2809",
          "\u280A",
          "\u280B",
          "\u280C",
          "\u280D",
          "\u280E",
          "\u280F",
          "\u2848",
          "\u2849",
          "\u284A",
          "\u284B",
          "\u284C",
          "\u284D",
          "\u284E",
          "\u284F",
          "\u2810",
          "\u2811",
          "\u2812",
          "\u2813",
          "\u2814",
          "\u2815",
          "\u2816",
          "\u2817",
          "\u2850",
          "\u2851",
          "\u2852",
          "\u2853",
          "\u2854",
          "\u2855",
          "\u2856",
          "\u2857",
          "\u2818",
          "\u2819",
          "\u281A",
          "\u281B",
          "\u281C",
          "\u281D",
          "\u281E",
          "\u281F",
          "\u2858",
          "\u2859",
          "\u285A",
          "\u285B",
          "\u285C",
          "\u285D",
          "\u285E",
          "\u285F",
          "\u2820",
          "\u2821",
          "\u2822",
          "\u2823",
          "\u2824",
          "\u2825",
          "\u2826",
          "\u2827",
          "\u2860",
          "\u2861",
          "\u2862",
          "\u2863",
          "\u2864",
          "\u2865",
          "\u2866",
          "\u2867",
          "\u2828",
          "\u2829",
          "\u282A",
          "\u282B",
          "\u282C",
          "\u282D",
          "\u282E",
          "\u282F",
          "\u2868",
          "\u2869",
          "\u286A",
          "\u286B",
          "\u286C",
          "\u286D",
          "\u286E",
          "\u286F",
          "\u2830",
          "\u2831",
          "\u2832",
          "\u2833",
          "\u2834",
          "\u2835",
          "\u2836",
          "\u2837",
          "\u2870",
          "\u2871",
          "\u2872",
          "\u2873",
          "\u2874",
          "\u2875",
          "\u2876",
          "\u2877",
          "\u2838",
          "\u2839",
          "\u283A",
          "\u283B",
          "\u283C",
          "\u283D",
          "\u283E",
          "\u283F",
          "\u2878",
          "\u2879",
          "\u287A",
          "\u287B",
          "\u287C",
          "\u287D",
          "\u287E",
          "\u287F",
          "\u2880",
          "\u2881",
          "\u2882",
          "\u2883",
          "\u2884",
          "\u2885",
          "\u2886",
          "\u2887",
          "\u28C0",
          "\u28C1",
          "\u28C2",
          "\u28C3",
          "\u28C4",
          "\u28C5",
          "\u28C6",
          "\u28C7",
          "\u2888",
          "\u2889",
          "\u288A",
          "\u288B",
          "\u288C",
          "\u288D",
          "\u288E",
          "\u288F",
          "\u28C8",
          "\u28C9",
          "\u28CA",
          "\u28CB",
          "\u28CC",
          "\u28CD",
          "\u28CE",
          "\u28CF",
          "\u2890",
          "\u2891",
          "\u2892",
          "\u2893",
          "\u2894",
          "\u2895",
          "\u2896",
          "\u2897",
          "\u28D0",
          "\u28D1",
          "\u28D2",
          "\u28D3",
          "\u28D4",
          "\u28D5",
          "\u28D6",
          "\u28D7",
          "\u2898",
          "\u2899",
          "\u289A",
          "\u289B",
          "\u289C",
          "\u289D",
          "\u289E",
          "\u289F",
          "\u28D8",
          "\u28D9",
          "\u28DA",
          "\u28DB",
          "\u28DC",
          "\u28DD",
          "\u28DE",
          "\u28DF",
          "\u28A0",
          "\u28A1",
          "\u28A2",
          "\u28A3",
          "\u28A4",
          "\u28A5",
          "\u28A6",
          "\u28A7",
          "\u28E0",
          "\u28E1",
          "\u28E2",
          "\u28E3",
          "\u28E4",
          "\u28E5",
          "\u28E6",
          "\u28E7",
          "\u28A8",
          "\u28A9",
          "\u28AA",
          "\u28AB",
          "\u28AC",
          "\u28AD",
          "\u28AE",
          "\u28AF",
          "\u28E8",
          "\u28E9",
          "\u28EA",
          "\u28EB",
          "\u28EC",
          "\u28ED",
          "\u28EE",
          "\u28EF",
          "\u28B0",
          "\u28B1",
          "\u28B2",
          "\u28B3",
          "\u28B4",
          "\u28B5",
          "\u28B6",
          "\u28B7",
          "\u28F0",
          "\u28F1",
          "\u28F2",
          "\u28F3",
          "\u28F4",
          "\u28F5",
          "\u28F6",
          "\u28F7",
          "\u28B8",
          "\u28B9",
          "\u28BA",
          "\u28BB",
          "\u28BC",
          "\u28BD",
          "\u28BE",
          "\u28BF",
          "\u28F8",
          "\u28F9",
          "\u28FA",
          "\u28FB",
          "\u28FC",
          "\u28FD",
          "\u28FE",
          "\u28FF"
        ]
      },
      sand: {
        interval: 80,
        frames: [
          "\u2801",
          "\u2802",
          "\u2804",
          "\u2840",
          "\u2848",
          "\u2850",
          "\u2860",
          "\u28C0",
          "\u28C1",
          "\u28C2",
          "\u28C4",
          "\u28CC",
          "\u28D4",
          "\u28E4",
          "\u28E5",
          "\u28E6",
          "\u28EE",
          "\u28F6",
          "\u28F7",
          "\u28FF",
          "\u287F",
          "\u283F",
          "\u289F",
          "\u281F",
          "\u285B",
          "\u281B",
          "\u282B",
          "\u288B",
          "\u280B",
          "\u280D",
          "\u2849",
          "\u2809",
          "\u2811",
          "\u2821",
          "\u2881"
        ]
      },
      line: {
        interval: 130,
        frames: [
          "-",
          "\\",
          "|",
          "/"
        ]
      },
      line2: {
        interval: 100,
        frames: [
          "\u2802",
          "-",
          "\u2013",
          "\u2014",
          "\u2013",
          "-"
        ]
      },
      pipe: {
        interval: 100,
        frames: [
          "\u2524",
          "\u2518",
          "\u2534",
          "\u2514",
          "\u251C",
          "\u250C",
          "\u252C",
          "\u2510"
        ]
      },
      simpleDots: {
        interval: 400,
        frames: [
          ".  ",
          ".. ",
          "...",
          "   "
        ]
      },
      simpleDotsScrolling: {
        interval: 200,
        frames: [
          ".  ",
          ".. ",
          "...",
          " ..",
          "  .",
          "   "
        ]
      },
      star: {
        interval: 70,
        frames: [
          "\u2736",
          "\u2738",
          "\u2739",
          "\u273A",
          "\u2739",
          "\u2737"
        ]
      },
      star2: {
        interval: 80,
        frames: [
          "+",
          "x",
          "*"
        ]
      },
      flip: {
        interval: 70,
        frames: [
          "_",
          "_",
          "_",
          "-",
          "`",
          "`",
          "'",
          "\xB4",
          "-",
          "_",
          "_",
          "_"
        ]
      },
      hamburger: {
        interval: 100,
        frames: [
          "\u2631",
          "\u2632",
          "\u2634"
        ]
      },
      growVertical: {
        interval: 120,
        frames: [
          "\u2581",
          "\u2583",
          "\u2584",
          "\u2585",
          "\u2586",
          "\u2587",
          "\u2586",
          "\u2585",
          "\u2584",
          "\u2583"
        ]
      },
      growHorizontal: {
        interval: 120,
        frames: [
          "\u258F",
          "\u258E",
          "\u258D",
          "\u258C",
          "\u258B",
          "\u258A",
          "\u2589",
          "\u258A",
          "\u258B",
          "\u258C",
          "\u258D",
          "\u258E"
        ]
      },
      balloon: {
        interval: 140,
        frames: [
          " ",
          ".",
          "o",
          "O",
          "@",
          "*",
          " "
        ]
      },
      balloon2: {
        interval: 120,
        frames: [
          ".",
          "o",
          "O",
          "\xB0",
          "O",
          "o",
          "."
        ]
      },
      noise: {
        interval: 100,
        frames: [
          "\u2593",
          "\u2592",
          "\u2591"
        ]
      },
      bounce: {
        interval: 120,
        frames: [
          "\u2801",
          "\u2802",
          "\u2804",
          "\u2802"
        ]
      },
      boxBounce: {
        interval: 120,
        frames: [
          "\u2596",
          "\u2598",
          "\u259D",
          "\u2597"
        ]
      },
      boxBounce2: {
        interval: 100,
        frames: [
          "\u258C",
          "\u2580",
          "\u2590",
          "\u2584"
        ]
      },
      triangle: {
        interval: 50,
        frames: [
          "\u25E2",
          "\u25E3",
          "\u25E4",
          "\u25E5"
        ]
      },
      binary: {
        interval: 80,
        frames: [
          "010010",
          "001100",
          "100101",
          "111010",
          "111101",
          "010111",
          "101011",
          "111000",
          "110011",
          "110101"
        ]
      },
      arc: {
        interval: 100,
        frames: [
          "\u25DC",
          "\u25E0",
          "\u25DD",
          "\u25DE",
          "\u25E1",
          "\u25DF"
        ]
      },
      circle: {
        interval: 120,
        frames: [
          "\u25E1",
          "\u2299",
          "\u25E0"
        ]
      },
      squareCorners: {
        interval: 180,
        frames: [
          "\u25F0",
          "\u25F3",
          "\u25F2",
          "\u25F1"
        ]
      },
      circleQuarters: {
        interval: 120,
        frames: [
          "\u25F4",
          "\u25F7",
          "\u25F6",
          "\u25F5"
        ]
      },
      circleHalves: {
        interval: 50,
        frames: [
          "\u25D0",
          "\u25D3",
          "\u25D1",
          "\u25D2"
        ]
      },
      squish: {
        interval: 100,
        frames: [
          "\u256B",
          "\u256A"
        ]
      },
      toggle: {
        interval: 250,
        frames: [
          "\u22B6",
          "\u22B7"
        ]
      },
      toggle2: {
        interval: 80,
        frames: [
          "\u25AB",
          "\u25AA"
        ]
      },
      toggle3: {
        interval: 120,
        frames: [
          "\u25A1",
          "\u25A0"
        ]
      },
      toggle4: {
        interval: 100,
        frames: [
          "\u25A0",
          "\u25A1",
          "\u25AA",
          "\u25AB"
        ]
      },
      toggle5: {
        interval: 100,
        frames: [
          "\u25AE",
          "\u25AF"
        ]
      },
      toggle6: {
        interval: 300,
        frames: [
          "\u101D",
          "\u1040"
        ]
      },
      toggle7: {
        interval: 80,
        frames: [
          "\u29BE",
          "\u29BF"
        ]
      },
      toggle8: {
        interval: 100,
        frames: [
          "\u25CD",
          "\u25CC"
        ]
      },
      toggle9: {
        interval: 100,
        frames: [
          "\u25C9",
          "\u25CE"
        ]
      },
      toggle10: {
        interval: 100,
        frames: [
          "\u3282",
          "\u3280",
          "\u3281"
        ]
      },
      toggle11: {
        interval: 50,
        frames: [
          "\u29C7",
          "\u29C6"
        ]
      },
      toggle12: {
        interval: 120,
        frames: [
          "\u2617",
          "\u2616"
        ]
      },
      toggle13: {
        interval: 80,
        frames: [
          "=",
          "*",
          "-"
        ]
      },
      arrow: {
        interval: 100,
        frames: [
          "\u2190",
          "\u2196",
          "\u2191",
          "\u2197",
          "\u2192",
          "\u2198",
          "\u2193",
          "\u2199"
        ]
      },
      arrow2: {
        interval: 80,
        frames: [
          "\u2B06\uFE0F ",
          "\u2197\uFE0F ",
          "\u27A1\uFE0F ",
          "\u2198\uFE0F ",
          "\u2B07\uFE0F ",
          "\u2199\uFE0F ",
          "\u2B05\uFE0F ",
          "\u2196\uFE0F "
        ]
      },
      arrow3: {
        interval: 120,
        frames: [
          "\u25B9\u25B9\u25B9\u25B9\u25B9",
          "\u25B8\u25B9\u25B9\u25B9\u25B9",
          "\u25B9\u25B8\u25B9\u25B9\u25B9",
          "\u25B9\u25B9\u25B8\u25B9\u25B9",
          "\u25B9\u25B9\u25B9\u25B8\u25B9",
          "\u25B9\u25B9\u25B9\u25B9\u25B8"
        ]
      },
      bouncingBar: {
        interval: 80,
        frames: [
          "[    ]",
          "[=   ]",
          "[==  ]",
          "[=== ]",
          "[====]",
          "[ ===]",
          "[  ==]",
          "[   =]",
          "[    ]",
          "[   =]",
          "[  ==]",
          "[ ===]",
          "[====]",
          "[=== ]",
          "[==  ]",
          "[=   ]"
        ]
      },
      bouncingBall: {
        interval: 80,
        frames: [
          "( \u25CF    )",
          "(  \u25CF   )",
          "(   \u25CF  )",
          "(    \u25CF )",
          "(     \u25CF)",
          "(    \u25CF )",
          "(   \u25CF  )",
          "(  \u25CF   )",
          "( \u25CF    )",
          "(\u25CF     )"
        ]
      },
      smiley: {
        interval: 200,
        frames: [
          "\u{1F604} ",
          "\u{1F61D} "
        ]
      },
      monkey: {
        interval: 300,
        frames: [
          "\u{1F648} ",
          "\u{1F648} ",
          "\u{1F649} ",
          "\u{1F64A} "
        ]
      },
      hearts: {
        interval: 100,
        frames: [
          "\u{1F49B} ",
          "\u{1F499} ",
          "\u{1F49C} ",
          "\u{1F49A} ",
          "\u2764\uFE0F "
        ]
      },
      clock: {
        interval: 100,
        frames: [
          "\u{1F55B} ",
          "\u{1F550} ",
          "\u{1F551} ",
          "\u{1F552} ",
          "\u{1F553} ",
          "\u{1F554} ",
          "\u{1F555} ",
          "\u{1F556} ",
          "\u{1F557} ",
          "\u{1F558} ",
          "\u{1F559} ",
          "\u{1F55A} "
        ]
      },
      earth: {
        interval: 180,
        frames: [
          "\u{1F30D} ",
          "\u{1F30E} ",
          "\u{1F30F} "
        ]
      },
      material: {
        interval: 17,
        frames: [
          "\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588",
          "\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588",
          "\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588",
          "\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588",
          "\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588",
          "\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588",
          "\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588",
          "\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581",
          "\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"
        ]
      },
      moon: {
        interval: 80,
        frames: [
          "\u{1F311} ",
          "\u{1F312} ",
          "\u{1F313} ",
          "\u{1F314} ",
          "\u{1F315} ",
          "\u{1F316} ",
          "\u{1F317} ",
          "\u{1F318} "
        ]
      },
      runner: {
        interval: 140,
        frames: [
          "\u{1F6B6} ",
          "\u{1F3C3} "
        ]
      },
      pong: {
        interval: 80,
        frames: [
          "\u2590\u2802       \u258C",
          "\u2590\u2808       \u258C",
          "\u2590 \u2802      \u258C",
          "\u2590 \u2820      \u258C",
          "\u2590  \u2840     \u258C",
          "\u2590  \u2820     \u258C",
          "\u2590   \u2802    \u258C",
          "\u2590   \u2808    \u258C",
          "\u2590    \u2802   \u258C",
          "\u2590    \u2820   \u258C",
          "\u2590     \u2840  \u258C",
          "\u2590     \u2820  \u258C",
          "\u2590      \u2802 \u258C",
          "\u2590      \u2808 \u258C",
          "\u2590       \u2802\u258C",
          "\u2590       \u2820\u258C",
          "\u2590       \u2840\u258C",
          "\u2590      \u2820 \u258C",
          "\u2590      \u2802 \u258C",
          "\u2590     \u2808  \u258C",
          "\u2590     \u2802  \u258C",
          "\u2590    \u2820   \u258C",
          "\u2590    \u2840   \u258C",
          "\u2590   \u2820    \u258C",
          "\u2590   \u2802    \u258C",
          "\u2590  \u2808     \u258C",
          "\u2590  \u2802     \u258C",
          "\u2590 \u2820      \u258C",
          "\u2590 \u2840      \u258C",
          "\u2590\u2820       \u258C"
        ]
      },
      shark: {
        interval: 120,
        frames: [
          "\u2590|\\____________\u258C",
          "\u2590_|\\___________\u258C",
          "\u2590__|\\__________\u258C",
          "\u2590___|\\_________\u258C",
          "\u2590____|\\________\u258C",
          "\u2590_____|\\_______\u258C",
          "\u2590______|\\______\u258C",
          "\u2590_______|\\_____\u258C",
          "\u2590________|\\____\u258C",
          "\u2590_________|\\___\u258C",
          "\u2590__________|\\__\u258C",
          "\u2590___________|\\_\u258C",
          "\u2590____________|\\\u258C",
          "\u2590____________/|\u258C",
          "\u2590___________/|_\u258C",
          "\u2590__________/|__\u258C",
          "\u2590_________/|___\u258C",
          "\u2590________/|____\u258C",
          "\u2590_______/|_____\u258C",
          "\u2590______/|______\u258C",
          "\u2590_____/|_______\u258C",
          "\u2590____/|________\u258C",
          "\u2590___/|_________\u258C",
          "\u2590__/|__________\u258C",
          "\u2590_/|___________\u258C",
          "\u2590/|____________\u258C"
        ]
      },
      dqpb: {
        interval: 100,
        frames: [
          "d",
          "q",
          "p",
          "b"
        ]
      },
      weather: {
        interval: 100,
        frames: [
          "\u2600\uFE0F ",
          "\u2600\uFE0F ",
          "\u2600\uFE0F ",
          "\u{1F324} ",
          "\u26C5\uFE0F ",
          "\u{1F325} ",
          "\u2601\uFE0F ",
          "\u{1F327} ",
          "\u{1F328} ",
          "\u{1F327} ",
          "\u{1F328} ",
          "\u{1F327} ",
          "\u{1F328} ",
          "\u26C8 ",
          "\u{1F328} ",
          "\u{1F327} ",
          "\u{1F328} ",
          "\u2601\uFE0F ",
          "\u{1F325} ",
          "\u26C5\uFE0F ",
          "\u{1F324} ",
          "\u2600\uFE0F ",
          "\u2600\uFE0F "
        ]
      },
      christmas: {
        interval: 400,
        frames: [
          "\u{1F332}",
          "\u{1F384}"
        ]
      },
      grenade: {
        interval: 80,
        frames: [
          "\u060C  ",
          "\u2032  ",
          " \xB4 ",
          " \u203E ",
          "  \u2E0C",
          "  \u2E0A",
          "  |",
          "  \u204E",
          "  \u2055",
          " \u0DF4 ",
          "  \u2053",
          "   ",
          "   ",
          "   "
        ]
      },
      point: {
        interval: 125,
        frames: [
          "\u2219\u2219\u2219",
          "\u25CF\u2219\u2219",
          "\u2219\u25CF\u2219",
          "\u2219\u2219\u25CF",
          "\u2219\u2219\u2219"
        ]
      },
      layer: {
        interval: 150,
        frames: [
          "-",
          "=",
          "\u2261"
        ]
      },
      betaWave: {
        interval: 80,
        frames: [
          "\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2",
          "\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2",
          "\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2",
          "\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2",
          "\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2",
          "\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2",
          "\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"
        ]
      },
      fingerDance: {
        interval: 160,
        frames: [
          "\u{1F918} ",
          "\u{1F91F} ",
          "\u{1F596} ",
          "\u270B ",
          "\u{1F91A} ",
          "\u{1F446} "
        ]
      },
      fistBump: {
        interval: 80,
        frames: [
          "\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ",
          "\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ",
          "\u{1F91C}\u3000\u3000\u3000\u3000\u{1F91B} ",
          "\u3000\u{1F91C}\u3000\u3000\u{1F91B}\u3000 ",
          "\u3000\u3000\u{1F91C}\u{1F91B}\u3000\u3000 ",
          "\u3000\u{1F91C}\u2728\u{1F91B}\u3000\u3000 ",
          "\u{1F91C}\u3000\u2728\u3000\u{1F91B}\u3000 "
        ]
      },
      soccerHeader: {
        interval: 80,
        frames: [
          " \u{1F9D1}\u26BD\uFE0F       \u{1F9D1} ",
          "\u{1F9D1}  \u26BD\uFE0F      \u{1F9D1} ",
          "\u{1F9D1}   \u26BD\uFE0F     \u{1F9D1} ",
          "\u{1F9D1}    \u26BD\uFE0F    \u{1F9D1} ",
          "\u{1F9D1}     \u26BD\uFE0F   \u{1F9D1} ",
          "\u{1F9D1}      \u26BD\uFE0F  \u{1F9D1} ",
          "\u{1F9D1}       \u26BD\uFE0F\u{1F9D1}  ",
          "\u{1F9D1}      \u26BD\uFE0F  \u{1F9D1} ",
          "\u{1F9D1}     \u26BD\uFE0F   \u{1F9D1} ",
          "\u{1F9D1}    \u26BD\uFE0F    \u{1F9D1} ",
          "\u{1F9D1}   \u26BD\uFE0F     \u{1F9D1} ",
          "\u{1F9D1}  \u26BD\uFE0F      \u{1F9D1} "
        ]
      },
      mindblown: {
        interval: 160,
        frames: [
          "\u{1F610} ",
          "\u{1F610} ",
          "\u{1F62E} ",
          "\u{1F62E} ",
          "\u{1F626} ",
          "\u{1F626} ",
          "\u{1F627} ",
          "\u{1F627} ",
          "\u{1F92F} ",
          "\u{1F4A5} ",
          "\u2728 ",
          "\u3000 ",
          "\u3000 ",
          "\u3000 "
        ]
      },
      speaker: {
        interval: 160,
        frames: [
          "\u{1F508} ",
          "\u{1F509} ",
          "\u{1F50A} ",
          "\u{1F509} "
        ]
      },
      orangePulse: {
        interval: 100,
        frames: [
          "\u{1F538} ",
          "\u{1F536} ",
          "\u{1F7E0} ",
          "\u{1F7E0} ",
          "\u{1F536} "
        ]
      },
      bluePulse: {
        interval: 100,
        frames: [
          "\u{1F539} ",
          "\u{1F537} ",
          "\u{1F535} ",
          "\u{1F535} ",
          "\u{1F537} "
        ]
      },
      orangeBluePulse: {
        interval: 100,
        frames: [
          "\u{1F538} ",
          "\u{1F536} ",
          "\u{1F7E0} ",
          "\u{1F7E0} ",
          "\u{1F536} ",
          "\u{1F539} ",
          "\u{1F537} ",
          "\u{1F535} ",
          "\u{1F535} ",
          "\u{1F537} "
        ]
      },
      timeTravel: {
        interval: 100,
        frames: [
          "\u{1F55B} ",
          "\u{1F55A} ",
          "\u{1F559} ",
          "\u{1F558} ",
          "\u{1F557} ",
          "\u{1F556} ",
          "\u{1F555} ",
          "\u{1F554} ",
          "\u{1F553} ",
          "\u{1F552} ",
          "\u{1F551} ",
          "\u{1F550} "
        ]
      },
      aesthetic: {
        interval: 80,
        frames: [
          "\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1",
          "\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1",
          "\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1",
          "\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1",
          "\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1",
          "\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1",
          "\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0",
          "\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"
        ]
      },
      dwarfFortress: {
        interval: 80,
        frames: [
          " \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u263A \u2588\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A\u2593\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A\u2593\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A\u2592\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A\u2592\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A\u2591\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A\u2591\u2588\u2588\xA3\xA3\xA3  ",
          "   \u263A \u2588\u2588\xA3\xA3\xA3  ",
          "    \u263A\u2588\u2588\xA3\xA3\xA3  ",
          "    \u263A\u2588\u2588\xA3\xA3\xA3  ",
          "    \u263A\u2593\u2588\xA3\xA3\xA3  ",
          "    \u263A\u2593\u2588\xA3\xA3\xA3  ",
          "    \u263A\u2592\u2588\xA3\xA3\xA3  ",
          "    \u263A\u2592\u2588\xA3\xA3\xA3  ",
          "    \u263A\u2591\u2588\xA3\xA3\xA3  ",
          "    \u263A\u2591\u2588\xA3\xA3\xA3  ",
          "    \u263A \u2588\xA3\xA3\xA3  ",
          "     \u263A\u2588\xA3\xA3\xA3  ",
          "     \u263A\u2588\xA3\xA3\xA3  ",
          "     \u263A\u2593\xA3\xA3\xA3  ",
          "     \u263A\u2593\xA3\xA3\xA3  ",
          "     \u263A\u2592\xA3\xA3\xA3  ",
          "     \u263A\u2592\xA3\xA3\xA3  ",
          "     \u263A\u2591\xA3\xA3\xA3  ",
          "     \u263A\u2591\xA3\xA3\xA3  ",
          "     \u263A \xA3\xA3\xA3  ",
          "      \u263A\xA3\xA3\xA3  ",
          "      \u263A\xA3\xA3\xA3  ",
          "      \u263A\u2593\xA3\xA3  ",
          "      \u263A\u2593\xA3\xA3  ",
          "      \u263A\u2592\xA3\xA3  ",
          "      \u263A\u2592\xA3\xA3  ",
          "      \u263A\u2591\xA3\xA3  ",
          "      \u263A\u2591\xA3\xA3  ",
          "      \u263A \xA3\xA3  ",
          "       \u263A\xA3\xA3  ",
          "       \u263A\xA3\xA3  ",
          "       \u263A\u2593\xA3  ",
          "       \u263A\u2593\xA3  ",
          "       \u263A\u2592\xA3  ",
          "       \u263A\u2592\xA3  ",
          "       \u263A\u2591\xA3  ",
          "       \u263A\u2591\xA3  ",
          "       \u263A \xA3  ",
          "        \u263A\xA3  ",
          "        \u263A\xA3  ",
          "        \u263A\u2593  ",
          "        \u263A\u2593  ",
          "        \u263A\u2592  ",
          "        \u263A\u2592  ",
          "        \u263A\u2591  ",
          "        \u263A\u2591  ",
          "        \u263A   ",
          "        \u263A  &",
          "        \u263A \u263C&",
          "       \u263A \u263C &",
          "       \u263A\u263C  &",
          "      \u263A\u263C  & ",
          "      \u203C   & ",
          "     \u263A   &  ",
          "    \u203C    &  ",
          "   \u263A    &   ",
          "  \u203C     &   ",
          " \u263A     &    ",
          "\u203C      &    ",
          "      &     ",
          "      &     ",
          "     &   \u2591  ",
          "     &   \u2592  ",
          "    &    \u2593  ",
          "    &    \xA3  ",
          "   &    \u2591\xA3  ",
          "   &    \u2592\xA3  ",
          "  &     \u2593\xA3  ",
          "  &     \xA3\xA3  ",
          " &     \u2591\xA3\xA3  ",
          " &     \u2592\xA3\xA3  ",
          "&      \u2593\xA3\xA3  ",
          "&      \xA3\xA3\xA3  ",
          "      \u2591\xA3\xA3\xA3  ",
          "      \u2592\xA3\xA3\xA3  ",
          "      \u2593\xA3\xA3\xA3  ",
          "      \u2588\xA3\xA3\xA3  ",
          "     \u2591\u2588\xA3\xA3\xA3  ",
          "     \u2592\u2588\xA3\xA3\xA3  ",
          "     \u2593\u2588\xA3\xA3\xA3  ",
          "     \u2588\u2588\xA3\xA3\xA3  ",
          "    \u2591\u2588\u2588\xA3\xA3\xA3  ",
          "    \u2592\u2588\u2588\xA3\xA3\xA3  ",
          "    \u2593\u2588\u2588\xA3\xA3\xA3  ",
          "    \u2588\u2588\u2588\xA3\xA3\xA3  ",
          "   \u2591\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "   \u2592\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "   \u2593\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "   \u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          "  \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  ",
          " \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3  "
        ]
      }
    };
  }
});

// node_modules/cli-spinners/index.js
var require_cli_spinners = __commonJS({
  "node_modules/cli-spinners/index.js"(exports, module) {
    "use strict";
    init_esbuild_shims();
    var spinners2 = Object.assign({}, require_spinners());
    var spinnersList = Object.keys(spinners2);
    Object.defineProperty(spinners2, "random", {
      get() {
        const randomIndex = Math.floor(Math.random() * spinnersList.length);
        const spinnerName = spinnersList[randomIndex];
        return spinners2[spinnerName];
      }
    });
    module.exports = spinners2;
  }
});

// packages/cli/src/ui/contexts/KeypressContext.tsx
init_esbuild_shims();
var import_react3 = __toESM(require_react(), 1);
import readline from "node:readline";
import { PassThrough } from "node:stream";

// packages/cli/src/ui/utils/mouse.ts
init_esbuild_shims();
var ESC = "\x1B";
var SGR_EVENT_PREFIX = `${ESC}[<`;
var X11_EVENT_PREFIX = `${ESC}[M`;
var MAX_SGR_MOUSE_SEQUENCE_LENGTH = 50;
var SGR_MOUSE_REGEX = /^\x1b\[<(\d+);(\d+);(\d+)([mM])/;
function getEventName(buttonCode, isRelease) {
  const isMove = (buttonCode & 32) !== 0;
  if (buttonCode === 66) return "scroll-left";
  if (buttonCode === 67) return "scroll-right";
  if ((buttonCode & 64) === 64) {
    return (buttonCode & 1) === 0 ? "scroll-up" : "scroll-down";
  }
  if (isMove) return "move";
  const button = buttonCode & 3;
  const type = isRelease ? "release" : "press";
  switch (button) {
    case 0:
      return `left-${type}`;
    case 1:
      return `middle-${type}`;
    case 2:
      return `right-${type}`;
    default:
      return null;
  }
}
__name(getEventName, "getEventName");
function buttonFromCode(code) {
  switch (code & 3) {
    case 0:
      return "left";
    case 1:
      return "middle";
    case 2:
      return "right";
    default:
      return "none";
  }
}
__name(buttonFromCode, "buttonFromCode");
function parseSGRMouseEvent(buffer) {
  const match = buffer.match(SGR_MOUSE_REGEX);
  if (!match) return null;
  const buttonCode = parseInt(match[1], 10);
  const col = parseInt(match[2], 10);
  const row = parseInt(match[3], 10);
  const isRelease = match[4] === "m";
  const name = getEventName(buttonCode, isRelease);
  if (!name) return null;
  return {
    event: {
      name,
      col,
      row,
      shift: (buttonCode & 4) !== 0,
      meta: (buttonCode & 8) !== 0,
      ctrl: (buttonCode & 16) !== 0,
      button: buttonFromCode(buttonCode)
    },
    length: match[0].length
  };
}
__name(parseSGRMouseEvent, "parseSGRMouseEvent");
var ENABLE_SGR_MOUSE = {
  button: "\x1B[?1002h\x1B[?1006h",
  any: "\x1B[?1003h\x1B[?1006h"
};
var DISABLE_SGR_MOUSE = {
  button: "\x1B[?1006l\x1B[?1002l",
  any: "\x1B[?1006l\x1B[?1003l"
};
function enableMouseEvents(stdout, tracking = "button") {
  stdout.write(ENABLE_SGR_MOUSE[tracking]);
}
__name(enableMouseEvents, "enableMouseEvents");
function disableMouseEvents(stdout, tracking = "button") {
  stdout.write(DISABLE_SGR_MOUSE[tracking]);
}
__name(disableMouseEvents, "disableMouseEvents");

// packages/cli/src/ui/utils/platformConstants.ts
init_esbuild_shims();
var KITTY_CTRL_C = "[99;5u";
var KITTY_KEYCODE_ENTER = 13;
var KITTY_KEYCODE_NUMPAD_ENTER = 57414;
var KITTY_KEYCODE_TAB = 9;
var KITTY_KEYCODE_BACKSPACE = 127;
var KITTY_MODIFIER_BASE = 1;
var KITTY_MODIFIER_EVENT_TYPES_OFFSET = 128;
var MODIFIER_SHIFT_BIT = 1;
var MODIFIER_ALT_BIT = 2;
var MODIFIER_CTRL_BIT = 4;
var VSCODE_SHIFT_ENTER_SEQUENCE = "\\\r\n";
var BACKSLASH_ENTER_DETECTION_WINDOW_MS = 5;
var MAX_KITTY_SEQUENCE_LENGTH = 32;
var CHAR_CODE_ESC = 27;

// packages/cli/src/ui/utils/clipboardUtils.ts
init_esbuild_shims();
import * as fs from "node:fs/promises";
import { constants as fsConstants } from "node:fs";
import { execSync, spawn } from "node:child_process";
import * as path from "node:path";
import { randomUUID } from "node:crypto";

// packages/cli/src/utils/osc.ts
init_esbuild_shims();
var ESC2 = "\x1B";
var BEL = "\x07";
var ST = ESC2 + "\\";
var OSC_PREFIX = ESC2 + "]";
var SEP = ";";
var OSC = {
  /** iTerm2 notification / progress */
  ITERM2: 9,
  /** Kitty desktop notification protocol */
  KITTY: 99,
  /** Ghostty / cmux notification */
  GHOSTTY: 777
};
function detectTerminal() {
  const termProgram = process.env["TERM_PROGRAM"];
  switch (termProgram) {
    case "iTerm.app":
      return "iTerm.app";
    case "kitty":
      return "kitty";
    case "ghostty":
      return "ghostty";
    case "Apple_Terminal":
      return "Apple_Terminal";
    default:
      break;
  }
  if (process.env["TERM"] === "xterm-ghostty") {
    return "ghostty";
  }
  if (process.env["TERM"]?.includes("kitty")) {
    return "kitty";
  }
  if (process.env["KITTY_WINDOW_ID"]) return "kitty";
  return "unknown";
}
__name(detectTerminal, "detectTerminal");
function sanitizeOscPayload(text) {
  return text.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\x80-\x9f]/g, "");
}
__name(sanitizeOscPayload, "sanitizeOscPayload");
function osc(...parts) {
  const isKitty = detectTerminal() === "kitty";
  const inScreen = !!process.env["STY"];
  const terminator = isKitty && !inScreen ? ST : BEL;
  const sanitized = parts.map(
    (p) => typeof p === "string" ? sanitizeOscPayload(p) : p
  );
  return `${OSC_PREFIX}${sanitized.join(SEP)}${terminator}`;
}
__name(osc, "osc");
function wrapForMultiplexer(sequence) {
  if (process.env["TMUX"]) {
    const escaped = sequence.replaceAll("\x1B", "\x1B\x1B");
    return `\x1BPtmux;${escaped}\x1B\\`;
  }
  if (process.env["STY"]) {
    return `\x1BP${sequence}\x1B\\`;
  }
  return sequence;
}
__name(wrapForMultiplexer, "wrapForMultiplexer");
function encodeKittyPayload(text) {
  return Buffer.from(text, "utf8").toString("base64");
}
__name(encodeKittyPayload, "encodeKittyPayload");
function oscITerm2Notify(title, message) {
  const displayString = title ? `${title}:
${message}` : message;
  return osc(OSC.ITERM2, `

${displayString}`);
}
__name(oscITerm2Notify, "oscITerm2Notify");
function oscKittyNotify(title, message, id) {
  return [
    osc(OSC.KITTY, `i=${id}:d=0:p=title:e=1`, encodeKittyPayload(title)),
    osc(OSC.KITTY, `i=${id}:p=body:e=1`, encodeKittyPayload(message)),
    osc(OSC.KITTY, `i=${id}:d=1:a=focus`, "")
  ];
}
__name(oscKittyNotify, "oscKittyNotify");
function oscGhosttyNotify(title, message) {
  return osc(OSC.GHOSTTY, "notify", title, message);
}
__name(oscGhosttyNotify, "oscGhosttyNotify");
function generateKittyId() {
  return Math.floor(Math.random() * 2 ** 31);
}
__name(generateKittyId, "generateKittyId");

// packages/cli/src/ui/utils/clipboardUtils.ts
var debugLogger = createDebugLogger("CLIPBOARD_UTILS");
var PROCESS_TIMEOUT_MS = 5e3;
function writeOsc52(text) {
  try {
    const MAX_OSC52_BYTES = 75e3;
    if (Buffer.byteLength(text, "utf-8") > MAX_OSC52_BYTES) {
      debugLogger.warn(
        `writeOsc52: text too large (${Buffer.byteLength(text, "utf-8")} bytes), skipping`
      );
      return false;
    }
    const base64 = Buffer.from(text, "utf-8").toString("base64");
    const sequence = wrapForMultiplexer(`\x1B]52;c;${base64}\x07`);
    const stream = process.stderr.isTTY ? process.stderr : process.stdout.isTTY ? process.stdout : null;
    if (!stream) {
      debugLogger.warn(
        "OSC 52 clipboard requires a TTY; stdout/stderr not connected to terminal"
      );
      return false;
    }
    stream.write(sequence, (err) => {
      if (err) debugLogger.warn("writeOsc52: async write failed:", err);
    });
    return true;
  } catch (e) {
    debugLogger.warn("writeOsc52 failed:", e);
    return false;
  }
}
__name(writeOsc52, "writeOsc52");
var linuxClipboardTool;
var cachedWlPasteImageTypes = null;
var clipboardModulePromise = null;
async function getClipboardModule() {
  if (!clipboardModulePromise) {
    const modName = "@teddyzhu/clipboard";
    clipboardModulePromise = import(modName).catch(() => {
      debugLogger.error(
        "Failed to load @teddyzhu/clipboard native module. Clipboard image features will be unavailable."
      );
      return null;
    });
  }
  return clipboardModulePromise;
}
__name(getClipboardModule, "getClipboardModule");
function getLinuxClipboardTool() {
  if (linuxClipboardTool !== void 0) return linuxClipboardTool;
  const sessionType = process.env["XDG_SESSION_TYPE"];
  const waylandDisplay = process.env["WAYLAND_DISPLAY"];
  const display = process.env["DISPLAY"];
  let toolName = null;
  if (sessionType === "wayland" || waylandDisplay) {
    toolName = "wl-paste";
  } else if (sessionType === "x11" || display) {
    toolName = "xclip";
  } else {
    linuxClipboardTool = null;
    return null;
  }
  try {
    execSync("command -v " + toolName, { stdio: "ignore" });
    linuxClipboardTool = toolName;
    return toolName;
  } catch {
    debugLogger.warn(`${toolName} not found`);
    linuxClipboardTool = null;
    return null;
  }
}
__name(getLinuxClipboardTool, "getLinuxClipboardTool");
async function saveFromCommand(command, args, destination) {
  let fd;
  try {
    fd = await fs.open(
      destination,
      fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL
    );
  } catch {
    return false;
  }
  return new Promise((resolve) => {
    const child = spawn(command, args, {
      stdio: ["ignore", "pipe", "pipe"]
    });
    const fileStream = fd.createWriteStream();
    let stderr = "";
    let resolved = false;
    const safeResolve = /* @__PURE__ */ __name((value) => {
      if (!resolved) {
        resolved = true;
        try {
          if (!child.killed) child.kill();
        } catch {
        }
        try {
          fileStream.destroy();
        } catch {
        }
        resolve(value);
      }
    }, "safeResolve");
    const timer = setTimeout(() => {
      debugLogger.debug(`${command} timed out after ${PROCESS_TIMEOUT_MS}ms`);
      safeResolve(false);
    }, PROCESS_TIMEOUT_MS);
    child.stderr.on("data", (data) => {
      stderr += data.toString();
    });
    child.stdout.pipe(fileStream);
    child.stdout.on("error", (err) => {
      debugLogger.debug(`stdout error for ${command}:`, err);
      clearTimeout(timer);
      safeResolve(false);
    });
    child.on("error", (err) => {
      debugLogger.debug(`Failed to spawn ${command}:`, err);
      clearTimeout(timer);
      safeResolve(false);
    });
    fileStream.on("error", (err) => {
      debugLogger.debug(`File stream error for ${destination}:`, err);
      clearTimeout(timer);
      safeResolve(false);
    });
    child.on("close", (code) => {
      clearTimeout(timer);
      if (resolved) return;
      if (code !== 0) {
        debugLogger.debug(
          `${command} exited with code ${code}. Args: ${args.join(" ")}`
        );
        if (stderr) debugLogger.debug(`${command} stderr: ${stderr.trim()}`);
        safeResolve(false);
        return;
      }
      const checkFile = /* @__PURE__ */ __name(() => {
        fs.stat(destination).then((stats) => {
          safeResolve(stats.size > 0);
        }).catch(() => {
          safeResolve(false);
        });
      }, "checkFile");
      if (fileStream.writableFinished) {
        checkFile();
      } else {
        fileStream.on("finish", checkFile);
        fileStream.on("close", () => {
          if (!resolved) checkFile();
        });
      }
    });
  });
}
__name(saveFromCommand, "saveFromCommand");
async function checkClipboardForImage(command, args) {
  if (command === "wl-paste" && args.length === 1 && args[0] === "--list-types") {
    const types = await getWlPasteImageTypes();
    return types.length > 0;
  }
  return new Promise((resolve) => {
    try {
      const child = spawn(command, args, {
        stdio: ["ignore", "pipe", "ignore"]
      });
      let stdout = "";
      const timer = setTimeout(() => {
        try {
          child.kill();
        } catch {
        }
        resolve(false);
      }, PROCESS_TIMEOUT_MS);
      child.stdout.on("data", (data) => {
        stdout += data.toString();
      });
      child.on("close", (code) => {
        clearTimeout(timer);
        resolve(
          code === 0 && stdout.split("\n").some((line) => line === "image/png" || line === "image/bmp")
        );
      });
      child.on("error", () => {
        clearTimeout(timer);
        resolve(false);
      });
    } catch {
      resolve(false);
    }
  });
}
__name(checkClipboardForImage, "checkClipboardForImage");
async function clipboardHasImage(onUnavailable) {
  cachedWlPasteImageTypes = null;
  if (process.platform === "linux") {
    try {
      const tool = getLinuxClipboardTool();
      if (tool === "wl-paste") {
        return checkClipboardForImage("wl-paste", ["--list-types"]);
      }
      if (tool === "xclip") {
        return checkClipboardForImage("xclip", [
          "-selection",
          "clipboard",
          "-t",
          "TARGETS",
          "-o"
        ]);
      }
    } catch (error) {
      debugLogger.error("Error checking clipboard for image:", error);
    }
    return false;
  }
  try {
    const mod = await getClipboardModule();
    if (!mod) {
      onUnavailable?.();
      return false;
    }
    const clipboard = new mod.ClipboardManager();
    return clipboard.hasFormat("image");
  } catch (error) {
    debugLogger.error("Error checking clipboard for image:", error);
    return false;
  }
}
__name(clipboardHasImage, "clipboardHasImage");
async function getWlPasteImageTypes() {
  if (cachedWlPasteImageTypes !== null) {
    return cachedWlPasteImageTypes;
  }
  return new Promise((resolve) => {
    const child = spawn("wl-paste", ["--list-types"], {
      stdio: ["ignore", "pipe", "ignore"]
    });
    let stdout = "";
    const timer = setTimeout(() => {
      try {
        child.kill();
      } catch {
      }
      resolve([]);
    }, PROCESS_TIMEOUT_MS);
    child.stdout.on("data", (data) => {
      stdout += data.toString();
    });
    child.on("close", (code) => {
      clearTimeout(timer);
      if (code !== 0) {
        resolve([]);
        return;
      }
      const types = stdout.trim().split("\n").filter((t2) => t2 === "image/png" || t2 === "image/bmp");
      cachedWlPasteImageTypes = types;
      resolve(types);
    });
    child.on("error", () => {
      clearTimeout(timer);
      resolve([]);
    });
  });
}
__name(getWlPasteImageTypes, "getWlPasteImageTypes");
async function saveFileWithWlPaste(tempFilePath) {
  const imageTypes = await getWlPasteImageTypes();
  if (imageTypes.includes("image/png")) {
    const success = await saveFromCommand(
      "wl-paste",
      ["--no-newline", "--type", "image/png"],
      tempFilePath
    );
    if (success) return tempFilePath;
    try {
      await fs.unlink(tempFilePath);
    } catch {
    }
  }
  if (imageTypes.includes("image/bmp")) {
    const bmpPath = tempFilePath.replace(/\.png$/, ".bmp");
    const bmpSuccess = await saveFromCommand(
      "wl-paste",
      ["--no-newline", "--type", "image/bmp"],
      bmpPath
    );
    if (bmpSuccess) {
      try {
        await new Promise((resolve, reject) => {
          const child = spawn(
            "python3",
            [
              "-c",
              "import sys; from PIL import Image; Image.open(sys.argv[1]).save(sys.argv[2])",
              bmpPath,
              tempFilePath
            ],
            { stdio: ["ignore", "ignore", "pipe"] }
          );
          let stderr = "";
          child.stderr.on("data", (d) => {
            stderr += d.toString();
          });
          const timer = setTimeout(() => {
            try {
              child.kill();
            } catch {
            }
            reject(new Error("python3 timed out"));
          }, PROCESS_TIMEOUT_MS);
          child.on("close", (code) => {
            clearTimeout(timer);
            if (code === 0) resolve();
            else
              reject(
                new Error(
                  `python3 exited with code ${code}${stderr ? ": " + stderr.trim() : ""}`
                )
              );
          });
          child.on("error", (err) => {
            clearTimeout(timer);
            reject(err);
          });
        });
        try {
          await fs.unlink(bmpPath);
        } catch {
        }
        return tempFilePath;
      } catch (err) {
        debugLogger.warn(
          "BMP-to-PNG conversion failed (install python3-pil for BMP support):",
          err
        );
        try {
          await fs.unlink(bmpPath);
        } catch {
        }
        try {
          await fs.unlink(tempFilePath);
        } catch {
        }
        return false;
      }
    }
    try {
      await fs.unlink(bmpPath);
    } catch {
    }
  }
  return false;
}
__name(saveFileWithWlPaste, "saveFileWithWlPaste");
async function saveFileWithXclip(tempFilePath) {
  const success = await saveFromCommand(
    "xclip",
    ["-selection", "clipboard", "-t", "image/png", "-o"],
    tempFilePath
  );
  if (success) return true;
  try {
    await fs.unlink(tempFilePath);
  } catch {
  }
  return false;
}
__name(saveFileWithXclip, "saveFileWithXclip");
async function saveClipboardImage(targetDir) {
  try {
    const baseDir = targetDir || process.cwd();
    const tempDir = path.join(baseDir, "clipboard");
    await fs.mkdir(tempDir, { recursive: true });
    const timestamp = (/* @__PURE__ */ new Date()).getTime();
    if (process.platform === "linux") {
      const pngPath = path.join(
        tempDir,
        `clipboard-${timestamp}-${randomUUID()}.png`
      );
      const tool = getLinuxClipboardTool();
      if (tool === "wl-paste") {
        const savedPath = await saveFileWithWlPaste(pngPath);
        if (savedPath) {
          try {
            const stats = await fs.stat(savedPath);
            if (stats.size > 0) return savedPath;
            await fs.unlink(savedPath);
          } catch {
          }
        }
        return null;
      }
      if (tool === "xclip") {
        if (await saveFileWithXclip(pngPath)) return pngPath;
        return null;
      }
      return null;
    }
    const mod = await getClipboardModule();
    if (!mod) return null;
    const clipboard = new mod.ClipboardManager();
    if (!clipboard.hasFormat("image")) {
      return null;
    }
    const tempFilePath = path.join(
      tempDir,
      `clipboard-${timestamp}-${randomUUID()}.png`
    );
    const imageData = clipboard.getImageData();
    const buffer = imageData.data;
    if (!buffer) {
      return null;
    }
    await fs.writeFile(tempFilePath, buffer);
    return tempFilePath;
  } catch (error) {
    debugLogger.error("Error saving clipboard image:", error);
    return null;
  }
}
__name(saveClipboardImage, "saveClipboardImage");
async function cleanupOldClipboardImages(targetDir) {
  try {
    const baseDir = targetDir || process.cwd();
    const tempDir = path.join(baseDir, "clipboard");
    const files = await fs.readdir(tempDir);
    const MAX_IMAGES = 100;
    const CLEANUP_COUNT = 50;
    const imageFiles = [];
    for (const file of files) {
      if (file.startsWith("clipboard-") && (file.endsWith(".png") || file.endsWith(".jpg") || file.endsWith(".webp") || file.endsWith(".heic") || file.endsWith(".heif") || file.endsWith(".tiff") || file.endsWith(".gif") || file.endsWith(".bmp"))) {
        const filePath = path.join(tempDir, file);
        const stats = await fs.stat(filePath);
        imageFiles.push({
          name: file,
          path: filePath,
          atime: stats.atimeMs
        });
      }
    }
    if (imageFiles.length > MAX_IMAGES) {
      imageFiles.sort((a, b) => a.atime - b.atime);
      const removeCount = Math.min(
        CLEANUP_COUNT,
        imageFiles.length - MAX_IMAGES + CLEANUP_COUNT
      );
      const filesToRemove = imageFiles.slice(0, removeCount);
      for (const file of filesToRemove) {
        await fs.unlink(file.path);
      }
    }
  } catch {
  }
}
__name(cleanupOldClipboardImages, "cleanupOldClipboardImages");

// packages/cli/src/ui/hooks/useFocus.ts
init_esbuild_shims();
var import_react2 = __toESM(require_react(), 1);

// packages/cli/src/ui/hooks/useKeypress.ts
init_esbuild_shims();
var import_react = __toESM(require_react(), 1);
function useKeypress(onKeypress, { isActive }) {
  const { subscribe, unsubscribe } = useKeypressContext();
  const onKeypressRef = (0, import_react.useRef)(onKeypress);
  onKeypressRef.current = onKeypress;
  const handleKeypress = (0, import_react.useCallback)((key) => {
    onKeypressRef.current(key);
  }, []);
  (0, import_react.useEffect)(() => {
    if (!isActive) {
      return;
    }
    subscribe(handleKeypress);
    return () => {
      unsubscribe(handleKeypress);
    };
  }, [isActive, handleKeypress, subscribe, unsubscribe]);
}
__name(useKeypress, "useKeypress");

// packages/cli/src/ui/hooks/useFocus.ts
var ENABLE_FOCUS_REPORTING = "\x1B[?1004h";
var DISABLE_FOCUS_REPORTING = "\x1B[?1004l";
var FOCUS_IN = "\x1B[I";
var FOCUS_OUT = "\x1B[O";
var useFocus = /* @__PURE__ */ __name(() => {
  const { stdin } = use_stdin_default();
  const { stdout } = use_stdout_default();
  const [isFocused, setIsFocused] = (0, import_react2.useState)(true);
  (0, import_react2.useEffect)(() => {
    const handleData = /* @__PURE__ */ __name((data) => {
      const sequence = data.toString();
      const lastFocusIn = sequence.lastIndexOf(FOCUS_IN);
      const lastFocusOut = sequence.lastIndexOf(FOCUS_OUT);
      if (lastFocusIn > lastFocusOut) {
        setIsFocused(true);
      } else if (lastFocusOut > lastFocusIn) {
        setIsFocused(false);
      }
    }, "handleData");
    stdout?.write(ENABLE_FOCUS_REPORTING);
    stdin?.on("data", handleData);
    return () => {
      stdout?.write(DISABLE_FOCUS_REPORTING);
      stdin?.removeListener("data", handleData);
    };
  }, [stdin, stdout]);
  useKeypress(
    (_) => {
      if (!isFocused) {
        setIsFocused(true);
      }
    },
    { isActive: true }
  );
  return isFocused;
}, "useFocus");

// packages/cli/src/ui/contexts/KeypressContext.tsx
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
var ESC3 = "\x1B";
var OPTION_T_COMPOSED_GLYPH = "\u2020";
var PASTE_MODE_PREFIX = `${ESC3}[200~`;
var PASTE_MODE_SUFFIX = `${ESC3}[201~`;
var KITTY_SEQUENCE_TIMEOUT_MS = 200;
var PASTE_IDLE_TIMEOUT_MS = 1e3;
var KITTY_KEYPAD_PRINTABLE_KEYCODE_TO_CHAR = {
  57399: "0",
  57400: "1",
  57401: "2",
  57402: "3",
  57403: "4",
  57404: "5",
  57405: "6",
  57406: "7",
  57407: "8",
  57408: "9",
  57409: ".",
  57410: "/",
  57411: "*",
  57412: "-",
  57413: "+",
  // 57414 is keypad Enter - handled separately via CSI~ sequence
  57415: "=",
  57416: ","
};
var KITTY_KEYPAD_FUNCTIONAL_KEYCODE_TO_NAME = {
  57417: "left",
  57418: "right",
  57419: "up",
  57420: "down",
  57421: "pageup",
  57422: "pagedown",
  57423: "home",
  57424: "end",
  57425: "insert",
  57426: "delete"
};
var KeypressContext = (0, import_react3.createContext)(
  void 0
);
var debugLogger2 = createDebugLogger("KEYPRESS");
function useKeypressContext() {
  const context = (0, import_react3.useContext)(KeypressContext);
  if (!context) {
    throw new Error(
      "useKeypressContext must be used within a KeypressProvider"
    );
  }
  return context;
}
__name(useKeypressContext, "useKeypressContext");
function KeypressProvider({
  children,
  kittyProtocolEnabled,
  pasteWorkaround = false,
  config,
  debugKeystrokeLogging,
  initialCapturedInput
}) {
  const { stdin, setRawMode } = use_stdin_default();
  const subscribers = (0, import_react3.useRef)(/* @__PURE__ */ new Set()).current;
  const mouseSubscribers = (0, import_react3.useRef)(/* @__PURE__ */ new Set()).current;
  const subscribe = (0, import_react3.useCallback)(
    (handler) => {
      subscribers.add(handler);
    },
    [subscribers]
  );
  const unsubscribe = (0, import_react3.useCallback)(
    (handler) => {
      subscribers.delete(handler);
    },
    [subscribers]
  );
  const subscribeMouse = (0, import_react3.useCallback)(
    (handler) => {
      mouseSubscribers.add(handler);
    },
    [mouseSubscribers]
  );
  const unsubscribeMouse = (0, import_react3.useCallback)(
    (handler) => {
      mouseSubscribers.delete(handler);
    },
    [mouseSubscribers]
  );
  (0, import_react3.useEffect)(() => {
    setRawMode(true);
    const capturedInput = initialCapturedInput ?? Buffer.alloc(0);
    const keypressStream = new PassThrough();
    let usePassthrough = false;
    if (pasteWorkaround) {
      usePassthrough = true;
    }
    let isPaste = false;
    let pasteBuffer = Buffer.alloc(0);
    let pasteAlreadyFlushed = false;
    let pasteIdleTimeout = null;
    const kittySequenceBufferRef = { current: "" };
    let kittySequenceTimeout = null;
    let backslashTimeout = null;
    let waitingForEnterAfterBackslash = false;
    let rawDataBuffer = Buffer.alloc(0);
    let rawFlushTimeout = null;
    let swallowingSgrMouse = false;
    let sgrMouseBuffer = "";
    let sgrMouseTimeout = null;
    const resetSgrMouse = /* @__PURE__ */ __name(() => {
      swallowingSgrMouse = false;
      sgrMouseBuffer = "";
      if (sgrMouseTimeout) {
        clearTimeout(sgrMouseTimeout);
        sgrMouseTimeout = null;
      }
    }, "resetSgrMouse");
    const updateKittyBuffer = /* @__PURE__ */ __name((value) => {
      kittySequenceBufferRef.current = value;
    }, "updateKittyBuffer");
    const clearKittyTimeout = /* @__PURE__ */ __name(() => {
      if (kittySequenceTimeout) {
        clearTimeout(kittySequenceTimeout);
        kittySequenceTimeout = null;
      }
    }, "clearKittyTimeout");
    const startKittyTimeout = /* @__PURE__ */ __name(() => {
      clearKittyTimeout();
      kittySequenceTimeout = setTimeout(() => {
        if (kittySequenceBufferRef.current) {
          while (kittySequenceBufferRef.current) {
            const parsed = parseKittyPrefix(kittySequenceBufferRef.current);
            if (parsed) {
              kittySequenceBufferRef.current = kittySequenceBufferRef.current.slice(parsed.length);
              broadcast(parsed.key);
              continue;
            }
            const plain = parsePlainTextPrefix(kittySequenceBufferRef.current);
            if (plain) {
              kittySequenceBufferRef.current = kittySequenceBufferRef.current.slice(plain.length);
              broadcast(plain.key);
              continue;
            }
            break;
          }
          if (kittySequenceBufferRef.current) {
            if (debugKeystrokeLogging) {
              debugLogger2.debug(
                "[DEBUG] Kitty buffer timeout, clearing:",
                kittySequenceBufferRef.current
              );
            }
            kittySequenceBufferRef.current = "";
          }
        }
      }, KITTY_SEQUENCE_TIMEOUT_MS);
    }, "startKittyTimeout");
    const clearKittyBufferAndTimeout = /* @__PURE__ */ __name(() => {
      clearKittyTimeout();
      kittySequenceBufferRef.current = "";
    }, "clearKittyBufferAndTimeout");
    const clearPasteIdleTimeout = /* @__PURE__ */ __name(() => {
      if (pasteIdleTimeout) {
        clearTimeout(pasteIdleTimeout);
        pasteIdleTimeout = null;
      }
    }, "clearPasteIdleTimeout");
    const forceFlushStuckPaste = /* @__PURE__ */ __name(() => {
      clearPasteIdleTimeout();
      if (!isPaste && pasteBuffer.length === 0) return;
      const buffered = pasteBuffer.toString();
      isPaste = false;
      pasteBuffer = Buffer.alloc(0);
      pasteAlreadyFlushed = true;
      if (buffered.length > 0) {
        broadcast({
          name: "",
          ctrl: false,
          meta: false,
          shift: false,
          paste: true,
          sequence: buffered
        });
      }
    }, "forceFlushStuckPaste");
    const startPasteIdleTimeout = /* @__PURE__ */ __name(() => {
      clearPasteIdleTimeout();
      pasteIdleTimeout = setTimeout(
        forceFlushStuckPaste,
        PASTE_IDLE_TIMEOUT_MS
      );
    }, "startPasteIdleTimeout");
    const createPrintableKey = /* @__PURE__ */ __name((char) => {
      const printableName = char === " " ? "space" : /^[A-Za-z]$/.test(char) ? char.toLowerCase() : char;
      return {
        name: printableName,
        ctrl: false,
        meta: false,
        shift: false,
        paste: false,
        sequence: char,
        kittyProtocol: true
      };
    }, "createPrintableKey");
    const parseKittyPrefix = /* @__PURE__ */ __name((buffer) => {
      const revTabLegacy = new RegExp(`^${ESC3}\\[Z`);
      let m = buffer.match(revTabLegacy);
      if (m) {
        return {
          key: {
            name: "tab",
            ctrl: false,
            meta: false,
            shift: true,
            paste: false,
            sequence: buffer.slice(0, m[0].length),
            kittyProtocol: true
          },
          length: m[0].length
        };
      }
      const revTabParam = new RegExp(`^${ESC3}\\[1;(\\d+)Z`);
      m = buffer.match(revTabParam);
      if (m) {
        let mods = parseInt(m[1], 10);
        if (mods >= KITTY_MODIFIER_EVENT_TYPES_OFFSET) {
          mods -= KITTY_MODIFIER_EVENT_TYPES_OFFSET;
        }
        const bits = mods - KITTY_MODIFIER_BASE;
        const alt = (bits & MODIFIER_ALT_BIT) === MODIFIER_ALT_BIT;
        const ctrl = (bits & MODIFIER_CTRL_BIT) === MODIFIER_CTRL_BIT;
        return {
          key: {
            name: "tab",
            ctrl,
            meta: alt,
            // Reverse tab implies Shift behavior; force shift regardless of mods
            shift: true,
            paste: false,
            sequence: buffer.slice(0, m[0].length),
            kittyProtocol: true
          },
          length: m[0].length
        };
      }
      const arrowPrefix = new RegExp(`^${ESC3}\\[1;(\\d+)([ABCDHFPQSR])`);
      m = buffer.match(arrowPrefix);
      if (m) {
        let mods = parseInt(m[1], 10);
        if (mods >= KITTY_MODIFIER_EVENT_TYPES_OFFSET) {
          mods -= KITTY_MODIFIER_EVENT_TYPES_OFFSET;
        }
        const bits = mods - KITTY_MODIFIER_BASE;
        const shift = (bits & MODIFIER_SHIFT_BIT) === MODIFIER_SHIFT_BIT;
        const alt = (bits & MODIFIER_ALT_BIT) === MODIFIER_ALT_BIT;
        const ctrl = (bits & MODIFIER_CTRL_BIT) === MODIFIER_CTRL_BIT;
        const sym = m[2];
        const symbolToName = {
          A: "up",
          B: "down",
          C: "right",
          D: "left",
          H: "home",
          F: "end",
          P: "f1",
          Q: "f2",
          R: "f3",
          S: "f4"
        };
        const name = symbolToName[sym] || "";
        if (!name) return null;
        return {
          key: {
            name,
            ctrl,
            meta: alt,
            shift,
            paste: false,
            sequence: buffer.slice(0, m[0].length),
            kittyProtocol: true
          },
          length: m[0].length
        };
      }
      const csiUPrefix = new RegExp(
        `^${ESC3}\\[(\\d+)(?::\\d+)*(?:;(\\d+)(?::\\d+)*)?(?:;\\d+)?([u~])`
      );
      m = buffer.match(csiUPrefix);
      if (m) {
        const keyCode = parseInt(m[1], 10);
        let modifiers = m[2] ? parseInt(m[2], 10) : KITTY_MODIFIER_BASE;
        if (modifiers >= KITTY_MODIFIER_EVENT_TYPES_OFFSET) {
          modifiers -= KITTY_MODIFIER_EVENT_TYPES_OFFSET;
        }
        const modifierBits = modifiers - KITTY_MODIFIER_BASE;
        const shift = (modifierBits & MODIFIER_SHIFT_BIT) === MODIFIER_SHIFT_BIT;
        const alt = (modifierBits & MODIFIER_ALT_BIT) === MODIFIER_ALT_BIT;
        const ctrl = (modifierBits & MODIFIER_CTRL_BIT) === MODIFIER_CTRL_BIT;
        const terminator = m[3];
        if (terminator === "~") {
          let name2 = null;
          switch (keyCode) {
            case 1:
              name2 = "home";
              break;
            case 2:
              name2 = "insert";
              break;
            case 3:
              name2 = "delete";
              break;
            case 4:
              name2 = "end";
              break;
            case 5:
              name2 = "pageup";
              break;
            case 6:
              name2 = "pagedown";
              break;
            default:
              break;
          }
          if (name2) {
            return {
              key: {
                name: name2,
                ctrl,
                meta: alt,
                shift,
                paste: false,
                sequence: buffer.slice(0, m[0].length),
                kittyProtocol: true
              },
              length: m[0].length
            };
          }
        }
        const kittyKeyCodeToName = {
          [CHAR_CODE_ESC]: "escape",
          [KITTY_KEYCODE_TAB]: "tab",
          [KITTY_KEYCODE_BACKSPACE]: "backspace",
          [KITTY_KEYCODE_ENTER]: "return",
          [KITTY_KEYCODE_NUMPAD_ENTER]: "return"
        };
        const name = kittyKeyCodeToName[keyCode];
        if (name) {
          return {
            key: {
              name,
              ctrl,
              meta: alt,
              shift,
              paste: false,
              sequence: buffer.slice(0, m[0].length),
              kittyProtocol: true
            },
            length: m[0].length
          };
        }
        if (!ctrl) {
          const keypadChar = KITTY_KEYPAD_PRINTABLE_KEYCODE_TO_CHAR[keyCode];
          if (keypadChar) {
            return {
              key: {
                name: keypadChar,
                ctrl: false,
                meta: alt,
                shift,
                paste: false,
                sequence: keypadChar,
                kittyProtocol: true
              },
              length: m[0].length
            };
          }
        }
        const keypadName = KITTY_KEYPAD_FUNCTIONAL_KEYCODE_TO_NAME[keyCode];
        if (keypadName) {
          return {
            key: {
              name: keypadName,
              ctrl,
              meta: alt,
              shift,
              paste: false,
              sequence: buffer.slice(0, m[0].length),
              kittyProtocol: true
            },
            length: m[0].length
          };
        }
        if (terminator === "u" && !ctrl && keyCode >= 32 && keyCode !== 127 && keyCode <= 1114111 && !(keyCode >= 57344 && keyCode <= 63743)) {
          return {
            key: {
              ...createPrintableKey(String.fromCodePoint(keyCode)),
              meta: alt,
              shift
            },
            length: m[0].length
          };
        }
        if (ctrl && keyCode >= "a".charCodeAt(0) && keyCode <= "z".charCodeAt(0)) {
          const letter = String.fromCharCode(keyCode);
          return {
            key: {
              name: letter,
              ctrl: true,
              meta: alt,
              shift,
              paste: false,
              sequence: buffer.slice(0, m[0].length),
              kittyProtocol: true
            },
            length: m[0].length
          };
        }
      }
      const legacyFuncKey = new RegExp(`^${ESC3}\\[([ABCDHF])`);
      m = buffer.match(legacyFuncKey);
      if (m) {
        const sym = m[1];
        const nameMap = {
          A: "up",
          B: "down",
          C: "right",
          D: "left",
          H: "home",
          F: "end"
        };
        const name = nameMap[sym];
        return {
          key: {
            name,
            ctrl: false,
            meta: false,
            shift: false,
            paste: false,
            sequence: buffer.slice(0, m[0].length),
            kittyProtocol: true
          },
          length: m[0].length
        };
      }
      return null;
    }, "parseKittyPrefix");
    const getCompleteCsiSequenceLength = /* @__PURE__ */ __name((buffer) => {
      if (!buffer.startsWith(`${ESC3}[`)) {
        return null;
      }
      for (let i = 2; i < buffer.length; i++) {
        const code = buffer.charCodeAt(i);
        if (code >= 64 && code <= 126) {
          return i + 1;
        }
        if (code < 32 || code > 63) {
          return 0;
        }
      }
      return null;
    }, "getCompleteCsiSequenceLength");
    const parsePlainTextPrefix = /* @__PURE__ */ __name((buffer) => {
      if (!buffer || buffer.startsWith(ESC3)) {
        return null;
      }
      const [char] = Array.from(buffer);
      if (!char) {
        return null;
      }
      return {
        key: createPrintableKey(char),
        length: char.length
      };
    }, "parsePlainTextPrefix");
    const broadcast = /* @__PURE__ */ __name((key) => {
      noteInteraction();
      for (const handler of subscribers) {
        handler(key);
      }
    }, "broadcast");
    const TERMINAL_RESPONSE_RE = /^\x1b\[[?>][\d;]*[uc]$/;
    const handleKeypress = /* @__PURE__ */ __name(async (_, key) => {
      if (TERMINAL_RESPONSE_RE.test(key.sequence)) {
        return;
      }
      if (key.sequence === FOCUS_IN || key.sequence === FOCUS_OUT) {
        return;
      }
      if (isPaste) {
        resetSgrMouse();
      } else if (swallowingSgrMouse) {
        if (key.ctrl && key.name === "c") {
          resetSgrMouse();
        } else if (key.name === "paste-start") {
          resetSgrMouse();
        } else {
          sgrMouseBuffer += key.sequence;
          if (key.name === "m" || key.sequence === "M") {
            swallowingSgrMouse = false;
            if (sgrMouseTimeout) {
              clearTimeout(sgrMouseTimeout);
              sgrMouseTimeout = null;
            }
            const parsed = parseSGRMouseEvent(sgrMouseBuffer);
            if (parsed) {
              for (const handler of mouseSubscribers) {
                handler(parsed.event);
              }
            }
            sgrMouseBuffer = "";
          } else if (sgrMouseBuffer.length >= MAX_SGR_MOUSE_SEQUENCE_LENGTH) {
            resetSgrMouse();
          }
          return;
        }
      }
      if (!isPaste && key.sequence === `${ESC3}[<`) {
        swallowingSgrMouse = true;
        sgrMouseBuffer = `${ESC3}[<`;
        if (sgrMouseTimeout) {
          clearTimeout(sgrMouseTimeout);
        }
        sgrMouseTimeout = setTimeout(() => {
          swallowingSgrMouse = false;
          sgrMouseBuffer = "";
          sgrMouseTimeout = null;
        }, KITTY_SEQUENCE_TIMEOUT_MS);
        return;
      }
      const isCtrlCKey = key.ctrl && key.name === "c" || key.sequence === `${ESC3}${KITTY_CTRL_C}`;
      if (isCtrlCKey) {
        if (isPaste || pasteBuffer.length > 0) {
          isPaste = false;
          pasteBuffer = Buffer.alloc(0);
          pasteAlreadyFlushed = true;
          clearPasteIdleTimeout();
        }
        if (kittySequenceBufferRef.current && debugKeystrokeLogging) {
          debugLogger2.debug(
            "[DEBUG] Kitty buffer cleared on Ctrl+C:",
            kittySequenceBufferRef.current
          );
        }
        clearKittyBufferAndTimeout();
        if (key.sequence === `${ESC3}${KITTY_CTRL_C}`) {
          broadcast({
            name: "c",
            ctrl: true,
            meta: false,
            shift: false,
            paste: false,
            sequence: key.sequence,
            kittyProtocol: true
          });
        } else {
          broadcast(key);
        }
        return;
      }
      if (key.name === "paste-start") {
        isPaste = true;
        pasteAlreadyFlushed = false;
        startPasteIdleTimeout();
        return;
      }
      if (key.name === "paste-end") {
        clearPasteIdleTimeout();
        if (pasteAlreadyFlushed) {
          pasteAlreadyFlushed = false;
          isPaste = false;
          pasteBuffer = Buffer.alloc(0);
          return;
        }
        isPaste = false;
        if (pasteBuffer.toString().length > 0) {
          broadcast({
            name: "",
            ctrl: false,
            meta: false,
            shift: false,
            paste: true,
            sequence: pasteBuffer.toString()
          });
        } else {
          let clipboardImageUnavailable = false;
          const hasImage = await clipboardHasImage(() => {
            clipboardImageUnavailable = true;
          });
          broadcast({
            name: "",
            ctrl: false,
            meta: false,
            shift: false,
            paste: true,
            pasteImage: hasImage,
            clipboardImageUnavailable,
            sequence: pasteBuffer.toString()
          });
        }
        pasteBuffer = Buffer.alloc(0);
        return;
      }
      if (isPaste) {
        pasteBuffer = Buffer.concat([pasteBuffer, Buffer.from(key.sequence)]);
        startPasteIdleTimeout();
        return;
      }
      if (key.name === "return" && waitingForEnterAfterBackslash) {
        if (backslashTimeout) {
          clearTimeout(backslashTimeout);
          backslashTimeout = null;
        }
        waitingForEnterAfterBackslash = false;
        broadcast({
          ...key,
          shift: true,
          sequence: "\r"
          // Corrected escaping for newline
        });
        return;
      }
      if (key.sequence === "\\" && !key.name) {
        waitingForEnterAfterBackslash = true;
        backslashTimeout = setTimeout(() => {
          waitingForEnterAfterBackslash = false;
          backslashTimeout = null;
          broadcast(key);
        }, BACKSLASH_ENTER_DETECTION_WINDOW_MS);
        return;
      }
      if (waitingForEnterAfterBackslash && key.name !== "return") {
        if (backslashTimeout) {
          clearTimeout(backslashTimeout);
          backslashTimeout = null;
        }
        waitingForEnterAfterBackslash = false;
        broadcast({
          name: "",
          sequence: "\\",
          ctrl: false,
          meta: false,
          shift: false,
          paste: false
        });
      }
      if (["up", "down", "left", "right"].includes(key.name)) {
        broadcast(key);
        return;
      }
      if (kittyProtocolEnabled) {
        if (kittySequenceBufferRef.current || key.sequence.startsWith(`${ESC3}[`) && !key.sequence.startsWith(PASTE_MODE_PREFIX) && !key.sequence.startsWith(PASTE_MODE_SUFFIX) && !key.sequence.startsWith(FOCUS_IN) && !key.sequence.startsWith(FOCUS_OUT)) {
          updateKittyBuffer(kittySequenceBufferRef.current + key.sequence);
          startKittyTimeout();
          if (debugKeystrokeLogging) {
            debugLogger2.debug(
              "[DEBUG] Kitty buffer accumulating:",
              kittySequenceBufferRef.current
            );
          }
          let bufferedInputHandled = false;
          while (kittySequenceBufferRef.current) {
            const parsed = parseKittyPrefix(kittySequenceBufferRef.current);
            if (parsed) {
              if (debugKeystrokeLogging) {
                const parsedSequence = kittySequenceBufferRef.current.slice(
                  0,
                  parsed.length
                );
                if (kittySequenceBufferRef.current.length > parsed.length) {
                  debugLogger2.debug(
                    "[DEBUG] Kitty sequence parsed successfully (prefix):",
                    parsedSequence
                  );
                } else {
                  debugLogger2.debug(
                    "[DEBUG] Kitty sequence parsed successfully:",
                    parsedSequence
                  );
                }
              }
              updateKittyBuffer(
                kittySequenceBufferRef.current.slice(parsed.length)
              );
              if (!kittySequenceBufferRef.current) {
                clearKittyTimeout();
              }
              broadcast(parsed.key);
              bufferedInputHandled = true;
              continue;
            }
            const completeUnsupportedCsiLength = getCompleteCsiSequenceLength(
              kittySequenceBufferRef.current
            );
            if (completeUnsupportedCsiLength) {
              if (debugKeystrokeLogging) {
                debugLogger2.debug(
                  "[DEBUG] Dropping unsupported complete CSI sequence:",
                  kittySequenceBufferRef.current.slice(
                    0,
                    completeUnsupportedCsiLength
                  )
                );
              }
              updateKittyBuffer(
                kittySequenceBufferRef.current.slice(
                  completeUnsupportedCsiLength
                )
              );
              if (!kittySequenceBufferRef.current) {
                clearKittyTimeout();
              }
              bufferedInputHandled = true;
              continue;
            }
            const plainTextPrefix = parsePlainTextPrefix(
              kittySequenceBufferRef.current
            );
            if (plainTextPrefix) {
              if (debugKeystrokeLogging) {
                debugLogger2.debug(
                  "[DEBUG] Recovered plain text after kitty sequence:",
                  plainTextPrefix.key.sequence
                );
              }
              updateKittyBuffer(
                kittySequenceBufferRef.current.slice(plainTextPrefix.length)
              );
              if (!kittySequenceBufferRef.current) {
                clearKittyTimeout();
              }
              broadcast(plainTextPrefix.key);
              bufferedInputHandled = true;
              continue;
            }
            const nextStart = kittySequenceBufferRef.current.indexOf(
              `${ESC3}[`,
              1
            );
            if (nextStart > 0) {
              if (debugKeystrokeLogging) {
                debugLogger2.debug(
                  "[DEBUG] Skipping incomplete/invalid CSI prefix:",
                  kittySequenceBufferRef.current.slice(0, nextStart)
                );
              }
              updateKittyBuffer(
                kittySequenceBufferRef.current.slice(nextStart)
              );
              if (!kittySequenceBufferRef.current) {
                clearKittyTimeout();
              }
              bufferedInputHandled = true;
              continue;
            }
            break;
          }
          if (bufferedInputHandled) return;
          if (config?.getDebugMode() || debugKeystrokeLogging) {
            const codes = Array.from(kittySequenceBufferRef.current).map(
              (ch) => ch.charCodeAt(0)
            );
            debugLogger2.warn("Kitty sequence buffer has char codes:", codes);
          }
          if (kittySequenceBufferRef.current.length > MAX_KITTY_SEQUENCE_LENGTH) {
            if (debugKeystrokeLogging) {
              debugLogger2.debug(
                "[DEBUG] Kitty buffer overflow, clearing:",
                kittySequenceBufferRef.current
              );
            }
            if (config) {
              const event = new KittySequenceOverflowEvent(
                kittySequenceBufferRef.current.length,
                kittySequenceBufferRef.current
              );
              logKittySequenceOverflow(config, event);
            }
            clearKittyBufferAndTimeout();
          } else {
            return;
          }
        }
      }
      if (key.name === "return" && key.sequence === `${ESC3}\r`) {
        key.meta = true;
      }
      if (process.platform === "darwin" && !isPaste && key.sequence === OPTION_T_COMPOSED_GLYPH) {
        key.name = "t";
        key.meta = true;
      }
      broadcast({ ...key, paste: isPaste });
    }, "handleKeypress");
    const clearRawFlushTimeout = /* @__PURE__ */ __name(() => {
      if (rawFlushTimeout) {
        clearTimeout(rawFlushTimeout);
        rawFlushTimeout = null;
      }
    }, "clearRawFlushTimeout");
    const createPasteKeyEvent = /* @__PURE__ */ __name((name = "", sequence = "") => ({
      name,
      ctrl: false,
      meta: false,
      shift: false,
      paste: false,
      sequence
    }), "createPasteKeyEvent");
    const shouldFlushRawDataAsPaste = /* @__PURE__ */ __name((data) => {
      const hasReturn = data.includes(13);
      const hasEmbeddedTab = data.length > 1 && data.includes(9);
      const isSingleReturn = data.length <= 2 && hasReturn;
      return !isSingleReturn && (hasReturn || hasEmbeddedTab);
    }, "shouldFlushRawDataAsPaste");
    const flushRawBuffer = /* @__PURE__ */ __name(() => {
      if (!rawDataBuffer.length) {
        return;
      }
      const pasteModePrefixBuffer = Buffer.from(PASTE_MODE_PREFIX);
      const pasteModeSuffixBuffer = Buffer.from(PASTE_MODE_SUFFIX);
      const data = rawDataBuffer;
      let cursor = 0;
      while (cursor < data.length) {
        const prefixPos = data.indexOf(pasteModePrefixBuffer, cursor);
        const suffixPos = data.indexOf(pasteModeSuffixBuffer, cursor);
        const hasPrefix = prefixPos !== -1 && prefixPos + pasteModePrefixBuffer.length <= data.length;
        const hasSuffix = suffixPos !== -1 && suffixPos + pasteModeSuffixBuffer.length <= data.length;
        let markerPos = -1;
        let markerLength = 0;
        let markerType = null;
        if (hasPrefix && (!hasSuffix || prefixPos < suffixPos)) {
          markerPos = prefixPos;
          markerLength = pasteModePrefixBuffer.length;
          markerType = "prefix";
        } else if (hasSuffix) {
          markerPos = suffixPos;
          markerLength = pasteModeSuffixBuffer.length;
          markerType = "suffix";
        }
        if (markerPos === -1) {
          break;
        }
        const nextData = data.slice(cursor, markerPos);
        if (nextData.length > 0) {
          keypressStream.write(nextData);
        }
        if (markerType === "prefix") {
          handleKeypress(void 0, createPasteKeyEvent("paste-start"));
        } else if (markerType === "suffix") {
          handleKeypress(void 0, createPasteKeyEvent("paste-end"));
        }
        cursor = markerPos + markerLength;
      }
      rawDataBuffer = data.slice(cursor);
      if (rawDataBuffer.length === 0) {
        return;
      }
      if (isPaste || !shouldFlushRawDataAsPaste(rawDataBuffer)) {
        keypressStream.write(rawDataBuffer);
      } else {
        handleKeypress(void 0, createPasteKeyEvent("paste-start"));
        keypressStream.write(rawDataBuffer);
        handleKeypress(void 0, createPasteKeyEvent("paste-end"));
      }
      rawDataBuffer = Buffer.alloc(0);
      clearRawFlushTimeout();
    }, "flushRawBuffer");
    const handleRawKeypress = /* @__PURE__ */ __name((_data) => {
      const data = Buffer.isBuffer(_data) ? _data : Buffer.from(_data, "utf8");
      rawDataBuffer = Buffer.concat([rawDataBuffer, data]);
      clearRawFlushTimeout();
      const isReturnChar = rawDataBuffer.length <= 2 && rawDataBuffer.includes(13);
      if (isReturnChar) {
        rawFlushTimeout = setTimeout(flushRawBuffer, 100);
      } else {
        flushRawBuffer();
      }
    }, "handleRawKeypress");
    let rl;
    if (usePassthrough) {
      rl = readline.createInterface({
        input: keypressStream,
        escapeCodeTimeout: 0
      });
      readline.emitKeypressEvents(keypressStream, rl);
      keypressStream.on("keypress", handleKeypress);
      stdin.on("data", handleRawKeypress);
    } else {
      rl = readline.createInterface({ input: stdin, escapeCodeTimeout: 0 });
      readline.emitKeypressEvents(stdin, rl);
      stdin.on("keypress", handleKeypress);
    }
    let replayPending = false;
    if (capturedInput.length > 0) {
      debugLogger2.debug(
        `Replaying ${capturedInput.length} bytes of captured input`
      );
      replayPending = true;
      setImmediate(() => {
        if (!replayPending) return;
        try {
          stdin.emit("data", capturedInput);
        } catch (err) {
          debugLogger2.error("Failed to replay captured input:", err);
        }
      });
    }
    return () => {
      replayPending = false;
      if (usePassthrough) {
        keypressStream.removeListener("keypress", handleKeypress);
        stdin.removeListener("data", handleRawKeypress);
      } else {
        stdin.removeListener("keypress", handleKeypress);
      }
      rl.close();
      setRawMode(false);
      if (backslashTimeout) {
        clearTimeout(backslashTimeout);
        backslashTimeout = null;
      }
      clearKittyBufferAndTimeout();
      clearPasteIdleTimeout();
      resetSgrMouse();
      if (rawFlushTimeout) {
        clearTimeout(rawFlushTimeout);
        rawFlushTimeout = null;
      }
      if (isPaste) {
        broadcast({
          name: "",
          ctrl: false,
          meta: false,
          shift: false,
          paste: true,
          sequence: pasteBuffer.toString()
        });
        pasteBuffer = Buffer.alloc(0);
      }
    };
  }, [
    stdin,
    setRawMode,
    kittyProtocolEnabled,
    debugKeystrokeLogging,
    pasteWorkaround,
    config,
    subscribers,
    mouseSubscribers,
    initialCapturedInput
  ]);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    KeypressContext.Provider,
    {
      value: {
        subscribe,
        unsubscribe,
        subscribeMouse,
        unsubscribeMouse,
        pasteWorkaround
      },
      children
    }
  );
}
__name(KeypressProvider, "KeypressProvider");

// packages/cli/src/ui/utils/computeStats.ts
init_esbuild_shims();
function calculateErrorRate(metrics) {
  if (metrics.api.totalRequests === 0) {
    return 0;
  }
  return metrics.api.totalErrors / metrics.api.totalRequests * 100;
}
__name(calculateErrorRate, "calculateErrorRate");
function calculateAverageLatency(metrics) {
  if (metrics.api.totalRequests === 0) {
    return 0;
  }
  return metrics.api.totalLatencyMs / metrics.api.totalRequests;
}
__name(calculateAverageLatency, "calculateAverageLatency");
function calculateCacheHitRate(metrics) {
  if (metrics.tokens.prompt === 0) {
    return 0;
  }
  return metrics.tokens.cached / metrics.tokens.prompt * 100;
}
__name(calculateCacheHitRate, "calculateCacheHitRate");
var computeSessionStats = /* @__PURE__ */ __name((metrics) => {
  const { models, tools, files } = metrics;
  const totalApiTime = Object.values(models).reduce(
    (acc, model) => acc + model.api.totalLatencyMs,
    0
  );
  const totalToolTime = tools.totalDurationMs;
  const agentActiveTime = totalApiTime + totalToolTime;
  const apiTimePercent = agentActiveTime > 0 ? totalApiTime / agentActiveTime * 100 : 0;
  const toolTimePercent = agentActiveTime > 0 ? totalToolTime / agentActiveTime * 100 : 0;
  const totalCachedTokens = Object.values(models).reduce(
    (acc, model) => acc + model.tokens.cached,
    0
  );
  const totalPromptTokens = Object.values(models).reduce(
    (acc, model) => acc + model.tokens.prompt,
    0
  );
  const cacheEfficiency = totalPromptTokens > 0 ? totalCachedTokens / totalPromptTokens * 100 : 0;
  const totalDecisions = tools.totalDecisions.accept + tools.totalDecisions.reject + tools.totalDecisions.modify;
  const successRate = tools.totalCalls > 0 ? tools.totalSuccess / tools.totalCalls * 100 : 0;
  const agreementRate = totalDecisions > 0 ? tools.totalDecisions.accept / totalDecisions * 100 : 0;
  return {
    totalApiTime,
    totalToolTime,
    agentActiveTime,
    apiTimePercent,
    toolTimePercent,
    cacheEfficiency,
    totalDecisions,
    successRate,
    agreementRate,
    totalCachedTokens,
    totalPromptTokens,
    totalLinesAdded: files.totalLinesAdded,
    totalLinesRemoved: files.totalLinesRemoved
  };
}, "computeSessionStats");

// packages/cli/src/services/commandUtils.ts
init_esbuild_shims();
function getEffectiveSupportedModes(cmd) {
  if (cmd.supportedModes !== void 0) {
    return cmd.supportedModes;
  }
  switch (cmd.kind) {
    case "built-in" /* BUILT_IN */:
      return ["interactive"];
    case "file" /* FILE */:
    case "skill" /* SKILL */:
    case "mcp-prompt" /* MCP_PROMPT */:
      return ["interactive", "non_interactive", "acp"];
    default:
      return ["interactive"];
  }
}
__name(getEffectiveSupportedModes, "getEffectiveSupportedModes");
function filterCommandsForMode(commands, mode) {
  return commands.filter(
    (cmd) => getEffectiveSupportedModes(cmd).includes(mode)
  );
}
__name(filterCommandsForMode, "filterCommandsForMode");

// packages/cli/src/ui/utils/resumeHistoryUtils.ts
init_esbuild_shims();
import * as path2 from "node:path";

// packages/cli/src/ui/components/messages/CompactToolGroupDisplay.tsx
init_esbuild_shims();

// packages/cli/src/ui/constants.ts
init_esbuild_shims();
var EstimatedArtWidth = 59;
var BoxBorderWidth = 1;
var BOX_PADDING_X = 1;
var UI_WIDTH = EstimatedArtWidth + BOX_PADDING_X * 2 + BoxBorderWidth * 2;
var SHELL_COMMAND_NAME = "Shell Command";
var SHELL_NAME = "Shell";
var TOOL_STATUS = {
  SUCCESS: "\u2713",
  PENDING: "o",
  EXECUTING: "\u22B7",
  CONFIRMING: "?",
  CANCELED: "-",
  ERROR: "x"
};

// packages/cli/src/ui/components/shared/ToolStatusIndicator.tsx
init_esbuild_shims();

// packages/cli/src/ui/components/GeminiRespondingSpinner.tsx
init_esbuild_shims();
var import_react6 = __toESM(require_react(), 1);

// node_modules/ink-spinner/build/index.js
init_esbuild_shims();
var import_react4 = __toESM(require_react(), 1);
var import_cli_spinners = __toESM(require_cli_spinners(), 1);
function Spinner({ type = "dots" }) {
  const [frame, setFrame] = (0, import_react4.useState)(0);
  const spinner = import_cli_spinners.default[type];
  (0, import_react4.useEffect)(() => {
    const timer = setInterval(() => {
      setFrame((previousFrame) => {
        const isLastFrame = previousFrame === spinner.frames.length - 1;
        return isLastFrame ? 0 : previousFrame + 1;
      });
    }, spinner.interval);
    return () => {
      clearInterval(timer);
    };
  }, [spinner]);
  return import_react4.default.createElement(Text, null, spinner.frames[frame]);
}
__name(Spinner, "Spinner");
var build_default = Spinner;

// packages/cli/src/ui/contexts/StreamingContext.tsx
init_esbuild_shims();
var import_react5 = __toESM(require_react(), 1);
var StreamingContext = (0, import_react5.createContext)(
  void 0
);
var useStreamingContext = /* @__PURE__ */ __name(() => {
  const context = import_react5.default.useContext(StreamingContext);
  if (context === void 0) {
    throw new Error(
      "useStreamingContext must be used within a StreamingContextProvider"
    );
  }
  return context;
}, "useStreamingContext");

// packages/cli/src/ui/textConstants.ts
init_esbuild_shims();
var SCREEN_READER_USER_PREFIX = "User: ";
var SCREEN_READER_MODEL_PREFIX = "Model: ";
var SCREEN_READER_LOADING = "loading";
var SCREEN_READER_RESPONDING = "responding";

// packages/cli/src/ui/components/GeminiRespondingSpinner.tsx
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
var TMUX_SPINNER_INTERVAL_MS = 750;
var TMUX_SPINNER_FRAMES = [".  ", ".. ", "..."];
var GeminiRespondingSpinner = /* @__PURE__ */ __name(({ nonRespondingDisplay, spinnerType = "dots" }) => {
  const streamingState = useStreamingContext();
  const isScreenReaderEnabled = use_is_screen_reader_enabled_default();
  if (streamingState === "responding" /* Responding */) {
    return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
      GeminiSpinner,
      {
        spinnerType,
        altText: SCREEN_READER_RESPONDING
      }
    );
  } else if (nonRespondingDisplay) {
    return isScreenReaderEnabled ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: SCREEN_READER_LOADING }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: theme.text.primary, children: nonRespondingDisplay });
  }
  return null;
}, "GeminiRespondingSpinner");
var GeminiSpinner = /* @__PURE__ */ __name(({
  spinnerType = "dots",
  altText
}) => {
  const isScreenReaderEnabled = use_is_screen_reader_enabled_default();
  const isTmux = Boolean(process.env["TMUX"]);
  const [tmuxFrameIndex, setTmuxFrameIndex] = (0, import_react6.useState)(0);
  (0, import_react6.useEffect)(() => {
    if (isScreenReaderEnabled || !isTmux) {
      return;
    }
    const interval = setInterval(() => {
      setTmuxFrameIndex((index) => (index + 1) % TMUX_SPINNER_FRAMES.length);
    }, TMUX_SPINNER_INTERVAL_MS);
    return () => clearInterval(interval);
  }, [isScreenReaderEnabled, isTmux]);
  if (isScreenReaderEnabled) {
    return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: altText });
  }
  if (isTmux) {
    return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: theme.text.primary, children: TMUX_SPINNER_FRAMES[tmuxFrameIndex] });
  }
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: theme.text.primary, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(build_default, { type: spinnerType }) });
}, "GeminiSpinner");

// packages/cli/src/ui/components/shared/ToolStatusIndicator.tsx
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
var STATUS_INDICATOR_WIDTH = 2;
var ToolStatusIndicator = /* @__PURE__ */ __name(({
  status,
  name
}) => {
  const isShell = name === SHELL_COMMAND_NAME || name === SHELL_NAME;
  const statusColor = isShell ? theme.ui.symbol : theme.status.warning;
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { minWidth: STATUS_INDICATOR_WIDTH, children: [
    status === "Pending" /* Pending */ && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: theme.status.success, children: TOOL_STATUS.PENDING }),
    status === "Executing" /* Executing */ && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
      GeminiRespondingSpinner,
      {
        spinnerType: "toggle",
        nonRespondingDisplay: TOOL_STATUS.EXECUTING
      }
    ),
    status === "Success" /* Success */ && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: theme.status.success, "aria-label": "Success:", children: TOOL_STATUS.SUCCESS }),
    status === "Confirming" /* Confirming */ && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: statusColor, "aria-label": "Confirming:", children: TOOL_STATUS.CONFIRMING }),
    status === "Canceled" /* Canceled */ && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: statusColor, "aria-label": "Canceled:", bold: true, children: TOOL_STATUS.CANCELED }),
    status === "Error" /* Error */ && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: theme.status.error, "aria-label": "Error:", bold: true, children: TOOL_STATUS.ERROR })
  ] });
}, "ToolStatusIndicator");

// packages/cli/src/ui/components/shared/ToolElapsedTime.tsx
init_esbuild_shims();
var import_react7 = __toESM(require_react(), 1);
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
var ToolElapsedTime = /* @__PURE__ */ __name(({
  status,
  executionStartTime,
  timeoutMs
}) => {
  const [elapsedSeconds, setElapsedSeconds] = (0, import_react7.useState)(0);
  (0, import_react7.useEffect)(() => {
    if (status !== "Executing" /* Executing */ || !executionStartTime) {
      setElapsedSeconds(0);
      return;
    }
    setElapsedSeconds(Math.floor((Date.now() - executionStartTime) / 1e3));
    const interval = setInterval(() => {
      setElapsedSeconds(Math.floor((Date.now() - executionStartTime) / 1e3));
    }, 1e3);
    return () => clearInterval(interval);
  }, [status, executionStartTime]);
  if (status !== "Executing" /* Executing */) return null;
  const hasTimeout = timeoutMs != null && timeoutMs > 0;
  if (!hasTimeout && elapsedSeconds < 3) return null;
  const elapsedStr = formatDuration(elapsedSeconds * 1e3, {
    hideTrailingZeros: true
  });
  const label = hasTimeout ? `(${elapsedStr} \xB7 timeout ${formatDuration(timeoutMs, { hideTrailingZeros: true })})` : elapsedStr;
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { flexShrink: 0, marginLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: theme.text.secondary, children: label }) });
}, "ToolElapsedTime");

// packages/cli/src/ui/components/messages/CompactToolGroupDisplay.tsx
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
function getOverallStatus(toolCalls) {
  if (toolCalls.some((t2) => t2.status === "Confirming" /* Confirming */))
    return "Confirming" /* Confirming */;
  if (toolCalls.some((t2) => t2.status === "Executing" /* Executing */))
    return "Executing" /* Executing */;
  if (toolCalls.some((t2) => t2.status === "Error" /* Error */))
    return "Error" /* Error */;
  if (toolCalls.some((t2) => t2.status === "Canceled" /* Canceled */))
    return "Canceled" /* Canceled */;
  if (toolCalls.some((t2) => t2.status === "Pending" /* Pending */))
    return "Pending" /* Pending */;
  return "Success" /* Success */;
}
__name(getOverallStatus, "getOverallStatus");
function getActiveTool(toolCalls) {
  return toolCalls.find((t2) => t2.status === "Confirming" /* Confirming */) ?? toolCalls.find((t2) => t2.status === "Executing" /* Executing */) ?? toolCalls[toolCalls.length - 1];
}
__name(getActiveTool, "getActiveTool");
function getShellTimeoutMs(tool) {
  const display = tool.resultDisplay;
  if (typeof display === "object" && display !== null && "ansiOutput" in display) {
    return display.timeoutMs;
  }
  return void 0;
}
__name(getShellTimeoutMs, "getShellTimeoutMs");
var TOOL_NAME_TO_CATEGORY = {
  [ToolDisplayNames.READ_FILE]: "read",
  [ToolDisplayNames.EDIT]: "edit",
  [ToolDisplayNames.WRITE_FILE]: "write",
  [ToolDisplayNames.NOTEBOOK_EDIT]: "edit",
  [ToolDisplayNames.GREP]: "search",
  [ToolDisplayNames.GLOB]: "search",
  [ToolDisplayNames.LS]: "list",
  [ToolDisplayNames.SHELL]: "command",
  [SHELL_COMMAND_NAME]: "command",
  [ToolDisplayNames.AGENT]: "agent",
  [ToolDisplayNames.WORKFLOW]: "agent",
  [ToolDisplayNames.SEND_MESSAGE]: "agent",
  "Read File": "read",
  "Read File(s)": "read",
  "Read Directory": "list",
  // Legacy display names (keys from ToolDisplayNamesMigration)
  SearchFiles: "search",
  FindFiles: "search",
  ReadFolder: "list",
  Task: "agent",
  TodoWrite: "other"
};
var CATEGORY_TEMPLATES = {
  read: {
    past: { one: "Read {{count}} file", many: "Read {{count}} files" },
    active: { one: "Reading {{count}} file", many: "Reading {{count}} files" },
    pastVerb: "Read",
    activeVerb: "Reading"
  },
  edit: {
    past: { one: "Edited {{count}} file", many: "Edited {{count}} files" },
    active: { one: "Editing {{count}} file", many: "Editing {{count}} files" },
    pastVerb: "Edited",
    activeVerb: "Editing"
  },
  write: {
    past: { one: "Wrote {{count}} file", many: "Wrote {{count}} files" },
    active: { one: "Writing {{count}} file", many: "Writing {{count}} files" },
    pastVerb: "Wrote",
    activeVerb: "Writing"
  },
  search: {
    past: {
      one: "Searched {{count}} pattern",
      many: "Searched {{count}} patterns"
    },
    active: {
      one: "Searching {{count}} pattern",
      many: "Searching {{count}} patterns"
    },
    pastVerb: "Searched",
    activeVerb: "Searching"
  },
  list: {
    past: {
      one: "Listed {{count}} directory",
      many: "Listed {{count}} directories"
    },
    active: {
      one: "Listing {{count}} directory",
      many: "Listing {{count}} directories"
    },
    pastVerb: "Listed",
    activeVerb: "Listing"
  },
  command: {
    past: { one: "Ran {{count}} command", many: "Ran {{count}} commands" },
    active: {
      one: "Running {{count}} command",
      many: "Running {{count}} commands"
    },
    pastVerb: "Ran",
    activeVerb: "Running"
  },
  agent: {
    past: { one: "Ran {{count}} agent", many: "Ran {{count}} agents" },
    active: {
      one: "Running {{count}} agent",
      many: "Running {{count}} agents"
    },
    pastVerb: "Ran",
    activeVerb: "Running"
  },
  other: {
    past: { one: "Used {{count}} tool", many: "Used {{count}} tools" },
    active: { one: "Using {{count}} tool", many: "Using {{count}} tools" },
    pastVerb: "Used",
    activeVerb: "Using"
  }
};
var CATEGORY_ORDER = [
  "search",
  "read",
  "list",
  "command",
  "edit",
  "write",
  "agent",
  "other"
];
var COLLAPSIBLE_CATEGORIES = /* @__PURE__ */ new Set([
  "read",
  "search",
  "list"
]);
function getToolCategory(toolName) {
  return TOOL_NAME_TO_CATEGORY[toolName] ?? "other";
}
__name(getToolCategory, "getToolCategory");
function isCollapsibleTool(toolName) {
  return COLLAPSIBLE_CATEGORIES.has(getToolCategory(toolName));
}
__name(isCollapsibleTool, "isCollapsibleTool");
function safeDescription(raw) {
  if (!raw) return void 0;
  const stripped = raw.replace(
    /\x1b\][^\x07]*\x07|\x1b[()][A-Z0-9]|\x1b\[[0-9;]*[a-zA-Z]|\x1b./g,
    ""
  );
  const cleaned = stripped.replace(/[\x00-\x1f\x7f]/g, " ").trim();
  if (cleaned.startsWith("{") || cleaned.startsWith("[")) return void 0;
  return cleaned || void 0;
}
__name(safeDescription, "safeDescription");
function buildToolSummary(toolCalls, isActive) {
  if (toolCalls.length === 0) return "";
  const toolsByCategory = /* @__PURE__ */ new Map();
  for (const tool of toolCalls) {
    const cat = getToolCategory(tool.name);
    const arr = toolsByCategory.get(cat) ?? [];
    arr.push(tool);
    toolsByCategory.set(cat, arr);
  }
  const parts = [];
  for (const cat of CATEGORY_ORDER) {
    const tools = toolsByCategory.get(cat);
    if (!tools || tools.length === 0) continue;
    const template = CATEGORY_TEMPLATES[cat];
    let part;
    if (tools.length === 1) {
      const safeDesc = safeDescription(tools[0].description);
      if (safeDesc !== void 0) {
        const verb = isActive ? template.activeVerb : template.pastVerb;
        part = `${verb} ${safeDesc}`;
      } else {
        part = t(isActive ? template.active.one : template.past.one, {
          count: "1"
        });
      }
    } else {
      const forms = isActive ? template.active : template.past;
      part = t(forms.many, { count: String(tools.length) });
    }
    if (parts.length > 0) {
      part = part.charAt(0).toLowerCase() + part.slice(1);
    }
    parts.push(part);
  }
  return parts.join(", ");
}
__name(buildToolSummary, "buildToolSummary");
var CompactToolGroupDisplay = /* @__PURE__ */ __name(({ toolCalls, contentWidth }) => {
  if (toolCalls.length === 0) return null;
  const overallStatus = getOverallStatus(toolCalls);
  const activeTool = getActiveTool(toolCalls);
  const isActive = overallStatus === "Executing" /* Executing */ || overallStatus === "Pending" /* Pending */ || overallStatus === "Confirming" /* Confirming */;
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { flexDirection: "column", width: contentWidth, paddingX: 1, gap: 0, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "row", children: [
    /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ToolStatusIndicator, { status: overallStatus, name: activeTool.name }),
    /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { flexGrow: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { wrap: "truncate-end", bold: true, children: [
      buildToolSummary(toolCalls, isActive),
      isActive && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { children: "\u2026" }, "ellipsis")
    ] }) }),
    /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
      ToolElapsedTime,
      {
        status: overallStatus,
        executionStartTime: activeTool.executionStartTime,
        timeoutMs: getShellTimeoutMs(activeTool)
      }
    )
  ] }) });
}, "CompactToolGroupDisplay");

// packages/cli/src/ui/utils/resumeHistoryUtils.ts
function extractTextFromParts(parts) {
  if (!parts) return "";
  const textParts = [];
  for (const part of parts) {
    if ("text" in part && part.text) {
      if (!("thought" in part && part.thought)) {
        textParts.push(part.text);
      }
    }
  }
  return textParts.join("\n");
}
__name(extractTextFromParts, "extractTextFromParts");
function extractThoughtTextFromParts(parts) {
  if (!parts) return "";
  const thoughtParts = [];
  for (const part of parts) {
    if ("text" in part && part.text && "thought" in part && part.thought) {
      thoughtParts.push(part.text);
    }
  }
  return thoughtParts.join("\n");
}
__name(extractThoughtTextFromParts, "extractThoughtTextFromParts");
function extractFunctionCalls(parts) {
  if (!parts) return [];
  const calls = [];
  for (const part of parts) {
    if ("functionCall" in part && part.functionCall) {
      const fc = part.functionCall;
      calls.push({
        id: fc.id || `call-${calls.length}`,
        name: fc.name || "unknown",
        args: fc.args || {}
      });
    }
  }
  return calls;
}
__name(extractFunctionCalls, "extractFunctionCalls");
function getTool(config, name) {
  if (!config) return void 0;
  const toolRegistry = config.getToolRegistry();
  return toolRegistry.getTool(name);
}
__name(getTool, "getTool");
function formatToolDescription(tool, args) {
  try {
    const invocation = tool.build(args);
    return invocation.getDescription();
  } catch {
    if (typeof args["description"] === "string") {
      return args["description"];
    }
    return "";
  }
}
__name(formatToolDescription, "formatToolDescription");
function restoreHistoryItem(raw) {
  if (!raw || typeof raw !== "object") {
    return;
  }
  const clone = { ...raw };
  if ("timestamp" in clone) {
    const ts = clone["timestamp"];
    if (typeof ts === "string" || typeof ts === "number") {
      clone["timestamp"] = new Date(ts);
    }
  }
  if (typeof clone["type"] !== "string") {
    return;
  }
  return clone;
}
__name(restoreHistoryItem, "restoreHistoryItem");
function createHistoryGapItem(gap) {
  return {
    type: "info" /* INFO */,
    text: formatHistoryGapNotice(gap)
  };
}
__name(createHistoryGapItem, "createHistoryGapItem");
function convertToHistoryItems(conversation, config, historyGaps) {
  const items = [];
  const gapByChildUuid = indexGapsByChild(historyGaps);
  const pendingAtCommands = [];
  let atCommandCounter = 0;
  const pendingToolCalls = /* @__PURE__ */ new Map();
  let currentToolGroup = [];
  const buildAtCommandDisplays = /* @__PURE__ */ __name((payload) => {
    if (payload.status === "error") {
      atCommandCounter += 1;
      const filesLabel = payload.filesRead?.length ? payload.filesRead.join(", ") : "files";
      return [
        {
          callId: `at-command-${atCommandCounter}`,
          name: "Read File(s)",
          description: "Error attempting to read files",
          status: "Error" /* Error */,
          resultDisplay: payload.message || `Error reading files (${filesLabel})`,
          confirmationDetails: void 0
        }
      ];
    }
    if (!payload.filesRead?.length) {
      atCommandCounter += 1;
      return [
        {
          callId: `at-command-${atCommandCounter}`,
          name: "Read File",
          description: "Read File(s)",
          status: "Success" /* Success */,
          resultDisplay: void 0,
          confirmationDetails: void 0
        }
      ];
    }
    return payload.filesRead.map((filePath) => {
      atCommandCounter += 1;
      const isDir = filePath.endsWith("/");
      return {
        callId: `at-command-${atCommandCounter}`,
        name: isDir ? "Read Directory" : "Read File",
        description: isDir ? `Read directory ${path2.basename(filePath)}` : `Read file ${path2.basename(filePath)}`,
        status: "Success" /* Success */,
        resultDisplay: void 0,
        confirmationDetails: void 0
      };
    });
  }, "buildAtCommandDisplays");
  for (const record of conversation.messages) {
    const gap = gapByChildUuid.get(record.uuid);
    if (gap) {
      if (currentToolGroup.length > 0) {
        items.push({ type: "tool_group", tools: [...currentToolGroup] });
        currentToolGroup = [];
      }
      pendingAtCommands.length = 0;
      items.push(createHistoryGapItem(gap));
    }
    if (record.type === "system") {
      if (record.subtype === "slash_command") {
        if (currentToolGroup.length > 0) {
          items.push({
            type: "tool_group",
            tools: [...currentToolGroup]
          });
          currentToolGroup = [];
        }
        const payload = record.systemPayload;
        if (!payload) continue;
        if (payload.phase === "invocation" && payload.rawCommand) {
          const sentToModel = typeof payload.sentToModel === "boolean" ? payload.sentToModel : void 0;
          items.push({
            type: "user",
            text: payload.rawCommand,
            ...sentToModel === void 0 ? {} : { sentToModel }
          });
        }
        if (payload.phase === "result") {
          const outputs = payload.outputHistoryItems ?? [];
          for (const raw of outputs) {
            const restored = restoreHistoryItem(raw);
            if (restored) {
              items.push(restored);
            }
          }
        }
      }
      if (record.subtype === "at_command") {
        const payload = record.systemPayload;
        if (!payload) continue;
        pendingAtCommands.push(payload);
      }
      if (record.subtype === "rewind") {
        items.push({ type: "info", text: "Conversation rewound." });
      }
      continue;
    }
    switch (record.type) {
      case "user": {
        if (record.subtype === "notification" || record.subtype === "cron") {
          const payload = record.systemPayload;
          const fallback = record.subtype === "cron" ? "Cron job fired" : "Background agent completed";
          const text2 = payload?.displayText || extractTextFromParts(record.message?.parts) || fallback;
          items.push({ type: "notification", text: text2 });
          break;
        }
        if (record.subtype === "mid_turn_user_message") {
          const payload = record.systemPayload;
          const text2 = payload?.displayText || extractTextFromParts(record.message?.parts);
          if (text2) {
            items.push({ type: "notification", text: text2 });
          }
          break;
        }
        if (pendingAtCommands.length > 0) {
          if (currentToolGroup.length > 0) {
            items.push({
              type: "tool_group",
              tools: [...currentToolGroup]
            });
            currentToolGroup = [];
          }
          const payload = pendingAtCommands.shift();
          const text2 = payload.userText || extractTextFromParts(record.message?.parts);
          if (text2) {
            items.push({ type: "user", text: text2 });
          }
          const toolDisplays = buildAtCommandDisplays(payload);
          if (toolDisplays.length > 0) {
            items.push({
              type: "tool_group",
              tools: toolDisplays
            });
          }
          break;
        }
        if (currentToolGroup.length > 0) {
          items.push({
            type: "tool_group",
            tools: [...currentToolGroup]
          });
          currentToolGroup = [];
        }
        const text = extractTextFromParts(record.message?.parts);
        if (text) {
          items.push({ type: "user", text });
        }
        break;
      }
      case "assistant": {
        const parts = record.message?.parts;
        const thoughtText = !config ? extractThoughtTextFromParts(parts) : "";
        const text = extractTextFromParts(parts);
        const functionCalls = extractFunctionCalls(parts);
        if (thoughtText) {
          if (currentToolGroup.length > 0) {
            items.push({
              type: "tool_group",
              tools: [...currentToolGroup]
            });
            currentToolGroup = [];
          }
          items.push({ type: "gemini_thought", text: thoughtText });
        }
        if (text) {
          if (currentToolGroup.length > 0) {
            items.push({
              type: "tool_group",
              tools: [...currentToolGroup]
            });
            currentToolGroup = [];
          }
          items.push({
            type: "gemini",
            text,
            timestamp: new Date(record.timestamp).getTime()
          });
        }
        for (const fc of functionCalls) {
          const tool = getTool(config, fc.name);
          pendingToolCalls.set(fc.id, { name: fc.name, args: fc.args });
          currentToolGroup.push({
            callId: fc.id,
            name: tool?.displayName || fc.name,
            description: tool ? formatToolDescription(tool, fc.args) : "",
            resultDisplay: void 0,
            status: "Success" /* Success */,
            // Will be updated by tool_result
            confirmationDetails: void 0
          });
        }
        break;
      }
      case "tool_result": {
        if (record.toolCallResult) {
          const callId = record.toolCallResult.callId;
          const toolCall = currentToolGroup.find((t2) => t2.callId === callId);
          if (toolCall) {
            const rawDisplay = record.toolCallResult.resultDisplay;
            toolCall.resultDisplay = rawDisplay;
            const rawStatus = record.toolCallResult["status"];
            toolCall.status = rawStatus === "error" ? "Error" /* Error */ : "Success" /* Success */;
            if (toolCall.status === "Success" /* Success */ && isCollapsibleTool(toolCall.name)) {
              toolCall.detailedDisplay = getToolResponseDisplayText(
                record.toolCallResult.responseParts ?? record.message?.parts
              );
            }
          }
          pendingToolCalls.delete(callId || "");
        }
        break;
      }
      default:
        break;
    }
  }
  if (pendingAtCommands.length > 0) {
    for (const payload of pendingAtCommands) {
      if (currentToolGroup.length > 0) {
        items.push({
          type: "tool_group",
          tools: [...currentToolGroup]
        });
        currentToolGroup = [];
      }
      const text = payload.userText;
      if (text) {
        items.push({ type: "user", text });
      }
      const toolDisplays = buildAtCommandDisplays(payload);
      if (toolDisplays.length > 0) {
        items.push({
          type: "tool_group",
          tools: toolDisplays
        });
      }
    }
  }
  if (currentToolGroup.length > 0) {
    items.push({
      type: "tool_group",
      tools: currentToolGroup
    });
  }
  return items;
}
__name(convertToHistoryItems, "convertToHistoryItems");
function buildResumedHistoryItems(sessionData, config, baseTimestamp = Date.now()) {
  const items = [];
  let idCounter = 1;
  const getNextId = /* @__PURE__ */ __name(() => baseTimestamp + idCounter++, "getNextId");
  const historyItems = convertToHistoryItems(
    sessionData.conversation,
    config,
    sessionData.historyGaps
  );
  for (const item of historyItems) {
    items.push({
      ...item,
      id: getNextId()
    });
  }
  return items;
}
__name(buildResumedHistoryItems, "buildResumedHistoryItems");
function applyResumeDisplayPolicy(items) {
  return items.map((item) => ({
    ...item,
    display: { ...item.display, suppressOnRestore: true }
  }));
}
__name(applyResumeDisplayPolicy, "applyResumeDisplayPolicy");
function createHistoryCollapseSummaryItem(messageCount) {
  const n = String(messageCount);
  return {
    type: "info" /* INFO */,
    text: t(
      "History collapsed: {{n}} messages hidden. Use /history expand-now to show.",
      { n }
    ),
    display: { kind: "collapse-summary" }
  };
}
__name(createHistoryCollapseSummaryItem, "createHistoryCollapseSummaryItem");
function stripSuppressOnRestore(item) {
  if (!item.display?.suppressOnRestore) return item;
  const { suppressOnRestore: _, ...rest } = item.display;
  return {
    ...item,
    display: Object.keys(rest).length > 0 ? rest : void 0
  };
}
__name(stripSuppressOnRestore, "stripSuppressOnRestore");
function expandCollapsedHistory(items) {
  return items.filter((item) => item.display?.kind !== "collapse-summary").map(stripSuppressOnRestore);
}
__name(expandCollapsedHistory, "expandCollapsedHistory");
function applyCollapsePolicyAndSummary(rawItems, collapseOnResume, collapsePreviewCount = 0) {
  if (!collapseOnResume) return rawItems;
  if (collapsePreviewCount === -1) return rawItems;
  let boundary = rawItems.length;
  if (collapsePreviewCount > 0) {
    let userTurnCount = 0;
    for (let i = rawItems.length - 1; i >= 0; i--) {
      if (rawItems[i].type === "user" /* USER */) {
        userTurnCount++;
        if (userTurnCount === collapsePreviewCount) {
          boundary = i;
          break;
        }
      }
    }
    if (userTurnCount < collapsePreviewCount) {
      boundary = 0;
    }
  }
  const hiddenItems = applyResumeDisplayPolicy(rawItems.slice(0, boundary));
  const visibleItems = rawItems.slice(boundary);
  const uiHistoryItems = [...hiddenItems, ...visibleItems];
  if (boundary > 0) {
    const nextId = rawItems[rawItems.length - 1].id + 1;
    return [
      ...uiHistoryItems,
      { id: nextId, ...createHistoryCollapseSummaryItem(boundary) }
    ];
  }
  return uiHistoryItems;
}
__name(applyCollapsePolicyAndSummary, "applyCollapsePolicyAndSummary");

// packages/cli/src/ui/commands/diffCommand.ts
init_esbuild_shims();
async function diffAction(context) {
  const { config } = context.services;
  if (!config) {
    return {
      type: "message",
      messageType: "error",
      content: t("Configuration not available.")
    };
  }
  if (context.executionMode === "interactive") {
    return { type: "dialog", dialog: "diff" };
  }
  const cwd = config.getWorkingDir() || config.getProjectRoot();
  if (!cwd) {
    return {
      type: "message",
      messageType: "error",
      content: t("Could not determine current working directory.")
    };
  }
  let result;
  try {
    result = await fetchGitDiff(cwd);
  } catch (error) {
    return {
      type: "message",
      messageType: "error",
      content: `${t("Failed to compute git diff stats")}: ${error instanceof Error ? error.message : String(error)}`
    };
  }
  if (!result) {
    return {
      type: "message",
      messageType: "info",
      content: t(
        "No diff available. Either this is not a git repository, HEAD is missing, or a merge/rebase/cherry-pick/revert is in progress."
      )
    };
  }
  if (result.stats.filesCount === 0) {
    return {
      type: "message",
      messageType: "info",
      content: t("Clean working tree \u2014 no changes against HEAD.")
    };
  }
  const model = buildDiffRenderModel(result);
  return {
    type: "message",
    messageType: "info",
    content: renderDiffModelText(model)
  };
}
__name(diffAction, "diffAction");
function buildDiffRenderModel(result) {
  const rows = [];
  for (const [filename, s] of result.perFileStats) {
    rows.push(toRow(filename, s));
  }
  const hiddenCount = Math.max(0, result.stats.filesCount - rows.length);
  return {
    filesCount: result.stats.filesCount,
    linesAdded: result.stats.linesAdded,
    linesRemoved: result.stats.linesRemoved,
    rows,
    hiddenCount
  };
}
__name(buildDiffRenderModel, "buildDiffRenderModel");
function toRow(filename, s) {
  if (s.isBinary) {
    return {
      filename,
      isBinary: true,
      isUntracked: Boolean(s.isUntracked),
      isDeleted: Boolean(s.isDeleted),
      truncated: false
    };
  }
  return {
    filename,
    added: s.added,
    removed: s.isUntracked ? 0 : s.removed,
    isBinary: false,
    isUntracked: Boolean(s.isUntracked),
    isDeleted: Boolean(s.isDeleted),
    truncated: Boolean(s.truncated)
  };
}
__name(toRow, "toRow");
function computeDiffColumnWidths(rows) {
  let maxAdded = 0;
  let maxRemoved = 0;
  for (const r of rows) {
    if (r.isBinary) continue;
    if ((r.added ?? 0) > maxAdded) maxAdded = r.added ?? 0;
    if ((r.removed ?? 0) > maxRemoved) maxRemoved = r.removed ?? 0;
  }
  const addWidth = String(maxAdded).length;
  const remWidth = String(maxRemoved).length;
  const statColumnWidth = 1 + addWidth + 1 + 1 + remWidth;
  return { addWidth, remWidth, statColumnWidth };
}
__name(computeDiffColumnWidths, "computeDiffColumnWidths");
function renderDiffModelText(model) {
  const { filesCount, linesAdded, linesRemoved, rows, hiddenCount } = model;
  const header = filesCount === 1 ? t("{{count}} file changed, +{{added}} / -{{removed}}", {
    count: String(filesCount),
    added: String(linesAdded),
    removed: String(linesRemoved)
  }) : t("{{count}} files changed, +{{added}} / -{{removed}}", {
    count: String(filesCount),
    added: String(linesAdded),
    removed: String(linesRemoved)
  });
  const lines = formatRowsText(rows);
  const capNote = hiddenCount > 0 && rows.length > 0 ? `
  ${t("\u2026and {{hidden}} more (showing first {{shown}})", {
    hidden: String(hiddenCount),
    shown: String(rows.length)
  })}` : "";
  return lines.length > 0 ? `${header}
${lines.join("\n")}${capNote}` : header;
}
__name(renderDiffModelText, "renderDiffModelText");
function formatRowsText(rows) {
  if (rows.length === 0) return [];
  const { addWidth, remWidth, statColumnWidth } = computeDiffColumnWidths(rows);
  const out = [];
  for (const r of rows) {
    const safeName = sanitizeFilenameForDisplay(r.filename);
    if (r.isBinary) {
      const suffix2 = r.isUntracked ? ` ${t("(binary, new)")}` : r.isDeleted ? ` ${t("(binary, deleted)")}` : ` ${t("(binary)")}`;
      out.push(`  ${padMarker("~", statColumnWidth)}  ${safeName}${suffix2}`);
      continue;
    }
    const added = `+${String(r.added ?? 0).padStart(addWidth)}`;
    const removed = `-${String(r.removed ?? 0).padStart(remWidth)}`;
    let suffix = "";
    if (r.isUntracked) {
      suffix = r.truncated ? ` ${t("(new, partial)")}` : ` ${t("(new)")}`;
    } else if (r.isDeleted) {
      suffix = ` ${t("(deleted)")}`;
    }
    out.push(`  ${added} ${removed}  ${safeName}${suffix}`);
  }
  return out;
}
__name(formatRowsText, "formatRowsText");
function padMarker(marker, width) {
  if (marker.length >= width) return marker;
  return `${marker}${" ".repeat(width - marker.length)}`;
}
__name(padMarker, "padMarker");
var diffCommand = {
  name: "diff",
  get description() {
    return t("Show working-tree change stats versus HEAD");
  },
  kind: "built-in" /* BUILT_IN */,
  supportedModes: ["interactive", "non_interactive", "acp"],
  action: diffAction
};

// packages/cli/src/utils/systemInfoFields.ts
init_esbuild_shims();
function getSystemInfoFields(info) {
  const fields = [];
  addField(fields, t("Qwen Code"), formatCliVersion(info));
  addField(fields, t("Runtime"), formatRuntime(info));
  addField(fields, t("IDE Client"), info.ideClient);
  addField(fields, "LSP", info.lspStatus ?? "");
  addField(fields, t("OS"), formatOs(info));
  addField(fields, t("Auth"), formatAuth(info));
  addField(fields, t("Base URL"), formatBaseUrl(info));
  addField(fields, t("Model"), info.modelVersion);
  addField(fields, t("Fast Model"), info.fastModel || info.modelVersion);
  addField(fields, t("Session ID"), info.sessionId);
  addField(fields, t("Sandbox"), info.sandboxEnv);
  addField(fields, t("Proxy"), formatProxy(info.proxy));
  addField(fields, t("Memory Usage"), info.memoryUsage);
  return fields;
}
__name(getSystemInfoFields, "getSystemInfoFields");
function addField(fields, label, value) {
  if (value) {
    fields.push({ label, value });
  }
}
__name(addField, "addField");
function formatCliVersion(info) {
  if (!info.cliVersion) {
    return "";
  }
  if (!info.gitCommit) {
    return info.cliVersion;
  }
  return `${info.cliVersion} (${info.gitCommit})`;
}
__name(formatCliVersion, "formatCliVersion");
function formatRuntime(info) {
  if (!info.nodeVersion && !info.npmVersion) {
    return "";
  }
  const node = info.nodeVersion ? `Node.js ${info.nodeVersion}` : "";
  const npm = info.npmVersion ? `npm ${info.npmVersion}` : "";
  return joinParts([node, npm], " / ");
}
__name(formatRuntime, "formatRuntime");
function formatOs(info) {
  return joinParts(
    [info.osPlatform, info.osArch, formatOsRelease(info.osRelease)],
    " "
  ).trim();
}
__name(formatOs, "formatOs");
function formatOsRelease(release) {
  if (!release) {
    return "";
  }
  return `(${release})`;
}
__name(formatOsRelease, "formatOsRelease");
function formatAuth(info) {
  if (!info.selectedAuthType) {
    return "";
  }
  const managedProvider = findProviderByCredentials(
    info.baseUrl,
    info.apiKeyEnvKey
  );
  if (managedProvider && resolveMetadataKey(managedProvider)) {
    return t(managedProvider.label);
  }
  if (info.selectedAuthType.startsWith("oauth") || info.selectedAuthType === "qwen-oauth") {
    return "Qwen OAuth";
  }
  return `API Key - ${info.selectedAuthType}`;
}
__name(formatAuth, "formatAuth");
function formatBaseUrl(info) {
  if (!info.selectedAuthType || !info.baseUrl) {
    return "";
  }
  if (info.selectedAuthType.startsWith("oauth") || info.selectedAuthType === "qwen-oauth") {
    return "";
  }
  return info.baseUrl;
}
__name(formatBaseUrl, "formatBaseUrl");
function formatProxy(proxy) {
  if (!proxy) {
    return "no proxy";
  }
  return redactProxy(proxy);
}
__name(formatProxy, "formatProxy");
function redactProxy(proxy) {
  try {
    const url = new URL(proxy);
    if (url.username || url.password) {
      url.username = url.username ? "***" : "";
      url.password = url.password ? "***" : "";
    }
    return url.toString();
  } catch {
    return proxy.replace(/\/\/[^/]*@/, "//***@");
  }
}
__name(redactProxy, "redactProxy");
function joinParts(parts, separator) {
  return parts.filter((part) => part).join(separator);
}
__name(joinParts, "joinParts");

// packages/cli/src/utils/costCalculator.ts
init_esbuild_shims();
function calculateCost(args) {
  const { inputTokens, outputTokens, pricing } = args;
  if (!pricing) return null;
  const inputCost = pricing.inputPerMillionTokens != null ? inputTokens / 1e6 * pricing.inputPerMillionTokens : 0;
  const outputCost = pricing.outputPerMillionTokens != null ? outputTokens / 1e6 * pricing.outputPerMillionTokens : 0;
  const total = inputCost + outputCost;
  return total > 0 ? total : null;
}
__name(calculateCost, "calculateCost");

// packages/cli/src/ui/utils/skill-level-label.ts
init_esbuild_shims();
function levelLabel(level) {
  switch (level) {
    case "project":
      return t("Project");
    case "user":
      return t("User");
    case "extension":
      return t("Extension");
    case "bundled":
      return t("Bundled");
    default: {
      const _exhaustive = level;
      return _exhaustive;
    }
  }
}
__name(levelLabel, "levelLabel");

export {
  enableMouseEvents,
  disableMouseEvents,
  VSCODE_SHIFT_ENTER_SEQUENCE,
  BEL,
  OSC_PREFIX,
  detectTerminal,
  wrapForMultiplexer,
  oscITerm2Notify,
  oscKittyNotify,
  oscGhosttyNotify,
  generateKittyId,
  writeOsc52,
  clipboardHasImage,
  saveClipboardImage,
  cleanupOldClipboardImages,
  useKeypress,
  useFocus,
  useKeypressContext,
  KeypressProvider,
  SCREEN_READER_USER_PREFIX,
  SCREEN_READER_MODEL_PREFIX,
  SHELL_COMMAND_NAME,
  SHELL_NAME,
  build_default,
  StreamingContext,
  useStreamingContext,
  GeminiRespondingSpinner,
  GeminiSpinner,
  STATUS_INDICATOR_WIDTH,
  ToolStatusIndicator,
  ToolElapsedTime,
  isCollapsibleTool,
  CompactToolGroupDisplay,
  getSystemInfoFields,
  calculateErrorRate,
  calculateAverageLatency,
  calculateCacheHitRate,
  computeSessionStats,
  calculateCost,
  getEffectiveSupportedModes,
  filterCommandsForMode,
  levelLabel,
  computeDiffColumnWidths,
  diffCommand,
  buildResumedHistoryItems,
  expandCollapsedHistory,
  applyCollapsePolicyAndSummary
};
/**
 * @license
 * Copyright 2025 Qwen
 * SPDX-License-Identifier: Apache-2.0
 *
 * Adapted from gemini-cli (Google LLC, Apache-2.0):
 * packages/cli/src/ui/utils/mouse.ts + utils/input.ts. Trimmed to the
 * subset the virtual-viewport scroll path needs (SGR + X11 parsing,
 * incomplete-sequence detection, enable/disable helpers).
 */
/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
/**
 * @license
 * Copyright 2026 Qwen Team
 * SPDX-License-Identifier: Apache-2.0
 */
/**
 * @license
 * Copyright 2025 Qwen
 * SPDX-License-Identifier: Apache-2.0
 */
/**
 * @license
 * Copyright 2025 Qwen Code
 * SPDX-License-Identifier: Apache-2.0
 */
